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/format.h>
18 #include <vlib/unix/cj.h>
21 #include <vnet/ethernet/ethernet.h>
22 #include <dpdk/device/dpdk.h>
24 #include <dpdk/device/dpdk_priv.h>
25 #include <vppinfra/error.h>
27 #define foreach_dpdk_tx_func_error \
28 _(BAD_RETVAL, "DPDK tx function returned an error") \
29 _(RING_FULL, "Tx packet drops (ring full)") \
30 _(PKT_DROP, "Tx packet drops (dpdk tx failure)") \
31 _(REPL_FAIL, "Tx packet drops (replication failure)")
35 #define _(f,s) DPDK_TX_FUNC_ERROR_##f,
36 foreach_dpdk_tx_func_error
39 } dpdk_tx_func_error_t;
41 static char *dpdk_tx_func_error_strings[] = {
43 foreach_dpdk_tx_func_error
48 dpdk_set_mac_address (vnet_hw_interface_t * hi, char *address)
51 dpdk_main_t *dm = &dpdk_main;
52 dpdk_device_t *xd = vec_elt_at_index (dm->devices, hi->dev_instance);
54 error = rte_eth_dev_default_mac_addr_set (xd->device_index,
55 (struct ether_addr *) address);
59 return clib_error_return (0, "mac address set failed: %d", error);
63 vec_reset_length (xd->default_mac_address);
64 vec_add (xd->default_mac_address, address, sizeof (address));
70 dpdk_replicate_packet_mb (vlib_buffer_t * b)
72 dpdk_main_t *dm = &dpdk_main;
73 struct rte_mbuf **mbufs = 0, *s, *d;
75 unsigned socket_id = rte_socket_id ();
78 ASSERT (dm->pktmbuf_pools[socket_id]);
79 s = rte_mbuf_from_vlib_buffer (b);
81 vec_validate (mbufs, nb_segs - 1);
83 if (rte_pktmbuf_alloc_bulk (dm->pktmbuf_pools[socket_id], mbufs, nb_segs))
90 d->nb_segs = s->nb_segs;
91 d->data_len = s->data_len;
92 d->pkt_len = s->pkt_len;
93 d->data_off = s->data_off;
94 clib_memcpy (d->buf_addr, s->buf_addr, RTE_PKTMBUF_HEADROOM + s->data_len);
96 for (i = 1; i < nb_segs; i++)
101 d->data_len = s->data_len;
102 clib_memcpy (d->buf_addr, s->buf_addr,
103 RTE_PKTMBUF_HEADROOM + s->data_len);
112 dpdk_tx_trace_buffer (dpdk_main_t * dm,
113 vlib_node_runtime_t * node,
115 u16 queue_id, u32 buffer_index, vlib_buffer_t * buffer)
117 vlib_main_t *vm = vlib_get_main ();
118 dpdk_tx_dma_trace_t *t0;
121 mb = rte_mbuf_from_vlib_buffer (buffer);
123 t0 = vlib_add_trace (vm, node, buffer, sizeof (t0[0]));
124 t0->queue_index = queue_id;
125 t0->device_index = xd->device_index;
126 t0->buffer_index = buffer_index;
127 clib_memcpy (&t0->mb, mb, sizeof (t0->mb));
128 clib_memcpy (&t0->buffer, buffer,
129 sizeof (buffer[0]) - sizeof (buffer->pre_data));
130 clib_memcpy (t0->buffer.pre_data, buffer->data + buffer->current_data,
131 sizeof (t0->buffer.pre_data));
134 static_always_inline void
135 dpdk_validate_rte_mbuf (vlib_main_t * vm, vlib_buffer_t * b,
138 struct rte_mbuf *mb, *first_mb, *last_mb;
140 /* buffer is coming from non-dpdk source so we need to init
142 if (PREDICT_FALSE ((b->flags & VLIB_BUFFER_EXT_HDR_VALID) == 0))
144 vlib_buffer_t *b2 = b;
145 last_mb = mb = rte_mbuf_from_vlib_buffer (b2);
146 rte_pktmbuf_reset (mb);
147 while (maybe_multiseg && (b2->flags & VLIB_BUFFER_NEXT_PRESENT))
149 b2 = vlib_get_buffer (vm, b2->next_buffer);
150 mb = rte_mbuf_from_vlib_buffer (b2);
151 rte_pktmbuf_reset (mb);
155 last_mb = first_mb = mb = rte_mbuf_from_vlib_buffer (b);
156 first_mb->nb_segs = 1;
157 mb->data_len = b->current_length;
158 mb->pkt_len = maybe_multiseg ? vlib_buffer_length_in_chain (vm, b) :
160 mb->data_off = VLIB_BUFFER_PRE_DATA_SIZE + b->current_data;
162 while (maybe_multiseg && (b->flags & VLIB_BUFFER_NEXT_PRESENT))
164 b = vlib_get_buffer (vm, b->next_buffer);
165 mb = rte_mbuf_from_vlib_buffer (b);
168 mb->data_len = b->current_length;
169 mb->pkt_len = b->current_length;
170 mb->data_off = VLIB_BUFFER_PRE_DATA_SIZE + b->current_data;
172 if (PREDICT_FALSE (b->n_add_refs))
174 rte_mbuf_refcnt_update (mb, b->n_add_refs);
181 * This function calls the dpdk's tx_burst function to transmit the packets
182 * on the tx_vector. It manages a lock per-device if the device does not
183 * support multiple queues. It returns the number of packets untransmitted
184 * on the tx_vector. If all packets are transmitted (the normal case), the
185 * function returns 0.
187 * The function assumes there is at least one packet on the tx_vector.
190 u32 tx_burst_vector_internal (vlib_main_t * vm,
192 struct rte_mbuf **tx_vector)
194 dpdk_main_t *dm = &dpdk_main;
203 ring = vec_header (tx_vector, sizeof (*ring));
205 n_packets = ring->tx_head - ring->tx_tail;
207 tx_head = ring->tx_head % xd->nb_tx_desc;
210 * Ensure rte_eth_tx_burst is not called with 0 packets, which can lead to
211 * unpredictable results.
213 ASSERT (n_packets > 0);
216 * Check for tx_vector overflow. If this fails it is a system configuration
217 * error. The ring should be sized big enough to handle the largest un-flowed
218 * off burst from a traffic manager. A larger size also helps performance
219 * a bit because it decreases the probability of having to issue two tx_burst
220 * calls due to a ring wrap.
222 ASSERT (n_packets < xd->nb_tx_desc);
223 ASSERT (ring->tx_tail == 0);
226 queue_id = vm->thread_index;
230 /* start the burst at the tail */
231 tx_tail = ring->tx_tail % xd->nb_tx_desc;
234 * This device only supports one TX queue,
235 * and we're running multi-threaded...
237 if (PREDICT_FALSE (xd->lockp != 0))
239 queue_id = queue_id % xd->tx_q_used;
240 while (__sync_lock_test_and_set (xd->lockp[queue_id], 1))
242 queue_id = (queue_id + 1) % xd->tx_q_used;
245 if (PREDICT_FALSE (xd->flags & DPDK_DEVICE_FLAG_HQOS)) /* HQoS ON */
247 /* no wrap, transmit in one burst */
248 dpdk_device_hqos_per_worker_thread_t *hqos =
249 &xd->hqos_wt[vm->thread_index];
251 ASSERT (hqos->swq != NULL);
253 dpdk_hqos_metadata_set (hqos,
254 &tx_vector[tx_tail], tx_head - tx_tail);
255 rv = rte_ring_sp_enqueue_burst (hqos->swq,
256 (void **) &tx_vector[tx_tail],
257 #if RTE_VERSION >= RTE_VERSION_NUM(17, 5, 0, 0)
258 (uint16_t) (tx_head - tx_tail), 0);
260 (uint16_t) (tx_head - tx_tail));
263 else if (PREDICT_TRUE (xd->flags & DPDK_DEVICE_FLAG_PMD))
265 /* no wrap, transmit in one burst */
266 rv = rte_eth_tx_burst (xd->device_index,
269 (uint16_t) (tx_head - tx_tail));
277 if (PREDICT_FALSE (xd->lockp != 0))
278 *xd->lockp[queue_id] = 0;
280 if (PREDICT_FALSE (rv < 0))
282 // emit non-fatal message, bump counter
283 vnet_main_t *vnm = dm->vnet_main;
284 vnet_interface_main_t *im = &vnm->interface_main;
287 node_index = vec_elt_at_index (im->hw_interfaces,
288 xd->hw_if_index)->tx_node_index;
290 vlib_error_count (vm, node_index, DPDK_TX_FUNC_ERROR_BAD_RETVAL, 1);
291 clib_warning ("rte_eth_tx_burst[%d]: error %d", xd->device_index,
293 return n_packets; // untransmitted packets
295 ring->tx_tail += (u16) rv;
296 n_packets -= (uint16_t) rv;
298 while (rv && n_packets && (n_retry > 0));
303 static_always_inline void
304 dpdk_prefetch_buffer_by_index (vlib_main_t * vm, u32 bi)
308 b = vlib_get_buffer (vm, bi);
309 mb = rte_mbuf_from_vlib_buffer (b);
310 CLIB_PREFETCH (mb, 2 * CLIB_CACHE_LINE_BYTES, STORE);
311 CLIB_PREFETCH (b, CLIB_CACHE_LINE_BYTES, LOAD);
314 static_always_inline void
315 dpdk_buffer_recycle (vlib_main_t * vm, vlib_node_runtime_t * node,
316 vlib_buffer_t * b, u32 bi, struct rte_mbuf **mbp)
318 dpdk_main_t *dm = &dpdk_main;
319 u32 my_cpu = vm->thread_index;
320 struct rte_mbuf *mb_new;
322 if (PREDICT_FALSE (b->flags & VLIB_BUFFER_RECYCLE) == 0)
325 mb_new = dpdk_replicate_packet_mb (b);
326 if (PREDICT_FALSE (mb_new == 0))
328 vlib_error_count (vm, node->node_index,
329 DPDK_TX_FUNC_ERROR_REPL_FAIL, 1);
330 b->flags |= VLIB_BUFFER_REPL_FAIL;
335 vec_add1 (dm->recycle[my_cpu], bi);
339 * Transmits the packets on the frame to the interface associated with the
340 * node. It first copies packets on the frame to a tx_vector containing the
341 * rte_mbuf pointers. It then passes this vector to tx_burst_vector_internal
342 * which calls the dpdk tx_burst function.
345 dpdk_interface_tx (vlib_main_t * vm,
346 vlib_node_runtime_t * node, vlib_frame_t * f)
348 dpdk_main_t *dm = &dpdk_main;
349 vnet_interface_output_runtime_t *rd = (void *) node->runtime_data;
350 dpdk_device_t *xd = vec_elt_at_index (dm->devices, rd->dev_instance);
351 u32 n_packets = f->n_vectors;
354 struct rte_mbuf **tx_vector;
356 u16 nb_tx_desc = xd->nb_tx_desc;
363 my_cpu = vm->thread_index;
367 tx_vector = xd->tx_vectors[queue_id];
368 ring = vec_header (tx_vector, sizeof (*ring));
370 n_on_ring = ring->tx_head - ring->tx_tail;
371 from = vlib_frame_vector_args (f);
373 ASSERT (n_packets <= VLIB_FRAME_SIZE);
375 if (PREDICT_FALSE (n_on_ring + n_packets > nb_tx_desc))
378 * Overflowing the ring should never happen.
379 * If it does then drop the whole frame.
381 vlib_error_count (vm, node->node_index, DPDK_TX_FUNC_ERROR_RING_FULL,
386 u32 bi0 = from[n_packets];
387 vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0);
388 struct rte_mbuf *mb0 = rte_mbuf_from_vlib_buffer (b0);
389 rte_pktmbuf_free (mb0);
394 if (PREDICT_FALSE (dm->tx_pcap_enable))
400 vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0);
401 if (dm->pcap_sw_if_index == 0 ||
402 dm->pcap_sw_if_index == vnet_buffer (b0)->sw_if_index[VLIB_TX])
403 pcap_add_buffer (&dm->pcap_main, vm, bi0, 512);
409 from = vlib_frame_vector_args (f);
411 i = ring->tx_head % nb_tx_desc;
415 u32 bi0, bi1, bi2, bi3;
416 struct rte_mbuf *mb0, *mb1, *mb2, *mb3;
417 vlib_buffer_t *b0, *b1, *b2, *b3;
420 dpdk_prefetch_buffer_by_index (vm, from[4]);
421 dpdk_prefetch_buffer_by_index (vm, from[5]);
422 dpdk_prefetch_buffer_by_index (vm, from[6]);
423 dpdk_prefetch_buffer_by_index (vm, from[7]);
431 b0 = vlib_get_buffer (vm, bi0);
432 b1 = vlib_get_buffer (vm, bi1);
433 b2 = vlib_get_buffer (vm, bi2);
434 b3 = vlib_get_buffer (vm, bi3);
436 or_flags = b0->flags | b1->flags | b2->flags | b3->flags;
438 if (or_flags & VLIB_BUFFER_NEXT_PRESENT)
440 dpdk_validate_rte_mbuf (vm, b0, 1);
441 dpdk_validate_rte_mbuf (vm, b1, 1);
442 dpdk_validate_rte_mbuf (vm, b2, 1);
443 dpdk_validate_rte_mbuf (vm, b3, 1);
447 dpdk_validate_rte_mbuf (vm, b0, 0);
448 dpdk_validate_rte_mbuf (vm, b1, 0);
449 dpdk_validate_rte_mbuf (vm, b2, 0);
450 dpdk_validate_rte_mbuf (vm, b3, 0);
453 mb0 = rte_mbuf_from_vlib_buffer (b0);
454 mb1 = rte_mbuf_from_vlib_buffer (b1);
455 mb2 = rte_mbuf_from_vlib_buffer (b2);
456 mb3 = rte_mbuf_from_vlib_buffer (b3);
458 if (PREDICT_FALSE (or_flags & VLIB_BUFFER_RECYCLE))
460 dpdk_buffer_recycle (vm, node, b0, bi0, &mb0);
461 dpdk_buffer_recycle (vm, node, b1, bi1, &mb1);
462 dpdk_buffer_recycle (vm, node, b2, bi2, &mb2);
463 dpdk_buffer_recycle (vm, node, b3, bi3, &mb3);
465 /* dont enqueue packets if replication failed as they must
466 be sent back to recycle */
467 if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_REPL_FAIL) == 0))
468 tx_vector[i++ % nb_tx_desc] = mb0;
469 if (PREDICT_TRUE ((b1->flags & VLIB_BUFFER_REPL_FAIL) == 0))
470 tx_vector[i++ % nb_tx_desc] = mb1;
471 if (PREDICT_TRUE ((b2->flags & VLIB_BUFFER_REPL_FAIL) == 0))
472 tx_vector[i++ % nb_tx_desc] = mb2;
473 if (PREDICT_TRUE ((b3->flags & VLIB_BUFFER_REPL_FAIL) == 0))
474 tx_vector[i++ % nb_tx_desc] = mb3;
478 if (PREDICT_FALSE (i + 3 >= nb_tx_desc))
480 tx_vector[i++ % nb_tx_desc] = mb0;
481 tx_vector[i++ % nb_tx_desc] = mb1;
482 tx_vector[i++ % nb_tx_desc] = mb2;
483 tx_vector[i++ % nb_tx_desc] = mb3;
488 tx_vector[i++] = mb0;
489 tx_vector[i++] = mb1;
490 tx_vector[i++] = mb2;
491 tx_vector[i++] = mb3;
496 if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
498 if (b0->flags & VLIB_BUFFER_IS_TRACED)
499 dpdk_tx_trace_buffer (dm, node, xd, queue_id, bi0, b0);
500 if (b1->flags & VLIB_BUFFER_IS_TRACED)
501 dpdk_tx_trace_buffer (dm, node, xd, queue_id, bi1, b1);
502 if (b2->flags & VLIB_BUFFER_IS_TRACED)
503 dpdk_tx_trace_buffer (dm, node, xd, queue_id, bi2, b2);
504 if (b3->flags & VLIB_BUFFER_IS_TRACED)
505 dpdk_tx_trace_buffer (dm, node, xd, queue_id, bi3, b3);
513 struct rte_mbuf *mb0;
519 b0 = vlib_get_buffer (vm, bi0);
521 dpdk_validate_rte_mbuf (vm, b0, 1);
523 mb0 = rte_mbuf_from_vlib_buffer (b0);
524 dpdk_buffer_recycle (vm, node, b0, bi0, &mb0);
526 if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
527 if (b0->flags & VLIB_BUFFER_IS_TRACED)
528 dpdk_tx_trace_buffer (dm, node, xd, queue_id, bi0, b0);
530 if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_REPL_FAIL) == 0))
532 tx_vector[i % nb_tx_desc] = mb0;
538 /* account for additional packets in the ring */
539 ring->tx_head += n_packets;
540 n_on_ring = ring->tx_head - ring->tx_tail;
542 /* transmit as many packets as possible */
543 n_packets = tx_burst_vector_internal (vm, xd, tx_vector);
546 * tx_pkts is the number of packets successfully transmitted
547 * This is the number originally on ring minus the number remaining on ring
549 tx_pkts = n_on_ring - n_packets;
552 /* If there is no callback then drop any non-transmitted packets */
553 if (PREDICT_FALSE (n_packets))
555 vlib_simple_counter_main_t *cm;
556 vnet_main_t *vnm = vnet_get_main ();
558 cm = vec_elt_at_index (vnm->interface_main.sw_if_counters,
559 VNET_INTERFACE_COUNTER_TX_ERROR);
561 vlib_increment_simple_counter (cm, my_cpu, xd->vlib_sw_if_index,
564 vlib_error_count (vm, node->node_index, DPDK_TX_FUNC_ERROR_PKT_DROP,
568 rte_pktmbuf_free (tx_vector[ring->tx_tail + n_packets]);
571 /* Reset head/tail to avoid unnecessary wrap */
576 /* Recycle replicated buffers */
577 if (PREDICT_FALSE (vec_len (dm->recycle[my_cpu])))
579 vlib_buffer_free (vm, dm->recycle[my_cpu],
580 vec_len (dm->recycle[my_cpu]));
581 _vec_len (dm->recycle[my_cpu]) = 0;
584 ASSERT (ring->tx_head >= ring->tx_tail);
590 dpdk_clear_hw_interface_counters (u32 instance)
592 dpdk_main_t *dm = &dpdk_main;
593 dpdk_device_t *xd = vec_elt_at_index (dm->devices, instance);
596 * Set the "last_cleared_stats" to the current stats, so that
597 * things appear to clear from a display perspective.
599 dpdk_update_counters (xd, vlib_time_now (dm->vlib_main));
601 clib_memcpy (&xd->last_cleared_stats, &xd->stats, sizeof (xd->stats));
602 clib_memcpy (xd->last_cleared_xstats, xd->xstats,
603 vec_len (xd->last_cleared_xstats) *
604 sizeof (xd->last_cleared_xstats[0]));
608 static clib_error_t *
609 dpdk_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
611 vnet_hw_interface_t *hif = vnet_get_hw_interface (vnm, hw_if_index);
612 uword is_up = (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) != 0;
613 dpdk_main_t *dm = &dpdk_main;
614 dpdk_device_t *xd = vec_elt_at_index (dm->devices, hif->dev_instance);
616 if (xd->flags & DPDK_DEVICE_FLAG_PMD_INIT_FAIL)
617 return clib_error_return (0, "Interface not initialized");
621 vnet_hw_interface_set_flags (vnm, xd->hw_if_index,
622 VNET_HW_INTERFACE_FLAG_LINK_UP);
623 if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) == 0)
624 dpdk_device_start (xd);
625 xd->flags |= DPDK_DEVICE_FLAG_ADMIN_UP;
626 f64 now = vlib_time_now (dm->vlib_main);
627 dpdk_update_counters (xd, now);
628 dpdk_update_link_state (xd, now);
632 vnet_hw_interface_set_flags (vnm, xd->hw_if_index, 0);
633 if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) != 0)
634 dpdk_device_stop (xd);
635 xd->flags &= ~DPDK_DEVICE_FLAG_ADMIN_UP;
638 return /* no error */ 0;
642 * Dynamically redirect all pkts from a specific interface
643 * to the specified node
646 dpdk_set_interface_next_node (vnet_main_t * vnm, u32 hw_if_index,
649 dpdk_main_t *xm = &dpdk_main;
650 vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
651 dpdk_device_t *xd = vec_elt_at_index (xm->devices, hw->dev_instance);
653 /* Shut off redirection */
654 if (node_index == ~0)
656 xd->per_interface_next_index = node_index;
660 xd->per_interface_next_index =
661 vlib_node_add_next (xm->vlib_main, dpdk_input_node.index, node_index);
665 static clib_error_t *
666 dpdk_subif_add_del_function (vnet_main_t * vnm,
668 struct vnet_sw_interface_t *st, int is_add)
670 dpdk_main_t *xm = &dpdk_main;
671 vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
672 dpdk_device_t *xd = vec_elt_at_index (xm->devices, hw->dev_instance);
673 vnet_sw_interface_t *t = (vnet_sw_interface_t *) st;
675 u32 prev_subifs = xd->num_subifs;
676 clib_error_t *err = 0;
680 else if (xd->num_subifs)
683 if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
686 /* currently we program VLANS only for IXGBE VF and I40E VF */
687 if ((xd->pmd != VNET_DPDK_PMD_IXGBEVF) && (xd->pmd != VNET_DPDK_PMD_I40EVF))
690 if (t->sub.eth.flags.no_tags == 1)
693 if ((t->sub.eth.flags.one_tag != 1) || (t->sub.eth.flags.exact_match != 1))
695 xd->num_subifs = prev_subifs;
696 err = clib_error_return (0, "unsupported VLAN setup");
700 vlan_offload = rte_eth_dev_get_vlan_offload (xd->device_index);
701 vlan_offload |= ETH_VLAN_FILTER_OFFLOAD;
703 if ((r = rte_eth_dev_set_vlan_offload (xd->device_index, vlan_offload)))
705 xd->num_subifs = prev_subifs;
706 err = clib_error_return (0, "rte_eth_dev_set_vlan_offload[%d]: err %d",
707 xd->device_index, r);
713 rte_eth_dev_vlan_filter (xd->device_index, t->sub.eth.outer_vlan_id,
716 xd->num_subifs = prev_subifs;
717 err = clib_error_return (0, "rte_eth_dev_vlan_filter[%d]: err %d",
718 xd->device_index, r);
724 xd->flags |= DPDK_DEVICE_FLAG_HAVE_SUBIF;
726 xd->flags &= ~DPDK_DEVICE_FLAG_HAVE_SUBIF;
732 VNET_DEVICE_CLASS (dpdk_device_class) = {
734 .tx_function = dpdk_interface_tx,
735 .tx_function_n_errors = DPDK_TX_FUNC_N_ERROR,
736 .tx_function_error_strings = dpdk_tx_func_error_strings,
737 .format_device_name = format_dpdk_device_name,
738 .format_device = format_dpdk_device,
739 .format_tx_trace = format_dpdk_tx_dma_trace,
740 .clear_counters = dpdk_clear_hw_interface_counters,
741 .admin_up_down_function = dpdk_interface_admin_up_down,
742 .subif_add_del_function = dpdk_subif_add_del_function,
743 .rx_redirect_to_node = dpdk_set_interface_next_node,
744 .mac_addr_change_function = dpdk_set_mac_address,
747 VLIB_DEVICE_TX_FUNCTION_MULTIARCH (dpdk_device_class, dpdk_interface_tx)
750 #define UP_DOWN_FLAG_EVENT 1
753 admin_up_down_process (vlib_main_t * vm,
754 vlib_node_runtime_t * rt, vlib_frame_t * f)
756 clib_error_t *error = 0;
758 uword *event_data = 0;
764 vlib_process_wait_for_event (vm);
766 event_type = vlib_process_get_events (vm, &event_data);
768 dpdk_main.admin_up_down_in_progress = 1;
772 case UP_DOWN_FLAG_EVENT:
774 if (vec_len (event_data) == 2)
776 sw_if_index = event_data[0];
777 flags = event_data[1];
779 vnet_sw_interface_set_flags (vnet_get_main (), sw_if_index,
781 clib_error_report (error);
787 vec_reset_length (event_data);
789 dpdk_main.admin_up_down_in_progress = 0;
792 return 0; /* or not */
796 VLIB_REGISTER_NODE (admin_up_down_process_node,static) = {
797 .function = admin_up_down_process,
798 .type = VLIB_NODE_TYPE_PROCESS,
799 .name = "admin-up-down-process",
800 .process_log2_n_stack_bytes = 17, // 256KB
805 * fd.io coding-style-patch-verification: ON
808 * eval: (c-set-style "gnu")