From: Bruce Richardson <bruce.richardson@intel.com>
To: Jan Viktorin <viktorin@rehivetech.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 03/14] eal/common: introduce union rte_device and related
Date: Wed, 13 Jan 2016 14:24:05 +0000 [thread overview]
Message-ID: <20160113142405.GA7756@bricha3-MOBL3> (raw)
In-Reply-To: <20160113151227.6cfcd0a9@pcviktorin.fit.vutbr.cz>
On Wed, Jan 13, 2016 at 03:12:27PM +0100, Jan Viktorin wrote:
> On Wed, 13 Jan 2016 14:01:19 +0000
> Bruce Richardson <bruce.richardson@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...?
>
I'd find it hard to see the need for actual magic numbers. I think the magic field
should be renamed to "type" and the values taken from a device_type enum. Should
make the code more readable e.g.
if (inst.dev.type == RTE_DEVTYPE_PCI) { ... }
/Bruce
next prev parent reply other threads:[~2016-01-13 14:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 01/14] eal/common: introduce RTE_PCI_DRV_MAGIC Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 02/14] eal/common: introduce RTE_PCI_DEVICE_MAGIC Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 03/14] eal/common: introduce union rte_device and related Jan Viktorin
2016-01-13 14:01 ` Bruce Richardson
2016-01-13 14:12 ` Jan Viktorin
2016-01-13 14:24 ` Bruce Richardson [this message]
2016-01-04 20:08 ` [dpdk-dev] [PATCH 04/14] eal/common: introduce function to_pci_driver Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 05/14] eal/common: introduce function to_pci_device Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 06/14] Include rte_dev.h instead of rte_pci.h Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 07/14] lib/ether: generalize rte_eth_dev_init/uninit Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 08/14] eal/common: introduce rte_bus_addr Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 09/14] lib/ether: generalize attach/detach of devices Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 10/14] lib/ether: copy the rte_device union instead of rte_pci_device Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 11/14] lib/ether: extract function rte_device_get_intr_handle Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 12/14] lib/ether: check magic before naming a zone Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 13/14] lib/ether: check magic in rte_eth_copy_pci_info Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 14/14] lib/ether: introduce rte_eth_copy_dev_info Jan Viktorin
[not found] ` <CALwxeUtxE5Gd+UvZOHz+fyHSjLi9Tjkc=99QHpag62KV+UP+NA@mail.gmail.com>
2016-01-11 17:29 ` [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
2016-01-13 14:07 ` David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160113142405.GA7756@bricha3-MOBL3 \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=viktorin@rehivetech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).