From patchwork Wed May 6 19:57:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69883 X-Patchwork-Delegate: david.marchand@redhat.com 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 144FFA034E; Wed, 6 May 2020 21:59:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E622B1DB28; Wed, 6 May 2020 21:58:22 +0200 (CEST) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id E890A1C139 for ; Wed, 6 May 2020 21:58:18 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id b8so1301844pgi.11 for ; Wed, 06 May 2020 12:58:18 -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=qxe+EzPiQW2RnVv4y4fAIXpL6/fZATPmcIYSu2kTbaQ=; b=QFSNpVOV3qpC3IGNrgwEJaZhNW4e0ZEJYgD2Hj3CdPv4jp0sbXVt3a449ob3tTPB5O HMtZdKfRoKrQ6MS99oIZsxivPYeWPVpHyhmSbJDb7YpmRshOyVi6oQOMpbxZJI9m2LaO 9meq93YjfIEp1fAA25HemyT4DZlre95rPea+bXGt6ZGOv8Zl5iFHndbPymS4eti1vOHz l0M29zregzRHa9KVt0pXSCZxMb8jm4modwUNDdJaxomXO3ssOy8VtSkTPFSa5nYNrX4U N+FcZ9rFFvZCkWsAlJSpB3/a6OMYu3XOlJzfCyICvgmaZRgmFUEW2vAfPmZdnwvwKHgG uM+A== 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=qxe+EzPiQW2RnVv4y4fAIXpL6/fZATPmcIYSu2kTbaQ=; b=kp9yPlyN639k5oBsPq/yK8qPeQjfsUvxRzrP8w3YG1wgTaTgeju1SH8+yjkLIlajcF S0FP2vqy1v26M7cJfWHE9+9R4jQlNkDLZytvXj5CAyh6FppKMIpHdh+q4564aUGsZqp7 8viL0NkS8uvjda66hK+H1xZUJLuN4ITVYw1l96FZ6Dzg78mnFbwIzPCJkGmsvvrM/upI CaCxCu8ru6q74TnLZFe4JxoGtMple7AIC/KcHbnM9wuBcewYxAdXvuuAJqqih+nVxvnm V0gJfx05zn1TSCrAbFm4hy5QAdruGxLhEteaPHuvmv/hYdq12c8ocA0D347n3T30JgLP M1Mg== X-Gm-Message-State: AGi0PuZEvP1ex8Wia2gKUlho0Wq+FyGdf8tSjChcXHspK7AO0ucZvBlw SClLTtQYgPg/7nDyk9AaUSyh7drXwFOAMA== X-Google-Smtp-Source: APiQypJLMQFtlkAwy5E/hoYu0WckhGHhwiIxS20OD2Flz3d4sTv9jWkaYB7YIGoA8J93TsjpsvlAOQ== X-Received: by 2002:a62:a10c:: with SMTP id b12mr10504704pff.14.1588795097540; Wed, 06 May 2020 12:58:17 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id w1sm2126238pgh.53.2020.05.06.12.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 12:58:16 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Maryam Tahhan , Reshma Pattan Date: Wed, 6 May 2020 12:57:58 -0700 Message-Id: <20200506195758.27057-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200506195758.27057-1-stephen@networkplumber.org> References: <20200506193741.24117-1-stephen@networkplumber.org> <20200506195758.27057-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 7/7] 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. The device owner is also a useful thing to show in port info. Signed-off-by: Stephen Hemminger --- app/proc-info/Makefile | 3 ++ app/proc-info/main.c | 74 ++++++++++++++++++++++++++++-------------- 2 files changed, 53 insertions(+), 24 deletions(-) diff --git a/app/proc-info/Makefile b/app/proc-info/Makefile index 214f3f54a1e9..f777e037861f 100644 --- a/app/proc-info/Makefile +++ b/app/proc-info/Makefile @@ -5,7 +5,10 @@ include $(RTE_SDK)/mk/rte.vars.mk APP = dpdk-procinfo +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -Wno-deprecated-declarations # all source are stored in SRCS-y diff --git a/app/proc-info/main.c b/app/proc-info/main.c index 00e06c986e27..e0b61b366312 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -676,19 +677,26 @@ eth_tx_queue_available(uint16_t port_id, uint16_t queue_id, uint16_t n) static void show_port(void) { - uint16_t i = 0; - int ret = 0, j, k; + uint32_t port_mask = enabled_port_mask; + 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 (port_mask = enabled_port_mask; port_mask != 0; + port_mask &= ~(1u << 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; + + i = ffs(port_mask) - 1; + + if (!rte_eth_dev_is_valid_port(i)) + continue; memset(&rss_conf, 0, sizeof(rss_conf)); @@ -707,6 +715,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", @@ -1342,6 +1355,7 @@ main(int argc, char **argv) char log_flag[] = "--log-level=6"; char *argp[argc + 4]; uint16_t nb_ports; + uint32_t port_mask; /* preparse app arguments */ ret = proc_info_preparse_args(argc, argv); @@ -1385,30 +1399,42 @@ 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; - - 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); + /* If no port mask was specified, one will be provided */ + if (enabled_port_mask == 0) { + RTE_ETH_FOREACH_DEV(i) { + enabled_port_mask |= 1u << i; } } + for (port_mask = enabled_port_mask; port_mask != 0; + port_mask &= ~(1u << i)) { + /* ffs() first bit is 1 not 0 */ + i = ffs(port_mask) - 1; + + if (i >= RTE_MAX_ETHPORTS) + break; + + 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); + + } + /* print port independent stats */ if (enable_metrics) metrics_display(RTE_METRICS_GLOBAL);