From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140088.outbound.protection.outlook.com [40.107.14.88]) by dpdk.org (Postfix) with ESMTP id 1FEFF3772 for ; Sun, 10 Mar 2019 15:55:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qut9OWkLaWrRDcLmOINAurswbkrLBQ/8535g8W3FaXk=; b=CQFS+b+bZZXi8I6sIt6YOszgDs572KK10FzzEik33Zz7c6duMBcPOC+y1f/tk0X6FEirkhai7pQSlokyGe7NuO1cDFsTXX+5cXOO02c2428YQ5eBMltfN1fiyH3FpaPPq+Uw3LKoQVEg079dZZvOpssfkRSsm4C+J+H9OtJdKVo= Received: from AM6PR05MB4213.eurprd05.prod.outlook.com (52.135.164.159) by AM6PR05MB6232.eurprd05.prod.outlook.com (20.178.95.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.18; Sun, 10 Mar 2019 14:55:54 +0000 Received: from AM6PR05MB4213.eurprd05.prod.outlook.com ([fe80::8455:2eac:8915:19d6]) by AM6PR05MB4213.eurprd05.prod.outlook.com ([fe80::8455:2eac:8915:19d6%6]) with mapi id 15.20.1686.021; Sun, 10 Mar 2019 14:55:54 +0000 From: Dekel Peled To: Shahaf Shuler , Yongseok Koh CC: "dev@dpdk.org" , Ori Kam Thread-Topic: [dpdk-dev] [PATCH v2] net/mlx5: support new representors' naming format Thread-Index: AQHU1MPO7xkqteZ3x0yqiYZpBK5DeqYEwkyw Date: Sun, 10 Mar 2019 14:55:54 +0000 Message-ID: References: <1551367513-38224-1-git-send-email-dekelp@mellanox.com> <1551599028-14591-1-git-send-email-dekelp@mellanox.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=dekelp@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8536c03d-9858-4835-0db3-08d6a5687f1a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM6PR05MB6232; x-ms-traffictypediagnostic: AM6PR05MB6232: x-ms-exchange-purlcount: 2 x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; AM6PR05MB6232; 23:EUm98EQsat9fMP7txJAu6tklDWG728hmBoatt9DsE?= =?us-ascii?Q?CDfE2/jmuKODPj7ivozkVhGd6CSId2JLRaE2z1/wEiQvX48SWlu/fpNs3nb8?= =?us-ascii?Q?UOa0yd2MFv8QZNtaWUX/aPaidpSI66R/jkArxWqdEYXcjcWK3CaU7mbXjBJE?= =?us-ascii?Q?uvis+Hrt9gTVDwNymx1VkP7HWZSJGF+DrbS1a7Ilp4qewFQ0UlDxBB4oB+EC?= =?us-ascii?Q?K8zbAUw0xk63Jjf3TR5ObeGANcouTlZtLfQVHXXu8nwXhbscTmMZc803Wr1a?= =?us-ascii?Q?kFuDYCxz7m2l+4PBNxbxtqwcP2yXklE37eBbXyP+9P0qOcVDDdhB0WoxR2je?= =?us-ascii?Q?EkI0TCbcqkhtHuXLukuR5lv1WJAhnetOISqnCal8vOWwYqy8QsXkVPiZIj2q?= =?us-ascii?Q?yNKr6Dgo8tULCDYZb1nG4oQqOZHtZOXsfSrCh1JuoGN9sw0uGteQ5YCr2uGS?= =?us-ascii?Q?UBGVKejCHLbrSUVtyIfkH5qNVXu38U4RXSVrvH7ifKgOc1ODsfY2+D4CrzIS?= =?us-ascii?Q?IMI8IdI/h97xJvMf2jfzTNxEQN1QsnMbIYyblPtVohFWDMYWsx5oQ185Wbtq?= =?us-ascii?Q?GNc0ck6LlhlVliIwSdP2ahqiRur8knAekWdg/pX92d9LrFfxjkVOY5NzRp8E?= =?us-ascii?Q?GUCde5k1gOewvqXqXQiZX63JBDwOixc1cYEoCAUhtlP2OaKaJ1JSLoUNSRvM?= =?us-ascii?Q?TaVV0ij7hbeTKFeLGmQ6HOPRH3PUrCeDdnciUYglxuenPnvFFmfcbif3N48t?= =?us-ascii?Q?kTwCc9SajaM9KNYg9RRsiaFT3h/kGH2iWElg/PsanRa5tunCeQ5C7bFOwlwE?= =?us-ascii?Q?z5mrvxth8ufBTOK6BNzU9UkancbkNKygD9BgKz1A7kJIu2U/79n8K6c0lcmd?= =?us-ascii?Q?09iLAfEF2WmWOu6HNW4yRoAfoRbOH9ii3bOSvxYxZBmU9rNXwnVAoXHp5IW7?= =?us-ascii?Q?Q6u5D91s3p85y7TZ+9O8m6GiMPMCBClUF0i6mp9nsfosVQKoZditOQI9GRWi?= =?us-ascii?Q?sCr69uC6v9X4x7aqRKxz7vHzAep0PAE8QF5JIeIoYzf3jU2vY2Vq92tMoJ/7?= =?us-ascii?Q?64ln0OcG31A8y5j3JMdzf+gOXYoc0dWKJY6g6W4kuu1yKZXfeziTPCwV0Kqb?= =?us-ascii?Q?vv/vlD+00kzyhKRhCtZLuzZgMMGVZVjY9ISN1Yo0AvN0VuyAkXDfklctw0zc?= =?us-ascii?Q?HTCOz90sPLxKwB8jmz6CPs2yAKsKZtaHu01FdY/FW8XYcWOldRr/VDciyD39?= =?us-ascii?Q?5xCRB5XD8+gKSkbMC2VRRcEX3Nn1C3BKZQcIk0vCg3iqjTv9Xp9BUDuRa7sM?= =?us-ascii?Q?XHh21JodduuTnljdbvEGAwnZ9L+RhWYwVfjwqB7o1rydJCzGjVwnCxJ+08gK?= =?us-ascii?Q?knSBA=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0972DEC1D9 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(376002)(346002)(366004)(199004)(189003)(13464003)(66066001)(99286004)(54906003)(110136005)(2906002)(316002)(476003)(486006)(446003)(11346002)(106356001)(105586002)(6506007)(53546011)(26005)(6116002)(186003)(14454004)(74316002)(97736004)(102836004)(68736007)(3846002)(45080400002)(81156014)(966005)(81166006)(76176011)(7736002)(8936002)(305945005)(7696005)(55016002)(86362001)(52536013)(6436002)(53936002)(229853002)(71190400001)(71200400001)(6246003)(9686003)(5660300002)(33656002)(478600001)(4326008)(25786009)(6636002)(6306002)(14444005)(256004)(107886003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB6232; H:AM6PR05MB4213.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: mdnnpSWqq/hnwbFuWET8+PFPNNiRviIK0Qb/Y8KCTXLACkeeb5mvU8hxkJeOp9WD5eTnL+TopC25+F0lU9ruz4V79vEKlgrlzD/azxFeZnYl4wQnrOTHRCrY6RhY5G9M5C7/8F58cv7HEJR3dElwR+l8U6K3Vw7/Af3P9x1tWM9FDC6ja+hBBq6IrA0FlonqPbZWFYc8kBnOTNes89t73PEzITAdywFN9fBLX/8vLOO2AE1fkIOv7KU8nmqsen87L//2dtGlA6fpvEsPvhCDimcc/r2VD1n/QiWiyq7ZV73e3eetVPxBDLiyu1e7d9KnBbPqo4N0i/fcFESWgXTyqXXgwqTlxeqohpR2kdIR76GLM9hqKLR/H89jvUjl+k3Ibv8Uj1UUQ8uzujI/to01DvazbARHWXvjom+04QTsv6k= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8536c03d-9858-4835-0db3-08d6a5687f1a X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Mar 2019 14:55:54.6238 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB6232 Subject: Re: [dpdk-dev] [PATCH v2] net/mlx5: support new representors' naming format 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: , X-List-Received-Date: Sun, 10 Mar 2019 14:55:57 -0000 Thanks, PSB. > -----Original Message----- > From: Shahaf Shuler > Sent: Thursday, March 7, 2019 10:58 AM > To: Dekel Peled ; Yongseok Koh > > Cc: dev@dpdk.org; Ori Kam ; Dekel Peled > > Subject: RE: [dpdk-dev] [PATCH v2] net/mlx5: support new representors' > naming format >=20 > Sunday, March 3, 2019 9:44 AM, Dekel Peled: > > Subject: [dpdk-dev] [PATCH v2] net/mlx5: support new representors' > > naming format >=20 > Representors' -> representor I'll amend it. >=20 > > > > Kernel update [1] introduce new format of representors names. > > This patch implements RFC [2], updating MLX5 PMD to support the new > > format, while maintaining support of the existing format. >=20 > As a high level comment, I would expect to have some function called > translate_phys_port_name to translate the netlink/sysfs output to the > representor number. > This function should be called from both sysfs and netlink routines. I'll add it. >=20 > > > > [1] > > > https://emea01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fgit > > > hub.com%2Ftorvalds%2Flinux%2Fcommit%2Fc12ecc2&data=3D02%7C01% > > > 7Cshahafs%40mellanox.com%7C98910a4923c64d7af0cc08d69fac0de0%7Ca65 > > > 2971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636871958646189312& > > > sdata=3DvMvheEzZJEWRTtSK7z2qjJSxR2o50KnLOGATBAVfueM%3D&reser > > ved=3D0 > > [2] > > > https://emea01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fmail > > s.dpdk.org%2Farchives%2Fdev%2F2019- > > > March%2F125676.html&data=3D02%7C01%7Cshahafs%40mellanox.com%7 > > > C98910a4923c64d7af0cc08d69fac0de0%7Ca652971c7d2e4d9ba6a4d149256f46 > > > 1b%7C0%7C0%7C636871958646189312&sdata=3DUWxPP9SXclFAz23dtBHU > > eIF7v9ZRqbEU4nXUsirDr%2Bg%3D&reserved=3D0 > > > > --- > > v2: Use public link to kernel patch, add link to RFC. > > --- > > > > Signed-off-by: Dekel Peled > > --- > > drivers/net/mlx5/mlx5_ethdev.c | 14 +++++++++++++- > > drivers/net/mlx5/mlx5_nl.c | 20 +++++++++++++++----- > > 2 files changed, 28 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/net/mlx5/mlx5_ethdev.c > > b/drivers/net/mlx5/mlx5_ethdev.c index 795c9c7..664f485 100644 > > --- a/drivers/net/mlx5/mlx5_ethdev.c > > +++ b/drivers/net/mlx5/mlx5_ethdev.c > > @@ -1359,7 +1359,8 @@ int mlx5_fw_version_get(struct rte_eth_dev > *dev, > > char *fw_ver, size_t fw_size) > > bool port_name_set =3D false; > > bool port_switch_id_set =3D false; > > bool device_dir =3D false; > > - char c; > > + char c, pf_c1, pf_c2, vf_c1, vf_c2; > > + int32_t pf_num; > > > > if (!if_indextoname(ifindex, ifname)) { > > rte_errno =3D errno; > > @@ -1375,9 +1376,20 @@ int mlx5_fw_version_get(struct rte_eth_dev > > *dev, char *fw_ver, size_t fw_size) > > > > file =3D fopen(phys_port_name, "rb"); > > if (file !=3D NULL) { > > + /* Check for port-name as a number (support kernel ver < > > 5.0 */ >=20 > Logically it should be the other way around. > First check for new kernel, if not, fall back to older one. I'll reorder. >=20 > > port_name_set =3D > > fscanf(file, "%d%c", &data.port_name, &c) =3D=3D 2 && > > c =3D=3D '\n'; > > + if (!port_name_set) { > > + /* > > + * Check for port-name as a string of the form pf0vf0 > > + * (support kernel ver >=3D 5.0) >=20 > According to the kernel commit, naming of type p0 or p1 (for the uplink > vport). Will it work w/ below fscanf? I don't need this name, only the representors names. e.g. pf0vf0 will result in name "0". P0 will also result in name "0" but it= is not valid. >=20 > > + */ > > + port_name_set =3D (fscanf(file, "%c%c%d%c%c%d%c", > > &pf_c1, > > + &pf_c2, &pf_num, &vf_c1, > > &vf_c2, > > + &data.port_name, &c) =3D=3D 7) > > && > > + c =3D=3D '\n'; > > + } >=20 >=20 > > fclose(file); > > } > > file =3D fopen(phys_switch_id, "rb"); > > diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c > > index > > 0bf6845..cc7b4b8 100644 > > --- a/drivers/net/mlx5/mlx5_nl.c > > +++ b/drivers/net/mlx5/mlx5_nl.c > > @@ -849,7 +849,7 @@ struct mlx5_nl_ifindex_data { > > while (off < nh->nlmsg_len) { > > struct rtattr *ra =3D (void *)((uintptr_t)nh + off); > > void *payload =3D RTA_DATA(ra); > > - char *end; > > + char *end, *vf_str; > > unsigned int i; > > > > if (ra->rta_len > nh->nlmsg_len - off) @@ -861,10 +861,20 > @@ struct > > mlx5_nl_ifindex_data { > > case IFLA_PHYS_PORT_NAME: > > errno =3D 0; > > info.port_name =3D strtol(payload, &end, 0); >=20 > Again, the logic should be first try the new naming and fallback to old o= nes. I'll reorder. >=20 > > - if (errno || > > - (size_t)(end - (char *)payload) !=3D strlen(payload)) > > - goto error; > > - port_name_set =3D true; > > + if (errno || ((size_t)(end - (char *)payload) !=3D > > + strlen(payload))) { > > + vf_str =3D strstr(payload, "vf"); > > + if (vf_str) { > > + errno =3D 0; > > + info.port_name =3D strtol(vf_str + 2, > > + &end, 0); >=20 > Again, true also in case port name is p0? See comment above. >=20 > > + port_name_set =3D true; > > + } > > + if (errno) > > + goto error; > > + } else { > > + port_name_set =3D true; > > + } > > break; > > case IFLA_PHYS_SWITCH_ID: > > info.switch_id =3D 0; > > -- > > 1.8.3.1