From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wj0-f194.google.com (mail-wj0-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id B7B3B2C60 for ; Tue, 20 Dec 2016 14:00:56 +0100 (CET) Received: by mail-wj0-f194.google.com with SMTP id he10so27613529wjc.2 for ; Tue, 20 Dec 2016 05:00:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Mn3Px1wrstNQuwDhlliyHI7NtCp84J50tgDIikgFtjw=; b=VUgQ0G6rY2tVc4mRmhnuxDnIxjUbefZ7En3umLC955B+GZIvjgLyDOD7ADvpzmxzE4 e+Xy8jmHQjhpV02/sHfp3QuXs9CbrykUV8lV7oNTXASDeGmEYSN/cBuKaC+Cst/h++kw KoYVdizw4sfgkNvgqAatZ0T+4nd4li8PYnAH83+50ir0GHbYHHs1awR3RcvdzRLXSx53 i/dgN+7M/HunD5f6MA1fWKOxizIwHSc2aT9DUmXd1BZNJGMLNE119Jeg8SvLkuF3RwbC eFrKPimrEOti77DIqJVoAR6Rzpj8EQujycCjNI9qQUQVeZZA1TJxsKR8dlLPxYbwgech wg9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Mn3Px1wrstNQuwDhlliyHI7NtCp84J50tgDIikgFtjw=; b=j/0pa6+fPCH6JrVEkez7HT+soE3sn2eD+R4QPr38/Isq2Osh8uFH39eb0goT7Yk1lq W5NkxFxZV1LVhSo5R9W2mbwbQNH880KrDxPdsW7Dv4LvKSsxxgICsCdfDpDkMssmuXf2 hDULz6zo5fOalYdJZYL21DdDslXWOY9nGUDibZK9CU5fg5DxqtqUAmuBcFHwi3diZLUP Gete4XYJKRl5HLkXyVrmLq08ldb15Su8tvMdBN5NgzkUYMll/mzJusiqj6FXANNmh+bR 0OXmtSMUD3G6YgifCmcHQwC1AVvrbAlLQLETfiE78N49oIKYikFbuTU/Z556EM7n87Tc ULVA== X-Gm-Message-State: AKaTC000zxduN0C0eWzyYVlOSYOgTPm5PqySGe/EVlvIBLFRGeeyqQwkO2ohZ+MffQGkMud1K1trf/z3R1aGag== X-Received: by 10.194.127.104 with SMTP id nf8mr18027015wjb.39.1482238856343; Tue, 20 Dec 2016 05:00:56 -0800 (PST) MIME-Version: 1.0 Sender: jblunck@gmail.com Received: by 10.28.63.83 with HTTP; Tue, 20 Dec 2016 05:00:55 -0800 (PST) In-Reply-To: <20161219215944.17226-5-sthemmin@microsoft.com> References: <20161219215944.17226-1-sthemmin@microsoft.com> <20161219215944.17226-5-sthemmin@microsoft.com> From: Jan Blunck Date: Tue, 20 Dec 2016 14:00:55 +0100 X-Google-Sender-Auth: VTgukfa8vT3i0GSXIfW32kl05cA Message-ID: To: Stephen Hemminger Cc: dev@dpdk.org, Stephen Hemminger Content-Type: text/plain; charset=UTF-8 Subject: Re: [dpdk-dev] [PATCH 04/13] eal: introduce driver type X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Dec 2016 13:00:56 -0000 On Mon, Dec 19, 2016 at 10:59 PM, Stephen Hemminger 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. > > /** > @@ -243,4 +252,4 @@ __attribute__((used)) = str > } > #endif > > -#endif /* _RTE_VDEV_H_ */ > +#endif /* _RTE_DEV_H_ */ > diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h > index 9ce88472..d377d539 100644 > --- a/lib/librte_eal/common/include/rte_pci.h > +++ b/lib/librte_eal/common/include/rte_pci.h > @@ -492,6 +492,7 @@ RTE_INIT(pciinitfn_ ##nm); \ > static void pciinitfn_ ##nm(void) \ > {\ > (pci_drv).driver.name = RTE_STR(nm);\ > + (pci_drv).driver.type = PMD_PCI; \ > rte_eal_pci_register(&pci_drv); \ > } \ > RTE_PMD_EXPORT_NAME(nm, __COUNTER__) > diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h > index 784e837d..98fb5bb5 100644 > --- a/lib/librte_eal/common/include/rte_vdev.h > +++ b/lib/librte_eal/common/include/rte_vdev.h > @@ -88,6 +88,7 @@ static void vdrvinitfn_ ##vdrv(void)\ > {\ > (vdrv).driver.name = RTE_STR(nm);\ > (vdrv).driver.alias = vdrvinit_ ## nm ## _alias;\ > + (vdrv).driver.type = PMD_VIRTUAL;\ > rte_eal_vdrv_register(&vdrv);\ > } \ > RTE_PMD_EXPORT_NAME(nm, __COUNTER__) > -- > 2.11.0 >