43 #define VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE (1 << 0) 44 #define VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE (1 << 1) 70 for (i = 0; i < n; i++) {
81 for (i = 0; i < n; i++) {
118 .name =
"vnet_sw_interface_set_flags",
124 .name =
"vnet_hw_interface_set_flags",
140 vnet_hw_interface_class_t * hw_class = vnet_get_hw_interface_class (vnm, hif->hw_class_index);
141 serialize_cstring (m, hw_class->name);
148 vec_add2 (sts, st, 1);
149 st->sw_hw_if_index = sif->sw_if_index;
150 st->flags = sif->flags;
162 vec_add2 (sts, st, 1);
163 st->sw_hw_if_index = hif->hw_if_index;
164 st->flags = hif->flags;
187 unserialize_cstring (m, &class_name);
188 p = hash_get_mem (im->hw_interface_class_by_name, class_name);
190 error = vnet_hw_interface_set_class_helper (vnm, hif->hw_if_index, p[0], 0);
192 clib_error_report (error);
193 vec_free (class_name);
213 _vnet_interface_function_list_elt_t *elt)
219 error = elt->fp(vnm, if_index, flags);
222 elt = elt->next_interface_function;
235 if (hw_class->interface_add_del_function
236 && (error = hw_class->interface_add_del_function (vnm, hw_if_index, is_create)))
239 if (dev_class->interface_add_del_function
240 && (error = dev_class->interface_add_del_function (vnm, hw_if_index, is_create)))
256 #define VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE (1 << 0) 257 #define VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE (1 << 1) 280 if (! is_create && (hi->
flags & mask) == flags)
284 if (! dev_class->redistribute)
300 if (hw_class->link_up_down_function
301 && (error = hw_class->link_up_down_function (vnm, hw_if_index,
357 if (flags != (si_sup->
flags & mask))
370 (0,
"not allowed as %U belong to a BondEthernet interface",
376 if ((si->
flags & mask) == flags)
385 if (! dev_class->redistribute)
411 old_flags = si->
flags;
415 si->
flags &= ~VNET_SW_INTERFACE_FLAG_ADMIN_UP;
417 if (dev_class->admin_up_down_function
418 && (error = dev_class->admin_up_down_function(vnm,
423 si->
flags = old_flags;
427 if (hw_class->admin_up_down_function
428 && (error = hw_class->admin_up_down_function(vnm,
433 si->
flags = old_flags;
438 if (! (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
457 (vnm, hw_if_index, flags,
465 (vnm, sw_if_index, flags,
523 dev_class->subif_add_del_function) {
524 error = dev_class->subif_add_del_function (vnm, hi->
hw_if_index,
532 (vnm, *sw_if_index, template->flags,
565 n->
function = dev_class->tx_function;
568 dev_class->tx_function_n_errors,
569 dev_class->tx_function_error_strings);
595 char * tx_node_name, * output_node_name;
602 if (dev_class->format_device_name)
604 dev_class->format_device_name, dev_instance);
605 else if (hw_class->format_interface_name)
606 hw->
name =
format (0,
"%U", hw_class->format_interface_name,
609 hw->
name =
format (0,
"%s%x", hw_class->name, dev_instance);
613 sizeof (hw->
name[0]),
622 memset (&sw, 0,
sizeof (sw));
639 tx_node_name = (
char *)
format (0,
"%v-tx", hw->
name);
640 output_node_name = (
char *)
format (0,
"%v-output", hw->
name);
672 memset (&r, 0,
sizeof (r));
674 r.runtime_data = &rt;
675 r.runtime_data_bytes =
sizeof (rt);
677 r.vector_size =
sizeof (
u32);
680 r.name = tx_node_name;
681 r.function = dev_class->tx_function;
690 r.name = output_node_name;
691 r.function = dev_class->no_flatten_output_chains ?
697 static char * e[] = {
699 "interface is deleted",
708 #define _(sym,str) vlib_node_add_named_next_with_slot (vm, \ 709 hw->output_node_index, str, \ 710 VNET_INTERFACE_OUTPUT_NEXT_##sym); 756 vnet_delete_sw_interface (vnm, sw_if_index);
782 u32 hw_if_index = va_arg (*va,
u32);
783 char * hw_class_name = va_arg (*va,
char *);
793 char * hw_class_name;
807 .name =
"vnet_hw_interface_set_class",
841 return clib_error_return (0,
"%v must be admin down to change class from %s to %s",
842 hi->
name, old_class->name, new_class->name);
845 if ((new_class->is_valid_class_for_interface
846 && ! new_class->is_valid_class_for_interface (vnm, hw_if_index, hw_class_index))
847 || (dev_class ->is_valid_class_for_interface
848 && ! dev_class->is_valid_class_for_interface (vnm, hw_if_index, hw_class_index)))
850 hi->
name, old_class->name, new_class->name);
859 if (old_class->hw_class_change)
860 old_class->hw_class_change (vnm, hw_if_index, old_class->index, new_class->index);
864 if (new_class->hw_class_change)
865 new_class->hw_class_change (vnm, hw_if_index, old_class->index, new_class->index);
867 if (dev_class->hw_class_change)
868 dev_class->hw_class_change (vnm, hw_if_index, new_class->index);
892 if (dev_class->rx_redirect_to_node)
894 dev_class->rx_redirect_to_node (vnm, hw_if_index, node_index);
898 return VNET_API_ERROR_UNIMPLEMENTED;
946 #define _(a) if (sizeof(o->a) > sizeof (o->unused)) \ 948 ("FATAL: size of opaque union subtype %s is %d (max %d)", \ 949 #a, sizeof(o->a), sizeof (o->unused)); 954 (0,
"FATAL: size of vlib buffer opaque %d, size of vnet opaque %d",
992 c = c->next_class_registration;
1011 c = c->next_class_registration;
1038 if (dev_class->name_renumber == 0 || dev_class->format_device_name == 0)
1039 return VNET_API_ERROR_UNIMPLEMENTED;
1041 rv = dev_class->name_renumber (hi, new_show_dev_instance);
1049 hi->
name =
format (0,
"%U", dev_class->format_device_name,
1096 "unable to find hw interface for index %u",
1100 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)
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)
always_inline vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
vnet_interface_main_t interface_main
always_inline vnet_hw_interface_class_t * vnet_get_hw_interface_class(vnet_main_t *vnm, u32 hw_class_index)
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
#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)
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...)
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)
uword vnet_interface_output_node(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define VLIB_INIT_FUNCTION(x)
static u32 vnet_create_sw_interface_no_callbacks(vnet_main_t *vnm, vnet_sw_interface_t *template)
vlib_combined_counter_main_t * combined_sw_if_counters
always_inline void unserialize_integer(serialize_main_t *m, void *x, u32 n_bytes)
#define hash_foreach(key_var, value_var, h, body)
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)
uword * hw_interface_by_name
always_inline void * clib_mem_alloc_aligned(uword size, uword align)
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)
u8 * format_vnet_interface_output_trace(u8 *s, va_list *va)
#define hash_unset_mem(h, key)
#define VNET_SW_INTERFACE_FLAG_BOND_SLAVE
static void serialize_vec_vnet_sw_hw_interface_state(serialize_main_t *m, va_list *va)
uword * sw_if_index_by_sup_and_sub
always_inline vnet_device_class_t * vnet_get_device_class(vnet_main_t *vnm, u32 dev_class_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).
uword vnet_interface_output_node_no_flatten(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
unformat_function_t * unformat_buffer
always_inline vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
always_inline 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)
always_inline vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
always_inline vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
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)
#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)
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)
#define vec_cmp(v1, v2)
Compare two vectors (only applicable to vectors of signed numbers).
uword * device_class_by_name
always_inline void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
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)
always_inline void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
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)
always_inline vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
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
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.
always_inline void vlib_zero_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
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
#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)