From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id ABAEDA0C47; Thu, 2 Sep 2021 14:33:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2EAE24003E; Thu, 2 Sep 2021 14:33:52 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2077.outbound.protection.outlook.com [40.107.95.77]) by mails.dpdk.org (Postfix) with ESMTP id D0CE74003C for ; Thu, 2 Sep 2021 14:33:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GFP5UbdfADSZG9juw2fVACCHzdt3HogmcuaM/gIOakR+VsekpaqoFwzXpx9Lhol7PHQszBsS+cLvFhQDO5Paols+M+L74Kgg0mI49oU60mG2DCS/3OOWhhyitNKP94HTDaSGBTbI6cgE/t0Fq5jKTkwlkevXtuLPE2epnHfuNSK78J3suiXHnIZTnKv2JCUwsxQs5IoFglhKEV1cbQ/o6LNZGMyOc3HzMubbN4W0McjvBEPM3nSiMZritJytUbsdB2nAb/ljT2RFY6V1TxME+wwhJF+qQJ/ZFR+scXk/RIW0H/FjaCc/J52cO4qUaRj4DC3VTS0cIYjqnoJumNqA9Q== 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; bh=oigRpC5OgFGnxa6oGm9rmQEGMHwYtHzRCqT95X1mFyM=; b=YnyGONnHR9c747EIvwSh/NclbPPv8JSRUQcaE7GGtFRSMDgx6kAKz8/aJvAaDt9LokVuKNso7uFLZtdD2C7XsOdMmsgjz8TUwfnOgwnN66VIpf2BP+EU1l1beCpWQQiWkhwhopBSz0BUGxs4vaVzHi9SJq//R0ElgmbJqL1aaqKVmdot/pkTzLL3vJ6hI7iDv1IUg5j8zvoAfU+iGqxBm+cQD1XHIZqqxvihRjW7RNZArSS+eaagD27/iRD5uGn+4k9og79OyZSX5xeSTQ2muB7XorOFpcqx0qgsvyJO/aemxZU7oE8vUODFsHWJjLcfnq+McbohOmITHTeDpM699A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oigRpC5OgFGnxa6oGm9rmQEGMHwYtHzRCqT95X1mFyM=; b=lDcwO+PSCM5xmUq0JaY2mz9fRDUEl9/JbsD29sbpduLnfmD6DHRLTZOG8BiNvLUkCnS/M12q7gOdEKOnZeR3I3+V/OFrkwM+7lgRDzkZVwSrKB+awirq/W1Oqwq2LMpYHOKWwy5K04T8RAztST070hHkk6Djlk6cv/wMe91Ppt8FGtxu9fcAWtZ/8KZ06YMIJssBSRogGDVOCcZI+tuNh2QeW62IC0BCJbMAfo3GRweygFyzx6E1FAba1025jjYX78jqI7/C2TGv0EkwraCV+c5Zrqm3j7ZbANihyKLCHt57vHmsnFPxSnqpndRXO5YUHlQG/BryBjfAMOPaIgHxDg== Received: from DM4PR12MB5373.namprd12.prod.outlook.com (2603:10b6:5:39a::17) by DM4PR12MB5054.namprd12.prod.outlook.com (2603:10b6:5:389::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.21; Thu, 2 Sep 2021 12:33:49 +0000 Received: from DM4PR12MB5373.namprd12.prod.outlook.com ([fe80::20f5:dbdd:64b1:617b]) by DM4PR12MB5373.namprd12.prod.outlook.com ([fe80::20f5:dbdd:64b1:617b%9]) with mapi id 15.20.4457.024; Thu, 2 Sep 2021 12:33:49 +0000 From: "Xueming(Steven) Li" To: Andrew Rybchenko , Xiaoyun Li CC: "dev@dpdk.org" , Viacheslav Galaktionov , Andy Moreton Thread-Topic: [PATCH v2] app/testpmd: add command to print representor info Thread-Index: AQHXnoMQ+aCzBK/8/0yuVtt1gfqvIquQsFZA Date: Thu, 2 Sep 2021 12:33:49 +0000 Message-ID: References: <20210827063935.1834143-1-andrew.rybchenko@oktetlabs.ru> <20210831161242.3465395-1-andrew.rybchenko@oktetlabs.ru> In-Reply-To: <20210831161242.3465395-1-andrew.rybchenko@oktetlabs.ru> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: oktetlabs.ru; dkim=none (message not signed) header.d=none;oktetlabs.ru; dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3e0b65af-93ff-4ecc-379f-08d96e0dea53 x-ms-traffictypediagnostic: DM4PR12MB5054: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:121; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: mBiySXolG/EbFR5PeH0sWqzU4uL6qW6MM/9yiIrDNfwhXiJ7oFP+Ywh19//6TvYStobrQRQREXkKBxe2cwGysTuN8WbeKDSPCyWd3lkFFZzyr/g3KUc/guCTFNWCOXFkEiL2NSFSJinKdKFwIKY9lworULRWgsEpH1EsXrJ5jPQyrZzUK77C6g3EDrb7nQBWJ+lEFw1uFA4g4X0+qbz4cv0MZ9lkfd7ldIUNYkH5CcJtmLuf1jP5oyh+ks+cfX4/lY9J4lHtoHTxBOXiCRUjG2rsz2SiUW03FkNfyqzwe6QjI46NELy5tkd9DlDypiuuyoacPfXC43C/2E9mdI37AfNjTA1C15LOf8trmZxwl/XFKvEwkq9wCW9nyo2xAr5mPUr2i7aLICHPpRNuOX0F0eS/l+19g8jl9ya1gzrCBORo2kqUeo9EPnYPS3IVGRUh6rnZ77NQbB2zsryFIHfacdNS6dJabeyQraEoUprcJqKYaTee8hdME6y0mSqvAxI3IXiJpjgWeYDftshTGhQO3hTh3PlVQVzxVPWGDGqnf/0d98z12J3Hk2oalOiUlMTGZAWXTbb9fQTAvZnIqnn2wihJowcKx6xCzziBblCO1X7GxStk9AxnfPoIOZoX2Bun/aZtozkiPQIUlp8JmET4ftmDsC9UI1XNwZkOpqvHbONGFy1PnIMC7pDIwnQ6InkUmiyAUMf+qYEbb2VeDvV2sA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR12MB5373.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(376002)(366004)(136003)(39860400002)(86362001)(2906002)(66476007)(76116006)(66946007)(33656002)(55016002)(66556008)(6506007)(8676002)(66446008)(26005)(64756008)(53546011)(9686003)(122000001)(5660300002)(54906003)(110136005)(7696005)(316002)(8936002)(83380400001)(71200400001)(4326008)(52536014)(38070700005)(478600001)(186003)(38100700002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?azG2iMFjHb3ulZDGuGu9KukEtpZogZDDh/9Yz/A4eRqowVDViiAbeN/edFZ2?= =?us-ascii?Q?Q7Lo4c1vKAf4jA8x8ToxwjWwRoix2ErXBpzkFOHnyudnWxXqV03SadKt8Yx6?= =?us-ascii?Q?SiAc+lmDiUeTG5AjEN8AqNcYyk7qMVCA93OcnZh2kJj+NYIh13ws3VHxiaxN?= =?us-ascii?Q?j9u0s0OLtto8GWQ+daicPV+32kRpEp9MWpq1Q4oMPuc+FdumcQ3JkoDIuw5s?= =?us-ascii?Q?aDC9fOksFDuD4kBFoSnfRSE8cyM2sawDCPazZ5EfvkvjaHF1CWoA4q8KBrrp?= =?us-ascii?Q?6n+yj6i2I/Xh4ga58UflPrQ/TKa2C7EKA0n5MhsXSgDGvjkHC7omf3ee0Mev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TUDL7iUn3UtEkhc34uN3DzXUjLA?= =?us-ascii?Q?3olEuAyJquV0DIroNEuA3EWB5jE6UGrISfReAcc892UXNofZ2qal/F8jQB6v?= =?us-ascii?Q?Dqnd+y4mPCEIs4PzwTIaUzMh?= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e0b65af-93ff-4ecc-379f-08d96e0dea53 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Sep 2021 12:33:49.4289 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: FeB1paDedP6aHDwq3Oteqm806a6xYIFl+xzkspTCBRa5BUmKsHZZFpCVxB2SitvtH4RbBf98O8tpssScMYAfig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5054 Subject: Re: [dpdk-dev] [PATCH v2] app/testpmd: add command to print representor info X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" > -----Original Message----- > From: Andrew Rybchenko > Sent: Wednesday, September 1, 2021 12:13 AM > To: Xiaoyun Li > Cc: dev@dpdk.org; Xueming(Steven) Li ; Viacheslav Ga= laktionov ; Andy > Moreton > Subject: [PATCH v2] app/testpmd: add command to print representor info >=20 > From: Viacheslav Galaktionov >=20 > Make it simpler to debug configurations and code related to the represent= or info API. >=20 > Signed-off-by: Viacheslav Galaktionov > Signed-off-by: Andrew Rybchenko > Reviewed-by: Andy Moreton > --- > v2: > - change output format to log just one line per range >=20 > app/test-pmd/cmdline.c | 135 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 135 insertions(+) >=20 > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 82253b= c751..ae700f9dd1 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -236,6 +236,10 @@ static void cmd_help_long_parsed(void *parsed_result= , > " Show port supported ptypes" > " for a specific port\n\n" >=20 > + "show port (port_id) representor info\n" > + " Show supported representors" > + " for a specific port\n\n" > + > "show device info (|all)" > " Show general information about devices probed.\n\n" >=20 > @@ -16962,6 +16966,136 @@ cmdline_parse_inst_t cmd_show_capability =3D { > }, > }; >=20 > +/* *** show port representors information *** */ struct > +cmd_representor_info_result { > + cmdline_fixed_string_t cmd_show; > + cmdline_fixed_string_t cmd_port; > + cmdline_fixed_string_t cmd_keyword; > + portid_t cmd_pid; > +}; > + > +static void > +cmd_representor_info_parsed(void *parsed_result, > + __rte_unused struct cmdline *cl, > + __rte_unused void *data) > +{ > + struct cmd_representor_info_result *res =3D parsed_result; > + struct rte_eth_representor_info *info; > + struct rte_eth_representor_range *range; > + uint32_t range_diff; > + uint32_t i; > + int ret; > + int num; > + > + if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { > + fprintf(stderr, "Invalid port id %u\n", res->cmd_pid); > + return; > + } > + > + ret =3D rte_eth_representor_info_get(res->cmd_pid, NULL); > + if (ret < 0) { > + fprintf(stderr, > + "Failed to get the number of representor info ranges for port %hu: %s= \n", > + res->cmd_pid, rte_strerror(-ret)); > + return; > + } > + num =3D ret; > + > + info =3D calloc(1, sizeof(*info) + num * sizeof(info->ranges[0])); > + if (info =3D=3D NULL) { > + fprintf(stderr, > + "Failed to allocate memory for representor info for port %hu\n", > + res->cmd_pid); > + return; > + } > + info->nb_ranges_alloc =3D num; > + > + ret =3D rte_eth_representor_info_get(res->cmd_pid, info); > + if (ret < 0) { > + fprintf(stderr, > + "Failed to get the representor info for port %hu: %s\n", > + res->cmd_pid, rte_strerror(-ret)); > + free(info); > + return; > + } > + > + printf("Port controller: %hu\n", info->controller); > + printf("Port PF: %hu\n", info->pf); > + > + printf("Ranges: %u\n", info->nb_ranges); > + for (i =3D 0; i < info->nb_ranges; i++) { > + range =3D &info->ranges[i]; > + range_diff =3D range->id_end - range->id_base; > + > + printf("%u. ", i + 1); > + printf("'%s' ", range->name); > + if (range_diff > 0) > + printf("[%u-%u]: ", range->id_base, range->id_end); > + else > + printf("[%u]: ", range->id_base); > + > + printf("Controller %d, PF %d", range->controller, range->pf); > + > + switch (range->type) { > + case RTE_ETH_REPRESENTOR_NONE: > + printf(", NONE\n"); > + break; > + case RTE_ETH_REPRESENTOR_VF: > + if (range_diff > 0) { > + printf(", VF %d..%d\n", range->vf, > + range->vf + range_diff); > + } else { > + printf(", VF %d\n", range->vf); > + } > + break; > + case RTE_ETH_REPRESENTOR_SF: > + printf(", SF %d\n", range->sf); > + break; > + case RTE_ETH_REPRESENTOR_PF: > + if (range_diff > 0) > + printf("..%d\n", range->pf + range_diff); > + else > + printf("\n"); > + break; > + default: > + printf(", UNKNOWN TYPE %d\n", range->type); > + break; > + } > + } > + > + free(info); > +} > + > +cmdline_parse_token_string_t cmd_representor_info_show =3D > + TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result, > + cmd_show, "show"); > +cmdline_parse_token_string_t cmd_representor_info_port =3D > + TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result, > + cmd_port, "port"); > +cmdline_parse_token_num_t cmd_representor_info_pid =3D > + TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result, > + cmd_pid, RTE_UINT16); > +cmdline_parse_token_string_t cmd_representor_info_keyword1 =3D > + TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result, > + cmd_keyword, "representor"); > +cmdline_parse_token_string_t cmd_representor_info_keyword2 =3D > + TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result, > + cmd_keyword, "info"); > + > +cmdline_parse_inst_t cmd_representor_info =3D { > + .f =3D cmd_representor_info_parsed, > + .data =3D NULL, > + .help_str =3D "show port representor info", > + .tokens =3D { > + (void *)&cmd_representor_info_show, > + (void *)&cmd_representor_info_port, > + (void *)&cmd_representor_info_pid, > + (void *)&cmd_representor_info_keyword1, > + (void *)&cmd_representor_info_keyword2, > + NULL, > + }, > +}; > + > /* *** show fec mode per port configuration *** */ struct cmd_show_fec_= metadata_result { > cmdline_fixed_string_t cmd_show; > @@ -17816,6 +17950,7 @@ cmdline_parse_ctx_t main_ctx[] =3D { > (cmdline_parse_inst_t *)&cmd_show_fec_mode, > (cmdline_parse_inst_t *)&cmd_set_fec_mode, > (cmdline_parse_inst_t *)&cmd_show_capability, > + (cmdline_parse_inst_t *)&cmd_representor_info, > NULL, > }; >=20 > -- > 2.30.2 Reviewed-by: Xueming(Steven) Li