1 /* Copyright (c) 2010, 2011 Nicira, Inc.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
22 #include "openvswitch/types.h"
27 struct flow_wildcards;
29 #define CFM_RANDOM_VLAN UINT16_MAX
31 #define CFM_FAULT_REASONS \
32 CFM_FAULT_REASON(RECV, recv) \
33 CFM_FAULT_REASON(RDI, rdi) \
34 CFM_FAULT_REASON(MAID, maid) \
35 CFM_FAULT_REASON(LOOPBACK, loopback) \
36 CFM_FAULT_REASON(OVERFLOW, overflow) \
37 CFM_FAULT_REASON(OVERRIDE, override) \
38 CFM_FAULT_REASON(INTERVAL, interval)
40 enum cfm_fault_bit_index {
41 #define CFM_FAULT_REASON(NAME, STR) CFM_FAULT_INDEX_##NAME,
43 #undef CFM_FAULT_REASON
47 enum cfm_fault_reason {
48 #define CFM_FAULT_REASON(NAME, STR) \
49 CFM_FAULT_##NAME = 1 << CFM_FAULT_INDEX_##NAME,
51 #undef CFM_FAULT_REASON
55 uint64_t mpid; /* The MPID of this CFM. */
56 int interval; /* The requested transmission interval. */
57 bool extended; /* Run in extended mode. */
58 bool demand; /* Run in demand mode. */
59 bool opup; /* Operational State. */
60 uint16_t ccm_vlan; /* CCM Vlan tag. Zero if none.
61 CFM_RANDOM_VLAN if random. */
62 uint8_t ccm_pcp; /* CCM Priority. Zero if none. */
64 bool check_tnl_key; /* Verify inbound packet key? */
68 struct cfm *cfm_create(const struct netdev *);
69 struct cfm *cfm_ref(const struct cfm *);
70 void cfm_unref(struct cfm *);
71 void cfm_run(struct cfm *);
72 bool cfm_should_send_ccm(struct cfm *);
73 void cfm_compose_ccm(struct cfm *, struct ofpbuf *packet, uint8_t eth_src[6]);
74 void cfm_wait(struct cfm *);
75 bool cfm_configure(struct cfm *, const struct cfm_settings *);
76 void cfm_set_netdev(struct cfm *, const struct netdev *);
77 bool cfm_should_process_flow(const struct cfm *cfm, const struct flow *,
78 struct flow_wildcards *);
79 void cfm_process_heartbeat(struct cfm *, const struct ofpbuf *packet);
80 int cfm_get_fault(const struct cfm *);
81 int cfm_get_health(const struct cfm *);
82 int cfm_get_opup(const struct cfm *);
83 void cfm_get_remote_mpids(const struct cfm *, const uint64_t **rmps,
85 const char *cfm_fault_reason_to_str(int fault);