From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 579934CC3 for ; Thu, 28 Mar 2019 16:03:53 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2019 08:03:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,280,1549958400"; d="scan'208";a="218427915" Received: from unknown (HELO saesrv02-S2600CWR.intel.com) ([10.224.122.203]) by orsmga001.jf.intel.com with ESMTP; 28 Mar 2019 08:03:48 -0700 From: Vipin Varghese To: dev@dpdk.org, marko.kovacevic@intel.com, reshma.pattan@intel.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, 28 Mar 2019 20:34:06 +0530 Message-Id: <20190328150406.12051-1-vipin.varghese@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190328145746.11786-1-vipin.varghese@intel.com> References: <20190328145746.11786-1-vipin.varghese@intel.com> Subject: [dpdk-dev] [PATCH v3] 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, 28 Mar 2019 15:03:53 -0000 Enhance pdump application, to allow user to run on multiple cores. Signed-off-by: Vipin Varghese --- Change Log: V3: - correct the parse_usage - Vipin Varghese - add change log - Vipin Varghese V2: - Replace option '-c' to '-l' - Keith Wiles --- app/pdump/main.c | 75 ++++++++++++++++++++++++++++++++------ doc/guides/tools/pdump.rst | 5 +++ 2 files changed, 69 insertions(+), 11 deletions(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index ccf2a1d2f..a2e092420 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -62,6 +62,7 @@ #define SIZE 256 #define BURST_SIZE 32 #define NUM_VDEVS 2 +#define CORES_STR_SIZE 32 /* true if x is a power of 2 */ #define POWEROF2(x) ((((x)-1) & (x)) == 0) @@ -144,7 +145,7 @@ static volatile uint8_t quit_signal; static void pdump_usage(const char *prgname) { - printf("usage: %s [EAL options] -- --pdump " + printf("usage: %s [EAL options] -- [-l ] --pdump " "'(port= | device_id=)," "(queue=)," "(rx-dev= |" @@ -415,6 +416,7 @@ print_pdump_stats(void) for (i = 0; i < num_tuples; i++) { printf("##### PDUMP DEBUG STATS #####\n"); pt = &pdump_t[i]; + printf(" == DPDK interface (%d) ==\n", i); printf(" -packets dequeued: %"PRIu64"\n", pt->stats.dequeue_pkts); printf(" -packets transmitted to vdev: %"PRIu64"\n", @@ -834,22 +836,62 @@ 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; + + 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; + + lcore_id = rte_get_next_lcore(lcore_id, 1, 1); + + if (rte_lcore_count() == 1) { + while (!quit_signal) { + for (i = 0; i < num_tuples; i++) { + struct pdump_tuples *pt = &pdump_t[i]; + pdump_packets(pt); + } + } + } else { + printf(" Tuples (%u) lcores (%u)\n", + num_tuples, rte_lcore_count()); + + if ((uint32_t)num_tuples >= rte_lcore_count()) { + printf("Insufficent Cores\n"); + return; + } - 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); + /* use remote launch for n interfaces */ + rte_eal_remote_launch(dump_packets_core, + &pdump_t[i], lcore_id); + lcore_id = rte_get_next_lcore(lcore_id, 0, 1); + + if (rte_eal_wait_lcore(lcore_id) < 0) + rte_exit(EXIT_FAILURE, "failed to wait\n"); } + + while (!quit_signal) + ; } } @@ -860,7 +902,7 @@ main(int argc, char **argv) int ret; int i; - char c_flag[] = "-c1"; + char c_flag[CORES_STR_SIZE] = "-c1"; char n_flag[] = "-n4"; char mp_flag[] = "--proc-type=secondary"; char *argp[argc + 3]; @@ -868,6 +910,17 @@ main(int argc, char **argv) /* catch ctrl-c so we can print on exit */ signal(SIGINT, signal_handler); + for (i = 0; i < argc; i++) { + if (strstr(argv[i], "-l")) { + snprintf(c_flag, RTE_DIM(c_flag), "-l %s", argv[i+1]); + strlcpy(argv[i], "", 2); + strlcpy(argv[i + 1], "", 2); + break; + } + } + + printf(" c_flag %s", c_flag); + argp[0] = argv[0]; argp[1] = c_flag; argp[2] = n_flag; diff --git a/doc/guides/tools/pdump.rst b/doc/guides/tools/pdump.rst index 7c2b73e72..3cfd9fc44 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 -- + [-l ] --pdump '(port= | device_id=), (queue=), (rx-dev= | @@ -43,6 +44,9 @@ The tool has a number of command line options: [mbuf-size=], [total-num-mbufs=]' +The ``-l`` command line option is optional and it takes list cores on which +capture for each ``--pdump`` is to be run. + The ``--pdump`` command line option is mandatory and it takes various sub arguments which are described in below section. @@ -113,3 +117,4 @@ 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,4,5 --pdump 'port=0,queue=*,rx-dev=/tmp/rx.pcap' --pdump 'port=1,queue=*,tx-dev=/tmp/tx.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 9655DA0679 for ; Thu, 28 Mar 2019 16:03:55 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 73F4B1B2AE; Thu, 28 Mar 2019 16:03:54 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 579934CC3 for ; Thu, 28 Mar 2019 16:03:53 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2019 08:03:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,280,1549958400"; d="scan'208";a="218427915" Received: from unknown (HELO saesrv02-S2600CWR.intel.com) ([10.224.122.203]) by orsmga001.jf.intel.com with ESMTP; 28 Mar 2019 08:03:48 -0700 From: Vipin Varghese To: dev@dpdk.org, marko.kovacevic@intel.com, reshma.pattan@intel.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, 28 Mar 2019 20:34:06 +0530 Message-Id: <20190328150406.12051-1-vipin.varghese@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190328145746.11786-1-vipin.varghese@intel.com> References: <20190328145746.11786-1-vipin.varghese@intel.com> Subject: [dpdk-dev] [PATCH v3] 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: <20190328150406.Tftqbn9OkJscujxjbbKmeD-Zuwkby96nsHzxaNOrZw8@z> Enhance pdump application, to allow user to run on multiple cores. Signed-off-by: Vipin Varghese --- Change Log: V3: - correct the parse_usage - Vipin Varghese - add change log - Vipin Varghese V2: - Replace option '-c' to '-l' - Keith Wiles --- app/pdump/main.c | 75 ++++++++++++++++++++++++++++++++------ doc/guides/tools/pdump.rst | 5 +++ 2 files changed, 69 insertions(+), 11 deletions(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index ccf2a1d2f..a2e092420 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -62,6 +62,7 @@ #define SIZE 256 #define BURST_SIZE 32 #define NUM_VDEVS 2 +#define CORES_STR_SIZE 32 /* true if x is a power of 2 */ #define POWEROF2(x) ((((x)-1) & (x)) == 0) @@ -144,7 +145,7 @@ static volatile uint8_t quit_signal; static void pdump_usage(const char *prgname) { - printf("usage: %s [EAL options] -- --pdump " + printf("usage: %s [EAL options] -- [-l ] --pdump " "'(port= | device_id=)," "(queue=)," "(rx-dev= |" @@ -415,6 +416,7 @@ print_pdump_stats(void) for (i = 0; i < num_tuples; i++) { printf("##### PDUMP DEBUG STATS #####\n"); pt = &pdump_t[i]; + printf(" == DPDK interface (%d) ==\n", i); printf(" -packets dequeued: %"PRIu64"\n", pt->stats.dequeue_pkts); printf(" -packets transmitted to vdev: %"PRIu64"\n", @@ -834,22 +836,62 @@ 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; + + 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; + + lcore_id = rte_get_next_lcore(lcore_id, 1, 1); + + if (rte_lcore_count() == 1) { + while (!quit_signal) { + for (i = 0; i < num_tuples; i++) { + struct pdump_tuples *pt = &pdump_t[i]; + pdump_packets(pt); + } + } + } else { + printf(" Tuples (%u) lcores (%u)\n", + num_tuples, rte_lcore_count()); + + if ((uint32_t)num_tuples >= rte_lcore_count()) { + printf("Insufficent Cores\n"); + return; + } - 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); + /* use remote launch for n interfaces */ + rte_eal_remote_launch(dump_packets_core, + &pdump_t[i], lcore_id); + lcore_id = rte_get_next_lcore(lcore_id, 0, 1); + + if (rte_eal_wait_lcore(lcore_id) < 0) + rte_exit(EXIT_FAILURE, "failed to wait\n"); } + + while (!quit_signal) + ; } } @@ -860,7 +902,7 @@ main(int argc, char **argv) int ret; int i; - char c_flag[] = "-c1"; + char c_flag[CORES_STR_SIZE] = "-c1"; char n_flag[] = "-n4"; char mp_flag[] = "--proc-type=secondary"; char *argp[argc + 3]; @@ -868,6 +910,17 @@ main(int argc, char **argv) /* catch ctrl-c so we can print on exit */ signal(SIGINT, signal_handler); + for (i = 0; i < argc; i++) { + if (strstr(argv[i], "-l")) { + snprintf(c_flag, RTE_DIM(c_flag), "-l %s", argv[i+1]); + strlcpy(argv[i], "", 2); + strlcpy(argv[i + 1], "", 2); + break; + } + } + + printf(" c_flag %s", c_flag); + argp[0] = argv[0]; argp[1] = c_flag; argp[2] = n_flag; diff --git a/doc/guides/tools/pdump.rst b/doc/guides/tools/pdump.rst index 7c2b73e72..3cfd9fc44 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 -- + [-l ] --pdump '(port= | device_id=), (queue=), (rx-dev= | @@ -43,6 +44,9 @@ The tool has a number of command line options: [mbuf-size=], [total-num-mbufs=]' +The ``-l`` command line option is optional and it takes list cores on which +capture for each ``--pdump`` is to be run. + The ``--pdump`` command line option is mandatory and it takes various sub arguments which are described in below section. @@ -113,3 +117,4 @@ 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,4,5 --pdump 'port=0,queue=*,rx-dev=/tmp/rx.pcap' --pdump 'port=1,queue=*,tx-dev=/tmp/tx.pcap' -- 2.17.1