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 D85A3A0521; Tue, 28 Jul 2020 07:39:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4235F1C044; Tue, 28 Jul 2020 07:39:49 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60044.outbound.protection.outlook.com [40.107.6.44]) by dpdk.org (Postfix) with ESMTP id 1462B1BFF2 for ; Tue, 28 Jul 2020 07:39:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DQrpScZbVvj9tAL9U57i5dw9RQjgI51nmkwGWcDa1Fb4trC9/ECZQw8ZnHJXhbSrE+J5lEs2BLTqfHwQXlI6vHuO+eOw+9PMBjoa/Da0Aw8O4cL4OrbXqzCVKMRCFvR585ZiONzfZ1z0wha13UnPIRNtlFm3AopMTWBz38iDXj4NNGleeDtXxyv9uvnlh1oQlFVNAC3NKR6oXCO0Qa9GzEQcALJMIkMLP8Dt+uoftbTjOk7DdFQep0rhs/zmXygGCbK5lDFCm+NVRdY8jcqa5eVtiZB6yUpf/NZ4Vj3k6Pz10c1QIoXLRi1t7bPqHf/lATEQUTe0Ullz//VYRzWLrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aJ9s7ioAEIzD2ufpU5WTt5AM+xOWGWRXHP2rqSBPtzs=; b=kVJzhx3Gtb5G0bYp+rQ8ghSyaoyA4/BM4mKz0Zf9qEYCBsIB/0Ypq7sPyJ/gddByN6oCsN+Yki+QJYWlSJzqgIvzm6v/XxngBR6CPLnL0qh42vyFbaUFDvPNIh6PUPo4l0vQpLxULH+yZzlktmgEHLguttYlHNXOHe8p/rLNlEymdeGCOZT8dP6cxBGMVGZK8y+PqvlYJbKINySuwntxZpMoUFmCsJJN9cBZO7XfeCm799j3iOmjSGGMU2v4KdIV31013PYu82RIqicsu1Lj65XxBgzTYNZiXDt9eVCclbQT2BtwPSFktKAp3hUqq6d/YEHr1InsgKteAfBUY9EBnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aJ9s7ioAEIzD2ufpU5WTt5AM+xOWGWRXHP2rqSBPtzs=; b=VDyhPwBdmCkdIserRHMEFjDrhw/PlS7lpTB23x+gx/0cimF2xk+VC84tt0f77/ENVmnFMT/cqAAJN/P0tkCyP2zMyahYSkBCUx3M5NS8Ma5GP6VuCEDNJwXTXcg6IpcCVK5+gi8Gb6aPnpRHFySiBcBmFdMDDJ3jwL+1GN/bkS4= Received: from AM6PR04MB4456.eurprd04.prod.outlook.com (2603:10a6:20b:22::25) by AM6PR04MB5077.eurprd04.prod.outlook.com (2603:10a6:20b:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.24; Tue, 28 Jul 2020 05:39:46 +0000 Received: from AM6PR04MB4456.eurprd04.prod.outlook.com ([fe80::50d:1b5:ef9f:655c]) by AM6PR04MB4456.eurprd04.prod.outlook.com ([fe80::50d:1b5:ef9f:655c%7]) with mapi id 15.20.3216.033; Tue, 28 Jul 2020 05:39:46 +0000 From: "Hemant Agrawal (OSS)" To: Stephen Hemminger , "dev@dpdk.org" Thread-Topic: [PATCH v4 8/8] app/proc-info: provide way to request info on owned ports Thread-Index: AQHWZKGA90O6eyf8lkOIV0c+4h4oGQ== Date: Tue, 28 Jul 2020 05:39:46 +0000 Message-ID: References: <20200506193741.24117-1-stephen@networkplumber.org> <20200721182242.5366-1-stephen@networkplumber.org> <20200721182242.5366-9-stephen@networkplumber.org> In-Reply-To: <20200721182242.5366-9-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: networkplumber.org; dkim=none (message not signed) header.d=none;networkplumber.org; dmarc=none action=none header.from=oss.nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [182.69.57.113] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 0c23463d-b64c-4f32-14f5-08d832b8a304 x-ms-traffictypediagnostic: AM6PR04MB5077: x-ms-exchange-sharedmailbox-routingagent-processed: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1265; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WBIWUv8JqL78Ou2loJFbBr7rpS8x6PXQwFQd2mxzomHsobzkI4YJS7JAOMgt+SV7iAw+JWMBBl6F9eCsq/dEfvLUnQCsWV0Hn2ByT5wmAshiixvh+emmcuVndSyvFWcGNkyh5yo1eMwJ0k8B0xZRczBvr0mvePSp0bVYtcgcPFnLRM9Rlud5naXZxkahny/ByDmSsDVDVV3VRrxqQ6HrWGWubKJ4k6hrCpeUp9a9t3TeGbb77MUVQms5w9jP2KZyr7q7mCAZP7Rq/nJI2KX3zbLzlqgZOj3N0PhSH7LWT1ayEzSr5nGDt4EIkz6nyV9RVLN6ZDLXtuToBnIDsszzy5UDc3lNNQQVRXYEW5PW3UwFCgolD3UxJBsm+PA5rfcM x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB4456.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(55016002)(110136005)(478600001)(7696005)(71200400001)(8676002)(316002)(8936002)(9686003)(53546011)(83380400001)(6506007)(186003)(52536014)(86362001)(33656002)(5660300002)(64756008)(26005)(66946007)(76116006)(2906002)(66446008)(66556008)(66476007)(43043002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: njjvbTuAf011ENhL9PzJ9HncUWMHqi+sadAFznrIRq0ad+AOTY1R2eNvVl4fk4DbO3H0wNKfV9M4TAKXO5rdijc0ln+Twf6DIEUPe+DC44U8v636QYfKF73Vh7+Dd7edfDJ8YJFbcU+pWQdzjG78MCzh9w9IBvLTIKklsuSLNlYF52k5KiwGYcL6eiMLIJhreR9bt8hW8MkLZa8FGKu/iduKwFRcw+4anK7T+TyPAOtjmb6V1GBqxoAkdopTHjYalnMfuSwz1/gDjzhr6hvVfy+cjUkhulGLyxi84jig6b1a9y+3I+9axge/+n8EHN1KaR0LubJbcavmwLAbClp8KnaZ50Z81lJvq2/z6Eav0HltkCSIR+7cr9gZRVmkrr95dglA/VnijGBG/q4rPJ7G5vJmKyiWuXZCvoag18sMWBRxKHiHO7J45dtIhqr0rPEIrXNQgluQcrkL3HdxHTIsQlNytmdTZZfPeXliSuDa0GR/Xl/f8rHgY9O8NRbL0tEn x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4456.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c23463d-b64c-4f32-14f5-08d832b8a304 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jul 2020 05:39:46.2360 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: M4PxbGSbIRq451dSrge9iv8lFhMfCfYIh+viwy4xJkeEaIIEiYbZdPHKlqoOyOpO1VCI2NrAVZQmDY7YW/kM7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5077 Subject: Re: [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" Hi Stephen, This patch has checkpatch errors ### [PATCH] app/proc-info: provide way to request info on owned ports ERROR:TRAILING_WHITESPACE: trailing whitespace #98: FILE: app/proc-info/main.c:702: +^I$ ERROR:TRAILING_WHITESPACE: trailing whitespace #111: FILE: app/proc-info/main.c:715: +^I^I$ ERROR:TRAILING_WHITESPACE: trailing whitespace #115: FILE: app/proc-info/main.c:719: +^I^I$ ERROR:TRAILING_WHITESPACE: trailing whitespace #149: FILE: app/proc-info/main.c:1431: +^I^I$ total: 4 errors, 0 warnings, 154 lines checked Regards, Hemant -----Original Message----- From: Stephen Hemminger =20 Sent: Tuesday, July 21, 2020 11:53 PM To: dev@dpdk.org Cc: Stephen Hemminger ; Hemant Agrawal Subject: [PATCH v4 8/8] app/proc-info: provide way to request info on owned= ports 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 leve= l ports. If portmask requests a specific port it will be shown even if owne= d. 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 =20 #include #include @@ -46,7 +47,7 @@ STATS_BDR_FMT, s, w, STATS_BDR_FMT) =20 /**< 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 =3D NULL; - unsigned long pm; =20 errno =3D 0; =20 /* parse hexadecimal string */ - pm =3D strtoul(portmask, &end, 16); - if ((portmask[0] =3D=3D '\0') || (end =3D=3D NULL) || (*end !=3D '\0') || - (errno !=3D 0)) { - printf("%s ERROR parsing the port mask\n", __func__); + enabled_port_mask =3D strtoul(portmask, &end, 16); + if (portmask[0] =3D=3D '\0' || end =3D=3D NULL || *end !=3D '\0' || errno= !=3D 0) { + fprintf(stderr, "Invalid portmask '%s'\n", portmask); return -1; } =20 - if (pm =3D=3D 0) - return -1; - - return pm; - + return 0; } =20 /* @@ -242,9 +237,7 @@ proc_info_parse_args(int argc, char **argv) switch (opt) { /* portmask */ case 'p': - enabled_port_mask =3D parse_portmask(optarg); - if (enabled_port_mask =3D=3D 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 =3D 0; - int ret =3D 0, j, k; + int i, ret, j, k; =20 snprintf(bdr_str, MAX_STRING_LEN, " show - Port PMD "); STATS_BDR_STR(10, bdr_str); - - RTE_ETH_FOREACH_DEV(i) { +=09 + for (i =3D 0; i < RTE_MAX_ETHPORTS; i++) { uint16_t mtu =3D 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; =20 + /* Skip if port is not in mask */ + if ((enabled_port_mask & (1ul << i)) =3D=3D 0) + continue; + =09 + /* Skip if port is unused */ + if (!rte_eth_dev_is_valid_port(i)) + continue; + =09 memset(&rss_conf, 0, sizeof(rss_conf)); =20 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)); =20 + ret =3D rte_eth_dev_owner_get(i, &owner); + if (ret =3D=3D 0 && owner.id !=3D RTE_ETH_DEV_NO_OWNER) + printf("\t -- owner %#"PRIx64":%s\n", + owner.id, owner.name); + ret =3D 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 =3D=3D 0) rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n"); =20 - /* If no port mask was specified*/ - if (enabled_port_mask =3D=3D 0) - enabled_port_mask =3D 0xffff; + /* If no port mask was specified, then show non-owned ports */ + if (enabled_port_mask =3D=3D 0) { + RTE_ETH_FOREACH_DEV(i) + enabled_port_mask =3D 1ul << i; + } + + for (i =3D 0; i < RTE_MAX_ETHPORTS; i++) { + + /* Skip if port is not in mask */ + if ((enabled_port_mask & (1ul << i)) =3D=3D 0) + continue; + =09 + /* 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); =20 - 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); - } } =20 /* print port independent stats */ -- 2.27.0