From patchwork Tue Jul 28 19:13:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 74962 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DDA91A052B; Tue, 28 Jul 2020 21:14:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 39A781C0CE; Tue, 28 Jul 2020 21:14:03 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id 543F71C0B4 for ; Tue, 28 Jul 2020 21:13:54 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id q17so10429609pls.9 for ; Tue, 28 Jul 2020 12:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xcX9eNGEAnm0RHIiNky2usP0Kr61Z7Vlgzqb1yCT9/E=; b=FGwin6pwbA+wE2vb0h9Gpchm7VDsEd3GSqzT7dFLb6eSc+WxK4Pv54jCpVoVYZkUrZ VrJq4pJUoj8KuSEUy5I5fLNYaRRF/jjfmpj9joPejS/cPCZ+fD0GVeroMyrhnya9bY/g qWyNMBWX45gCTHW600W3qIwN5H6prNPgVe1/AA/0Bqj1/mPy/751+qsywHDv62ZuXWjH lvioOefpYNrlIjbsz4FSctgyUBrdkcR76aA+c+N1mWDrnHT2THUkES1AqOzNqLInnZxo mq8TxssZ/LyrlP8z5DDH9cxfbMyzMnwawzUKcFFcoYG8C/gbZo4skLbB2o94/fu+F8RP 7yWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xcX9eNGEAnm0RHIiNky2usP0Kr61Z7Vlgzqb1yCT9/E=; b=XFzzWMZJDSf3gd3uWKrMrGkhpkuzhoTlYQB2PPLM+UdBfdVatmSdaYGKdNwgdFeXhF sQ6x33wjjaMvh4oiAqYk/v/avql0R1XeShztXEyunkep7UIMMOFEMlZCjuSrCMyYMDuN 76SztF62AV+C/zyKejXOZ7Yq2tmJPVyQk+/VXB+/vYwYlvlqMbHsv8MyJVh9PdEjDpDc 8V+KdJvPH740Yj7G4uIJouwWh9yHc4wP02NIpjt3L+0WOxAz7LNwwpfbt4hbmxwMvZjl sUrwAtNJWsLOjmfOu5M9nI/FAb8kwG7Wq0IzVfDkH0sylhwTDuKl6k0W5LSn4rTU8+X+ uPuA== X-Gm-Message-State: AOAM530Hdk4DovumaGQZBjYuFEnFNqZ7uHugCHebEA4R8UqtyhG8Szml omTeK5w12tAw9u1Z3/OqXhDpRGAqRoDI8w== X-Google-Smtp-Source: ABdhPJwI9Yio+xq/1Awfu48Qd48P2eFHZYDNZ59Fz/pKJnQZCu6CTDJWRmfCmkaTHtFGsdxMhXZRSw== X-Received: by 2002:a17:902:6b43:: with SMTP id g3mr18997469plt.303.1595963632991; Tue, 28 Jul 2020 12:13:52 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id x66sm19045748pgb.12.2020.07.28.12.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 12:13:52 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Hemant Agrawal Date: Tue, 28 Jul 2020 12:13:30 -0700 Message-Id: <20200728191330.20864-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200728191330.20864-1-stephen@networkplumber.org> References: <20200506193741.24117-1-stephen@networkplumber.org> <20200728191330.20864-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 8/8] app/proc-info: provide way to request info on owned ports 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" 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 Acked-by: Hemant Agrawal --- app/proc-info/main.c | 92 ++++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 38 deletions(-) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index 282af670d20a..f78cc0f59c74 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -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,19 +695,27 @@ 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)); @@ -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", @@ -1412,28 +1418,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 */