2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #include <vnet/vnet.h>
16 #include <vppinfra/vec.h>
17 #include <vppinfra/error.h>
18 #include <vppinfra/format.h>
19 #include <vppinfra/xxhash.h>
21 #include <vnet/ethernet/ethernet.h>
22 #include <vnet/devices/dpdk/dpdk.h>
23 #include <vnet/classify/vnet_classify.h>
24 #include <vnet/mpls-gre/packet.h>
25 #include <vnet/handoff.h>
27 #include "dpdk_priv.h"
30 #define MAX(a,b) ((a) < (b) ? (b) : (a))
34 #define MIN(a,b) ((a) < (b) ? (a) : (b))
38 * At least in certain versions of ESXi, vmware e1000's don't honor the
39 * "strip rx CRC" bit. Set this flag to work around that bug FOR UNIT TEST ONLY.
41 * If wireshark complains like so:
43 * "Frame check sequence: 0x00000000 [incorrect, should be <hex-num>]"
44 * and you're using ESXi emulated e1000's, set this flag FOR UNIT TEST ONLY.
46 * Note: do NOT check in this file with this workaround enabled! You'll lose
47 * actual data from e.g. 10xGE interfaces. The extra 4 bytes annoy
48 * wireshark, but they're harmless...
50 #define VMWARE_LENGTH_BUG_WORKAROUND 0
52 static char * dpdk_error_strings[] = {
59 dpdk_mbuf_is_ip4(struct rte_mbuf *mb)
61 return RTE_ETH_IS_IPV4_HDR(mb->packet_type) != 0;
65 dpdk_mbuf_is_ip6(struct rte_mbuf *mb)
67 return RTE_ETH_IS_IPV6_HDR(mb->packet_type) != 0;
71 vlib_buffer_is_mpls(vlib_buffer_t * b)
73 ethernet_header_t *h = (ethernet_header_t *) b->data;
74 return (h->type == clib_host_to_net_u16(ETHERNET_TYPE_MPLS_UNICAST));
78 dpdk_rx_next_and_error_from_mb_flags_x1 (dpdk_device_t *xd, struct rte_mbuf *mb,
80 u8 * next0, u8 * error0)
83 uint16_t mb_flags = mb->ol_flags;
85 if (PREDICT_FALSE(mb_flags & (
86 #ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS
87 PKT_EXT_RX_PKT_ERROR | PKT_EXT_RX_BAD_FCS |
88 #endif /* RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS */
89 PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD
92 /* some error was flagged. determine the drop reason */
93 n0 = DPDK_RX_NEXT_DROP;
95 #ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS
96 (mb_flags & PKT_EXT_RX_PKT_ERROR) ? DPDK_ERROR_RX_PACKET_ERROR :
97 (mb_flags & PKT_EXT_RX_BAD_FCS) ? DPDK_ERROR_RX_BAD_FCS :
98 #endif /* RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS */
99 (mb_flags & PKT_RX_IP_CKSUM_BAD) ? DPDK_ERROR_IP_CHECKSUM_ERROR :
100 (mb_flags & PKT_RX_L4_CKSUM_BAD) ? DPDK_ERROR_L4_CHECKSUM_ERROR :
105 *error0 = DPDK_ERROR_NONE;
106 if (PREDICT_FALSE(xd->per_interface_next_index != ~0))
108 n0 = xd->per_interface_next_index;
109 b0->flags |= BUFFER_HANDOFF_NEXT_VALID;
110 if (PREDICT_TRUE (dpdk_mbuf_is_ip4(mb)))
111 vnet_buffer(b0)->handoff.next_index = HANDOFF_DISPATCH_NEXT_IP4_INPUT;
112 else if (PREDICT_TRUE(dpdk_mbuf_is_ip6(mb)))
113 vnet_buffer(b0)->handoff.next_index = HANDOFF_DISPATCH_NEXT_IP6_INPUT;
114 else if (PREDICT_TRUE(vlib_buffer_is_mpls(b0)))
115 vnet_buffer(b0)->handoff.next_index = HANDOFF_DISPATCH_NEXT_MPLS_INPUT;
117 vnet_buffer(b0)->handoff.next_index = HANDOFF_DISPATCH_NEXT_ETHERNET_INPUT;
119 else if (PREDICT_FALSE(xd->vlan_subifs || (mb_flags & PKT_RX_VLAN_PKT)))
120 n0 = DPDK_RX_NEXT_ETHERNET_INPUT;
123 if (PREDICT_TRUE (dpdk_mbuf_is_ip4(mb)))
124 n0 = DPDK_RX_NEXT_IP4_INPUT;
125 else if (PREDICT_TRUE(dpdk_mbuf_is_ip6(mb)))
126 n0 = DPDK_RX_NEXT_IP6_INPUT;
127 else if (PREDICT_TRUE(vlib_buffer_is_mpls(b0)))
128 n0 = DPDK_RX_NEXT_MPLS_INPUT;
130 n0 = DPDK_RX_NEXT_ETHERNET_INPUT;
136 void dpdk_rx_trace (dpdk_main_t * dm,
137 vlib_node_runtime_t * node,
143 vlib_main_t * vm = vlib_get_main();
154 dpdk_rx_dma_trace_t * t0;
161 b0 = vlib_get_buffer (vm, bi0);
162 mb = rte_mbuf_from_vlib_buffer(b0);
163 dpdk_rx_next_and_error_from_mb_flags_x1 (xd, mb, b0,
165 vlib_trace_buffer (vm, node, next0, b0, /* follow_chain */ 0);
166 t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
167 t0->queue_index = queue_id;
168 t0->device_index = xd->device_index;
169 t0->buffer_index = bi0;
171 clib_memcpy (&t0->mb, mb, sizeof (t0->mb));
172 clib_memcpy (&t0->buffer, b0, sizeof (b0[0]) - sizeof (b0->pre_data));
173 clib_memcpy (t0->buffer.pre_data, b0->data, sizeof (t0->buffer.pre_data));
174 clib_memcpy (&t0->data, mb->buf_addr + mb->data_off, sizeof (t0->data));
176 #ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS
178 * Clear overloaded TX offload flags when a DPDK driver
179 * is using them for RX flags (e.g. Cisco VIC Ethernet driver)
181 mb->ol_flags &= PKT_EXT_RX_CLR_TX_FLAGS_MASK;
182 #endif /* RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS */
189 * dpdk_efd_update_counters()
190 * Update EFD (early-fast-discard) counters
192 void dpdk_efd_update_counters (dpdk_device_t *xd,
196 if (enabled & DPDK_EFD_MONITOR_ENABLED)
198 u64 now = clib_cpu_time_now();
199 if (xd->efd_agent.last_poll_time > 0)
201 u64 elapsed_time = (now - xd->efd_agent.last_poll_time);
202 if (elapsed_time > xd->efd_agent.max_poll_delay)
203 xd->efd_agent.max_poll_delay = elapsed_time;
205 xd->efd_agent.last_poll_time = now;
208 xd->efd_agent.total_packet_cnt += n_buffers;
209 xd->efd_agent.last_burst_sz = n_buffers;
211 if (n_buffers > xd->efd_agent.max_burst_sz)
212 xd->efd_agent.max_burst_sz = n_buffers;
214 if (PREDICT_FALSE(n_buffers == VLIB_FRAME_SIZE))
216 xd->efd_agent.full_frames_cnt++;
217 xd->efd_agent.consec_full_frames_cnt++;
221 xd->efd_agent.consec_full_frames_cnt = 0;
225 /* is_efd_discardable()
226 * returns non zero DPDK error if packet meets early-fast-discard criteria,
229 u32 is_efd_discardable (vlib_thread_main_t *tm,
233 ethernet_header_t *eh = (ethernet_header_t *) b0->data;
235 if (eh->type == clib_host_to_net_u16(ETHERNET_TYPE_IP4))
238 (ip4_header_t *)&(b0->data[sizeof(ethernet_header_t)]);
239 u8 pkt_prec = (ipv4->tos >> 5);
241 return (tm->efd.ip_prec_bitmap & (1 << pkt_prec) ?
242 DPDK_ERROR_IPV4_EFD_DROP_PKTS : DPDK_ERROR_NONE);
244 else if (eh->type == clib_net_to_host_u16(ETHERNET_TYPE_IP6))
247 (ip6_header_t *)&(b0->data[sizeof(ethernet_header_t)]);
249 ((ipv6->ip_version_traffic_class_and_flow_label >> 20) & 0xff);
251 return (tm->efd.ip_prec_bitmap & (1 << pkt_tclass) ?
252 DPDK_ERROR_IPV6_EFD_DROP_PKTS : DPDK_ERROR_NONE);
254 else if (eh->type == clib_net_to_host_u16(ETHERNET_TYPE_MPLS_UNICAST))
256 mpls_unicast_header_t *mpls =
257 (mpls_unicast_header_t *)&(b0->data[sizeof(ethernet_header_t)]);
258 u8 pkt_exp = ((mpls->label_exp_s_ttl >> 9) & 0x07);
260 return (tm->efd.mpls_exp_bitmap & (1 << pkt_exp) ?
261 DPDK_ERROR_MPLS_EFD_DROP_PKTS : DPDK_ERROR_NONE);
263 else if ((eh->type == clib_net_to_host_u16(ETHERNET_TYPE_VLAN)) ||
264 (eh->type == clib_net_to_host_u16(ETHERNET_TYPE_DOT1AD)))
266 ethernet_vlan_header_t *vlan =
267 (ethernet_vlan_header_t *)&(b0->data[sizeof(ethernet_header_t)]);
268 u8 pkt_cos = ((vlan->priority_cfi_and_id >> 13) & 0x07);
270 return (tm->efd.vlan_cos_bitmap & (1 << pkt_cos) ?
271 DPDK_ERROR_VLAN_EFD_DROP_PKTS : DPDK_ERROR_NONE);
274 return DPDK_ERROR_NONE;
278 * This function is used when there are no worker threads.
279 * The main thread performs IO and forwards the packets.
281 static inline u32 dpdk_device_input ( dpdk_main_t * dm,
283 vlib_node_runtime_t * node,
289 u32 next_index = DPDK_RX_NEXT_ETHERNET_INPUT;
290 u32 n_left_to_next, * to_next;
292 vlib_main_t * vm = vlib_get_main();
293 uword n_rx_bytes = 0;
294 u32 n_trace, trace_cnt __attribute__((unused));
295 vlib_buffer_free_list_t * fl;
296 u8 efd_discard_burst = 0;
297 u32 buffer_flags_template;
299 if (xd->admin_up == 0)
302 n_buffers = dpdk_rx_burst(dm, xd, queue_id);
306 /* check if EFD (dpdk) is enabled */
307 if (PREDICT_FALSE(use_efd && dm->efd.enabled))
309 /* reset a few stats */
310 xd->efd_agent.last_poll_time = 0;
311 xd->efd_agent.last_burst_sz = 0;
316 buffer_flags_template = dm->buffer_flags_template;
318 vec_reset_length (xd->d_trace_buffers);
319 trace_cnt = n_trace = vlib_get_trace_count (vm, node);
321 fl = vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
324 * DAW-FIXME: VMXNET3 device stop/start doesn't work,
325 * therefore fake the stop in the dpdk driver by
326 * silently dropping all of the incoming pkts instead of
327 * stopping the driver / hardware.
329 if (PREDICT_FALSE(xd->admin_up != 1))
331 for (mb_index = 0; mb_index < n_buffers; mb_index++)
332 rte_pktmbuf_free (xd->rx_vectors[queue_id][mb_index]);
337 /* Check for congestion if EFD (Early-Fast-Discard) is enabled
338 * in any mode (e.g. dpdk, monitor, or drop_all)
340 if (PREDICT_FALSE(use_efd && dm->efd.enabled))
342 /* update EFD counters */
343 dpdk_efd_update_counters(xd, n_buffers, dm->efd.enabled);
345 if (PREDICT_FALSE(dm->efd.enabled & DPDK_EFD_DROPALL_ENABLED))
347 /* discard all received packets */
348 for (mb_index = 0; mb_index < n_buffers; mb_index++)
349 rte_pktmbuf_free(xd->rx_vectors[queue_id][mb_index]);
351 xd->efd_agent.discard_cnt += n_buffers;
352 increment_efd_drop_counter(vm,
353 DPDK_ERROR_VLAN_EFD_DROP_PKTS,
359 if (PREDICT_FALSE(xd->efd_agent.consec_full_frames_cnt >=
360 dm->efd.consec_full_frames_hi_thresh))
362 u32 device_queue_sz = rte_eth_rx_queue_count(xd->device_index,
364 if (device_queue_sz >= dm->efd.queue_hi_thresh)
366 /* dpdk device queue has reached the critical threshold */
367 xd->efd_agent.congestion_cnt++;
369 /* apply EFD to packets from the burst */
370 efd_discard_burst = 1;
377 while (n_buffers > 0)
382 vlib_buffer_t * b0, * b_seg, * b_chain = 0;
385 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
387 while (n_buffers > 0 && n_left_to_next > 0)
390 struct rte_mbuf *mb = xd->rx_vectors[queue_id][mb_index];
391 struct rte_mbuf *mb_seg = mb->next;
393 if (PREDICT_TRUE(n_buffers > 2))
395 struct rte_mbuf *pfmb = xd->rx_vectors[queue_id][mb_index+2];
396 vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb);
397 CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, STORE);
398 CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE);
403 b0 = vlib_buffer_from_rte_mbuf(mb);
405 /* check whether EFD is looking for packets to discard */
406 if (PREDICT_FALSE(efd_discard_burst))
408 vlib_thread_main_t * tm = vlib_get_thread_main();
410 if (PREDICT_TRUE(cntr_type = is_efd_discardable(tm, b0, mb)))
412 rte_pktmbuf_free(mb);
413 xd->efd_agent.discard_cnt++;
414 increment_efd_drop_counter(vm,
423 /* Prefetch one next segment if it exists. */
424 if (PREDICT_FALSE(mb->nb_segs > 1))
426 struct rte_mbuf *pfmb = mb->next;
427 vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb);
428 CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, LOAD);
429 CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE);
433 vlib_buffer_init_for_free_list (b0, fl);
435 bi0 = vlib_get_buffer_index (vm, b0);
441 dpdk_rx_next_and_error_from_mb_flags_x1 (xd, mb, b0,
443 #ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS
445 * Clear overloaded TX offload flags when a DPDK driver
446 * is using them for RX flags (e.g. Cisco VIC Ethernet driver)
449 if (PREDICT_TRUE(trace_cnt == 0))
450 mb->ol_flags &= PKT_EXT_RX_CLR_TX_FLAGS_MASK;
453 #endif /* RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS */
455 b0->error = node->errors[error0];
457 l3_offset0 = ((next0 == DPDK_RX_NEXT_IP4_INPUT ||
458 next0 == DPDK_RX_NEXT_IP6_INPUT ||
459 next0 == DPDK_RX_NEXT_MPLS_INPUT) ?
460 sizeof (ethernet_header_t) : 0);
462 b0->current_data = l3_offset0;
463 /* Some drivers like fm10k receive frames with
464 mb->data_off > RTE_PKTMBUF_HEADROOM */
465 b0->current_data += mb->data_off - RTE_PKTMBUF_HEADROOM;
466 b0->current_length = mb->data_len - l3_offset0;
468 b0->flags = buffer_flags_template;
470 if (VMWARE_LENGTH_BUG_WORKAROUND)
471 b0->current_length -= 4;
473 vnet_buffer(b0)->sw_if_index[VLIB_RX] = xd->vlib_sw_if_index;
474 vnet_buffer(b0)->sw_if_index[VLIB_TX] = (u32)~0;
475 n_rx_bytes += mb->pkt_len;
477 /* Process subsequent segments of multi-segment packets */
478 while ((mb->nb_segs > 1) && (nb_seg < mb->nb_segs))
482 b_seg = vlib_buffer_from_rte_mbuf(mb_seg);
483 vlib_buffer_init_for_free_list (b_seg, fl);
485 ASSERT((b_seg->flags & VLIB_BUFFER_NEXT_PRESENT) == 0);
486 ASSERT(b_seg->current_data == 0);
489 * The driver (e.g. virtio) may not put the packet data at the start
490 * of the segment, so don't assume b_seg->current_data == 0 is correct.
492 b_seg->current_data = (mb_seg->buf_addr + mb_seg->data_off) - (void *)b_seg->data;
494 b_seg->current_length = mb_seg->data_len;
495 b0->total_length_not_including_first_buffer +=
498 b_chain->flags |= VLIB_BUFFER_NEXT_PRESENT;
499 b_chain->next_buffer = vlib_get_buffer_index (vm, b_seg);
502 mb_seg = mb_seg->next;
507 * Turn this on if you run into
508 * "bad monkey" contexts, and you want to know exactly
509 * which nodes they've visited... See main.c...
511 VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b0);
513 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
514 to_next, n_left_to_next,
516 if (PREDICT_FALSE (n_trace > mb_index))
517 vec_add1 (xd->d_trace_buffers, bi0);
521 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
524 if (PREDICT_FALSE (vec_len (xd->d_trace_buffers) > 0))
526 dpdk_rx_trace (dm, node, xd, queue_id, xd->d_trace_buffers,
527 vec_len (xd->d_trace_buffers));
528 vlib_set_trace_count (vm, node, n_trace - vec_len (xd->d_trace_buffers));
531 vlib_increment_combined_counter
532 (vnet_get_main()->interface_main.combined_sw_if_counters
533 + VNET_INTERFACE_COUNTER_RX,
535 xd->vlib_sw_if_index,
536 mb_index, n_rx_bytes);
538 dpdk_worker_t * dw = vec_elt_at_index(dm->workers, cpu_index);
539 dw->aggregate_rx_packets += mb_index;
544 static inline void poll_rate_limit(dpdk_main_t * dm)
546 /* Limit the poll rate by sleeping for N msec between polls */
547 if (PREDICT_FALSE (dm->poll_sleep != 0))
549 struct timespec ts, tsrem;
552 ts.tv_nsec = 1000*1000*dm->poll_sleep; /* 1ms */
554 while (nanosleep(&ts, &tsrem) < 0)
561 /** \brief Main DPDK input node
564 This is the main DPDK input node: across each assigned interface,
565 call rte_eth_rx_burst(...) or similar to obtain a vector of
566 packets to process. Handle early packet discard. Derive @c
567 vlib_buffer_t metadata from <code>struct rte_mbuf</code> metadata,
568 Depending on the resulting metadata: adjust <code>b->current_data,
569 b->current_length </code> and dispatch directly to
570 ip4-input-no-checksum, or ip6-input. Trace the packet if required.
572 @param vm vlib_main_t corresponding to the current thread
573 @param node vlib_node_runtime_t
574 @param frame vlib_frame_t input-node, not used.
576 @par Graph mechanics: buffer metadata, next index usage
579 - <code>struct rte_mbuf mb->ol_flags</code>
580 - PKT_EXT_RX_PKT_ERROR, PKT_EXT_RX_BAD_FCS
581 PKT_RX_IP_CKSUM_BAD, PKT_RX_L4_CKSUM_BAD
582 - <code> RTE_ETH_IS_xxx_HDR(mb->packet_type) </code>
583 - packet classification result
586 - <code>b->error</code> if the packet is to be dropped immediately
587 - <code>b->current_data, b->current_length</code>
588 - adjusted as needed to skip the L2 header in direct-dispatch cases
589 - <code>vnet_buffer(b)->sw_if_index[VLIB_RX]</code>
590 - rx interface sw_if_index
591 - <code>vnet_buffer(b)->sw_if_index[VLIB_TX] = ~0</code>
592 - required by ipX-lookup
593 - <code>b->flags</code>
594 - to indicate multi-segment pkts (VLIB_BUFFER_NEXT_PRESENT), etc.
597 - Static arcs to: error-drop, ethernet-input,
598 ip4-input-no-checksum, ip6-input, mpls-gre-input
599 - per-interface redirection, controlled by
600 <code>xd->per_interface_next_index</code>
604 dpdk_input (vlib_main_t * vm,
605 vlib_node_runtime_t * node,
608 dpdk_main_t * dm = &dpdk_main;
610 uword n_rx_packets = 0;
611 dpdk_device_and_queue_t * dq;
612 u32 cpu_index = os_get_cpu_number();
615 * Poll all devices on this cpu for input/interrupts.
617 vec_foreach (dq, dm->devices_by_cpu[cpu_index])
619 xd = vec_elt_at_index(dm->devices, dq->device);
620 ASSERT(dq->queue_id == 0);
621 n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, 0, 0);
630 dpdk_input_rss (vlib_main_t * vm,
631 vlib_node_runtime_t * node,
634 dpdk_main_t * dm = &dpdk_main;
636 uword n_rx_packets = 0;
637 dpdk_device_and_queue_t * dq;
638 u32 cpu_index = os_get_cpu_number();
641 * Poll all devices on this cpu for input/interrupts.
643 vec_foreach (dq, dm->devices_by_cpu[cpu_index])
645 xd = vec_elt_at_index(dm->devices, dq->device);
646 n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id, 0);
655 dpdk_input_efd (vlib_main_t * vm,
656 vlib_node_runtime_t * node,
659 dpdk_main_t * dm = &dpdk_main;
661 uword n_rx_packets = 0;
662 dpdk_device_and_queue_t * dq;
663 u32 cpu_index = os_get_cpu_number();
666 * Poll all devices on this cpu for input/interrupts.
668 vec_foreach (dq, dm->devices_by_cpu[cpu_index])
670 xd = vec_elt_at_index(dm->devices, dq->device);
671 n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id, 1);
680 VLIB_REGISTER_NODE (dpdk_input_node) = {
681 .function = dpdk_input,
682 .type = VLIB_NODE_TYPE_INPUT,
683 .name = "dpdk-input",
685 /* Will be enabled if/when hardware is detected. */
686 .state = VLIB_NODE_STATE_DISABLED,
688 .format_buffer = format_ethernet_header_with_length,
689 .format_trace = format_dpdk_rx_dma_trace,
691 .n_errors = DPDK_N_ERROR,
692 .error_strings = dpdk_error_strings,
694 .n_next_nodes = DPDK_RX_N_NEXT,
696 [DPDK_RX_NEXT_DROP] = "error-drop",
697 [DPDK_RX_NEXT_ETHERNET_INPUT] = "ethernet-input",
698 [DPDK_RX_NEXT_IP4_INPUT] = "ip4-input-no-checksum",
699 [DPDK_RX_NEXT_IP6_INPUT] = "ip6-input",
700 [DPDK_RX_NEXT_MPLS_INPUT] = "mpls-gre-input",
705 /* handle dpdk_input_rss alternative function */
706 VLIB_NODE_FUNCTION_MULTIARCH_CLONE(dpdk_input)
707 VLIB_NODE_FUNCTION_MULTIARCH_CLONE(dpdk_input_rss)
708 VLIB_NODE_FUNCTION_MULTIARCH_CLONE(dpdk_input_efd)
710 /* this macro defines dpdk_input_rss_multiarch_select() */
711 CLIB_MULTIARCH_SELECT_FN(dpdk_input);
712 CLIB_MULTIARCH_SELECT_FN(dpdk_input_rss);
713 CLIB_MULTIARCH_SELECT_FN(dpdk_input_efd);
716 * Override the next nodes for the dpdk input nodes.
717 * Must be invoked prior to VLIB_INIT_FUNCTION calls.
719 void dpdk_set_next_node (dpdk_rx_next_t next, char *name)
721 vlib_node_registration_t *r = &dpdk_input_node;
722 vlib_node_registration_t *r_handoff = &handoff_dispatch_node;
726 case DPDK_RX_NEXT_IP4_INPUT:
727 case DPDK_RX_NEXT_IP6_INPUT:
728 case DPDK_RX_NEXT_MPLS_INPUT:
729 case DPDK_RX_NEXT_ETHERNET_INPUT:
730 r->next_nodes[next] = name;
731 r_handoff->next_nodes[next] = name;
735 clib_warning ("%s: illegal next %d\n", __FUNCTION__, next);
742 * Based on the operation type, set lower/upper bits for the given index value
745 set_efd_bitmap (u8 *bitmap, u32 value, u32 op)
750 for (ix = 0; ix < 8; ix++) {
751 if (((op == EFD_OPERATION_LESS_THAN) && (ix < value)) ||
752 ((op == EFD_OPERATION_GREATER_OR_EQUAL) && (ix >= value))){
753 (*bitmap) |= (1 << ix);
759 efd_config (u32 enabled,
760 u32 ip_prec, u32 ip_op,
761 u32 mpls_exp, u32 mpls_op,
762 u32 vlan_cos, u32 vlan_op)
764 vlib_thread_main_t * tm = vlib_get_thread_main();
765 dpdk_main_t * dm = &dpdk_main;
768 tm->efd.enabled |= VLIB_EFD_DISCARD_ENABLED;
769 dm->efd.enabled |= DPDK_EFD_DISCARD_ENABLED;
771 tm->efd.enabled &= ~VLIB_EFD_DISCARD_ENABLED;
772 dm->efd.enabled &= ~DPDK_EFD_DISCARD_ENABLED;
775 set_efd_bitmap(&tm->efd.ip_prec_bitmap, ip_prec, ip_op);
776 set_efd_bitmap(&tm->efd.mpls_exp_bitmap, mpls_exp, mpls_op);
777 set_efd_bitmap(&tm->efd.vlan_cos_bitmap, vlan_cos, vlan_op);