2012-05-02 15:21:36 -07:00
|
|
|
/* Copyright (c) 2010, 2011 Nicira, Inc.
|
2010-11-15 16:20:01 -08:00
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef CFM_H
|
|
|
|
|
#define CFM_H 1
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
#include "hmap.h"
|
2011-03-25 13:57:21 -07:00
|
|
|
#include "openvswitch/types.h"
|
2010-11-15 16:20:01 -08:00
|
|
|
|
|
|
|
|
struct flow;
|
2011-03-25 13:57:21 -07:00
|
|
|
struct ofpbuf;
|
2013-05-15 14:31:06 -07:00
|
|
|
struct netdev;
|
2013-06-17 18:07:33 -07:00
|
|
|
struct flow_wildcards;
|
2010-11-15 16:20:01 -08:00
|
|
|
|
2012-03-09 18:16:20 -08:00
|
|
|
#define CFM_RANDOM_VLAN UINT16_MAX
|
|
|
|
|
|
2012-02-07 14:35:09 -08:00
|
|
|
#define CFM_FAULT_REASONS \
|
|
|
|
|
CFM_FAULT_REASON(RECV, recv) \
|
|
|
|
|
CFM_FAULT_REASON(RDI, rdi) \
|
|
|
|
|
CFM_FAULT_REASON(MAID, maid) \
|
|
|
|
|
CFM_FAULT_REASON(LOOPBACK, loopback) \
|
|
|
|
|
CFM_FAULT_REASON(OVERFLOW, overflow) \
|
2013-09-20 15:32:08 -07:00
|
|
|
CFM_FAULT_REASON(OVERRIDE, override)
|
2012-02-07 14:35:09 -08:00
|
|
|
|
|
|
|
|
enum cfm_fault_bit_index {
|
|
|
|
|
#define CFM_FAULT_REASON(NAME, STR) CFM_FAULT_INDEX_##NAME,
|
|
|
|
|
CFM_FAULT_REASONS
|
|
|
|
|
#undef CFM_FAULT_REASON
|
|
|
|
|
CFM_FAULT_N_REASONS
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum cfm_fault_reason {
|
|
|
|
|
#define CFM_FAULT_REASON(NAME, STR) \
|
|
|
|
|
CFM_FAULT_##NAME = 1 << CFM_FAULT_INDEX_##NAME,
|
|
|
|
|
CFM_FAULT_REASONS
|
|
|
|
|
#undef CFM_FAULT_REASON
|
|
|
|
|
};
|
|
|
|
|
|
2011-05-13 15:37:23 -07:00
|
|
|
struct cfm_settings {
|
2011-09-01 13:28:25 -07:00
|
|
|
uint64_t mpid; /* The MPID of this CFM. */
|
2010-11-15 16:20:01 -08:00
|
|
|
int interval; /* The requested transmission interval. */
|
2011-08-30 17:37:06 -07:00
|
|
|
bool extended; /* Run in extended mode. */
|
2013-05-15 14:31:06 -07:00
|
|
|
bool demand; /* Run in demand mode. */
|
2011-10-06 22:43:05 -07:00
|
|
|
bool opup; /* Operational State. */
|
2012-03-09 18:16:20 -08:00
|
|
|
uint16_t ccm_vlan; /* CCM Vlan tag. Zero if none.
|
|
|
|
|
CFM_RANDOM_VLAN if random. */
|
2012-02-02 15:48:13 -08:00
|
|
|
uint8_t ccm_pcp; /* CCM Priority. Zero if none. */
|
2012-10-12 13:19:35 -07:00
|
|
|
|
|
|
|
|
bool check_tnl_key; /* Verify inbound packet key? */
|
2010-11-15 16:20:01 -08:00
|
|
|
};
|
|
|
|
|
|
2011-05-13 16:53:24 -07:00
|
|
|
void cfm_init(void);
|
2013-05-15 14:31:06 -07:00
|
|
|
struct cfm *cfm_create(const struct netdev *);
|
2013-06-18 16:31:43 -07:00
|
|
|
struct cfm *cfm_ref(const struct cfm *);
|
|
|
|
|
void cfm_unref(struct cfm *);
|
2011-03-22 16:57:43 -07:00
|
|
|
void cfm_run(struct cfm *);
|
|
|
|
|
bool cfm_should_send_ccm(struct cfm *);
|
2011-05-13 18:11:43 -07:00
|
|
|
void cfm_compose_ccm(struct cfm *, struct ofpbuf *packet, uint8_t eth_src[6]);
|
2010-11-15 16:20:01 -08:00
|
|
|
void cfm_wait(struct cfm *);
|
2011-05-13 15:37:23 -07:00
|
|
|
bool cfm_configure(struct cfm *, const struct cfm_settings *);
|
2013-06-03 13:49:13 -07:00
|
|
|
void cfm_set_netdev(struct cfm *, const struct netdev *);
|
2013-06-17 18:07:33 -07:00
|
|
|
bool cfm_should_process_flow(const struct cfm *cfm, const struct flow *,
|
|
|
|
|
struct flow_wildcards *);
|
2010-11-15 16:20:01 -08:00
|
|
|
void cfm_process_heartbeat(struct cfm *, const struct ofpbuf *packet);
|
2014-04-03 10:20:44 -07:00
|
|
|
bool cfm_check_status_change(struct cfm *);
|
2012-02-07 14:35:09 -08:00
|
|
|
int cfm_get_fault(const struct cfm *);
|
2013-10-22 05:16:23 +00:00
|
|
|
uint64_t cfm_get_flap_count(const struct cfm *);
|
2012-04-05 14:30:23 -07:00
|
|
|
int cfm_get_health(const struct cfm *);
|
2012-08-10 16:36:18 -07:00
|
|
|
int cfm_get_opup(const struct cfm *);
|
2013-07-23 13:09:38 -07:00
|
|
|
void cfm_get_remote_mpids(const struct cfm *, uint64_t **rmps, size_t *n_rmps);
|
2012-02-07 14:35:09 -08:00
|
|
|
const char *cfm_fault_reason_to_str(int fault);
|
2011-05-13 15:37:23 -07:00
|
|
|
|
2013-10-16 03:32:33 +00:00
|
|
|
long long int cfm_wake_time(struct cfm*);
|
2010-11-15 16:20:01 -08:00
|
|
|
#endif /* cfm.h */
|