From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30057.outbound.protection.outlook.com [40.107.3.57]) by dpdk.org (Postfix) with ESMTP id 4A0EC4CBB for ; Thu, 13 Sep 2018 00:50:14 +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=kv+mSuj1QFVt8dGQi8HMZNo2FwjBYJw12Oddfq8zzfo=; b=FZntNDzIpfSaq7wYQLd4UVf73nVkxlFBO89u7ZiYSMhr3KI+8VY1vLwpaiEepfxiBE1trBHlkWiSVWSpcfGCgOwNU56S0JDVHLoKzu6IImAxEPQNSjXV9IvxCRMMKTKhTtmcJaYyDkqAOD1kv2bsoNeodNafDNKx4SnA2Y91ntc= Received: from VI1PR0502MB3743.eurprd05.prod.outlook.com (52.134.8.154) by VI1PR0502MB3853.eurprd05.prod.outlook.com (52.134.9.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Wed, 12 Sep 2018 22:50:12 +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; Wed, 12 Sep 2018 22:50:12 +0000 From: Ophir Munk To: "dev@dpdk.org" , Gaetan Rivet CC: Olga Shern , Thomas Monjalon , Shahaf Shuler , Asaf Penso Thread-Topic: [dpdk-dev] [RFC] eal: allow hotplug to skip an already probed device Thread-Index: AdRK6jq18+jMrkm+RYKtZs6P5186vQ== Date: Wed, 12 Sep 2018 22:50:11 +0000 Message-ID: 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; VI1PR0502MB3853; 6:nzwqe+sM4iKB2oGTqvqm/uvthr8KiiMX/HeOHdUQEK1zImb9xGFGcqvaYFFh2A+oBBq3kUu+JnYebgYiAhAIQfeipM7F04tYOBnamIQTDv4asNzVkayptxtjxuIHSz1l8UbFn64+tFL64iCiKcfa9Y742rVsClrepM3HoOvNu9HmShlUUIeY2S0nPA0PpGETWmQGwlXVirhRB3RNKcn9yr7ROMOdkDmgkWuogCsFHvSrDiPm0iIjSp3Q5VPExY9rWZrGvE8QST9eTEoz7jEmCEfr+lLj1cBl0QPDewG4mDioHW0MboqqpcQkxBsEgUWZ0XM5hSuQ7Q/fxJPhjmY4C2ehWZCOqUKh1kWkyOoA0on9PeDvHKs7olsbTXc4RvuHGP6te1PelaOejVDPuSx0+y+JF5beOLo8UPnMMHDgEuNs8jFzEQ724xuiJTFmVr7qElRkfGXlJghMFv0XjCJMlA==; 5:yoySm32Mk2OJkWD068jtYGYQvcW9JtLa/7HatgOdWI4qB+Dj8tYSbfI7C7hMawSK60/+O0ljD8NN9D8hMe7UBxFeX/AjbEFTf2b5E/73UFpNeC6OoZ239tGPfGRQDtQQE6BKeaoUp/Gso6m2sBlz6jVhFiKHw1Kfg4bsSvk6Qvw=; 7:bqd7uQdsfEOzKU7gc8HkQqpG8HPw/txFwviCEnETNlrhogiEr7HXheY3axsR2fPN65Rac3BiQB+gMm0jOSpBW1i8DRBXGmMne1rif0Ar0I3eCPWwkMOO/Wu/RfVoLSt72pi6+w9VOzQdIaY5wObY2t2fmoNuDSP7prT0BKrmjb64W2UHtgkaDKm2M5uZNj6qPiwXrNcw80bmMJxGGNkBiL0VPzd1WjNfapXIMq9V+A1pl0y4AqNtwtSMZOylmfEl x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: c3628d12-169a-4e2b-d626-08d619021913 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:VI1PR0502MB3853; x-ms-traffictypediagnostic: VI1PR0502MB3853: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: 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)(93006095)(93001095)(3002001)(3231311)(944501410)(52105095)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(201708071742011)(7699050); SRVR:VI1PR0502MB3853; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0502MB3853; x-forefront-prvs: 07935ACF08 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(376002)(396003)(136003)(39860400002)(189003)(13464003)(199004)(6116002)(86362001)(66066001)(486006)(2501003)(256004)(14444005)(305945005)(7696005)(8676002)(7736002)(74316002)(3846002)(110136005)(54906003)(316002)(2906002)(26005)(81166006)(81156014)(8936002)(106356001)(105586002)(99286004)(186003)(102836004)(478600001)(53936002)(25786009)(9686003)(55016002)(6436002)(33656002)(2900100001)(229853002)(476003)(97736004)(68736007)(5660300001)(53546011)(107886003)(4326008)(5250100002)(14454004)(6246003)(6506007); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0502MB3853; 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: Xgw9LyscfcNsKDbiPQYHU+BrELX9c7ShEkjH5Swaz+ITQqWPJatZSQE0kr6qz6ng6Un/xCWsRwIcKLgt1DlJ1VQ/d6hBGNi+Qyqj5vUWC7H8J0GBfjxjg0GKGg91n2EwovqpdWFax43cUZrH6SpWwpBfUrtPV61D8EKoRhtQ3/WRZcn5HDnTL1YMALzdkxXM3spWw3eTYIqodkja/ZQu3qD+nsgxCkDOIxZjRInmnBSglJ/DfgXQMA91BlmLdY57daDKlfkT0VSSYryb0aKbpGa+angH9cXK+zVkRw+gYpP0KvN5z4J+dbdaa+DC5Nmo0Lks2fPu505zYqD7ze+bAl9LuP1ZKtixqvSQ3YmAo20= 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: c3628d12-169a-4e2b-d626-08d619021913 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Sep 2018 22:50:11.9242 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB3853 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Sep 2018 22:50:14 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon > Sent: Saturday, September 08, 2018 12:10 AM > To: dev@dpdk.org > Cc: gaetan.rivet@6wind.com > Subject: [dpdk-dev] [RFC] eal: allow hotplug to skip an already probed=20 > device >=20 > In the devargs syntax for device representors, it is possible to add=20 > several devices at once: -w dbdf,representor=3D[0-3] It will become a=20 > more frequent case when introducing wildcards and ranges in the new devar= gs syntax. >=20 > If a devargs string is provided for probing, and updated with a bigger=20 > range for a new probing, then we do not want it to fail because part=20 > of this range was already probed previously. >=20 When having devargs with representors ("dbdf,representor=3D") 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 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=20 > 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) the second call to rte_eal_= hotplug_add() will call the PMD probe callback, which may fail unless it is= aware of "fail_existing" parameter. Alternatively "fail_existing" may be better named "enable_multi_probe". 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.=20 > Signed-off-by: Thomas Monjalon > --- > 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 +++-=20 > 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=20 > 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=20 > 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=20 > char *devname, > - const char *devargs); > + const char *devargs, bool fail_existing); >=20 > /** > * @warning > -- > 2.18.0