4 * Copyright(c) 2016 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 #include <rte_common.h>
46 #include <rte_debug.h>
47 #include <rte_ethdev.h>
48 #include <rte_memory.h>
49 #include <rte_lcore.h>
50 #include <rte_branch_prediction.h>
51 #include <rte_errno.h>
53 #include <rte_kvargs.h>
54 #include <rte_mempool.h>
56 #include <rte_pdump.h>
58 #define CMD_LINE_OPT_PDUMP "pdump"
59 #define PDUMP_PORT_ARG "port"
60 #define PDUMP_PCI_ARG "device_id"
61 #define PDUMP_QUEUE_ARG "queue"
62 #define PDUMP_DIR_ARG "dir"
63 #define PDUMP_RX_DEV_ARG "rx-dev"
64 #define PDUMP_TX_DEV_ARG "tx-dev"
65 #define PDUMP_RING_SIZE_ARG "ring-size"
66 #define PDUMP_MSIZE_ARG "mbuf-size"
67 #define PDUMP_NUM_MBUFS_ARG "total-num-mbufs"
68 #define CMD_LINE_OPT_SER_SOCK_PATH "server-socket-path"
69 #define CMD_LINE_OPT_CLI_SOCK_PATH "client-socket-path"
71 #define VDEV_PCAP "net_pcap_%s_%d,tx_pcap=%s"
72 #define VDEV_IFACE "net_pcap_%s_%d,tx_iface=%s"
73 #define TX_STREAM_SIZE 64
75 #define MP_NAME "pdump_pool_%d"
77 #define RX_RING "rx_ring_%d"
78 #define TX_RING "tx_ring_%d"
83 /* Maximum long option length for option parsing. */
84 #define APP_ARG_TCPDUMP_MAX_TUPLES 54
85 #define MBUF_POOL_CACHE_SIZE 250
86 #define TX_DESC_PER_QUEUE 512
87 #define RX_DESC_PER_QUEUE 128
88 #define MBUFS_PER_POOL 65535
89 #define MAX_LONG_OPT_SZ 64
90 #define RING_SIZE 16384
95 #define RTE_RING_SZ_MASK (unsigned)(0x0fffffff) /**< Ring size mask */
96 /* true if x is a power of 2 */
97 #define POWEROF2(x) ((((x)-1) & (x)) == 0)
114 const char *valid_pdump_arguments
[] = {
128 uint64_t dequeue_pkts
;
133 struct pdump_tuples
{
138 char rx_dev
[TX_STREAM_SIZE
];
139 char tx_dev
[TX_STREAM_SIZE
];
141 uint16_t mbuf_data_size
;
142 uint32_t total_num_mbufs
;
144 /* params for library API call */
146 struct rte_mempool
*mp
;
147 struct rte_ring
*rx_ring
;
148 struct rte_ring
*tx_ring
;
150 /* params for packet dumping */
151 enum pdump_by dump_by_type
;
154 enum pcap_stream rx_vdev_stream_type
;
155 enum pcap_stream tx_vdev_stream_type
;
156 bool single_pdump_dev
;
159 struct pdump_stats stats
;
160 } __rte_cache_aligned
;
161 static struct pdump_tuples pdump_t
[APP_ARG_TCPDUMP_MAX_TUPLES
];
170 static struct rte_eth_conf port_conf_default
;
171 volatile uint8_t quit_signal
;
172 static char server_socket_path
[PATH_MAX
];
173 static char client_socket_path
[PATH_MAX
];
175 /**< display usage */
177 pdump_usage(const char *prgname
)
179 printf("usage: %s [EAL options] -- --pdump "
180 "'(port=<port id> | device_id=<pci id or vdev name>),"
181 "(queue=<queue_id>),"
182 "(rx-dev=<iface or pcap file> |"
183 " tx-dev=<iface or pcap file>,"
184 "[ring-size=<ring size>default:16384],"
185 "[mbuf-size=<mbuf data size>default:2176],"
186 "[total-num-mbufs=<number of mbufs>default:65535]'\n"
187 "[--server-socket-path=<server socket dir>"
188 "default:/var/run/.dpdk/ (or) ~/.dpdk/]\n"
189 "[--client-socket-path=<client socket dir>"
190 "default:/var/run/.dpdk/ (or) ~/.dpdk/]\n",
195 parse_device_id(const char *key __rte_unused
, const char *value
,
198 struct pdump_tuples
*pt
= extra_args
;
200 pt
->device_id
= strdup(value
);
201 pt
->dump_by_type
= DEVICE_ID
;
207 parse_queue(const char *key __rte_unused
, const char *value
, void *extra_args
)
210 struct pdump_tuples
*pt
= extra_args
;
212 if (!strcmp(value
, "*"))
213 pt
->queue
= RTE_PDUMP_ALL_QUEUES
;
215 n
= strtoul(value
, NULL
, 10);
216 pt
->queue
= (uint16_t) n
;
222 parse_rxtxdev(const char *key
, const char *value
, void *extra_args
)
225 struct pdump_tuples
*pt
= extra_args
;
227 if (!strcmp(key
, PDUMP_RX_DEV_ARG
)) {
228 snprintf(pt
->rx_dev
, sizeof(pt
->rx_dev
), "%s", value
);
229 /* identify the tx stream type for pcap vdev */
230 if (if_nametoindex(pt
->rx_dev
))
231 pt
->rx_vdev_stream_type
= IFACE
;
232 } else if (!strcmp(key
, PDUMP_TX_DEV_ARG
)) {
233 snprintf(pt
->tx_dev
, sizeof(pt
->tx_dev
), "%s", value
);
234 /* identify the tx stream type for pcap vdev */
235 if (if_nametoindex(pt
->tx_dev
))
236 pt
->tx_vdev_stream_type
= IFACE
;
243 parse_uint_value(const char *key
, const char *value
, void *extra_args
)
252 t
= strtoul(value
, &end
, 10);
254 if (errno
!= 0 || end
[0] != 0 || t
< v
->min
|| t
> v
->max
) {
255 printf("invalid value:\"%s\" for key:\"%s\", "
256 "value must be >= %"PRIu64
" and <= %"PRIu64
"\n",
257 value
, key
, v
->min
, v
->max
);
260 if (!strcmp(key
, PDUMP_RING_SIZE_ARG
) && !POWEROF2(t
)) {
261 printf("invalid value:\"%s\" for key:\"%s\", "
262 "value must be power of 2\n", value
, key
);
274 parse_pdump(const char *optarg
)
276 struct rte_kvargs
*kvlist
;
277 int ret
= 0, cnt1
, cnt2
;
278 struct pdump_tuples
*pt
;
279 struct parse_val v
= {0};
281 pt
= &pdump_t
[num_tuples
];
283 /* initial check for invalid arguments */
284 kvlist
= rte_kvargs_parse(optarg
, valid_pdump_arguments
);
285 if (kvlist
== NULL
) {
286 printf("--pdump=\"%s\": invalid argument passed\n", optarg
);
290 /* port/device_id parsing and validation */
291 cnt1
= rte_kvargs_count(kvlist
, PDUMP_PORT_ARG
);
292 cnt2
= rte_kvargs_count(kvlist
, PDUMP_PCI_ARG
);
293 if (!((cnt1
== 1 && cnt2
== 0) || (cnt1
== 0 && cnt2
== 1))) {
294 printf("--pdump=\"%s\": must have either port or "
295 "device_id argument\n", optarg
);
298 } else if (cnt1
== 1) {
300 v
.max
= RTE_MAX_ETHPORTS
-1;
301 ret
= rte_kvargs_process(kvlist
, PDUMP_PORT_ARG
,
302 &parse_uint_value
, &v
);
305 pt
->port
= (uint8_t) v
.val
;
306 pt
->dump_by_type
= PORT_ID
;
307 } else if (cnt2
== 1) {
308 ret
= rte_kvargs_process(kvlist
, PDUMP_PCI_ARG
,
309 &parse_device_id
, pt
);
314 /* queue parsing and validation */
315 cnt1
= rte_kvargs_count(kvlist
, PDUMP_QUEUE_ARG
);
317 printf("--pdump=\"%s\": must have queue argument\n", optarg
);
321 ret
= rte_kvargs_process(kvlist
, PDUMP_QUEUE_ARG
, &parse_queue
, pt
);
325 /* rx-dev and tx-dev parsing and validation */
326 cnt1
= rte_kvargs_count(kvlist
, PDUMP_RX_DEV_ARG
);
327 cnt2
= rte_kvargs_count(kvlist
, PDUMP_TX_DEV_ARG
);
328 if (cnt1
== 0 && cnt2
== 0) {
329 printf("--pdump=\"%s\": must have either rx-dev or "
330 "tx-dev argument\n", optarg
);
333 } else if (cnt1
== 1 && cnt2
== 1) {
334 ret
= rte_kvargs_process(kvlist
, PDUMP_RX_DEV_ARG
,
338 ret
= rte_kvargs_process(kvlist
, PDUMP_TX_DEV_ARG
,
342 /* if captured packets has to send to the same vdev */
343 if (!strcmp(pt
->rx_dev
, pt
->tx_dev
))
344 pt
->single_pdump_dev
= true;
345 pt
->dir
= RTE_PDUMP_FLAG_RXTX
;
346 } else if (cnt1
== 1) {
347 ret
= rte_kvargs_process(kvlist
, PDUMP_RX_DEV_ARG
,
351 pt
->dir
= RTE_PDUMP_FLAG_RX
;
352 } else if (cnt2
== 1) {
353 ret
= rte_kvargs_process(kvlist
, PDUMP_TX_DEV_ARG
,
357 pt
->dir
= RTE_PDUMP_FLAG_TX
;
361 /* ring_size parsing and validation */
362 cnt1
= rte_kvargs_count(kvlist
, PDUMP_RING_SIZE_ARG
);
365 v
.max
= RTE_RING_SZ_MASK
-1;
366 ret
= rte_kvargs_process(kvlist
, PDUMP_RING_SIZE_ARG
,
367 &parse_uint_value
, &v
);
370 pt
->ring_size
= (uint32_t) v
.val
;
372 pt
->ring_size
= RING_SIZE
;
374 /* mbuf_data_size parsing and validation */
375 cnt1
= rte_kvargs_count(kvlist
, PDUMP_MSIZE_ARG
);
379 ret
= rte_kvargs_process(kvlist
, PDUMP_MSIZE_ARG
,
380 &parse_uint_value
, &v
);
383 pt
->mbuf_data_size
= (uint16_t) v
.val
;
385 pt
->mbuf_data_size
= RTE_MBUF_DEFAULT_BUF_SIZE
;
387 /* total_num_mbufs parsing and validation */
388 cnt1
= rte_kvargs_count(kvlist
, PDUMP_NUM_MBUFS_ARG
);
392 ret
= rte_kvargs_process(kvlist
, PDUMP_NUM_MBUFS_ARG
,
393 &parse_uint_value
, &v
);
396 pt
->total_num_mbufs
= (uint16_t) v
.val
;
398 pt
->total_num_mbufs
= MBUFS_PER_POOL
;
403 rte_kvargs_free(kvlist
);
407 /* Parse the argument given in the command line of the application */
409 launch_args_parse(int argc
, char **argv
, char *prgname
)
413 static struct option long_option
[] = {
415 {"server-socket-path", 1, 0, 0},
416 {"client-socket-path", 1, 0, 0},
421 pdump_usage(prgname
);
423 /* Parse command line */
424 while ((opt
= getopt_long(argc
, argv
, " ",
425 long_option
, &option_index
)) != EOF
) {
428 if (!strncmp(long_option
[option_index
].name
,
430 sizeof(CMD_LINE_OPT_PDUMP
))) {
431 ret
= parse_pdump(optarg
);
433 pdump_usage(prgname
);
438 if (!strncmp(long_option
[option_index
].name
,
439 CMD_LINE_OPT_SER_SOCK_PATH
,
440 sizeof(CMD_LINE_OPT_SER_SOCK_PATH
))) {
441 snprintf(server_socket_path
,
442 sizeof(server_socket_path
), "%s",
446 if (!strncmp(long_option
[option_index
].name
,
447 CMD_LINE_OPT_CLI_SOCK_PATH
,
448 sizeof(CMD_LINE_OPT_CLI_SOCK_PATH
))) {
449 snprintf(client_socket_path
,
450 sizeof(client_socket_path
), "%s",
456 pdump_usage(prgname
);
465 print_pdump_stats(void)
468 struct pdump_tuples
*pt
;
470 for (i
= 0; i
< num_tuples
; i
++) {
471 printf("##### PDUMP DEBUG STATS #####\n");
473 printf(" -packets dequeued: %"PRIu64
"\n",
474 pt
->stats
.dequeue_pkts
);
475 printf(" -packets transmitted to vdev: %"PRIu64
"\n",
477 printf(" -packets freed: %"PRIu64
"\n",
478 pt
->stats
.freed_pkts
);
483 disable_pdump(struct pdump_tuples
*pt
)
485 if (pt
->dump_by_type
== DEVICE_ID
)
486 rte_pdump_disable_by_deviceid(pt
->device_id
, pt
->queue
,
488 else if (pt
->dump_by_type
== PORT_ID
)
489 rte_pdump_disable(pt
->port
, pt
->queue
, pt
->dir
);
493 pdump_rxtx(struct rte_ring
*ring
, uint8_t vdev_id
, struct pdump_stats
*stats
)
495 /* write input packets of port to vdev for pdump */
496 struct rte_mbuf
*rxtx_bufs
[BURST_SIZE
];
498 /* first dequeue packets from ring of primary process */
499 const uint16_t nb_in_deq
= rte_ring_dequeue_burst(ring
,
500 (void *)rxtx_bufs
, BURST_SIZE
);
501 stats
->dequeue_pkts
+= nb_in_deq
;
504 /* then sent on vdev */
505 uint16_t nb_in_txd
= rte_eth_tx_burst(
507 0, rxtx_bufs
, nb_in_deq
);
508 stats
->tx_pkts
+= nb_in_txd
;
510 if (unlikely(nb_in_txd
< nb_in_deq
)) {
512 rte_pktmbuf_free(rxtx_bufs
[nb_in_txd
]);
514 } while (++nb_in_txd
< nb_in_deq
);
520 free_ring_data(struct rte_ring
*ring
, uint8_t vdev_id
,
521 struct pdump_stats
*stats
)
523 while (rte_ring_count(ring
))
524 pdump_rxtx(ring
, vdev_id
, stats
);
531 struct pdump_tuples
*pt
;
533 for (i
= 0; i
< num_tuples
; i
++) {
541 rte_ring_free(pt
->rx_ring
);
543 rte_ring_free(pt
->tx_ring
);
548 cleanup_pdump_resources(void)
551 struct pdump_tuples
*pt
;
553 /* disable pdump and free the pdump_tuple resources */
554 for (i
= 0; i
< num_tuples
; i
++) {
557 /* remove callbacks */
561 * transmit rest of the enqueued packets of the rings on to
562 * the vdev, in order to release mbufs to the mepool.
564 if (pt
->dir
& RTE_PDUMP_FLAG_RX
)
565 free_ring_data(pt
->rx_ring
, pt
->rx_vdev_id
, &pt
->stats
);
566 if (pt
->dir
& RTE_PDUMP_FLAG_TX
)
567 free_ring_data(pt
->tx_ring
, pt
->tx_vdev_id
, &pt
->stats
);
573 signal_handler(int sig_num
)
575 if (sig_num
== SIGINT
) {
576 printf("\n\nSignal %d received, preparing to exit...\n",
583 configure_vdev(uint8_t port_id
)
585 struct ether_addr addr
;
586 const uint16_t rxRings
= 0, txRings
= 1;
587 const uint8_t nb_ports
= rte_eth_dev_count();
591 if (port_id
> nb_ports
)
594 ret
= rte_eth_dev_configure(port_id
, rxRings
, txRings
,
597 rte_exit(EXIT_FAILURE
, "dev config failed\n");
599 for (q
= 0; q
< txRings
; q
++) {
600 ret
= rte_eth_tx_queue_setup(port_id
, q
, TX_DESC_PER_QUEUE
,
601 rte_eth_dev_socket_id(port_id
), NULL
);
603 rte_exit(EXIT_FAILURE
, "queue setup failed\n");
606 ret
= rte_eth_dev_start(port_id
);
608 rte_exit(EXIT_FAILURE
, "dev start failed\n");
610 rte_eth_macaddr_get(port_id
, &addr
);
611 printf("Port %u MAC: %02"PRIx8
" %02"PRIx8
" %02"PRIx8
612 " %02"PRIx8
" %02"PRIx8
" %02"PRIx8
"\n",
614 addr
.addr_bytes
[0], addr
.addr_bytes
[1],
615 addr
.addr_bytes
[2], addr
.addr_bytes
[3],
616 addr
.addr_bytes
[4], addr
.addr_bytes
[5]);
618 rte_eth_promiscuous_enable(port_id
);
624 create_mp_ring_vdev(void)
628 struct pdump_tuples
*pt
= NULL
;
629 struct rte_mempool
*mbuf_pool
= NULL
;
630 char vdev_args
[SIZE
];
631 char ring_name
[SIZE
];
632 char mempool_name
[SIZE
];
634 for (i
= 0; i
< num_tuples
; i
++) {
636 snprintf(mempool_name
, SIZE
, MP_NAME
, i
);
637 mbuf_pool
= rte_mempool_lookup(mempool_name
);
638 if (mbuf_pool
== NULL
) {
640 mbuf_pool
= rte_pktmbuf_pool_create(mempool_name
,
642 MBUF_POOL_CACHE_SIZE
, 0,
645 if (mbuf_pool
== NULL
) {
647 rte_exit(EXIT_FAILURE
,
648 "Mempool creation failed: %s\n",
649 rte_strerror(rte_errno
));
654 if (pt
->dir
== RTE_PDUMP_FLAG_RXTX
) {
655 /* if captured packets has to send to the same vdev */
657 snprintf(ring_name
, SIZE
, RX_RING
, i
);
658 pt
->rx_ring
= rte_ring_create(ring_name
, pt
->ring_size
,
660 if (pt
->rx_ring
== NULL
) {
662 rte_exit(EXIT_FAILURE
, "%s:%s:%d\n",
663 rte_strerror(rte_errno
),
668 snprintf(ring_name
, SIZE
, TX_RING
, i
);
669 pt
->tx_ring
= rte_ring_create(ring_name
, pt
->ring_size
,
671 if (pt
->tx_ring
== NULL
) {
673 rte_exit(EXIT_FAILURE
, "%s:%s:%d\n",
674 rte_strerror(rte_errno
),
679 (pt
->rx_vdev_stream_type
== IFACE
) ?
680 snprintf(vdev_args
, SIZE
, VDEV_IFACE
, RX_STR
, i
,
682 snprintf(vdev_args
, SIZE
, VDEV_PCAP
, RX_STR
, i
,
684 if (rte_eth_dev_attach(vdev_args
, &portid
) < 0) {
686 rte_exit(EXIT_FAILURE
,
687 "vdev creation failed:%s:%d\n",
690 pt
->rx_vdev_id
= portid
;
693 configure_vdev(pt
->rx_vdev_id
);
695 if (pt
->single_pdump_dev
)
696 pt
->tx_vdev_id
= portid
;
698 (pt
->tx_vdev_stream_type
== IFACE
) ?
699 snprintf(vdev_args
, SIZE
, VDEV_IFACE
, TX_STR
, i
,
701 snprintf(vdev_args
, SIZE
, VDEV_PCAP
, TX_STR
, i
,
703 if (rte_eth_dev_attach(vdev_args
,
706 rte_exit(EXIT_FAILURE
,
707 "vdev creation failed:"
708 "%s:%d\n", __func__
, __LINE__
);
710 pt
->tx_vdev_id
= portid
;
713 configure_vdev(pt
->tx_vdev_id
);
715 } else if (pt
->dir
== RTE_PDUMP_FLAG_RX
) {
718 snprintf(ring_name
, SIZE
, RX_RING
, i
);
719 pt
->rx_ring
= rte_ring_create(ring_name
, pt
->ring_size
,
721 if (pt
->rx_ring
== NULL
) {
723 rte_exit(EXIT_FAILURE
, "%s\n",
724 rte_strerror(rte_errno
));
727 (pt
->rx_vdev_stream_type
== IFACE
) ?
728 snprintf(vdev_args
, SIZE
, VDEV_IFACE
, RX_STR
, i
,
730 snprintf(vdev_args
, SIZE
, VDEV_PCAP
, RX_STR
, i
,
732 if (rte_eth_dev_attach(vdev_args
, &portid
) < 0) {
734 rte_exit(EXIT_FAILURE
,
735 "vdev creation failed:%s:%d\n",
738 pt
->rx_vdev_id
= portid
;
740 configure_vdev(pt
->rx_vdev_id
);
741 } else if (pt
->dir
== RTE_PDUMP_FLAG_TX
) {
744 snprintf(ring_name
, SIZE
, TX_RING
, i
);
745 pt
->tx_ring
= rte_ring_create(ring_name
, pt
->ring_size
,
747 if (pt
->tx_ring
== NULL
) {
749 rte_exit(EXIT_FAILURE
, "%s\n",
750 rte_strerror(rte_errno
));
753 (pt
->tx_vdev_stream_type
== IFACE
) ?
754 snprintf(vdev_args
, SIZE
, VDEV_IFACE
, TX_STR
, i
,
756 snprintf(vdev_args
, SIZE
, VDEV_PCAP
, TX_STR
, i
,
758 if (rte_eth_dev_attach(vdev_args
, &portid
) < 0) {
760 rte_exit(EXIT_FAILURE
,
761 "vdev creation failed\n");
763 pt
->tx_vdev_id
= portid
;
766 configure_vdev(pt
->tx_vdev_id
);
775 struct pdump_tuples
*pt
;
776 int ret
= 0, ret1
= 0;
778 if (server_socket_path
[0] != 0)
779 ret
= rte_pdump_set_socket_dir(server_socket_path
,
780 RTE_PDUMP_SOCKET_SERVER
);
781 if (ret
== 0 && client_socket_path
[0] != 0) {
782 ret
= rte_pdump_set_socket_dir(client_socket_path
,
783 RTE_PDUMP_SOCKET_CLIENT
);
786 cleanup_pdump_resources();
787 rte_exit(EXIT_FAILURE
,
788 "failed to set socket paths of server:%s, "
794 for (i
= 0; i
< num_tuples
; i
++) {
796 if (pt
->dir
== RTE_PDUMP_FLAG_RXTX
) {
797 if (pt
->dump_by_type
== DEVICE_ID
) {
798 ret
= rte_pdump_enable_by_deviceid(
804 ret1
= rte_pdump_enable_by_deviceid(
810 } else if (pt
->dump_by_type
== PORT_ID
) {
811 ret
= rte_pdump_enable(pt
->port
, pt
->queue
,
813 pt
->rx_ring
, pt
->mp
, NULL
);
814 ret1
= rte_pdump_enable(pt
->port
, pt
->queue
,
816 pt
->tx_ring
, pt
->mp
, NULL
);
818 } else if (pt
->dir
== RTE_PDUMP_FLAG_RX
) {
819 if (pt
->dump_by_type
== DEVICE_ID
)
820 ret
= rte_pdump_enable_by_deviceid(
823 pt
->dir
, pt
->rx_ring
,
825 else if (pt
->dump_by_type
== PORT_ID
)
826 ret
= rte_pdump_enable(pt
->port
, pt
->queue
,
828 pt
->rx_ring
, pt
->mp
, NULL
);
829 } else if (pt
->dir
== RTE_PDUMP_FLAG_TX
) {
830 if (pt
->dump_by_type
== DEVICE_ID
)
831 ret
= rte_pdump_enable_by_deviceid(
835 pt
->tx_ring
, pt
->mp
, NULL
);
836 else if (pt
->dump_by_type
== PORT_ID
)
837 ret
= rte_pdump_enable(pt
->port
, pt
->queue
,
839 pt
->tx_ring
, pt
->mp
, NULL
);
841 if (ret
< 0 || ret1
< 0) {
842 cleanup_pdump_resources();
843 rte_exit(EXIT_FAILURE
, "%s\n", rte_strerror(rte_errno
));
852 struct pdump_tuples
*pt
;
854 while (!quit_signal
) {
855 for (i
= 0; i
< num_tuples
; i
++) {
857 if (pt
->dir
& RTE_PDUMP_FLAG_RX
)
858 pdump_rxtx(pt
->rx_ring
, pt
->rx_vdev_id
,
860 if (pt
->dir
& RTE_PDUMP_FLAG_TX
)
861 pdump_rxtx(pt
->tx_ring
, pt
->tx_vdev_id
,
868 main(int argc
, char **argv
)
874 char c_flag
[] = "-c1";
875 char n_flag
[] = "-n4";
876 char mp_flag
[] = "--proc-type=secondary";
877 char *argp
[argc
+ 3];
879 /* catch ctrl-c so we can print on exit */
880 signal(SIGINT
, signal_handler
);
887 for (i
= 1; i
< argc
; i
++)
888 argp
[i
+ 3] = argv
[i
];
892 diag
= rte_eal_init(argc
, argp
);
894 rte_panic("Cannot init EAL\n");
899 /* parse app arguments */
901 ret
= launch_args_parse(argc
, argv
, argp
[0]);
903 rte_exit(EXIT_FAILURE
, "Invalid argument\n");
906 /* create mempool, ring and vdevs info */
907 create_mp_ring_vdev();
911 cleanup_pdump_resources();
912 /* dump debug stats */