From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AA2CAA04B1; Thu, 24 Sep 2020 07:35:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 180D31DD71; Thu, 24 Sep 2020 07:34:58 +0200 (CEST) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id D919C1DD56 for ; Thu, 24 Sep 2020 07:34:50 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id b124so1161523pfg.13 for ; Wed, 23 Sep 2020 22:34:50 -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=saEJf9aDDP8G1rcyLHugLFE2Yje+nPwZEKkPL359VRQ=; b=rbXRYPuLaXBpmLh0zi27wdgxSScCutFx5g6YOybw7R4YBft8oS9RSoRSf9EnRKBz41 wwiHLw3RPzmOqfu7WbJaAUsi7DS48bWlHtdL64snGUnM1h4QU10ByA1nhXEnvTX0zWAr jKH9g1gUXL1dSCz0d6BQGw453xBfp7jE4vOG99kv93pNHPSFA6ySPgClwjyqehjIhBaJ CaPy8DzfxAVV6twA6QVpO56Kzq+QLUa+v25k08j4nBWpb+a0KJrKCC8SzuLzRg6CUNd0 e5EnloMId/zO3X6GvDVpJZt377o5KJs2kSyE1hW3t7rByUYScadoDBswSfqsB74u/gvo qo5Q== 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=saEJf9aDDP8G1rcyLHugLFE2Yje+nPwZEKkPL359VRQ=; b=H+V433BnsSGh8DGe5WjiAHRBN3VCkewxldLhIopbUxod6gJPhZHPU+1kOrlj2aL6Km exXr15TWvL1zRRORCBlharqc52/nck3GDwvUN2ZOh9RoQnLDPhe+ZgPPMCKLUDTdu9Na kYrRbTGdYdwhQ7Hs4ysOES4jgPxLl9neiXDaeFOA79+autx+PytRan/8LYzNykGmqvlq 9YLZ31cjBZLhTOuUHpf1rvgaQdrzXOdeeftVP8pur6ep1uw/uEpDXG9snN+F7+f9cjZC xKkmYTn0jGZJITAOh40gs67CcE+y+RI5vZx47mMqxFHb7FgyQz9zpy5tLkpQZhimFMmD OQIg== X-Gm-Message-State: AOAM532kISBfSAv9EmaX/ArMHHDS04hzT84VuHhb600vdfiEgHGIL7ri GnIVyUc/bKQny8ZSDwEEUURM08ahNEDYiA== X-Google-Smtp-Source: ABdhPJyMJ0jurWZju2arc0dcpaRusOXr78nGKJ5FVXB40tUo+IeoPhH7oqs+3OfoQwm7EH3AxBE6Qg== X-Received: by 2002:a63:1408:: with SMTP id u8mr2428462pgl.297.1600925689651; Wed, 23 Sep 2020 22:34:49 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id v8sm1529609pgg.58.2020.09.23.22.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 22:34:48 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Hemant Agrawal Date: Wed, 23 Sep 2020 22:34:33 -0700 Message-Id: <20200924053433.12648-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200924053433.12648-1-stephen@networkplumber.org> References: <20200728191330.20864-1-stephen@networkplumber.org> <20200924053433.12648-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6 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. 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 e90e9aba080e..267e16bc318b 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; } @@ -695,13 +688,12 @@ show_offloads(uint64_t offloads, 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; @@ -709,6 +701,15 @@ show_port(void) char link_status_text[RTE_ETH_LINK_MAX_STR_LEN]; 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)); @@ -727,6 +728,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", @@ -1397,28 +1403,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