FD.io VPP  v17.01-9-ge7dcee4
Vector Packet Processing
ethernet.h File Reference
+ Include dependency graph for ethernet.h:

Go to the source code of this file.

Data Structures

struct  ethernet_max_header_t
 
struct  ethernet_interface
 
struct  ethernet_type_info_t
 
struct  subint_config_t
 
struct  main_intf_t
 
struct  vlan_intf_t
 
struct  vlan_table_t
 
struct  qinq_intf_t
 
struct  qinq_table_t
 
struct  next_by_ethertype_t
 
struct  ethernet_main_t
 

Macros

#define ETHERNET_MIN_PACKET_BYTES   64
 
#define ETHERNET_MAX_PACKET_BYTES   9216
 
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL   (1 << 0)
 
#define ETHERNET_INTERFACE_FLAG_CONFIG_PROMISC(flags)   (((flags) & ~ETHERNET_INTERFACE_FLAG_ACCEPT_ALL) == 0)
 
#define ETHERNET_INTERFACE_FLAG_MTU   (1 << 1)
 
#define ETHERNET_INTERFACE_FLAG_CONFIG_MTU(flags)   ((flags) & ETHERNET_INTERFACE_FLAG_MTU)
 
#define ethernet_error(n, c, s)   ETHERNET_ERROR_##n,
 
#define SUBINT_CONFIG_MATCH_0_TAG   (1<<0)
 
#define SUBINT_CONFIG_MATCH_1_TAG   (1<<1)
 
#define SUBINT_CONFIG_MATCH_2_TAG   (1<<2)
 
#define SUBINT_CONFIG_MATCH_3_TAG   (1<<3)
 
#define SUBINT_CONFIG_VALID   (1<<4)
 
#define SUBINT_CONFIG_L2   (1<<5)
 
#define ethernet_buffer_get_vlan_count(b)
 Returns the number of VLAN headers in the current Ethernet frame in the buffer. More...
 
#define ethernet_buffer_set_vlan_count(b, v)
 Sets the number of VLAN headers in the current Ethernet frame in the buffer. More...
 
#define ethernet_buffer_adjust_vlan_count(b, v)
 Adjusts the vlan count by the delta in 'v'. More...
 
#define ethernet_buffer_adjust_vlan_count_by_bytes(b, v)
 Adjusts the vlan count by the header size byte delta in 'v'. More...
 
#define ethernet_buffer_header_size(b)
 Determine the size of the Ethernet headers of the current frame in the buffer. More...
 

Typedefs

typedef u32ethernet_flag_change_function_t) (vnet_main_t *vnm, struct vnet_hw_interface_t *hi, u32 flags)
 
typedef struct ethernet_interface ethernet_interface_t
 

Enumerations

enum  ethernet_error_t { ethernet_error, ethernet_error }
 

Functions

static u64 ethernet_mac_address_u64 (u8 *a)
 
static int ethernet_mac_address_is_multicast_u64 (u64 a)
 
static_always_inline int ethernet_frame_is_tagged (u16 type)
 
static u32 eth_create_valid_subint_match_flags (u32 num_tags)
 
static ethernet_type_info_tethernet_get_type_info (ethernet_main_t *em, ethernet_type_t type)
 
ethernet_interface_tethernet_get_interface (ethernet_main_t *em, u32 hw_if_index)
 
clib_error_tethernet_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)
 
void ethernet_delete_interface (vnet_main_t *vnm, u32 hw_if_index)
 
void ethernet_register_input_type (vlib_main_t *vm, ethernet_type_t type, u32 node_index)
 
void ethernet_register_l2_input (vlib_main_t *vm, u32 node_index)
 
void ethernet_register_l3_redirect (vlib_main_t *vm, u32 node_index)
 
u8format_ethernet_address (u8 *s, va_list *args)
 
u8format_ethernet_type (u8 *s, va_list *args)
 
u8format_ethernet_vlan_tci (u8 *s, va_list *va)
 
u8format_ethernet_header (u8 *s, va_list *args)
 
u8format_ethernet_header_with_length (u8 *s, va_list *args)
 
uword unformat_ethernet_address (unformat_input_t *input, va_list *args)
 
uword unformat_ethernet_type_host_byte_order (unformat_input_t *input, va_list *args)
 
uword unformat_ethernet_type_net_byte_order (unformat_input_t *input, va_list *args)
 
uword unformat_ethernet_header (unformat_input_t *input, va_list *args)
 
uword unformat_ethernet_interface (unformat_input_t *input, va_list *args)
 
uword unformat_pg_ethernet_header (unformat_input_t *input, va_list *args)
 
static void ethernet_setup_node (vlib_main_t *vm, u32 node_index)
 
static ethernet_header_tethernet_buffer_get_header (vlib_buffer_t *b)
 
ethernet_main_tethernet_get_main (vlib_main_t *vm)
 
u32 ethernet_set_flags (vnet_main_t *vnm, u32 hw_if_index, u32 flags)
 
void ethernet_sw_interface_set_l2_mode (vnet_main_t *vnm, u32 sw_if_index, u32 l2)
 
void ethernet_sw_interface_set_l2_mode_noport (vnet_main_t *vnm, u32 sw_if_index, u32 l2)
 
void ethernet_set_rx_redirect (vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 enable)
 
int vnet_arp_set_ip4_over_ethernet (vnet_main_t *vnm, u32 sw_if_index, void *a_arg, int is_static)
 
int vnet_arp_unset_ip4_over_ethernet (vnet_main_t *vnm, u32 sw_if_index, void *a_arg)
 Control Plane hook to remove an ARP entry. More...
 
int vnet_proxy_arp_fib_reset (u32 fib_id)
 
clib_error_tnext_by_ethertype_init (next_by_ethertype_t *l3_next)
 
clib_error_tnext_by_ethertype_register (next_by_ethertype_t *l3_next, u32 ethertype, u32 next_index)
 
int vnet_create_loopback_interface (u32 *sw_if_indexp, u8 *mac_address)
 
int vnet_delete_loopback_interface (u32 sw_if_index)
 
int vnet_delete_sub_interface (u32 sw_if_index)
 
static void eth_vlan_table_lookups (ethernet_main_t *em, vnet_main_t *vnm, u32 port_sw_if_index0, u16 first_ethertype, u16 outer_id, u16 inner_id, vnet_hw_interface_t **hi, main_intf_t **main_intf, vlan_intf_t **vlan_intf, qinq_intf_t **qinq_intf)
 
static u32 eth_identify_subint (vnet_hw_interface_t *hi, vlib_buffer_t *b0, u32 match_flags, main_intf_t *main_intf, vlan_intf_t *vlan_intf, qinq_intf_t *qinq_intf, u32 *new_sw_if_index, u8 *error0, u32 *is_l2)
 
static u32 eth_mac_equal (u8 *mac1, u8 *mac2)
 
static ethernet_main_tvnet_get_ethernet_main (void)
 
void vnet_register_ip4_arp_resolution_event (vnet_main_t *vnm, void *address_arg, uword node_index, uword type_opaque, uword data)
 
int vnet_add_del_ip4_arp_change_event (vnet_main_t *vnm, void *data_callback, u32 pid, void *address_arg, uword node_index, uword type_opaque, uword data, int is_add)
 
void ethernet_arp_change_mac (u32 sw_if_index)
 
void ethernet_ndp_change_mac (u32 sw_if_index)
 
void arp_update_adjacency (vnet_main_t *vnm, u32 sw_if_index, u32 ai)
 
void ethernet_update_adjacency (vnet_main_t *vnm, u32 sw_if_index, u32 ai)
 
u8ethernet_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' More...
 

Variables

vnet_hw_interface_class_t ethernet_hw_interface_class
 
ethernet_main_t ethernet_main
 
vlib_node_registration_t ethernet_input_node
 (constructor) VLIB_REGISTER_NODE (ethernet_input_node) More...
 

Macro Definition Documentation

#define ethernet_buffer_adjust_vlan_count (   b,
  v 
)
Value:
( \
)
#define ethernet_buffer_get_vlan_count(b)
Returns the number of VLAN headers in the current Ethernet frame in the buffer.
Definition: ethernet.h:352
#define v
Definition: acl.c:314
#define ethernet_buffer_set_vlan_count(b, v)
Sets the number of VLAN headers in the current Ethernet frame in the buffer.
Definition: ethernet.h:360
i64 word
Definition: types.h:111

Adjusts the vlan count by the delta in 'v'.

Definition at line 366 of file ethernet.h.

#define ethernet_buffer_adjust_vlan_count_by_bytes (   b,
  v 
)
Value:
( \
(b)->flags = ((b)->flags & ~ETH_BUFFER_VLAN_BITS) | (( \
)
#define v
Definition: acl.c:314
#define LOG2_ETH_BUFFER_VLAN_1_DEEP
Definition: buffer.h:58
u32 flags
Definition: vhost-user.h:75
#define ETH_BUFFER_VLAN_BITS
Definition: buffer.h:61

Adjusts the vlan count by the header size byte delta in 'v'.

Definition at line 372 of file ethernet.h.

#define ethernet_buffer_get_vlan_count (   b)
Value:
( \
)
#define LOG2_ETH_BUFFER_VLAN_1_DEEP
Definition: buffer.h:58
u32 flags
Definition: vhost-user.h:75
#define ETH_BUFFER_VLAN_BITS
Definition: buffer.h:61

Returns the number of VLAN headers in the current Ethernet frame in the buffer.

Returns 0, 1, 2 for the known header count. The value 3 indicates the number of headers is not known.

Definition at line 352 of file ethernet.h.

#define ethernet_buffer_header_size (   b)
Value:
( \
)
#define ethernet_buffer_get_vlan_count(b)
Returns the number of VLAN headers in the current Ethernet frame in the buffer.
Definition: ethernet.h:352

Determine the size of the Ethernet headers of the current frame in the buffer.

This uses the VLAN depth flags that are set by ethernet-input. Because these flags are stored in the vlib_buffer_t "flags" field this count is valid regardless of the node so long as it's checked downstream of ethernet-input; That is, the value is not stored in the opaque space.

Definition at line 387 of file ethernet.h.

#define ethernet_buffer_set_vlan_count (   b,
  v 
)
Value:
( \
(b)->flags = ((b)->flags & ~ETH_BUFFER_VLAN_BITS) | \
)
#define v
Definition: acl.c:314
#define LOG2_ETH_BUFFER_VLAN_1_DEEP
Definition: buffer.h:58
u32 flags
Definition: vhost-user.h:75
#define ETH_BUFFER_VLAN_BITS
Definition: buffer.h:61

Sets the number of VLAN headers in the current Ethernet frame in the buffer.

Values 0, 1, 2 indicate the header count. The value 3 indicates the number of headers is not known.

Definition at line 360 of file ethernet.h.

#define ethernet_error (   n,
  c,
 
)    ETHERNET_ERROR_##n,

Definition at line 150 of file ethernet.h.

#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL   (1 << 0)

Definition at line 113 of file ethernet.h.

#define ETHERNET_INTERFACE_FLAG_CONFIG_MTU (   flags)    ((flags) & ETHERNET_INTERFACE_FLAG_MTU)

Definition at line 119 of file ethernet.h.

#define ETHERNET_INTERFACE_FLAG_CONFIG_PROMISC (   flags)    (((flags) & ~ETHERNET_INTERFACE_FLAG_ACCEPT_ALL) == 0)

Definition at line 114 of file ethernet.h.

#define ETHERNET_INTERFACE_FLAG_MTU   (1 << 1)

Definition at line 118 of file ethernet.h.

#define ETHERNET_MAX_PACKET_BYTES   9216

Definition at line 106 of file ethernet.h.

#define ETHERNET_MIN_PACKET_BYTES   64

Definition at line 105 of file ethernet.h.

#define SUBINT_CONFIG_L2   (1<<5)

Definition at line 171 of file ethernet.h.

#define SUBINT_CONFIG_MATCH_0_TAG   (1<<0)

Definition at line 166 of file ethernet.h.

#define SUBINT_CONFIG_MATCH_1_TAG   (1<<1)

Definition at line 167 of file ethernet.h.

#define SUBINT_CONFIG_MATCH_2_TAG   (1<<2)

Definition at line 168 of file ethernet.h.

#define SUBINT_CONFIG_MATCH_3_TAG   (1<<3)

Definition at line 169 of file ethernet.h.

#define SUBINT_CONFIG_VALID   (1<<4)

Definition at line 170 of file ethernet.h.

Typedef Documentation

typedef u32( ethernet_flag_change_function_t) (vnet_main_t *vnm, struct vnet_hw_interface_t *hi, u32 flags)

Definition at line 103 of file ethernet.h.

Enumeration Type Documentation

Enumerator
ethernet_error 
ethernet_error 

Definition at line 148 of file ethernet.h.

Function Documentation

void arp_update_adjacency ( vnet_main_t vnm,
u32  sw_if_index,
u32  ai 
)

Definition at line 428 of file arp.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 eth_create_valid_subint_match_flags ( u32  num_tags)
inlinestatic

Definition at line 176 of file ethernet.h.

+ Here is the caller graph for this function:

static u32 eth_identify_subint ( vnet_hw_interface_t hi,
vlib_buffer_t b0,
u32  match_flags,
main_intf_t main_intf,
vlan_intf_t vlan_intf,
qinq_intf_t qinq_intf,
u32 new_sw_if_index,
u8 error0,
u32 is_l2 
)
inlinestatic

Definition at line 462 of file ethernet.h.

+ Here is the caller graph for this function:

static u32 eth_mac_equal ( u8 mac1,
u8 mac2 
)
inlinestatic

Definition at line 514 of file ethernet.h.

+ Here is the caller graph for this function:

static void eth_vlan_table_lookups ( ethernet_main_t em,
vnet_main_t vnm,
u32  port_sw_if_index0,
u16  first_ethertype,
u16  outer_id,
u16  inner_id,
vnet_hw_interface_t **  hi,
main_intf_t **  main_intf,
vlan_intf_t **  vlan_intf,
qinq_intf_t **  qinq_intf 
)
inlinestatic

Definition at line 423 of file ethernet.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ethernet_arp_change_mac ( u32  sw_if_index)

Definition at line 2349 of file arp.c.

+ Here is the caller graph for this function:

static ethernet_header_t* ethernet_buffer_get_header ( vlib_buffer_t b)
inlinestatic

Definition at line 342 of file ethernet.h.

+ Here is the caller graph for this function:

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'

Definition at line 59 of file interface.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ethernet_delete_interface ( vnet_main_t vnm,
u32  hw_if_index 
)

Definition at line 275 of file interface.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static_always_inline int ethernet_frame_is_tagged ( u16  type)

Definition at line 65 of file ethernet.h.

+ Here is the caller graph for this function:

ethernet_interface_t* ethernet_get_interface ( ethernet_main_t em,
u32  hw_if_index 
)

Definition at line 563 of file interface.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ethernet_main_t* ethernet_get_main ( vlib_main_t vm)

Definition at line 116 of file init.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ethernet_type_info_t* ethernet_get_type_info ( ethernet_main_t em,
ethernet_type_t  type 
)
inlinestatic

Definition at line 273 of file ethernet.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int ethernet_mac_address_is_multicast_u64 ( u64  a)
inlinestatic

Definition at line 59 of file ethernet.h.

static u64 ethernet_mac_address_u64 ( u8 a)
inlinestatic

Definition at line 49 of file ethernet.h.

void ethernet_ndp_change_mac ( u32  sw_if_index)

Definition at line 4055 of file ip6_neighbor.c.

+ Here is the caller graph for this function:

void ethernet_register_input_type ( vlib_main_t vm,
ethernet_type_t  type,
u32  node_index 
)

Definition at line 1282 of file node.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 226 of file interface.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ethernet_register_l2_input ( vlib_main_t vm,
u32  node_index 
)

Definition at line 1313 of file node.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ethernet_register_l3_redirect ( vlib_main_t vm,
u32  node_index 
)

Definition at line 1334 of file node.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 ethernet_set_flags ( vnet_main_t vnm,
u32  hw_if_index,
u32  flags 
)

Definition at line 319 of file interface.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ethernet_set_rx_redirect ( vnet_main_t vnm,
vnet_hw_interface_t hi,
u32  enable 
)

+ Here is the caller graph for this function:

static void ethernet_setup_node ( vlib_main_t vm,
u32  node_index 
)
inlinestatic

Definition at line 331 of file ethernet.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ethernet_sw_interface_set_l2_mode ( vnet_main_t vnm,
u32  sw_if_index,
u32  l2 
)

Definition at line 954 of file node.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ethernet_sw_interface_set_l2_mode_noport ( vnet_main_t vnm,
u32  sw_if_index,
u32  l2 
)

Definition at line 1003 of file node.c.

+ Here is the call graph for this function:

void ethernet_update_adjacency ( vnet_main_t vnm,
u32  sw_if_index,
u32  ai 
)

Definition at line 151 of file interface.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_ethernet_address ( u8 s,
va_list *  args 
)

Definition at line 44 of file format.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_ethernet_header ( u8 s,
va_list *  args 
)

Definition at line 190 of file format.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_ethernet_header_with_length ( u8 s,
va_list *  args 
)

Definition at line 115 of file format.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_ethernet_type ( u8 s,
va_list *  args 
)

Definition at line 58 of file format.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_ethernet_vlan_tci ( u8 s,
va_list *  va 
)

Definition at line 73 of file format.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

clib_error_t* next_by_ethertype_init ( next_by_ethertype_t l3_next)

Definition at line 1177 of file node.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

clib_error_t* next_by_ethertype_register ( next_by_ethertype_t l3_next,
u32  ethertype,
u32  next_index 
)

Definition at line 1207 of file node.c.

+ Here is the caller graph for this function:

uword unformat_ethernet_address ( unformat_input_t input,
va_list *  args 
)

Definition at line 245 of file format.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uword unformat_ethernet_header ( unformat_input_t input,
va_list *  args 
)

Definition at line 295 of file format.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uword unformat_ethernet_interface ( unformat_input_t input,
va_list *  args 
)

Definition at line 205 of file interface.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uword unformat_ethernet_type_host_byte_order ( unformat_input_t input,
va_list *  args 
)

Definition at line 254 of file format.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uword unformat_ethernet_type_net_byte_order ( unformat_input_t input,
va_list *  args 
)

Definition at line 283 of file format.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uword unformat_pg_ethernet_header ( unformat_input_t input,
va_list *  args 
)

Definition at line 82 of file pg.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int vnet_add_del_ip4_arp_change_event ( vnet_main_t vnm,
void *  data_callback,
u32  pid,
void *  address_arg,
uword  node_index,
uword  type_opaque,
uword  data,
int  is_add 
)

Definition at line 649 of file arp.c.

+ Here is the caller graph for this function:

int vnet_arp_set_ip4_over_ethernet ( vnet_main_t vnm,
u32  sw_if_index,
void *  a_arg,
int  is_static 
)

Definition at line 1785 of file arp.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int vnet_arp_unset_ip4_over_ethernet ( vnet_main_t vnm,
u32  sw_if_index,
void *  a_arg 
)

Control Plane hook to remove an ARP entry.

Definition at line 1441 of file arp.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int vnet_create_loopback_interface ( u32 sw_if_indexp,
u8 mac_address 
)

Definition at line 437 of file interface.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int vnet_delete_loopback_interface ( u32  sw_if_index)

Definition at line 573 of file interface.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int vnet_delete_sub_interface ( u32  sw_if_index)

Definition at line 588 of file interface.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ethernet_main_t* vnet_get_ethernet_main ( void  )
inlinestatic

Definition at line 522 of file ethernet.h.

+ Here is the call graph for this function:

int vnet_proxy_arp_fib_reset ( u32  fib_id)

Definition at line 1843 of file arp.c.

void vnet_register_ip4_arp_resolution_event ( vnet_main_t vnm,
void *  address_arg,
uword  node_index,
uword  type_opaque,
uword  data 
)

Definition at line 618 of file arp.c.

+ Here is the caller graph for this function:

Variable Documentation

vnet_hw_interface_class_t ethernet_hw_interface_class
vlib_node_registration_t ethernet_input_node
Initial value:
= {
.function = ethernet_input,
.name = "ethernet-input",
.vector_size = sizeof (u32),
.n_errors = ETHERNET_N_ERROR,
.error_strings = ethernet_error_strings,
.n_next_nodes = ETHERNET_INPUT_N_NEXT,
.next_nodes = {
#define _(s,n)
},
.format_trace = format_ethernet_input_trace,
.unformat_buffer = unformat_ethernet_header,
}
static u8 * format_ethernet_input_trace(u8 *s, va_list *va)
Definition: node.c:66
#define foreach_ethernet_input_next
Definition: node.c:47
static uword ethernet_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: node.c:734
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
Definition: format.c:115
static char * ethernet_error_strings[]
Definition: node.c:1090
unsigned int u32
Definition: types.h:88
uword unformat_ethernet_header(unformat_input_t *input, va_list *args)
Definition: format.c:295

(constructor) VLIB_REGISTER_NODE (ethernet_input_node)

Definition at line 1097 of file node.c.

ethernet_main_t ethernet_main

Definition at line 270 of file ethernet.h.