58 void *rewrite,
uword max_rewrite_bytes)
67 uword n_bytes =
sizeof (h[0]);
89 if (n_bytes > max_rewrite_bytes)
94 #define _(a,b) case VNET_L3_PACKET_TYPE_##a: type = ETHERNET_TYPE_##b; break 97 _(MPLS_UNICAST, MPLS_UNICAST);
98 _(MPLS_MULTICAST, MPLS_MULTICAST);
117 clib_host_to_net_u16 (ETHERNET_TYPE_DOT1AD) :
118 clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
121 outer->
type = clib_host_to_net_u16 (type);
130 clib_host_to_net_u16 (ETHERNET_TYPE_DOT1AD) :
131 clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
134 outer->
type = clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
137 inner->
type = clib_host_to_net_u16 (type);
142 h->
type = clib_host_to_net_u16 (type);
163 u32 *result = va_arg (*args,
u32 *);
174 *result = hw_if_index;
185 u32 * hw_if_index_return,
199 dev_class_index, dev_instance,
201 *hw_if_index_return = hw_if_index;
296 u32 n_left_from, n_left_to_next, n_copy, *from, *to_next;
298 u32 i, next_node_index, bvi_flag, sw_if_index;
299 u32 n_pkts = 0, n_bytes = 0;
311 next_node_index = loop_node->
next_nodes[next_index];
312 bvi_flag = (next_node_index ==
l2input_node.index) ? 1 : 0;
317 while (n_left_from > 0)
321 n_copy =
clib_min (n_left_from, n_left_to_next);
323 clib_memcpy (to_next, from, n_copy *
sizeof (from[0]));
324 n_left_to_next -= n_copy;
325 n_left_from -= n_copy;
355 sw_if_index, n_pkts, n_bytes);
364 u32 dev_instance = va_arg (*args,
u32);
365 return format (s,
"loop%d", dev_instance);
384 .no_flatten_output_chains = 1,
403 *sw_if_indexp = (
u32) ~ 0;
405 memset (address, 0,
sizeof (address));
412 if (memcmp (address, mac_address,
sizeof (address)))
413 clib_memcpy (address, mac_address,
sizeof (address));
418 address[5] = instance;
423 ethernet_simulated_device_class.index, instance++, address, &hw_if_index,
428 rv = VNET_API_ERROR_INVALID_REGISTRATION;
456 memset (mac_address, 0,
sizeof (mac_address));
489 .path =
"loopback create-interface",
490 .short_help =
"loopback create-interface [mac <mac-addr>]",
508 .path =
"create loopback interface",
509 .short_help =
"create loopback interface [mac <mac-addr>]",
531 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
545 u32 sw_if_index = ~0;
557 if (sw_if_index == ~0)
580 .path =
"loopback delete-interface",
581 .short_help =
"loopback delete-interface intfc <interface>",
598 .path =
"delete loopback interface",
599 .short_help =
"delete loopback interface intfc <interface>",
unformat_function_t unformat_vnet_hw_interface
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
int vnet_delete_loopback_interface(u32 sw_if_index)
sll srl srl sll sra u16x4 i
static clib_error_t * delete_simulated_ethernet_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static vlib_main_t * vlib_get_main(void)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_interface_main_t interface_main
static uword ethernet_set_rewrite(vnet_main_t *vnm, u32 sw_if_index, u32 l3_type, void *dst_address, void *rewrite, uword max_rewrite_bytes)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
struct vnet_sub_interface_t::@120::@121::@123 flags
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
#define clib_error_report(e)
#define VNET_HW_INTERFACE_FLAG_LINK_UP
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
format_function_t format_vnet_sw_if_index_name
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
ethernet_main_t ethernet_main
vnet_main_t * vnet_get_main(void)
u8 * format_ethernet_address(u8 *s, va_list *args)
vlib_combined_counter_main_t * combined_sw_if_counters
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
ethernet_flag_change_function_t * flag_change
static clib_error_t * simulated_ethernet_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
u32 max_supported_packet_bytes
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define pool_put(P, E)
Free an object E in pool P.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vnet_hw_interface_class_t ethernet_hw_interface_class
uword unformat_ethernet_interface(unformat_input_t *input, va_list *args)
static clib_error_t * create_simulated_ethernet_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
VNET_HW_INTERFACE_CLASS(ethernet_hw_interface_class)
#define vec_free(V)
Free vector's memory (no header).
#define clib_memcpy(a, b, c)
#define VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
int vnet_create_loopback_interface(u32 *sw_if_indexp, u8 *mac_address)
struct vnet_sub_interface_t::@120 eth
static u8 * format_simulated_ethernet_name(u8 *s, va_list *args)
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
static uword simulated_ethernet_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
u32 max_l3_packet_bytes[VLIB_N_RX_TX]
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u32 packet_increment, u32 byte_increment)
Increment a combined counter.
#define pool_put_index(p, i)
Free pool element with given index.
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
u32( ethernet_flag_change_function_t)(vnet_main_t *vnm, struct vnet_hw_interface_t *hi, u32 flags)
static void * vlib_frame_args(vlib_frame_t *f)
Get pointer to frame scalar data.
vlan_intf_t vlans[ETHERNET_N_VLAN]
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_elt(v, i)
Get vector value at index i.
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
vlib_node_main_t node_main
vnet_sw_interface_t * sw_interfaces
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
u32 min_supported_packet_bytes
#define ETHERNET_MAX_PACKET_BYTES
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
u32 per_packet_overhead_bytes
#define clib_error_return(e, args...)
VNET_DEVICE_CLASS(ethernet_simulated_device_class)
uword vlib_node_add_named_next_with_slot(vlib_main_t *vm, uword node, char *name, uword slot)
ethernet_interface_t * interfaces
#define ETHERNET_MIN_PACKET_BYTES
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static void ethernet_setup_node(vlib_main_t *vm, u32 node_index)
uword unformat_ethernet_header(unformat_input_t *input, va_list *args)