1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016 Intel Corporation
16 #include <rte_common.h>
17 #include <rte_debug.h>
18 #include <rte_ethdev.h>
19 #include <rte_memory.h>
20 #include <rte_lcore.h>
21 #include <rte_branch_prediction.h>
22 #include <rte_errno.h>
24 #include <rte_kvargs.h>
25 #include <rte_mempool.h>
27 #include <rte_string_fns.h>
28 #include <rte_pdump.h>
30 #define CMD_LINE_OPT_PDUMP "pdump"
31 #define CMD_LINE_OPT_PDUMP_NUM 256
32 #define CMD_LINE_OPT_MULTI "multi"
33 #define CMD_LINE_OPT_MULTI_NUM 257
34 #define PDUMP_PORT_ARG "port"
35 #define PDUMP_PCI_ARG "device_id"
36 #define PDUMP_QUEUE_ARG "queue"
37 #define PDUMP_DIR_ARG "dir"
38 #define PDUMP_RX_DEV_ARG "rx-dev"
39 #define PDUMP_TX_DEV_ARG "tx-dev"
40 #define PDUMP_RING_SIZE_ARG "ring-size"
41 #define PDUMP_MSIZE_ARG "mbuf-size"
42 #define PDUMP_NUM_MBUFS_ARG "total-num-mbufs"
44 #define VDEV_NAME_FMT "net_pcap_%s_%d"
45 #define VDEV_PCAP_ARGS_FMT "tx_pcap=%s"
46 #define VDEV_IFACE_ARGS_FMT "tx_iface=%s"
47 #define TX_STREAM_SIZE 64
49 #define MP_NAME "pdump_pool_%d"
51 #define RX_RING "rx_ring_%d"
52 #define TX_RING "tx_ring_%d"
57 /* Maximum long option length for option parsing. */
58 #define APP_ARG_TCPDUMP_MAX_TUPLES 54
59 #define MBUF_POOL_CACHE_SIZE 250
60 #define TX_DESC_PER_QUEUE 512
61 #define RX_DESC_PER_QUEUE 128
62 #define MBUFS_PER_POOL 65535
63 #define MAX_LONG_OPT_SZ 64
64 #define RING_SIZE 16384
69 /* true if x is a power of 2 */
70 #define POWEROF2(x) ((((x)-1) & (x)) == 0)
87 static const char * const valid_pdump_arguments[] = {
101 uint64_t dequeue_pkts;
106 struct pdump_tuples {
111 char rx_dev[TX_STREAM_SIZE];
112 char tx_dev[TX_STREAM_SIZE];
114 uint16_t mbuf_data_size;
115 uint32_t total_num_mbufs;
117 /* params for library API call */
119 struct rte_mempool *mp;
120 struct rte_ring *rx_ring;
121 struct rte_ring *tx_ring;
123 /* params for packet dumping */
124 enum pdump_by dump_by_type;
127 enum pcap_stream rx_vdev_stream_type;
128 enum pcap_stream tx_vdev_stream_type;
129 bool single_pdump_dev;
132 struct pdump_stats stats;
133 } __rte_cache_aligned;
134 static struct pdump_tuples pdump_t[APP_ARG_TCPDUMP_MAX_TUPLES];
142 static int num_tuples;
143 static struct rte_eth_conf port_conf_default;
144 static volatile uint8_t quit_signal;
145 static uint8_t multiple_core_capture;
147 /**< display usage */
149 pdump_usage(const char *prgname)
151 printf("usage: %s [EAL options]"
152 " --["CMD_LINE_OPT_MULTI"]\n"
153 " --"CMD_LINE_OPT_PDUMP" "
154 "'(port=<port id> | device_id=<pci id or vdev name>),"
155 "(queue=<queue_id>),"
156 "(rx-dev=<iface or pcap file> |"
157 " tx-dev=<iface or pcap file>,"
158 "[ring-size=<ring size>default:16384],"
159 "[mbuf-size=<mbuf data size>default:2176],"
160 "[total-num-mbufs=<number of mbufs>default:65535]'\n",
165 parse_device_id(const char *key __rte_unused, const char *value,
168 struct pdump_tuples *pt = extra_args;
170 pt->device_id = strdup(value);
171 pt->dump_by_type = DEVICE_ID;
177 parse_queue(const char *key __rte_unused, const char *value, void *extra_args)
180 struct pdump_tuples *pt = extra_args;
182 if (!strcmp(value, "*"))
183 pt->queue = RTE_PDUMP_ALL_QUEUES;
185 n = strtoul(value, NULL, 10);
186 pt->queue = (uint16_t) n;
192 parse_rxtxdev(const char *key, const char *value, void *extra_args)
195 struct pdump_tuples *pt = extra_args;
197 if (!strcmp(key, PDUMP_RX_DEV_ARG)) {
198 strlcpy(pt->rx_dev, value, sizeof(pt->rx_dev));
199 /* identify the tx stream type for pcap vdev */
200 if (if_nametoindex(pt->rx_dev))
201 pt->rx_vdev_stream_type = IFACE;
202 } else if (!strcmp(key, PDUMP_TX_DEV_ARG)) {
203 strlcpy(pt->tx_dev, value, sizeof(pt->tx_dev));
204 /* identify the tx stream type for pcap vdev */
205 if (if_nametoindex(pt->tx_dev))
206 pt->tx_vdev_stream_type = IFACE;
213 parse_uint_value(const char *key, const char *value, void *extra_args)
222 t = strtoul(value, &end, 10);
224 if (errno != 0 || end[0] != 0 || t < v->min || t > v->max) {
225 printf("invalid value:\"%s\" for key:\"%s\", "
226 "value must be >= %"PRIu64" and <= %"PRIu64"\n",
227 value, key, v->min, v->max);
230 if (!strcmp(key, PDUMP_RING_SIZE_ARG) && !POWEROF2(t)) {
231 printf("invalid value:\"%s\" for key:\"%s\", "
232 "value must be power of 2\n", value, key);
244 parse_pdump(const char *optarg)
246 struct rte_kvargs *kvlist;
247 int ret = 0, cnt1, cnt2;
248 struct pdump_tuples *pt;
249 struct parse_val v = {0};
251 pt = &pdump_t[num_tuples];
253 /* initial check for invalid arguments */
254 kvlist = rte_kvargs_parse(optarg, valid_pdump_arguments);
255 if (kvlist == NULL) {
256 printf("--pdump=\"%s\": invalid argument passed\n", optarg);
260 /* port/device_id parsing and validation */
261 cnt1 = rte_kvargs_count(kvlist, PDUMP_PORT_ARG);
262 cnt2 = rte_kvargs_count(kvlist, PDUMP_PCI_ARG);
263 if (!((cnt1 == 1 && cnt2 == 0) || (cnt1 == 0 && cnt2 == 1))) {
264 printf("--pdump=\"%s\": must have either port or "
265 "device_id argument\n", optarg);
268 } else if (cnt1 == 1) {
270 v.max = RTE_MAX_ETHPORTS-1;
271 ret = rte_kvargs_process(kvlist, PDUMP_PORT_ARG,
272 &parse_uint_value, &v);
275 pt->port = (uint16_t) v.val;
276 pt->dump_by_type = PORT_ID;
277 } else if (cnt2 == 1) {
278 ret = rte_kvargs_process(kvlist, PDUMP_PCI_ARG,
279 &parse_device_id, pt);
284 /* queue parsing and validation */
285 cnt1 = rte_kvargs_count(kvlist, PDUMP_QUEUE_ARG);
287 printf("--pdump=\"%s\": must have queue argument\n", optarg);
291 ret = rte_kvargs_process(kvlist, PDUMP_QUEUE_ARG, &parse_queue, pt);
295 /* rx-dev and tx-dev parsing and validation */
296 cnt1 = rte_kvargs_count(kvlist, PDUMP_RX_DEV_ARG);
297 cnt2 = rte_kvargs_count(kvlist, PDUMP_TX_DEV_ARG);
298 if (cnt1 == 0 && cnt2 == 0) {
299 printf("--pdump=\"%s\": must have either rx-dev or "
300 "tx-dev argument\n", optarg);
303 } else if (cnt1 == 1 && cnt2 == 1) {
304 ret = rte_kvargs_process(kvlist, PDUMP_RX_DEV_ARG,
308 ret = rte_kvargs_process(kvlist, PDUMP_TX_DEV_ARG,
312 /* if captured packets has to send to the same vdev */
313 if (!strcmp(pt->rx_dev, pt->tx_dev))
314 pt->single_pdump_dev = true;
315 pt->dir = RTE_PDUMP_FLAG_RXTX;
316 } else if (cnt1 == 1) {
317 ret = rte_kvargs_process(kvlist, PDUMP_RX_DEV_ARG,
321 pt->dir = RTE_PDUMP_FLAG_RX;
322 } else if (cnt2 == 1) {
323 ret = rte_kvargs_process(kvlist, PDUMP_TX_DEV_ARG,
327 pt->dir = RTE_PDUMP_FLAG_TX;
331 /* ring_size parsing and validation */
332 cnt1 = rte_kvargs_count(kvlist, PDUMP_RING_SIZE_ARG);
335 v.max = RTE_RING_SZ_MASK-1;
336 ret = rte_kvargs_process(kvlist, PDUMP_RING_SIZE_ARG,
337 &parse_uint_value, &v);
340 pt->ring_size = (uint32_t) v.val;
342 pt->ring_size = RING_SIZE;
344 /* mbuf_data_size parsing and validation */
345 cnt1 = rte_kvargs_count(kvlist, PDUMP_MSIZE_ARG);
349 ret = rte_kvargs_process(kvlist, PDUMP_MSIZE_ARG,
350 &parse_uint_value, &v);
353 pt->mbuf_data_size = (uint16_t) v.val;
355 pt->mbuf_data_size = RTE_MBUF_DEFAULT_BUF_SIZE;
357 /* total_num_mbufs parsing and validation */
358 cnt1 = rte_kvargs_count(kvlist, PDUMP_NUM_MBUFS_ARG);
362 ret = rte_kvargs_process(kvlist, PDUMP_NUM_MBUFS_ARG,
363 &parse_uint_value, &v);
366 pt->total_num_mbufs = (uint16_t) v.val;
368 pt->total_num_mbufs = MBUFS_PER_POOL;
373 rte_kvargs_free(kvlist);
377 /* Parse the argument given in the command line of the application */
379 launch_args_parse(int argc, char **argv, char *prgname)
383 static struct option long_option[] = {
384 {CMD_LINE_OPT_PDUMP, 1, 0, CMD_LINE_OPT_PDUMP_NUM},
385 {CMD_LINE_OPT_MULTI, 0, 0, CMD_LINE_OPT_MULTI_NUM},
390 pdump_usage(prgname);
392 /* Parse command line */
393 while ((opt = getopt_long(argc, argv, " ",
394 long_option, &option_index)) != EOF) {
396 case CMD_LINE_OPT_PDUMP_NUM:
397 ret = parse_pdump(optarg);
399 pdump_usage(prgname);
403 case CMD_LINE_OPT_MULTI_NUM:
404 multiple_core_capture = 1;
407 pdump_usage(prgname);
416 print_pdump_stats(void)
419 struct pdump_tuples *pt;
421 for (i = 0; i < num_tuples; i++) {
422 printf("##### PDUMP DEBUG STATS #####\n");
424 printf(" -packets dequeued: %"PRIu64"\n",
425 pt->stats.dequeue_pkts);
426 printf(" -packets transmitted to vdev: %"PRIu64"\n",
428 printf(" -packets freed: %"PRIu64"\n",
429 pt->stats.freed_pkts);
434 disable_pdump(struct pdump_tuples *pt)
436 if (pt->dump_by_type == DEVICE_ID)
437 rte_pdump_disable_by_deviceid(pt->device_id, pt->queue,
439 else if (pt->dump_by_type == PORT_ID)
440 rte_pdump_disable(pt->port, pt->queue, pt->dir);
444 pdump_rxtx(struct rte_ring *ring, uint16_t vdev_id, struct pdump_stats *stats)
446 /* write input packets of port to vdev for pdump */
447 struct rte_mbuf *rxtx_bufs[BURST_SIZE];
449 /* first dequeue packets from ring of primary process */
450 const uint16_t nb_in_deq = rte_ring_dequeue_burst(ring,
451 (void *)rxtx_bufs, BURST_SIZE, NULL);
452 stats->dequeue_pkts += nb_in_deq;
455 /* then sent on vdev */
456 uint16_t nb_in_txd = rte_eth_tx_burst(
458 0, rxtx_bufs, nb_in_deq);
459 stats->tx_pkts += nb_in_txd;
461 if (unlikely(nb_in_txd < nb_in_deq)) {
463 rte_pktmbuf_free(rxtx_bufs[nb_in_txd]);
465 } while (++nb_in_txd < nb_in_deq);
471 free_ring_data(struct rte_ring *ring, uint16_t vdev_id,
472 struct pdump_stats *stats)
474 while (rte_ring_count(ring))
475 pdump_rxtx(ring, vdev_id, stats);
482 struct pdump_tuples *pt;
484 for (i = 0; i < num_tuples; i++) {
492 rte_ring_free(pt->rx_ring);
494 rte_ring_free(pt->tx_ring);
499 cleanup_pdump_resources(void)
502 struct pdump_tuples *pt;
503 char name[RTE_ETH_NAME_MAX_LEN];
505 /* disable pdump and free the pdump_tuple resources */
506 for (i = 0; i < num_tuples; i++) {
509 /* remove callbacks */
513 * transmit rest of the enqueued packets of the rings on to
514 * the vdev, in order to release mbufs to the mepool.
516 if (pt->dir & RTE_PDUMP_FLAG_RX)
517 free_ring_data(pt->rx_ring, pt->rx_vdev_id, &pt->stats);
518 if (pt->dir & RTE_PDUMP_FLAG_TX)
519 free_ring_data(pt->tx_ring, pt->tx_vdev_id, &pt->stats);
521 /* Remove the vdev(s) created */
522 if (pt->dir & RTE_PDUMP_FLAG_RX) {
523 rte_eth_dev_get_name_by_port(pt->rx_vdev_id, name);
524 rte_eal_hotplug_remove("vdev", name);
527 if (pt->single_pdump_dev)
530 if (pt->dir & RTE_PDUMP_FLAG_TX) {
531 rte_eth_dev_get_name_by_port(pt->tx_vdev_id, name);
532 rte_eal_hotplug_remove("vdev", name);
540 signal_handler(int sig_num)
542 if (sig_num == SIGINT) {
543 printf("\n\nSignal %d received, preparing to exit...\n",
550 configure_vdev(uint16_t port_id)
552 struct rte_ether_addr addr;
553 const uint16_t rxRings = 0, txRings = 1;
557 if (!rte_eth_dev_is_valid_port(port_id))
560 ret = rte_eth_dev_configure(port_id, rxRings, txRings,
563 rte_exit(EXIT_FAILURE, "dev config failed\n");
565 for (q = 0; q < txRings; q++) {
566 ret = rte_eth_tx_queue_setup(port_id, q, TX_DESC_PER_QUEUE,
567 rte_eth_dev_socket_id(port_id), NULL);
569 rte_exit(EXIT_FAILURE, "queue setup failed\n");
572 ret = rte_eth_dev_start(port_id);
574 rte_exit(EXIT_FAILURE, "dev start failed\n");
576 rte_eth_macaddr_get(port_id, &addr);
577 printf("Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
578 " %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
580 addr.addr_bytes[0], addr.addr_bytes[1],
581 addr.addr_bytes[2], addr.addr_bytes[3],
582 addr.addr_bytes[4], addr.addr_bytes[5]);
584 rte_eth_promiscuous_enable(port_id);
590 create_mp_ring_vdev(void)
594 struct pdump_tuples *pt = NULL;
595 struct rte_mempool *mbuf_pool = NULL;
596 char vdev_name[SIZE];
597 char vdev_args[SIZE];
598 char ring_name[SIZE];
599 char mempool_name[SIZE];
601 for (i = 0; i < num_tuples; i++) {
603 snprintf(mempool_name, SIZE, MP_NAME, i);
604 mbuf_pool = rte_mempool_lookup(mempool_name);
605 if (mbuf_pool == NULL) {
607 mbuf_pool = rte_pktmbuf_pool_create(mempool_name,
609 MBUF_POOL_CACHE_SIZE, 0,
612 if (mbuf_pool == NULL) {
614 rte_exit(EXIT_FAILURE,
615 "Mempool creation failed: %s\n",
616 rte_strerror(rte_errno));
621 if (pt->dir == RTE_PDUMP_FLAG_RXTX) {
622 /* if captured packets has to send to the same vdev */
624 snprintf(ring_name, SIZE, RX_RING, i);
625 pt->rx_ring = rte_ring_create(ring_name, pt->ring_size,
627 if (pt->rx_ring == NULL) {
629 rte_exit(EXIT_FAILURE, "%s:%s:%d\n",
630 rte_strerror(rte_errno),
635 snprintf(ring_name, SIZE, TX_RING, i);
636 pt->tx_ring = rte_ring_create(ring_name, pt->ring_size,
638 if (pt->tx_ring == NULL) {
640 rte_exit(EXIT_FAILURE, "%s:%s:%d\n",
641 rte_strerror(rte_errno),
646 snprintf(vdev_name, sizeof(vdev_name),
647 VDEV_NAME_FMT, RX_STR, i);
648 (pt->rx_vdev_stream_type == IFACE) ?
649 snprintf(vdev_args, sizeof(vdev_args),
650 VDEV_IFACE_ARGS_FMT, pt->rx_dev) :
651 snprintf(vdev_args, sizeof(vdev_args),
652 VDEV_PCAP_ARGS_FMT, pt->rx_dev);
653 if (rte_eal_hotplug_add("vdev", vdev_name,
656 rte_exit(EXIT_FAILURE,
657 "vdev creation failed:%s:%d\n",
660 if (rte_eth_dev_get_port_by_name(vdev_name,
662 rte_eal_hotplug_remove("vdev", vdev_name);
664 rte_exit(EXIT_FAILURE,
665 "cannot find added vdev %s:%s:%d\n",
666 vdev_name, __func__, __LINE__);
668 pt->rx_vdev_id = portid;
671 configure_vdev(pt->rx_vdev_id);
673 if (pt->single_pdump_dev)
674 pt->tx_vdev_id = portid;
676 snprintf(vdev_name, sizeof(vdev_name),
677 VDEV_NAME_FMT, TX_STR, i);
678 (pt->rx_vdev_stream_type == IFACE) ?
679 snprintf(vdev_args, sizeof(vdev_args),
680 VDEV_IFACE_ARGS_FMT, pt->tx_dev) :
681 snprintf(vdev_args, sizeof(vdev_args),
682 VDEV_PCAP_ARGS_FMT, pt->tx_dev);
683 if (rte_eal_hotplug_add("vdev", vdev_name,
686 rte_exit(EXIT_FAILURE,
687 "vdev creation failed:"
688 "%s:%d\n", __func__, __LINE__);
690 if (rte_eth_dev_get_port_by_name(vdev_name,
692 rte_eal_hotplug_remove("vdev",
695 rte_exit(EXIT_FAILURE,
696 "cannot find added vdev %s:%s:%d\n",
697 vdev_name, __func__, __LINE__);
699 pt->tx_vdev_id = portid;
702 configure_vdev(pt->tx_vdev_id);
704 } else if (pt->dir == RTE_PDUMP_FLAG_RX) {
707 snprintf(ring_name, SIZE, RX_RING, i);
708 pt->rx_ring = rte_ring_create(ring_name, pt->ring_size,
710 if (pt->rx_ring == NULL) {
712 rte_exit(EXIT_FAILURE, "%s\n",
713 rte_strerror(rte_errno));
716 snprintf(vdev_name, sizeof(vdev_name),
717 VDEV_NAME_FMT, RX_STR, i);
718 (pt->rx_vdev_stream_type == IFACE) ?
719 snprintf(vdev_args, sizeof(vdev_args),
720 VDEV_IFACE_ARGS_FMT, pt->rx_dev) :
721 snprintf(vdev_args, sizeof(vdev_args),
722 VDEV_PCAP_ARGS_FMT, pt->rx_dev);
723 if (rte_eal_hotplug_add("vdev", vdev_name,
726 rte_exit(EXIT_FAILURE,
727 "vdev creation failed:%s:%d\n",
730 if (rte_eth_dev_get_port_by_name(vdev_name,
732 rte_eal_hotplug_remove("vdev", vdev_name);
734 rte_exit(EXIT_FAILURE,
735 "cannot find added vdev %s:%s:%d\n",
736 vdev_name, __func__, __LINE__);
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 snprintf(vdev_name, sizeof(vdev_name),
754 VDEV_NAME_FMT, TX_STR, i);
755 (pt->tx_vdev_stream_type == IFACE) ?
756 snprintf(vdev_args, sizeof(vdev_args),
757 VDEV_IFACE_ARGS_FMT, pt->tx_dev) :
758 snprintf(vdev_args, sizeof(vdev_args),
759 VDEV_PCAP_ARGS_FMT, pt->tx_dev);
760 if (rte_eal_hotplug_add("vdev", vdev_name,
763 rte_exit(EXIT_FAILURE,
764 "vdev creation failed\n");
766 if (rte_eth_dev_get_port_by_name(vdev_name,
768 rte_eal_hotplug_remove("vdev", vdev_name);
770 rte_exit(EXIT_FAILURE,
771 "cannot find added vdev %s:%s:%d\n",
772 vdev_name, __func__, __LINE__);
774 pt->tx_vdev_id = portid;
777 configure_vdev(pt->tx_vdev_id);
786 struct pdump_tuples *pt;
787 int ret = 0, ret1 = 0;
789 for (i = 0; i < num_tuples; i++) {
791 if (pt->dir == RTE_PDUMP_FLAG_RXTX) {
792 if (pt->dump_by_type == DEVICE_ID) {
793 ret = rte_pdump_enable_by_deviceid(
799 ret1 = rte_pdump_enable_by_deviceid(
805 } else if (pt->dump_by_type == PORT_ID) {
806 ret = rte_pdump_enable(pt->port, pt->queue,
808 pt->rx_ring, pt->mp, NULL);
809 ret1 = rte_pdump_enable(pt->port, pt->queue,
811 pt->tx_ring, pt->mp, NULL);
813 } else if (pt->dir == RTE_PDUMP_FLAG_RX) {
814 if (pt->dump_by_type == DEVICE_ID)
815 ret = rte_pdump_enable_by_deviceid(
818 pt->dir, pt->rx_ring,
820 else if (pt->dump_by_type == PORT_ID)
821 ret = rte_pdump_enable(pt->port, pt->queue,
823 pt->rx_ring, pt->mp, NULL);
824 } else if (pt->dir == RTE_PDUMP_FLAG_TX) {
825 if (pt->dump_by_type == DEVICE_ID)
826 ret = rte_pdump_enable_by_deviceid(
830 pt->tx_ring, pt->mp, NULL);
831 else if (pt->dump_by_type == PORT_ID)
832 ret = rte_pdump_enable(pt->port, pt->queue,
834 pt->tx_ring, pt->mp, NULL);
836 if (ret < 0 || ret1 < 0) {
837 cleanup_pdump_resources();
838 rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno));
844 pdump_packets(struct pdump_tuples *pt)
846 if (pt->dir & RTE_PDUMP_FLAG_RX)
847 pdump_rxtx(pt->rx_ring, pt->rx_vdev_id, &pt->stats);
848 if (pt->dir & RTE_PDUMP_FLAG_TX)
849 pdump_rxtx(pt->tx_ring, pt->tx_vdev_id, &pt->stats);
853 dump_packets_core(void *arg)
855 struct pdump_tuples *pt = (struct pdump_tuples *) arg;
857 printf(" core (%u); port %u device (%s) queue %u\n",
858 rte_lcore_id(), pt->port, pt->device_id, pt->queue);
871 uint32_t lcore_id = 0;
873 if (!multiple_core_capture) {
874 printf(" core (%u), capture for (%d) tuples\n",
875 rte_lcore_id(), num_tuples);
877 for (i = 0; i < num_tuples; i++)
878 printf(" - port %u device (%s) queue %u\n",
880 pdump_t[i].device_id,
883 while (!quit_signal) {
884 for (i = 0; i < num_tuples; i++)
885 pdump_packets(&pdump_t[i]);
891 /* check if there enough core */
892 if ((uint32_t)num_tuples >= rte_lcore_count()) {
893 printf("Insufficient cores to run parallel!\n");
897 lcore_id = rte_get_next_lcore(lcore_id, 1, 0);
899 for (i = 0; i < num_tuples; i++) {
900 rte_eal_remote_launch(dump_packets_core,
901 &pdump_t[i], lcore_id);
902 lcore_id = rte_get_next_lcore(lcore_id, 1, 0);
904 if (rte_eal_wait_lcore(lcore_id) < 0)
905 rte_exit(EXIT_FAILURE, "failed to wait\n");
914 main(int argc, char **argv)
920 char n_flag[] = "-n4";
921 char mp_flag[] = "--proc-type=secondary";
922 char *argp[argc + 2];
924 /* catch ctrl-c so we can print on exit */
925 signal(SIGINT, signal_handler);
931 for (i = 1; i < argc; i++)
932 argp[i + 2] = argv[i];
936 diag = rte_eal_init(argc, argp);
938 rte_panic("Cannot init EAL\n");
940 if (rte_eth_dev_count_avail() == 0)
941 rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
946 /* parse app arguments */
948 ret = launch_args_parse(argc, argv, argp[0]);
950 rte_exit(EXIT_FAILURE, "Invalid argument\n");
953 /* create mempool, ring and vdevs info */
954 create_mp_ring_vdev();
958 cleanup_pdump_resources();
959 /* dump debug stats */
962 ret = rte_eal_cleanup();
964 printf("Error from rte_eal_cleanup(), %d\n", ret);