]>
Commit | Line | Data |
---|---|---|
0477baa9 | 1 | /* Copyright (c) 2010, 2011, 2015 Nicira, Inc. |
b31bcf60 EJ |
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 | ||
ee89ea7b | 21 | #include "openvswitch/hmap.h" |
2a899f6e | 22 | #include "openvswitch/types.h" |
3bd0fd39 | 23 | #include "packets.h" |
b31bcf60 EJ |
24 | |
25 | struct flow; | |
cf62fa4c | 26 | struct dp_packet; |
90967e95 | 27 | struct netdev; |
642dc74d | 28 | struct flow_wildcards; |
b31bcf60 | 29 | |
189cb9e4 EJ |
30 | #define CFM_RANDOM_VLAN UINT16_MAX |
31 | ||
b9380396 EJ |
32 | #define CFM_FAULT_REASONS \ |
33 | CFM_FAULT_REASON(RECV, recv) \ | |
34 | CFM_FAULT_REASON(RDI, rdi) \ | |
35 | CFM_FAULT_REASON(MAID, maid) \ | |
36 | CFM_FAULT_REASON(LOOPBACK, loopback) \ | |
37 | CFM_FAULT_REASON(OVERFLOW, overflow) \ | |
0258d4a0 | 38 | CFM_FAULT_REASON(OVERRIDE, override) |
b9380396 EJ |
39 | |
40 | enum cfm_fault_bit_index { | |
41 | #define CFM_FAULT_REASON(NAME, STR) CFM_FAULT_INDEX_##NAME, | |
42 | CFM_FAULT_REASONS | |
43 | #undef CFM_FAULT_REASON | |
44 | CFM_FAULT_N_REASONS | |
45 | }; | |
46 | ||
47 | enum cfm_fault_reason { | |
48 | #define CFM_FAULT_REASON(NAME, STR) \ | |
49 | CFM_FAULT_##NAME = 1 << CFM_FAULT_INDEX_##NAME, | |
50 | CFM_FAULT_REASONS | |
51 | #undef CFM_FAULT_REASON | |
52 | }; | |
53 | ||
a5610457 | 54 | struct cfm_settings { |
348f01e3 | 55 | uint64_t mpid; /* The MPID of this CFM. */ |
b31bcf60 | 56 | int interval; /* The requested transmission interval. */ |
ef9819b5 | 57 | bool extended; /* Run in extended mode. */ |
90967e95 | 58 | bool demand; /* Run in demand mode. */ |
86dc6501 | 59 | bool opup; /* Operational State. */ |
189cb9e4 EJ |
60 | uint16_t ccm_vlan; /* CCM Vlan tag. Zero if none. |
61 | CFM_RANDOM_VLAN if random. */ | |
a7aa2d3c | 62 | uint8_t ccm_pcp; /* CCM Priority. Zero if none. */ |
b363bae4 EJ |
63 | |
64 | bool check_tnl_key; /* Verify inbound packet key? */ | |
b31bcf60 EJ |
65 | }; |
66 | ||
685acfd9 AW |
67 | /* CFM status query. */ |
68 | struct cfm_status { | |
69 | /* 0 if not faulted, otherwise a combination of one or more reasons. */ | |
70 | enum cfm_fault_reason faults; | |
71 | ||
72 | /* 0 if the remote CFM endpoint is operationally down, | |
73 | * 1 if the remote CFM endpoint is operationally up, | |
74 | * -1 if we don't know because the remote CFM endpoint is not in extended | |
75 | * mode. */ | |
76 | int remote_opstate; | |
77 | ||
78 | uint64_t flap_count; | |
79 | ||
80 | /* Ordinarily a "health status" in the range 0...100 inclusive, with 0 | |
81 | * being worst and 100 being best, or -1 if the health status is not | |
82 | * well-defined. */ | |
83 | int health; | |
84 | ||
85 | /* MPIDs of remote maintenance points whose CCMs have been received. */ | |
86 | uint64_t *rmps; | |
87 | size_t n_rmps; | |
88 | }; | |
89 | ||
9ac3fce4 | 90 | void cfm_init(void); |
90967e95 | 91 | struct cfm *cfm_create(const struct netdev *); |
8e9a73fa EJ |
92 | struct cfm *cfm_ref(const struct cfm *); |
93 | void cfm_unref(struct cfm *); | |
a58727fb | 94 | void cfm_run(struct cfm *); |
a58727fb | 95 | bool cfm_should_send_ccm(struct cfm *); |
0477baa9 | 96 | void cfm_compose_ccm(struct cfm *, struct dp_packet *, |
74ff3298 | 97 | const struct eth_addr eth_src); |
0477baa9 | 98 | long long int cfm_wait(struct cfm *); |
a5610457 | 99 | bool cfm_configure(struct cfm *, const struct cfm_settings *); |
9d46b444 | 100 | void cfm_set_netdev(struct cfm *, const struct netdev *); |
642dc74d JP |
101 | bool cfm_should_process_flow(const struct cfm *cfm, const struct flow *, |
102 | struct flow_wildcards *); | |
cf62fa4c | 103 | void cfm_process_heartbeat(struct cfm *, const struct dp_packet *packet); |
88bf179a | 104 | bool cfm_check_status_change(struct cfm *); |
b9380396 | 105 | int cfm_get_fault(const struct cfm *); |
76c4290d | 106 | uint64_t cfm_get_flap_count(const struct cfm *); |
3967a833 | 107 | int cfm_get_health(const struct cfm *); |
4653c558 | 108 | int cfm_get_opup(const struct cfm *); |
13b1b2ae | 109 | void cfm_get_remote_mpids(const struct cfm *, uint64_t **rmps, size_t *n_rmps); |
685acfd9 | 110 | void cfm_get_status(const struct cfm *, struct cfm_status *); |
b9380396 | 111 | const char *cfm_fault_reason_to_str(int fault); |
a5610457 | 112 | |
526d174a | 113 | long long int cfm_wake_time(struct cfm*); |
b31bcf60 | 114 | #endif /* cfm.h */ |