On Tue, 20 Dec 2016 14:00:55 +0100 Jan Blunck <jblu...@infradead.org> wrote:
> On Mon, Dec 19, 2016 at 10:59 PM, Stephen Hemminger > <step...@networkplumber.org> wrote: > > Since multiple buses and device types need to be supported. > > Provide type field in driver. > > --- > > lib/librte_eal/common/include/rte_dev.h | 15 ++++++++++++--- > > lib/librte_eal/common/include/rte_pci.h | 1 + > > lib/librte_eal/common/include/rte_vdev.h | 1 + > > 3 files changed, 14 insertions(+), 3 deletions(-) > > > > diff --git a/lib/librte_eal/common/include/rte_dev.h > > b/lib/librte_eal/common/include/rte_dev.h > > index e5471a22..3f4e26e6 100644 > > --- a/lib/librte_eal/common/include/rte_dev.h > > +++ b/lib/librte_eal/common/include/rte_dev.h > > @@ -144,12 +144,21 @@ void rte_eal_device_insert(struct rte_device *dev); > > void rte_eal_device_remove(struct rte_device *dev); > > > > /** > > + * Type of device driver > > + */ > > +enum rte_driver_type { > > + PMD_VIRTUAL, > > + PMD_PCI, > > +}; > > + > > +/** > > * A structure describing a device driver. > > */ > > struct rte_driver { > > TAILQ_ENTRY(rte_driver) next; /**< Next in list. */ > > - const char *name; /**< Driver name. */ > > - const char *alias; /**< Driver alias. */ > > + const char *name; /**< Driver name. */ > > + const char *alias; /**< Driver alias. */ > > + enum rte_driver_type type; /**< Driver type. */ > > }; > > I wonder who is the user of the type. It can't be the driver itself > because it must be aware of what kind of low-level interface it > serves. So this seems to be a helper to allow users of rte_driver to > upcast to the object that embeds the rte_driver at runtime. I don't > believe that this is a good interface because it often leads to ugly > and error prone code. The thing I ran into was the test code. The testpmd (and related code) is an example of how some code might want to use dev_info_get to find out about a device then take some action based on the driver type. Testpmd has code that manipulates PCI registers. Right now it is broken when run on virtual devices.