summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorVipin Varghese <vipin.varghese@intel.com>2019-04-04 14:25:15 +0530
committerThomas Monjalon <thomas@monjalon.net>2019-04-22 21:45:16 +0200
commitb2854d5317e834afe22e71412befe95b63aded4b (patch)
tree878a8f2166e399de8b738295787aae01e5018f1e /app
parente442df31121abae2b11410ac89e24cac4fe9c4f2 (diff)
downloaddpdk-b2854d5317e834afe22e71412befe95b63aded4b.zip
dpdk-b2854d5317e834afe22e71412befe95b63aded4b.tar.gz
dpdk-b2854d5317e834afe22e71412befe95b63aded4b.tar.xz
app/pdump: support multi-core capture
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 <vipin.varghese@intel.com> Acked-by: Reshma Pattan <reshma.pattan@intel.com>
Diffstat (limited to 'app')
-rw-r--r--app/pdump/main.c99
1 files changed, 78 insertions, 21 deletions
diff --git a/app/pdump/main.c b/app/pdump/main.c
index 950f434..3d20854 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -28,6 +28,9 @@
#include <rte_pdump.h>
#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=<port id> | device_id=<pci id or vdev name>),"
"(queue=<queue_id>),"
"(rx-dev=<iface or pcap file> |"
@@ -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;
@@ -835,22 +841,73 @@ 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