From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ophirmu@mellanox.com>
Received: from EUR01-VE1-obe.outbound.protection.outlook.com
 (mail-ve1eur01on0064.outbound.protection.outlook.com [104.47.1.64])
 by dpdk.org (Postfix) with ESMTP id 44BE34D27
 for <dev@dpdk.org>; Thu, 13 Sep 2018 08:29:41 +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=8Hg5aAYhcv60kkR7tvjq7qPYnJaXWRfhU0uiKq/pAUA=;
 b=rCjGgNqNucG7Y1LyGZr2Xpz1Dk+n0PDiWg0pz7511cOrkQ3scUcNnPb5wyCYvNqzB5eL+IoV6VXOAB0Z1W9IdqTLjBBq7iJua74IFyzasF99Vgp6ATzByKP0c3AFNN+42H1EOjWUNtYS5wrTHFnZ/uzj1hoqyAIQoUQ8fFs1gc4=
Received: from VI1PR0502MB3743.eurprd05.prod.outlook.com (52.134.8.154) by
 VI1PR0502MB4016.eurprd05.prod.outlook.com (52.134.18.139) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.1122.15; Thu, 13 Sep 2018 06:29:39 +0000
Received: from VI1PR0502MB3743.eurprd05.prod.outlook.com
 ([fe80::29c9:a95f:afaf:1b95]) by VI1PR0502MB3743.eurprd05.prod.outlook.com
 ([fe80::29c9:a95f:afaf:1b95%2]) with mapi id 15.20.1122.018; Thu, 13 Sep 2018
 06:29:39 +0000
From: Ophir Munk <ophirmu@mellanox.com>
To: Thomas Monjalon <thomas@monjalon.net>, "dev@dpdk.org" <dev@dpdk.org>
CC: "gaetan.rivet@6wind.com" <gaetan.rivet@6wind.com>, Olga Shern
 <olgas@mellanox.com>, Shahaf Shuler <shahafs@mellanox.com>, Asaf Penso
 <asafp@mellanox.com>
Thread-Topic: [dpdk-dev] [RFC] eal: allow hotplug to skip an already probed
 device
Thread-Index: AQHURv/v7ja+NYglY0Cgqh67kq59O6Ttx6Fw
Date: Thu, 13 Sep 2018 06:29:39 +0000
Message-ID: <VI1PR0502MB37432D841E4B2FEA47689F48D11A0@VI1PR0502MB3743.eurprd05.prod.outlook.com>
References: <20180907230958.21402-1-thomas@monjalon.net>
In-Reply-To: <20180907230958.21402-1-thomas@monjalon.net>
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=ophirmu@mellanox.com; 
x-originating-ip: [89.138.189.162]
x-ms-publictraffictype: Email
x-microsoft-exchange-diagnostics: 1; VI1PR0502MB4016;
 6:p2Zg3g5hWN/vgtU6rG1kxIEj5vZhy6v+kpN9Ip03qaRrJt/S6wgXS3NAzf0VC+vwZPwFNChHUQUazH0P1TDC1ASknHss2XFbgSjDfNzzbqUU8+UTKslf8ZAT/wafhx9GuuqTJS1ymf9lRV6957hVnbzAopNJxCAdevDgpte0qIF/UMkrtxOLdRm+B3r3ng0iWEJzcD+C+MxbvOBccWuinJQTCzHkN8sOilgIgwEsx+E08htJg7XdgJXF/1ZLN+XjsvtVgsG3lC+HdjUdmhlLo06SyBr830U4zn4OseG8O7zid0MR86h4FmC3h6sWE6p7QaJa0GiRBXo/rSmrzescA3VSMjZw3lZhxnv0L1aB4edvZuc70qh44xqm4yBPn9bHZUDkbrkLdbR7PAxTknYCc7y0FAjb47RMTtsraURxtzHQk+iWSjM1Jilb2vb3Da3go/Y7MAYAyBN5sgvkSWpYJw==;
 5:f5Yycq6YMVkHB1SWHfgXSGE6XUlpzUGZhAViiou9ucrZ3JEC6p197P05298aX4xZIzBT/wQmhUtFbIkpECiq2ATOKmFTjfk1lb7N+FOgDBj+jDHBha4RARLG5w69yBEnQIGeJNxp/1uuUVHALvTkEyubrMAaqsmzYDjwLs01DLc=;
 7:87cUo4U8miC92Jr6bxrkEvEv1rwb1/hM0WnJ7YWmXn+rAPf+F8K+iC4c8xPmExXcXmCxZFUvcs5fzwFmkS+581SsTAkR2ENYDqEK7jLTGzscITjLHPJjcz9/ZkemWn/A3WMcDWTkzpaYZdUrX+lIYo/XnNLSoTE9PBce9kj5I93mmtzINF+IPmqrkmT+MryKyRpMBJYE+5n+r0ggZEiyk176oa2IS+myKdTyyLLRq9nYjGD3FyrEmWjTC5QV3NEX
x-ms-exchange-antispam-srfa-diagnostics: SOS;
x-ms-office365-filtering-correlation-id: 8e1532c8-c7ae-4476-b933-08d6194248c0
x-ms-office365-filtering-ht: Tenant
x-microsoft-antispam: BCL:0; PCL:0;
 RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);
 SRVR:VI1PR0502MB4016; 
x-ms-traffictypediagnostic: VI1PR0502MB4016:
x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr
x-microsoft-antispam-prvs: <VI1PR0502MB4016C88B4860AEA6D64EC058D11A0@VI1PR0502MB4016.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)(5005006)(8121501046)(823301075)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201708071742011)(7699050);
 SRVR:VI1PR0502MB4016; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0502MB4016; 
x-forefront-prvs: 07943272E1
x-forefront-antispam-report: SFV:NSPM;
 SFS:(10009020)(366004)(346002)(396003)(376002)(39860400002)(136003)(13464003)(189003)(199004)(486006)(99286004)(25786009)(316002)(54906003)(110136005)(6246003)(97736004)(107886003)(7736002)(3846002)(33656002)(6116002)(305945005)(4326008)(7696005)(76176011)(2501003)(26005)(53546011)(229853002)(5250100002)(55016002)(102836004)(6436002)(53936002)(74316002)(476003)(2900100001)(256004)(14444005)(11346002)(446003)(9686003)(68736007)(66066001)(81156014)(5660300001)(81166006)(6506007)(186003)(14454004)(86362001)(8936002)(8676002)(2906002)(478600001)(106356001)(105586002);
 DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0502MB4016;
 H:VI1PR0502MB3743.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-microsoft-antispam-message-info: DZfsZhS1JqsWilSUWyzMvwFyckfsTfGdSgwVaZ0rtCFz5MFwWX/QD5Ed9bay3tmysKc+jEa7lC98Z0cikkjKqpOlR9gHiD/Nk9sWJmUIAIziKejlHcx5LahB7FXsPY5+0uavYQi+ebqJ/KYoQLCVKicCHZnJDBvlbSyU28AZIx2pGET8zybbBQB+6iRJpIEN0cif4k3a2ubtS5aJQNJCvsMLwWGcxODpiCzHIEUEMCMUDODF/ZC1FZWzRijGwCjUEh3v3wi/YHPeHeg8JSPiqPYncB3gY6iCQa4BJR1N186XuLxkHQHPfGrmW6wmQEZNO0bLV68v7XjZ1NLYYNWFm0vvFvfLQfgAFxQAJkEkHT0=
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: 8e1532c8-c7ae-4476-b933-08d6194248c0
X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Sep 2018 06:29:39.7128 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b
X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB4016
Subject: Re: [dpdk-dev] [RFC] eal: allow hotplug to skip an already probed
 device
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: Thu, 13 Sep 2018 06:29:42 -0000



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Saturday, September 08, 2018 2:10 AM
> To: dev@dpdk.org
> Cc: gaetan.rivet@6wind.com
> Subject: [dpdk-dev] [RFC] eal: allow hotplug to skip an already probed de=
vice
>=20
> In the devargs syntax for device representors, it is possible to add seve=
ral
> devices at once: -w dbdf,representor=3D[0-3] It will become a more freque=
nt
> case when introducing wildcards and ranges in the new devargs syntax.
>=20
> If a devargs string is provided for probing, and updated with a bigger ra=
nge
> for a new probing, then we do not want it to fail because part of this ra=
nge
> was already probed previously.
>=20

When having devargs with representors ("dbdf,representor=3D<args>") there i=
s actually just one PCI device to probe (whose address is "dbdf", the maste=
r) while the representors themselves are net devices all using the same PCI=
 "dbdf" address.=20
The way to see it: when running "lspci": only the "dpdf" PCI device appears=
 while when executing "ifconfig" - all representors are shown as net device=
s.
When calling rte_eal_hotplug_add() for the first time there is a flow which=
 eventually calls the PMD probe callback (e.g. mlx5_pci_probe() in case of =
mlx5 PMD).=20
When calling rte_eal_hotplug_add() for several times we should skip failure=
s till we reach the PMD probe callback.

Skipping failures can be done as follows:
1. In file ./lib/librte_eal/common/eal_common_dev.c, function: rte_eal_hotp=
lug_add(), remove the following code:

if (dev->driver !=3D NULL) {
	RTE_LOG(ERR, EAL, "Device is already plugged\n");
	return -EEXIST}

2. In file ./drivers/bus/pci/pci_common.cm function: pci_probe_all_drivers(=
), remove the following code:

/* Check if a driver is already loaded */ if (dev->driver !=3D NULL)
	return -1;


However the substantial major changes are in each individual PMD probe call=
back when it is called several times with different devargs. For example it=
 should not fail an already probed PCI device and just create new eth devic=
es for new representors.


> On the opposite, we could require rte_eal_hotplug_add() to try to add all
> matching devices, and fail if one is already probed.
>=20
> That's why a new parameter is added to specify if the function must fail =
or
> not when trying to add an already probed device.
>=20

Please note this new parameter ("fail_existing") will have to be propagated=
 to all PMD probe callbacks.
Otherwise, in case (fail_existing =3D=3D false) a second call to rte_eal_ho=
tplug_add() will call the PMD probe callback, which may fail unless it is a=
ware of "fail_existing" parameter.
Alternatively "fail_existing" may be better named "enable_multi_probes".
Anyway - if the PMD probe() callback has to be updated to return a success/=
failure value (for more than one probe) - maybe we do not need a new parame=
ter and can rely on the PMD probe() callback the take the decision by retur=
ning success/failure value.

The counter part of rte_eal_hotplug_add() is rte_eal_hotplug_remove() which=
 must be updated as well. For example when representors 1 and 2 exist - the=
n removing just representor 1 will have to make sure that the PCI device us=
ed for both representors is not unplugged since representor 2 is not remove=
d and it uses the same PCI device as representor 1.

> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> This patch contains only the change in the function itself as RFC.
>=20
> This idea was presented at Dublin during the "hotplug talk".
> ---
>  lib/librte_eal/common/eal_common_dev.c  | 4 +++-
> lib/librte_eal/common/include/rte_dev.h | 5 ++++-
>  2 files changed, 7 insertions(+), 2 deletions(-)
>=20
> diff --git a/lib/librte_eal/common/eal_common_dev.c
> b/lib/librte_eal/common/eal_common_dev.c
> index 678dbcac7..17d7e9089 100644
> --- a/lib/librte_eal/common/eal_common_dev.c
> +++ b/lib/librte_eal/common/eal_common_dev.c
> @@ -128,7 +128,7 @@ int rte_eal_dev_detach(struct rte_device *dev)  }
>=20
>  int __rte_experimental rte_eal_hotplug_add(const char *busname, const
> char *devname,
> -			const char *devargs)
> +			const char *devargs, bool fail_existing)
>  {
>  	struct rte_bus *bus;
>  	struct rte_device *dev;
> @@ -173,6 +173,8 @@ int __rte_experimental rte_eal_hotplug_add(const
> char *busname, const char *devn
>  	}
>=20
>  	if (dev->driver !=3D NULL) {
> +		if (!fail_existing)
> +			return 0;
>  		RTE_LOG(ERR, EAL, "Device is already plugged\n");
>  		return -EEXIST;
>  	}
> diff --git a/lib/librte_eal/common/include/rte_dev.h
> b/lib/librte_eal/common/include/rte_dev.h
> index b80a80598..10a1cd2b4 100644
> --- a/lib/librte_eal/common/include/rte_dev.h
> +++ b/lib/librte_eal/common/include/rte_dev.h
> @@ -201,11 +201,14 @@ int rte_eal_dev_detach(struct rte_device *dev);
>   *   capable of handling it and pass it to the driver probing function.
>   * @param devargs
>   *   Device arguments to be passed to the driver.
> + * @param fail_existing
> + *   If true and a matching device is already probed, then return -EEXIS=
T.
> + *   If false, then skip the already probed device without returning an =
error.
>   * @return
>   *   0 on success, negative on error.
>   */
>  int __rte_experimental rte_eal_hotplug_add(const char *busname, const
> char *devname,
> -			const char *devargs);
> +			const char *devargs, bool fail_existing);
>=20
>  /**
>   * @warning
> --
> 2.18.0