43 #define VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE (1 << 0) 44 #define VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE (1 << 1) 77 for (i = 0; i < n; i++)
80 sizeof (s[i].sw_hw_if_index));
93 for (i = 0; i < n; i++)
96 sizeof (s[i].sw_hw_if_index));
137 .name =
"vnet_sw_interface_set_flags",.serialize =
143 .name =
"vnet_hw_interface_set_flags",.serialize =
160 vnet_hw_interface_class_t * hw_class = vnet_get_hw_interface_class (vnm, hif->hw_class_index);
161 serialize_cstring (m, hw_class->name);
170 vec_add2 (sts, st, 1);
171 st->sw_hw_if_index = sif->sw_if_index;
172 st->flags = sif->flags;
186 vec_add2 (sts, st, 1);
187 st->sw_hw_if_index = hif->hw_if_index;
188 st->flags = hif->flags;
214 unserialize_cstring (m, &class_name);
215 p = hash_get_mem (im->hw_interface_class_by_name, class_name);
217 error = vnet_hw_interface_set_class_helper (vnm, hif->hw_if_index, p[0], 0);
219 clib_error_report (error);
220 vec_free (class_name);
241 _vnet_interface_function_list_elt_t *
248 error = elt->fp (vnm, if_index, flags);
251 elt = elt->next_interface_function;
267 if (hw_class->interface_add_del_function
269 hw_class->interface_add_del_function (vnm, hw_if_index, is_create)))
272 if (dev_class->interface_add_del_function
274 dev_class->interface_add_del_function (vnm, hw_if_index,
292 #define VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE (1 << 0) 293 #define VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE (1 << 1) 320 if (!is_create && (hi->
flags & mask) == flags)
324 if (!dev_class->redistribute)
340 if (hw_class->link_up_down_function
341 && (error = hw_class->link_up_down_function (vnm, hw_if_index,
346 (vnm, hw_if_index, is_create,
388 sw_interface_admin_up_down_functions);
403 if ((flags != (si_sup->
flags & mask)) &&
405 && ((si_sup->
flags & mask) ==
421 (0,
"not allowed as %U belong to a BondEthernet interface",
427 if ((si->
flags & mask) == flags)
438 if (!dev_class->redistribute)
469 old_flags = si->
flags;
473 si->
flags &= ~VNET_SW_INTERFACE_FLAG_ADMIN_UP;
475 if (dev_class->admin_up_down_function
476 && (error = dev_class->admin_up_down_function (vnm,
481 si->
flags = old_flags;
485 if (hw_class->admin_up_down_function
486 && (error = hw_class->admin_up_down_function (vnm,
491 si->
flags = old_flags;
496 if (!(flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
516 (vnm, hw_if_index, flags,
524 (vnm, sw_if_index, flags,
584 dev_class->subif_add_del_function)
586 error = dev_class->subif_add_del_function (vnm, hi->
hw_if_index,
595 (vnm, *sw_if_index, template->flags,
632 n->
function = dev_class->tx_function;
635 dev_class->tx_function_n_errors,
636 dev_class->tx_function_error_strings);
653 u32 hw_class_index,
u32 hw_instance)
663 char *tx_node_name, *output_node_name;
670 if (dev_class->format_device_name)
671 hw->
name =
format (0,
"%U", dev_class->format_device_name, dev_instance);
672 else if (hw_class->format_interface_name)
673 hw->
name =
format (0,
"%U", hw_class->format_interface_name,
676 hw->
name =
format (0,
"%s%x", hw_class->name, dev_instance);
680 sizeof (hw->
name[0]),
689 memset (&sw, 0,
sizeof (sw));
706 tx_node_name = (
char *)
format (0,
"%v-tx", hw->
name);
707 output_node_name = (
char *)
format (0,
"%v-output", hw->
name);
740 node->
function = dev_class->no_flatten_output_chains ?
748 node->
function = dev_class->tx_function;
766 memset (&r, 0,
sizeof (r));
768 r.runtime_data = &rt;
769 r.runtime_data_bytes =
sizeof (rt);
771 r.vector_size =
sizeof (
u32);
774 r.name = tx_node_name;
775 r.function = dev_class->tx_function;
784 r.name = output_node_name;
785 r.function = dev_class->no_flatten_output_chains ?
793 "interface is deleted",
801 #define _(sym,str) vlib_node_add_named_next_with_slot (vm, \ 802 hw->output_node_index, str, \ 803 VNET_INTERFACE_OUTPUT_NEXT_##sym); 848 vnet_delete_sw_interface (vnm, sw_if_index);
862 "interface-%d-output-deleted", hw_if_index);
879 u32 hw_if_index = va_arg (*va,
u32);
880 char *hw_class_name = va_arg (*va,
char *);
908 .name =
"vnet_hw_interface_set_class",.serialize =
914 u32 hw_class_index,
u32 hw_instance)
927 u32 hw_class_index,
u32 redistribute)
949 "%v must be admin down to change class from %s to %s",
950 hi->
name, old_class->name, new_class->name);
953 if ((new_class->is_valid_class_for_interface
954 && !new_class->is_valid_class_for_interface (vnm, hw_if_index,
956 || (dev_class->is_valid_class_for_interface
957 && !dev_class->is_valid_class_for_interface (vnm, hw_if_index,
960 "%v class cannot be changed from %s to %s",
961 hi->
name, old_class->name, new_class->name);
966 &vnet_hw_interface_set_class_msg, hw_if_index,
972 if (old_class->hw_class_change)
973 old_class->hw_class_change (vnm, hw_if_index, old_class->index,
979 if (new_class->hw_class_change)
980 new_class->hw_class_change (vnm, hw_if_index, old_class->index,
983 if (dev_class->hw_class_change)
984 dev_class->hw_class_change (vnm, hw_if_index, new_class->index);
1012 if (dev_class->rx_redirect_to_node)
1014 dev_class->rx_redirect_to_node (vnm, hw_if_index, node_index);
1018 return VNET_API_ERROR_UNIMPLEMENTED;
1069 #define _(a) if (sizeof(o->a) > sizeof (o->unused)) \ 1071 ("FATAL: size of opaque union subtype %s is %d (max %d)", \ 1072 #a, sizeof(o->a), sizeof (o->unused)); 1077 (0,
"FATAL: size of vlib buffer opaque %d, size of vnet opaque %d",
1114 c = c->next_class_registration;
1133 c = c->next_class_registration;
1161 if (dev_class->name_renumber == 0 || dev_class->format_device_name == 0)
1162 return VNET_API_ERROR_UNIMPLEMENTED;
1164 rv = dev_class->name_renumber (hi, new_show_dev_instance);
1172 hi->
name =
format (0,
"%U", dev_class->format_device_name,
1220 "unable to find hw interface for index %u",
1224 old_name = hw->
name;
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void serialize_vnet_interface_state(serialize_main_t *m, va_list *va)
sll srl srl sll sra u16x4 i
static clib_error_t * vnet_hw_interface_set_class_helper(vnet_main_t *vnm, u32 hw_if_index, u32 hw_class_index, u32 redistribute)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
volatile u32 * sw_if_counter_lock
vnet_hw_interface_nodes_t * deleted_hw_interface_nodes
#define INTF_OUTPUT_FEAT_DONE
#define vec_serialize(m, v, f)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_interface_main_t interface_main
void * vnet_interface_output_node_multiarch_select(void)
uword vlib_node_add_next_with_slot(vlib_main_t *vm, uword node_index, uword next_node_index, uword slot)
int vnet_hw_interface_rx_redirect_to_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
void vlib_register_errors(vlib_main_t *vm, u32 node_index, u32 n_errors, char *error_strings[])
int vnet_interface_add_del_feature(vnet_main_t *vnm, vlib_main_t *vm, u32 sw_if_index, intf_output_feat_t feature, int is_add)
#define vec_unserialize(m, v, f)
format_function_t * format_trace
vnet_device_class_t * device_class_registrations
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
word vnet_sw_interface_compare(vnet_main_t *vnm, uword sw_if_index0, uword sw_if_index1)
int vnet_interface_name_renumber(u32 sw_if_index, u32 new_show_dev_instance)
_vnet_interface_function_list_elt_t * sw_interface_admin_up_down_functions
struct _vlib_node_registration vlib_node_registration_t
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define hash_set_mem(h, key, value)
MC_SERIALIZE_MSG(vnet_sw_interface_set_flags_msg, static)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
uword * sub_interface_sw_if_index_by_id
static void unserialize_vnet_hw_interface_set_flags(serialize_main_t *m, va_list *va)
#define clib_error_report(e)
#define VNET_HW_INTERFACE_FLAG_LINK_UP
struct _vnet_device_class vnet_device_class_t
#define mc_serialize(mc, msg, args...)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static clib_error_t * vnet_hw_interface_set_flags_helper(vnet_main_t *vnm, u32 hw_if_index, u32 flags, u32 helper_flags)
f64 max_rate_bits_per_sec
#define VNET_HW_INTERFACE_FLAG_DUPLEX_MASK
vlib_node_function_t * function
u32 vlib_register_node(vlib_main_t *vm, vlib_node_registration_t *r)
static void unserialize_vec_vnet_sw_hw_interface_state(serialize_main_t *m, va_list *va)
#define VNET_HW_INTERFACE_FLAG_SPEED_MASK
vnet_main_t * vnet_get_main(void)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
void vlib_worker_thread_node_runtime_update(void)
vlib_node_function_t * function
#define VLIB_INIT_FUNCTION(x)
static u32 vnet_create_sw_interface_no_callbacks(vnet_main_t *vnm, vnet_sw_interface_t *template)
static vnet_device_class_t * vnet_get_device_class(vnet_main_t *vnm, u32 dev_class_index)
vlib_combined_counter_main_t * combined_sw_if_counters
#define hash_foreach(key_var, value_var, h, body)
void * vnet_interface_output_node_no_flatten_multiarch_select(void)
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * call_hw_interface_add_del_callbacks(vnet_main_t *vnm, u32 hw_if_index, u32 is_create)
#define vec_end(v)
End (last data address) of vector.
#define vlib_call_init_function(vm, x)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
_vnet_interface_function_list_elt_t * hw_interface_link_up_down_functions
#define hash_create_string(elts, value_bytes)
char * name
The counter collection's name.
uword * hw_interface_by_name
void vlib_node_rename(vlib_main_t *vm, u32 node_index, char *fmt,...)
vnet_hw_interface_t * hw_interfaces
#define hash_create_mem(elts, key_bytes, value_bytes)
format_function_t format_vnet_sw_interface_name
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread u16 counters, and the shared vlib_counter_t...
u8 * format_vnet_interface_output_trace(u8 *s, va_list *va)
#define hash_unset_mem(h, key)
#define VNET_SW_INTERFACE_FLAG_BOND_SLAVE
#define pool_put(P, E)
Free an object E in pool P.
static void serialize_vec_vnet_sw_hw_interface_state(serialize_main_t *m, va_list *va)
uword * sw_if_index_by_sup_and_sub
static void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
Get node runtime private data by node index.
static void unserialize_vnet_hw_interface_set_class(serialize_main_t *m, va_list *va)
vlib_simple_counter_main_t * sw_if_counters
word vnet_hw_interface_compare(vnet_main_t *vnm, uword hw_if_index0, uword hw_if_index1)
format_function_t * format_buffer
uword * hw_interface_class_by_name
void unserialize_cstring(serialize_main_t *m, char **s)
void unserialize_vnet_interface_state(serialize_main_t *m, va_list *va)
clib_error_t * vnet_rename_interface(vnet_main_t *vnm, u32 hw_if_index, char *new_name)
_vnet_interface_function_list_elt_t * sw_interface_add_del_functions
_vnet_interface_function_list_elt_t * hw_interface_add_del_functions
clib_error_t * serialize(serialize_main_t *m,...)
#define vec_free(V)
Free vector's memory (no header).
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
unformat_function_t * unformat_buffer
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
static void unserialize_integer(serialize_main_t *m, void *x, u32 n_bytes)
static void serialize_integer(serialize_main_t *m, u64 x, u32 n_bytes)
static clib_error_t * call_sw_interface_add_del_callbacks(vnet_main_t *vnm, u32 sw_if_index, u32 is_create)
void vnet_hw_interface_init_for_class(vnet_main_t *vnm, u32 hw_if_index, u32 hw_class_index, u32 hw_instance)
static void setup_output_node(vlib_main_t *vm, u32 node_index, vnet_hw_interface_class_t *hw_class)
format_function_t format_vnet_sw_interface_flags
static void unserialize_vnet_sw_interface_set_flags(serialize_main_t *m, va_list *va)
#define VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE
static clib_error_t * vnet_sw_interface_set_flags_helper(vnet_main_t *vnm, u32 sw_if_index, u32 flags, u32 helper_flags)
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
void vlib_validate_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
validate a simple counter
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
u32 max_l3_packet_bytes[VLIB_N_RX_TX]
static void serialize_vnet_sw_hw_interface_set_flags(serialize_main_t *m, va_list *va)
#define VNET_SW_INTERFACE_FLAG_PUNT
static void setup_tx_node(vlib_main_t *vm, u32 node_index, vnet_device_class_t *dev_class)
static vnet_hw_interface_class_t * vnet_get_hw_interface_class(vnet_main_t *vnm, u32 hw_class_index)
clib_error_t * unserialize(serialize_main_t *m,...)
static clib_error_t * call_elf_section_interface_callbacks(vnet_main_t *vnm, u32 if_index, u32 flags, _vnet_interface_function_list_elt_t *elt)
static void vlib_zero_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
Clear a simple counter Clears the set of per-thread u16 counters, and the u64 counter.
#define vec_cmp(v1, v2)
Compare two vectors (only applicable to vectors of signed numbers).
uword * device_class_by_name
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
void serialize_cstring(serialize_main_t *m, char *s)
#define VLIB_NODE_FLAG_IS_OUTPUT
#define hash_create_vec(elts, key_bytes, value_bytes)
struct _vnet_hw_interface_class vnet_hw_interface_class_t
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * vnet_interface_init(vlib_main_t *vm)
static clib_error_t * vnet_interface_cli_init(vlib_main_t *vm)
static int vnet_hw_interface_rx_redirect_to_node_helper(vnet_main_t *vnm, u32 hw_if_index, u32 node_index, u32 redistribute)
vnet_sw_interface_t * sw_interfaces
vnet_hw_interface_class_t * hw_interface_class_registrations
char * name
The counter collection's name.
u32 output_feature_bitmap
vnet_hw_interface_class_t * hw_interface_classes
u32 opaque[8]
Opaque data used by sub-graphs for their own purposes.
static void * clib_mem_alloc_aligned(uword size, uword align)
static void serialize_vnet_hw_interface_set_class(serialize_main_t *m, va_list *va)
#define foreach_intf_output_feat
vnet_sw_interface_type_t type
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.
void vnet_delete_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
vnet_device_class_t * device_classes
u32 per_packet_overhead_bytes
#define clib_error_return(e, args...)
clib_error_t * vnet_create_sw_interface(vnet_main_t *vnm, vnet_sw_interface_t *template, u32 *sw_if_index)
#define foreach_buffer_opaque_union_subtype
uword vlib_node_add_named_next_with_slot(vlib_main_t *vm, uword node, char *name, uword slot)
#define CLIB_CACHE_LINE_BYTES
#define VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE
clib_error_t * vnet_hw_interface_set_class(vnet_main_t *vnm, u32 hw_if_index, u32 hw_class_index)