From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet Subject: Re: [PATCH v7 03/11] net/failsafe: add fail-safe PMD Date: Sun, 9 Jul 2017 14:35:21 +0200 Message-ID: <20170709123521.GV11154@bidouze.vm.6wind.com> References: <1a589e5bf8e6babbd364b3976511289f6762cafa.1499564333.git.gaetan.rivet@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: dev To: Jan Blunck Return-path: Received: from mail-wr0-f171.google.com (mail-wr0-f171.google.com [209.85.128.171]) by dpdk.org (Postfix) with ESMTP id 9CA5E5592 for ; Sun, 9 Jul 2017 14:35:31 +0200 (CEST) Received: by mail-wr0-f171.google.com with SMTP id 77so103706906wrb.1 for ; Sun, 09 Jul 2017 05:35:31 -0700 (PDT) Content-Disposition: inline In-Reply-To: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Sun, Jul 09, 2017 at 07:10:49AM -0400, Jan Blunck wrote: > On Sat, Jul 8, 2017 at 9:47 PM, Gaetan Rivet wrote: > > +static int > > +fs_parse_device(struct sub_device *sdev, char *args) > > +{ > > + struct rte_devargs *d; > > + int ret; > > + > > + d = &sdev->devargs; > > + DEBUG("%s", args); > > + ret = rte_eal_devargs_parse(args, d); > > + if (ret) { > > + DEBUG("devargs parsing failed with code %d", ret); > > + return ret; > > + } > > + sdev->bus = d->bus; > > + sdev->state = DEV_PARSED; > > You seem to be mostly interested in the bus name for the device. Why > don't you track this via your sub_device structure instead of using > rte_devargs? > > I don't understand. I track it in my sub_device structure by copying the info from the devargs? How would you get it otherwise? Devargs still has to be used as a common format that can be parsed by EAL helpers. I could certainly parse it myself, but then I would have to follow any evolution of the parameter format, and I prefer to delegate this to the EAL. > > + return 0; > > +} > > + [...] > > +static struct rte_eth_dev * > > +fs_find_ethdev(const struct rte_device *dev) > > +{ > > + struct rte_eth_dev *eth_dev; > > + uint8_t i; > > + > > + RTE_ETH_FOREACH_DEV(i) { > > + eth_dev = &rte_eth_devices[i]; > > + if (eth_dev->device == dev) > > + return eth_dev; > > + } > > + return NULL; > > +} > > Why don't you use rte_eth_dev_allocated() here? > > IIRC, at the time I choose to roll out my own version, there was ambiguities about device names availability, with some devices using their rte_devargs name, others writing their own. It has been stabilized it seems, and now I think rte_eth_dev_allocated could be used. [...] > > + > > +static int > > +fs_bus_init(struct rte_eth_dev *dev) > > +{ > > + struct sub_device *sdev; > > + struct rte_device *rdev; > > + struct rte_devargs *da; > > + uint8_t i; > > + int ret; > > + > > + FOREACH_SUBDEV(sdev, i, dev) { > > + if (sdev->state != DEV_PARSED) > > + continue; > > + da = &sdev->devargs; > > + rdev = rte_eal_hotplug_add(da->bus->name, > > + da->name, > > + da->args); > > Why don't you track the bus name through your sub_device structure instead? > > Do you mean + rdev = rte_eal_hotplug_add(sdev->bus->name, + da->name, + da->args); instead? I guess for this example it was mostly for the sake of consistency, but the bus handle within the sub_device could be used. Actually I dislike having a copy of an info. I have this info both within the sub_device directly and within the rte_devargs within the sub_device. It should be streamlined. -- Gaëtan Rivet 6WIND