From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20050.outbound.protection.outlook.com [40.107.2.50]) by dpdk.org (Postfix) with ESMTP id B8AE62B87 for ; Thu, 7 Mar 2019 12:12:13 +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=o2a+FGnVv/eTSHmZiiiCjtFv+n1XAxCMmF2/JZ9XB4E=; b=mQlcxXxM2UYRcDDeYA09cUSrQ/jGAncKVJfEr7yYZafj1QankiXiAwL9A7Hlz45ByI3TCz/MC8v/gn8Ceu1WL7wqcFyMx5ktmYleX1Idy8yMxoffbLY8V522hFGcC767YYERpfKApbZHCbfjqAGLcfPoaVjU3hZZQaGlxURQHl0= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.188.154) by AM4PR05MB3155.eurprd05.prod.outlook.com (10.170.126.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.19; Thu, 7 Mar 2019 11:12:12 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::6d47:c56e:e19d:5e15]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::6d47:c56e:e19d:5e15%5]) with mapi id 15.20.1686.018; Thu, 7 Mar 2019 11:12:12 +0000 From: Slava Ovsiienko To: Shahaf Shuler CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v2 1/1] net/mlx5: add representor recognition on kernels 5.x Thread-Index: AQHUzPmB23tlrqrew06hQap65znIJ6X/6egAgAAlsHA= Date: Thu, 7 Mar 2019 11:12:12 +0000 Message-ID: References: <1550738519-4251-1-git-send-email-viacheslavo@mellanox.com> <1551092489-12247-1-git-send-email-viacheslavo@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=viacheslavo@mellanox.com; x-originating-ip: [95.164.10.10] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9a0c9260-a11a-4761-433a-08d6a2edbfb8 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:AM4PR05MB3155; x-ms-traffictypediagnostic: AM4PR05MB3155: x-ms-exchange-purlcount: 2 x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; AM4PR05MB3155; 23:skEne78Xl4gzcsIRLkhvyvpNLpJpdXzl/XhoG0735?= =?us-ascii?Q?o8fHShlFYV9b8ATFU6PnilvyvzzxDsPeV3LVfUAHZI5Jp7At1Dcb6XVAzu6P?= =?us-ascii?Q?irieYIgC9ShlKgxTWJzc8k0ThdrgSEcqa5vpXROz5datsEq/FGDNC8ZpLF22?= =?us-ascii?Q?k9nXz0Yig+NKJP+ZffeyBGRkeF68QsPAne0qsXnm6eprxkAt62Gn1FK8mQb1?= =?us-ascii?Q?GcqYzu5q/SfNh+K/M1aACckMyCuvNlVs0QXMWfYq+YmlTDi5Zg6KebedT1Yr?= =?us-ascii?Q?BI4ETYLTd38+R1BmZ4O9/n4Eety42GcewrcG8AzrFFLG1Jx7NlIISoeREiUk?= =?us-ascii?Q?YUJtAIBqq8Fa6zMgrjcvCeij0QOFL/pkCjBIe7ZDq3TXEuVr5VHrJfpBso99?= =?us-ascii?Q?zKvfEe0YI+EDaYPmfP/TSFiYOkNqSSPE/puE6W5UF72mYpZVXE0z1VNcF/r6?= =?us-ascii?Q?Aas3/aih40XoW2XrEsZ+ZH+Iy6GJb84Lhgvr4ggkjyyRdLMzAQNhPyTMo8TA?= =?us-ascii?Q?S4ieQop//cvMvUCJUmHC9evMB2ueIGG5UXB/K950ZfdCuk49oorooqL9ZqzA?= =?us-ascii?Q?nIt+nJNQdUT+gdift9m20IXmqnyqLvFCIkGk9E6zDOVFFqAx8auWtQjm/kJg?= =?us-ascii?Q?A4qwl/mtWqobFYe9GJQWMul4SMChdSOPqtO9RTkA6Qe0wbBcx/t0L2RJwoOJ?= =?us-ascii?Q?HaaLEaVUxl8iuj9ty3iQDaoqtqyr2e08rYlteIQCL5nOACWUTLFxiYuQGun2?= =?us-ascii?Q?6Swu1iCgrtZIPWEbFFAQjcFlbY7JW2wEOMhtoHM84l2TRyuYy1sjw+dW/Eyc?= =?us-ascii?Q?SAUo4qgFgufOynQ2MhyRdZqoT8W8XbT8vNzSH3mseXGaqPaaH/+ppBFI+W6c?= =?us-ascii?Q?gEIXpjn2y6Ew8Yxoi9dsl4dHoIAJzTOzPomUH4IgRBOC/aG0gcW17hBMl3YQ?= =?us-ascii?Q?caieO8QybmDz6I8+b/Ie/FomHEDqQQ1WS6egWSDl96W2oCvpasCZz59xcdvU?= =?us-ascii?Q?6E9Wfshuy2xYBB2SvLap0ALEGJ+XFEOOxCGdduoLasR8DHgVkMLen8y+cJcg?= =?us-ascii?Q?B7HXA9NIBgFHcS2wf5pdBZ2oGZfss+yWnQxByEkdUGPCfrid6fj5LGV1UpCx?= =?us-ascii?Q?dR+P6wwSzJnz9Dc50lOevr2Dy2n8Qe1znGXOP9nHGGzq+jSiNmGDHmdL0jYD?= =?us-ascii?Q?OrH41IYnnBEjhM9AatffcAUQoQ+teuHAjne0Y8KGv1WmMNLIlasnKAHSBqIT?= =?us-ascii?Q?fD9zmVzk1QNCtSNLYL6tZ6x4iOHxJH7L131eIHjwpZ+xtbcnUzfURhVfnzvR?= =?us-ascii?Q?FUR7K6mXJsWXW88DAsXDe8=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 096943F07A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(39860400002)(346002)(396003)(376002)(13464003)(199004)(189003)(6506007)(6862004)(45080400002)(6636002)(71190400001)(7736002)(5660300002)(7696005)(14454004)(966005)(76176011)(478600001)(6246003)(74316002)(305945005)(486006)(53546011)(55016002)(102836004)(53936002)(9686003)(6306002)(106356001)(105586002)(6436002)(14444005)(86362001)(81156014)(68736007)(8936002)(26005)(476003)(81166006)(97736004)(256004)(71200400001)(33656002)(2906002)(229853002)(66066001)(25786009)(4326008)(99286004)(446003)(186003)(52536013)(316002)(3846002)(6116002)(11346002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3155; H:AM4PR05MB3265.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: lCtmS7zD8udKe74DnOmEB5sdNE0tIEFNw3Jh/yQXtfEbwETYJF8N/D8lk6nUXmyg2yM2+mBezeRnjdfrlLbNEnYOpuKBjAX70h/skcuvywU9Cf2MWLnIcEW4980i/nGQg0/Dtvu7r9EWusgG7iPxP6LDYBW8bE6CE6esIbPkMnBt/20dJ5FI+hTuucgmveUcV5H1NW8RObnQQHSEnFHH2g9iw5rX65oRoSEsQMqAJmD/PPEYO8tyxYbYn7n1PwLzMyheu8/8clhvEGRxRDQKLpHgbU5jsDLB0gPWLktw/PHZDfC/8a2PU4I+ynCO30pRPwzPKJsGlWRNeVbW2XypP3/UYEkOkGRDDO5RAxLdZFbNXKKpqKH+V5BQtVRlXg3jIbIMrvxaNpA4j0QB8xkACvunivcAc9YjYFSb1/qF/dk= 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: 9a0c9260-a11a-4761-433a-08d6a2edbfb8 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Mar 2019 11:12:12.6216 (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: AM4PR05MB3155 Subject: Re: [dpdk-dev] [PATCH v2 1/1] net/mlx5: add representor recognition on kernels 5.x 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 11:12:14 -0000 > -----Original Message----- > From: Shahaf Shuler > Sent: Thursday, March 7, 2019 10:44 > To: Slava Ovsiienko > Cc: dev@dpdk.org > Subject: RE: [dpdk-dev] [PATCH v2 1/1] net/mlx5: add representor > recognition on kernels 5.x >=20 > Monday, February 25, 2019 1:01 PM, Viacheslav Ovsiienko: > > Subject: [dpdk-dev] [PATCH v2 1/1] net/mlx5: add representor > > recognition on kernels 5.x > > > > The master device and VF representors were distinguished by presence > > of port name, master device did not have one. The new Linux kernels > > starting from 5.0 provide the port name for master device and the > > implemented representor recognizing method does not work. > > The new recognizing method is based on quiering the VF number, created > > on the base of the device. > > > > The IFLA_NUM_VF attribute is returned by kernel if IFLA_EXT_MASK > > attribute is specified in the Netlink request message. > > > > Also the presence of device symlink in device sysfs folder is added to > > distinguish representors with sysfs based method. >=20 > w/ kernel 5.x, there is also a new naming scheme for representor, right? > Wouldn't it be simpler to use it in order to decide uplink/regular > representor? There should not be any assumption regarding port index, we can't say for sure on which port index we have uplink representor. It is possible to compare the port name against -1, but it is quite possible situation=20 (old kernels with new drivers, I had been working with such setup for a while) in that have the multiport Infiniband device and old naming an= d we are unable recognize the Uplink rep by port name.=20 So, it seems to me, the querying numVF/sysfs method is more reliable and works for all settings I've tested. >=20 > There is already patch for it from Dekel: > https://patches.dpdk.org/patch/50771/ Yes, It's included in RFC because patchset is not functional w/o Dekel's pa= tch. The patchset will be rebased and Dekel's commit will be excluded in the next versions. >=20 > > > > Signed-off-by: Viacheslav Ovsiienko > > > > --- > > v2: > > fopen is replaced with opendir to detect whether directory exists > > > > v1: > > > > > https://emea01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fpatc > > > hes.dpdk.org%2Fpatch%2F50411%2F&data=3D02%7C01%7Cshahafs%40m > > > ellanox.com%7C570dc79e8c0f40b23a7208d69b109fa0%7Ca652971c7d2e4d9 > b > > > a6a4d149256f461b%7C0%7C0%7C636866893031018956&sdata=3DjftQKX8 > B > > d1ZVcT38q6TLSukJYMo9VRIyEPEHhFu00S4%3D&reserved=3D0 > > --- > > drivers/net/mlx5/Makefile | 10 ++++++++++ > > drivers/net/mlx5/meson.build | 4 ++++ > > drivers/net/mlx5/mlx5_ethdev.c | 13 +++++++++++-- > > drivers/net/mlx5/mlx5_nl.c | 25 ++++++++++++++++++++++--- > > 4 files changed, 47 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile > > index > > 9a7da18..c326494 100644 > > --- a/drivers/net/mlx5/Makefile > > +++ b/drivers/net/mlx5/Makefile > > @@ -226,6 +226,16 @@ mlx5_autoconf.h.new: > $(RTE_SDK)/buildtools/auto- > > config-h.sh > > enum RDMA_NLDEV_ATTR_NDEV_INDEX \ > > $(AUTOCONF_OUTPUT) > > $Q sh -- '$<' '$@' \ > > + HAVE_IFLA_NUM_VF \ > > + linux/if_link.h \ > > + enum IFLA_NUM_VF \ > > + $(AUTOCONF_OUTPUT) > > + $Q sh -- '$<' '$@' \ > > + HAVE_IFLA_EXT_MASK \ > > + linux/if_link.h \ > > + enum IFLA_EXT_MASK \ > > + $(AUTOCONF_OUTPUT) > > + $Q sh -- '$<' '$@' \ > > HAVE_IFLA_PHYS_SWITCH_ID \ > > linux/if_link.h \ > > enum IFLA_PHYS_SWITCH_ID \ > > diff --git a/drivers/net/mlx5/meson.build > > b/drivers/net/mlx5/meson.build index 4540c45..0bb2f3a 100644 > > --- a/drivers/net/mlx5/meson.build > > +++ b/drivers/net/mlx5/meson.build > > @@ -133,6 +133,10 @@ if build > > 'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ], > > [ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h', > > 'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ], > > + [ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h', > > + 'IFLA_NUM_VF' ], > > + [ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h', > > + 'IFLA_EXT_MASK' ], > > [ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h', > > 'IFLA_PHYS_SWITCH_ID' ], > > [ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h', diff --git > > a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c > > index > > 8158b4a..c30fcb0 100644 > > --- a/drivers/net/mlx5/mlx5_ethdev.c > > +++ b/drivers/net/mlx5/mlx5_ethdev.c > > @@ -1354,9 +1354,11 @@ int mlx5_fw_version_get(struct rte_eth_dev > > *dev, char *fw_ver, size_t fw_size) { > > char ifname[IF_NAMESIZE]; > > FILE *file; > > + DIR *dir; > > struct mlx5_switch_info data =3D { .master =3D 0, }; > > bool port_name_set =3D false; > > bool port_switch_id_set =3D false; > > + bool device_dir =3D false; > > char c; > > > > if (!if_indextoname(ifindex, ifname)) { @@ -1368,6 +1370,8 @@ int > > mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t > > fw_size) > > ifname); > > MKSTR(phys_switch_id, "/sys/class/net/%s/phys_switch_id", > > ifname); > > + MKSTR(pci_device, "/sys/class/net/%s/device", > > + ifname); > > > > file =3D fopen(phys_port_name, "rb"); > > if (file !=3D NULL) { > > @@ -1385,8 +1389,13 @@ int mlx5_fw_version_get(struct rte_eth_dev > > *dev, char *fw_ver, size_t fw_size) > > fscanf(file, "%" SCNx64 "%c", &data.switch_id, &c) =3D=3D 2 && > > c =3D=3D '\n'; > > fclose(file); > > - data.master =3D port_switch_id_set && !port_name_set; > > - data.representor =3D port_switch_id_set && port_name_set; > > + dir =3D opendir(pci_device); > > + if (dir !=3D NULL) { > > + closedir(dir); > > + device_dir =3D true; > > + } > > + data.master =3D port_switch_id_set && (!port_name_set || > > device_dir); > > + data.representor =3D port_switch_id_set && port_name_set && > > !device_dir; > > *info =3D data; > > return 0; > > } > > diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c > > index > > d61826a..694edf1 100644 > > --- a/drivers/net/mlx5/mlx5_nl.c > > +++ b/drivers/net/mlx5/mlx5_nl.c > > @@ -65,6 +65,12 @@ > > #endif > > > > /* These are normally found in linux/if_link.h. */ > > +#ifndef HAVE_IFLA_NUM_VF > > +#define IFLA_NUM_VF 21 > > +#endif > > +#ifndef HAVE_IFLA_EXT_MASK > > +#define IFLA_EXT_MASK 29 > > +#endif > > #ifndef HAVE_IFLA_PHYS_SWITCH_ID > > #define IFLA_PHYS_SWITCH_ID 36 > > #endif > > @@ -836,6 +842,7 @@ struct mlx5_nl_ifindex_data { > > size_t off =3D NLMSG_LENGTH(sizeof(struct ifinfomsg)); > > bool port_name_set =3D false; > > bool switch_id_set =3D false; > > + bool num_vf_set =3D false; > > > > if (nh->nlmsg_type !=3D RTM_NEWLINK) > > goto error; > > @@ -848,6 +855,9 @@ struct mlx5_nl_ifindex_data { > > if (ra->rta_len > nh->nlmsg_len - off) > > goto error; > > switch (ra->rta_type) { > > + case IFLA_NUM_VF: > > + num_vf_set =3D true; > > + break; > > case IFLA_PHYS_PORT_NAME: > > errno =3D 0; > > info.port_name =3D strtol(payload, &end, 0); @@ - > > 867,8 +877,8 @@ struct mlx5_nl_ifindex_data { > > } > > off +=3D RTA_ALIGN(ra->rta_len); > > } > > - info.master =3D switch_id_set && !port_name_set; > > - info.representor =3D switch_id_set && port_name_set; > > + info.master =3D switch_id_set && (!port_name_set || num_vf_set); > > + info.representor =3D switch_id_set && port_name_set && > > !num_vf_set; > > memcpy(arg, &info, sizeof(info)); > > return 0; > > error: > > @@ -896,9 +906,13 @@ struct mlx5_nl_ifindex_data { > > struct { > > struct nlmsghdr nh; > > struct ifinfomsg info; > > + struct rtattr rta; > > + uint32_t extmask; > > } req =3D { > > .nh =3D { > > - .nlmsg_len =3D NLMSG_LENGTH(sizeof(req.info)), > > + .nlmsg_len =3D NLMSG_LENGTH > > + (sizeof(req.info) + > > + RTA_LENGTH(sizeof(uint32_t))), > > .nlmsg_type =3D RTM_GETLINK, > > .nlmsg_flags =3D NLM_F_REQUEST | NLM_F_ACK, > > }, > > @@ -906,6 +920,11 @@ struct mlx5_nl_ifindex_data { > > .ifi_family =3D AF_UNSPEC, > > .ifi_index =3D ifindex, > > }, > > + .rta =3D { > > + .rta_type =3D IFLA_EXT_MASK, > > + .rta_len =3D RTA_LENGTH(sizeof(int32_t)), > > + }, > > + .extmask =3D RTE_LE32(1), > > }; > > int ret; > > > > -- > > 1.8.3.1