From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70052.outbound.protection.outlook.com [40.107.7.52]) by dpdk.org (Postfix) with ESMTP id 0C4772C17 for ; Thu, 7 Mar 2019 09:57:36 +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=qpnqKb02ppA/LeQw7X27ya5LDcecDCwZqKv0qRrosaA=; b=Ic8Lq0ZcGY9dV9rCg3go3pbkXr84kG01YtqwAoUZHWRxpiZvMkm33JoIf0XbMtaW/o6TKyItnABctastZt9tqofjov0pdCiKlZle51G3u4tEyihK2mfgTzuLAyFVuyJge/BXru+O37/PbUcaD14pwAiknrOALAefio0zjFteQqY= Received: from AM0PR0502MB3795.eurprd05.prod.outlook.com (52.133.45.150) by AM0PR0502MB3812.eurprd05.prod.outlook.com (52.133.47.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.18; Thu, 7 Mar 2019 08:57:34 +0000 Received: from AM0PR0502MB3795.eurprd05.prod.outlook.com ([fe80::84f3:7e92:7a51:1003]) by AM0PR0502MB3795.eurprd05.prod.outlook.com ([fe80::84f3:7e92:7a51:1003%2]) with mapi id 15.20.1686.018; Thu, 7 Mar 2019 08:57:34 +0000 From: Shahaf Shuler To: Dekel Peled , Yongseok Koh CC: "dev@dpdk.org" , Ori Kam , Dekel Peled Thread-Topic: [dpdk-dev] [PATCH v2] net/mlx5: support new representors' naming format Thread-Index: AQHU0ZTsXQKq1OSzOkGokOqGAIGEvaX/4R2Q Date: Thu, 7 Mar 2019 08:57:34 +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: <1551599028-14591-1-git-send-email-dekelp@mellanox.com> 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=shahafs@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 25b117fc-47d3-43d4-59b0-08d6a2daf0a2 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:AM0PR0502MB3812; x-ms-traffictypediagnostic: AM0PR0502MB3812: x-ms-exchange-purlcount: 2 x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; AM0PR0502MB3812; 23:pCtoU4nAftQvrG3cZmolWlH6yCo7AhWBrtQ9hPo?= =?us-ascii?Q?IahO3yWDvMQZtGahBNDcZ06ZDaYQ11xVH3950bKM/+gnY9C3BHcNZJOjgwvF?= =?us-ascii?Q?eYRzPCXf8+pIHOolZ0M3kNWAIZrCAD6KZpsFRgtv04NntprzQade3zNEoWKF?= =?us-ascii?Q?cFdDSAmPwJNeTw+374x7sucDLD0ibtZSGOT2LtXAd1DSfKX1UPmVxUvugZDx?= =?us-ascii?Q?yfvEPGP/qnBiOlJ6v2GKJbS80Yd9WQd+Sv1Im0iDdNZissyXbVvGvt/RKNKX?= =?us-ascii?Q?sLgwPyPiShBy9xTVC2vdST1gbU+Ihy43GfXO66flurZgRzjKRDQXazNFf+9X?= =?us-ascii?Q?W8HBK+2EavQmu2RkPFiXrXKrAro4uc6GEF7pfThQTf+PjVAbHwWFXHuyBL77?= =?us-ascii?Q?vS8l3YvynEnjaiOzf/c3J4C/hcdgNz8G32gP8RVCoSeQ8YWOy+0QDcu7agVi?= =?us-ascii?Q?oJHf7+t7ram0sRWNMVyElIr75kN/bbs5viZkYY7IPsTeF9D/LwFa2/zmSFtN?= =?us-ascii?Q?mmN4WLr6zzsWfxwckAjLYDLLtGkGDx+C0e4C5aC7WLS47+zqJOE3tRj0Jx2x?= =?us-ascii?Q?EMnhKJ8eFAsBJJxQn6JyoSCot7k5eBc2kbmvQurJE24Q8J2sNlIcWrXH7rG+?= =?us-ascii?Q?NX+xCia0dKzHoUQjIergq2p/UVDVNaXeoyQ4Bacsj08h27zrBYk1c4DrlLnw?= =?us-ascii?Q?e8q1Nm+reLtBu1z8v/JOYp2EeDdWGD0LOTB6JBwuuokit6e2Izcch8SIFuqe?= =?us-ascii?Q?jlJnpg/RydgnNsiSu8gIVqBUwfanlrwhh7CbOgPPmkDiDuw3dws6jo/x1ZXb?= =?us-ascii?Q?qsfjJrn0E4dYmhlqmEdCheoif0sR5Y+uIXTKbX4HtnJ4CMimPQodvYXcOZwK?= =?us-ascii?Q?l5J8bQlQAcqlG9/5P89hPbXYBQbZVExgYoUT5x+twnMWXlUVPG10HXj27p+d?= =?us-ascii?Q?OPExFYH1eIDmhXBvCi0rkMlkTiynaeNzmwD9EywUrM9A9ZVtor9KAbuSNloq?= =?us-ascii?Q?U9dteTJI+HWSHQZ3yduxcMrwuWdkDxQjutuYLptLVJmdNoGqmuZqQr1hxU8D?= =?us-ascii?Q?807XLHJZDD5NEn7hivssTYGcf/HVHa1uj+eWyixsTEuZSg0PVOB53mnxrRHe?= =?us-ascii?Q?2wN7DJ2kQBottLvjX5mjTHGQCJQrWjxf/Bnqp0L8/Q15VmZQYwsfyjctalc4?= =?us-ascii?Q?P2GRxsOXNITz9UW8KLw435uBqaRea8l/chTR7Ow8MMYs9PuIK6QBn6Uu5ZX7?= =?us-ascii?Q?WH/E7yQotGnU8rcVxWQz89qi9gP301M9gZZ8JxHe/JYzfZVPCp5oRlzOaXW7?= =?us-ascii?Q?g+MkfBmFJbxYRCaM+whtgjoA=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 096943F07A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(136003)(346002)(39860400002)(366004)(199004)(189003)(186003)(102836004)(6506007)(99286004)(26005)(486006)(4326008)(6636002)(5660300002)(86362001)(52536013)(7696005)(71200400001)(2906002)(71190400001)(76176011)(45080400002)(25786009)(105586002)(3846002)(106356001)(55016002)(6306002)(9686003)(81156014)(7736002)(81166006)(53936002)(97736004)(107886003)(6436002)(6246003)(229853002)(14444005)(256004)(66066001)(33656002)(305945005)(478600001)(316002)(8936002)(6116002)(966005)(54906003)(110136005)(14454004)(476003)(74316002)(446003)(68736007)(11346002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3812; H:AM0PR0502MB3795.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: jQapxxXA79rypFZO4zuCURlEPZUsnUQWTyyJDwNDZ9WvTxOjiqp5odRkrRuzge8LFUod8RjptjdMqHvIkW0MT7x7NHdjB766Yh48JORo2C8itAEAOQsw9TVUltTtGezOdbc15aFnc0rnJH1J8KEpVb/tl3PcM7AnO09Z4+QrJTAQ5CwtKD5v842vSHHWDSox2cdnBQV96Ao2mqPARYkOz4ySrNZ8ejK7paEbMwG5bACseuIwNUOzm20MiJYW/dO3aG7im0vpkzEg+zf5rOKDXNWe3SiT5fAApc1G+oGqRRaNrW3e5u+ToafXauLAKIlDdm2NDWpsF42qUp4x+KrKkFtrWVI6QvMrgQRYd97fUq1ia2E/AKtwJHov41HW5Q8xQstmagxHnNFe9sFjvxlVGfMbPVAdbtdjjaV9YxKah8Q= 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: 25b117fc-47d3-43d4-59b0-08d6a2daf0a2 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Mar 2019 08:57:34.1924 (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: AM0PR0502MB3812 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: Thu, 07 Mar 2019 08:57:36 -0000 Sunday, March 3, 2019 9:44 AM, Dekel Peled: > Subject: [dpdk-dev] [PATCH v2] net/mlx5: support new representors' > naming format Representors' -> representor=20 >=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. As a high level comment, I would expect to have some function called transl= ate_phys_port_name to translate the netlink/sysfs output to the representor= number. This function should be called from both sysfs and netlink routines.=20 >=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 >=20 > --- > v2: Use public link to kernel patch, add link to RFC. > --- >=20 > 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(-) >=20 > 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; >=20 > 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) >=20 > file =3D fopen(phys_port_name, "rb"); > if (file !=3D NULL) { > + /* Check for port-name as a number (support kernel ver < > 5.0 */ Logically it should be the other way around. First check for new kernel, if not, fall back to older one.=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) According to the kernel commit, naming of type p0 or p1 (for the uplink vpo= rt). Will it work w/ below fscanf?=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'; > + } > 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 inde= x > 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; >=20 > 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); Again, the logic should be first try the new naming and fallback to old one= s.=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); Again, true also in case port name is p0?=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