58 const static u8 ethernet_mcast_dst_mac[] = {
59 0x1, 0x0, 0x5e, 0x0, 0x0, 0x0,
62 return (ethernet_mcast_dst_mac);
68 const static u8 ethernet_mcast_dst_mac[] = {
69 0x33, 0x33, 0x00, 0x0, 0x0, 0x0,
72 return (ethernet_mcast_dst_mac);
91 uword n_bytes =
sizeof (h[0]);
131 #define _(a,b) case VNET_LINK_##a: type = ETHERNET_TYPE_##b; break 163 clib_host_to_net_u16 (ETHERNET_TYPE_DOT1AD) :
164 clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
167 outer->
type = clib_host_to_net_u16 (type);
176 clib_host_to_net_u16 (ETHERNET_TYPE_DOT1AD) :
177 clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
180 outer->
type = clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
183 inner->
type = clib_host_to_net_u16 (type);
188 h->
type = clib_host_to_net_u16 (type);
259 u32 *result = va_arg (*args,
u32 *);
270 *result = hw_if_index;
281 u32 * hw_if_index_return,
295 dev_class_index, dev_instance,
297 *hw_if_index_return = hw_if_index;
396 u32 n_left_from, *from;
405 u32 new_rx_sw_if_index = ~0;
406 u32 new_tx_sw_if_index = ~0;
423 while (n_left_from >= 4)
425 u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
426 u32 not_all_match_config;
443 not_all_match_config = (sw_if_index0 ^ sw_if_index1)
444 ^ (sw_if_index2 ^ sw_if_index3);
445 not_all_match_config += sw_if_index0 ^ new_rx_sw_if_index;
450 next[0] = next_index;
451 next[1] = next_index;
452 next[2] = next_index;
453 next[3] = next_index;
478 thread_index, new_rx_sw_if_index,
496 != new_rx_sw_if_index))
506 next[0] = next_index;
515 thread_index, new_rx_sw_if_index,
519 != new_rx_sw_if_index))
529 next[1] = next_index;
538 thread_index, new_rx_sw_if_index,
542 != new_rx_sw_if_index))
552 next[2] = next_index;
561 thread_index, new_rx_sw_if_index,
565 != new_rx_sw_if_index))
575 next[3] = next_index;
584 thread_index, new_rx_sw_if_index,
590 while (n_left_from > 0)
593 != new_rx_sw_if_index))
603 next[0] = next_index;
612 thread_index, new_rx_sw_if_index,
627 u32 dev_instance = va_arg (*args,
u32);
628 return format (s,
"loop%d", dev_instance);
667 #define LOOPBACK_MAX_INSTANCE (16 * 1024) 738 u8 is_specified,
u32 user_instance)
752 *sw_if_indexp = (
u32) ~ 0;
763 return VNET_API_ERROR_INVALID_REGISTRATION;
771 if (memcmp (address, mac_address,
sizeof (address)))
772 clib_memcpy (address, mac_address,
sizeof (address));
777 address[5] = instance;
782 ethernet_simulated_device_class.index, instance, address, &hw_if_index,
787 rv = VNET_API_ERROR_INVALID_REGISTRATION;
824 u32 user_instance = 0;
826 clib_memset (mac_address, 0,
sizeof (mac_address));
832 if (
unformat (input,
"instance %d", &user_instance))
839 is_specified, user_instance);
862 .path =
"loopback create-interface",
863 .short_help =
"loopback create-interface [mac <mac-addr>] [instance <instance>]",
881 .path =
"create loopback interface",
882 .short_help =
"create loopback interface [mac <mac-addr>] [instance <instance>]",
903 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
906 if (hw == 0 || hw->
dev_class_index != ethernet_simulated_device_class.index)
907 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
910 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
925 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
934 u64 sup_and_sub_key =
941 rv = VNET_API_ERROR_INVALID_SUB_SW_IF_INDEX;
964 if (sw_if_index == ~0)
991 if (sw_if_index == ~0)
995 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
1015 .path =
"loopback delete-interface",
1016 .short_help =
"loopback delete-interface intfc <interface>",
1033 .path =
"delete loopback interface",
1034 .short_help =
"delete loopback interface intfc <interface>",
1048 .path =
"delete sub-interface",
1049 .short_help =
"delete sub-interface <interface>",
unformat_function_t unformat_vnet_hw_interface
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
int vnet_delete_loopback_interface(u32 sw_if_index)
const u8 * ethernet_ip6_mcast_dst_addr(void)
static clib_error_t * delete_simulated_ethernet_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define hash_unset(h, key)
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_interface_main_t interface_main
uword vlib_node_add_named_next_with_slot(vlib_main_t *vm, uword node, char *name, uword slot)
vnet_p2p_sub_interface_t p2p
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
void arp_update_adjacency(vnet_main_t *vnm, u32 sw_if_index, u32 ai)
int vnet_delete_sub_interface(u32 sw_if_index)
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. ...
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
VLIB_DEVICE_TX_FUNCTION_MULTIARCH(ethernet_simulated_device_class, simulated_ethernet_interface_tx)
unformat_function_t unformat_vnet_sw_interface
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
#define VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define clib_memcpy(d, s, n)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
struct vnet_sub_interface_t::@198::@199::@201 flags
ethernet_main_t ethernet_main
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
vnet_flood_class_t flood_class
void default_update_adjacency(vnet_main_t *vnm, u32 sw_if_index, u32 ai)
Default adjacency update function.
u8 * format_ethernet_address(u8 *s, va_list *args)
void ip6_ethernet_update_adjacency(vnet_main_t *vnm, u32 sw_if_index, u32 ai)
vlib_combined_counter_main_t * combined_sw_if_counters
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#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)
#define clib_error_return(e, args...)
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.
static clib_error_t * ethernet_mac_change(vnet_hw_interface_t *hi, const u8 *old_address, const u8 *mac_address)
static u32 loopback_instance_alloc(u8 is_specified, u32 want)
#define LOOPBACK_MAX_INSTANCE
#define pool_put(P, E)
Free an object E in pool P.
uword * sw_if_index_by_sup_and_sub
static int loopback_instance_free(u32 instance)
vl_api_address_union_t src_address
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)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
struct vnet_sub_interface_t::@198 eth
#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.
const u8 * ethernet_ip4_mcast_dst_addr(void)
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
int vnet_create_loopback_interface(u32 *sw_if_indexp, u8 *mac_address, u8 is_specified, u32 user_instance)
#define VLIB_CLI_COMMAND(x,...)
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)
Echo packets back to ethernet/l2-input.
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
#define pool_put_index(p, i)
Free pool element with given index.
void ethernet_ndp_change_mac(u32 sw_if_index)
u32() ethernet_flag_change_function_t(vnet_main_t *vnm, struct vnet_hw_interface_t *hi, u32 flags)
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)
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
#define clib_error_report(e)
vlan_intf_t vlans[ETHERNET_N_VLAN]
uword * bm_loopback_instances
static vlib_main_t * vlib_get_main(void)
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
fib_protocol_t ia_nh_proto
The protocol of the neighbor/peer.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
vnet_sw_interface_t * sw_interfaces
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
u8 * ethernet_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
build a rewrite string to use for sending packets of type 'link_type' to 'dst_address' ...
void vnet_sw_interface_set_mtu(vnet_main_t *vnm, u32 sw_if_index, u32 mtu)
static void hash_unset_mem_free(uword **h, void *key)
u32 min_supported_packet_bytes
vnet_sw_interface_type_t type
#define STRUCT_SIZE_OF(t, f)
#define ETHERNET_MAX_PACKET_BYTES
void vnet_delete_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
VNET_DEVICE_CLASS(ethernet_simulated_device_class)
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
static uword clib_bitmap_first_clear(uword *ai)
Return the lowest numbered clear bit in a bitmap.
ethernet_interface_t * interfaces
#define ETHERNET_MIN_PACKET_BYTES
void ethernet_arp_change_mac(u32 sw_if_index)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
void ethernet_update_adjacency(vnet_main_t *vnm, u32 sw_if_index, u32 ai)
static clib_error_t * delete_sub_interface(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * simulated_ethernet_mac_change(vnet_hw_interface_t *hi, const u8 *old_address, const u8 *mac_address)
static void ethernet_setup_node(vlib_main_t *vm, u32 node_index)
uword unformat_ethernet_header(unformat_input_t *input, va_list *args)