From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 1A1BB695D for ; Mon, 1 Oct 2018 13:27:39 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us4.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id BB10A8006B; Mon, 1 Oct 2018 11:27:37 +0000 (UTC) Received: from [192.168.38.17] (91.220.146.112) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 1 Oct 2018 12:27:31 +0100 To: Thomas Monjalon , CC: , , , , References: <20180907222727.20521-1-thomas@monjalon.net> <20180928162144.1972-1-thomas@monjalon.net> <20180928162144.1972-5-thomas@monjalon.net> From: Andrew Rybchenko Message-ID: <7955fa9c-21ea-295b-2c1c-5a0ab7a472c6@solarflare.com> Date: Mon, 1 Oct 2018 14:26:48 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180928162144.1972-5-thomas@monjalon.net> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB X-Originating-IP: [91.220.146.112] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24128.003 X-TM-AS-Result: No-9.555000-8.000000-10 X-TMASE-MatchedRID: zGP2F0O7j/sOwH4pD14DsPHkpkyUphL9Ct59Uh3p/NVqv/+QKNcPLvPM gMdM5A4efNcL9d3klHyksAmc2I2bGhnsS71Oo/HwQpxiLlDD9FWyeEt6/0zzycWkDW4kV3WapMB UwgqWxUe/VQbNHOdHkHvASbP8C3XjCvmAQXzxgF1jVtAwIy+afkyQ5fRSh265TUobVis5Bb87Qm s3AC7auzxOxTEbgyTykZOl7WKIImrvXOvQVlExsG4djWaei+WE+gD2vYtOFhgqtq5d3cxkNTg/4 K+fB93hUd9domYOmpM/o1nCq9+VwcY4z+/r6EbtRbt3yaCLv6Q= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--9.555000-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24128.003 X-MDID: 1538393258-t9WcJvTXvfLY 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 11:27:39 -0000 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. > +} <...>