4 * Copyright(c) 2014 John W. Linville <linville@tuxdriver.com>
6 * Originally based upon librte_pmd_pcap code:
8 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2014 6WIND S.A.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
16 * * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in
20 * the documentation and/or other materials provided with the
22 * * Neither the name of Intel Corporation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 #include <rte_ethdev.h>
41 #include <rte_malloc.h>
42 #include <rte_kvargs.h>
45 #include <linux/if_ether.h>
46 #include <linux/if_packet.h>
47 #include <arpa/inet.h>
49 #include <sys/types.h>
50 #include <sys/socket.h>
51 #include <sys/ioctl.h>
56 #include "rte_eth_af_packet.h"
58 #define ETH_AF_PACKET_IFACE_ARG "iface"
59 #define ETH_AF_PACKET_NUM_Q_ARG "qpairs"
60 #define ETH_AF_PACKET_BLOCKSIZE_ARG "blocksz"
61 #define ETH_AF_PACKET_FRAMESIZE_ARG "framesz"
62 #define ETH_AF_PACKET_FRAMECOUNT_ARG "framecnt"
64 #define DFLT_BLOCK_SIZE (1 << 12)
65 #define DFLT_FRAME_SIZE (1 << 11)
66 #define DFLT_FRAME_COUNT (1 << 9)
73 unsigned int framecount;
74 unsigned int framenum;
76 struct rte_mempool *mb_pool;
78 volatile unsigned long rx_pkts;
79 volatile unsigned long err_pkts;
87 unsigned int framecount;
88 unsigned int framenum;
90 volatile unsigned long tx_pkts;
91 volatile unsigned long err_pkts;
94 struct pmd_internals {
98 struct ether_addr eth_addr;
100 struct tpacket_req req;
102 struct pkt_rx_queue rx_queue[RTE_PMD_AF_PACKET_MAX_RINGS];
103 struct pkt_tx_queue tx_queue[RTE_PMD_AF_PACKET_MAX_RINGS];
106 static const char *valid_arguments[] = {
107 ETH_AF_PACKET_IFACE_ARG,
108 ETH_AF_PACKET_NUM_Q_ARG,
109 ETH_AF_PACKET_BLOCKSIZE_ARG,
110 ETH_AF_PACKET_FRAMESIZE_ARG,
111 ETH_AF_PACKET_FRAMECOUNT_ARG,
115 static const char *drivername = "AF_PACKET PMD";
117 static struct rte_eth_link pmd_link = {
119 .link_duplex = ETH_LINK_FULL_DUPLEX,
124 eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
127 struct tpacket2_hdr *ppd;
128 struct rte_mbuf *mbuf;
130 struct pkt_rx_queue *pkt_q = queue;
132 unsigned int framecount, framenum;
134 if (unlikely(nb_pkts == 0))
138 * Reads the given number of packets from the AF_PACKET socket one by
139 * one and copies the packet data into a newly allocated mbuf.
141 framecount = pkt_q->framecount;
142 framenum = pkt_q->framenum;
143 for (i = 0; i < nb_pkts; i++) {
144 /* point at the next incoming frame */
145 ppd = (struct tpacket2_hdr *) pkt_q->rd[framenum].iov_base;
146 if ((ppd->tp_status & TP_STATUS_USER) == 0)
149 /* allocate the next mbuf */
150 mbuf = rte_pktmbuf_alloc(pkt_q->mb_pool);
151 if (unlikely(mbuf == NULL))
154 /* packet will fit in the mbuf, go ahead and receive it */
155 rte_pktmbuf_pkt_len(mbuf) = rte_pktmbuf_data_len(mbuf) = ppd->tp_snaplen;
156 pbuf = (uint8_t *) ppd + ppd->tp_mac;
157 memcpy(rte_pktmbuf_mtod(mbuf, void *), pbuf, rte_pktmbuf_data_len(mbuf));
159 /* release incoming frame and advance ring buffer */
160 ppd->tp_status = TP_STATUS_KERNEL;
161 if (++framenum >= framecount)
164 /* account for the receive frame */
168 pkt_q->framenum = framenum;
169 pkt_q->rx_pkts += num_rx;
174 * Callback to handle sending packets through a real NIC.
177 eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
179 struct tpacket2_hdr *ppd;
180 struct rte_mbuf *mbuf;
182 unsigned int framecount, framenum;
184 struct pkt_tx_queue *pkt_q = queue;
188 if (unlikely(nb_pkts == 0))
191 memset(&pfd, 0, sizeof(pfd));
192 pfd.fd = pkt_q->sockfd;
193 pfd.events = POLLOUT;
196 framecount = pkt_q->framecount;
197 framenum = pkt_q->framenum;
198 ppd = (struct tpacket2_hdr *) pkt_q->rd[framenum].iov_base;
199 for (i = 0; i < nb_pkts; i++) {
200 /* point at the next incoming frame */
201 if ((ppd->tp_status != TP_STATUS_AVAILABLE) &&
202 (poll(&pfd, 1, -1) < 0))
205 /* copy the tx frame data */
207 pbuf = (uint8_t *) ppd + TPACKET2_HDRLEN -
208 sizeof(struct sockaddr_ll);
209 memcpy(pbuf, rte_pktmbuf_mtod(mbuf, void*), rte_pktmbuf_data_len(mbuf));
210 ppd->tp_len = ppd->tp_snaplen = rte_pktmbuf_data_len(mbuf);
212 /* release incoming frame and advance ring buffer */
213 ppd->tp_status = TP_STATUS_SEND_REQUEST;
214 if (++framenum >= framecount)
216 ppd = (struct tpacket2_hdr *) pkt_q->rd[framenum].iov_base;
219 rte_pktmbuf_free(mbuf);
222 /* kick-off transmits */
223 sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0);
225 pkt_q->framenum = framenum;
226 pkt_q->tx_pkts += num_tx;
227 pkt_q->err_pkts += nb_pkts - num_tx;
232 eth_dev_start(struct rte_eth_dev *dev)
234 dev->data->dev_link.link_status = 1;
239 * This function gets called when the current port gets stopped.
242 eth_dev_stop(struct rte_eth_dev *dev)
246 struct pmd_internals *internals = dev->data->dev_private;
248 for (i = 0; i < internals->nb_queues; i++) {
249 sockfd = internals->rx_queue[i].sockfd;
252 sockfd = internals->tx_queue[i].sockfd;
257 dev->data->dev_link.link_status = 0;
261 eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
267 eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
269 struct pmd_internals *internals = dev->data->dev_private;
271 dev_info->driver_name = drivername;
272 dev_info->if_index = internals->if_index;
273 dev_info->max_mac_addrs = 1;
274 dev_info->max_rx_pktlen = (uint32_t)ETH_FRAME_LEN;
275 dev_info->max_rx_queues = (uint16_t)internals->nb_queues;
276 dev_info->max_tx_queues = (uint16_t)internals->nb_queues;
277 dev_info->min_rx_bufsize = 0;
278 dev_info->pci_dev = NULL;
282 eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats)
285 unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;
286 const struct pmd_internals *internal = dev->data->dev_private;
288 memset(igb_stats, 0, sizeof(*igb_stats));
290 imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ?
291 internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS);
292 for (i = 0; i < imax; i++) {
293 igb_stats->q_ipackets[i] = internal->rx_queue[i].rx_pkts;
294 rx_total += igb_stats->q_ipackets[i];
297 imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ?
298 internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS);
299 for (i = 0; i < imax; i++) {
300 igb_stats->q_opackets[i] = internal->tx_queue[i].tx_pkts;
301 igb_stats->q_errors[i] = internal->tx_queue[i].err_pkts;
302 tx_total += igb_stats->q_opackets[i];
303 tx_err_total += igb_stats->q_errors[i];
306 igb_stats->ipackets = rx_total;
307 igb_stats->opackets = tx_total;
308 igb_stats->oerrors = tx_err_total;
312 eth_stats_reset(struct rte_eth_dev *dev)
315 struct pmd_internals *internal = dev->data->dev_private;
317 for (i = 0; i < internal->nb_queues; i++)
318 internal->rx_queue[i].rx_pkts = 0;
320 for (i = 0; i < internal->nb_queues; i++) {
321 internal->tx_queue[i].tx_pkts = 0;
322 internal->tx_queue[i].err_pkts = 0;
327 eth_dev_close(struct rte_eth_dev *dev __rte_unused)
332 eth_queue_release(void *q __rte_unused)
337 eth_link_update(struct rte_eth_dev *dev __rte_unused,
338 int wait_to_complete __rte_unused)
344 eth_rx_queue_setup(struct rte_eth_dev *dev,
345 uint16_t rx_queue_id,
346 uint16_t nb_rx_desc __rte_unused,
347 unsigned int socket_id __rte_unused,
348 const struct rte_eth_rxconf *rx_conf __rte_unused,
349 struct rte_mempool *mb_pool)
351 struct pmd_internals *internals = dev->data->dev_private;
352 struct pkt_rx_queue *pkt_q = &internals->rx_queue[rx_queue_id];
353 struct rte_pktmbuf_pool_private *mbp_priv;
356 pkt_q->mb_pool = mb_pool;
358 /* Now get the space available for data in the mbuf */
359 mbp_priv = rte_mempool_get_priv(pkt_q->mb_pool);
360 buf_size = (uint16_t) (mbp_priv->mbuf_data_room_size -
361 RTE_PKTMBUF_HEADROOM);
363 if (ETH_FRAME_LEN > buf_size) {
365 "%s: %d bytes will not fit in mbuf (%d bytes)\n",
366 dev->data->name, ETH_FRAME_LEN, buf_size);
370 dev->data->rx_queues[rx_queue_id] = pkt_q;
376 eth_tx_queue_setup(struct rte_eth_dev *dev,
377 uint16_t tx_queue_id,
378 uint16_t nb_tx_desc __rte_unused,
379 unsigned int socket_id __rte_unused,
380 const struct rte_eth_txconf *tx_conf __rte_unused)
383 struct pmd_internals *internals = dev->data->dev_private;
385 dev->data->tx_queues[tx_queue_id] = &internals->tx_queue[tx_queue_id];
389 static struct eth_dev_ops ops = {
390 .dev_start = eth_dev_start,
391 .dev_stop = eth_dev_stop,
392 .dev_close = eth_dev_close,
393 .dev_configure = eth_dev_configure,
394 .dev_infos_get = eth_dev_info,
395 .rx_queue_setup = eth_rx_queue_setup,
396 .tx_queue_setup = eth_tx_queue_setup,
397 .rx_queue_release = eth_queue_release,
398 .tx_queue_release = eth_queue_release,
399 .link_update = eth_link_update,
400 .stats_get = eth_stats_get,
401 .stats_reset = eth_stats_reset,
405 * Opens an AF_PACKET socket
408 open_packet_iface(const char *key __rte_unused,
409 const char *value __rte_unused,
412 int *sockfd = extra_args;
414 /* Open an AF_PACKET socket... */
415 *sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
417 RTE_LOG(ERR, PMD, "Could not open AF_PACKET socket\n");
425 rte_pmd_init_internals(const char *name,
427 const unsigned nb_queues,
428 unsigned int blocksize,
429 unsigned int blockcnt,
430 unsigned int framesize,
431 unsigned int framecnt,
432 const unsigned numa_node,
433 struct pmd_internals **internals,
434 struct rte_eth_dev **eth_dev,
435 struct rte_kvargs *kvlist)
437 struct rte_eth_dev_data *data = NULL;
438 struct rte_pci_device *pci_dev = NULL;
439 struct rte_kvargs_pair *pair = NULL;
443 struct sockaddr_ll sockaddr;
444 struct tpacket_req *req;
445 struct pkt_rx_queue *rx_queue;
446 struct pkt_tx_queue *tx_queue;
447 int rc, qsockfd, tpver, discard;
448 unsigned int i, q, rdsize;
449 int fanout_arg __rte_unused, bypass __rte_unused;
451 for (k_idx = 0; k_idx < kvlist->count; k_idx++) {
452 pair = &kvlist->pairs[k_idx];
453 if (strstr(pair->key, ETH_AF_PACKET_IFACE_ARG) != NULL)
458 "%s: no interface specified for AF_PACKET ethdev\n",
464 "%s: creating AF_PACKET-backed ethdev on numa socket %u\n",
468 * now do all data allocation - for eth_dev structure, dummy pci driver
469 * and internal (private) data
471 data = rte_zmalloc_socket(name, sizeof(*data), 0, numa_node);
475 pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);
479 *internals = rte_zmalloc_socket(name, sizeof(**internals),
481 if (*internals == NULL)
484 req = &((*internals)->req);
486 req->tp_block_size = blocksize;
487 req->tp_block_nr = blockcnt;
488 req->tp_frame_size = framesize;
489 req->tp_frame_nr = framecnt;
491 ifnamelen = strlen(pair->value);
492 if (ifnamelen < sizeof(ifr.ifr_name)) {
493 memcpy(ifr.ifr_name, pair->value, ifnamelen);
494 ifr.ifr_name[ifnamelen] = '\0';
497 "%s: I/F name too long (%s)\n",
501 if (ioctl(sockfd, SIOCGIFINDEX, &ifr) == -1) {
503 "%s: ioctl failed (SIOCGIFINDEX)\n",
507 (*internals)->if_index = ifr.ifr_ifindex;
509 if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) == -1) {
511 "%s: ioctl failed (SIOCGIFHWADDR)\n",
515 memcpy(&(*internals)->eth_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
517 memset(&sockaddr, 0, sizeof(sockaddr));
518 sockaddr.sll_family = AF_PACKET;
519 sockaddr.sll_protocol = htons(ETH_P_ALL);
520 sockaddr.sll_ifindex = (*internals)->if_index;
522 #if defined(PACKET_FANOUT)
523 fanout_arg = (getpid() ^ (*internals)->if_index) & 0xffff;
524 fanout_arg |= (PACKET_FANOUT_HASH | PACKET_FANOUT_FLAG_DEFRAG) << 16;
525 #if defined(PACKET_FANOUT_FLAG_ROLLOVER)
526 fanout_arg |= PACKET_FANOUT_FLAG_ROLLOVER << 16;
530 for (q = 0; q < nb_queues; q++) {
531 /* Open an AF_PACKET socket for this queue... */
532 qsockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
535 "%s: could not open AF_PACKET socket\n",
541 rc = setsockopt(qsockfd, SOL_PACKET, PACKET_VERSION,
542 &tpver, sizeof(tpver));
545 "%s: could not set PACKET_VERSION on AF_PACKET "
546 "socket for %s\n", name, pair->value);
551 rc = setsockopt(qsockfd, SOL_PACKET, PACKET_LOSS,
552 &discard, sizeof(discard));
555 "%s: could not set PACKET_LOSS on "
556 "AF_PACKET socket for %s\n", name, pair->value);
560 #if defined(PACKET_QDISC_BYPASS)
562 rc = setsockopt(qsockfd, SOL_PACKET, PACKET_QDISC_BYPASS,
563 &bypass, sizeof(bypass));
566 "%s: could not set PACKET_QDISC_BYPASS "
567 "on AF_PACKET socket for %s\n", name,
573 rc = setsockopt(qsockfd, SOL_PACKET, PACKET_RX_RING, req, sizeof(*req));
576 "%s: could not set PACKET_RX_RING on AF_PACKET "
577 "socket for %s\n", name, pair->value);
581 rc = setsockopt(qsockfd, SOL_PACKET, PACKET_TX_RING, req, sizeof(*req));
584 "%s: could not set PACKET_TX_RING on AF_PACKET "
585 "socket for %s\n", name, pair->value);
589 rx_queue = &((*internals)->rx_queue[q]);
590 rx_queue->framecount = req->tp_frame_nr;
592 rx_queue->map = mmap(NULL, 2 * req->tp_block_size * req->tp_block_nr,
593 PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED,
595 if (rx_queue->map == MAP_FAILED) {
597 "%s: call to mmap failed on AF_PACKET socket for %s\n",
602 /* rdsize is same for both Tx and Rx */
603 rdsize = req->tp_frame_nr * sizeof(*(rx_queue->rd));
605 rx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);
606 for (i = 0; i < req->tp_frame_nr; ++i) {
607 rx_queue->rd[i].iov_base = rx_queue->map + (i * framesize);
608 rx_queue->rd[i].iov_len = req->tp_frame_size;
610 rx_queue->sockfd = qsockfd;
612 tx_queue = &((*internals)->tx_queue[q]);
613 tx_queue->framecount = req->tp_frame_nr;
615 tx_queue->map = rx_queue->map + req->tp_block_size * req->tp_block_nr;
617 tx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);
618 for (i = 0; i < req->tp_frame_nr; ++i) {
619 tx_queue->rd[i].iov_base = tx_queue->map + (i * framesize);
620 tx_queue->rd[i].iov_len = req->tp_frame_size;
622 tx_queue->sockfd = qsockfd;
624 rc = bind(qsockfd, (const struct sockaddr*)&sockaddr, sizeof(sockaddr));
627 "%s: could not bind AF_PACKET socket to %s\n",
632 #if defined(PACKET_FANOUT)
633 rc = setsockopt(qsockfd, SOL_PACKET, PACKET_FANOUT,
634 &fanout_arg, sizeof(fanout_arg));
637 "%s: could not set PACKET_FANOUT on AF_PACKET socket "
638 "for %s\n", name, pair->value);
644 /* reserve an ethdev entry */
645 *eth_dev = rte_eth_dev_allocate(name);
646 if (*eth_dev == NULL)
650 * now put it all together
651 * - store queue data in internals,
652 * - store numa_node info in pci_driver
653 * - point eth_dev_data to internals and pci_driver
654 * - and point eth_dev structure to new eth_dev_data structure
657 (*internals)->nb_queues = nb_queues;
659 data->dev_private = *internals;
660 data->port_id = (*eth_dev)->data->port_id;
661 data->nb_rx_queues = (uint16_t)nb_queues;
662 data->nb_tx_queues = (uint16_t)nb_queues;
663 data->dev_link = pmd_link;
664 data->mac_addrs = &(*internals)->eth_addr;
666 pci_dev->numa_node = numa_node;
668 (*eth_dev)->data = data;
669 (*eth_dev)->dev_ops = &ops;
670 (*eth_dev)->pci_dev = pci_dev;
679 for (q = 0; q < nb_queues; q++) {
680 if ((*internals)->rx_queue[q].rd)
681 rte_free((*internals)->rx_queue[q].rd);
682 if ((*internals)->tx_queue[q].rd)
683 rte_free((*internals)->tx_queue[q].rd);
686 rte_free(*internals);
691 rte_eth_from_packet(const char *name,
693 const unsigned numa_node,
694 struct rte_kvargs *kvlist)
696 struct pmd_internals *internals = NULL;
697 struct rte_eth_dev *eth_dev = NULL;
698 struct rte_kvargs_pair *pair = NULL;
700 unsigned int blockcount;
701 unsigned int blocksize = DFLT_BLOCK_SIZE;
702 unsigned int framesize = DFLT_FRAME_SIZE;
703 unsigned int framecount = DFLT_FRAME_COUNT;
704 unsigned int qpairs = 1;
706 /* do some parameter checking */
711 * Walk arguments for configurable settings
713 for (k_idx = 0; k_idx < kvlist->count; k_idx++) {
714 pair = &kvlist->pairs[k_idx];
715 if (strstr(pair->key, ETH_AF_PACKET_NUM_Q_ARG) != NULL) {
716 qpairs = atoi(pair->value);
718 qpairs > RTE_PMD_AF_PACKET_MAX_RINGS) {
720 "%s: invalid qpairs value\n",
726 if (strstr(pair->key, ETH_AF_PACKET_BLOCKSIZE_ARG) != NULL) {
727 blocksize = atoi(pair->value);
730 "%s: invalid blocksize value\n",
736 if (strstr(pair->key, ETH_AF_PACKET_FRAMESIZE_ARG) != NULL) {
737 framesize = atoi(pair->value);
740 "%s: invalid framesize value\n",
746 if (strstr(pair->key, ETH_AF_PACKET_FRAMECOUNT_ARG) != NULL) {
747 framecount = atoi(pair->value);
750 "%s: invalid framecount value\n",
758 if (framesize > blocksize) {
760 "%s: AF_PACKET MMAP frame size exceeds block size!\n",
765 blockcount = framecount / (blocksize / framesize);
768 "%s: invalid AF_PACKET MMAP parameters\n", name);
772 RTE_LOG(INFO, PMD, "%s: AF_PACKET MMAP parameters:\n", name);
773 RTE_LOG(INFO, PMD, "%s:\tblock size %d\n", name, blocksize);
774 RTE_LOG(INFO, PMD, "%s:\tblock count %d\n", name, blockcount);
775 RTE_LOG(INFO, PMD, "%s:\tframe size %d\n", name, framesize);
776 RTE_LOG(INFO, PMD, "%s:\tframe count %d\n", name, framecount);
778 if (rte_pmd_init_internals(name, *sockfd, qpairs,
779 blocksize, blockcount,
780 framesize, framecount,
781 numa_node, &internals, ð_dev,
785 eth_dev->rx_pkt_burst = eth_af_packet_rx;
786 eth_dev->tx_pkt_burst = eth_af_packet_tx;
792 rte_pmd_af_packet_devinit(const char *name, const char *params)
796 struct rte_kvargs *kvlist;
799 RTE_LOG(INFO, PMD, "Initializing pmd_af_packet for %s\n", name);
801 numa_node = rte_socket_id();
803 kvlist = rte_kvargs_parse(params, valid_arguments);
808 * If iface argument is passed we open the NICs and use them for
811 if (rte_kvargs_count(kvlist, ETH_AF_PACKET_IFACE_ARG) == 1) {
813 ret = rte_kvargs_process(kvlist, ETH_AF_PACKET_IFACE_ARG,
814 &open_packet_iface, &sockfd);
819 ret = rte_eth_from_packet(name, &sockfd, numa_node, kvlist);
820 close(sockfd); /* no longer needed */
828 static struct rte_driver pmd_af_packet_drv = {
829 .name = "eth_af_packet",
831 .init = rte_pmd_af_packet_devinit,
834 PMD_REGISTER_DRIVER(pmd_af_packet_drv);