1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
11 #include <rte_cycles.h>
12 #include <ethdev_driver.h>
13 #include <ethdev_vdev.h>
14 #include <rte_kvargs.h>
15 #include <rte_malloc.h>
17 #include <rte_mbuf_dyn.h>
18 #include <rte_bus_vdev.h>
20 #include "pcap_osdep.h"
22 #define RTE_ETH_PCAP_SNAPSHOT_LEN 65535
23 #define RTE_ETH_PCAP_SNAPLEN RTE_ETHER_MAX_JUMBO_FRAME_LEN
24 #define RTE_ETH_PCAP_PROMISC 1
25 #define RTE_ETH_PCAP_TIMEOUT -1
27 #define ETH_PCAP_RX_PCAP_ARG "rx_pcap"
28 #define ETH_PCAP_TX_PCAP_ARG "tx_pcap"
29 #define ETH_PCAP_RX_IFACE_ARG "rx_iface"
30 #define ETH_PCAP_RX_IFACE_IN_ARG "rx_iface_in"
31 #define ETH_PCAP_TX_IFACE_ARG "tx_iface"
32 #define ETH_PCAP_IFACE_ARG "iface"
33 #define ETH_PCAP_PHY_MAC_ARG "phy_mac"
34 #define ETH_PCAP_INFINITE_RX_ARG "infinite_rx"
36 #define ETH_PCAP_ARG_MAXLEN 64
38 #define RTE_PMD_PCAP_MAX_QUEUES 16
40 static char errbuf[PCAP_ERRBUF_SIZE];
41 static struct timespec start_time;
42 static uint64_t start_cycles;
44 static uint8_t iface_idx;
46 static uint64_t timestamp_rx_dynflag;
47 static int timestamp_dynfield_offset = -1;
50 volatile unsigned long pkts;
51 volatile unsigned long bytes;
52 volatile unsigned long err_pkts;
55 struct queue_missed_stat {
56 /* last value retrieved from pcap */
58 /* stores values lost by pcap stop or rollover */
59 unsigned long mnemonic;
60 /* value on last reset */
64 struct pcap_rx_queue {
67 struct rte_mempool *mb_pool;
68 struct queue_stat rx_stat;
69 struct queue_missed_stat missed_stat;
71 char type[ETH_PCAP_ARG_MAXLEN];
73 /* Contains pre-generated packets to be looped through */
74 struct rte_ring *pkts;
77 struct pcap_tx_queue {
80 struct queue_stat tx_stat;
82 char type[ETH_PCAP_ARG_MAXLEN];
85 struct pmd_internals {
86 struct pcap_rx_queue rx_queue[RTE_PMD_PCAP_MAX_QUEUES];
87 struct pcap_tx_queue tx_queue[RTE_PMD_PCAP_MAX_QUEUES];
88 char devargs[ETH_PCAP_ARG_MAXLEN];
89 struct rte_ether_addr eth_addr;
93 unsigned int infinite_rx;
96 struct pmd_process_private {
97 pcap_t *rx_pcap[RTE_PMD_PCAP_MAX_QUEUES];
98 pcap_t *tx_pcap[RTE_PMD_PCAP_MAX_QUEUES];
99 pcap_dumper_t *tx_dumper[RTE_PMD_PCAP_MAX_QUEUES];
103 unsigned int num_of_queue;
104 struct devargs_queue {
105 pcap_dumper_t *dumper;
109 } queue[RTE_PMD_PCAP_MAX_QUEUES];
113 struct pmd_devargs_all {
114 struct pmd_devargs rx_queues;
115 struct pmd_devargs tx_queues;
117 unsigned int is_tx_pcap;
118 unsigned int is_tx_iface;
119 unsigned int is_rx_pcap;
120 unsigned int is_rx_iface;
121 unsigned int infinite_rx;
124 static const char *valid_arguments[] = {
125 ETH_PCAP_RX_PCAP_ARG,
126 ETH_PCAP_TX_PCAP_ARG,
127 ETH_PCAP_RX_IFACE_ARG,
128 ETH_PCAP_RX_IFACE_IN_ARG,
129 ETH_PCAP_TX_IFACE_ARG,
131 ETH_PCAP_PHY_MAC_ARG,
132 ETH_PCAP_INFINITE_RX_ARG,
136 static struct rte_eth_link pmd_link = {
137 .link_speed = ETH_SPEED_NUM_10G,
138 .link_duplex = ETH_LINK_FULL_DUPLEX,
139 .link_status = ETH_LINK_DOWN,
140 .link_autoneg = ETH_LINK_FIXED,
143 RTE_LOG_REGISTER(eth_pcap_logtype, pmd.net.pcap, NOTICE);
145 #define PMD_LOG(level, fmt, args...) \
146 rte_log(RTE_LOG_ ## level, eth_pcap_logtype, \
147 "%s(): " fmt "\n", __func__, ##args)
149 static struct queue_missed_stat*
150 queue_missed_stat_update(struct rte_eth_dev *dev, unsigned int qid)
152 struct pmd_internals *internals = dev->data->dev_private;
153 struct queue_missed_stat *missed_stat =
154 &internals->rx_queue[qid].missed_stat;
155 const struct pmd_process_private *pp = dev->process_private;
156 pcap_t *pcap = pp->rx_pcap[qid];
157 struct pcap_stat stat;
159 if (!pcap || (pcap_stats(pcap, &stat) != 0))
162 /* rollover check - best effort fixup assuming single rollover */
163 if (stat.ps_drop < missed_stat->pcap)
164 missed_stat->mnemonic += UINT_MAX;
165 missed_stat->pcap = stat.ps_drop;
171 queue_missed_stat_on_stop_update(struct rte_eth_dev *dev, unsigned int qid)
173 struct queue_missed_stat *missed_stat =
174 queue_missed_stat_update(dev, qid);
176 missed_stat->mnemonic += missed_stat->pcap;
177 missed_stat->pcap = 0;
181 queue_missed_stat_reset(struct rte_eth_dev *dev, unsigned int qid)
183 struct queue_missed_stat *missed_stat =
184 queue_missed_stat_update(dev, qid);
186 missed_stat->reset = missed_stat->pcap;
187 missed_stat->mnemonic = 0;
191 queue_missed_stat_get(struct rte_eth_dev *dev, unsigned int qid)
193 const struct queue_missed_stat *missed_stat =
194 queue_missed_stat_update(dev, qid);
196 return missed_stat->pcap + missed_stat->mnemonic - missed_stat->reset;
200 eth_pcap_rx_jumbo(struct rte_mempool *mb_pool, struct rte_mbuf *mbuf,
201 const u_char *data, uint16_t data_len)
203 /* Copy the first segment. */
204 uint16_t len = rte_pktmbuf_tailroom(mbuf);
205 struct rte_mbuf *m = mbuf;
207 rte_memcpy(rte_pktmbuf_append(mbuf, len), data, len);
211 while (data_len > 0) {
212 /* Allocate next mbuf and point to that. */
213 m->next = rte_pktmbuf_alloc(mb_pool);
215 if (unlikely(!m->next))
220 /* Headroom is not needed in chained mbufs. */
221 rte_pktmbuf_prepend(m, rte_pktmbuf_headroom(m));
225 /* Copy next segment. */
226 len = RTE_MIN(rte_pktmbuf_tailroom(m), data_len);
227 rte_memcpy(rte_pktmbuf_append(m, len), data, len);
234 return mbuf->nb_segs;
238 eth_pcap_rx_infinite(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
241 struct pcap_rx_queue *pcap_q = queue;
242 uint32_t rx_bytes = 0;
244 if (unlikely(nb_pkts == 0))
247 if (rte_pktmbuf_alloc_bulk(pcap_q->mb_pool, bufs, nb_pkts) != 0)
250 for (i = 0; i < nb_pkts; i++) {
251 struct rte_mbuf *pcap_buf;
252 int err = rte_ring_dequeue(pcap_q->pkts, (void **)&pcap_buf);
256 rte_memcpy(rte_pktmbuf_mtod(bufs[i], void *),
257 rte_pktmbuf_mtod(pcap_buf, void *),
259 bufs[i]->data_len = pcap_buf->data_len;
260 bufs[i]->pkt_len = pcap_buf->pkt_len;
261 bufs[i]->port = pcap_q->port_id;
262 rx_bytes += pcap_buf->data_len;
264 /* Enqueue packet back on ring to allow infinite rx. */
265 rte_ring_enqueue(pcap_q->pkts, pcap_buf);
268 pcap_q->rx_stat.pkts += i;
269 pcap_q->rx_stat.bytes += rx_bytes;
275 eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
278 struct pcap_pkthdr header;
279 struct pmd_process_private *pp;
280 const u_char *packet;
281 struct rte_mbuf *mbuf;
282 struct pcap_rx_queue *pcap_q = queue;
284 uint32_t rx_bytes = 0;
287 pp = rte_eth_devices[pcap_q->port_id].process_private;
288 pcap = pp->rx_pcap[pcap_q->queue_id];
290 if (unlikely(pcap == NULL || nb_pkts == 0))
293 /* Reads the given number of packets from the pcap file one by one
294 * and copies the packet data into a newly allocated mbuf to return.
296 for (i = 0; i < nb_pkts; i++) {
297 /* Get the next PCAP packet */
298 packet = pcap_next(pcap, &header);
299 if (unlikely(packet == NULL))
302 mbuf = rte_pktmbuf_alloc(pcap_q->mb_pool);
303 if (unlikely(mbuf == NULL))
306 if (header.caplen <= rte_pktmbuf_tailroom(mbuf)) {
307 /* pcap packet will fit in the mbuf, can copy it */
308 rte_memcpy(rte_pktmbuf_mtod(mbuf, void *), packet,
310 mbuf->data_len = (uint16_t)header.caplen;
312 /* Try read jumbo frame into multi mbufs. */
313 if (unlikely(eth_pcap_rx_jumbo(pcap_q->mb_pool,
316 header.caplen) == -1)) {
317 rte_pktmbuf_free(mbuf);
322 mbuf->pkt_len = (uint16_t)header.caplen;
323 *RTE_MBUF_DYNFIELD(mbuf, timestamp_dynfield_offset,
324 rte_mbuf_timestamp_t *) =
325 (uint64_t)header.ts.tv_sec * 1000000 +
327 mbuf->ol_flags |= timestamp_rx_dynflag;
328 mbuf->port = pcap_q->port_id;
331 rx_bytes += header.caplen;
333 pcap_q->rx_stat.pkts += num_rx;
334 pcap_q->rx_stat.bytes += rx_bytes;
340 eth_null_rx(void *queue __rte_unused,
341 struct rte_mbuf **bufs __rte_unused,
342 uint16_t nb_pkts __rte_unused)
347 #define NSEC_PER_SEC 1000000000L
350 * This function stores nanoseconds in `tv_usec` field of `struct timeval`,
351 * because `ts` goes directly to nanosecond-precision dump.
354 calculate_timestamp(struct timeval *ts) {
356 struct timespec cur_time;
358 cycles = rte_get_timer_cycles() - start_cycles;
359 cur_time.tv_sec = cycles / hz;
360 cur_time.tv_nsec = (cycles % hz) * NSEC_PER_SEC / hz;
362 ts->tv_sec = start_time.tv_sec + cur_time.tv_sec;
363 ts->tv_usec = start_time.tv_nsec + cur_time.tv_nsec;
364 if (ts->tv_usec >= NSEC_PER_SEC) {
365 ts->tv_usec -= NSEC_PER_SEC;
371 * Callback to handle writing packets to a pcap file.
374 eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
377 struct rte_mbuf *mbuf;
378 struct pmd_process_private *pp;
379 struct pcap_tx_queue *dumper_q = queue;
381 uint32_t tx_bytes = 0;
382 struct pcap_pkthdr header;
383 pcap_dumper_t *dumper;
384 unsigned char temp_data[RTE_ETH_PCAP_SNAPLEN];
387 pp = rte_eth_devices[dumper_q->port_id].process_private;
388 dumper = pp->tx_dumper[dumper_q->queue_id];
390 if (dumper == NULL || nb_pkts == 0)
393 /* writes the nb_pkts packets to the previously opened pcap file
395 for (i = 0; i < nb_pkts; i++) {
397 len = caplen = rte_pktmbuf_pkt_len(mbuf);
398 if (unlikely(!rte_pktmbuf_is_contiguous(mbuf) &&
399 len > sizeof(temp_data))) {
400 caplen = sizeof(temp_data);
403 calculate_timestamp(&header.ts);
405 header.caplen = caplen;
406 /* rte_pktmbuf_read() returns a pointer to the data directly
407 * in the mbuf (when the mbuf is contiguous) or, otherwise,
408 * a pointer to temp_data after copying into it.
410 pcap_dump((u_char *)dumper, &header,
411 rte_pktmbuf_read(mbuf, 0, caplen, temp_data));
415 rte_pktmbuf_free(mbuf);
419 * Since there's no place to hook a callback when the forwarding
420 * process stops and to make sure the pcap file is actually written,
421 * we flush the pcap dumper within each burst.
423 pcap_dump_flush(dumper);
424 dumper_q->tx_stat.pkts += num_tx;
425 dumper_q->tx_stat.bytes += tx_bytes;
426 dumper_q->tx_stat.err_pkts += nb_pkts - num_tx;
432 * Callback to handle dropping packets in the infinite rx case.
435 eth_tx_drop(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
438 uint32_t tx_bytes = 0;
439 struct pcap_tx_queue *tx_queue = queue;
441 if (unlikely(nb_pkts == 0))
444 for (i = 0; i < nb_pkts; i++) {
445 tx_bytes += bufs[i]->pkt_len;
446 rte_pktmbuf_free(bufs[i]);
449 tx_queue->tx_stat.pkts += nb_pkts;
450 tx_queue->tx_stat.bytes += tx_bytes;
456 * Callback to handle sending packets through a real NIC.
459 eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
463 struct rte_mbuf *mbuf;
464 struct pmd_process_private *pp;
465 struct pcap_tx_queue *tx_queue = queue;
467 uint32_t tx_bytes = 0;
469 unsigned char temp_data[RTE_ETH_PCAP_SNAPLEN];
472 pp = rte_eth_devices[tx_queue->port_id].process_private;
473 pcap = pp->tx_pcap[tx_queue->queue_id];
475 if (unlikely(nb_pkts == 0 || pcap == NULL))
478 for (i = 0; i < nb_pkts; i++) {
480 len = rte_pktmbuf_pkt_len(mbuf);
481 if (unlikely(!rte_pktmbuf_is_contiguous(mbuf) &&
482 len > sizeof(temp_data))) {
484 "Dropping multi segment PCAP packet. Size (%zd) > max size (%zd).",
485 len, sizeof(temp_data));
486 rte_pktmbuf_free(mbuf);
490 /* rte_pktmbuf_read() returns a pointer to the data directly
491 * in the mbuf (when the mbuf is contiguous) or, otherwise,
492 * a pointer to temp_data after copying into it.
494 ret = pcap_sendpacket(pcap,
495 rte_pktmbuf_read(mbuf, 0, len, temp_data), len);
496 if (unlikely(ret != 0))
500 rte_pktmbuf_free(mbuf);
503 tx_queue->tx_stat.pkts += num_tx;
504 tx_queue->tx_stat.bytes += tx_bytes;
505 tx_queue->tx_stat.err_pkts += i - num_tx;
511 * pcap_open_live wrapper function
514 open_iface_live(const char *iface, pcap_t **pcap) {
515 *pcap = pcap_open_live(iface, RTE_ETH_PCAP_SNAPLEN,
516 RTE_ETH_PCAP_PROMISC, RTE_ETH_PCAP_TIMEOUT, errbuf);
519 PMD_LOG(ERR, "Couldn't open %s: %s", iface, errbuf);
527 open_single_iface(const char *iface, pcap_t **pcap)
529 if (open_iface_live(iface, pcap) < 0) {
530 PMD_LOG(ERR, "Couldn't open interface %s", iface);
538 open_single_tx_pcap(const char *pcap_filename, pcap_dumper_t **dumper)
543 * We need to create a dummy empty pcap_t to use it
544 * with pcap_dump_open(). We create big enough an Ethernet
547 tx_pcap = pcap_open_dead_with_tstamp_precision(DLT_EN10MB,
548 RTE_ETH_PCAP_SNAPSHOT_LEN, PCAP_TSTAMP_PRECISION_NANO);
549 if (tx_pcap == NULL) {
550 PMD_LOG(ERR, "Couldn't create dead pcap");
554 /* The dumper is created using the previous pcap_t reference */
555 *dumper = pcap_dump_open(tx_pcap, pcap_filename);
556 if (*dumper == NULL) {
558 PMD_LOG(ERR, "Couldn't open %s for writing.",
568 open_single_rx_pcap(const char *pcap_filename, pcap_t **pcap)
570 *pcap = pcap_open_offline(pcap_filename, errbuf);
572 PMD_LOG(ERR, "Couldn't open %s: %s", pcap_filename,
581 count_packets_in_pcap(pcap_t **pcap, struct pcap_rx_queue *pcap_q)
583 const u_char *packet;
584 struct pcap_pkthdr header;
585 uint64_t pcap_pkt_count = 0;
587 while ((packet = pcap_next(*pcap, &header)))
590 /* The pcap is reopened so it can be used as normal later. */
593 open_single_rx_pcap(pcap_q->name, pcap);
595 return pcap_pkt_count;
599 eth_dev_start(struct rte_eth_dev *dev)
602 struct pmd_internals *internals = dev->data->dev_private;
603 struct pmd_process_private *pp = dev->process_private;
604 struct pcap_tx_queue *tx;
605 struct pcap_rx_queue *rx;
607 /* Special iface case. Single pcap is open and shared between tx/rx. */
608 if (internals->single_iface) {
609 tx = &internals->tx_queue[0];
610 rx = &internals->rx_queue[0];
612 if (!pp->tx_pcap[0] &&
613 strcmp(tx->type, ETH_PCAP_IFACE_ARG) == 0) {
614 if (open_single_iface(tx->name, &pp->tx_pcap[0]) < 0)
616 pp->rx_pcap[0] = pp->tx_pcap[0];
622 /* If not open already, open tx pcaps/dumpers */
623 for (i = 0; i < dev->data->nb_tx_queues; i++) {
624 tx = &internals->tx_queue[i];
626 if (!pp->tx_dumper[i] &&
627 strcmp(tx->type, ETH_PCAP_TX_PCAP_ARG) == 0) {
628 if (open_single_tx_pcap(tx->name,
629 &pp->tx_dumper[i]) < 0)
631 } else if (!pp->tx_pcap[i] &&
632 strcmp(tx->type, ETH_PCAP_TX_IFACE_ARG) == 0) {
633 if (open_single_iface(tx->name, &pp->tx_pcap[i]) < 0)
638 /* If not open already, open rx pcaps */
639 for (i = 0; i < dev->data->nb_rx_queues; i++) {
640 rx = &internals->rx_queue[i];
642 if (pp->rx_pcap[i] != NULL)
645 if (strcmp(rx->type, ETH_PCAP_RX_PCAP_ARG) == 0) {
646 if (open_single_rx_pcap(rx->name, &pp->rx_pcap[i]) < 0)
648 } else if (strcmp(rx->type, ETH_PCAP_RX_IFACE_ARG) == 0) {
649 if (open_single_iface(rx->name, &pp->rx_pcap[i]) < 0)
655 for (i = 0; i < dev->data->nb_rx_queues; i++)
656 dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
658 for (i = 0; i < dev->data->nb_tx_queues; i++)
659 dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
661 dev->data->dev_link.link_status = ETH_LINK_UP;
667 * This function gets called when the current port gets stopped.
668 * Is the only place for us to close all the tx streams dumpers.
669 * If not called the dumpers will be flushed within each tx burst.
672 eth_dev_stop(struct rte_eth_dev *dev)
675 struct pmd_internals *internals = dev->data->dev_private;
676 struct pmd_process_private *pp = dev->process_private;
678 /* Special iface case. Single pcap is open and shared between tx/rx. */
679 if (internals->single_iface) {
680 queue_missed_stat_on_stop_update(dev, 0);
681 if (pp->tx_pcap[0] != NULL) {
682 pcap_close(pp->tx_pcap[0]);
683 pp->tx_pcap[0] = NULL;
684 pp->rx_pcap[0] = NULL;
689 for (i = 0; i < dev->data->nb_tx_queues; i++) {
690 if (pp->tx_dumper[i] != NULL) {
691 pcap_dump_close(pp->tx_dumper[i]);
692 pp->tx_dumper[i] = NULL;
695 if (pp->tx_pcap[i] != NULL) {
696 pcap_close(pp->tx_pcap[i]);
697 pp->tx_pcap[i] = NULL;
701 for (i = 0; i < dev->data->nb_rx_queues; i++) {
702 if (pp->rx_pcap[i] != NULL) {
703 queue_missed_stat_on_stop_update(dev, i);
704 pcap_close(pp->rx_pcap[i]);
705 pp->rx_pcap[i] = NULL;
710 for (i = 0; i < dev->data->nb_rx_queues; i++)
711 dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
713 for (i = 0; i < dev->data->nb_tx_queues; i++)
714 dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
716 dev->data->dev_link.link_status = ETH_LINK_DOWN;
722 eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
728 eth_dev_info(struct rte_eth_dev *dev,
729 struct rte_eth_dev_info *dev_info)
731 struct pmd_internals *internals = dev->data->dev_private;
733 dev_info->if_index = internals->if_index;
734 dev_info->max_mac_addrs = 1;
735 dev_info->max_rx_pktlen = (uint32_t) -1;
736 dev_info->max_rx_queues = dev->data->nb_rx_queues;
737 dev_info->max_tx_queues = dev->data->nb_tx_queues;
738 dev_info->min_rx_bufsize = 0;
744 eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
747 unsigned long rx_packets_total = 0, rx_bytes_total = 0;
748 unsigned long rx_missed_total = 0;
749 unsigned long tx_packets_total = 0, tx_bytes_total = 0;
750 unsigned long tx_packets_err_total = 0;
751 const struct pmd_internals *internal = dev->data->dev_private;
753 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
754 i < dev->data->nb_rx_queues; i++) {
755 stats->q_ipackets[i] = internal->rx_queue[i].rx_stat.pkts;
756 stats->q_ibytes[i] = internal->rx_queue[i].rx_stat.bytes;
757 rx_packets_total += stats->q_ipackets[i];
758 rx_bytes_total += stats->q_ibytes[i];
759 rx_missed_total += queue_missed_stat_get(dev, i);
762 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
763 i < dev->data->nb_tx_queues; i++) {
764 stats->q_opackets[i] = internal->tx_queue[i].tx_stat.pkts;
765 stats->q_obytes[i] = internal->tx_queue[i].tx_stat.bytes;
766 tx_packets_total += stats->q_opackets[i];
767 tx_bytes_total += stats->q_obytes[i];
768 tx_packets_err_total += internal->tx_queue[i].tx_stat.err_pkts;
771 stats->ipackets = rx_packets_total;
772 stats->ibytes = rx_bytes_total;
773 stats->imissed = rx_missed_total;
774 stats->opackets = tx_packets_total;
775 stats->obytes = tx_bytes_total;
776 stats->oerrors = tx_packets_err_total;
782 eth_stats_reset(struct rte_eth_dev *dev)
785 struct pmd_internals *internal = dev->data->dev_private;
787 for (i = 0; i < dev->data->nb_rx_queues; i++) {
788 internal->rx_queue[i].rx_stat.pkts = 0;
789 internal->rx_queue[i].rx_stat.bytes = 0;
790 queue_missed_stat_reset(dev, i);
793 for (i = 0; i < dev->data->nb_tx_queues; i++) {
794 internal->tx_queue[i].tx_stat.pkts = 0;
795 internal->tx_queue[i].tx_stat.bytes = 0;
796 internal->tx_queue[i].tx_stat.err_pkts = 0;
803 infinite_rx_ring_free(struct rte_ring *pkts)
805 struct rte_mbuf *bufs;
807 while (!rte_ring_dequeue(pkts, (void **)&bufs))
808 rte_pktmbuf_free(bufs);
814 eth_dev_close(struct rte_eth_dev *dev)
817 struct pmd_internals *internals = dev->data->dev_private;
819 PMD_LOG(INFO, "Closing pcap ethdev on NUMA socket %d",
824 rte_free(dev->process_private);
826 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
829 /* Device wide flag, but cleanup must be performed per queue. */
830 if (internals->infinite_rx) {
831 for (i = 0; i < dev->data->nb_rx_queues; i++) {
832 struct pcap_rx_queue *pcap_q = &internals->rx_queue[i];
835 * 'pcap_q->pkts' can be NULL if 'eth_dev_close()'
836 * called before 'eth_rx_queue_setup()' has been called
838 if (pcap_q->pkts == NULL)
841 infinite_rx_ring_free(pcap_q->pkts);
845 if (internals->phy_mac == 0)
846 /* not dynamically allocated, must not be freed */
847 dev->data->mac_addrs = NULL;
853 eth_queue_release(void *q __rte_unused)
858 eth_link_update(struct rte_eth_dev *dev __rte_unused,
859 int wait_to_complete __rte_unused)
865 eth_rx_queue_setup(struct rte_eth_dev *dev,
866 uint16_t rx_queue_id,
867 uint16_t nb_rx_desc __rte_unused,
868 unsigned int socket_id __rte_unused,
869 const struct rte_eth_rxconf *rx_conf __rte_unused,
870 struct rte_mempool *mb_pool)
872 struct pmd_internals *internals = dev->data->dev_private;
873 struct pcap_rx_queue *pcap_q = &internals->rx_queue[rx_queue_id];
875 pcap_q->mb_pool = mb_pool;
876 pcap_q->port_id = dev->data->port_id;
877 pcap_q->queue_id = rx_queue_id;
878 dev->data->rx_queues[rx_queue_id] = pcap_q;
880 if (internals->infinite_rx) {
881 struct pmd_process_private *pp;
882 char ring_name[RTE_RING_NAMESIZE];
883 static uint32_t ring_number;
884 uint64_t pcap_pkt_count = 0;
885 struct rte_mbuf *bufs[1];
888 pp = rte_eth_devices[pcap_q->port_id].process_private;
889 pcap = &pp->rx_pcap[pcap_q->queue_id];
891 if (unlikely(*pcap == NULL))
894 pcap_pkt_count = count_packets_in_pcap(pcap, pcap_q);
896 snprintf(ring_name, sizeof(ring_name), "PCAP_RING%" PRIu32,
899 pcap_q->pkts = rte_ring_create(ring_name,
900 rte_align64pow2(pcap_pkt_count + 1), 0,
901 RING_F_SP_ENQ | RING_F_SC_DEQ);
906 /* Fill ring with packets from PCAP file one by one. */
907 while (eth_pcap_rx(pcap_q, bufs, 1)) {
908 /* Check for multiseg mbufs. */
909 if (bufs[0]->nb_segs != 1) {
910 infinite_rx_ring_free(pcap_q->pkts);
912 "Multiseg mbufs are not supported in infinite_rx mode.");
916 rte_ring_enqueue_bulk(pcap_q->pkts,
917 (void * const *)bufs, 1, NULL);
920 if (rte_ring_count(pcap_q->pkts) < pcap_pkt_count) {
921 infinite_rx_ring_free(pcap_q->pkts);
923 "Not enough mbufs to accommodate packets in pcap file. "
924 "At least %" PRIu64 " mbufs per queue is required.",
930 * Reset the stats for this queue since eth_pcap_rx calls above
931 * didn't result in the application receiving packets.
933 pcap_q->rx_stat.pkts = 0;
934 pcap_q->rx_stat.bytes = 0;
941 eth_tx_queue_setup(struct rte_eth_dev *dev,
942 uint16_t tx_queue_id,
943 uint16_t nb_tx_desc __rte_unused,
944 unsigned int socket_id __rte_unused,
945 const struct rte_eth_txconf *tx_conf __rte_unused)
947 struct pmd_internals *internals = dev->data->dev_private;
948 struct pcap_tx_queue *pcap_q = &internals->tx_queue[tx_queue_id];
950 pcap_q->port_id = dev->data->port_id;
951 pcap_q->queue_id = tx_queue_id;
952 dev->data->tx_queues[tx_queue_id] = pcap_q;
958 eth_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
960 dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
966 eth_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
968 dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
974 eth_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
976 dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
982 eth_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
984 dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
989 static const struct eth_dev_ops ops = {
990 .dev_start = eth_dev_start,
991 .dev_stop = eth_dev_stop,
992 .dev_close = eth_dev_close,
993 .dev_configure = eth_dev_configure,
994 .dev_infos_get = eth_dev_info,
995 .rx_queue_setup = eth_rx_queue_setup,
996 .tx_queue_setup = eth_tx_queue_setup,
997 .rx_queue_start = eth_rx_queue_start,
998 .tx_queue_start = eth_tx_queue_start,
999 .rx_queue_stop = eth_rx_queue_stop,
1000 .tx_queue_stop = eth_tx_queue_stop,
1001 .rx_queue_release = eth_queue_release,
1002 .tx_queue_release = eth_queue_release,
1003 .link_update = eth_link_update,
1004 .stats_get = eth_stats_get,
1005 .stats_reset = eth_stats_reset,
1009 add_queue(struct pmd_devargs *pmd, const char *name, const char *type,
1010 pcap_t *pcap, pcap_dumper_t *dumper)
1012 if (pmd->num_of_queue >= RTE_PMD_PCAP_MAX_QUEUES)
1015 pmd->queue[pmd->num_of_queue].pcap = pcap;
1017 pmd->queue[pmd->num_of_queue].dumper = dumper;
1018 pmd->queue[pmd->num_of_queue].name = name;
1019 pmd->queue[pmd->num_of_queue].type = type;
1020 pmd->num_of_queue++;
1025 * Function handler that opens the pcap file for reading a stores a
1026 * reference of it for use it later on.
1029 open_rx_pcap(const char *key, const char *value, void *extra_args)
1031 const char *pcap_filename = value;
1032 struct pmd_devargs *rx = extra_args;
1033 pcap_t *pcap = NULL;
1035 if (open_single_rx_pcap(pcap_filename, &pcap) < 0)
1038 if (add_queue(rx, pcap_filename, key, pcap, NULL) < 0) {
1047 * Opens a pcap file for writing and stores a reference to it
1048 * for use it later on.
1051 open_tx_pcap(const char *key, const char *value, void *extra_args)
1053 const char *pcap_filename = value;
1054 struct pmd_devargs *dumpers = extra_args;
1055 pcap_dumper_t *dumper;
1057 if (open_single_tx_pcap(pcap_filename, &dumper) < 0)
1060 if (add_queue(dumpers, pcap_filename, key, NULL, dumper) < 0) {
1061 pcap_dump_close(dumper);
1069 * Opens an interface for reading and writing
1072 open_rx_tx_iface(const char *key, const char *value, void *extra_args)
1074 const char *iface = value;
1075 struct pmd_devargs *tx = extra_args;
1076 pcap_t *pcap = NULL;
1078 if (open_single_iface(iface, &pcap) < 0)
1081 tx->queue[0].pcap = pcap;
1082 tx->queue[0].name = iface;
1083 tx->queue[0].type = key;
1089 set_iface_direction(const char *iface, pcap_t *pcap,
1090 pcap_direction_t direction)
1092 const char *direction_str = (direction == PCAP_D_IN) ? "IN" : "OUT";
1093 if (pcap_setdirection(pcap, direction) < 0) {
1094 PMD_LOG(ERR, "Setting %s pcap direction %s failed - %s\n",
1095 iface, direction_str, pcap_geterr(pcap));
1098 PMD_LOG(INFO, "Setting %s pcap direction %s\n",
1099 iface, direction_str);
1104 open_iface(const char *key, const char *value, void *extra_args)
1106 const char *iface = value;
1107 struct pmd_devargs *pmd = extra_args;
1108 pcap_t *pcap = NULL;
1110 if (open_single_iface(iface, &pcap) < 0)
1112 if (add_queue(pmd, iface, key, pcap, NULL) < 0) {
1121 * Opens a NIC for reading packets from it
1124 open_rx_iface(const char *key, const char *value, void *extra_args)
1126 int ret = open_iface(key, value, extra_args);
1129 if (strcmp(key, ETH_PCAP_RX_IFACE_IN_ARG) == 0) {
1130 struct pmd_devargs *pmd = extra_args;
1131 unsigned int qid = pmd->num_of_queue - 1;
1133 set_iface_direction(pmd->queue[qid].name,
1134 pmd->queue[qid].pcap,
1142 rx_iface_args_process(const char *key, const char *value, void *extra_args)
1144 if (strcmp(key, ETH_PCAP_RX_IFACE_ARG) == 0 ||
1145 strcmp(key, ETH_PCAP_RX_IFACE_IN_ARG) == 0)
1146 return open_rx_iface(key, value, extra_args);
1152 * Opens a NIC for writing packets to it
1155 open_tx_iface(const char *key, const char *value, void *extra_args)
1157 return open_iface(key, value, extra_args);
1161 select_phy_mac(const char *key __rte_unused, const char *value,
1165 const int phy_mac = atoi(value);
1166 int *enable_phy_mac = extra_args;
1169 *enable_phy_mac = 1;
1175 get_infinite_rx_arg(const char *key __rte_unused,
1176 const char *value, void *extra_args)
1179 const int infinite_rx = atoi(value);
1180 int *enable_infinite_rx = extra_args;
1182 if (infinite_rx > 0)
1183 *enable_infinite_rx = 1;
1189 pmd_init_internals(struct rte_vdev_device *vdev,
1190 const unsigned int nb_rx_queues,
1191 const unsigned int nb_tx_queues,
1192 struct pmd_internals **internals,
1193 struct rte_eth_dev **eth_dev)
1195 struct rte_eth_dev_data *data;
1196 struct pmd_process_private *pp;
1197 unsigned int numa_node = vdev->device.numa_node;
1199 PMD_LOG(INFO, "Creating pcap-backed ethdev on numa socket %d",
1202 pp = (struct pmd_process_private *)
1203 rte_zmalloc(NULL, sizeof(struct pmd_process_private),
1204 RTE_CACHE_LINE_SIZE);
1208 "Failed to allocate memory for process private");
1212 /* reserve an ethdev entry */
1213 *eth_dev = rte_eth_vdev_allocate(vdev, sizeof(**internals));
1218 (*eth_dev)->process_private = pp;
1219 /* now put it all together
1220 * - store queue data in internals,
1221 * - store numa_node info in eth_dev
1222 * - point eth_dev_data to internals
1223 * - and point eth_dev structure to new eth_dev_data structure
1225 *internals = (*eth_dev)->data->dev_private;
1227 * Interface MAC = 02:70:63:61:70:<iface_idx>
1228 * derived from: 'locally administered':'p':'c':'a':'p':'iface_idx'
1229 * where the middle 4 characters are converted to hex.
1231 (*internals)->eth_addr = (struct rte_ether_addr) {
1232 .addr_bytes = { 0x02, 0x70, 0x63, 0x61, 0x70, iface_idx++ }
1234 (*internals)->phy_mac = 0;
1235 data = (*eth_dev)->data;
1236 data->nb_rx_queues = (uint16_t)nb_rx_queues;
1237 data->nb_tx_queues = (uint16_t)nb_tx_queues;
1238 data->dev_link = pmd_link;
1239 data->mac_addrs = &(*internals)->eth_addr;
1240 data->promiscuous = 1;
1241 data->all_multicast = 1;
1242 data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
1245 * NOTE: we'll replace the data element, of originally allocated
1246 * eth_dev so the rings are local per-process
1248 (*eth_dev)->dev_ops = &ops;
1250 strlcpy((*internals)->devargs, rte_vdev_device_args(vdev),
1251 ETH_PCAP_ARG_MAXLEN);
1257 eth_pcap_update_mac(const char *if_name, struct rte_eth_dev *eth_dev,
1258 const unsigned int numa_node)
1261 struct rte_ether_addr mac;
1263 if (osdep_iface_mac_get(if_name, &mac) < 0)
1266 mac_addrs = rte_zmalloc_socket(NULL, RTE_ETHER_ADDR_LEN, 0, numa_node);
1267 if (mac_addrs == NULL)
1270 PMD_LOG(INFO, "Setting phy MAC for %s", if_name);
1271 rte_memcpy(mac_addrs, mac.addr_bytes, RTE_ETHER_ADDR_LEN);
1272 eth_dev->data->mac_addrs = mac_addrs;
1277 eth_from_pcaps_common(struct rte_vdev_device *vdev,
1278 struct pmd_devargs_all *devargs_all,
1279 struct pmd_internals **internals, struct rte_eth_dev **eth_dev)
1281 struct pmd_process_private *pp;
1282 struct pmd_devargs *rx_queues = &devargs_all->rx_queues;
1283 struct pmd_devargs *tx_queues = &devargs_all->tx_queues;
1284 const unsigned int nb_rx_queues = rx_queues->num_of_queue;
1285 const unsigned int nb_tx_queues = tx_queues->num_of_queue;
1288 if (pmd_init_internals(vdev, nb_rx_queues, nb_tx_queues, internals,
1292 pp = (*eth_dev)->process_private;
1293 for (i = 0; i < nb_rx_queues; i++) {
1294 struct pcap_rx_queue *rx = &(*internals)->rx_queue[i];
1295 struct devargs_queue *queue = &rx_queues->queue[i];
1297 pp->rx_pcap[i] = queue->pcap;
1298 strlcpy(rx->name, queue->name, sizeof(rx->name));
1299 strlcpy(rx->type, queue->type, sizeof(rx->type));
1302 for (i = 0; i < nb_tx_queues; i++) {
1303 struct pcap_tx_queue *tx = &(*internals)->tx_queue[i];
1304 struct devargs_queue *queue = &tx_queues->queue[i];
1306 pp->tx_dumper[i] = queue->dumper;
1307 pp->tx_pcap[i] = queue->pcap;
1308 strlcpy(tx->name, queue->name, sizeof(tx->name));
1309 strlcpy(tx->type, queue->type, sizeof(tx->type));
1316 eth_from_pcaps(struct rte_vdev_device *vdev,
1317 struct pmd_devargs_all *devargs_all)
1319 struct pmd_internals *internals = NULL;
1320 struct rte_eth_dev *eth_dev = NULL;
1321 struct pmd_devargs *rx_queues = &devargs_all->rx_queues;
1322 int single_iface = devargs_all->single_iface;
1323 unsigned int infinite_rx = devargs_all->infinite_rx;
1326 ret = eth_from_pcaps_common(vdev, devargs_all, &internals, ð_dev);
1331 /* store weather we are using a single interface for rx/tx or not */
1332 internals->single_iface = single_iface;
1335 internals->if_index =
1336 osdep_iface_index_get(rx_queues->queue[0].name);
1338 /* phy_mac arg is applied only only if "iface" devarg is provided */
1339 if (rx_queues->phy_mac) {
1340 if (eth_pcap_update_mac(rx_queues->queue[0].name,
1341 eth_dev, vdev->device.numa_node) == 0)
1342 internals->phy_mac = 1;
1346 internals->infinite_rx = infinite_rx;
1347 /* Assign rx ops. */
1349 eth_dev->rx_pkt_burst = eth_pcap_rx_infinite;
1350 else if (devargs_all->is_rx_pcap || devargs_all->is_rx_iface ||
1352 eth_dev->rx_pkt_burst = eth_pcap_rx;
1354 eth_dev->rx_pkt_burst = eth_null_rx;
1356 /* Assign tx ops. */
1357 if (devargs_all->is_tx_pcap)
1358 eth_dev->tx_pkt_burst = eth_pcap_tx_dumper;
1359 else if (devargs_all->is_tx_iface || single_iface)
1360 eth_dev->tx_pkt_burst = eth_pcap_tx;
1362 eth_dev->tx_pkt_burst = eth_tx_drop;
1364 rte_eth_dev_probing_finish(eth_dev);
1369 pmd_pcap_probe(struct rte_vdev_device *dev)
1372 struct rte_kvargs *kvlist;
1373 struct pmd_devargs pcaps = {0};
1374 struct pmd_devargs dumpers = {0};
1375 struct rte_eth_dev *eth_dev = NULL;
1376 struct pmd_internals *internal;
1379 struct pmd_devargs_all devargs_all = {
1386 name = rte_vdev_device_name(dev);
1387 PMD_LOG(INFO, "Initializing pmd_pcap for %s", name);
1389 timespec_get(&start_time, TIME_UTC);
1390 start_cycles = rte_get_timer_cycles();
1391 hz = rte_get_timer_hz();
1393 ret = rte_mbuf_dyn_rx_timestamp_register(×tamp_dynfield_offset,
1394 ×tamp_rx_dynflag);
1396 PMD_LOG(ERR, "Failed to register Rx timestamp field/flag");
1400 if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
1401 eth_dev = rte_eth_dev_attach_secondary(name);
1403 PMD_LOG(ERR, "Failed to probe %s", name);
1407 internal = eth_dev->data->dev_private;
1409 kvlist = rte_kvargs_parse(internal->devargs, valid_arguments);
1413 kvlist = rte_kvargs_parse(rte_vdev_device_args(dev),
1420 * If iface argument is passed we open the NICs and use them for
1423 if (rte_kvargs_count(kvlist, ETH_PCAP_IFACE_ARG) == 1) {
1425 ret = rte_kvargs_process(kvlist, ETH_PCAP_IFACE_ARG,
1426 &open_rx_tx_iface, &pcaps);
1430 dumpers.queue[0] = pcaps.queue[0];
1432 ret = rte_kvargs_process(kvlist, ETH_PCAP_PHY_MAC_ARG,
1433 &select_phy_mac, &pcaps.phy_mac);
1437 dumpers.phy_mac = pcaps.phy_mac;
1439 devargs_all.single_iface = 1;
1440 pcaps.num_of_queue = 1;
1441 dumpers.num_of_queue = 1;
1447 * We check whether we want to open a RX stream from a real NIC, a
1448 * pcap file or open a dummy RX stream
1450 devargs_all.is_rx_pcap =
1451 rte_kvargs_count(kvlist, ETH_PCAP_RX_PCAP_ARG) ? 1 : 0;
1452 devargs_all.is_rx_iface =
1453 (rte_kvargs_count(kvlist, ETH_PCAP_RX_IFACE_ARG) +
1454 rte_kvargs_count(kvlist, ETH_PCAP_RX_IFACE_IN_ARG)) ? 1 : 0;
1455 pcaps.num_of_queue = 0;
1457 devargs_all.is_tx_pcap =
1458 rte_kvargs_count(kvlist, ETH_PCAP_TX_PCAP_ARG) ? 1 : 0;
1459 devargs_all.is_tx_iface =
1460 rte_kvargs_count(kvlist, ETH_PCAP_TX_IFACE_ARG) ? 1 : 0;
1461 dumpers.num_of_queue = 0;
1463 if (devargs_all.is_rx_pcap) {
1465 * We check whether we want to infinitely rx the pcap file.
1467 unsigned int infinite_rx_arg_cnt = rte_kvargs_count(kvlist,
1468 ETH_PCAP_INFINITE_RX_ARG);
1470 if (infinite_rx_arg_cnt == 1) {
1471 ret = rte_kvargs_process(kvlist,
1472 ETH_PCAP_INFINITE_RX_ARG,
1473 &get_infinite_rx_arg,
1474 &devargs_all.infinite_rx);
1477 PMD_LOG(INFO, "infinite_rx has been %s for %s",
1478 devargs_all.infinite_rx ? "enabled" : "disabled",
1481 } else if (infinite_rx_arg_cnt > 1) {
1482 PMD_LOG(WARNING, "infinite_rx has not been enabled since the "
1483 "argument has been provided more than once "
1487 ret = rte_kvargs_process(kvlist, ETH_PCAP_RX_PCAP_ARG,
1488 &open_rx_pcap, &pcaps);
1489 } else if (devargs_all.is_rx_iface) {
1490 ret = rte_kvargs_process(kvlist, NULL,
1491 &rx_iface_args_process, &pcaps);
1492 } else if (devargs_all.is_tx_iface || devargs_all.is_tx_pcap) {
1495 /* Count number of tx queue args passed before dummy rx queue
1496 * creation so a dummy rx queue can be created for each tx queue
1498 unsigned int num_tx_queues =
1499 (rte_kvargs_count(kvlist, ETH_PCAP_TX_PCAP_ARG) +
1500 rte_kvargs_count(kvlist, ETH_PCAP_TX_IFACE_ARG));
1502 PMD_LOG(INFO, "Creating null rx queue since no rx queues were provided.");
1504 /* Creating a dummy rx queue for each tx queue passed */
1505 for (i = 0; i < num_tx_queues; i++)
1506 ret = add_queue(&pcaps, "dummy_rx", "rx_null", NULL,
1509 PMD_LOG(ERR, "Error - No rx or tx queues provided");
1516 * We check whether we want to open a TX stream to a real NIC,
1517 * a pcap file, or drop packets on tx
1519 if (devargs_all.is_tx_pcap) {
1520 ret = rte_kvargs_process(kvlist, ETH_PCAP_TX_PCAP_ARG,
1521 &open_tx_pcap, &dumpers);
1522 } else if (devargs_all.is_tx_iface) {
1523 ret = rte_kvargs_process(kvlist, ETH_PCAP_TX_IFACE_ARG,
1524 &open_tx_iface, &dumpers);
1528 PMD_LOG(INFO, "Dropping packets on tx since no tx queues were provided.");
1530 /* Add 1 dummy queue per rxq which counts and drops packets. */
1531 for (i = 0; i < pcaps.num_of_queue; i++)
1532 ret = add_queue(&dumpers, "dummy_tx", "tx_drop", NULL,
1540 if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
1541 struct pmd_process_private *pp;
1544 internal = eth_dev->data->dev_private;
1545 pp = (struct pmd_process_private *)
1547 sizeof(struct pmd_process_private),
1548 RTE_CACHE_LINE_SIZE);
1552 "Failed to allocate memory for process private");
1557 eth_dev->dev_ops = &ops;
1558 eth_dev->device = &dev->device;
1560 /* setup process private */
1561 for (i = 0; i < pcaps.num_of_queue; i++)
1562 pp->rx_pcap[i] = pcaps.queue[i].pcap;
1564 for (i = 0; i < dumpers.num_of_queue; i++) {
1565 pp->tx_dumper[i] = dumpers.queue[i].dumper;
1566 pp->tx_pcap[i] = dumpers.queue[i].pcap;
1569 eth_dev->process_private = pp;
1570 eth_dev->rx_pkt_burst = eth_pcap_rx;
1571 if (devargs_all.is_tx_pcap)
1572 eth_dev->tx_pkt_burst = eth_pcap_tx_dumper;
1574 eth_dev->tx_pkt_burst = eth_pcap_tx;
1576 rte_eth_dev_probing_finish(eth_dev);
1580 devargs_all.rx_queues = pcaps;
1581 devargs_all.tx_queues = dumpers;
1583 ret = eth_from_pcaps(dev, &devargs_all);
1586 rte_kvargs_free(kvlist);
1592 pmd_pcap_remove(struct rte_vdev_device *dev)
1594 struct rte_eth_dev *eth_dev = NULL;
1599 eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev));
1600 if (eth_dev == NULL)
1601 return 0; /* port already released */
1603 eth_dev_close(eth_dev);
1604 rte_eth_dev_release_port(eth_dev);
1609 static struct rte_vdev_driver pmd_pcap_drv = {
1610 .probe = pmd_pcap_probe,
1611 .remove = pmd_pcap_remove,
1614 RTE_PMD_REGISTER_VDEV(net_pcap, pmd_pcap_drv);
1615 RTE_PMD_REGISTER_ALIAS(net_pcap, eth_pcap);
1616 RTE_PMD_REGISTER_PARAM_STRING(net_pcap,
1617 ETH_PCAP_RX_PCAP_ARG "=<string> "
1618 ETH_PCAP_TX_PCAP_ARG "=<string> "
1619 ETH_PCAP_RX_IFACE_ARG "=<ifc> "
1620 ETH_PCAP_RX_IFACE_IN_ARG "=<ifc> "
1621 ETH_PCAP_TX_IFACE_ARG "=<ifc> "
1622 ETH_PCAP_IFACE_ARG "=<ifc> "
1623 ETH_PCAP_PHY_MAC_ARG "=<int>"
1624 ETH_PCAP_INFINITE_RX_ARG "=<0|1>");