From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 1FC8E58EC for ; Mon, 1 Oct 2018 22:04:03 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 91E7D2205A; Mon, 1 Oct 2018 16:04:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 01 Oct 2018 16:04:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=rxiKRGspA3gtTSpWsrGk769Aqt +anZYIJgu2pghjTNI=; b=hMCnFZZTI2qzBYTesz/3uGgnmOK4RI2p4o3/laANt7 7+NXq746rzV6fIfcP20BLGji6iuAfYf1YrnfaR5cMrIep7U/OG6cVtcaC5xNWjij XIdk31VJN4spzAiWcRVbZ5XaqlLabqE/HmJOqvgeHQv1Oi6GMLfsvwp0oDQNT2gc I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=rxiKRG spA3gtTSpWsrGk769Aqt+anZYIJgu2pghjTNI=; b=M5GmfsFCC9+aiKZAF79Fju doQ1/pKuICIylWhKFBYLPj/sSEMh2dJH++cSk54wc0KR8Gqja4choMX2p6nR0iY0 ldL4lgUGT3uC7j98BpvT7bSQFnm2YGZA0UCMcdf+ezixvFVViePtgmQlnB3J4IYz 3wmevAQu6mSZY14MHPvBufUO6Fp46IT7zL/0HEruN2mnngh44Z0MmUq9PjNZVpLb AUCx+TZu9hE9vDfA2sqjqQ4WD8gfbnwMpc9PxL8+zXFhGFAgXwwHIhmXdvRmJnWe k6n7mUi6bCzIBHR4kEkC4EMscZmt2xbvEf0Ux/7HNesAE11NzUx3qu63mcU441fA == X-ME-Sender: X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 6BF87E405E; Mon, 1 Oct 2018 16:04:00 -0400 (EDT) From: Thomas Monjalon To: Andrew Rybchenko Cc: dev@dpdk.org, gaetan.rivet@6wind.com, ophirmu@mellanox.com, qi.z.zhang@intel.com, ferruh.yigit@intel.com, ktraynor@redhat.com Date: Mon, 01 Oct 2018 22:03:59 +0200 Message-ID: <5671799.PGEWDzNARk@xps> In-Reply-To: <7955fa9c-21ea-295b-2c1c-5a0ab7a472c6@solarflare.com> References: <20180907222727.20521-1-thomas@monjalon.net> <20180928162144.1972-5-thomas@monjalon.net> <7955fa9c-21ea-295b-2c1c-5a0ab7a472c6@solarflare.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v3 4/4] eal: simplify parameters of hotplug functions 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: Mon, 01 Oct 2018 20:04:03 -0000 01/10/2018 13:26, Andrew Rybchenko: > On 9/28/18 7:21 PM, Thomas Monjalon wrote: > > All information about a device to probe can be grouped > > in a common string, which is what we usually call devargs. > > An application should not have to parse this string before > > calling the EAL probe function. > > And the syntax could evolve to be more complex and support > > matching multiple devices in one string. > > That's why the bus name and device name should be removed from > > rte_eal_hotplug_add(). > > Instead of changing this function, a simpler one is added > > and used in the old one, which may be deprecated later. > > > > When removing a device, we already know its rte_device handle > > which can be directly passed as parameter of rte_eal_hotplug_remove(). > > If the rte_device is not known, it can be retrieved with the devargs, > > by iterating in the device list (future RTE_DEV_FOREACH()). > > Similarly to the probing case, a new function is added > > and used in the old one, which may be deprecated later. > > The new function is used in failsafe, because the replacement is easy. > > > > Signed-off-by: Thomas Monjalon > > Minor memory leak below, when fixed: > > Reviewed-by: Andrew Rybchenko > > <...> > > > diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c > > index a9be58edf..b40e4c0d0 100644 > > --- a/lib/librte_eal/common/eal_common_dev.c > > +++ b/lib/librte_eal/common/eal_common_dev.c > > @@ -129,46 +129,57 @@ int rte_eal_dev_detach(struct rte_device *dev) > > > > int > > rte_eal_hotplug_add(const char *busname, const char *devname, > > - const char *devargs) > > + const char *drvargs) > > +{ > > + char *devargs = NULL; > > + int size, length = -1; > > + > > + do { /* 2 iterations: first is to know string length */ > > + size = length + 1; > > + length = snprintf(devargs, size, "%s:%s,%s", busname, devname, drvargs); > > + if (length >= size) > > + devargs = malloc(length + 1); > > + if (devargs == NULL) > > + return -ENOMEM; > > + } while (size == 0); > > + > > + return rte_dev_probe(devargs); > > I think we should free devargs after the call. Good catch! Will fix in v4, thank you.