On Sun, Jul 09, 2017 at 07:10:49AM -0400, Jan Blunck wrote: > On Sat, Jul 8, 2017 at 9:47 PM, Gaetan Rivet <gaetan.ri...@6wind.com> 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