From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 39376A00C2; Sat, 9 Apr 2022 17:31:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B89AF4067E; Sat, 9 Apr 2022 17:31:01 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id E6DEE4067C for ; Sat, 9 Apr 2022 17:30:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649518260; x=1681054260; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=nZg4gE2El23ZySJlg4SPwJp7S52midbxyB275eGOkOQ=; b=hIqQbfIa7KAQKY+VGZa9WKR18JdVSH/XYI1+ko9XtOruHIyDwyxHybIb 4c5j/rcKrRAN0C6S8sfUeEIc8l3+GYF0O/KdDaOEWECE7AcghtHK6JqF8 jAYMWlqnZTvl3w9jQjXLSarF6s9/u+097EjrhRGP7rtirhjw99FYFvRtk ekimUrSIk7niSAcacgbjdZ12DqHU8Xs3CrY4YbynhQfMqrEI8H1vRMlLY rZHonrAoe5VD9Bn+vXDEahCd12UebwxqlLcDoxVveYrgnvpSXNaZLTILE zuVqXsDp6/J7KoSXMo12jth3HylvnJiUGPj69afSnDQTjUDMfOB6xVtdJ g==; X-IronPort-AV: E=McAfee;i="6400,9594,10312"; a="348252073" X-IronPort-AV: E=Sophos;i="5.90,248,1643702400"; d="scan'208";a="348252073" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2022 08:30:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,248,1643702400"; d="scan'208";a="698689084" Received: from txanpdk03.an.intel.com ([10.123.117.78]) by fmsmga001.fm.intel.com with ESMTP; 09 Apr 2022 08:30:58 -0700 From: Timothy McDaniel To: jerinj@marvell.com Cc: dev@dpdk.org Subject: [PATCH] app/eventdev_dump: introduce eventdev_dump application Date: Sat, 9 Apr 2022 10:30:56 -0500 Message-Id: <20220409153056.1010236-1-timothy.mcdaniel@intel.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The eventdev_dump application provides an easy way to query and display xstats and pmd dump data. It should work with all eventdevs. See the help usage for the full set of supported queries. Signed-off-by: Timothy McDaniel --- app/eventdev_dump/main.c | 284 ++++++++++++++++++++++++++++++++++ app/eventdev_dump/meson.build | 5 + app/meson.build | 1 + 3 files changed, 290 insertions(+) create mode 100644 app/eventdev_dump/main.c create mode 100644 app/eventdev_dump/meson.build diff --git a/app/eventdev_dump/main.c b/app/eventdev_dump/main.c new file mode 100644 index 0000000000..c80baa4c45 --- /dev/null +++ b/app/eventdev_dump/main.c @@ -0,0 +1,284 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018-2019 Intel Corporation + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* Note - port_queue_id in xstats APIs is 8 bits, so we have a maximum of + * 256 ports and queues + */ +#define MAX_PORTS_QUEUES 256 +int num_ports; +uint8_t ports[MAX_PORTS_QUEUES]; +int num_queues; +uint8_t queues[MAX_PORTS_QUEUES]; + +int evdev_id; +bool do_dump; +bool do_device_stats; +bool do_all_ports; +bool do_all_queues; +bool do_reset; + +/* No required options */ +static struct option long_options[] = { + {0, 0, 0, 0} +}; + +static void +usage(void) +{ + const char *usage_str = + "Usage: eventdev_dump [options]\n" + "Options:\n" + " -i Eventdev id, default is 0\n" + " -D Dump\n" + " -P Get port stats for all ports\n" + " -p Get port stats for specified port\n" + " -Q Get queue stats for all queues\n" + " -q Get queue stats for specified queue\n" + " -r Reset stats after reading them\n" + "\n"; + + printf("%s\n", usage_str); + exit(1); +} + +static void +parse_app_args(int argc, char **argv) +{ + /* Parse cli options*/ + int option_index; + int c; + opterr = 0; + + for (;;) { + c = getopt_long(argc, argv, "dDi:p:Pq:Qr", long_options, + &option_index); + if (c == -1) + break; + + switch (c) { + case 'd': + do_device_stats = true; + break; + case 'D': + do_dump = true; + break; + case 'i': + evdev_id = atoi(optarg); + break; + case 'p': + ports[num_ports] = atoi(optarg); + num_ports++; + break; + case 'P': + do_all_ports = true; + break; + case 'q': + queues[num_queues] = atoi(optarg); + num_queues++; + break; + case 'Q': + do_all_queues = true; + break; + case 'r': + do_reset = true; + break; + default: + usage(); + } + } +} + +static int +dump_all(int evdev_id) +{ + int ret = 0; + + ret = rte_event_dev_dump(evdev_id, stdout); + return ret; +} + +static void +get_stats(uint8_t dev_id, + enum rte_event_dev_xstats_mode mode, + uint8_t queue_port_id, + bool reset) +{ + int ret; + struct rte_event_dev_xstats_name *xstats_names; + unsigned int *ids; + unsigned int size; + int i; + + + /* Get amount of storage required */ + ret = rte_event_dev_xstats_names_get(dev_id, + mode, + queue_port_id, + NULL, /* names */ + NULL, /* ids */ + 0); /* num */ + + if (ret < 0) + rte_panic("rte_event_dev_xstats_names_get err %d\n", ret); + + if (ret == 0) { + printf( + "No stats available for this item, mode=%d, queue_port_id=%d\n", + mode, queue_port_id); + return; + } + + size = (unsigned int)ret; /* number of names */ + + /* Get memory to hold stat names, IDs, and values */ + + xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size); + ids = malloc(sizeof(unsigned int) * size); + + + if (!xstats_names || !ids) + rte_panic("unable to alloc memory for stats retrieval\n"); + + ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id, + xstats_names, ids, + size); + if (ret != (int)size) + rte_panic("rte_event_dev_xstats_names_get err %d\n", ret); + + if (!reset) { + uint64_t *values; + + values = malloc(sizeof(uint64_t) * size); + if (!values) + rte_panic("unable to alloc memory for stats retrieval\n"); + + ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id, + ids, values, size); + + if (ret != (int)size) + rte_panic("rte_event_dev_xstats_get err %d\n", ret); + + for (i = 0; i < (int)size; i++) { + printf("id (%u) %s = %"PRIu64"\n", + ids[i], &xstats_names[i].name[0], values[i]); + } + + free(values); + } else + rte_event_dev_xstats_reset(dev_id, mode, queue_port_id, + ids, size); + + free(xstats_names); + free(ids); +} + +static void +process_stats(bool reset) +{ + int i; + + if (do_device_stats) { + get_stats(evdev_id, + RTE_EVENT_DEV_XSTATS_DEVICE, + 0, + reset); + } + + if (do_all_ports) { + for (i = 0; i < MAX_PORTS_QUEUES; i++) { + get_stats(evdev_id, + RTE_EVENT_DEV_XSTATS_PORT, + i, + reset); + } + } else { + for (i = 0; i < num_ports; i++) { + get_stats(evdev_id, + RTE_EVENT_DEV_XSTATS_PORT, + ports[i], + reset); + } + } + + if (do_all_queues) { + for (i = 0; i < MAX_PORTS_QUEUES; i++) { + get_stats(evdev_id, + RTE_EVENT_DEV_XSTATS_QUEUE, + i, + reset); + } + } else { + for (i = 0; i < num_queues; i++) { + get_stats(evdev_id, + RTE_EVENT_DEV_XSTATS_QUEUE, + queues[i], + reset); + } + } +} + +int +main(int argc, char **argv) +{ + int diag; + int ret; + int i; + char c_flag[] = "-c1"; + char n_flag[] = "-n4"; + char mp_flag[] = "--proc-type=secondary"; + char *argp[argc + 3]; + + argp[0] = argv[0]; + argp[1] = c_flag; + argp[2] = n_flag; + argp[3] = mp_flag; + + for (i = 1; i < argc; i++) + argp[i + 3] = argv[i]; + + argc += 3; + + diag = rte_eal_init(argc, argp); + if (diag < 0) + rte_panic("Cannot init EAL\n"); + + argc -= diag; + argv += (diag - 3); + + /* Parse cli options*/ + parse_app_args(argc, argv); + + const uint8_t ndevs = rte_event_dev_count(); + if (ndevs == 0) + rte_panic("No event devs found. Do you need" + " to pass in a --vdev flag?\n"); + if (ndevs > 1) + printf("Warning: More than one event dev, but using idx 0\n"); + + if (do_dump) { + ret = dump_all(evdev_id); + if (ret) + rte_panic("dump failed with err=%d\n", ret); + } + + /* Get and output any stats requested on the command line */ + process_stats(false); + + /* Reset the stats we just output? */ + if (do_reset) + process_stats(true); + + return 0; +} diff --git a/app/eventdev_dump/meson.build b/app/eventdev_dump/meson.build new file mode 100644 index 0000000000..70d7db52d1 --- /dev/null +++ b/app/eventdev_dump/meson.build @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +sources = files('main.c') +deps += ['eventdev'] diff --git a/app/meson.build b/app/meson.build index 93d8c15032..06aecefca3 100644 --- a/app/meson.build +++ b/app/meson.build @@ -18,6 +18,7 @@ apps = [ 'test-pmd', 'test-regex', 'test-sad', + 'eventdev_dump', ] default_cflags = machine_args + ['-DALLOW_EXPERIMENTAL_API'] -- 2.25.1