From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 1A9BE5F29 for ; Thu, 4 Apr 2019 10:54:58 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2019 01:54:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,306,1549958400"; d="scan'208";a="146518239" Received: from unknown (HELO saesrv02-S2600CWR.intel.com) ([10.224.122.203]) by FMSMGA003.fm.intel.com with ESMTP; 04 Apr 2019 01:54:55 -0700 From: Vipin Varghese To: dev@dpdk.org, marko.kovacevic@intel.com, reshma.pattan@intel.com, david.marchand@redhat.com Cc: keith.wiles@intel.com, john.mcnamara@intel.com, stephen1.byrne@intel.com, amit.tamboli@intel.com, sanjay.padubidri@intel.com, amol.patel@intel.com, Vipin Varghese Date: Thu, 4 Apr 2019 14:25:15 +0530 Message-Id: <20190404085515.15789-3-vipin.varghese@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190404085515.15789-1-vipin.varghese@intel.com> References: <20190402091836.35779-3-vipin.varghese@intel.com> <20190404085515.15789-1-vipin.varghese@intel.com> Subject: [dpdk-dev] [PATCH v6 2/2] app/pdump: enhance to support multi-core capture X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Apr 2019 08:55:00 -0000 Add option --multi, to enhance pdump application to allow capture on unique cores for each --pdump option. If option --multi is ignored the default capture occurs on single core for all --pdump options. Signed-off-by: Vipin Varghese --- app/pdump/main.c | 99 ++++++++++++++++++++++++++++++-------- doc/guides/tools/pdump.rst | 8 ++- 2 files changed, 85 insertions(+), 22 deletions(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index c1db2eb8d..ae2c01b7b 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -28,6 +28,9 @@ #include #define CMD_LINE_OPT_PDUMP "pdump" +#define CMD_LINE_OPT_PDUMP_NUM 256 +#define CMD_LINE_OPT_MULTI "multi" +#define CMD_LINE_OPT_MULTI_NUM 257 #define PDUMP_PORT_ARG "port" #define PDUMP_PCI_ARG "device_id" #define PDUMP_QUEUE_ARG "queue" @@ -139,12 +142,15 @@ struct parse_val { static int num_tuples; static struct rte_eth_conf port_conf_default; static volatile uint8_t quit_signal; +static uint8_t multiple_core_capture; /**< display usage */ static void pdump_usage(const char *prgname) { - printf("usage: %s [EAL options] -- --pdump " + printf("usage: %s [EAL options]" + " --["CMD_LINE_OPT_MULTI"]\n" + " --"CMD_LINE_OPT_PDUMP" " "'(port= | device_id=)," "(queue=)," "(rx-dev= |" @@ -375,7 +381,8 @@ launch_args_parse(int argc, char **argv, char *prgname) int opt, ret; int option_index; static struct option long_option[] = { - {"pdump", 1, 0, 0}, + {CMD_LINE_OPT_PDUMP, 1, 0, CMD_LINE_OPT_PDUMP_NUM}, + {CMD_LINE_OPT_MULTI, 0, 0, CMD_LINE_OPT_MULTI_NUM}, {NULL, 0, 0, 0} }; @@ -386,17 +393,16 @@ launch_args_parse(int argc, char **argv, char *prgname) while ((opt = getopt_long(argc, argv, " ", long_option, &option_index)) != EOF) { switch (opt) { - case 0: - if (!strncmp(long_option[option_index].name, - CMD_LINE_OPT_PDUMP, - sizeof(CMD_LINE_OPT_PDUMP))) { - ret = parse_pdump(optarg); - if (ret) { - pdump_usage(prgname); - return -1; - } + case CMD_LINE_OPT_PDUMP_NUM: + ret = parse_pdump(optarg); + if (ret) { + pdump_usage(prgname); + return -1; } break; + case CMD_LINE_OPT_MULTI_NUM: + multiple_core_capture = 1; + break; default: pdump_usage(prgname); return -1; @@ -834,23 +840,74 @@ enable_pdump(void) } } +static inline void +pdump_packets(struct pdump_tuples *pt) +{ + if (pt->dir & RTE_PDUMP_FLAG_RX) + pdump_rxtx(pt->rx_ring, pt->rx_vdev_id, &pt->stats); + if (pt->dir & RTE_PDUMP_FLAG_TX) + pdump_rxtx(pt->tx_ring, pt->tx_vdev_id, &pt->stats); +} + +static int +dump_packets_core(void *arg) +{ + struct pdump_tuples *pt = (struct pdump_tuples *) arg; + + printf(" core (%u); port %u device (%s) queue %u\n", + rte_lcore_id(), pt->port, pt->device_id, pt->queue); + fflush(stdout); + + while (!quit_signal) + pdump_packets(pt); + + return 0; +} + static inline void dump_packets(void) { int i; - struct pdump_tuples *pt; + uint32_t lcore_id = 0; + + if (!multiple_core_capture) { + printf(" core (%u), capture for (%d) tuples\n", + rte_lcore_id(), num_tuples); + + for (i = 0; i < num_tuples; i++) + printf(" - port %u device (%s) queue %u\n", + pdump_t[i].port, + pdump_t[i].device_id, + pdump_t[i].queue); - while (!quit_signal) { - for (i = 0; i < num_tuples; i++) { - pt = &pdump_t[i]; - if (pt->dir & RTE_PDUMP_FLAG_RX) - pdump_rxtx(pt->rx_ring, pt->rx_vdev_id, - &pt->stats); - if (pt->dir & RTE_PDUMP_FLAG_TX) - pdump_rxtx(pt->tx_ring, pt->tx_vdev_id, - &pt->stats); + while (!quit_signal) { + for (i = 0; i < num_tuples; i++) + pdump_packets(&pdump_t[i]); } + + return; + } + + /* check if there enough core */ + if ((uint32_t)num_tuples >= rte_lcore_count()) { + printf("Insufficient cores to run parallel!\n"); + return; } + + lcore_id = rte_get_next_lcore(lcore_id, 1, 0); + + for (i = 0; i < num_tuples; i++) { + rte_eal_remote_launch(dump_packets_core, + &pdump_t[i], lcore_id); + lcore_id = rte_get_next_lcore(lcore_id, 1, 0); + + if (rte_eal_wait_lcore(lcore_id) < 0) + rte_exit(EXIT_FAILURE, "failed to wait\n"); + } + + /* master core */ + while (!quit_signal) + ; } int diff --git a/doc/guides/tools/pdump.rst b/doc/guides/tools/pdump.rst index 7c2b73e72..53cd2b464 100644 --- a/doc/guides/tools/pdump.rst +++ b/doc/guides/tools/pdump.rst @@ -35,6 +35,7 @@ The tool has a number of command line options: .. code-block:: console ./build/app/dpdk-pdump -- + [--multi] --pdump '(port= | device_id=), (queue=), (rx-dev= | @@ -43,6 +44,10 @@ The tool has a number of command line options: [mbuf-size=], [total-num-mbufs=]' +The ``--multi`` command line option is optional argument. If passed, capture +will be running on unique cores for all ``--pdump`` options. If ignored, +capture will be running on single core for all ``--pdump`` options. + The ``--pdump`` command line option is mandatory and it takes various sub arguments which are described in below section. @@ -112,4 +117,5 @@ Example .. code-block:: console - $ sudo ./build/app/dpdk-pdump -- --pdump 'port=0,queue=*,rx-dev=/tmp/rx.pcap' + $ sudo ./build/app/dpdk-pdump -l 3 -- --pdump 'port=0,queue=*,rx-dev=/tmp/rx.pcap' + $ sudo ./build/app/dpdk-pdump -l 3,4,5 -- --multi --pdump 'port=0,queue=*,rx-dev=/tmp/rx-1.pcap' --pdump 'port=1,queue=*,rx-dev=/tmp/rx-2.pcap' -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 352E2A0679 for ; Thu, 4 Apr 2019 10:55:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D2AC25F2D; Thu, 4 Apr 2019 10:55:01 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 1A9BE5F29 for ; Thu, 4 Apr 2019 10:54:58 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2019 01:54:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,306,1549958400"; d="scan'208";a="146518239" Received: from unknown (HELO saesrv02-S2600CWR.intel.com) ([10.224.122.203]) by FMSMGA003.fm.intel.com with ESMTP; 04 Apr 2019 01:54:55 -0700 From: Vipin Varghese To: dev@dpdk.org, marko.kovacevic@intel.com, reshma.pattan@intel.com, david.marchand@redhat.com Cc: keith.wiles@intel.com, john.mcnamara@intel.com, stephen1.byrne@intel.com, amit.tamboli@intel.com, sanjay.padubidri@intel.com, amol.patel@intel.com, Vipin Varghese Date: Thu, 4 Apr 2019 14:25:15 +0530 Message-Id: <20190404085515.15789-3-vipin.varghese@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190404085515.15789-1-vipin.varghese@intel.com> References: <20190402091836.35779-3-vipin.varghese@intel.com> <20190404085515.15789-1-vipin.varghese@intel.com> Subject: [dpdk-dev] [PATCH v6 2/2] app/pdump: enhance to support multi-core capture X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190404085515.FQMozQ_65io59UUVNWo0HkeKLn0zIbP0xU0g0YI9bfk@z> Add option --multi, to enhance pdump application to allow capture on unique cores for each --pdump option. If option --multi is ignored the default capture occurs on single core for all --pdump options. Signed-off-by: Vipin Varghese --- app/pdump/main.c | 99 ++++++++++++++++++++++++++++++-------- doc/guides/tools/pdump.rst | 8 ++- 2 files changed, 85 insertions(+), 22 deletions(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index c1db2eb8d..ae2c01b7b 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -28,6 +28,9 @@ #include #define CMD_LINE_OPT_PDUMP "pdump" +#define CMD_LINE_OPT_PDUMP_NUM 256 +#define CMD_LINE_OPT_MULTI "multi" +#define CMD_LINE_OPT_MULTI_NUM 257 #define PDUMP_PORT_ARG "port" #define PDUMP_PCI_ARG "device_id" #define PDUMP_QUEUE_ARG "queue" @@ -139,12 +142,15 @@ struct parse_val { static int num_tuples; static struct rte_eth_conf port_conf_default; static volatile uint8_t quit_signal; +static uint8_t multiple_core_capture; /**< display usage */ static void pdump_usage(const char *prgname) { - printf("usage: %s [EAL options] -- --pdump " + printf("usage: %s [EAL options]" + " --["CMD_LINE_OPT_MULTI"]\n" + " --"CMD_LINE_OPT_PDUMP" " "'(port= | device_id=)," "(queue=)," "(rx-dev= |" @@ -375,7 +381,8 @@ launch_args_parse(int argc, char **argv, char *prgname) int opt, ret; int option_index; static struct option long_option[] = { - {"pdump", 1, 0, 0}, + {CMD_LINE_OPT_PDUMP, 1, 0, CMD_LINE_OPT_PDUMP_NUM}, + {CMD_LINE_OPT_MULTI, 0, 0, CMD_LINE_OPT_MULTI_NUM}, {NULL, 0, 0, 0} }; @@ -386,17 +393,16 @@ launch_args_parse(int argc, char **argv, char *prgname) while ((opt = getopt_long(argc, argv, " ", long_option, &option_index)) != EOF) { switch (opt) { - case 0: - if (!strncmp(long_option[option_index].name, - CMD_LINE_OPT_PDUMP, - sizeof(CMD_LINE_OPT_PDUMP))) { - ret = parse_pdump(optarg); - if (ret) { - pdump_usage(prgname); - return -1; - } + case CMD_LINE_OPT_PDUMP_NUM: + ret = parse_pdump(optarg); + if (ret) { + pdump_usage(prgname); + return -1; } break; + case CMD_LINE_OPT_MULTI_NUM: + multiple_core_capture = 1; + break; default: pdump_usage(prgname); return -1; @@ -834,23 +840,74 @@ enable_pdump(void) } } +static inline void +pdump_packets(struct pdump_tuples *pt) +{ + if (pt->dir & RTE_PDUMP_FLAG_RX) + pdump_rxtx(pt->rx_ring, pt->rx_vdev_id, &pt->stats); + if (pt->dir & RTE_PDUMP_FLAG_TX) + pdump_rxtx(pt->tx_ring, pt->tx_vdev_id, &pt->stats); +} + +static int +dump_packets_core(void *arg) +{ + struct pdump_tuples *pt = (struct pdump_tuples *) arg; + + printf(" core (%u); port %u device (%s) queue %u\n", + rte_lcore_id(), pt->port, pt->device_id, pt->queue); + fflush(stdout); + + while (!quit_signal) + pdump_packets(pt); + + return 0; +} + static inline void dump_packets(void) { int i; - struct pdump_tuples *pt; + uint32_t lcore_id = 0; + + if (!multiple_core_capture) { + printf(" core (%u), capture for (%d) tuples\n", + rte_lcore_id(), num_tuples); + + for (i = 0; i < num_tuples; i++) + printf(" - port %u device (%s) queue %u\n", + pdump_t[i].port, + pdump_t[i].device_id, + pdump_t[i].queue); - while (!quit_signal) { - for (i = 0; i < num_tuples; i++) { - pt = &pdump_t[i]; - if (pt->dir & RTE_PDUMP_FLAG_RX) - pdump_rxtx(pt->rx_ring, pt->rx_vdev_id, - &pt->stats); - if (pt->dir & RTE_PDUMP_FLAG_TX) - pdump_rxtx(pt->tx_ring, pt->tx_vdev_id, - &pt->stats); + while (!quit_signal) { + for (i = 0; i < num_tuples; i++) + pdump_packets(&pdump_t[i]); } + + return; + } + + /* check if there enough core */ + if ((uint32_t)num_tuples >= rte_lcore_count()) { + printf("Insufficient cores to run parallel!\n"); + return; } + + lcore_id = rte_get_next_lcore(lcore_id, 1, 0); + + for (i = 0; i < num_tuples; i++) { + rte_eal_remote_launch(dump_packets_core, + &pdump_t[i], lcore_id); + lcore_id = rte_get_next_lcore(lcore_id, 1, 0); + + if (rte_eal_wait_lcore(lcore_id) < 0) + rte_exit(EXIT_FAILURE, "failed to wait\n"); + } + + /* master core */ + while (!quit_signal) + ; } int diff --git a/doc/guides/tools/pdump.rst b/doc/guides/tools/pdump.rst index 7c2b73e72..53cd2b464 100644 --- a/doc/guides/tools/pdump.rst +++ b/doc/guides/tools/pdump.rst @@ -35,6 +35,7 @@ The tool has a number of command line options: .. code-block:: console ./build/app/dpdk-pdump -- + [--multi] --pdump '(port= | device_id=), (queue=), (rx-dev= | @@ -43,6 +44,10 @@ The tool has a number of command line options: [mbuf-size=], [total-num-mbufs=]' +The ``--multi`` command line option is optional argument. If passed, capture +will be running on unique cores for all ``--pdump`` options. If ignored, +capture will be running on single core for all ``--pdump`` options. + The ``--pdump`` command line option is mandatory and it takes various sub arguments which are described in below section. @@ -112,4 +117,5 @@ Example .. code-block:: console - $ sudo ./build/app/dpdk-pdump -- --pdump 'port=0,queue=*,rx-dev=/tmp/rx.pcap' + $ sudo ./build/app/dpdk-pdump -l 3 -- --pdump 'port=0,queue=*,rx-dev=/tmp/rx.pcap' + $ sudo ./build/app/dpdk-pdump -l 3,4,5 -- --multi --pdump 'port=0,queue=*,rx-dev=/tmp/rx-1.pcap' --pdump 'port=1,queue=*,rx-dev=/tmp/rx-2.pcap' -- 2.17.1