FD.io VPP  v16.12-rc0-308-g931be3a
Vector Packet Processing
ip6_hop_by_hop.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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_ip6_hop_by_hop_ioam_h__
16 #define __included_ip6_hop_by_hop_ioam_h__
17 
19 #include <vnet/ip/ip.h>
20 
21 
22 #define MAX_IP6_HBH_OPTION 256
23 
24 /* To determine whether a node is decap MS bit is set */
25 #define IOAM_DECAP_BIT 0x80000000
26 
27 #define IOAM_DEAP_ENABLED(opaque_data) (opaque_data & IOAM_DECAP_BIT)
28 
29 #define IOAM_SET_DECAP(opaque_data) \
30  (opaque_data |= IOAM_DECAP_BIT)
31 
32 #define IOAM_MASK_DECAP_BIT(x) (x & ~IOAM_DECAP_BIT)
33 
34 /*
35  * Stores the run time flow data of hbh options
36  */
37 typedef struct {
39  u8 flow_name[64];
40 } flow_data_t;
41 
42 typedef struct {
43  /* The current rewrite we're using */
45 
46  /* Trace data processing callback */
48  /* Configuration data */
49  /* Adjacency */
51 #define IOAM_HBYH_ADD 0
52 #define IOAM_HBYH_MOD 1
53 #define IOAM_HBYH_POP 2
55  /* time scale transform. Joy. */
58 
59 
60  /* Trace option */
62 
63  /* Pot option */
65 
66  /* Per Packet Counter option */
68 
69  /* Enabling analyis of iOAM data on decap node */
71 
72 #define TSP_SECONDS 0
73 #define TSP_MILLISECONDS 1
74 #define TSP_MICROSECONDS 2
75 #define TSP_NANOSECONDS 3
76 
77  /* Array of function pointers to ADD and POP HBH option handling routines */
78  u8 options_size[MAX_IP6_HBH_OPTION];
79  int (*add_options[MAX_IP6_HBH_OPTION])(u8 *rewrite_string, u8 *rewrite_size);
81  int (*get_sizeof_options[MAX_IP6_HBH_OPTION])(u32 *rewrite_size);
82  int (*config_handler[MAX_IP6_HBH_OPTION]) (void *data, u8 disable);
83 
84  /* Array of function pointers to handle hbh options being used with classifier */
85  u32 (*flow_handler[MAX_IP6_HBH_OPTION])(u32 flow_ctx, u8 add);
87 
88  /* convenience */
92 
94 
95 extern u8 * format_path_map(u8 * s, va_list * args);
96 
97 extern clib_error_t *
98 ip6_ioam_enable(int has_trace_option, int has_pot_option,
99  int has_seqno_option, int has_analyse_option);
100 
101 extern int ip6_ioam_set_destination (ip6_address_t *addr, u32 mask_width,
102  u32 vrf_id, int is_add, int is_pop, int is_none);
103 
104 extern clib_error_t * clear_ioam_rewrite_fn(void);
105 
107 {
108  return (a->as_u32 == 0);
109 }
110 
111 static inline void copy_ip6_address (ip6_address_t *dst, ip6_address_t *src)
112 {
113  dst->as_u64[0] = src->as_u64[0];
114  dst->as_u64[1] = src->as_u64[1];
115 }
116 
117 static inline void set_zero_ip6_address (ip6_address_t *a)
118 {
119  a->as_u64[0] = 0;
120  a->as_u64[1] = 0;
121 }
122 
124 {
125  return ((a1->as_u64[0] == a2->as_u64[0]) && (a1->as_u64[1] == a2->as_u64[1]));
126 }
128 {
129  return ((a->as_u64[0] == 0) && (a->as_u64[1] == 0));
130 }
131 
132 int ip6_hbh_add_register_option (u8 option,
133  u8 size,
134  int rewrite_options(u8 *rewrite_string, u8 *size));
135 int ip6_hbh_add_unregister_option (u8 option);
136 
137 int ip6_hbh_pop_register_option (u8 option,
138  int options(vlib_buffer_t *b,
140 int ip6_hbh_pop_unregister_option (u8 option);
141 
142 int
144  int get_sizeof_hdr_options(u32 *rewrite_size));
145 
146 int
147 ip6_ioam_set_rewrite (u8 **rwp, int has_trace_option,
148  int has_pot_option, int has_seq_no);
149 
150 int
152  int config_handler(void *data, u8 disable));
153 
155 
157  u32 ioam_flow_handler(u32 flow_ctx, u8 add));
158 
160 
162 
163 static inline flow_data_t * get_flow (u32 index)
164 {
165  flow_data_t *flow = NULL;
167 
168  if (pool_is_free_index (hm->flows, index))
169  return NULL;
170 
171  flow = pool_elt_at_index (hm->flows, index);
172  return flow;
173 }
174 
175 static inline u32 get_flow_data_from_flow_ctx (u32 flow_ctx, u8 option)
176 {
177  flow_data_t *flow = NULL;
179  u32 index;
180 
181  index = IOAM_MASK_DECAP_BIT(flow_ctx);
182  //flow = pool_elt_at_index (hm->flows, index);
183  flow = &hm->flows[index];
184  return (flow->ctx[option]);
185 }
186 
187 static inline u8 is_seqno_enabled (void)
188 {
189  return (ip6_hop_by_hop_ioam_main.has_seqno_option);
190 }
191 
192 #endif /* __included_ip6_hop_by_hop_ioam_h__ */
a
Definition: bitmap.h:516
int ip6_ioam_set_rewrite(u8 **rwp, int has_trace_option, int has_pot_option, int has_seq_no)
u64 as_u64[2]
Definition: ip6_packet.h:50
#define NULL
Definition: clib.h:55
int ip6_hbh_flow_handler_unregister(u8 option)
int ip6_hbh_get_sizeof_register_option(u8 option, int get_sizeof_hdr_options(u32 *rewrite_size))
u32 ctx[MAX_IP6_HBH_OPTION]
int ip6_hbh_config_handler_register(u8 option, int config_handler(void *data, u8 disable))
int ip6_hbh_add_register_option(u8 option, u8 size, int rewrite_options(u8 *rewrite_string, u8 *size))
int ip6_ioam_set_destination(ip6_address_t *addr, u32 mask_width, u32 vrf_id, int is_add, int is_pop, int is_none)
int ip6_hbh_config_handler_unregister(u8 option)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
add
Definition: vector_sse2.h:285
clib_error_t * ip6_ioam_enable(int has_trace_option, int has_pot_option, int has_seqno_option, int has_analyse_option)
static u32 get_flow_data_from_flow_ctx(u32 flow_ctx, u8 option)
static flow_data_t * get_flow(u32 index)
static void set_zero_ip6_address(ip6_address_t *a)
clib_error_t * clear_ioam_rewrite_fn(void)
u8 * get_flow_name_from_flow_ctx(u32 flow_ctx)
static u8 cmp_ip6_address(ip6_address_t *a1, ip6_address_t *a2)
static u8 is_seqno_enabled(void)
u8 * format_path_map(u8 *s, va_list *args)
static u8 is_zero_ip4_address(ip4_address_t *a)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:211
ip6_hop_by_hop_ioam_main_t ip6_hop_by_hop_ioam_main
unsigned int u32
Definition: types.h:88
static u8 is_zero_ip6_address(ip6_address_t *a)
u32 size
Definition: vhost-user.h:76
int ip6_hbh_flow_handler_register(u8 option, u32 ioam_flow_handler(u32 flow_ctx, u8 add))
int ip6_hbh_pop_register_option(u8 option, int options(vlib_buffer_t *b, ip6_header_t *ip, ip6_hop_by_hop_option_t *opt))
double f64
Definition: types.h:142
unsigned char u8
Definition: types.h:56
#define IOAM_MASK_DECAP_BIT(x)
vhost_vring_addr_t addr
Definition: vhost-user.h:81
static void copy_ip6_address(ip6_address_t *dst, ip6_address_t *src)
int ip6_hbh_pop_unregister_option(u8 option)
#define MAX_IP6_HBH_OPTION
int ip6_hbh_add_unregister_option(u8 option)