From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40043.outbound.protection.outlook.com [40.107.4.43]) by dpdk.org (Postfix) with ESMTP id 43D9C2C18 for ; Thu, 7 Mar 2019 09:44:10 +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=TC+xiZfkV3oeJvdOTlKDOn0oY11SNNnxDNY5NM8QHaA=; b=sTscMsTQ/55JW46ZH4PfVZ1YC7LD6oi44EKX3pRq5VsjtnNb1G1rN3Pv9aFTBPkUMJ3agh2VdMUS82VTh7Vu8Be/gSFymKtw9nXXAQdkiJqWqlUN5o3RMzoKpn3gNOZTTM2ldqN8FAdr/XP3uAPcmnkpy0yiBDflJyucyp9tZ18= Received: from AM0PR0502MB3795.eurprd05.prod.outlook.com (52.133.45.150) by AM0PR0502MB4035.eurprd05.prod.outlook.com (52.133.36.138) 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 08:44:08 +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:44:08 +0000 From: Shahaf Shuler To: Slava Ovsiienko CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v2 1/1] net/mlx5: add representor recognition on kernels 5.x Thread-Index: AQHUzPl+k9g2FcwRnkKzE1JGgDSo66X/3Cag Date: Thu, 7 Mar 2019 08:44:08 +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: <1551092489-12247-1-git-send-email-viacheslavo@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: 1ce8a4cd-9a7d-4ae3-a11e-08d6a2d91046 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:AM0PR0502MB4035; x-ms-traffictypediagnostic: AM0PR0502MB4035: x-ms-exchange-purlcount: 2 x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; AM0PR0502MB4035; 23:mm1Om+qJ15cVfSKHXjwKXlQGO1xpztiuLIzs2vv?= =?us-ascii?Q?Lo2bAvnEAs/z0gnKoz7nplMRcXIQXZr3fFp3OFT+8RefwL7YVwdVFuZphOvm?= =?us-ascii?Q?f6Ny0uZfwa8iAYWiK3pV2ttbXgDsFgSkMLBUaBvuyJJ+UG9jP7pB5ESVyg60?= =?us-ascii?Q?yB7tMcmGwGqsSYDsl2Ki9euD4A0qjFNh1w3cFLUN6+j0y6H7baICB0yMfFru?= =?us-ascii?Q?vfMf8DaNi0e8eLUTsY5BFkYt3f2gMKeW+CyAbepU0CztKZbg5nSLbS2mcfr8?= =?us-ascii?Q?G1RrivRNr+I07Sno+YXLCSmVWvpFqYoRbpH/X8NnxTu3cO4qEDO7+9i3PtFF?= =?us-ascii?Q?a8rD0tyYgjnsPRkShyahJWc04qvI7qdPk2RwDrkM5NpRh8WR21om23eb/37R?= =?us-ascii?Q?IUilUUBegbuD3i6BpEbZ8GUU7TsVVlVm031w/Qd5v7soAFtMqY1jhsJ4JgGJ?= =?us-ascii?Q?E8iXDJx+dXoR7zcqNLjNxKGWZNAvRKGQEuVzh+u3BgwT3ZdA7fZTPp2qfad5?= =?us-ascii?Q?rpaQwDrgDBFFrzkMRgsOwvOF7RR1BtI61qMavOZzermBLtUz0uVQts9ym6Bt?= =?us-ascii?Q?gglrcQjMETv92+yqkAvi6k0hvjWPu2MGALfxZAAZoVqufvz84MkukCitEHqb?= =?us-ascii?Q?8kR5cucbLAXeGHqYBCLJmHDQWlwwxe+RajmwDY81pNMNFiP6fPGVske+KQO0?= =?us-ascii?Q?jx7yotMBB+VfKpnEuQCTmsx+XQpywMhyUP+8mG1TRAYdbIYs6HGWR5wDJ11I?= =?us-ascii?Q?gjsQ/8YM/vKiCd7GHEpXjYeA7lfMl6abnhSpJ8C8pqlWWFf6IMpMdJWWNuHW?= =?us-ascii?Q?xCDZ9X3Ij6n1iblLIy5Z3fragMslEGIghoquhta9+q2Dsd+AKrHniznXlx3c?= =?us-ascii?Q?zK35yUMmAjApSVd49cE1pjEcIsaXMMVhJPjYjirruq4FiZ0joTLCWqQQsSmp?= =?us-ascii?Q?QviHO6kTmssXdnmzAamsoQztmd4QE7AmebRhTcRL4KmRcNvazTlMMrmQ1C7a?= =?us-ascii?Q?mn+Q9UnAZQs6QgjFkEvXq+4lO6TceRt+febB32rmhU6vxLA9dddvfhwgbDIY?= =?us-ascii?Q?mBynSuewS9PybuQGbNqgNi/nUvvgxRV1yCEGT3lDvSZu8k9ErZOVQgWGZ0T6?= =?us-ascii?Q?hO/pnYULVJ6pDVP/nvjqVbL7kCJ1CBajtXv1ikb4uAOu6+nIEPz99PYUW2vh?= =?us-ascii?Q?u+JmVr651jRDfYxwnZr8zfMfQW3/M02fVjqN9XSSgahLs/lRds8pO1ijmqEW?= =?us-ascii?Q?J90/zgfixBPlkFdjN4oZCpCr9nmyrlfv/8vpA5VhO?= x-microsoft-antispam-prvs: x-forefront-prvs: 096943F07A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(376002)(366004)(136003)(346002)(189003)(199004)(86362001)(305945005)(26005)(102836004)(14454004)(316002)(11346002)(446003)(7736002)(14444005)(7696005)(186003)(25786009)(99286004)(256004)(478600001)(97736004)(45080400002)(2906002)(5660300002)(966005)(76176011)(66066001)(6636002)(55016002)(6306002)(9686003)(33656002)(53936002)(6436002)(6116002)(52536013)(6506007)(74316002)(476003)(486006)(106356001)(105586002)(8936002)(71200400001)(68736007)(71190400001)(81156014)(6246003)(81166006)(229853002)(6862004)(3846002)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB4035; H:AM0PR0502MB3795.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: akWKObxpaBBCfZnzyfyb2vIHl/aLBjMuMdTTv1IfxBvja/BYWUahsqc1IqhqGHGerMflULFRYLlHWlo18jccXUz26IwgUkdT4gHInWdf2q7Iv9+meDWAnZoTfrgm7zmEMdlhxD0qpmDFXJcrgoO4RfO7HTLfuOe9wQWVuLwZTPj+JkFPx2jCBhJ+QBHYobduZjkNmNNjzyY09lGP/CBIkhaYMAvLAIvhtjp0yhyMyZRrrkmsk9NvW0ZqKjVUti6h6s/I36K39Kldim4RdYZz7RK9vbKTlSUcKEfCQod641rTaXi3DK9QZx2Aq5uF6Bxs0ccW2a1CuOaw6OQ1Y8BGSeH1ydYyapSIMgObDrEZD9wZ2Vhd1Tj+SDBbFlqHcfL7MNJWi9iLuOuP8d9E8DvtILF6JxBGJ5n0teG2Ymw9WMY= 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: 1ce8a4cd-9a7d-4ae3-a11e-08d6a2d91046 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Mar 2019 08:44:08.2189 (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: AM0PR0502MB4035 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 08:44:10 -0000 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 >=20 > 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. >=20 > The IFLA_NUM_VF attribute is returned by kernel if IFLA_EXT_MASK > attribute is specified in the Netlink request message. >=20 > Also the presence of device symlink in device sysfs folder is added to > distinguish representors with sysfs based method. 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 represen= tor?=20 There is already patch for it from Dekel: https://patches.dpdk.org/patch/50771/ >=20 > Signed-off-by: Viacheslav Ovsiienko >=20 > --- > v2: > fopen is replaced with opendir to detect whether directory exists >=20 > v1: >=20 > 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%7Ca652971c7d2e4d9b > a6a4d149256f461b%7C0%7C0%7C636866893031018956&sdata=3DjftQKX8B > 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(-) >=20 > 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; >=20 > 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); >=20 > 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 inde= x > d61826a..694edf1 100644 > --- a/drivers/net/mlx5/mlx5_nl.c > +++ b/drivers/net/mlx5/mlx5_nl.c > @@ -65,6 +65,12 @@ > #endif >=20 > /* 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; >=20 > 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; >=20 > -- > 1.8.3.1