dpdk: Add support for Mellanox ConnectX-4 devices
[vpp.git] / vpp / oam / oam.h
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
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 #ifndef __included_oam_h__
16 #define __included_oam_h__
17
18 #include <vlib/vlib.h>
19 #include <vnet/vnet.h>
20 #include <vnet/ip/ip.h>
21 #include <vnet/interface.h>
22
23 /* 36 octets, make a note of it... */
24 /* *INDENT-OFF* */
25 typedef CLIB_PACKED (struct {
26   ip4_header_t ip4;
27   icmp46_header_t icmp;
28   u16 id;
29   u16 seq;
30   u8 data[8];
31 }) oam_template_t;
32 /* *INDENT-ON* */
33
34 /* *INDENT-OFF* */
35 typedef CLIB_PACKED (struct {
36   u64 v8[4];
37   u32 v4;
38 }) oam_template_copy_t;
39 /* *INDENT-ON* */
40
41 typedef enum
42 {
43   OAM_STATE_UNKNOWN = 0,
44   OAM_STATE_ALIVE,
45   OAM_STATE_DEAD,
46 } oam_state_t;
47
48 typedef struct
49 {
50   ip4_address_t src_address;
51   ip4_address_t dst_address;
52   u32 fib_id;
53   u32 fib_index;
54   f64 last_heard_time;
55   u16 seq;
56   u16 last_heard_seq;
57   u16 id;
58   u8 state;
59   oam_template_t *template;
60 } oam_target_t;
61
62 typedef struct
63 {
64   /* OAM targets */
65   oam_target_t *targets;
66   uword *target_by_address_and_fib_id;
67
68   /* Config parameters */
69   f64 interval;
70   u32 misses_allowed;
71
72   /* random number seed */
73   u32 random_seed;
74   u16 icmp_id;
75
76   /* oam packet template */
77   vlib_packet_template_t packet_template;
78
79   /* convenience */
80   vlib_main_t *vlib_main;
81   vnet_main_t *vnet_main;
82 } oam_main_t;
83
84 int vpe_oam_add_del_target (ip4_address_t * src_address,
85                             ip4_address_t * dst_address,
86                             u32 fib_id, int is_add);
87
88 #endif /* __included_oam_h__ */
89
90 /*
91  * fd.io coding-style-patch-verification: ON
92  *
93  * Local Variables:
94  * eval: (c-set-style "gnu")
95  * End:
96  */