1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Intel Corporation.
9 #include <netinet/in.h>
11 #include <sys/socket.h>
12 #include <sys/ioctl.h>
13 #include <linux/if_ether.h>
14 #include <linux/if_xdp.h>
15 #include <linux/if_link.h>
16 #include <linux/ethtool.h>
17 #include <linux/sockios.h>
18 #include "af_xdp_deps.h"
21 #include <rte_ethdev.h>
22 #include <rte_ethdev_driver.h>
23 #include <rte_ethdev_vdev.h>
24 #include <rte_kvargs.h>
25 #include <rte_bus_vdev.h>
26 #include <rte_string_fns.h>
27 #include <rte_branch_prediction.h>
28 #include <rte_common.h>
31 #include <rte_ether.h>
32 #include <rte_lcore.h>
34 #include <rte_memory.h>
35 #include <rte_memzone.h>
36 #include <rte_mempool.h>
38 #include <rte_malloc.h>
40 #include <rte_spinlock.h>
57 RTE_LOG_REGISTER(af_xdp_logtype, pmd.net.af_xdp, NOTICE);
59 #define AF_XDP_LOG(level, fmt, args...) \
60 rte_log(RTE_LOG_ ## level, af_xdp_logtype, \
61 "%s(): " fmt, __func__, ##args)
63 #define ETH_AF_XDP_FRAME_SIZE 2048
64 #define ETH_AF_XDP_NUM_BUFFERS 4096
65 #define ETH_AF_XDP_DFLT_NUM_DESCS XSK_RING_CONS__DEFAULT_NUM_DESCS
66 #define ETH_AF_XDP_DFLT_START_QUEUE_IDX 0
67 #define ETH_AF_XDP_DFLT_QUEUE_COUNT 1
69 #define ETH_AF_XDP_RX_BATCH_SIZE 32
70 #define ETH_AF_XDP_TX_BATCH_SIZE 32
73 struct xsk_umem_info {
74 struct xsk_umem *umem;
75 struct rte_ring *buf_ring;
76 const struct rte_memzone *mz;
77 struct rte_mempool *mb_pool;
90 struct xsk_ring_cons rx;
91 struct xsk_umem_info *umem;
92 struct xsk_socket *xsk;
93 struct rte_mempool *mb_pool;
95 struct rx_stats stats;
97 struct xsk_ring_prod fq;
98 struct xsk_ring_cons cq;
100 struct pkt_tx_queue *pair;
101 struct pollfd fds[1];
111 struct pkt_tx_queue {
112 struct xsk_ring_prod tx;
113 struct xsk_umem_info *umem;
115 struct tx_stats stats;
117 struct pkt_rx_queue *pair;
121 struct pmd_internals {
123 char if_name[IFNAMSIZ];
127 int combined_queue_cnt;
129 char prog_path[PATH_MAX];
130 bool custom_prog_configured;
132 struct rte_ether_addr eth_addr;
134 struct pkt_rx_queue *rx_queues;
135 struct pkt_tx_queue *tx_queues;
138 #define ETH_AF_XDP_IFACE_ARG "iface"
139 #define ETH_AF_XDP_START_QUEUE_ARG "start_queue"
140 #define ETH_AF_XDP_QUEUE_COUNT_ARG "queue_count"
141 #define ETH_AF_XDP_SHARED_UMEM_ARG "shared_umem"
142 #define ETH_AF_XDP_PROG_ARG "xdp_prog"
144 static const char * const valid_arguments[] = {
145 ETH_AF_XDP_IFACE_ARG,
146 ETH_AF_XDP_START_QUEUE_ARG,
147 ETH_AF_XDP_QUEUE_COUNT_ARG,
148 ETH_AF_XDP_SHARED_UMEM_ARG,
153 static const struct rte_eth_link pmd_link = {
154 .link_speed = ETH_SPEED_NUM_10G,
155 .link_duplex = ETH_LINK_FULL_DUPLEX,
156 .link_status = ETH_LINK_DOWN,
157 .link_autoneg = ETH_LINK_AUTONEG
160 /* List which tracks PMDs to facilitate sharing UMEMs across them. */
161 struct internal_list {
162 TAILQ_ENTRY(internal_list) next;
163 struct rte_eth_dev *eth_dev;
166 TAILQ_HEAD(internal_list_head, internal_list);
167 static struct internal_list_head internal_list =
168 TAILQ_HEAD_INITIALIZER(internal_list);
170 static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
172 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
174 reserve_fill_queue_zc(struct xsk_umem_info *umem, uint16_t reserve_size,
175 struct rte_mbuf **bufs, struct xsk_ring_prod *fq)
180 if (unlikely(!xsk_ring_prod__reserve(fq, reserve_size, &idx))) {
181 for (i = 0; i < reserve_size; i++)
182 rte_pktmbuf_free(bufs[i]);
183 AF_XDP_LOG(DEBUG, "Failed to reserve enough fq descs.\n");
187 for (i = 0; i < reserve_size; i++) {
191 fq_addr = xsk_ring_prod__fill_addr(fq, idx++);
192 addr = (uint64_t)bufs[i] - (uint64_t)umem->buffer -
193 umem->mb_pool->header_size;
197 xsk_ring_prod__submit(fq, reserve_size);
203 reserve_fill_queue_cp(struct xsk_umem_info *umem, uint16_t reserve_size,
204 struct rte_mbuf **bufs __rte_unused,
205 struct xsk_ring_prod *fq)
207 void *addrs[reserve_size];
211 if (rte_ring_dequeue_bulk(umem->buf_ring, addrs, reserve_size, NULL)
213 AF_XDP_LOG(DEBUG, "Failed to get enough buffers for fq.\n");
217 if (unlikely(!xsk_ring_prod__reserve(fq, reserve_size, &idx))) {
218 AF_XDP_LOG(DEBUG, "Failed to reserve enough fq descs.\n");
219 rte_ring_enqueue_bulk(umem->buf_ring, addrs,
224 for (i = 0; i < reserve_size; i++) {
227 fq_addr = xsk_ring_prod__fill_addr(fq, idx++);
228 *fq_addr = (uint64_t)addrs[i];
231 xsk_ring_prod__submit(fq, reserve_size);
238 reserve_fill_queue(struct xsk_umem_info *umem, uint16_t reserve_size,
239 struct rte_mbuf **bufs, struct xsk_ring_prod *fq)
241 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
242 return reserve_fill_queue_zc(umem, reserve_size, bufs, fq);
244 return reserve_fill_queue_cp(umem, reserve_size, bufs, fq);
248 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
250 af_xdp_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
252 struct pkt_rx_queue *rxq = queue;
253 struct xsk_ring_cons *rx = &rxq->rx;
254 struct xsk_ring_prod *fq = &rxq->fq;
255 struct xsk_umem_info *umem = rxq->umem;
257 unsigned long rx_bytes = 0;
259 struct rte_mbuf *fq_bufs[ETH_AF_XDP_RX_BATCH_SIZE];
261 /* allocate bufs for fill queue replenishment after rx */
262 if (rte_pktmbuf_alloc_bulk(umem->mb_pool, fq_bufs, nb_pkts)) {
264 "Failed to get enough buffers for fq.\n");
268 rcvd = xsk_ring_cons__peek(rx, nb_pkts, &idx_rx);
271 #if defined(XDP_USE_NEED_WAKEUP)
272 if (xsk_ring_prod__needs_wakeup(fq))
273 (void)poll(rxq->fds, 1, 1000);
279 for (i = 0; i < rcvd; i++) {
280 const struct xdp_desc *desc;
285 desc = xsk_ring_cons__rx_desc(rx, idx_rx++);
289 offset = xsk_umem__extract_offset(addr);
290 addr = xsk_umem__extract_addr(addr);
292 bufs[i] = (struct rte_mbuf *)
293 xsk_umem__get_data(umem->buffer, addr +
294 umem->mb_pool->header_size);
295 bufs[i]->data_off = offset - sizeof(struct rte_mbuf) -
296 rte_pktmbuf_priv_size(umem->mb_pool) -
297 umem->mb_pool->header_size;
299 rte_pktmbuf_pkt_len(bufs[i]) = len;
300 rte_pktmbuf_data_len(bufs[i]) = len;
304 xsk_ring_cons__release(rx, rcvd);
306 (void)reserve_fill_queue(umem, rcvd, fq_bufs, fq);
309 rxq->stats.rx_pkts += rcvd;
310 rxq->stats.rx_bytes += rx_bytes;
314 rte_mempool_put_bulk(umem->mb_pool, (void **)&fq_bufs[rcvd],
321 af_xdp_rx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
323 struct pkt_rx_queue *rxq = queue;
324 struct xsk_ring_cons *rx = &rxq->rx;
325 struct xsk_umem_info *umem = rxq->umem;
326 struct xsk_ring_prod *fq = &rxq->fq;
328 unsigned long rx_bytes = 0;
330 uint32_t free_thresh = fq->size >> 1;
331 struct rte_mbuf *mbufs[ETH_AF_XDP_RX_BATCH_SIZE];
333 if (xsk_prod_nb_free(fq, free_thresh) >= free_thresh)
334 (void)reserve_fill_queue(umem, ETH_AF_XDP_RX_BATCH_SIZE,
337 if (unlikely(rte_pktmbuf_alloc_bulk(rxq->mb_pool, mbufs, nb_pkts) != 0))
340 rcvd = xsk_ring_cons__peek(rx, nb_pkts, &idx_rx);
342 #if defined(XDP_USE_NEED_WAKEUP)
343 if (xsk_ring_prod__needs_wakeup(fq))
344 (void)poll(rxq->fds, 1, 1000);
350 for (i = 0; i < rcvd; i++) {
351 const struct xdp_desc *desc;
356 desc = xsk_ring_cons__rx_desc(rx, idx_rx++);
359 pkt = xsk_umem__get_data(rxq->umem->mz->addr, addr);
361 rte_memcpy(rte_pktmbuf_mtod(mbufs[i], void *), pkt, len);
362 rte_ring_enqueue(umem->buf_ring, (void *)addr);
363 rte_pktmbuf_pkt_len(mbufs[i]) = len;
364 rte_pktmbuf_data_len(mbufs[i]) = len;
369 xsk_ring_cons__release(rx, rcvd);
372 rxq->stats.rx_pkts += rcvd;
373 rxq->stats.rx_bytes += rx_bytes;
377 rte_mempool_put_bulk(rxq->mb_pool, (void **)&mbufs[rcvd],
385 eth_af_xdp_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
387 nb_pkts = RTE_MIN(nb_pkts, ETH_AF_XDP_RX_BATCH_SIZE);
389 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
390 return af_xdp_rx_zc(queue, bufs, nb_pkts);
392 return af_xdp_rx_cp(queue, bufs, nb_pkts);
397 pull_umem_cq(struct xsk_umem_info *umem, int size, struct xsk_ring_cons *cq)
402 n = xsk_ring_cons__peek(cq, size, &idx_cq);
404 for (i = 0; i < n; i++) {
406 addr = *xsk_ring_cons__comp_addr(cq, idx_cq++);
407 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
408 addr = xsk_umem__extract_addr(addr);
409 rte_pktmbuf_free((struct rte_mbuf *)
410 xsk_umem__get_data(umem->buffer,
411 addr + umem->mb_pool->header_size));
413 rte_ring_enqueue(umem->buf_ring, (void *)addr);
417 xsk_ring_cons__release(cq, n);
421 kick_tx(struct pkt_tx_queue *txq, struct xsk_ring_cons *cq)
423 struct xsk_umem_info *umem = txq->umem;
425 pull_umem_cq(umem, XSK_RING_CONS__DEFAULT_NUM_DESCS, cq);
427 #if defined(XDP_USE_NEED_WAKEUP)
428 if (xsk_ring_prod__needs_wakeup(&txq->tx))
430 while (send(xsk_socket__fd(txq->pair->xsk), NULL,
431 0, MSG_DONTWAIT) < 0) {
432 /* some thing unexpected */
433 if (errno != EBUSY && errno != EAGAIN && errno != EINTR)
436 /* pull from completion queue to leave more space */
439 XSK_RING_CONS__DEFAULT_NUM_DESCS,
444 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
446 af_xdp_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
448 struct pkt_tx_queue *txq = queue;
449 struct xsk_umem_info *umem = txq->umem;
450 struct rte_mbuf *mbuf;
451 unsigned long tx_bytes = 0;
455 struct xdp_desc *desc;
456 uint64_t addr, offset;
457 struct xsk_ring_cons *cq = &txq->pair->cq;
458 uint32_t free_thresh = cq->size >> 1;
460 if (xsk_cons_nb_avail(cq, free_thresh) >= free_thresh)
461 pull_umem_cq(umem, XSK_RING_CONS__DEFAULT_NUM_DESCS, cq);
463 for (i = 0; i < nb_pkts; i++) {
466 if (mbuf->pool == umem->mb_pool) {
467 if (!xsk_ring_prod__reserve(&txq->tx, 1, &idx_tx)) {
469 if (!xsk_ring_prod__reserve(&txq->tx, 1,
473 desc = xsk_ring_prod__tx_desc(&txq->tx, idx_tx);
474 desc->len = mbuf->pkt_len;
475 addr = (uint64_t)mbuf - (uint64_t)umem->buffer -
476 umem->mb_pool->header_size;
477 offset = rte_pktmbuf_mtod(mbuf, uint64_t) -
479 umem->mb_pool->header_size;
480 offset = offset << XSK_UNALIGNED_BUF_OFFSET_SHIFT;
481 desc->addr = addr | offset;
484 struct rte_mbuf *local_mbuf =
485 rte_pktmbuf_alloc(umem->mb_pool);
488 if (local_mbuf == NULL)
491 if (!xsk_ring_prod__reserve(&txq->tx, 1, &idx_tx)) {
492 rte_pktmbuf_free(local_mbuf);
497 desc = xsk_ring_prod__tx_desc(&txq->tx, idx_tx);
498 desc->len = mbuf->pkt_len;
500 addr = (uint64_t)local_mbuf - (uint64_t)umem->buffer -
501 umem->mb_pool->header_size;
502 offset = rte_pktmbuf_mtod(local_mbuf, uint64_t) -
503 (uint64_t)local_mbuf +
504 umem->mb_pool->header_size;
505 pkt = xsk_umem__get_data(umem->buffer, addr + offset);
506 offset = offset << XSK_UNALIGNED_BUF_OFFSET_SHIFT;
507 desc->addr = addr | offset;
508 rte_memcpy(pkt, rte_pktmbuf_mtod(mbuf, void *),
510 rte_pktmbuf_free(mbuf);
514 tx_bytes += mbuf->pkt_len;
520 xsk_ring_prod__submit(&txq->tx, count);
522 txq->stats.tx_pkts += count;
523 txq->stats.tx_bytes += tx_bytes;
524 txq->stats.tx_dropped += nb_pkts - count;
530 af_xdp_tx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
532 struct pkt_tx_queue *txq = queue;
533 struct xsk_umem_info *umem = txq->umem;
534 struct rte_mbuf *mbuf;
535 void *addrs[ETH_AF_XDP_TX_BATCH_SIZE];
536 unsigned long tx_bytes = 0;
539 struct xsk_ring_cons *cq = &txq->pair->cq;
541 nb_pkts = RTE_MIN(nb_pkts, ETH_AF_XDP_TX_BATCH_SIZE);
543 pull_umem_cq(umem, nb_pkts, cq);
545 nb_pkts = rte_ring_dequeue_bulk(umem->buf_ring, addrs,
550 if (xsk_ring_prod__reserve(&txq->tx, nb_pkts, &idx_tx) != nb_pkts) {
552 rte_ring_enqueue_bulk(umem->buf_ring, addrs, nb_pkts, NULL);
556 for (i = 0; i < nb_pkts; i++) {
557 struct xdp_desc *desc;
560 desc = xsk_ring_prod__tx_desc(&txq->tx, idx_tx + i);
562 desc->len = mbuf->pkt_len;
564 desc->addr = (uint64_t)addrs[i];
565 pkt = xsk_umem__get_data(umem->mz->addr,
567 rte_memcpy(pkt, rte_pktmbuf_mtod(mbuf, void *), desc->len);
568 tx_bytes += mbuf->pkt_len;
569 rte_pktmbuf_free(mbuf);
572 xsk_ring_prod__submit(&txq->tx, nb_pkts);
576 txq->stats.tx_pkts += nb_pkts;
577 txq->stats.tx_bytes += tx_bytes;
584 eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
586 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
587 return af_xdp_tx_zc(queue, bufs, nb_pkts);
589 return af_xdp_tx_cp(queue, bufs, nb_pkts);
594 eth_dev_start(struct rte_eth_dev *dev)
596 dev->data->dev_link.link_status = ETH_LINK_UP;
601 /* This function gets called when the current port gets stopped. */
603 eth_dev_stop(struct rte_eth_dev *dev)
605 dev->data->dev_link.link_status = ETH_LINK_DOWN;
609 /* Find ethdev in list */
610 static inline struct internal_list *
611 find_internal_resource(struct pmd_internals *port_int)
614 struct internal_list *list = NULL;
616 if (port_int == NULL)
619 pthread_mutex_lock(&internal_list_lock);
621 TAILQ_FOREACH(list, &internal_list, next) {
622 struct pmd_internals *list_int =
623 list->eth_dev->data->dev_private;
624 if (list_int == port_int) {
630 pthread_mutex_unlock(&internal_list_lock);
638 /* Check if the netdev,qid context already exists */
640 ctx_exists(struct pkt_rx_queue *rxq, const char *ifname,
641 struct pkt_rx_queue *list_rxq, const char *list_ifname)
645 if (rxq->xsk_queue_idx == list_rxq->xsk_queue_idx &&
646 !strncmp(ifname, list_ifname, IFNAMSIZ)) {
647 AF_XDP_LOG(ERR, "ctx %s,%i already exists, cannot share umem\n",
648 ifname, rxq->xsk_queue_idx);
655 /* Get a pointer to an existing UMEM which overlays the rxq's mb_pool */
657 get_shared_umem(struct pkt_rx_queue *rxq, const char *ifname,
658 struct xsk_umem_info **umem)
660 struct internal_list *list;
661 struct pmd_internals *internals;
663 struct rte_mempool *mb_pool = rxq->mb_pool;
668 pthread_mutex_lock(&internal_list_lock);
670 TAILQ_FOREACH(list, &internal_list, next) {
671 internals = list->eth_dev->data->dev_private;
672 for (i = 0; i < internals->queue_cnt; i++) {
673 struct pkt_rx_queue *list_rxq =
674 &internals->rx_queues[i];
677 if (mb_pool == internals->rx_queues[i].mb_pool) {
678 if (ctx_exists(rxq, ifname, list_rxq,
679 internals->if_name)) {
684 &internals->rx_queues[i].umem->refcnt,
686 *umem = internals->rx_queues[i].umem;
694 pthread_mutex_unlock(&internal_list_lock);
700 eth_dev_configure(struct rte_eth_dev *dev)
702 struct pmd_internals *internal = dev->data->dev_private;
704 /* rx/tx must be paired */
705 if (dev->data->nb_rx_queues != dev->data->nb_tx_queues)
708 if (internal->shared_umem) {
709 struct internal_list *list = NULL;
710 const char *name = dev->device->name;
712 /* Ensure PMD is not already inserted into the list */
713 list = find_internal_resource(internal);
717 list = rte_zmalloc_socket(name, sizeof(*list), 0,
718 dev->device->numa_node);
723 pthread_mutex_lock(&internal_list_lock);
724 TAILQ_INSERT_TAIL(&internal_list, list, next);
725 pthread_mutex_unlock(&internal_list_lock);
732 eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
734 struct pmd_internals *internals = dev->data->dev_private;
736 dev_info->if_index = internals->if_index;
737 dev_info->max_mac_addrs = 1;
738 dev_info->max_rx_pktlen = ETH_FRAME_LEN;
739 dev_info->max_rx_queues = internals->queue_cnt;
740 dev_info->max_tx_queues = internals->queue_cnt;
742 dev_info->min_mtu = RTE_ETHER_MIN_MTU;
743 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
744 dev_info->max_mtu = getpagesize() -
745 sizeof(struct rte_mempool_objhdr) -
746 sizeof(struct rte_mbuf) -
747 RTE_PKTMBUF_HEADROOM - XDP_PACKET_HEADROOM;
749 dev_info->max_mtu = ETH_AF_XDP_FRAME_SIZE - XDP_PACKET_HEADROOM;
752 dev_info->default_rxportconf.nb_queues = 1;
753 dev_info->default_txportconf.nb_queues = 1;
754 dev_info->default_rxportconf.ring_size = ETH_AF_XDP_DFLT_NUM_DESCS;
755 dev_info->default_txportconf.ring_size = ETH_AF_XDP_DFLT_NUM_DESCS;
761 eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
763 struct pmd_internals *internals = dev->data->dev_private;
764 struct xdp_statistics xdp_stats;
765 struct pkt_rx_queue *rxq;
766 struct pkt_tx_queue *txq;
770 for (i = 0; i < dev->data->nb_rx_queues; i++) {
771 optlen = sizeof(struct xdp_statistics);
772 rxq = &internals->rx_queues[i];
774 stats->q_ipackets[i] = rxq->stats.rx_pkts;
775 stats->q_ibytes[i] = rxq->stats.rx_bytes;
777 stats->q_opackets[i] = txq->stats.tx_pkts;
778 stats->q_obytes[i] = txq->stats.tx_bytes;
780 stats->ipackets += stats->q_ipackets[i];
781 stats->ibytes += stats->q_ibytes[i];
782 stats->imissed += rxq->stats.rx_dropped;
783 stats->oerrors += txq->stats.tx_dropped;
784 ret = getsockopt(xsk_socket__fd(rxq->xsk), SOL_XDP,
785 XDP_STATISTICS, &xdp_stats, &optlen);
787 AF_XDP_LOG(ERR, "getsockopt() failed for XDP_STATISTICS.\n");
790 stats->imissed += xdp_stats.rx_dropped;
792 stats->opackets += stats->q_opackets[i];
793 stats->obytes += stats->q_obytes[i];
800 eth_stats_reset(struct rte_eth_dev *dev)
802 struct pmd_internals *internals = dev->data->dev_private;
805 for (i = 0; i < internals->queue_cnt; i++) {
806 memset(&internals->rx_queues[i].stats, 0,
807 sizeof(struct rx_stats));
808 memset(&internals->tx_queues[i].stats, 0,
809 sizeof(struct tx_stats));
816 remove_xdp_program(struct pmd_internals *internals)
818 uint32_t curr_prog_id = 0;
820 if (bpf_get_link_xdp_id(internals->if_index, &curr_prog_id,
821 XDP_FLAGS_UPDATE_IF_NOEXIST)) {
822 AF_XDP_LOG(ERR, "bpf_get_link_xdp_id failed\n");
825 bpf_set_link_xdp_fd(internals->if_index, -1,
826 XDP_FLAGS_UPDATE_IF_NOEXIST);
830 xdp_umem_destroy(struct xsk_umem_info *umem)
832 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
833 umem->mb_pool = NULL;
835 rte_memzone_free(umem->mz);
838 rte_ring_free(umem->buf_ring);
839 umem->buf_ring = NULL;
847 eth_dev_close(struct rte_eth_dev *dev)
849 struct pmd_internals *internals = dev->data->dev_private;
850 struct pkt_rx_queue *rxq;
853 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
856 AF_XDP_LOG(INFO, "Closing AF_XDP ethdev on numa socket %u\n",
859 for (i = 0; i < internals->queue_cnt; i++) {
860 rxq = &internals->rx_queues[i];
861 if (rxq->umem == NULL)
863 xsk_socket__delete(rxq->xsk);
865 if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE)
867 (void)xsk_umem__delete(rxq->umem->umem);
868 xdp_umem_destroy(rxq->umem);
871 /* free pkt_tx_queue */
877 * MAC is not allocated dynamically, setting it to NULL would prevent
878 * from releasing it in rte_eth_dev_release_port.
880 dev->data->mac_addrs = NULL;
882 remove_xdp_program(internals);
884 if (internals->shared_umem) {
885 struct internal_list *list;
887 /* Remove ethdev from list used to track and share UMEMs */
888 list = find_internal_resource(internals);
890 pthread_mutex_lock(&internal_list_lock);
891 TAILQ_REMOVE(&internal_list, list, next);
892 pthread_mutex_unlock(&internal_list_lock);
901 eth_queue_release(void *q __rte_unused)
906 eth_link_update(struct rte_eth_dev *dev __rte_unused,
907 int wait_to_complete __rte_unused)
912 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
913 static inline uintptr_t get_base_addr(struct rte_mempool *mp, uint64_t *align)
915 struct rte_mempool_memhdr *memhdr;
916 uintptr_t memhdr_addr, aligned_addr;
918 memhdr = STAILQ_FIRST(&mp->mem_list);
919 memhdr_addr = (uintptr_t)memhdr->addr;
920 aligned_addr = memhdr_addr & ~(getpagesize() - 1);
921 *align = memhdr_addr - aligned_addr;
927 xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals,
928 struct pkt_rx_queue *rxq)
930 struct xsk_umem_info *umem = NULL;
932 struct xsk_umem_config usr_config = {
933 .fill_size = ETH_AF_XDP_DFLT_NUM_DESCS * 2,
934 .comp_size = ETH_AF_XDP_DFLT_NUM_DESCS,
935 .flags = XDP_UMEM_UNALIGNED_CHUNK_FLAG};
936 void *base_addr = NULL;
937 struct rte_mempool *mb_pool = rxq->mb_pool;
938 uint64_t umem_size, align = 0;
940 if (internals->shared_umem) {
941 if (get_shared_umem(rxq, internals->if_name, &umem) < 0)
945 __atomic_load_n(&umem->refcnt, __ATOMIC_ACQUIRE) <
947 AF_XDP_LOG(INFO, "%s,qid%i sharing UMEM\n",
948 internals->if_name, rxq->xsk_queue_idx);
949 __atomic_fetch_add(&umem->refcnt, 1, __ATOMIC_ACQUIRE);
954 usr_config.frame_size =
955 rte_mempool_calc_obj_size(mb_pool->elt_size,
956 mb_pool->flags, NULL);
957 usr_config.frame_headroom = mb_pool->header_size +
958 sizeof(struct rte_mbuf) +
959 rte_pktmbuf_priv_size(mb_pool) +
960 RTE_PKTMBUF_HEADROOM;
962 umem = rte_zmalloc_socket("umem", sizeof(*umem), 0,
965 AF_XDP_LOG(ERR, "Failed to allocate umem info");
969 umem->mb_pool = mb_pool;
970 base_addr = (void *)get_base_addr(mb_pool, &align);
971 umem_size = (uint64_t)mb_pool->populated_size *
972 (uint64_t)usr_config.frame_size +
975 ret = xsk_umem__create(&umem->umem, base_addr, umem_size,
976 &rxq->fq, &rxq->cq, &usr_config);
978 AF_XDP_LOG(ERR, "Failed to create umem");
981 umem->buffer = base_addr;
983 if (internals->shared_umem) {
984 umem->max_xsks = mb_pool->populated_size /
985 ETH_AF_XDP_NUM_BUFFERS;
986 AF_XDP_LOG(INFO, "Max xsks for UMEM %s: %u\n",
987 mb_pool->name, umem->max_xsks);
990 __atomic_store_n(&umem->refcnt, 1, __ATOMIC_RELEASE);
995 xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals,
996 struct pkt_rx_queue *rxq)
998 struct xsk_umem_info *umem;
999 const struct rte_memzone *mz;
1000 struct xsk_umem_config usr_config = {
1001 .fill_size = ETH_AF_XDP_DFLT_NUM_DESCS,
1002 .comp_size = ETH_AF_XDP_DFLT_NUM_DESCS,
1003 .frame_size = ETH_AF_XDP_FRAME_SIZE,
1004 .frame_headroom = 0 };
1005 char ring_name[RTE_RING_NAMESIZE];
1006 char mz_name[RTE_MEMZONE_NAMESIZE];
1010 umem = rte_zmalloc_socket("umem", sizeof(*umem), 0, rte_socket_id());
1012 AF_XDP_LOG(ERR, "Failed to allocate umem info");
1016 snprintf(ring_name, sizeof(ring_name), "af_xdp_ring_%s_%u",
1017 internals->if_name, rxq->xsk_queue_idx);
1018 umem->buf_ring = rte_ring_create(ring_name,
1019 ETH_AF_XDP_NUM_BUFFERS,
1022 if (umem->buf_ring == NULL) {
1023 AF_XDP_LOG(ERR, "Failed to create rte_ring\n");
1027 for (i = 0; i < ETH_AF_XDP_NUM_BUFFERS; i++)
1028 rte_ring_enqueue(umem->buf_ring,
1029 (void *)(i * ETH_AF_XDP_FRAME_SIZE));
1031 snprintf(mz_name, sizeof(mz_name), "af_xdp_umem_%s_%u",
1032 internals->if_name, rxq->xsk_queue_idx);
1033 mz = rte_memzone_reserve_aligned(mz_name,
1034 ETH_AF_XDP_NUM_BUFFERS * ETH_AF_XDP_FRAME_SIZE,
1035 rte_socket_id(), RTE_MEMZONE_IOVA_CONTIG,
1038 AF_XDP_LOG(ERR, "Failed to reserve memzone for af_xdp umem.\n");
1042 ret = xsk_umem__create(&umem->umem, mz->addr,
1043 ETH_AF_XDP_NUM_BUFFERS * ETH_AF_XDP_FRAME_SIZE,
1048 AF_XDP_LOG(ERR, "Failed to create umem");
1057 xdp_umem_destroy(umem);
1062 load_custom_xdp_prog(const char *prog_path, int if_index)
1064 int ret, prog_fd = -1;
1065 struct bpf_object *obj;
1066 struct bpf_map *map;
1068 ret = bpf_prog_load(prog_path, BPF_PROG_TYPE_XDP, &obj, &prog_fd);
1070 AF_XDP_LOG(ERR, "Failed to load program %s\n", prog_path);
1075 * The loaded program must provision for a map of xsks, such that some
1076 * traffic can be redirected to userspace. When the xsk is created,
1077 * libbpf inserts it into the map.
1079 map = bpf_object__find_map_by_name(obj, "xsks_map");
1081 AF_XDP_LOG(ERR, "Failed to find xsks_map in %s\n", prog_path);
1085 /* Link the program with the given network device */
1086 ret = bpf_set_link_xdp_fd(if_index, prog_fd,
1087 XDP_FLAGS_UPDATE_IF_NOEXIST);
1089 AF_XDP_LOG(ERR, "Failed to set prog fd %d on interface\n",
1094 AF_XDP_LOG(INFO, "Successfully loaded XDP program %s with fd %d\n",
1095 prog_path, prog_fd);
1101 xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
1104 struct xsk_socket_config cfg;
1105 struct pkt_tx_queue *txq = rxq->pair;
1107 int reserve_size = ETH_AF_XDP_DFLT_NUM_DESCS;
1108 struct rte_mbuf *fq_bufs[reserve_size];
1110 rxq->umem = xdp_umem_configure(internals, rxq);
1111 if (rxq->umem == NULL)
1113 txq->umem = rxq->umem;
1115 cfg.rx_size = ring_size;
1116 cfg.tx_size = ring_size;
1117 cfg.libbpf_flags = 0;
1118 cfg.xdp_flags = XDP_FLAGS_UPDATE_IF_NOEXIST;
1121 #if defined(XDP_USE_NEED_WAKEUP)
1122 cfg.bind_flags |= XDP_USE_NEED_WAKEUP;
1125 if (strnlen(internals->prog_path, PATH_MAX) &&
1126 !internals->custom_prog_configured) {
1127 ret = load_custom_xdp_prog(internals->prog_path,
1128 internals->if_index);
1130 AF_XDP_LOG(ERR, "Failed to load custom XDP program %s\n",
1131 internals->prog_path);
1134 internals->custom_prog_configured = 1;
1137 if (internals->shared_umem)
1138 ret = create_shared_socket(&rxq->xsk, internals->if_name,
1139 rxq->xsk_queue_idx, rxq->umem->umem, &rxq->rx,
1140 &txq->tx, &rxq->fq, &rxq->cq, &cfg);
1142 ret = xsk_socket__create(&rxq->xsk, internals->if_name,
1143 rxq->xsk_queue_idx, rxq->umem->umem, &rxq->rx,
1147 AF_XDP_LOG(ERR, "Failed to create xsk socket.\n");
1151 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
1152 if (rte_pktmbuf_alloc_bulk(rxq->umem->mb_pool, fq_bufs, reserve_size)) {
1153 AF_XDP_LOG(DEBUG, "Failed to get enough buffers for fq.\n");
1157 ret = reserve_fill_queue(rxq->umem, reserve_size, fq_bufs, &rxq->fq);
1159 xsk_socket__delete(rxq->xsk);
1160 AF_XDP_LOG(ERR, "Failed to reserve fill queue.\n");
1167 if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) == 0)
1168 xdp_umem_destroy(rxq->umem);
1174 eth_rx_queue_setup(struct rte_eth_dev *dev,
1175 uint16_t rx_queue_id,
1176 uint16_t nb_rx_desc,
1177 unsigned int socket_id __rte_unused,
1178 const struct rte_eth_rxconf *rx_conf __rte_unused,
1179 struct rte_mempool *mb_pool)
1181 struct pmd_internals *internals = dev->data->dev_private;
1182 struct pkt_rx_queue *rxq;
1185 rxq = &internals->rx_queues[rx_queue_id];
1187 AF_XDP_LOG(INFO, "Set up rx queue, rx queue id: %d, xsk queue id: %d\n",
1188 rx_queue_id, rxq->xsk_queue_idx);
1190 #ifndef XDP_UMEM_UNALIGNED_CHUNK_FLAG
1191 uint32_t buf_size, data_size;
1193 /* Now get the space available for data in the mbuf */
1194 buf_size = rte_pktmbuf_data_room_size(mb_pool) -
1195 RTE_PKTMBUF_HEADROOM;
1196 data_size = ETH_AF_XDP_FRAME_SIZE;
1198 if (data_size > buf_size) {
1199 AF_XDP_LOG(ERR, "%s: %d bytes will not fit in mbuf (%d bytes)\n",
1200 dev->device->name, data_size, buf_size);
1206 rxq->mb_pool = mb_pool;
1208 if (xsk_configure(internals, rxq, nb_rx_desc)) {
1209 AF_XDP_LOG(ERR, "Failed to configure xdp socket\n");
1214 rxq->fds[0].fd = xsk_socket__fd(rxq->xsk);
1215 rxq->fds[0].events = POLLIN;
1217 dev->data->rx_queues[rx_queue_id] = rxq;
1225 eth_tx_queue_setup(struct rte_eth_dev *dev,
1226 uint16_t tx_queue_id,
1227 uint16_t nb_tx_desc __rte_unused,
1228 unsigned int socket_id __rte_unused,
1229 const struct rte_eth_txconf *tx_conf __rte_unused)
1231 struct pmd_internals *internals = dev->data->dev_private;
1232 struct pkt_tx_queue *txq;
1234 txq = &internals->tx_queues[tx_queue_id];
1236 dev->data->tx_queues[tx_queue_id] = txq;
1241 eth_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
1243 struct pmd_internals *internals = dev->data->dev_private;
1244 struct ifreq ifr = { .ifr_mtu = mtu };
1248 s = socket(PF_INET, SOCK_DGRAM, 0);
1252 strlcpy(ifr.ifr_name, internals->if_name, IFNAMSIZ);
1253 ret = ioctl(s, SIOCSIFMTU, &ifr);
1256 return (ret < 0) ? -errno : 0;
1260 eth_dev_change_flags(char *if_name, uint32_t flags, uint32_t mask)
1266 s = socket(PF_INET, SOCK_DGRAM, 0);
1270 strlcpy(ifr.ifr_name, if_name, IFNAMSIZ);
1271 if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0) {
1275 ifr.ifr_flags &= mask;
1276 ifr.ifr_flags |= flags;
1277 if (ioctl(s, SIOCSIFFLAGS, &ifr) < 0) {
1287 eth_dev_promiscuous_enable(struct rte_eth_dev *dev)
1289 struct pmd_internals *internals = dev->data->dev_private;
1291 return eth_dev_change_flags(internals->if_name, IFF_PROMISC, ~0);
1295 eth_dev_promiscuous_disable(struct rte_eth_dev *dev)
1297 struct pmd_internals *internals = dev->data->dev_private;
1299 return eth_dev_change_flags(internals->if_name, 0, ~IFF_PROMISC);
1302 static const struct eth_dev_ops ops = {
1303 .dev_start = eth_dev_start,
1304 .dev_stop = eth_dev_stop,
1305 .dev_close = eth_dev_close,
1306 .dev_configure = eth_dev_configure,
1307 .dev_infos_get = eth_dev_info,
1308 .mtu_set = eth_dev_mtu_set,
1309 .promiscuous_enable = eth_dev_promiscuous_enable,
1310 .promiscuous_disable = eth_dev_promiscuous_disable,
1311 .rx_queue_setup = eth_rx_queue_setup,
1312 .tx_queue_setup = eth_tx_queue_setup,
1313 .rx_queue_release = eth_queue_release,
1314 .tx_queue_release = eth_queue_release,
1315 .link_update = eth_link_update,
1316 .stats_get = eth_stats_get,
1317 .stats_reset = eth_stats_reset,
1320 /** parse integer from integer argument */
1322 parse_integer_arg(const char *key __rte_unused,
1323 const char *value, void *extra_args)
1325 int *i = (int *)extra_args;
1328 *i = strtol(value, &end, 10);
1330 AF_XDP_LOG(ERR, "Argument has to be positive.\n");
1337 /** parse name argument */
1339 parse_name_arg(const char *key __rte_unused,
1340 const char *value, void *extra_args)
1342 char *name = extra_args;
1344 if (strnlen(value, IFNAMSIZ) > IFNAMSIZ - 1) {
1345 AF_XDP_LOG(ERR, "Invalid name %s, should be less than %u bytes.\n",
1350 strlcpy(name, value, IFNAMSIZ);
1355 /** parse xdp prog argument */
1357 parse_prog_arg(const char *key __rte_unused,
1358 const char *value, void *extra_args)
1360 char *path = extra_args;
1362 if (strnlen(value, PATH_MAX) == PATH_MAX) {
1363 AF_XDP_LOG(ERR, "Invalid path %s, should be less than %u bytes.\n",
1368 if (access(value, F_OK) != 0) {
1369 AF_XDP_LOG(ERR, "Error accessing %s: %s\n",
1370 value, strerror(errno));
1374 strlcpy(path, value, PATH_MAX);
1380 xdp_get_channels_info(const char *if_name, int *max_queues,
1381 int *combined_queues)
1383 struct ethtool_channels channels;
1387 fd = socket(AF_INET, SOCK_DGRAM, 0);
1391 channels.cmd = ETHTOOL_GCHANNELS;
1392 ifr.ifr_data = (void *)&channels;
1393 strlcpy(ifr.ifr_name, if_name, IFNAMSIZ);
1394 ret = ioctl(fd, SIOCETHTOOL, &ifr);
1396 if (errno == EOPNOTSUPP) {
1404 if (channels.max_combined == 0 || errno == EOPNOTSUPP) {
1405 /* If the device says it has no channels, then all traffic
1406 * is sent to a single stream, so max queues = 1.
1409 *combined_queues = 1;
1411 *max_queues = channels.max_combined;
1412 *combined_queues = channels.combined_count;
1421 parse_parameters(struct rte_kvargs *kvlist, char *if_name, int *start_queue,
1422 int *queue_cnt, int *shared_umem, char *prog_path)
1426 ret = rte_kvargs_process(kvlist, ETH_AF_XDP_IFACE_ARG,
1427 &parse_name_arg, if_name);
1431 ret = rte_kvargs_process(kvlist, ETH_AF_XDP_START_QUEUE_ARG,
1432 &parse_integer_arg, start_queue);
1436 ret = rte_kvargs_process(kvlist, ETH_AF_XDP_QUEUE_COUNT_ARG,
1437 &parse_integer_arg, queue_cnt);
1438 if (ret < 0 || *queue_cnt <= 0) {
1443 ret = rte_kvargs_process(kvlist, ETH_AF_XDP_SHARED_UMEM_ARG,
1444 &parse_integer_arg, shared_umem);
1448 ret = rte_kvargs_process(kvlist, ETH_AF_XDP_PROG_ARG,
1449 &parse_prog_arg, prog_path);
1454 rte_kvargs_free(kvlist);
1459 get_iface_info(const char *if_name,
1460 struct rte_ether_addr *eth_addr,
1464 int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
1469 strlcpy(ifr.ifr_name, if_name, IFNAMSIZ);
1470 if (ioctl(sock, SIOCGIFINDEX, &ifr))
1473 *if_index = ifr.ifr_ifindex;
1475 if (ioctl(sock, SIOCGIFHWADDR, &ifr))
1478 rte_memcpy(eth_addr, ifr.ifr_hwaddr.sa_data, RTE_ETHER_ADDR_LEN);
1488 static struct rte_eth_dev *
1489 init_internals(struct rte_vdev_device *dev, const char *if_name,
1490 int start_queue_idx, int queue_cnt, int shared_umem,
1491 const char *prog_path)
1493 const char *name = rte_vdev_device_name(dev);
1494 const unsigned int numa_node = dev->device.numa_node;
1495 struct pmd_internals *internals;
1496 struct rte_eth_dev *eth_dev;
1500 internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
1501 if (internals == NULL)
1504 internals->start_queue_idx = start_queue_idx;
1505 internals->queue_cnt = queue_cnt;
1506 strlcpy(internals->if_name, if_name, IFNAMSIZ);
1507 strlcpy(internals->prog_path, prog_path, PATH_MAX);
1508 internals->custom_prog_configured = 0;
1510 #ifndef ETH_AF_XDP_SHARED_UMEM
1512 AF_XDP_LOG(ERR, "Shared UMEM feature not available. "
1513 "Check kernel and libbpf version\n");
1514 goto err_free_internals;
1517 internals->shared_umem = shared_umem;
1519 if (xdp_get_channels_info(if_name, &internals->max_queue_cnt,
1520 &internals->combined_queue_cnt)) {
1521 AF_XDP_LOG(ERR, "Failed to get channel info of interface: %s\n",
1523 goto err_free_internals;
1526 if (queue_cnt > internals->combined_queue_cnt) {
1527 AF_XDP_LOG(ERR, "Specified queue count %d is larger than combined queue count %d.\n",
1528 queue_cnt, internals->combined_queue_cnt);
1529 goto err_free_internals;
1532 internals->rx_queues = rte_zmalloc_socket(NULL,
1533 sizeof(struct pkt_rx_queue) * queue_cnt,
1535 if (internals->rx_queues == NULL) {
1536 AF_XDP_LOG(ERR, "Failed to allocate memory for rx queues.\n");
1537 goto err_free_internals;
1540 internals->tx_queues = rte_zmalloc_socket(NULL,
1541 sizeof(struct pkt_tx_queue) * queue_cnt,
1543 if (internals->tx_queues == NULL) {
1544 AF_XDP_LOG(ERR, "Failed to allocate memory for tx queues.\n");
1547 for (i = 0; i < queue_cnt; i++) {
1548 internals->tx_queues[i].pair = &internals->rx_queues[i];
1549 internals->rx_queues[i].pair = &internals->tx_queues[i];
1550 internals->rx_queues[i].xsk_queue_idx = start_queue_idx + i;
1551 internals->tx_queues[i].xsk_queue_idx = start_queue_idx + i;
1554 ret = get_iface_info(if_name, &internals->eth_addr,
1555 &internals->if_index);
1559 eth_dev = rte_eth_vdev_allocate(dev, 0);
1560 if (eth_dev == NULL)
1563 eth_dev->data->dev_private = internals;
1564 eth_dev->data->dev_link = pmd_link;
1565 eth_dev->data->mac_addrs = &internals->eth_addr;
1566 eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
1567 eth_dev->dev_ops = &ops;
1568 eth_dev->rx_pkt_burst = eth_af_xdp_rx;
1569 eth_dev->tx_pkt_burst = eth_af_xdp_tx;
1571 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
1572 AF_XDP_LOG(INFO, "Zero copy between umem and mbuf enabled.\n");
1578 rte_free(internals->tx_queues);
1580 rte_free(internals->rx_queues);
1582 rte_free(internals);
1587 rte_pmd_af_xdp_probe(struct rte_vdev_device *dev)
1589 struct rte_kvargs *kvlist;
1590 char if_name[IFNAMSIZ] = {'\0'};
1591 int xsk_start_queue_idx = ETH_AF_XDP_DFLT_START_QUEUE_IDX;
1592 int xsk_queue_cnt = ETH_AF_XDP_DFLT_QUEUE_COUNT;
1593 int shared_umem = 0;
1594 char prog_path[PATH_MAX] = {'\0'};
1595 struct rte_eth_dev *eth_dev = NULL;
1598 AF_XDP_LOG(INFO, "Initializing pmd_af_xdp for %s\n",
1599 rte_vdev_device_name(dev));
1601 name = rte_vdev_device_name(dev);
1602 if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
1603 strlen(rte_vdev_device_args(dev)) == 0) {
1604 eth_dev = rte_eth_dev_attach_secondary(name);
1605 if (eth_dev == NULL) {
1606 AF_XDP_LOG(ERR, "Failed to probe %s\n", name);
1609 eth_dev->dev_ops = &ops;
1610 rte_eth_dev_probing_finish(eth_dev);
1614 kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments);
1615 if (kvlist == NULL) {
1616 AF_XDP_LOG(ERR, "Invalid kvargs key\n");
1620 if (dev->device.numa_node == SOCKET_ID_ANY)
1621 dev->device.numa_node = rte_socket_id();
1623 if (parse_parameters(kvlist, if_name, &xsk_start_queue_idx,
1624 &xsk_queue_cnt, &shared_umem, prog_path) < 0) {
1625 AF_XDP_LOG(ERR, "Invalid kvargs value\n");
1629 if (strlen(if_name) == 0) {
1630 AF_XDP_LOG(ERR, "Network interface must be specified\n");
1634 eth_dev = init_internals(dev, if_name, xsk_start_queue_idx,
1635 xsk_queue_cnt, shared_umem, prog_path);
1636 if (eth_dev == NULL) {
1637 AF_XDP_LOG(ERR, "Failed to init internals\n");
1641 rte_eth_dev_probing_finish(eth_dev);
1647 rte_pmd_af_xdp_remove(struct rte_vdev_device *dev)
1649 struct rte_eth_dev *eth_dev = NULL;
1651 AF_XDP_LOG(INFO, "Removing AF_XDP ethdev on numa socket %u\n",
1657 /* find the ethdev entry */
1658 eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev));
1659 if (eth_dev == NULL)
1662 eth_dev_close(eth_dev);
1663 rte_eth_dev_release_port(eth_dev);
1669 static struct rte_vdev_driver pmd_af_xdp_drv = {
1670 .probe = rte_pmd_af_xdp_probe,
1671 .remove = rte_pmd_af_xdp_remove,
1674 RTE_PMD_REGISTER_VDEV(net_af_xdp, pmd_af_xdp_drv);
1675 RTE_PMD_REGISTER_PARAM_STRING(net_af_xdp,
1677 "start_queue=<int> "
1678 "queue_count=<int> "
1679 "shared_umem=<int> "
1680 "xdp_prog=<string> ");