]> git.proxmox.com Git - mirror_ovs.git/blob - lib/cfm.h
cfm: Scope CFM packets to key zero.
[mirror_ovs.git] / lib / cfm.h
1 /* Copyright (c) 2010, 2011 Nicira, Inc.
2 *
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:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
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.
14 */
15
16 #ifndef CFM_H
17 #define CFM_H 1
18
19 #include <stdint.h>
20
21 #include "hmap.h"
22 #include "openvswitch/types.h"
23
24 struct flow;
25 struct ofpbuf;
26
27 #define CFM_RANDOM_VLAN UINT16_MAX
28
29 #define CFM_FAULT_REASONS \
30 CFM_FAULT_REASON(RECV, recv) \
31 CFM_FAULT_REASON(RDI, rdi) \
32 CFM_FAULT_REASON(MAID, maid) \
33 CFM_FAULT_REASON(LOOPBACK, loopback) \
34 CFM_FAULT_REASON(OVERFLOW, overflow) \
35 CFM_FAULT_REASON(OVERRIDE, override) \
36 CFM_FAULT_REASON(INTERVAL, interval)
37
38 enum cfm_fault_bit_index {
39 #define CFM_FAULT_REASON(NAME, STR) CFM_FAULT_INDEX_##NAME,
40 CFM_FAULT_REASONS
41 #undef CFM_FAULT_REASON
42 CFM_FAULT_N_REASONS
43 };
44
45 enum cfm_fault_reason {
46 #define CFM_FAULT_REASON(NAME, STR) \
47 CFM_FAULT_##NAME = 1 << CFM_FAULT_INDEX_##NAME,
48 CFM_FAULT_REASONS
49 #undef CFM_FAULT_REASON
50 };
51
52 struct cfm_settings {
53 uint64_t mpid; /* The MPID of this CFM. */
54 int interval; /* The requested transmission interval. */
55 bool extended; /* Run in extended mode. */
56 bool opup; /* Operational State. */
57 uint16_t ccm_vlan; /* CCM Vlan tag. Zero if none.
58 CFM_RANDOM_VLAN if random. */
59 uint8_t ccm_pcp; /* CCM Priority. Zero if none. */
60
61 bool check_tnl_key; /* Verify inbound packet key? */
62 };
63
64 void cfm_init(void);
65 struct cfm *cfm_create(const char *name);
66 void cfm_destroy(struct cfm *);
67 void cfm_run(struct cfm *);
68 bool cfm_should_send_ccm(struct cfm *);
69 void cfm_compose_ccm(struct cfm *, struct ofpbuf *packet, uint8_t eth_src[6]);
70 void cfm_wait(struct cfm *);
71 bool cfm_configure(struct cfm *, const struct cfm_settings *);
72 bool cfm_should_process_flow(const struct cfm *cfm, const struct flow *);
73 void cfm_process_heartbeat(struct cfm *, const struct ofpbuf *packet);
74 int cfm_get_fault(const struct cfm *);
75 int cfm_get_health(const struct cfm *);
76 int cfm_get_opup(const struct cfm *);
77 void cfm_get_remote_mpids(const struct cfm *, const uint64_t **rmps,
78 size_t *n_rmps);
79 const char *cfm_fault_reason_to_str(int fault);
80
81 #endif /* cfm.h */