From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by dpdk.org (Postfix) with ESMTP id ACFEC2C2A for ; Wed, 28 Jun 2017 15:09:10 +0200 (CEST) Received: by mail-wm0-f51.google.com with SMTP id b184so58217787wme.1 for ; Wed, 28 Jun 2017 06:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=PrPZyB+hVw8KJd782KyrRuHRLqoMQsnTlnY23GuD8NM=; b=R6akDRoNJEMLjNdYcjeaNjUt5aJKRESNFZ3Heg3Xswq1dEx5PTLAhxD4hUiPnKN0Rs g6oVx6F5O7BDrZT9nAJ2SJQD4rU5GUqBr4xHQLeQpbHti9+EiPCdvp17OU8k+8Nl98LC GSIlShs7yokgRlusPRhlP7H6aH85DNRwnGIYrdfyGoOWdbjUvQ23I1OXY8Zv9DdSj5RJ RUPFe/PYsjkMSgyujvHI72B9G5X+UrOw21JZ93HJQY7bwtm9TGmlSg1n5p3KZO5H3fit sO07SyIoDsAXlTBjD5dAGSRuV3o4OD7XWUm6xdlMLjBgUgUtyjk+oAe28HGlsR/y/bOf fxsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=PrPZyB+hVw8KJd782KyrRuHRLqoMQsnTlnY23GuD8NM=; b=N9Ir3PYWRh9VB76JHAfY0r5Xp+wAjZ2kkrgpepMB9cU4QWRHNVZqgrWS5vFSKFT5lS jq8+Eg9Ksbqzon4yiNJP2bHD6Ocu5+h04Q1n5Fw7hrhGdex8PlyV6Jp85fnADi4buLI4 5clkv5A+g7kXnPt/kiUOxpB0Dln7rrfOp2NERsDxeqtcLOcR3Ra03QVO0MOFkGOCTIoG 7iOnn//jJPT6Iun/O8sdxHgDfPw9dtjKOAsFkMOhe0MF/PxT8eO0lCSc/sctjwU2C/T4 ht2ccXxD7F1l+n25jT3kcoB9JHKKlCikXq+kPuGORcDiz5X4PlLtgpdQfv3oaR+4Xit5 fHHA== X-Gm-Message-State: AKS2vOx/tx564csZdqY8UPxI01+dAuDZ1diXrbEGyU+8iuASr9/PVhLt OD28eJto0xsPF76ArK1SurYY7Iznzw== X-Received: by 10.28.134.79 with SMTP id i76mr7156698wmd.108.1498655350311; Wed, 28 Jun 2017 06:09:10 -0700 (PDT) MIME-Version: 1.0 Sender: jblunck@gmail.com Received: by 10.28.5.136 with HTTP; Wed, 28 Jun 2017 06:09:09 -0700 (PDT) In-Reply-To: <14287370.n4WKZa6dWl@xps> References: <4639959.eMbdazoqpE@xps> <14287370.n4WKZa6dWl@xps> From: Jan Blunck Date: Wed, 28 Jun 2017 15:09:09 +0200 X-Google-Sender-Auth: M-Pnp0tAEFPxntUbTsJHB6EMkaw Message-ID: To: Thomas Monjalon Cc: dev , Gaetan Rivet Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v6 05/11] bus: introduce hotplug functionality 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, 28 Jun 2017 13:09:10 -0000 On Wed, Jun 28, 2017 at 2:11 PM, Thomas Monjalon wrote: > 28/06/2017 13:58, Jan Blunck: >> On Wed, Jun 28, 2017 at 1:44 PM, Thomas Monjalon wrote: >> > 27/06/2017 21:03, Jan Blunck: >> >> On Tue, Jun 27, 2017 at 6:11 PM, Gaetan Rivet wrote: >> >> > --- a/lib/librte_eal/common/include/rte_bus.h >> >> > +++ b/lib/librte_eal/common/include/rte_bus.h >> >> > /** >> >> > + * Implementation specific probe function which is responsible for linking >> >> > + * devices on that bus with applicable drivers. >> >> > + * The plugged device might already have been used previously by the bus, >> >> > + * in which case some buses might prefer to detect and re-use the relevant >> >> > + * information pertaining to this device. >> >> > + * >> >> > + * @param da >> >> > + * Device declaration. >> >> > + * >> >> > + * @return >> >> > + * The pointer to a valid rte_device usable by the bus on success. >> >> > + * NULL on error. rte_errno is then set. >> >> > + */ >> >> > +typedef struct rte_device * (*rte_bus_plug_t)(struct rte_devargs *da); >> >> >> >> Shouldn't this be orthogonal to unplug() and take a rte_device. You >> >> should only be able to plug devices that have been found by scan >> >> before. >> > >> > Plugging a device that has been scanned before is a special case. >> > In a true hotplug scenario, we could use this plug function passing >> > a devargs. >> > I don't see any issue passing rte_devargs to plug and rte_device to unplug. >> >> What do you mean by "true hotplug"? > > I mean a kernel notification of a new device. > Does a "false hotplug" exist, too? :) >> The problem with this is that passing just rte_devargs to plug() >> requires the bus to parse and enrich the rte_devargs with bus >> specifics. From there it gets folded into the to-be-created bus >> specific rte_XXX_device. This makes it unnecessarily complicated and >> even worse it adds a second code path how devices come alive. > > Just after the notification, the rte_device does not exist yet. > So the plug function could share the same code as the scan function > to get the metadata and create the device instance. > Exactly this is what I want to avoid. The plug() function would become a "scan-one and probe". From my point of view plug() and unplug() should be orthogonal. The plug() and unplug() should only be responsible for adding drivers with optional arguments. The EAL should allow the drivers to get unplugged/re-plugged at run-time. I want to be able to change arguments ... or even drivers :) >> When we get notified about a hotplug event we already know which bus >> this event belongs to: >> >> 1. scan the bus for incoming devices > > No need to scan every devices here. > This is a readdir followed by open+read+close for any new device. This code belongs here anyway. Its lightweight if nothing changed. The scan itself should be idempotent anyway. >> 2. plug single device with devargs and probe for drivers >> >> Makes sense? > > I want to make sure there is no misunderstanding first :) Which makes sense. That is probably my fault due to being too distracted with other things and not communicating well enough while Gaetan consumed my code.