From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id BC63BA00E6 for ; Thu, 21 Mar 2019 13:14:21 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 82FD31B4BB; Thu, 21 Mar 2019 13:14:21 +0100 (CET) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140083.outbound.protection.outlook.com [40.107.14.83]) by dpdk.org (Postfix) with ESMTP id D32D31B4B5 for ; Thu, 21 Mar 2019 13:14:19 +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=A420IEUevKS6LrLk49WH0J4jliGwHfHgH0Lpu040E6M=; b=qVsVjJhO9QaNkW10Qus5b4sdFwhoOPiL7p/5vLG+fBELH9s0phA+Mlg8shv6Pb0baXtqq7SZgCGmVymakpdCB4TDZwsiJfQvDbKi+DNfaVkkVIKTmzKwjuwF4XgnnIJWpG0Kj5cU6o7wmldeXVlX0GtN9yQpjIHam6lqWqYA3pI= Received: from AM0PR0502MB3795.eurprd05.prod.outlook.com (52.133.45.150) by AM0PR0502MB3827.eurprd05.prod.outlook.com (52.133.47.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.15; Thu, 21 Mar 2019 12:14:17 +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.1730.013; Thu, 21 Mar 2019 12:14:16 +0000 From: Shahaf Shuler To: Slava Ovsiienko , "dev@dpdk.org" Thread-Topic: [PATCH 03/14] net/mlx5: modify get ifindex routine for multiport IB Thread-Index: AQHU373Irn8J7JKOZ0+NU7QZU20LeaYVzNwA Date: Thu, 21 Mar 2019 12:14:16 +0000 Message-ID: References: <1551376985-11096-1-git-send-email-viacheslavo@mellanox.com> <1553155888-27498-1-git-send-email-viacheslavo@mellanox.com> <1553155888-27498-4-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1553155888-27498-4-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: [31.154.10.105] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e4207880-e778-4695-72d0-08d6adf6bd56 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:AM0PR0502MB3827; x-ms-traffictypediagnostic: AM0PR0502MB3827: x-microsoft-antispam-prvs: x-forefront-prvs: 0983EAD6B2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(346002)(39860400002)(136003)(376002)(189003)(199004)(81166006)(97736004)(33656002)(68736007)(74316002)(25786009)(7736002)(305945005)(110136005)(316002)(14454004)(2906002)(446003)(2501003)(52536014)(11346002)(476003)(71190400001)(256004)(86362001)(486006)(99286004)(186003)(5660300002)(66066001)(26005)(7696005)(53936002)(76176011)(102836004)(55016002)(9686003)(6436002)(71200400001)(229853002)(3846002)(8676002)(8936002)(81156014)(478600001)(6246003)(106356001)(6506007)(6116002)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3827; H:AM0PR0502MB3795.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:3; 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: nCUsKg63NlkMEiIEptmMXD/FfLrKkVdFxLxyPDG28/hmkG8HZsxnU6oLMrJd4ctxJWXZ1HkljhzWoqU+0iwVCIR0sHquDEhVZe4Jst8tImQJ6D+IG8+VoL4o692iYyHxQ1t8oQKdgOW/ugpqFGekwOZ3Wr7MaU9J5w/dyBfUb7u2ILh4/xAIil78VJBfAWF792OXSSl+uJ4NB1CBYcsa97L9tvMTR0hWPum3JKdX29BgLhVXYF03aDXCzBqvIcAVwqYPJhE+W+8qFgaSn5kLy8hJqKUlJqZ6klSo/NCF9YbIU6gW7iJouKNgqmiNXDwC6jUPCl7AlOSavmbJhJMS+u7E4i2eki7artPi7yYLZgqTVLaIu5Uk71bGKYVZO5qA3aKvvJCXMDRbFQxbwg95M1KTxfFdKB1IaW7rA5HPIV8= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4207880-e778-4695-72d0-08d6adf6bd56 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Mar 2019 12:14:16.8702 (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: AM0PR0502MB3827 Subject: Re: [dpdk-dev] [PATCH 03/14] net/mlx5: modify get ifindex routine for multiport IB 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190321121416.umP2n9Jx8UqBgO-4UDvPv6yo55L_Xt3tl5QW05NplZs@z> Thursday, March 21, 2019 10:11 AM, Viacheslav Ovsiienko: > Subject: [PATCH 03/14] net/mlx5: modify get ifindex routine for multiport= IB >=20 > There is the routine mlx5_nl_ifindex() returning the network interface in= dex > associated with Infiniband device. > We are going to support multiport IB devices, now function takes the IB p= ort > as argument and returns ifindex associated with tuple >=20 > Signed-off-by: Viacheslav Ovsiienko > --- > drivers/net/mlx5/mlx5.c | 2 +- > drivers/net/mlx5/mlx5.h | 2 +- > drivers/net/mlx5/mlx5_ethdev.c | 2 +- > drivers/net/mlx5/mlx5_nl.c | 20 +++++++++++++------- > 4 files changed, 16 insertions(+), 10 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index > ea3d00c..89c30af 100644 > --- a/drivers/net/mlx5/mlx5.c > +++ b/drivers/net/mlx5/mlx5.c > @@ -1441,7 +1441,7 @@ struct mlx5_dev_spawn_data { > list[i].ifindex =3D 0; > else > list[i].ifindex =3D mlx5_nl_ifindex > - (nl_rdma, list[i].ibv_dev->name); > + (nl_rdma, list[i].ibv_dev->name, 1); Why hardcoded to 1? > if (nl_route < 0 || > !list[i].ifindex || > mlx5_nl_switch_info(nl_route, list[i].ifindex, diff --git > a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index > 1716cd1..f5e29ca 100644 > --- a/drivers/net/mlx5/mlx5.h > +++ b/drivers/net/mlx5/mlx5.h > @@ -470,7 +470,7 @@ int mlx5_nl_mac_addr_remove(struct rte_eth_dev > *dev, struct ether_addr *mac, void mlx5_nl_mac_addr_flush(struct > rte_eth_dev *dev); int mlx5_nl_promisc(struct rte_eth_dev *dev, int > enable); int mlx5_nl_allmulti(struct rte_eth_dev *dev, int enable); - > unsigned int mlx5_nl_ifindex(int nl, const char *name); > +unsigned int mlx5_nl_ifindex(int nl, const char *name, uint32_t > +pindex); > int mlx5_nl_switch_info(int nl, unsigned int ifindex, > struct mlx5_switch_info *info); >=20 > diff --git a/drivers/net/mlx5/mlx5_ethdev.c > b/drivers/net/mlx5/mlx5_ethdev.c index 81f2a42..5b44889 100644 > --- a/drivers/net/mlx5/mlx5_ethdev.c > +++ b/drivers/net/mlx5/mlx5_ethdev.c > @@ -222,7 +222,7 @@ struct ethtool_link_settings { > struct mlx5_priv *priv =3D dev->data->dev_private; > unsigned int ifindex =3D > priv->nl_socket_rdma >=3D 0 ? > - mlx5_nl_ifindex(priv->nl_socket_rdma, priv->ibdev_name) : > 0; > + mlx5_nl_ifindex(priv->nl_socket_rdma, priv->ibdev_name, > 1) : 0; >=20 > if (!ifindex) { > if (!priv->representor) > diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c inde= x > aa49cb4..6e9145a 100644 > --- a/drivers/net/mlx5/mlx5_nl.c > +++ b/drivers/net/mlx5/mlx5_nl.c > @@ -85,11 +85,12 @@ struct mlx5_nl_mac_addr { > int mac_n; /**< Number of addresses in the array. */ }; >=20 > -/** Data structure used by mlx5_nl_ifindex_cb(). */ > +/** Data structure used by mlx5_nl_cmdget_cb(). */ > struct mlx5_nl_ifindex_data { > const char *name; /**< IB device name (in). */ > uint32_t ibindex; /**< IB device index (out). */ > uint32_t ifindex; /**< Network interface index (out). */ > + uint32_t portnum; /**< IB device max port number. */ What happen w/ old kernel which don't support it? the portnum is ignored?=20 > }; >=20 > /** > @@ -695,12 +696,13 @@ struct mlx5_nl_ifindex_data { > * 0 on success, a negative errno value otherwise and rte_errno is set= . > */ > static int > -mlx5_nl_ifindex_cb(struct nlmsghdr *nh, void *arg) > +mlx5_nl_cmdget_cb(struct nlmsghdr *nh, void *arg) > { > struct mlx5_nl_ifindex_data *data =3D arg; > size_t off =3D NLMSG_HDRLEN; > uint32_t ibindex =3D 0; > uint32_t ifindex =3D 0; > + uint32_t portnum =3D 0; > int found =3D 0; >=20 > if (nh->nlmsg_type !=3D > @@ -725,6 +727,9 @@ struct mlx5_nl_ifindex_data { > case RDMA_NLDEV_ATTR_NDEV_INDEX: > ifindex =3D *(uint32_t *)payload; > break; > + case RDMA_NLDEV_ATTR_PORT_INDEX: > + portnum =3D *(uint32_t *)payload; > + break; > default: > break; > } > @@ -733,6 +738,7 @@ struct mlx5_nl_ifindex_data { > if (found) { > data->ibindex =3D ibindex; > data->ifindex =3D ifindex; > + data->portnum =3D portnum; > } > return 0; > error: > @@ -751,15 +757,15 @@ struct mlx5_nl_ifindex_data { > * Netlink socket of the RDMA kind (NETLINK_RDMA). > * @param[in] name > * IB device name. > - * > + * @param[in] pindex > + * IB device port index, starting from 1 > * @return > * A valid (nonzero) interface index on success, 0 otherwise and rte_e= rrno > * is set. > */ > unsigned int > -mlx5_nl_ifindex(int nl, const char *name) > +mlx5_nl_ifindex(int nl, const char *name, uint32_t pindex) > { > - static const uint32_t pindex =3D 1; > uint32_t seq =3D random(); > struct mlx5_nl_ifindex_data data =3D { > .name =3D name, > @@ -785,7 +791,7 @@ struct mlx5_nl_ifindex_data { > ret =3D mlx5_nl_send(nl, &req.nh, seq); > if (ret < 0) > return 0; > - ret =3D mlx5_nl_recv(nl, seq, mlx5_nl_ifindex_cb, &data); > + ret =3D mlx5_nl_recv(nl, seq, mlx5_nl_cmdget_cb, &data); > if (ret < 0) > return 0; > if (!data.ibindex) > @@ -808,7 +814,7 @@ struct mlx5_nl_ifindex_data { > ret =3D mlx5_nl_send(nl, &req.nh, seq); > if (ret < 0) > return 0; > - ret =3D mlx5_nl_recv(nl, seq, mlx5_nl_ifindex_cb, &data); > + ret =3D mlx5_nl_recv(nl, seq, mlx5_nl_cmdget_cb, &data); > if (ret < 0) > return 0; > if (!data.ifindex) > -- > 1.8.3.1