blob: a8235d3d9eef2356878cba1501af34fd8cf0cc6b [file] [log] [blame]
Damjan Marion22311502016-10-28 20:30:15 +02001/*
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
16#ifndef included_features_h
17#define included_features_h
18
19#include <vnet/vnet.h>
Damjan Marion96b41f72016-11-10 18:01:42 +010020#include <vnet/api_errno.h>
Damjan Marion35af9e52017-03-06 12:02:50 +010021#include <vnet/devices/devices.h>
Damjan Marion22311502016-10-28 20:30:15 +020022
23/** feature registration object */
24typedef struct _vnet_feature_arc_registration
25{
26 /** next registration in list of all registrations*/
27 struct _vnet_feature_arc_registration *next;
28 /** Feature Arc name */
29 char *arc_name;
30 /** Start nodes */
31 char **start_nodes;
32 int n_start_nodes;
Dave Baracha25def72018-11-26 11:04:45 -050033 /** End of the arc (optional, for consistency-checking) */
34 char *last_in_arc;
Damjan Marion22311502016-10-28 20:30:15 +020035 /* Feature arc index, assigned by init function */
Damjan Marion87cd1192016-11-04 11:00:27 +010036 u8 feature_arc_index;
Damjan Marion8b3191e2016-11-09 19:54:20 +010037 u8 *arc_index_ptr;
Damjan Marion22311502016-10-28 20:30:15 +020038} vnet_feature_arc_registration_t;
39
Pavel Kotucek7490a752016-11-15 09:19:11 +010040/* Enable feature callback. */
41typedef clib_error_t *(vnet_feature_enable_disable_function_t)
42 (u32 sw_if_index, int enable_disable);
43
Damjan Marion22311502016-10-28 20:30:15 +020044/** feature registration object */
45typedef struct _vnet_feature_registration
46{
47 /** next registration in list of all registrations*/
Damjan Marion13adc3d2018-04-09 20:59:53 +020048 struct _vnet_feature_registration *next, *next_in_arc;
Damjan Marion22311502016-10-28 20:30:15 +020049 /** Feature arc name */
50 char *arc_name;
51 /** Graph node name */
52 char *node_name;
53 /** Pointer to this feature index, filled in by vnet_feature_arc_init */
Damjan Marion8b3191e2016-11-09 19:54:20 +010054 u32 *feature_index_ptr;
55 u32 feature_index;
Damjan Marion22311502016-10-28 20:30:15 +020056 /** Constraints of the form "this feature runs before X" */
57 char **runs_before;
58 /** Constraints of the form "this feature runs after Y" */
59 char **runs_after;
Pavel Kotucek7490a752016-11-15 09:19:11 +010060
61 /** Function to enable/disable feature **/
62 vnet_feature_enable_disable_function_t *enable_disable_cb;
Damjan Marion22311502016-10-28 20:30:15 +020063} vnet_feature_registration_t;
64
Dave Barach2dd192b2018-11-19 09:31:48 -050065/** constraint registration object */
66typedef struct _vnet_feature_constraint_registration
67{
68 /** next constraint set in list of all registrations*/
69 struct _vnet_feature_constraint_registration *next, *next_in_arc;
70 /** Feature arc name */
71 char *arc_name;
72
73 /** Feature arc index, assigned by init function */
74 u8 feature_arc_index;
75
76 /** Node names, to run in the specified order */
77 char **node_names;
78} vnet_feature_constraint_registration_t;
79
Damjan Marion22311502016-10-28 20:30:15 +020080typedef struct vnet_feature_config_main_t_
81{
82 vnet_config_main_t config_main;
83 u32 *config_index_by_sw_if_index;
84} vnet_feature_config_main_t;
85
86typedef struct
87{
88 /** feature arc configuration list */
89 vnet_feature_arc_registration_t *next_arc;
90 uword **arc_index_by_name;
91
92 /** feature path configuration lists */
93 vnet_feature_registration_t *next_feature;
94 vnet_feature_registration_t **next_feature_by_arc;
Dave Barach2dd192b2018-11-19 09:31:48 -050095 vnet_feature_constraint_registration_t *next_constraint;
96 vnet_feature_constraint_registration_t **next_constraint_by_arc;
Damjan Marion22311502016-10-28 20:30:15 +020097 uword **next_feature_by_name;
98
99 /** feature config main objects */
100 vnet_feature_config_main_t *feature_config_mains;
101
102 /** Save partial order results for show command */
103 char ***feature_nodes;
104
105 /** bitmap of interfaces which have driver rx features configured */
106 uword **sw_if_index_has_features;
107
108 /** feature reference counts by interface */
109 i16 **feature_count_by_sw_if_index;
110
Damjan Marion87cd1192016-11-04 11:00:27 +0100111 /** Feature arc index for device-input */
112 u8 device_input_feature_arc_index;
113
Damjan Marion22311502016-10-28 20:30:15 +0200114 /** convenience */
115 vlib_main_t *vlib_main;
116 vnet_main_t *vnet_main;
117} vnet_feature_main_t;
118
119extern vnet_feature_main_t feature_main;
120
Damjan Marion6e363512018-08-10 22:39:11 +0200121#ifndef CLIB_MARCH_VARIANT
Damjan Marion22311502016-10-28 20:30:15 +0200122#define VNET_FEATURE_ARC_INIT(x,...) \
123 __VA_ARGS__ vnet_feature_arc_registration_t vnet_feat_arc_##x;\
124static void __vnet_add_feature_arc_registration_##x (void) \
125 __attribute__((__constructor__)) ; \
126static void __vnet_add_feature_arc_registration_##x (void) \
127{ \
128 vnet_feature_main_t * fm = &feature_main; \
129 vnet_feat_arc_##x.next = fm->next_arc; \
130 fm->next_arc = & vnet_feat_arc_##x; \
131} \
Damjan Marion72d2c4f2018-04-05 21:32:29 +0200132static void __vnet_rm_feature_arc_registration_##x (void) \
133 __attribute__((__destructor__)) ; \
134static void __vnet_rm_feature_arc_registration_##x (void) \
135{ \
136 vnet_feature_main_t * fm = &feature_main; \
137 vnet_feature_arc_registration_t *r = &vnet_feat_arc_##x; \
138 VLIB_REMOVE_FROM_LINKED_LIST (fm->next_arc, r, next); \
139} \
Damjan Marion22311502016-10-28 20:30:15 +0200140__VA_ARGS__ vnet_feature_arc_registration_t vnet_feat_arc_##x
141
142#define VNET_FEATURE_INIT(x,...) \
143 __VA_ARGS__ vnet_feature_registration_t vnet_feat_##x; \
144static void __vnet_add_feature_registration_##x (void) \
145 __attribute__((__constructor__)) ; \
146static void __vnet_add_feature_registration_##x (void) \
147{ \
148 vnet_feature_main_t * fm = &feature_main; \
149 vnet_feat_##x.next = fm->next_feature; \
150 fm->next_feature = & vnet_feat_##x; \
151} \
Damjan Marion72d2c4f2018-04-05 21:32:29 +0200152static void __vnet_rm_feature_registration_##x (void) \
153 __attribute__((__destructor__)) ; \
154static void __vnet_rm_feature_registration_##x (void) \
155{ \
156 vnet_feature_main_t * fm = &feature_main; \
157 vnet_feature_registration_t *r = &vnet_feat_##x; \
158 VLIB_REMOVE_FROM_LINKED_LIST (fm->next_feature, r, next); \
159} \
Damjan Marion22311502016-10-28 20:30:15 +0200160__VA_ARGS__ vnet_feature_registration_t vnet_feat_##x
Dave Barach2dd192b2018-11-19 09:31:48 -0500161
162#define VNET_FEATURE_ARC_ORDER(x,...) \
163 __VA_ARGS__ vnet_feature_constraint_registration_t \
164vnet_feature_constraint_##x; \
165static void __vnet_add_constraint_registration_##x (void) \
166 __attribute__((__constructor__)) ; \
167static void __vnet_add_constraint_registration_##x (void) \
168{ \
169 vnet_feature_main_t * fm = &feature_main; \
170 vnet_feature_constraint_##x.next = fm->next_constraint; \
171 fm->next_constraint = & vnet_feature_constraint_##x; \
172} \
173static void __vnet_rm_constraint_registration_##x (void) \
174 __attribute__((__destructor__)) ; \
175static void __vnet_rm_constraint_registration_##x (void) \
176{ \
177 vnet_feature_main_t * fm = &feature_main; \
178 vnet_feature_constraint_registration_t *r = &vnet_feature_constraint_##x; \
179 VLIB_REMOVE_FROM_LINKED_LIST (fm->next_constraint, r, next); \
180} \
181__VA_ARGS__ vnet_feature_constraint_registration_t vnet_feature_constraint_##x
182
Damjan Marion6e363512018-08-10 22:39:11 +0200183#else
184#define VNET_FEATURE_ARC_INIT(x,...) \
185extern vnet_feature_arc_registration_t __clib_unused vnet_feat_arc_##x; \
186static vnet_feature_arc_registration_t __clib_unused __clib_unused_vnet_feat_arc_##x
187#define VNET_FEATURE_INIT(x,...) \
188extern vnet_feature_registration_t __clib_unused vnet_feat_##x; \
189static vnet_feature_registration_t __clib_unused __clib_unused_vnet_feat_##x
Dave Barach2dd192b2018-11-19 09:31:48 -0500190
191#define VNET_FEATURE_ARC_ORDER(x,...) \
192extern vnet_feature_constraint_registration_t \
193__clib_unused vnet_feature_constraint_##x; \
194static vnet_feature_constraint_registration_t __clib_unused \
195__clib_unused_vnet_feature_constraint_##x
196
197
Damjan Marion6e363512018-08-10 22:39:11 +0200198#endif
Damjan Marion22311502016-10-28 20:30:15 +0200199
200void
Damjan Marion87cd1192016-11-04 11:00:27 +0100201vnet_config_update_feature_count (vnet_feature_main_t * fm, u8 arc,
Damjan Marion22311502016-10-28 20:30:15 +0200202 u32 sw_if_index, int is_add);
203
Damjan Marion87cd1192016-11-04 11:00:27 +0100204u32 vnet_get_feature_index (u8 arc, const char *s);
205u8 vnet_get_feature_arc_index (const char *s);
Pavel Kotucek7490a752016-11-15 09:19:11 +0100206vnet_feature_registration_t *vnet_get_feature_reg (const char *arc_name,
207 const char *node_name);
208
Damjan Marion22311502016-10-28 20:30:15 +0200209
Damjan Marion96b41f72016-11-10 18:01:42 +0100210int
Damjan Marion8b3191e2016-11-09 19:54:20 +0100211vnet_feature_enable_disable_with_index (u8 arc_index, u32 feature_index,
212 u32 sw_if_index, int enable_disable,
213 void *feature_config,
214 u32 n_feature_config_bytes);
215
216int
Damjan Marion22311502016-10-28 20:30:15 +0200217vnet_feature_enable_disable (const char *arc_name, const char *node_name,
218 u32 sw_if_index, int enable_disable,
219 void *feature_config,
220 u32 n_feature_config_bytes);
221
Neale Ranns5d0136f2020-05-12 08:51:02 +0000222u32
Neale Ranns4ec36c52020-03-31 09:21:29 -0400223vnet_feature_modify_end_node (u8 arc_index, u32 sw_if_index, u32 node_index);
224
Neale Ranns6fdcc3d2021-10-08 07:30:47 +0000225u32 vnet_feature_get_end_node (u8 arc_index, u32 sw_if_index);
226
227u32 vnet_feature_reset_end_node (u8 arc_index, u32 sw_if_index);
228
Steven Luong71e5b472019-10-10 11:36:41 -0700229static_always_inline u32
230vnet_get_feature_count (u8 arc, u32 sw_if_index)
231{
232 vnet_feature_main_t *fm = &feature_main;
233 return (fm->feature_count_by_sw_if_index[arc][sw_if_index]);
234}
235
Damjan Marion8b3191e2016-11-09 19:54:20 +0100236static inline vnet_feature_config_main_t *
237vnet_get_feature_arc_config_main (u8 arc_index)
238{
239 vnet_feature_main_t *fm = &feature_main;
240
241 if (arc_index == (u8) ~ 0)
242 return 0;
243
244 return &fm->feature_config_mains[arc_index];
245}
Damjan Marion22311502016-10-28 20:30:15 +0200246
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100247static_always_inline vnet_feature_config_main_t *
248vnet_feature_get_config_main (u16 arc)
249{
250 vnet_feature_main_t *fm = &feature_main;
251 return &fm->feature_config_mains[arc];
252}
253
Damjan Marion22311502016-10-28 20:30:15 +0200254static_always_inline int
Damjan Marion87cd1192016-11-04 11:00:27 +0100255vnet_have_features (u8 arc, u32 sw_if_index)
Damjan Marion22311502016-10-28 20:30:15 +0200256{
257 vnet_feature_main_t *fm = &feature_main;
258 return clib_bitmap_get (fm->sw_if_index_has_features[arc], sw_if_index);
259}
260
261static_always_inline u32
Damjan Marion87cd1192016-11-04 11:00:27 +0100262vnet_get_feature_config_index (u8 arc, u32 sw_if_index)
Damjan Marion22311502016-10-28 20:30:15 +0200263{
264 vnet_feature_main_t *fm = &feature_main;
265 vnet_feature_config_main_t *cm = &fm->feature_config_mains[arc];
266 return vec_elt (cm->config_index_by_sw_if_index, sw_if_index);
267}
268
Damjan Marion87cd1192016-11-04 11:00:27 +0100269static_always_inline void *
270vnet_feature_arc_start_with_data (u8 arc, u32 sw_if_index, u32 * next,
271 vlib_buffer_t * b, u32 n_data_bytes)
Damjan Marion22311502016-10-28 20:30:15 +0200272{
273 vnet_feature_main_t *fm = &feature_main;
Damjan Marion87cd1192016-11-04 11:00:27 +0100274 vnet_feature_config_main_t *cm;
275 cm = &fm->feature_config_mains[arc];
Damjan Marion22311502016-10-28 20:30:15 +0200276
277 if (PREDICT_FALSE (vnet_have_features (arc, sw_if_index)))
278 {
Damjan Marionaa682a32018-04-26 22:45:40 +0200279 vnet_buffer (b)->feature_arc_index = arc;
Damjan Marion87cd1192016-11-04 11:00:27 +0100280 b->current_config_index =
Damjan Marion22311502016-10-28 20:30:15 +0200281 vec_elt (cm->config_index_by_sw_if_index, sw_if_index);
Damjan Marion87cd1192016-11-04 11:00:27 +0100282 return vnet_get_config_data (&cm->config_main, &b->current_config_index,
283 next, n_data_bytes);
Damjan Marion22311502016-10-28 20:30:15 +0200284 }
Damjan Marion05bb1dd2016-11-08 21:28:22 +0100285 return 0;
Damjan Marion22311502016-10-28 20:30:15 +0200286}
287
Neale Ranns4ec36c52020-03-31 09:21:29 -0400288static_always_inline void *
289vnet_feature_arc_start_w_cfg_index (u8 arc,
290 u32 sw_if_index,
291 u32 * next,
292 vlib_buffer_t * b, u32 cfg_index)
293{
294 vnet_feature_main_t *fm = &feature_main;
295 vnet_feature_config_main_t *cm;
296 cm = &fm->feature_config_mains[arc];
297
298 vnet_buffer (b)->feature_arc_index = arc;
299 b->current_config_index = cfg_index;
300
301 return vnet_get_config_data (&cm->config_main, &b->current_config_index,
302 next, 0);
303}
304
Damjan Marion22311502016-10-28 20:30:15 +0200305static_always_inline void
Damjan Marion87cd1192016-11-04 11:00:27 +0100306vnet_feature_arc_start (u8 arc, u32 sw_if_index, u32 * next0,
307 vlib_buffer_t * b0)
308{
309 vnet_feature_arc_start_with_data (arc, sw_if_index, next0, b0, 0);
310}
311
312static_always_inline void *
Damjan Marion7d98a122018-07-19 20:42:08 +0200313vnet_feature_next_with_data (u32 * next0, vlib_buffer_t * b0,
314 u32 n_data_bytes)
Damjan Marion87cd1192016-11-04 11:00:27 +0100315{
316 vnet_feature_main_t *fm = &feature_main;
Damjan Marionaa682a32018-04-26 22:45:40 +0200317 u8 arc = vnet_buffer (b0)->feature_arc_index;
Damjan Marion87cd1192016-11-04 11:00:27 +0100318 vnet_feature_config_main_t *cm = &fm->feature_config_mains[arc];
319
320 return vnet_get_config_data (&cm->config_main,
321 &b0->current_config_index, next0,
322 n_data_bytes);
323}
324
325static_always_inline void
Damjan Marion7d98a122018-07-19 20:42:08 +0200326vnet_feature_next (u32 * next0, vlib_buffer_t * b0)
Damjan Marion87cd1192016-11-04 11:00:27 +0100327{
Damjan Marion7d98a122018-07-19 20:42:08 +0200328 vnet_feature_next_with_data (next0, b0, 0);
Damjan Marion87cd1192016-11-04 11:00:27 +0100329}
330
Neale Ranns5cd31ec2020-02-24 12:54:31 +0000331static_always_inline void
332vnet_feature_next_u16 (u16 * next0, vlib_buffer_t * b0)
333{
334 u32 next32;
335 vnet_feature_next_with_data (&next32, b0, 0);
336 *next0 = next32;
337}
338
Damjan Mariondc091332018-02-25 22:52:07 +0100339static_always_inline int
340vnet_device_input_have_features (u32 sw_if_index)
341{
342 vnet_feature_main_t *fm = &feature_main;
343 return vnet_have_features (fm->device_input_feature_arc_index, sw_if_index);
344}
345
Damjan Marion87cd1192016-11-04 11:00:27 +0100346static_always_inline void
347vnet_feature_start_device_input_x1 (u32 sw_if_index, u32 * next0,
Damjan Marion35af9e52017-03-06 12:02:50 +0100348 vlib_buffer_t * b0)
Damjan Marion22311502016-10-28 20:30:15 +0200349{
350 vnet_feature_main_t *fm = &feature_main;
351 vnet_feature_config_main_t *cm;
Damjan Marion87cd1192016-11-04 11:00:27 +0100352 u8 feature_arc_index = fm->device_input_feature_arc_index;
353 cm = &fm->feature_config_mains[feature_arc_index];
Damjan Marion22311502016-10-28 20:30:15 +0200354
355 if (PREDICT_FALSE
356 (clib_bitmap_get
Damjan Marion87cd1192016-11-04 11:00:27 +0100357 (fm->sw_if_index_has_features[feature_arc_index], sw_if_index)))
Damjan Marion22311502016-10-28 20:30:15 +0200358 {
359 /*
360 * Save next0 so that the last feature in the chain
361 * can skip ethernet-input if indicated...
362 */
Damjan Marion35af9e52017-03-06 12:02:50 +0100363 u16 adv;
364
Damjan Marion35af9e52017-03-06 12:02:50 +0100365 adv = device_input_next_node_advance[*next0];
Damjan Marion35af9e52017-03-06 12:02:50 +0100366 vlib_buffer_advance (b0, -adv);
Damjan Marion22311502016-10-28 20:30:15 +0200367
Damjan Marionaa682a32018-04-26 22:45:40 +0200368 vnet_buffer (b0)->feature_arc_index = feature_arc_index;
Damjan Marion22311502016-10-28 20:30:15 +0200369 b0->current_config_index =
370 vec_elt (cm->config_index_by_sw_if_index, sw_if_index);
371 vnet_get_config_data (&cm->config_main, &b0->current_config_index,
372 next0, /* # bytes of config data */ 0);
373 }
374}
375
Damjan Marion87cd1192016-11-04 11:00:27 +0100376static_always_inline void
377vnet_feature_start_device_input_x2 (u32 sw_if_index,
378 u32 * next0,
379 u32 * next1,
Damjan Marion35af9e52017-03-06 12:02:50 +0100380 vlib_buffer_t * b0, vlib_buffer_t * b1)
Damjan Marion87cd1192016-11-04 11:00:27 +0100381{
382 vnet_feature_main_t *fm = &feature_main;
383 vnet_feature_config_main_t *cm;
384 u8 feature_arc_index = fm->device_input_feature_arc_index;
385 cm = &fm->feature_config_mains[feature_arc_index];
386
387 if (PREDICT_FALSE
388 (clib_bitmap_get
389 (fm->sw_if_index_has_features[feature_arc_index], sw_if_index)))
390 {
391 /*
392 * Save next0 so that the last feature in the chain
393 * can skip ethernet-input if indicated...
394 */
Damjan Marion35af9e52017-03-06 12:02:50 +0100395 u16 adv;
396
Damjan Marion35af9e52017-03-06 12:02:50 +0100397 adv = device_input_next_node_advance[*next0];
Damjan Marion35af9e52017-03-06 12:02:50 +0100398 vlib_buffer_advance (b0, -adv);
399
Damjan Marion35af9e52017-03-06 12:02:50 +0100400 adv = device_input_next_node_advance[*next1];
Damjan Marion35af9e52017-03-06 12:02:50 +0100401 vlib_buffer_advance (b1, -adv);
Damjan Marion87cd1192016-11-04 11:00:27 +0100402
Damjan Marionaa682a32018-04-26 22:45:40 +0200403 vnet_buffer (b0)->feature_arc_index = feature_arc_index;
404 vnet_buffer (b1)->feature_arc_index = feature_arc_index;
Damjan Marion87cd1192016-11-04 11:00:27 +0100405 b0->current_config_index =
406 vec_elt (cm->config_index_by_sw_if_index, sw_if_index);
407 b1->current_config_index = b0->current_config_index;
408 vnet_get_config_data (&cm->config_main, &b0->current_config_index,
409 next0, /* # bytes of config data */ 0);
410 vnet_get_config_data (&cm->config_main, &b1->current_config_index,
411 next1, /* # bytes of config data */ 0);
412 }
413}
414
Damjan Marion7dc41462016-11-15 19:47:58 +0100415static_always_inline void
416vnet_feature_start_device_input_x4 (u32 sw_if_index,
417 u32 * next0,
418 u32 * next1,
419 u32 * next2,
420 u32 * next3,
421 vlib_buffer_t * b0,
422 vlib_buffer_t * b1,
Damjan Marion35af9e52017-03-06 12:02:50 +0100423 vlib_buffer_t * b2, vlib_buffer_t * b3)
Damjan Marion7dc41462016-11-15 19:47:58 +0100424{
425 vnet_feature_main_t *fm = &feature_main;
426 vnet_feature_config_main_t *cm;
427 u8 feature_arc_index = fm->device_input_feature_arc_index;
428 cm = &fm->feature_config_mains[feature_arc_index];
429
430 if (PREDICT_FALSE
431 (clib_bitmap_get
432 (fm->sw_if_index_has_features[feature_arc_index], sw_if_index)))
433 {
434 /*
435 * Save next0 so that the last feature in the chain
436 * can skip ethernet-input if indicated...
437 */
Damjan Marion35af9e52017-03-06 12:02:50 +0100438 u16 adv;
439
Damjan Marion35af9e52017-03-06 12:02:50 +0100440 adv = device_input_next_node_advance[*next0];
Damjan Marion35af9e52017-03-06 12:02:50 +0100441 vlib_buffer_advance (b0, -adv);
442
Damjan Marion35af9e52017-03-06 12:02:50 +0100443 adv = device_input_next_node_advance[*next1];
Damjan Marion35af9e52017-03-06 12:02:50 +0100444 vlib_buffer_advance (b1, -adv);
445
Damjan Marion35af9e52017-03-06 12:02:50 +0100446 adv = device_input_next_node_advance[*next2];
Damjan Marion35af9e52017-03-06 12:02:50 +0100447 vlib_buffer_advance (b2, -adv);
448
Damjan Marion35af9e52017-03-06 12:02:50 +0100449 adv = device_input_next_node_advance[*next3];
Damjan Marion35af9e52017-03-06 12:02:50 +0100450 vlib_buffer_advance (b3, -adv);
Damjan Marion7dc41462016-11-15 19:47:58 +0100451
Damjan Marionaa682a32018-04-26 22:45:40 +0200452 vnet_buffer (b0)->feature_arc_index = feature_arc_index;
453 vnet_buffer (b1)->feature_arc_index = feature_arc_index;
454 vnet_buffer (b2)->feature_arc_index = feature_arc_index;
455 vnet_buffer (b3)->feature_arc_index = feature_arc_index;
Damjan Marion7dc41462016-11-15 19:47:58 +0100456
457 b0->current_config_index =
458 vec_elt (cm->config_index_by_sw_if_index, sw_if_index);
459 b1->current_config_index = b0->current_config_index;
460 b2->current_config_index = b0->current_config_index;
461 b3->current_config_index = b0->current_config_index;
462
463 vnet_get_config_data (&cm->config_main, &b0->current_config_index,
464 next0, /* # bytes of config data */ 0);
465 vnet_get_config_data (&cm->config_main, &b1->current_config_index,
466 next1, /* # bytes of config data */ 0);
467 vnet_get_config_data (&cm->config_main, &b2->current_config_index,
468 next2, /* # bytes of config data */ 0);
469 vnet_get_config_data (&cm->config_main, &b3->current_config_index,
470 next3, /* # bytes of config data */ 0);
471 }
472}
Damjan Marion87cd1192016-11-04 11:00:27 +0100473
Damjan Marion22311502016-10-28 20:30:15 +0200474#define VNET_FEATURES(...) (char*[]) { __VA_ARGS__, 0}
475
Dave Barach2dd192b2018-11-19 09:31:48 -0500476clib_error_t *vnet_feature_arc_init
477 (vlib_main_t * vm,
478 vnet_config_main_t * vcm,
479 char **feature_start_nodes,
480 int num_feature_start_nodes,
Dave Barach5f9f3c82019-11-22 17:42:58 -0500481 char *last_in_arc,
Dave Barach2dd192b2018-11-19 09:31:48 -0500482 vnet_feature_registration_t * first_reg,
483 vnet_feature_constraint_registration_t * first_const_set,
484 char ***in_feature_nodes);
Damjan Marion22311502016-10-28 20:30:15 +0200485
Dave Barach525c9d02018-05-26 10:48:55 -0400486void vnet_interface_features_show (vlib_main_t * vm, u32 sw_if_index,
487 int verbose);
Damjan Marion22311502016-10-28 20:30:15 +0200488
Neale Rannsc8972fe2019-12-02 23:10:08 +0000489typedef void (*vnet_feature_update_cb_t) (u32 sw_if_index,
490 u8 arc_index,
491 u8 is_enable, void *cb);
492
493extern void vnet_feature_register (vnet_feature_update_cb_t cb, void *data);
494
Dave Barachcaebbcf2020-07-29 18:07:02 -0400495int
496vnet_feature_is_enabled (const char *arc_name, const char *feature_node_name,
497 u32 sw_if_index);
498
Damjan Marion22311502016-10-28 20:30:15 +0200499#endif /* included_feature_h */
500
501/*
502 * fd.io coding-style-patch-verification: ON
503 *
504 * Local Variables:
505 * eval: (c-set-style "gnu")
506 * End:
507 */