[dpdk-dev] eventdev: event device to contain rte device holder

Message ID 1487242349-16801-1-git-send-email-nipun.gupta@nxp.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Nipun Gupta Feb. 16, 2017, 10:52 a.m. UTC
  Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>

rte_device is a generic device which is available to the applications
and EAL. This patch replaces rte_pci_device in 'struct rte_eventdev'
and in 'struct rte_event_dev_info' with common rte_device.
---
 drivers/event/skeleton/skeleton_eventdev.c | 2 +-
 lib/librte_eventdev/rte_eventdev.c         | 6 +++---
 lib/librte_eventdev/rte_eventdev.h         | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)
  

Comments

Stephen Hemminger Feb. 17, 2017, 7:30 p.m. UTC | #1
On Thu, 16 Feb 2017 16:22:29 +0530
Nipun Gupta <nipun.gupta@nxp.com> wrote:

> Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
> 
> rte_device is a generic device which is available to the applications
> and EAL. This patch replaces rte_pci_device in 'struct rte_eventdev'
> and in 'struct rte_event_dev_info' with common rte_device.
> ---
>  drivers/event/skeleton/skeleton_eventdev.c | 2 +-
>  lib/librte_eventdev/rte_eventdev.c         | 6 +++---
>  lib/librte_eventdev/rte_eventdev.h         | 6 +++---
>  3 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c
> index dee0faf..770dce3 100644
> --- a/drivers/event/skeleton/skeleton_eventdev.c
> +++ b/drivers/event/skeleton/skeleton_eventdev.c
> @@ -383,7 +383,7 @@
>  	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
>  		return 0;
>  
> -	pci_dev = eventdev->pci_dev;
> +	pci_dev = RTE_DEV_TO_PCI(eventdev->dev);

How will this work when there are more than just PCI devices?
For example, upcoming patches will add rte_vmbus_device.  There is no
run time type checking in C.
  
Nipun Gupta Feb. 20, 2017, 4:48 a.m. UTC | #2
Hi Stephen,

> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Saturday, February 18, 2017 1:00
> To: Nipun Gupta <nipun.gupta@nxp.com>
> Cc: dev@dpdk.org; Hemant Agrawal <hemant.agrawal@nxp.com>;
> jerin.jacob@caviumnetworks.com; bruce.richardson@intel.com;
> gage.eads@intel.com; harry.van.haaren@intel.com
> Subject: Re: [dpdk-dev] [PATCH] eventdev: event device to contain rte device
> holder
> 
> On Thu, 16 Feb 2017 16:22:29 +0530
> Nipun Gupta <nipun.gupta@nxp.com> wrote:
> 
> > Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
> >
> > rte_device is a generic device which is available to the applications
> > and EAL. This patch replaces rte_pci_device in 'struct rte_eventdev'
> > and in 'struct rte_event_dev_info' with common rte_device.
> > ---
> >  drivers/event/skeleton/skeleton_eventdev.c | 2 +-
> >  lib/librte_eventdev/rte_eventdev.c         | 6 +++---
> >  lib/librte_eventdev/rte_eventdev.h         | 6 +++---
> >  3 files changed, 7 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/event/skeleton/skeleton_eventdev.c
> b/drivers/event/skeleton/skeleton_eventdev.c
> > index dee0faf..770dce3 100644
> > --- a/drivers/event/skeleton/skeleton_eventdev.c
> > +++ b/drivers/event/skeleton/skeleton_eventdev.c
> > @@ -383,7 +383,7 @@
> >  	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> >  		return 0;
> >
> > -	pci_dev = eventdev->pci_dev;
> > +	pci_dev = RTE_DEV_TO_PCI(eventdev->dev);
> 
> How will this work when there are more than just PCI devices?
> For example, upcoming patches will add rte_vmbus_device.  There is no
> run time type checking in C.

This is within the device driver. AFAIU, a driver will be based on a single bus and
it will get its own device by calling the right conversion function.
So, if a new bus like vmbus is there shall be a corresponding RTE_DEV_TO_xyDEV
to get the 'devices on vmbus' from 'rte_device'.

Thanks,
Nipun
  
Shreyansh Jain March 3, 2017, 9:09 a.m. UTC | #3
On Thursday 16 February 2017 04:22 PM, Nipun Gupta wrote:
> Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
>
> rte_device is a generic device which is available to the applications
> and EAL. This patch replaces rte_pci_device in 'struct rte_eventdev'
> and in 'struct rte_event_dev_info' with common rte_device.

Patch context and Signed-off are in reverse order.

> ---
>  drivers/event/skeleton/skeleton_eventdev.c | 2 +-
>  lib/librte_eventdev/rte_eventdev.c         | 6 +++---
>  lib/librte_eventdev/rte_eventdev.h         | 6 +++---
>  3 files changed, 7 insertions(+), 7 deletions(-)
>

Other than that:
Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
  

Patch

diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c
index dee0faf..770dce3 100644
--- a/drivers/event/skeleton/skeleton_eventdev.c
+++ b/drivers/event/skeleton/skeleton_eventdev.c
@@ -383,7 +383,7 @@ 
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
-	pci_dev = eventdev->pci_dev;
+	pci_dev = RTE_DEV_TO_PCI(eventdev->dev);
 
 	skel->reg_base = (uintptr_t)pci_dev->mem_resource[0].addr;
 	if (!skel->reg_base) {
diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index 91bd1c9..f6a2a56 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -125,7 +125,7 @@ 
 
 	dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
 
-	dev_info->pci_dev = dev->pci_dev;
+	dev_info->dev = dev->dev;
 	if (dev->driver)
 		dev_info->driver_name = dev->driver->pci_drv.driver.name;
 	return 0;
@@ -1196,7 +1196,7 @@  struct rte_eventdev *
 					"device data");
 	}
 
-	eventdev->pci_dev = pci_dev;
+	eventdev->dev = &pci_dev->device;
 	eventdev->driver = eventdrv;
 
 	/* Invoke PMD device initialization function */
@@ -1250,7 +1250,7 @@  struct rte_eventdev *
 	/* Free event device */
 	rte_event_pmd_release(eventdev);
 
-	eventdev->pci_dev = NULL;
+	eventdev->dev = NULL;
 	eventdev->driver = NULL;
 
 	return 0;
diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h
index c2f9310..2335917 100644
--- a/lib/librte_eventdev/rte_eventdev.h
+++ b/lib/librte_eventdev/rte_eventdev.h
@@ -330,7 +330,7 @@ 
  */
 struct rte_event_dev_info {
 	const char *driver_name;	/**< Event driver name */
-	struct rte_pci_device *pci_dev;	/**< PCI information */
+	struct rte_device *dev;	/**< Device information */
 	uint32_t min_dequeue_timeout_ns;
 	/**< Minimum supported global dequeue timeout(ns) by this device */
 	uint32_t max_dequeue_timeout_ns;
@@ -1057,8 +1057,8 @@  struct rte_eventdev {
 	/**< Pointer to device data */
 	const struct rte_eventdev_ops *dev_ops;
 	/**< Functions exported by PMD */
-	struct rte_pci_device *pci_dev;
-	/**< PCI info. supplied by probing */
+	struct rte_device *dev;
+	/**< Device info. supplied by probing */
 	const struct rte_eventdev_driver *driver;
 	/**< Driver for this device */