From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <shahafs@mellanox.com>
Received: from EUR01-HE1-obe.outbound.protection.outlook.com
 (mail-he1eur01on0059.outbound.protection.outlook.com [104.47.0.59])
 by dpdk.org (Postfix) with ESMTP id F355C1B518
 for <dev@dpdk.org>; Sun, 17 Jun 2018 12:14:59 +0200 (CEST)
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=4mkxlwFit+2WAVHKX14x1LqYbTt6NB6d2ma4RRhvwGY=;
 b=wgrBy+2y/RRmtG1VCNx0qbyr657dLUnilxk7w2gTb8Vi2wHioCTPH+8BxV0SPQE+TUxTwgxdvVrMnKHciPLkjuMyl8cXgXeOueVUHl4QL1RnBJJD2d1dLwk/zihGmhh2ZZxHYBRfHx/wT5TmeZTr3kLHzqwsQSnnG5g9XPTANXM=
Received: from DB7PR05MB4426.eurprd05.prod.outlook.com (52.134.109.15) by
 DB7PR05MB4170.eurprd05.prod.outlook.com (52.134.107.151) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.863.19; Sun, 17 Jun 2018 10:14:58 +0000
Received: from DB7PR05MB4426.eurprd05.prod.outlook.com
 ([fe80::4c94:2db9:b8c5:cc6b]) by DB7PR05MB4426.eurprd05.prod.outlook.com
 ([fe80::4c94:2db9:b8c5:cc6b%4]) with mapi id 15.20.0863.016; Sun, 17 Jun 2018
 10:14:58 +0000
From: Shahaf Shuler <shahafs@mellanox.com>
To: Adrien Mazarguil <adrien.mazarguil@6wind.com>
CC: "dev@dpdk.org" <dev@dpdk.org>
Thread-Topic: [PATCH v2 3/7] net/mlx5: split PCI from generic probing code
Thread-Index: AQHUA7qckXlwJHF2u0yRuR5SKsHC56RkKoDg
Date: Sun, 17 Jun 2018 10:14:58 +0000
Message-ID: <DB7PR05MB4426658A7B634342D0739177C3720@DB7PR05MB4426.eurprd05.prod.outlook.com>
References: <20180525161814.13873-1-adrien.mazarguil@6wind.com>
 <20180614083047.10812-1-adrien.mazarguil@6wind.com>
 <20180614083047.10812-4-adrien.mazarguil@6wind.com>
In-Reply-To: <20180614083047.10812-4-adrien.mazarguil@6wind.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-microsoft-exchange-diagnostics: 1; DB7PR05MB4170;
 7:TsFCf3gBXRCswa415Jy6iHklKMsJ1f6nCefzSrEUQm/+ZcPbm6wDow7WA0+MYugErJ+4fqukekMPj29Sw0fDAY+JWhyULDVudCuFzQB3VLg5K3azzBdnHT/Jg6lZkEHFMs4DbC9whuWar1bYbMUJuQQVXfoOCh9vynVFysLCXQ+b9Yzx+6cirr18V3PpFJiDnpFs6PmRbYlblGfaqyFokyhPSPvS6xFhuxt+dBwpM7n8R/fcXq65va+7RICNwgb6
x-ms-exchange-antispam-srfa-diagnostics: SOS;
x-ms-office365-filtering-correlation-id: b8b3c505-8bf7-46db-1983-08d5d43b2e52
x-ms-office365-filtering-ht: Tenant
x-microsoft-antispam: UriScan:; BCL:0; PCL:0;
 RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(48565401081)(2017052603328)(7153060)(7193020);
 SRVR:DB7PR05MB4170; 
x-ms-traffictypediagnostic: DB7PR05MB4170:
x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr
x-microsoft-antispam-prvs: <DB7PR05MB4170ED16712EE8AC469C23B5C3720@DB7PR05MB4170.eurprd05.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:;
x-ms-exchange-senderadcheck: 1
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0;
 RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016);
 SRVR:DB7PR05MB4170; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4170; 
x-forefront-prvs: 07063A0A30
x-forefront-antispam-report: SFV:NSPM;
 SFS:(10009020)(39860400002)(346002)(39380400002)(396003)(376002)(366004)(199004)(189003)(53936002)(6916009)(81166006)(81156014)(6436002)(8936002)(86362001)(6246003)(229853002)(8676002)(478600001)(105586002)(305945005)(106356001)(316002)(9686003)(97736004)(74316002)(5660300001)(55016002)(14454004)(7736002)(25786009)(26005)(33656002)(4326008)(2900100001)(76176011)(6506007)(3660700001)(476003)(11346002)(486006)(2906002)(102836004)(59450400001)(66066001)(7696005)(6116002)(3280700002)(68736007)(446003)(5250100002)(186003)(99286004)(3846002)(41533002);
 DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4170;
 H:DB7PR05MB4426.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-microsoft-antispam-message-info: UBU7FIBbQ/iqPx1WPH9LHNxjvFu9b+Z+YOkTd0+5M/j4+09N/bU9UgHcDUali5BFop/5mLhGusg85EZ36w5Bk0KzGb7/M/YnXwLPcneQSP8FJWFFmCW+zGlRZrb5/xt+XHKDgruTdgfzw0DNmxWt8CtVQqSXVyo2NaZrdpxWrLYjiQL3GjcluMnE8p9euMgj
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
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: b8b3c505-8bf7-46db-1983-08d5d43b2e52
X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jun 2018 10:14:58.7459 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4170
Subject: Re: [dpdk-dev] [PATCH v2 3/7] net/mlx5: split PCI from generic
	probing code
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Sun, 17 Jun 2018 10:15:00 -0000

Thursday, June 14, 2018 11:35 AM, Adrien Mazarguil:
> Subject: [PATCH v2 3/7] net/mlx5: split PCI from generic probing code
>=20
> All the generic probing code needs is an IB device. While this device is
> currently supplied by a PCI lookup, other methods will be added soon.
>=20
> This patch divides the original function, which has become huge over time=
, as
> follows:
>=20
> 1. PCI-specific (mlx5_pci_probe()).
> 2. All ports of a Verbs device (mlx5_dev_spawn()).
> 3. A given port of a Verbs device (mlx5_dev_spawn_one()).
>=20
> (Patch based on prior work from Yuanhan Liu)
>=20
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> --
> v2 changes:
>=20
> - Fixed device naming. A port suffix is now appended only if several IB
>   ports happen to be detected.
> - Added separate message to distinguish missing kernel drivers from other
>   initialization errors, as it was confusing.

[...]

> +/**
> + * DPDK callback to register a PCI device.
> + *
> + * This function creates an Ethernet device for each port of a given
> + * PCI device.
> + *
> + * @param[in] pci_drv
> + *   PCI driver structure (mlx5_driver).
> + * @param[in] pci_dev
> + *   PCI device information.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set=
.
> + */
> +static int
> +mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
> +	       struct rte_pci_device *pci_dev) {
> +	struct ibv_device **ibv_list;
> +	struct rte_eth_dev **eth_list =3D NULL;
> +	int vf;
> +	int ret;
> +
> +	assert(pci_drv =3D=3D &mlx5_driver);
> +	switch (pci_dev->id.device_id) {
> +	case PCI_DEVICE_ID_MELLANOX_CONNECTX4VF:
> +	case PCI_DEVICE_ID_MELLANOX_CONNECTX4LXVF:
> +	case PCI_DEVICE_ID_MELLANOX_CONNECTX5VF:
> +	case PCI_DEVICE_ID_MELLANOX_CONNECTX5EXVF:
> +		vf =3D 1;
> +		break;
> +	default:
> +		vf =3D 0;
> +	}

Even though I couldn't find any functional bug, I think it is logically mor=
e correct to determine if pci device is vf after we know this is Mellanox d=
evice.=20
Meaning the above block should be ...

> +	errno =3D 0;
> +	ibv_list =3D mlx5_glue->get_device_list(&ret);
> +	if (!ibv_list) {
> +		rte_errno =3D errno ? errno : ENOSYS;
> +		DRV_LOG(ERR, "cannot list devices, is ib_uverbs loaded?");
>  		return -rte_errno;
>  	}
> -	return 0;
> +	while (ret-- > 0) {
> +		struct rte_pci_addr pci_addr;
> +
> +		DRV_LOG(DEBUG, "checking device \"%s\"", ibv_list[ret]-
> >name);
> +		if (mlx5_ibv_device_to_pci_addr(ibv_list[ret], &pci_addr))
> +			continue;
> +		if (pci_dev->addr.domain !=3D pci_addr.domain ||
> +		    pci_dev->addr.bus !=3D pci_addr.bus ||
> +		    pci_dev->addr.devid !=3D pci_addr.devid ||
> +		    pci_dev->addr.function !=3D pci_addr.function)
> +			continue;
> +		DRV_LOG(INFO, "PCI information matches, using device
> \"%s\"",
> +			ibv_list[ret]->name);
> +		break;
> +	}

Here.=20

> +	if (ret >=3D 0)
> +		eth_list =3D mlx5_dev_spawn(&pci_dev->device, ibv_list[ret],
> vf);
> +	mlx5_glue->free_device_list(ibv_list);
> +	if (!ret) {
> +		DRV_LOG(WARNING,
> +			"no Verbs device matches PCI device " PCI_PRI_FMT
> ","
> +			" are kernel drivers loaded?",
> +			pci_dev->addr.domain, pci_dev->addr.bus,
> +			pci_dev->addr.devid, pci_dev->addr.function);
> +		rte_errno =3D ENOENT;
> +		ret =3D -rte_errno;
> +	} else if (!eth_list || !*eth_list) {
> +		DRV_LOG(ERR,
> +			"probe of PCI device " PCI_PRI_FMT " aborted after"
> +			" encountering an error: %s",
> +			pci_dev->addr.domain, pci_dev->addr.bus,
> +			pci_dev->addr.devid, pci_dev->addr.function,
> +			strerror(rte_errno));
> +		ret =3D -rte_errno;
> +	} else {
> +		for (ret =3D 0; eth_list[ret]; ++ret) {
> +			rte_eth_copy_pci_info(eth_list[ret], pci_dev);
> +			rte_eth_dev_probing_finish(eth_list[ret]);
> +		}
> +		ret =3D 0;
> +	}
> +	free(eth_list);
> +	return ret;
>  }
>=20
>  static const struct rte_pci_id mlx5_pci_id_map[] =3D {
> --
> 2.11.0