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 B52CDA0526; Tue, 21 Jul 2020 20:24:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 277961C0D4; Tue, 21 Jul 2020 20:23:14 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 086B31C0C0 for ; Tue, 21 Jul 2020 20:23:05 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id s26so11117619pfm.4 for ; Tue, 21 Jul 2020 11:23:04 -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=ayjpsRuSmwaP8iEWgmrAlJ/SL79IxKv+SuNzii3piHE=; b=oVr9WPcdQcgAWHYYGpQjH/tBoa7PTwmb4mCZ2ER1AQqCgOWGmC0gJ0B35RdHyJN+IS Z1PCDZG0BYDGcX/uV54T3zdbD/wyExPwnHHSy+k3tmao2rd6SKFGLJLGdYblIqJlwO9r 5KGO0ou0SH7pMICxu2CAPbggvmcUlg9pZqcWhbcrCWSZl+f5ViDTt8BLxjDFJlrS5/S8 6l0OkOtdjxaqfjErM5Dw+nQZAhayQAUp8Jdseg13RgNr5rVSejgLsmH/qWMNFsXV05pW hXCUgvZJbsKsjDl2rn66i1utCER6AWa4jUdrOy65jz9peOB7IJFpf3pDqEbDbLqe1K11 v4pA== 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=ayjpsRuSmwaP8iEWgmrAlJ/SL79IxKv+SuNzii3piHE=; b=KMM3lHQ6R2OvwhO16Oh40F9NXJ4vZtvi6wLtc6vZYT0JpeRvs0oPSfBNgbIYL/nrf/ liy8v18YtFr78fIUM/HOtI9cH2RIDeDaVy9B6CFXM0qNRm2+9Wh8M1RqefFd62MKUFMD Hqmy+7Jir3WueOYCWs6H7o4zIIbWkZ5uBi4jCX8X2ys9lnUIYOARgW+KT4C+hgHy3RFO JZs/bThEaNRADVu2AUc9urbkO4WQtwlq2UvSVoShKRnUIB1gZbT8kAvkUPmjIAW9bUL5 9c51FG9dAM+cl0S94J1bfENBnA0wwu2L5m227SkJZ1Q+PmubJxjAlcTuv1Uqe1JLx3PT XRPA== X-Gm-Message-State: AOAM531IlD7d1P7qoRcb476bVxg02JzZbRbayvT8Ofqw8smjhWdwrTP2 VIdVWDPLHWt18G9+7twKFE2Hdp0ZIZbVuQ== X-Google-Smtp-Source: ABdhPJyPYVrPMzXih6RbBYmvWY+z0/9BPaJ1g7/tMPJfvmX6WPYzkZRSlqavOyLj7uDhm+XTF8DEXA== X-Received: by 2002:a63:5013:: with SMTP id e19mr23775662pgb.68.1595355783613; Tue, 21 Jul 2020 11:23:03 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 76sm21434031pfu.139.2020.07.21.11.23.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 11:23:02 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Hemant Agrawal Date: Tue, 21 Jul 2020 11:22:42 -0700 Message-Id: <20200721182242.5366-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200721182242.5366-1-stephen@networkplumber.org> References: <20200506193741.24117-1-stephen@networkplumber.org> <20200721182242.5366-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 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 | 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 #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,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