41 return (h->
type == clib_host_to_net_u16 (ETHERNET_TYPE_IP4));
48 return (h->
type == clib_host_to_net_u16 (ETHERNET_TYPE_IP6));
55 return (h->
type == clib_host_to_net_u16 (ETHERNET_TYPE_MPLS_UNICAST));
58 #if RTE_VERSION < RTE_VERSION_NUM(16, 11, 0, 0) 60 #define PKT_RX_IP_CKSUM_GOOD (1ULL << 7) 67 if (
PREDICT_TRUE ((mb->ol_flags & PKT_RX_IP_CKSUM_GOOD) != 0))
82 #if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0) 83 return (mb->packet_type & RTE_PTYPE_L2_ETHER_VLAN) ==
84 RTE_PTYPE_L2_ETHER_VLAN;
88 (PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ_STRIPPED)) ==
96 return RTE_ETH_IS_IPV4_HDR (mb->packet_type) != 0;
102 return RTE_ETH_IS_IPV6_HDR (mb->packet_type) != 0;
123 if (mb->ol_flags & PKT_RX_IP_CKSUM_BAD)
125 *error = DPDK_ERROR_IP_CHECKSUM_ERROR;
129 *error = DPDK_ERROR_NONE;
199 n_this_chunk = rte_eth_rx_burst (xd->
device_index, queue_id,
202 n_buffers += n_this_chunk;
203 n_left -= n_this_chunk;
206 if (n_this_chunk < 32)
224 struct rte_mbuf *mb_seg = 0;
229 while ((mb->nb_segs > 1) && (nb_seg < mb->nb_segs))
244 (mb_seg->buf_addr + mb_seg->data_off) - (
void *) b_seg->
data;
253 mb_seg = mb_seg->next;
276 u32 n_left_to_next, *to_next;
279 uword n_rx_bytes = 0;
280 u32 n_trace, trace_cnt __attribute__ ((unused));
282 u32 buffer_flags_template;
306 struct rte_mbuf *mb = xd->
rx_vectors[queue_id][mb_index++];
317 while (n_buffers > 0)
320 u32 bi0, next0, l3_offset0;
321 u32 bi1, next1, l3_offset1;
322 u32 bi2, next2, l3_offset2;
323 u32 bi3, next3, l3_offset3;
324 u8 error0, error1, error2, error3;
329 while (n_buffers > 8 && n_left_to_next > 4)
331 struct rte_mbuf *mb0 = xd->
rx_vectors[queue_id][mb_index];
332 struct rte_mbuf *mb1 = xd->
rx_vectors[queue_id][mb_index + 1];
333 struct rte_mbuf *mb2 = xd->
rx_vectors[queue_id][mb_index + 2];
334 struct rte_mbuf *mb3 = xd->
rx_vectors[queue_id][mb_index + 3];
358 or_ol_flags = (mb0->ol_flags | mb1->ol_flags |
359 mb2->ol_flags | mb3->ol_flags);
439 b0->
flags = buffer_flags_template;
440 b1->
flags = buffer_flags_template;
441 b2->
flags = buffer_flags_template;
442 b3->
flags = buffer_flags_template;
454 n_rx_bytes += mb0->pkt_len;
455 n_rx_bytes += mb1->pkt_len;
456 n_rx_bytes += mb2->pkt_len;
457 n_rx_bytes += mb3->pkt_len;
480 &next0, &next1, &next2, &next3,
482 l3_offset0, l3_offset1,
483 l3_offset2, l3_offset3);
486 to_next, n_left_to_next,
488 next0, next1, next2, next3);
492 while (n_buffers > 0 && n_left_to_next > 0)
494 struct rte_mbuf *mb0 = xd->
rx_vectors[queue_id][mb_index];
526 b0->
current_data += mb0->data_off - RTE_PKTMBUF_HEADROOM;
529 b0->
flags = buffer_flags_template;
533 n_rx_bytes += mb0->pkt_len;
550 to_next, n_left_to_next,
583 struct timespec ts, tsrem;
588 while (nanosleep (&ts, &tsrem) < 0)
641 uword n_rx_packets = 0;
665 .name =
"dpdk-input",
666 .sibling_of =
"device-input",
669 .state = VLIB_NODE_STATE_DISABLED,
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.
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)
#define rte_mbuf_from_vlib_buffer(x)
static int vlib_buffer_is_mpls(vlib_buffer_t *b)
static int vlib_buffer_is_ip6(vlib_buffer_t *b)
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
static vlib_main_t * vlib_get_main(void)
static u32 dpdk_rx_burst(dpdk_main_t *dm, dpdk_device_t *xd, u16 queue_id)
static u32 dpdk_rx_next_from_etype(struct rte_mbuf *mb, vlib_buffer_t *b0)
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
#define foreach_dpdk_error
static_always_inline void vnet_feature_start_device_input_x1(u32 sw_if_index, u32 *next0, vlib_buffer_t *b0, u16 buffer_advanced0)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vlib_validate_buffer_enqueue_x4(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, bi2, bi3, next0, next1, next2, next3)
Finish enqueueing four buffers forward in the graph.
static_always_inline u32 dpdk_device_input(dpdk_main_t *dm, dpdk_device_t *xd, vlib_node_runtime_t *node, u32 cpu_index, u16 queue_id)
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 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.
#define static_always_inline
static int dpdk_mbuf_is_ip4(struct rte_mbuf *mb)
#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.
#define DPDK_DEVICE_FLAG_MAYBE_MULTISEG
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
#define VLIB_BUFFER_NEXT_PRESENT
const u32 device_input_next_node_advance[((VNET_DEVICE_INPUT_N_NEXT_NODES/CLIB_CACHE_LINE_BYTES)+1)*CLIB_CACHE_LINE_BYTES]
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 int dpdk_mbuf_is_vlan(struct rte_mbuf *mb)
uword os_get_cpu_number(void)
#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_always_inline void dpdk_prefetch_buffer(struct rte_mbuf *mb)
struct rte_mbuf *** rx_vectors
#define clib_memcpy(a, b, c)
static_always_inline void dpdk_process_subseq_segs(vlib_main_t *vm, vlib_buffer_t *b, struct rte_mbuf *mb, vlib_buffer_free_list_t *fl)
#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.
#define DPDK_DEVICE_FLAG_PMD_SUPPORTS_PTYPE
static int vlib_buffer_is_ip4(vlib_buffer_t *b)
VLIB_NODE_FUNCTION_MULTIARCH(dpdk_input_node, dpdk_input)
u32 next_buffer
Next buffer for this linked-list of buffers.
static void dpdk_rx_error_from_mb(struct rte_mbuf *mb, u32 *next, u8 *error)
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)
static_always_inline void vnet_feature_start_device_input_x4(u32 sw_if_index, u32 *next0, u32 *next1, u32 *next2, u32 *next3, vlib_buffer_t *b0, vlib_buffer_t *b1, vlib_buffer_t *b2, vlib_buffer_t *b3, u16 buffer_advanced0, u16 buffer_advanced1, u16 buffer_advanced2, u16 buffer_advanced3)
u32 buffer_flags_template
#define VLIB_REGISTER_NODE(x,...)
#define vlib_buffer_from_rte_mbuf(x)
#define vec_foreach(var, vec)
Vector iterator.
static u32 dpdk_rx_next_from_mb(struct rte_mbuf *mb, vlib_buffer_t *b0)
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)
#define CLIB_CACHE_LINE_BYTES
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.
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".