46 reg->
cb (sw_if_index, arc_index, is_enable, reg->
data);
67 areg->feature_arc_index = arc_index;
68 if (areg->arc_index_ptr)
69 *areg->arc_index_ptr = arc_index;
74 while ((s = areg->start_nodes[i]))
78 areg->n_start_nodes =
i;
101 clib_warning (
"Unknown feature arc '%s'", freg->arc_name);
106 arc_index = areg->feature_arc_index;
125 clib_warning (
"Unknown feature arc '%s'", creg->arc_name);
130 arc_index = areg->feature_arc_index;
147 char **features_in_order, *last_feature;
149 arc_index = areg->feature_arc_index;
153 (vm, vcm, areg->start_nodes, areg->n_start_nodes,
166 if (areg->last_in_arc &&
vec_len (features_in_order) > 0)
168 last_feature = features_in_order[
vec_len (features_in_order) - 1];
169 if (strncmp (areg->last_in_arc, last_feature,
170 strlen (areg->last_in_arc)))
172 (
"WARNING: %s arc: last node is %s, but expected %s!",
173 areg->arc_name, last_feature, areg->last_in_arc);
184 freg = freg->next_in_arc;
209 return reg->feature_arc_index;
218 if (arc_index == (
u8) ~ 0)
248 return reg->feature_index;
254 void *feature_config,
255 u32 n_feature_config_bytes)
262 if (arc_index == (
u8) ~ 0)
263 return VNET_API_ERROR_INVALID_VALUE;
265 if (feature_index == ~0)
266 return VNET_API_ERROR_INVALID_VALUE_2;
275 if (!enable_disable && feature_count < 1)
282 n_feature_config_bytes);
290 enable_disable = (enable_disable > 0);
291 feature_count += enable_disable ? 1 : -1;
292 ASSERT (feature_count >= 0);
296 (feature_count > 0));
306 void *feature_config,
u32 n_feature_config_bytes)
313 if (arc_index == (
u8) ~ 0)
314 return VNET_API_ERROR_INVALID_VALUE;
319 sw_if_index, enable_disable,
321 n_feature_config_bytes);
332 if (arc_index == (
u8) ~ 0)
333 return VNET_API_ERROR_INVALID_VALUE;
335 if (end_node_index == ~0)
336 return VNET_API_ERROR_INVALID_VALUE_2;
357 return (
int) reg1->feature_index - reg2->feature_index;
392 freg = freg->next_in_arc;
425 .path =
"show features",
426 .short_help =
"show features [verbose]",
439 u32 node_index, current_config_index;
457 feature_arc = areg->feature_arc_index;
463 if (NULL == cm[feature_arc].config_index_by_sw_if_index ||
464 vec_len (cm[feature_arc].config_index_by_sw_if_index) <=
471 current_config_index =
472 vec_elt (cm[feature_arc].config_index_by_sw_if_index, sw_if_index);
474 if (current_config_index == ~0)
480 ASSERT (current_config_index
501 [current_config_index]);
517 u8 *feature_name = 0;
529 &sw_if_index, &feature_name, &arc_name))
531 else if (
unformat (line_input,
"disable"))
539 if (!feature_name || !arc_name)
545 if (sw_if_index == ~0)
558 if (arc_index == (
u8) ~ 0)
562 (
const char *) arc_name);
569 (
const char *) feature_name);
574 "Feature (%s) not registered to arc (%s)... See 'show features verbose' for valid feature/arc combinations. ",
575 feature_name, arc_name);
578 if (reg->enable_disable_cb)
579 error = reg->enable_disable_cb (sw_if_index, enable);
582 (
const char *) feature_name, sw_if_index,
603 .path =
"set interface feature",
604 .short_help =
"set interface feature <intfc> <feature_name> arc <arc_name> " vnet_config_main_t config_main
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vnet_feature_register(vnet_feature_update_cb_t cb, void *data)
vnet_feature_update_cb_t cb
static void vent_feature_reg_invoke(u32 sw_if_index, u8 arc_index, u8 is_enable)
vnet_config_feature_t * features
struct _vnet_feature_constraint_registration vnet_feature_constraint_registration_t
constraint registration object
u8 vnet_get_feature_arc_index(const char *s)
vnet_main_t * vnet_get_main(void)
char *** feature_nodes
Save partial order results for show command.
vnet_feature_registration_t * next_feature
feature path configuration lists
u32 vnet_config_del_feature(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 feature_index, void *feature_config, u32 n_feature_config_bytes)
u32 * config_index_by_sw_if_index
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
#define hash_set_mem(h, key, value)
unformat_function_t unformat_vnet_sw_interface
format_function_t format_vnet_sw_if_index_name
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
clib_error_t * vnet_feature_arc_init(vlib_main_t *vm, vnet_config_main_t *vcm, char **feature_start_nodes, int num_feature_start_nodes, char *last_in_arc, vnet_feature_registration_t *first_reg, vnet_feature_constraint_registration_t *first_const_set, char ***in_feature_nodes)
Initialize a feature graph arc.
u32 vnet_config_modify_end_node(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 end_node_index)
vnet_feature_constraint_registration_t * next_constraint
static vnet_feature_upd_registration_t * regs
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
vnet_feature_registration_t * vnet_get_feature_reg(const char *arc_name, const char *node_name)
int vnet_feature_enable_disable_with_index(u8 arc_index, u32 feature_index, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
#define clib_error_return(e, args...)
u32 vnet_get_feature_index(u8 arc, const char *s)
static clib_error_t * vnet_feature_init(vlib_main_t *vm)
#define hash_create_string(elts, value_bytes)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static clib_error_t * set_interface_features_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 vnet_feature_modify_end_node(u8 arc_index, u32 sw_if_index, u32 end_node_index)
void(* vnet_feature_update_cb_t)(u32 sw_if_index, u8 arc_index, u8 is_enable, void *cb)
uword ** next_feature_by_name
u32 * config_pool_index_by_user_index
static int feature_cmp(void *a1, void *a2)
void vnet_interface_features_show(vlib_main_t *vm, u32 sw_if_index, int verbose)
Display the set of driver features configured on a specific interface Called by "show interface" hand...
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
vnet_feature_constraint_registration_t ** next_constraint_by_arc
uword ** arc_index_by_name
i16 ** feature_count_by_sw_if_index
feature reference counts by interface
#define VLIB_CLI_COMMAND(x,...)
#define uword_to_pointer(u, type)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
struct vnet_feature_upd_registration_t_ vnet_feature_upd_registration_t
vnet_feature_registration_t ** next_feature_by_arc
#define clib_error_report(e)
u32 vnet_config_add_feature(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 feature_index, void *feature_config, u32 n_feature_config_bytes)
static uword pointer_to_uword(const void *p)
static vlib_main_t * vlib_get_main(void)
#define vec_elt(v, i)
Get vector value at index i.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
struct _vnet_feature_arc_registration vnet_feature_arc_registration_t
feature registration object
#define hash_get_mem(h, key)
vnet_feature_arc_registration_t * next_arc
feature arc configuration list
uword ** sw_if_index_has_features
bitmap of interfaces which have driver rx features configured
vnet_config_t * config_pool
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
#define vec_foreach(var, vec)
Vector iterator.
static clib_error_t * show_features_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Display the set of available driver features.
u32 * end_node_indices_by_user_index
vnet_feature_config_main_t * feature_config_mains
feature config main objects
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
vnet_feature_main_t feature_main
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
struct _vnet_feature_registration vnet_feature_registration_t
feature registration object