|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
31 #define foreach_bond_tx_error \
32 _ (NONE, "no error") \
33 _ (IF_DOWN, "interface down") \
34 _ (BAD_LB_MODE, "bad load balance mode") \
35 _ (NO_MEMBER, "no member")
39 #define _(f,s) BOND_TX_ERROR_##f,
62 s =
format (s,
"src %U, dst %U, %s -> %s",
70 #ifndef CLIB_MARCH_VARIANT
78 s =
format (s,
"BondEthernet%lu", bif->
id);
97 if ((bif_hw->
l2_if_count == 1) && (l2_if_adjust == 1))
107 else if ((bif_hw->
l2_if_count == 0) && (l2_if_adjust == -1))
159 "No bond interface found for sw_if_index %u",
175 for (j =
i - 1; j > -1; j--)
242 ethertype_p = ð->
type;
246 vlan = (
void *) (eth + 1);
247 ethertype_p = &vlan->
type;
248 if (*ethertype_p ==
ntohs (ETHERNET_TYPE_VLAN))
251 ethertype_p = &vlan->
type;
263 u16 ethertype, *ethertype_p;
264 u32 *mac1, *mac2, *mac3;
269 if ((ethertype != htons (ETHERNET_TYPE_IP4)) &&
270 (ethertype != htons (ETHERNET_TYPE_IP6)))
274 ip_version = (
ip4->ip_version_and_header_length >> 4);
276 if (ip_version == 0x4)
291 else if (ip_version == 0x6)
305 (&
ip6->src_address.as_uword[0],
uword),
324 u16 ethertype, *ethertype_p;
329 if ((ethertype != htons (ETHERNET_TYPE_IP4)) &&
330 (ethertype != htons (ETHERNET_TYPE_IP6)))
334 ip_version = (
ip4->ip_version_and_header_length >> 4);
336 if (ip_version == 0x4)
341 is_tcp_udp = (
ip4->protocol == IP_PROTOCOL_TCP) ||
342 (
ip4->protocol == IP_PROTOCOL_UDP);
350 else if (ip_version == 0x6)
359 (
ip6->protocol == IP_PROTOCOL_UDP)))
362 tcp = (
void *) (
ip6 + 1);
364 else if (
ip6->protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
368 if ((hbh->
protocol == IP_PROTOCOL_TCP)
369 || (hbh->
protocol == IP_PROTOCOL_UDP))
380 (&
ip6->src_address.as_uword[0],
uword),
425 if (lb_alg == BOND_LB_L2)
432 else if (lb_alg == BOND_LB_L34)
439 else if (lb_alg == BOND_LB_L23)
446 else if (lb_alg == BOND_LB_RR)
453 else if (lb_alg == BOND_LB_BC)
472 if (bif->
lb == BOND_LB_L2)
474 else if (bif->
lb == BOND_LB_L34)
476 else if (bif->
lb == BOND_LB_L23)
478 else if (bif->
lb == BOND_LB_RR)
480 else if (bif->
lb == BOND_LB_BC)
495 int use_modulo_shortcut)
499 #ifdef CLIB_HAVE_VEC256
501 u32x8 mask8, sc8u, h8a, h8b;
504 if (use_modulo_shortcut)
506 mask8 = u32x8_splat (
mask);
510 mask8 = u32x8_splat (0xffff);
511 sc8u = u32x8_splat (n_members);
517 h8a = u32x8_load_unaligned (
h) & mask8;
518 h8b = u32x8_load_unaligned (
h + 8) & mask8;
520 if (use_modulo_shortcut == 0)
526 u32x8_store_unaligned (h8a,
h);
527 u32x8_store_unaligned (h8b,
h + 8);
535 if (use_modulo_shortcut)
554 if (use_modulo_shortcut)
566 int single_sw_if_index)
705 return frame->n_vectors;
708 n_members =
vec_len (bif->active_members);
718 return frame->n_vectors;
724 if ((bif->lb == BOND_LB_AB) ||
PREDICT_FALSE (n_members == 1))
734 if (bif->lb == BOND_LB_BC)
747 if (bif->n_numa_members >= 1)
748 n_members = bif->n_numa_members;
750 if (bif->lb == BOND_LB_L2)
752 else if (bif->lb == BOND_LB_L34)
754 else if (bif->lb == BOND_LB_L23)
756 else if (bif->lb == BOND_LB_RR)
766 return frame->n_vectors;
782 for (p = 0; p < n_members; p++)
799 return frame->n_vectors;
818 uword event_type, *event_data = 0;
846 .name =
"bond-process",
static_always_inline void bond_hash_to_port(u32 *h, u32 n_left, u32 n_members, int use_modulo_shortcut)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(bond_member_interface_add_del)
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static vlib_buffer_t * vlib_buffer_copy(vlib_main_t *vm, vlib_buffer_t *b)
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static char * bond_tx_error_strings[]
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static_always_inline int ethernet_frame_is_tagged(u16 type)
bond_per_port_queue_t * per_port_queue
struct _tcp_header tcp_header_t
u8 * format_ethernet_address(u8 *s, va_list *args)
vlib_get_buffers(vm, from, b, n_left_from)
static_always_inline u16 * bond_locate_ethertype(ethernet_header_t *eth)
vlib_main_t vlib_node_runtime_t * node
u8 * format_bond_interface_name(u8 *s, va_list *args)
#define clib_error_return(e, args...)
VNET_DEVICE_CLASS(af_xdp_device_class)
static walk_rc_t bond_active_interface_switch_cb(vnet_main_t *vnm, u32 sw_if_index, void *arg)
@ VNET_SW_INTERFACE_FLAG_ADMIN_UP
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static bond_if_t * bond_get_bond_if_by_sw_if_index(u32 sw_if_index)
@ VNET_HW_INTERFACE_FLAG_LINK_UP
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
vlib_simple_counter_main_t * sw_if_counters
static void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
#define BOND_MODULO_SHORTCUT(a)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
#define VNET_DEVICE_CLASS_TX_FN(devclass)
static_always_inline u32 bond_lb_l23(vlib_buffer_t *b0)
#define vec_elt(v, i)
Get vector value at index i.
VNET_DEVICE_CLASS_TX_FN() bond_dev_class(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type,...
static u8 * format_bond_tx_trace(u8 *s, va_list *args)
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static __clib_unused clib_error_t * bond_subif_add_del_function(vnet_main_t *vnm, u32 hw_if_index, struct vnet_sw_interface_t *st, int is_add)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_main_t * vnet_get_main(void)
ethernet_header_t ethernet
void ip6_neighbor_advertise(vlib_main_t *vm, vnet_main_t *vnm, u32 sw_if_index, const ip6_address_t *addr)
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static_always_inline void bond_update_sw_if_index(bond_per_thread_data_t *ptd, bond_if_t *bif, u32 *bi, vlib_buffer_t **b, u32 *data, u32 n_left, int single_sw_if_index)
static vlib_frame_t * vnet_get_frame_to_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
void bond_detach_member(vlib_main_t *vm, bond_detach_member_args_t *args)
#define static_always_inline
static_always_inline u32 lb_hash_hash(u64 k0, u64 k1, u64 k2, u64 k3, u64 k4)
#define vec_foreach_index(var, v)
Iterate over vector indices.
static clib_error_t * bond_member_interface_add_del(vnet_main_t *vnm, u32 sw_if_index, u32 is_add)
u32 buffers[VLIB_FRAME_SIZE]
#define clib_mem_unaligned(pointer, type)
#define VLIB_NODE_FLAG_TRACE_SUPPORTED
manual_print typedef address
static_always_inline u32 bond_lb_round_robin(bond_if_t *bif, vlib_buffer_t *b0, uword n_members)
void ip4_neighbor_advertise(vlib_main_t *vm, vnet_main_t *vnm, u32 sw_if_index, const ip4_address_t *addr)
static void vlib_set_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 count)
static_always_inline void bond_tx_inline(vlib_main_t *vm, bond_if_t *bif, vlib_buffer_t **b, u32 *h, u32 n_left, uword n_members, u32 lb_alg)
struct _vlib_node_registration vlib_node_registration_t
static clib_error_t * bond_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
#define foreach_bond_tx_error
description fragment has unexpected format
static_always_inline f32x8 f32x8_from_u32x8(u32x8 v)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
static_always_inline void clib_prefetch_load(void *p)
static vnet_hw_interface_t * vnet_get_hw_interface_or_null(vnet_main_t *vnm, u32 hw_if_index)
static void vnet_put_frame_to_sw_interface(vnet_main_t *vnm, u32 sw_if_index, vlib_frame_t *f)
#define vec_foreach(var, vec)
Vector iterator.
static_always_inline u32 bond_lb_l34(vlib_buffer_t *b0)
static member_if_t * bond_get_member_by_sw_if_index(u32 sw_if_index)
static clib_error_t * bond_add_del_mac_address(vnet_hw_interface_t *hi, const u8 *address, u8 is_add)
static_always_inline void bond_tx_trace(vlib_main_t *vm, vlib_node_runtime_t *node, bond_if_t *bif, vlib_buffer_t **b, u32 n_left, u32 *h)
clib_error_t * vnet_hw_interface_add_del_mac_address(vnet_main_t *vnm, u32 hw_if_index, const u8 *mac_address, u8 is_add)
static_always_inline u32 lb_hash_hash_2_tuples(u64 k0, u32 k1)
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static_always_inline u32x8 u32x8_from_f32x8(f32x8 v)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vnet_interface_output_runtime_t * rt
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
static_always_inline u32 bond_lb_broadcast(vlib_main_t *vm, bond_if_t *bif, vlib_buffer_t *b0, uword n_members)
static uword bond_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
bond_per_thread_data_t * per_thread_data
void vnet_hw_interface_walk_sw(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_sw_interface_walk_t fn, void *ctx)
Walk the SW interfaces on a HW interface - this is the super interface and any sub-interfaces.
static_always_inline u32 bond_lb_l2(vlib_buffer_t *b0)
static __clib_warn_unused_result int vlib_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, vlib_buffer_t *b, int follow_chain)
vl_api_interface_index_t sw_if_index
enum walk_rc_t_ walk_rc_t
Walk return code.
static __clib_unused clib_error_t * bond_set_l2_mode_function(vnet_main_t *vnm, struct vnet_hw_interface_t *bif_hw, i32 l2_if_adjust)
@ VNET_INTERFACE_COUNTER_DROP
static_always_inline void bond_tx_add_to_queue(bond_per_thread_data_t *ptd, u32 port, u32 bi)
vnet_interface_main_t interface_main
vlib_node_registration_t bond_process_node
(constructor) VLIB_REGISTER_NODE (bond_process_node)
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)
vl_api_wireguard_peer_flags_t flags