[dpdk-dev] [PATCH 03/14] eal/common: introduce union rte_device and related
Jan Viktorin
viktorin at rehivetech.com
Wed Jan 13 15:12:27 CET 2016
On Wed, 13 Jan 2016 14:01:19 +0000
Bruce Richardson <bruce.richardson at intel.com> wrote:
> On Mon, Jan 04, 2016 at 09:08:15PM +0100, Jan Viktorin wrote:
> > The union rte_device can be used in situations where we want to work with all
> > devices without distinguishing among bus-specific features (PCI, ...).
> > The target device type can be detected by reading the magic.
> >
> > Also, the macros RTE_DEVICE_DECL and RTE_DEVICE_PTR_DECL are introduced to
> > provide a generic way to declare a device or a pointer to a device. The macros
> > aim to preserve API backwards-compatibility. Eg.
> >
> > struct old_super_struct { => struct old_super_struct {
> > struct rte_pci_device *pci_dev; => RTE_DEVICE_PTR_DECL(pci_dev);
> > ... => ...
> > }; => };
> >
> > struct old_super_struct inst;
> >
> > The new code should reference inst.dev.pci, the old code can still use the
> > inst.pci_dev. The previously introduced magic is included so one can ask the
> > instance about its type:
> >
> > if (inst.dev.magic == RTE_PCI_DEVICE_MAGIC) {
> > ...
> > }
>
> Rather than magic numbers i.e. #defines, an enum might be better.
True. However, would it be helpful to put really some _magic_ numbers
there for debugging purposes (to clearly recognize the data type)? Or,
is it sufficient to just say 1 for PCI, 2 for SoC, 3 for xxx...?
>
> /Bruce
>
--
Jan Viktorin E-mail: Viktorin at RehiveTech.com
System Architect Web: www.RehiveTech.com
RehiveTech
Brno, Czech Republic
More information about the dev
mailing list