From: Stephen Hemminger <stephen@networkplumber.org> To: dev@dpdk.org Cc: Stephen Hemminger <stephen@networkplumber.org>, Hemant Agrawal <hemant.agrawal@nxp.com> Subject: [dpdk-dev] [PATCH v4 8/8] app/proc-info: provide way to request info on owned ports Date: Tue, 21 Jul 2020 11:22:42 -0700 Message-ID: <20200721182242.5366-9-stephen@networkplumber.org> (raw) In-Reply-To: <20200721182242.5366-1-stephen@networkplumber.org> There are cases where a port maybe owned by another (failsafe, netvsc, bond); but currently proc-info has no way to look at stats of those ports. This patch provides way for the user to explicitly ask for these ports. If no portmask is given the output is unchanged; it only shows the top level ports. If portmask requests a specific port it will be shown even if owned. Increase the size of port mask variable to unsigned long to allow up to 64 ports to be handled on 64 bit architecture. The device owner is also a useful thing to show in port info. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com> --- app/proc-info/main.c | 94 ++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 39 deletions(-) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index aa074dc7c429..77a59bcefb9b 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -12,6 +12,7 @@ #include <stdlib.h> #include <getopt.h> #include <unistd.h> +#include <strings.h> #include <rte_eal.h> #include <rte_common.h> @@ -46,7 +47,7 @@ STATS_BDR_FMT, s, w, STATS_BDR_FMT) /**< mask of enabled ports */ -static uint32_t enabled_port_mask; +static unsigned long enabled_port_mask; /**< Enable stats. */ static uint32_t enable_stats; /**< Enable xstats. */ @@ -128,23 +129,17 @@ static int parse_portmask(const char *portmask) { char *end = NULL; - unsigned long pm; errno = 0; /* parse hexadecimal string */ - pm = strtoul(portmask, &end, 16); - if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0') || - (errno != 0)) { - printf("%s ERROR parsing the port mask\n", __func__); + enabled_port_mask = strtoul(portmask, &end, 16); + if (portmask[0] == '\0' || end == NULL || *end != '\0' || errno != 0) { + fprintf(stderr, "Invalid portmask '%s'\n", portmask); return -1; } - if (pm == 0) - return -1; - - return pm; - + return 0; } /* @@ -242,9 +237,7 @@ proc_info_parse_args(int argc, char **argv) switch (opt) { /* portmask */ case 'p': - enabled_port_mask = parse_portmask(optarg); - if (enabled_port_mask == 0) { - printf("invalid portmask\n"); + if (parse_portmask(optarg) < 0) { proc_info_usage(prgname); return -1; } @@ -702,20 +695,28 @@ show_security_context(uint16_t portid) static void show_port(void) { - uint16_t i = 0; - int ret = 0, j, k; + int i, ret, j, k; snprintf(bdr_str, MAX_STRING_LEN, " show - Port PMD "); STATS_BDR_STR(10, bdr_str); - - RTE_ETH_FOREACH_DEV(i) { + + for (i = 0; i < RTE_MAX_ETHPORTS; i++) { uint16_t mtu = 0; struct rte_eth_link link; struct rte_eth_dev_info dev_info; struct rte_eth_rss_conf rss_conf; struct rte_eth_fc_conf fc_conf; struct rte_ether_addr mac; + struct rte_eth_dev_owner owner; + /* Skip if port is not in mask */ + if ((enabled_port_mask & (1ul << i)) == 0) + continue; + + /* Skip if port is unused */ + if (!rte_eth_dev_is_valid_port(i)) + continue; + memset(&rss_conf, 0, sizeof(rss_conf)); snprintf(bdr_str, MAX_STRING_LEN, " Port %u ", i); @@ -733,6 +734,11 @@ show_port(void) dev_info.driver_name, dev_info.device->name, rte_eth_dev_socket_id(i)); + ret = rte_eth_dev_owner_get(i, &owner); + if (ret == 0 && owner.id != RTE_ETH_DEV_NO_OWNER) + printf("\t -- owner %#"PRIx64":%s\n", + owner.id, owner.name); + ret = rte_eth_link_get(i, &link); if (ret < 0) { printf("Link get failed (port %u): %s\n", @@ -1411,28 +1417,38 @@ main(int argc, char **argv) if (nb_ports == 0) rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n"); - /* If no port mask was specified*/ - if (enabled_port_mask == 0) - enabled_port_mask = 0xffff; + /* If no port mask was specified, then show non-owned ports */ + if (enabled_port_mask == 0) { + RTE_ETH_FOREACH_DEV(i) + enabled_port_mask = 1ul << i; + } + + for (i = 0; i < RTE_MAX_ETHPORTS; i++) { + + /* Skip if port is not in mask */ + if ((enabled_port_mask & (1ul << i)) == 0) + continue; + + /* Skip if port is unused */ + if (!rte_eth_dev_is_valid_port(i)) + continue; + + if (enable_stats) + nic_stats_display(i); + else if (enable_xstats) + nic_xstats_display(i); + else if (reset_stats) + nic_stats_clear(i); + else if (reset_xstats) + nic_xstats_clear(i); + else if (enable_xstats_name) + nic_xstats_by_name_display(i, xstats_name); + else if (nb_xstats_ids > 0) + nic_xstats_by_ids_display(i, xstats_ids, + nb_xstats_ids); + else if (enable_metrics) + metrics_display(i); - RTE_ETH_FOREACH_DEV(i) { - if (enabled_port_mask & (1 << i)) { - if (enable_stats) - nic_stats_display(i); - else if (enable_xstats) - nic_xstats_display(i); - else if (reset_stats) - nic_stats_clear(i); - else if (reset_xstats) - nic_xstats_clear(i); - else if (enable_xstats_name) - nic_xstats_by_name_display(i, xstats_name); - else if (nb_xstats_ids > 0) - nic_xstats_by_ids_display(i, xstats_ids, - nb_xstats_ids); - else if (enable_metrics) - metrics_display(i); - } } /* print port independent stats */ -- 2.27.0
next prev parent reply other threads:[~2020-07-21 18:24 UTC|newest] Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-06 19:37 [dpdk-dev] [PATCH 0/7] proc-info enhancements Stephen Hemminger 2020-05-06 19:37 ` [dpdk-dev] [PATCH 1/7] app/proc-info: remove unused logtype #define Stephen Hemminger 2020-05-06 19:37 ` [dpdk-dev] [PATCH 2/7] app/proc-info: eliminate useless borders Stephen Hemminger 2020-05-06 19:37 ` [dpdk-dev] [PATCH 3/7] app/proc-info: hide EAL info messages Stephen Hemminger 2020-05-06 19:37 ` [dpdk-dev] [PATCH 4/7] app/proc-info: add more info to show_ports Stephen Hemminger 2020-05-06 19:37 ` [dpdk-dev] [PATCH 5/7] app/proc-info: hide crypto-context display Stephen Hemminger 2020-05-06 19:37 ` [dpdk-dev] [PATCH 6/7] app/proc-info: dump rx and tx descriptor info Stephen Hemminger 2020-05-06 19:37 ` [dpdk-dev] [PATCH 7/7] app/proc-info: provide way to request info on owned ports Stephen Hemminger 2020-05-06 19:57 ` [dpdk-dev] [PATCH v2 0/7] app/proc-info enhancements Stephen Hemminger 2020-05-06 19:57 ` [dpdk-dev] [PATCH v2 1/7] app/proc-info: remove unused logtype #define Stephen Hemminger 2020-05-06 19:57 ` [dpdk-dev] [PATCH v2 2/7] app/proc-info: eliminate useless borders Stephen Hemminger 2020-05-06 19:57 ` [dpdk-dev] [PATCH v2 3/7] app/proc-info: hide EAL info messages Stephen Hemminger 2020-05-06 19:57 ` [dpdk-dev] [PATCH v2 4/7] app/proc-info: add more info to show_ports Stephen Hemminger 2020-07-13 12:09 ` Hemant Agrawal 2020-05-06 19:57 ` [dpdk-dev] [PATCH v2 5/7] app/proc-info: hide crypto-context display Stephen Hemminger 2020-05-06 19:57 ` [dpdk-dev] [PATCH v2 6/7] app/proc-info: dump rx and tx descriptor info Stephen Hemminger 2020-07-13 12:08 ` Hemant Agrawal 2020-05-06 19:57 ` [dpdk-dev] [PATCH v2 7/7] app/proc-info: provide way to request info on owned ports Stephen Hemminger 2020-07-13 12:10 ` [dpdk-dev] [PATCH v2 0/7] app/proc-info enhancements Hemant Agrawal 2020-07-15 21:22 ` [dpdk-dev] [PATCH v3 0/7] app/proc-info enhancments Stephen Hemminger 2020-07-15 21:22 ` [dpdk-dev] [PATCH v3 1/7] app/proc-info: remove unused logtype #define Stephen Hemminger 2020-07-15 21:22 ` [dpdk-dev] [PATCH v3 2/7] app/proc-info: eliminate useless borders Stephen Hemminger 2020-07-17 14:06 ` Thomas Monjalon 2020-08-13 4:10 ` Varghese, Vipin 2020-08-13 16:11 ` Stephen Hemminger 2020-08-14 0:45 ` Varghese, Vipin 2020-08-14 1:14 ` Varghese, Vipin 2020-08-14 3:18 ` Stephen Hemminger 2020-08-14 11:08 ` Varghese, Vipin 2020-08-14 14:56 ` Stephen Hemminger 2020-08-15 2:48 ` Varghese, Vipin 2020-07-15 21:22 ` [dpdk-dev] [PATCH v3 3/7] app/proc-info: hide EAL info messages Stephen Hemminger 2020-07-17 14:04 ` Thomas Monjalon 2020-07-15 21:22 ` [dpdk-dev] [PATCH v3 4/7] app/proc-info: add more info to show_ports Stephen Hemminger 2020-07-15 21:22 ` [dpdk-dev] [PATCH v3 5/7] app/proc-info: dump rx and tx descriptor info Stephen Hemminger 2020-07-15 21:22 ` [dpdk-dev] [PATCH v3 6/7] app/proc-info: provide way to request info on owned ports Stephen Hemminger 2020-07-17 15:01 ` Thomas Monjalon 2020-07-21 17:05 ` Stephen Hemminger 2020-07-21 17:08 ` Thomas Monjalon 2020-07-21 17:37 ` Stephen Hemminger 2020-07-15 21:22 ` [dpdk-dev] [PATCH v3 7/7] app/proc-info: add crypto security context info Stephen Hemminger 2020-07-21 18:22 ` [dpdk-dev] [PATCH v4 0/8] app/proc-info enhancements Stephen Hemminger 2020-07-21 18:22 ` [dpdk-dev] [PATCH v4 1/8] app/proc-info: remove unused logtype #define Stephen Hemminger 2020-07-21 18:22 ` [dpdk-dev] [PATCH v4 2/8] app/proc-info: eliminate useless borders Stephen Hemminger 2020-07-21 18:22 ` [dpdk-dev] [PATCH v4 3/8] app/proc-info: hide EAL info messages Stephen Hemminger 2020-07-21 18:22 ` [dpdk-dev] [PATCH v4 4/8] app/proc-info: add more info to show_ports Stephen Hemminger 2020-07-28 7:22 ` Hemant Agrawal (OSS) 2020-07-21 18:22 ` [dpdk-dev] [PATCH v4 5/8] app/proc-info: enhance mempool to print ops name Stephen Hemminger 2020-07-21 18:22 ` [dpdk-dev] [PATCH v4 6/8] app/proc-info: dump rx and tx descriptor info Stephen Hemminger 2020-07-21 18:22 ` [dpdk-dev] [PATCH v4 7/8] app/proc-info: add crypto security context info Stephen Hemminger 2020-07-21 18:22 ` Stephen Hemminger [this message] 2020-07-28 5:39 ` [dpdk-dev] [PATCH v4 8/8] app/proc-info: provide way to request info on owned ports Hemant Agrawal (OSS) 2020-07-28 5:45 ` Stephen Hemminger 2020-07-28 19:13 ` [dpdk-dev] [PATCH v5 0/8] app/proc-info enhancements Stephen Hemminger 2020-07-28 19:13 ` [dpdk-dev] [PATCH v5 1/8] app/proc-info: remove unused logtype #define Stephen Hemminger 2020-07-28 19:13 ` [dpdk-dev] [PATCH v5 2/8] app/proc-info: eliminate useless borders Stephen Hemminger 2020-07-28 19:13 ` [dpdk-dev] [PATCH v5 3/8] app/proc-info: hide EAL info messages Stephen Hemminger 2020-07-28 19:13 ` [dpdk-dev] [PATCH v5 4/8] app/proc-info: add more info to show_ports Stephen Hemminger 2020-07-28 19:13 ` [dpdk-dev] [PATCH v5 5/8] app/proc-info: enhance mempool to print ops name Stephen Hemminger 2020-07-28 19:13 ` [dpdk-dev] [PATCH v5 6/8] app/proc-info: dump rx and tx descriptor info Stephen Hemminger 2020-07-28 19:13 ` [dpdk-dev] [PATCH v5 7/8] app/proc-info: add crypto security context info Stephen Hemminger 2020-07-28 19:13 ` [dpdk-dev] [PATCH v5 8/8] app/proc-info: provide way to request info on owned ports Stephen Hemminger 2020-09-18 22:12 ` [dpdk-dev] [PATCH v5 0/8] app/proc-info enhancements Stephen Hemminger 2020-09-24 5:34 ` [dpdk-dev] [PATCH v6 0/7] app/proc-info: enhancements Stephen Hemminger 2020-09-24 5:34 ` [dpdk-dev] [PATCH v6 1/7] app/proc-info: remove unused logtype #define Stephen Hemminger 2020-09-24 5:34 ` [dpdk-dev] [PATCH v6 2/7] app/proc-info: eliminate useless borders Stephen Hemminger 2020-09-24 5:34 ` [dpdk-dev] [PATCH v6 3/7] app/proc-info: hide EAL info messages Stephen Hemminger 2020-09-24 5:34 ` [dpdk-dev] [PATCH v6 4/7] app/proc-info: add more info to show_ports Stephen Hemminger 2020-09-24 5:34 ` [dpdk-dev] [PATCH v6 5/7] app/proc-info: dump rx and tx descriptor info Stephen Hemminger 2020-09-24 5:34 ` [dpdk-dev] [PATCH v6 6/7] app/proc-info: add crypto security context info Stephen Hemminger 2020-09-24 5:34 ` [dpdk-dev] [PATCH v6 7/7] app/proc-info: provide way to request info on owned ports Stephen Hemminger 2020-10-19 22:39 ` [dpdk-dev] [PATCH v6 0/7] app/proc-info: enhancements Thomas Monjalon 2020-08-12 0:52 ` [dpdk-dev] [PATCH 0/7] proc-info enhancements Stephen Hemminger
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200721182242.5366-9-stephen@networkplumber.org \ --to=stephen@networkplumber.org \ --cc=dev@dpdk.org \ --cc=hemant.agrawal@nxp.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
DPDK patches and discussions This inbox may be cloned and mirrored by anyone: git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \ dev@dpdk.org public-inbox-index dev Example config snippet for mirrors. Newsgroup available over NNTP: nntp://inbox.dpdk.org/inbox.dpdk.dev AGPL code for this site: git clone https://public-inbox.org/public-inbox.git