32 #define MAX(a,b) ((a) < (b) ? (b) : (a)) 36 #define MIN(a,b) ((a) < (b) ? (a) : (b)) 52 #define VMWARE_LENGTH_BUG_WORKAROUND 0 63 return RTE_ETH_IS_IPV4_HDR (mb->packet_type) != 0;
69 return RTE_ETH_IS_IPV6_HDR (mb->packet_type) != 0;
76 return (h->
type == clib_host_to_net_u16 (ETHERNET_TYPE_MPLS_UNICAST));
86 uint16_t mb_flags = mb->ol_flags;
89 #ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS
90 PKT_EXT_RX_PKT_ERROR | PKT_EXT_RX_BAD_FCS |
92 PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD)))
97 #ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS 98 (mb_flags & PKT_EXT_RX_PKT_ERROR) ? DPDK_ERROR_RX_PACKET_ERROR :
99 (mb_flags & PKT_EXT_RX_BAD_FCS) ? DPDK_ERROR_RX_BAD_FCS :
101 (mb_flags & PKT_RX_IP_CKSUM_BAD) ? DPDK_ERROR_IP_CHECKSUM_ERROR :
102 (mb_flags & PKT_RX_L4_CKSUM_BAD) ? DPDK_ERROR_L4_CHECKSUM_ERROR :
107 *error0 = DPDK_ERROR_NONE;
127 (mb_flags & PKT_RX_VLAN_PKT)))
183 #ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS 188 mb->ol_flags &= PKT_EXT_RX_CLR_TX_FLAGS_MASK;
241 if (eh->
type == clib_host_to_net_u16 (ETHERNET_TYPE_IP4))
245 u8 pkt_prec = (ipv4->
tos >> 5);
248 DPDK_ERROR_IPV4_EFD_DROP_PKTS : DPDK_ERROR_NONE);
250 else if (eh->
type == clib_net_to_host_u16 (ETHERNET_TYPE_IP6))
258 DPDK_ERROR_IPV6_EFD_DROP_PKTS : DPDK_ERROR_NONE);
260 else if (eh->
type == clib_net_to_host_u16 (ETHERNET_TYPE_MPLS_UNICAST))
267 DPDK_ERROR_MPLS_EFD_DROP_PKTS : DPDK_ERROR_NONE);
269 else if ((eh->
type == clib_net_to_host_u16 (ETHERNET_TYPE_VLAN)) ||
270 (eh->
type == clib_net_to_host_u16 (ETHERNET_TYPE_DOT1AD)))
277 DPDK_ERROR_VLAN_EFD_DROP_PKTS : DPDK_ERROR_NONE);
280 return DPDK_ERROR_NONE;
297 n_this_chunk = rte_eth_rx_burst (xd->
device_index, queue_id,
300 n_buffers += n_this_chunk;
301 n_left -= n_this_chunk;
304 if (n_this_chunk < 32)
324 u32 cpu_index,
u16 queue_id,
int use_efd)
328 u32 n_left_to_next, *to_next;
331 uword n_rx_bytes = 0;
332 u32 n_trace, trace_cnt __attribute__ ((unused));
334 u8 efd_discard_burst = 0;
335 u32 buffer_flags_template;
372 for (mb_index = 0; mb_index < n_buffers; mb_index++)
373 rte_pktmbuf_free (xd->
rx_vectors[queue_id][mb_index]);
377 DPDK_ERROR_VLAN_EFD_DROP_PKTS,
394 efd_discard_burst = 1;
401 while (n_buffers > 0)
411 while (n_buffers > 0 && n_left_to_next > 0)
414 struct rte_mbuf *mb = xd->
rx_vectors[queue_id][mb_index];
415 struct rte_mbuf *mb_seg = mb->next;
419 struct rte_mbuf *pfmb = xd->
rx_vectors[queue_id][mb_index + 2];
436 rte_pktmbuf_free (mb);
448 struct rte_mbuf *pfmb = mb->next;
465 #ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS 472 mb->ol_flags &= PKT_EXT_RX_CLR_TX_FLAGS_MASK;
487 b0->
current_data += mb->data_off - RTE_PKTMBUF_HEADROOM;
490 b0->
flags = buffer_flags_template;
497 n_rx_bytes += mb->pkt_len;
500 while ((mb->nb_segs > 1) && (nb_seg < mb->nb_segs))
515 (mb_seg->buf_addr + mb_seg->data_off) - (
void *) b_seg->
data;
524 mb_seg = mb_seg->next;
539 to_next, n_left_to_next,
574 struct timespec ts, tsrem;
579 while (nanosleep (&ts, &tsrem) < 0)
633 uword n_rx_packets = 0;
660 uword n_rx_packets = 0;
686 uword n_rx_packets = 0;
710 .name =
"dpdk-input",
713 .state = VLIB_NODE_STATE_DISABLED,
746 for (ix = 0; ix < 8; ix++)
751 (*bitmap) |= (1 << ix);
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.
static void dpdk_rx_next_and_error_from_mb_flags_x1(dpdk_device_t *xd, struct rte_mbuf *mb, vlib_buffer_t *b0, u32 *next0, u8 *error0)
void dpdk_rx_trace(dpdk_main_t *dm, vlib_node_runtime_t *node, dpdk_device_t *xd, u16 queue_id, u32 *buffers, uword n_buffers)
uword dpdk_input_rss(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
#define rte_mbuf_from_vlib_buffer(x)
static int vlib_buffer_is_mpls(vlib_buffer_t *b)
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
void dpdk_efd_update_counters(dpdk_device_t *xd, u32 n_buffers, u16 enabled)
static vlib_main_t * vlib_get_main(void)
static u32 dpdk_rx_burst(dpdk_main_t *dm, dpdk_device_t *xd, u16 queue_id)
#define VLIB_EFD_DISCARD_ENABLED
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
#define foreach_dpdk_error
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static u64 clib_cpu_time_now(void)
#define BUFFER_HANDOFF_NEXT_VALID
u32 per_interface_next_index
static int dpdk_mbuf_is_ip6(struct rte_mbuf *mb)
static void poll_rate_limit(dpdk_main_t *dm)
static char * dpdk_error_strings[]
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define DPDK_DEVICE_FLAG_PMD
static u32 dpdk_device_input(dpdk_main_t *dm, dpdk_device_t *xd, vlib_node_runtime_t *node, u32 cpu_index, u16 queue_id, int use_efd)
static void vlib_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, vlib_buffer_t *b, int follow_chain)
static void vlib_buffer_init_for_free_list(vlib_buffer_t *_dst, vlib_buffer_free_list_t *fl)
vnet_main_t * vnet_get_main(void)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static int dpdk_mbuf_is_ip4(struct rte_mbuf *mb)
void efd_config(u32 enabled, u32 ip_prec, u32 ip_op, u32 mpls_exp, u32 mpls_op, u32 vlan_cos, u32 vlan_op)
static_always_inline void vnet_feature_device_input_redirect_x1(vlib_node_runtime_t *node, u32 sw_if_index, u32 *next0, vlib_buffer_t *b0, u16 buffer_advanced0)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
#define VMWARE_LENGTH_BUG_WORKAROUND
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
#define VLIB_BUFFER_NEXT_PRESENT
u16 consec_full_frames_hi_thresh
format_function_t format_dpdk_rx_dma_trace
u16 current_length
Nbytes between current data and the end of this buffer.
dpdk_device_and_queue_t ** devices_by_cpu
static_always_inline void increment_efd_drop_counter(vlib_main_t *vm, u32 counter_index, u32 count)
u32 consec_full_frames_cnt
#define DPDK_EFD_DISCARD_ENABLED
uword os_get_cpu_number(void)
#define DPDK_EFD_MONITOR_ENABLED
#define VNET_DEVICE_INPUT_NEXT_NODES
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#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).
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define DPDK_DEVICE_FLAG_ADMIN_UP
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
#define CLIB_PREFETCH(addr, size, type)
static vlib_thread_main_t * vlib_get_thread_main()
struct rte_mbuf *** rx_vectors
#define clib_memcpy(a, b, c)
#define VLIB_NODE_FUNCTION_MULTIARCH_CLONE(fn)
#define EFD_OPERATION_GREATER_OR_EQUAL
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
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.
u32 next_buffer
Next buffer for this linked-list of buffers.
#define DPDK_DEVICE_FLAG_HAVE_SUBIF
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
dpdk_efd_agent_t efd_agent
#define DPDK_EFD_DROPALL_ENABLED
u32 buffer_flags_template
#define VLIB_REGISTER_NODE(x,...)
#define vlib_buffer_from_rte_mbuf(x)
#define vec_foreach(var, vec)
Vector iterator.
#define EFD_OPERATION_LESS_THAN
static vlib_buffer_free_list_t * vlib_buffer_get_free_list(vlib_main_t *vm, u32 free_list_index)
static void vlib_set_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 count)
u32 is_efd_discardable(vlib_thread_main_t *tm, vlib_buffer_t *b0, struct rte_mbuf *mb)
#define CLIB_CACHE_LINE_BYTES
CLIB_MULTIARCH_SELECT_FN(dpdk_input)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static uword dpdk_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
Main DPDK input node.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
uword dpdk_input_efd(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
void set_efd_bitmap(u8 *bitmap, u32 value, u32 op)