VPP-470: Introduce VxLAN-GPE as transport for iOAM.
[vpp.git] / plugins / ioam-plugin / ioam / lib-vxlan-gpe / vxlan_gpe_ioam.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_vxlan_gpe_ioam_h__
16 #define __included_vxlan_gpe_ioam_h__
17
18 #include <vnet/vxlan-gpe/vxlan_gpe.h>
19 #include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
20 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam_packet.h>
21 #include <vnet/ip/ip.h>
22
23
24 typedef struct vxlan_gpe_ioam_main_
25 {
26   /* time scale transform. Joy. */
27   u32 unix_time_0;
28   f64 vlib_time_0;
29
30
31   /* Trace option */
32   u8 has_trace_option;
33
34   /* Pot option */
35   u8 has_pot_option;
36
37 #define PPC_NONE  0
38 #define PPC_ENCAP 1
39 #define PPC_DECAP 2
40   u8 has_ppc_option;
41
42 #define TSP_SECONDS              0
43 #define TSP_MILLISECONDS         1
44 #define TSP_MICROSECONDS         2
45 #define TSP_NANOSECONDS          3
46
47   /* Array of function pointers to ADD and POP VxLAN-GPE iOAM option handling routines */
48   u8 options_size[256];
49   int (*add_options[256]) (u8 * rewrite_string, u8 * rewrite_size);
50   int (*pop_options[256]) (ip4_header_t * ip, vxlan_gpe_ioam_option_t * opt);
51
52   /* Array of function pointers to iOAM option handling routines */
53   int (*options[256]) (vlib_buffer_t * b, vxlan_gpe_ioam_option_t * opt,
54                        u8 is_ipv4, u8 use_adj);
55   u8 *(*trace[256]) (u8 * s, vxlan_gpe_ioam_option_t * opt);
56
57   /* API message ID base */
58   u16 msg_id_base;
59
60   /* Override to export for iOAM */
61   uword decap_v4_next_override;
62   uword decap_v6_next_override;
63
64   /* sequence of node graph for encap */
65   uword encap_v4_next_node;
66   uword encap_v6_next_node;
67
68   /** State convenience vlib_main_t */
69   vlib_main_t *vlib_main;
70   /** State convenience vnet_main_t */
71   vnet_main_t *vnet_main;
72
73
74 } vxlan_gpe_ioam_main_t;
75 extern vxlan_gpe_ioam_main_t vxlan_gpe_ioam_main;
76
77 /*
78  * Primary h-b-h handler trace support
79  */
80 typedef struct
81 {
82   u32 next_index;
83   u32 trace_len;
84   u8 option_data[256];
85 } ioam_trace_t;
86
87
88 vlib_node_registration_t vxlan_gpe_encap_ioam_v4_node;
89 vlib_node_registration_t vxlan_gpe_decap_ioam_v4_node;
90
91 clib_error_t *vxlan_gpe_ioam_enable (int has_trace_option, int has_pot_option,
92                                      int has_ppc_option);
93
94 clib_error_t *vxlan_gpe_ioam_disable (int has_trace_option,
95                                       int has_pot_option, int has_ppc_option);
96
97 clib_error_t *vxlan_gpe_ioam_set (vxlan_gpe_tunnel_t * t,
98                                   int has_trace_option,
99                                   int has_pot_option,
100                                   int has_ppc_option, u8 ipv6_set);
101 clib_error_t *vxlan_gpe_ioam_clear (vxlan_gpe_tunnel_t * t,
102                                     int has_trace_option, int has_pot_option,
103                                     int has_ppc_option, u8 ipv6_set);
104
105 int vxlan_gpe_ioam_add_register_option (u8 option,
106                                         u8 size,
107                                         int rewrite_options (u8 *
108                                                              rewrite_string,
109                                                              u8 *
110                                                              rewrite_size));
111
112 int vxlan_gpe_add_unregister_option (u8 option);
113
114 int vxlan_gpe_ioam_register_option (u8 option,
115                                     int options (vlib_buffer_t * b,
116                                                  vxlan_gpe_ioam_option_t *
117                                                  opt, u8 is_ipv4, u8 use_adj),
118                                     u8 * trace (u8 * s,
119                                                 vxlan_gpe_ioam_option_t *
120                                                 opt));
121 int vxlan_gpe_ioam_unregister_option (u8 option);
122
123 int vxlan_gpe_trace_profile_setup (void);
124
125 int vxlan_gpe_trace_profile_cleanup (void);
126
127 typedef enum
128 {
129   VXLAN_GPE_DECAP_IOAM_V4_NEXT_POP,
130   VXLAN_GPE_DECAP_IOAM_V4_NEXT_DROP,
131   VXLAN_GPE_DECAP_IOAM_V4_N_NEXT
132 } vxlan_gpe_decap_ioam_v4_next_t;
133
134 #endif
135
136 /*
137  * fd.io coding-style-patch-verification: ON
138  *
139  * Local Variables:
140  * eval: (c-set-style "gnu")
141  * End:
142  */