DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev]  [PATCH] eventdev: remove PCI dependency
@ 2017-06-01 16:41 Jerin Jacob
  2017-06-05 12:55 ` Gaëtan Rivet
  2017-06-06 14:10 ` [dpdk-dev] [PATCH v2] " Jerin Jacob
  0 siblings, 2 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-01 16:41 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, harry.van.haaren, hemant.agrawal, gage.eads,
	nipun.gupta, Jerin Jacob, Gaetan Rivet

Remove the PCI dependency from generic data structures
and moved the PCI specific code to rte_event_pmd_pci*

CC: Gaetan Rivet <gaetan.rivet@6wind.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 drivers/event/skeleton/skeleton_eventdev.c | 30 +++++++++-----
 lib/librte_eventdev/rte_eventdev.c         | 37 +++++++-----------
 lib/librte_eventdev/rte_eventdev.h         |  2 -
 lib/librte_eventdev/rte_eventdev_pmd.h     | 63 ++++--------------------------
 4 files changed, 41 insertions(+), 91 deletions(-)

diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c
index 800bd76e0..34684aba0 100644
--- a/drivers/event/skeleton/skeleton_eventdev.c
+++ b/drivers/event/skeleton/skeleton_eventdev.c
@@ -427,18 +427,28 @@ static const struct rte_pci_id pci_id_skeleton_map[] = {
 	},
 };
 
-static struct rte_eventdev_driver pci_eventdev_skeleton_pmd = {
-	.pci_drv = {
-		.id_table = pci_id_skeleton_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
-		.probe = rte_event_pmd_pci_probe,
-		.remove = rte_event_pmd_pci_remove,
-	},
-	.eventdev_init = skeleton_eventdev_init,
-	.dev_private_size = sizeof(struct skeleton_eventdev),
+static int
+event_skeleton_pci_probe(struct rte_pci_driver *pci_drv,
+			 struct rte_pci_device *pci_dev)
+{
+	return rte_event_pmd_pci_probe(pci_drv, pci_dev,
+		sizeof(struct skeleton_eventdev), skeleton_eventdev_init);
+}
+
+static int
+event_skeleton_pci_remove(struct rte_pci_device *pci_dev)
+{
+	return rte_event_pmd_pci_remove(pci_dev, NULL);
+}
+
+static struct rte_pci_driver pci_eventdev_skeleton_pmd = {
+	.id_table = pci_id_skeleton_map,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+	.probe = event_skeleton_pci_probe,
+	.remove = event_skeleton_pci_remove,
 };
 
-RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd.pci_drv);
+RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(event_skeleton_pci, pci_id_skeleton_map);
 
 /* VDEV based event device */
diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index 20afc3f0e..91f950666 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -126,8 +126,6 @@ rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
 	dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
 
 	dev_info->dev = dev->dev;
-	if (dev->driver)
-		dev_info->driver_name = dev->driver->pci_drv.driver.name;
 	return 0;
 }
 
@@ -1250,18 +1248,18 @@ rte_event_pmd_vdev_uninit(const char *name)
 
 int
 rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
-			struct rte_pci_device *pci_dev)
+			struct rte_pci_device *pci_dev,
+			size_t private_data_size,
+			eventdev_pmd_pci_callback_t devinit)
 {
-	struct rte_eventdev_driver *eventdrv;
 	struct rte_eventdev *eventdev;
 
 	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
 
 	int retval;
 
-	eventdrv = (struct rte_eventdev_driver *)pci_drv;
-	if (eventdrv == NULL)
-		return -ENODEV;
+	if (devinit == NULL)
+		return -EINVAL;
 
 	rte_pci_device_name(&pci_dev->addr, eventdev_name,
 			sizeof(eventdev_name));
@@ -1275,7 +1273,7 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 		eventdev->data->dev_private =
 				rte_zmalloc_socket(
 						"eventdev private structure",
-						eventdrv->dev_private_size,
+						private_data_size,
 						RTE_CACHE_LINE_SIZE,
 						rte_socket_id());
 
@@ -1285,10 +1283,9 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 	}
 
 	eventdev->dev = &pci_dev->device;
-	eventdev->driver = eventdrv;
 
 	/* Invoke PMD device initialization function */
-	retval = (*eventdrv->eventdev_init)(eventdev);
+	retval = devinit(eventdev);
 	if (retval == 0)
 		return 0;
 
@@ -1307,12 +1304,12 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 }
 
 int
-rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
+rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
+			 eventdev_pmd_pci_callback_t devuninit)
 {
-	const struct rte_eventdev_driver *eventdrv;
 	struct rte_eventdev *eventdev;
 	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
-	int ret;
+	int ret = 0;
 
 	if (pci_dev == NULL)
 		return -EINVAL;
@@ -1324,22 +1321,16 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
 	if (eventdev == NULL)
 		return -ENODEV;
 
-	eventdrv = (const struct rte_eventdev_driver *)pci_dev->driver;
-	if (eventdrv == NULL)
-		return -ENODEV;
-
 	/* Invoke PMD device un-init function */
-	if (*eventdrv->eventdev_uninit) {
-		ret = (*eventdrv->eventdev_uninit)(eventdev);
-		if (ret)
-			return ret;
-	}
+	if (devuninit)
+		ret = devuninit(eventdev);
+	if (ret)
+		return ret;
 
 	/* Free event device */
 	rte_event_pmd_release(eventdev);
 
 	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 20e7293e0..c5b2b7453 100644
--- a/lib/librte_eventdev/rte_eventdev.h
+++ b/lib/librte_eventdev/rte_eventdev.h
@@ -1063,8 +1063,6 @@ struct rte_eventdev {
 	/**< Functions exported by PMD */
 	struct rte_device *dev;
 	/**< Device info. supplied by probing */
-	const struct rte_eventdev_driver *driver;
-	/**< Driver for this device */
 
 	RTE_STD_C11
 	uint8_t attached : 1;
diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
index 4005b3c98..faa6989b4 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd.h
@@ -87,60 +87,6 @@ extern "C" {
 #define RTE_EVENTDEV_DETACHED  (0)
 #define RTE_EVENTDEV_ATTACHED  (1)
 
-/**
- * Initialisation function of a event driver invoked for each matching
- * event PCI device detected during the PCI probing phase.
- *
- * @param dev
- *   The dev pointer is the address of the *rte_eventdev* structure associated
- *   with the matching device and which has been [automatically] allocated in
- *   the *rte_event_devices* array.
- *
- * @return
- *   - 0: Success, the device is properly initialised by the driver.
- *        In particular, the driver MUST have set up the *dev_ops* pointer
- *        of the *dev* structure.
- *   - <0: Error code of the device initialisation failure.
- */
-typedef int (*eventdev_init_t)(struct rte_eventdev *dev);
-
-/**
- * Finalisation function of a driver invoked for each matching
- * PCI device detected during the PCI closing phase.
- *
- * @param dev
- *   The dev pointer is the address of the *rte_eventdev* structure associated
- *   with the matching device and which	has been [automatically] allocated in
- *   the *rte_event_devices* array.
- *
- * @return
- *   - 0: Success, the device is properly finalised by the driver.
- *        In particular, the driver MUST free the *dev_ops* pointer
- *        of the *dev* structure.
- *   - <0: Error code of the device initialisation failure.
- */
-typedef int (*eventdev_uninit_t)(struct rte_eventdev *dev);
-
-/**
- * The structure associated with a PMD driver.
- *
- * Each driver acts as a PCI driver and is represented by a generic
- * *event_driver* structure that holds:
- *
- * - An *rte_pci_driver* structure (which must be the first field).
- *
- * - The *eventdev_init* function invoked for each matching PCI device.
- *
- * - The size of the private data to allocate for each matching device.
- */
-struct rte_eventdev_driver {
-	struct rte_pci_driver pci_drv;	/**< The PMD is also a PCI driver. */
-	unsigned int dev_private_size;	/**< Size of device private data. */
-
-	eventdev_init_t eventdev_init;	/**< Device init function. */
-	eventdev_uninit_t eventdev_uninit; /**< Device uninit function. */
-};
-
 /** Global structure used for maintaining state of allocated event devices */
 struct rte_eventdev_global {
 	uint8_t nb_devs;	/**< Number of devices found */
@@ -579,18 +525,23 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
 int
 rte_event_pmd_vdev_uninit(const char *name);
 
+typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
+
 /**
  * Wrapper for use by pci drivers as a .probe function to attach to a event
  * interface.
  */
 int rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
-			    struct rte_pci_device *pci_dev);
+			    struct rte_pci_device *pci_dev,
+			    size_t private_data_size,
+			    eventdev_pmd_pci_callback_t devinit);
 
 /**
  * Wrapper for use by pci drivers as a .remove function to detach a event
  * interface.
  */
-int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev);
+int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
+			     eventdev_pmd_pci_callback_t devuninit);
 
 #ifdef __cplusplus
 }
-- 
2.13.0

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH] eventdev: remove PCI dependency
  2017-06-01 16:41 [dpdk-dev] [PATCH] eventdev: remove PCI dependency Jerin Jacob
@ 2017-06-05 12:55 ` Gaëtan Rivet
  2017-06-06  3:05   ` Jerin Jacob
  2017-06-06 14:10 ` [dpdk-dev] [PATCH v2] " Jerin Jacob
  1 sibling, 1 reply; 20+ messages in thread
From: Gaëtan Rivet @ 2017-06-05 12:55 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: dev, bruce.richardson, harry.van.haaren, hemant.agrawal,
	gage.eads, nipun.gupta

Hi Jerin,

On Thu, Jun 01, 2017 at 10:11:46PM +0530, Jerin Jacob wrote:
> Remove the PCI dependency from generic data structures
> and moved the PCI specific code to rte_event_pmd_pci*
> 

Thanks for working on this.

Do you plan on removing rte_pci.h in rte_eventdev_pmd.h? Do you think it
would be feasible?

> CC: Gaetan Rivet <gaetan.rivet@6wind.com>
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
>  drivers/event/skeleton/skeleton_eventdev.c | 30 +++++++++-----
>  lib/librte_eventdev/rte_eventdev.c         | 37 +++++++-----------
>  lib/librte_eventdev/rte_eventdev.h         |  2 -
>  lib/librte_eventdev/rte_eventdev_pmd.h     | 63 ++++--------------------------
>  4 files changed, 41 insertions(+), 91 deletions(-)
> 
> diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c
> index 800bd76e0..34684aba0 100644
> --- a/drivers/event/skeleton/skeleton_eventdev.c
> +++ b/drivers/event/skeleton/skeleton_eventdev.c
> @@ -427,18 +427,28 @@ static const struct rte_pci_id pci_id_skeleton_map[] = {
>  	},
>  };
>  
> -static struct rte_eventdev_driver pci_eventdev_skeleton_pmd = {
> -	.pci_drv = {
> -		.id_table = pci_id_skeleton_map,
> -		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
> -		.probe = rte_event_pmd_pci_probe,
> -		.remove = rte_event_pmd_pci_remove,
> -	},
> -	.eventdev_init = skeleton_eventdev_init,
> -	.dev_private_size = sizeof(struct skeleton_eventdev),
> +static int
> +event_skeleton_pci_probe(struct rte_pci_driver *pci_drv,
> +			 struct rte_pci_device *pci_dev)
> +{
> +	return rte_event_pmd_pci_probe(pci_drv, pci_dev,
> +		sizeof(struct skeleton_eventdev), skeleton_eventdev_init);
> +}
> +
> +static int
> +event_skeleton_pci_remove(struct rte_pci_device *pci_dev)
> +{
> +	return rte_event_pmd_pci_remove(pci_dev, NULL);
> +}
> +
> +static struct rte_pci_driver pci_eventdev_skeleton_pmd = {
> +	.id_table = pci_id_skeleton_map,
> +	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
> +	.probe = event_skeleton_pci_probe,
> +	.remove = event_skeleton_pci_remove,
>  };
>  
> -RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd.pci_drv);
> +RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd);
>  RTE_PMD_REGISTER_PCI_TABLE(event_skeleton_pci, pci_id_skeleton_map);
>  
>  /* VDEV based event device */
> diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
> index 20afc3f0e..91f950666 100644
> --- a/lib/librte_eventdev/rte_eventdev.c
> +++ b/lib/librte_eventdev/rte_eventdev.c
> @@ -126,8 +126,6 @@ rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
>  	dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
>  
>  	dev_info->dev = dev->dev;
> -	if (dev->driver)
> -		dev_info->driver_name = dev->driver->pci_drv.driver.name;
>  	return 0;
>  }
>  
> @@ -1250,18 +1248,18 @@ rte_event_pmd_vdev_uninit(const char *name)
>  
>  int
>  rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> -			struct rte_pci_device *pci_dev)
> +			struct rte_pci_device *pci_dev,
> +			size_t private_data_size,
> +			eventdev_pmd_pci_callback_t devinit)
>  {
> -	struct rte_eventdev_driver *eventdrv;
>  	struct rte_eventdev *eventdev;
>  
>  	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
>  
>  	int retval;
>  
> -	eventdrv = (struct rte_eventdev_driver *)pci_drv;
> -	if (eventdrv == NULL)
> -		return -ENODEV;
> +	if (devinit == NULL)
> +		return -EINVAL;
>  
>  	rte_pci_device_name(&pci_dev->addr, eventdev_name,
>  			sizeof(eventdev_name));
> @@ -1275,7 +1273,7 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
>  		eventdev->data->dev_private =
>  				rte_zmalloc_socket(
>  						"eventdev private structure",
> -						eventdrv->dev_private_size,
> +						private_data_size,
>  						RTE_CACHE_LINE_SIZE,
>  						rte_socket_id());
>  
> @@ -1285,10 +1283,9 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
>  	}
>  
>  	eventdev->dev = &pci_dev->device;
> -	eventdev->driver = eventdrv;
>  
>  	/* Invoke PMD device initialization function */
> -	retval = (*eventdrv->eventdev_init)(eventdev);
> +	retval = devinit(eventdev);
>  	if (retval == 0)
>  		return 0;
>  
> @@ -1307,12 +1304,12 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
>  }
>  
>  int
> -rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
> +rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
> +			 eventdev_pmd_pci_callback_t devuninit)
>  {
> -	const struct rte_eventdev_driver *eventdrv;
>  	struct rte_eventdev *eventdev;
>  	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
> -	int ret;
> +	int ret = 0;
>  
>  	if (pci_dev == NULL)
>  		return -EINVAL;
> @@ -1324,22 +1321,16 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
>  	if (eventdev == NULL)
>  		return -ENODEV;
>  
> -	eventdrv = (const struct rte_eventdev_driver *)pci_dev->driver;
> -	if (eventdrv == NULL)
> -		return -ENODEV;
> -
>  	/* Invoke PMD device un-init function */
> -	if (*eventdrv->eventdev_uninit) {
> -		ret = (*eventdrv->eventdev_uninit)(eventdev);
> -		if (ret)
> -			return ret;
> -	}
> +	if (devuninit)
> +		ret = devuninit(eventdev);
> +	if (ret)
> +		return ret;
>  
>  	/* Free event device */
>  	rte_event_pmd_release(eventdev);
>  
>  	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 20e7293e0..c5b2b7453 100644
> --- a/lib/librte_eventdev/rte_eventdev.h
> +++ b/lib/librte_eventdev/rte_eventdev.h
> @@ -1063,8 +1063,6 @@ struct rte_eventdev {
>  	/**< Functions exported by PMD */
>  	struct rte_device *dev;
>  	/**< Device info. supplied by probing */
> -	const struct rte_eventdev_driver *driver;
> -	/**< Driver for this device */
>  
>  	RTE_STD_C11
>  	uint8_t attached : 1;
> diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
> index 4005b3c98..faa6989b4 100644
> --- a/lib/librte_eventdev/rte_eventdev_pmd.h
> +++ b/lib/librte_eventdev/rte_eventdev_pmd.h
> @@ -87,60 +87,6 @@ extern "C" {
>  #define RTE_EVENTDEV_DETACHED  (0)
>  #define RTE_EVENTDEV_ATTACHED  (1)
>  
> -/**
> - * Initialisation function of a event driver invoked for each matching
> - * event PCI device detected during the PCI probing phase.
> - *
> - * @param dev
> - *   The dev pointer is the address of the *rte_eventdev* structure associated
> - *   with the matching device and which has been [automatically] allocated in
> - *   the *rte_event_devices* array.
> - *
> - * @return
> - *   - 0: Success, the device is properly initialised by the driver.
> - *        In particular, the driver MUST have set up the *dev_ops* pointer
> - *        of the *dev* structure.
> - *   - <0: Error code of the device initialisation failure.
> - */
> -typedef int (*eventdev_init_t)(struct rte_eventdev *dev);
> -
> -/**
> - * Finalisation function of a driver invoked for each matching
> - * PCI device detected during the PCI closing phase.
> - *
> - * @param dev
> - *   The dev pointer is the address of the *rte_eventdev* structure associated
> - *   with the matching device and which	has been [automatically] allocated in
> - *   the *rte_event_devices* array.
> - *
> - * @return
> - *   - 0: Success, the device is properly finalised by the driver.
> - *        In particular, the driver MUST free the *dev_ops* pointer
> - *        of the *dev* structure.
> - *   - <0: Error code of the device initialisation failure.
> - */
> -typedef int (*eventdev_uninit_t)(struct rte_eventdev *dev);
> -
> -/**
> - * The structure associated with a PMD driver.
> - *
> - * Each driver acts as a PCI driver and is represented by a generic
> - * *event_driver* structure that holds:
> - *
> - * - An *rte_pci_driver* structure (which must be the first field).
> - *
> - * - The *eventdev_init* function invoked for each matching PCI device.
> - *
> - * - The size of the private data to allocate for each matching device.
> - */
> -struct rte_eventdev_driver {
> -	struct rte_pci_driver pci_drv;	/**< The PMD is also a PCI driver. */
> -	unsigned int dev_private_size;	/**< Size of device private data. */
> -
> -	eventdev_init_t eventdev_init;	/**< Device init function. */
> -	eventdev_uninit_t eventdev_uninit; /**< Device uninit function. */
> -};
> -
>  /** Global structure used for maintaining state of allocated event devices */
>  struct rte_eventdev_global {
>  	uint8_t nb_devs;	/**< Number of devices found */
> @@ -579,18 +525,23 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
>  int
>  rte_event_pmd_vdev_uninit(const char *name);
>  
> +typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
> +
>  /**
>   * Wrapper for use by pci drivers as a .probe function to attach to a event
>   * interface.
>   */
>  int rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> -			    struct rte_pci_device *pci_dev);
> +			    struct rte_pci_device *pci_dev,
> +			    size_t private_data_size,
> +			    eventdev_pmd_pci_callback_t devinit);
>  
>  /**
>   * Wrapper for use by pci drivers as a .remove function to detach a event
>   * interface.
>   */
> -int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev);
> +int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
> +			     eventdev_pmd_pci_callback_t devuninit);
>  
>  #ifdef __cplusplus
>  }
> -- 
> 2.13.0
> 

-- 
Gaëtan Rivet
6WIND

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH] eventdev: remove PCI dependency
  2017-06-05 12:55 ` Gaëtan Rivet
@ 2017-06-06  3:05   ` Jerin Jacob
  2017-06-06  8:09     ` Gaëtan Rivet
  0 siblings, 1 reply; 20+ messages in thread
From: Jerin Jacob @ 2017-06-06  3:05 UTC (permalink / raw)
  To: Gaëtan Rivet
  Cc: dev, bruce.richardson, harry.van.haaren, hemant.agrawal,
	gage.eads, nipun.gupta

-----Original Message-----
> Date: Mon, 5 Jun 2017 14:55:55 +0200
> From: Gaëtan Rivet <gaetan.rivet@6wind.com>
> To: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Cc: dev@dpdk.org, bruce.richardson@intel.com, harry.van.haaren@intel.com,
>  hemant.agrawal@nxp.com, gage.eads@intel.com, nipun.gupta@nxp.com
> Subject: Re: [dpdk-dev] [PATCH] eventdev: remove PCI dependency
> User-Agent: Mutt/1.5.23 (2014-03-12)
> 
> Hi Jerin,

Hi Gaëtan,

> 
> On Thu, Jun 01, 2017 at 10:11:46PM +0530, Jerin Jacob wrote:
> > Remove the PCI dependency from generic data structures
> > and moved the PCI specific code to rte_event_pmd_pci*
> > 
> 
> Thanks for working on this.
> 
> Do you plan on removing rte_pci.h in rte_eventdev_pmd.h? Do you think it
> would be feasible?

That is for PCI PMD specific probe(rte_event_pmd_pci_probe() and rte_event_pmd_pci_remove()),
More like, lib/librte_ether/rte_ethdev_pci.h functions in ethdev.
So, I think, It is OK to keep rte_pci.h for PMD specific functions.


> 
> > CC: Gaetan Rivet <gaetan.rivet@6wind.com>
> > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> > ---
> >  drivers/event/skeleton/skeleton_eventdev.c | 30 +++++++++-----
> >  lib/librte_eventdev/rte_eventdev.c         | 37 +++++++-----------
> >  lib/librte_eventdev/rte_eventdev.h         |  2 -
> >  lib/librte_eventdev/rte_eventdev_pmd.h     | 63 ++++--------------------------
> >  4 files changed, 41 insertions(+), 91 deletions(-)
> > 
> > diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c
> > index 800bd76e0..34684aba0 100644
> > --- a/drivers/event/skeleton/skeleton_eventdev.c
> > +++ b/drivers/event/skeleton/skeleton_eventdev.c
> > @@ -427,18 +427,28 @@ static const struct rte_pci_id pci_id_skeleton_map[] = {
> >  	},
> >  };
> >  
> > -static struct rte_eventdev_driver pci_eventdev_skeleton_pmd = {
> > -	.pci_drv = {
> > -		.id_table = pci_id_skeleton_map,
> > -		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
> > -		.probe = rte_event_pmd_pci_probe,
> > -		.remove = rte_event_pmd_pci_remove,
> > -	},
> > -	.eventdev_init = skeleton_eventdev_init,
> > -	.dev_private_size = sizeof(struct skeleton_eventdev),
> > +static int
> > +event_skeleton_pci_probe(struct rte_pci_driver *pci_drv,
> > +			 struct rte_pci_device *pci_dev)
> > +{
> > +	return rte_event_pmd_pci_probe(pci_drv, pci_dev,
> > +		sizeof(struct skeleton_eventdev), skeleton_eventdev_init);
> > +}
> > +
> > +static int
> > +event_skeleton_pci_remove(struct rte_pci_device *pci_dev)
> > +{
> > +	return rte_event_pmd_pci_remove(pci_dev, NULL);
> > +}
> > +
> > +static struct rte_pci_driver pci_eventdev_skeleton_pmd = {
> > +	.id_table = pci_id_skeleton_map,
> > +	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
> > +	.probe = event_skeleton_pci_probe,
> > +	.remove = event_skeleton_pci_remove,
> >  };
> >  
> > -RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd.pci_drv);
> > +RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd);
> >  RTE_PMD_REGISTER_PCI_TABLE(event_skeleton_pci, pci_id_skeleton_map);
> >  
> >  /* VDEV based event device */
> > diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
> > index 20afc3f0e..91f950666 100644
> > --- a/lib/librte_eventdev/rte_eventdev.c
> > +++ b/lib/librte_eventdev/rte_eventdev.c
> > @@ -126,8 +126,6 @@ rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
> >  	dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
> >  
> >  	dev_info->dev = dev->dev;
> > -	if (dev->driver)
> > -		dev_info->driver_name = dev->driver->pci_drv.driver.name;
> >  	return 0;
> >  }
> >  
> > @@ -1250,18 +1248,18 @@ rte_event_pmd_vdev_uninit(const char *name)
> >  
> >  int
> >  rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> > -			struct rte_pci_device *pci_dev)
> > +			struct rte_pci_device *pci_dev,
> > +			size_t private_data_size,
> > +			eventdev_pmd_pci_callback_t devinit)
> >  {
> > -	struct rte_eventdev_driver *eventdrv;
> >  	struct rte_eventdev *eventdev;
> >  
> >  	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
> >  
> >  	int retval;
> >  
> > -	eventdrv = (struct rte_eventdev_driver *)pci_drv;
> > -	if (eventdrv == NULL)
> > -		return -ENODEV;
> > +	if (devinit == NULL)
> > +		return -EINVAL;
> >  
> >  	rte_pci_device_name(&pci_dev->addr, eventdev_name,
> >  			sizeof(eventdev_name));
> > @@ -1275,7 +1273,7 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> >  		eventdev->data->dev_private =
> >  				rte_zmalloc_socket(
> >  						"eventdev private structure",
> > -						eventdrv->dev_private_size,
> > +						private_data_size,
> >  						RTE_CACHE_LINE_SIZE,
> >  						rte_socket_id());
> >  
> > @@ -1285,10 +1283,9 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> >  	}
> >  
> >  	eventdev->dev = &pci_dev->device;
> > -	eventdev->driver = eventdrv;
> >  
> >  	/* Invoke PMD device initialization function */
> > -	retval = (*eventdrv->eventdev_init)(eventdev);
> > +	retval = devinit(eventdev);
> >  	if (retval == 0)
> >  		return 0;
> >  
> > @@ -1307,12 +1304,12 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> >  }
> >  
> >  int
> > -rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
> > +rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
> > +			 eventdev_pmd_pci_callback_t devuninit)
> >  {
> > -	const struct rte_eventdev_driver *eventdrv;
> >  	struct rte_eventdev *eventdev;
> >  	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
> > -	int ret;
> > +	int ret = 0;
> >  
> >  	if (pci_dev == NULL)
> >  		return -EINVAL;
> > @@ -1324,22 +1321,16 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
> >  	if (eventdev == NULL)
> >  		return -ENODEV;
> >  
> > -	eventdrv = (const struct rte_eventdev_driver *)pci_dev->driver;
> > -	if (eventdrv == NULL)
> > -		return -ENODEV;
> > -
> >  	/* Invoke PMD device un-init function */
> > -	if (*eventdrv->eventdev_uninit) {
> > -		ret = (*eventdrv->eventdev_uninit)(eventdev);
> > -		if (ret)
> > -			return ret;
> > -	}
> > +	if (devuninit)
> > +		ret = devuninit(eventdev);
> > +	if (ret)
> > +		return ret;
> >  
> >  	/* Free event device */
> >  	rte_event_pmd_release(eventdev);
> >  
> >  	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 20e7293e0..c5b2b7453 100644
> > --- a/lib/librte_eventdev/rte_eventdev.h
> > +++ b/lib/librte_eventdev/rte_eventdev.h
> > @@ -1063,8 +1063,6 @@ struct rte_eventdev {
> >  	/**< Functions exported by PMD */
> >  	struct rte_device *dev;
> >  	/**< Device info. supplied by probing */
> > -	const struct rte_eventdev_driver *driver;
> > -	/**< Driver for this device */
> >  
> >  	RTE_STD_C11
> >  	uint8_t attached : 1;
> > diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
> > index 4005b3c98..faa6989b4 100644
> > --- a/lib/librte_eventdev/rte_eventdev_pmd.h
> > +++ b/lib/librte_eventdev/rte_eventdev_pmd.h
> > @@ -87,60 +87,6 @@ extern "C" {
> >  #define RTE_EVENTDEV_DETACHED  (0)
> >  #define RTE_EVENTDEV_ATTACHED  (1)
> >  
> > -/**
> > - * Initialisation function of a event driver invoked for each matching
> > - * event PCI device detected during the PCI probing phase.
> > - *
> > - * @param dev
> > - *   The dev pointer is the address of the *rte_eventdev* structure associated
> > - *   with the matching device and which has been [automatically] allocated in
> > - *   the *rte_event_devices* array.
> > - *
> > - * @return
> > - *   - 0: Success, the device is properly initialised by the driver.
> > - *        In particular, the driver MUST have set up the *dev_ops* pointer
> > - *        of the *dev* structure.
> > - *   - <0: Error code of the device initialisation failure.
> > - */
> > -typedef int (*eventdev_init_t)(struct rte_eventdev *dev);
> > -
> > -/**
> > - * Finalisation function of a driver invoked for each matching
> > - * PCI device detected during the PCI closing phase.
> > - *
> > - * @param dev
> > - *   The dev pointer is the address of the *rte_eventdev* structure associated
> > - *   with the matching device and which	has been [automatically] allocated in
> > - *   the *rte_event_devices* array.
> > - *
> > - * @return
> > - *   - 0: Success, the device is properly finalised by the driver.
> > - *        In particular, the driver MUST free the *dev_ops* pointer
> > - *        of the *dev* structure.
> > - *   - <0: Error code of the device initialisation failure.
> > - */
> > -typedef int (*eventdev_uninit_t)(struct rte_eventdev *dev);
> > -
> > -/**
> > - * The structure associated with a PMD driver.
> > - *
> > - * Each driver acts as a PCI driver and is represented by a generic
> > - * *event_driver* structure that holds:
> > - *
> > - * - An *rte_pci_driver* structure (which must be the first field).
> > - *
> > - * - The *eventdev_init* function invoked for each matching PCI device.
> > - *
> > - * - The size of the private data to allocate for each matching device.
> > - */
> > -struct rte_eventdev_driver {
> > -	struct rte_pci_driver pci_drv;	/**< The PMD is also a PCI driver. */
> > -	unsigned int dev_private_size;	/**< Size of device private data. */
> > -
> > -	eventdev_init_t eventdev_init;	/**< Device init function. */
> > -	eventdev_uninit_t eventdev_uninit; /**< Device uninit function. */
> > -};
> > -
> >  /** Global structure used for maintaining state of allocated event devices */
> >  struct rte_eventdev_global {
> >  	uint8_t nb_devs;	/**< Number of devices found */
> > @@ -579,18 +525,23 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
> >  int
> >  rte_event_pmd_vdev_uninit(const char *name);
> >  
> > +typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
> > +
> >  /**
> >   * Wrapper for use by pci drivers as a .probe function to attach to a event
> >   * interface.
> >   */
> >  int rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> > -			    struct rte_pci_device *pci_dev);
> > +			    struct rte_pci_device *pci_dev,
> > +			    size_t private_data_size,
> > +			    eventdev_pmd_pci_callback_t devinit);
> >  
> >  /**
> >   * Wrapper for use by pci drivers as a .remove function to detach a event
> >   * interface.
> >   */
> > -int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev);
> > +int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
> > +			     eventdev_pmd_pci_callback_t devuninit);
> >  
> >  #ifdef __cplusplus
> >  }
> > -- 
> > 2.13.0
> > 
> 
> -- 
> Gaëtan Rivet
> 6WIND

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH] eventdev: remove PCI dependency
  2017-06-06  3:05   ` Jerin Jacob
@ 2017-06-06  8:09     ` Gaëtan Rivet
  2017-06-06  9:01       ` Jerin Jacob
  0 siblings, 1 reply; 20+ messages in thread
From: Gaëtan Rivet @ 2017-06-06  8:09 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: dev, bruce.richardson, harry.van.haaren, hemant.agrawal,
	gage.eads, nipun.gupta

On Tue, Jun 06, 2017 at 08:35:48AM +0530, Jerin Jacob wrote:
> -----Original Message-----
> > Date: Mon, 5 Jun 2017 14:55:55 +0200
> > From: Gaëtan Rivet <gaetan.rivet@6wind.com>
> > To: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> > Cc: dev@dpdk.org, bruce.richardson@intel.com, harry.van.haaren@intel.com,
> >  hemant.agrawal@nxp.com, gage.eads@intel.com, nipun.gupta@nxp.com
> > Subject: Re: [dpdk-dev] [PATCH] eventdev: remove PCI dependency
> > User-Agent: Mutt/1.5.23 (2014-03-12)
> > 
> > Hi Jerin,
> 
> Hi Gaëtan,
> 
> > 
> > On Thu, Jun 01, 2017 at 10:11:46PM +0530, Jerin Jacob wrote:
> > > Remove the PCI dependency from generic data structures
> > > and moved the PCI specific code to rte_event_pmd_pci*
> > > 
> > 
> > Thanks for working on this.
> > 
> > Do you plan on removing rte_pci.h in rte_eventdev_pmd.h? Do you think it
> > would be feasible?
> 
> That is for PCI PMD specific probe(rte_event_pmd_pci_probe() and rte_event_pmd_pci_remove()),
> More like, lib/librte_ether/rte_ethdev_pci.h functions in ethdev.
> So, I think, It is OK to keep rte_pci.h for PMD specific functions.
> 
> 

Ok, sure. However rte_eventdev.c includes both rte_pci.h and
rte_eventdev_pmd.h. Can it be made independent from the PMD specific
include?

> > 
> > > CC: Gaetan Rivet <gaetan.rivet@6wind.com>
> > > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> > > ---
> > >  drivers/event/skeleton/skeleton_eventdev.c | 30 +++++++++-----
> > >  lib/librte_eventdev/rte_eventdev.c         | 37 +++++++-----------
> > >  lib/librte_eventdev/rte_eventdev.h         |  2 -
> > >  lib/librte_eventdev/rte_eventdev_pmd.h     | 63 ++++--------------------------
> > >  4 files changed, 41 insertions(+), 91 deletions(-)
> > > 
> > > diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c
> > > index 800bd76e0..34684aba0 100644
> > > --- a/drivers/event/skeleton/skeleton_eventdev.c
> > > +++ b/drivers/event/skeleton/skeleton_eventdev.c
> > > @@ -427,18 +427,28 @@ static const struct rte_pci_id pci_id_skeleton_map[] = {
> > >  	},
> > >  };
> > >  
> > > -static struct rte_eventdev_driver pci_eventdev_skeleton_pmd = {
> > > -	.pci_drv = {
> > > -		.id_table = pci_id_skeleton_map,
> > > -		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
> > > -		.probe = rte_event_pmd_pci_probe,
> > > -		.remove = rte_event_pmd_pci_remove,
> > > -	},
> > > -	.eventdev_init = skeleton_eventdev_init,
> > > -	.dev_private_size = sizeof(struct skeleton_eventdev),
> > > +static int
> > > +event_skeleton_pci_probe(struct rte_pci_driver *pci_drv,
> > > +			 struct rte_pci_device *pci_dev)
> > > +{
> > > +	return rte_event_pmd_pci_probe(pci_drv, pci_dev,
> > > +		sizeof(struct skeleton_eventdev), skeleton_eventdev_init);
> > > +}
> > > +
> > > +static int
> > > +event_skeleton_pci_remove(struct rte_pci_device *pci_dev)
> > > +{
> > > +	return rte_event_pmd_pci_remove(pci_dev, NULL);
> > > +}
> > > +
> > > +static struct rte_pci_driver pci_eventdev_skeleton_pmd = {
> > > +	.id_table = pci_id_skeleton_map,
> > > +	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
> > > +	.probe = event_skeleton_pci_probe,
> > > +	.remove = event_skeleton_pci_remove,
> > >  };
> > >  
> > > -RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd.pci_drv);
> > > +RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd);
> > >  RTE_PMD_REGISTER_PCI_TABLE(event_skeleton_pci, pci_id_skeleton_map);
> > >  
> > >  /* VDEV based event device */
> > > diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
> > > index 20afc3f0e..91f950666 100644
> > > --- a/lib/librte_eventdev/rte_eventdev.c
> > > +++ b/lib/librte_eventdev/rte_eventdev.c
> > > @@ -126,8 +126,6 @@ rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
> > >  	dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
> > >  
> > >  	dev_info->dev = dev->dev;
> > > -	if (dev->driver)
> > > -		dev_info->driver_name = dev->driver->pci_drv.driver.name;
> > >  	return 0;
> > >  }
> > >  
> > > @@ -1250,18 +1248,18 @@ rte_event_pmd_vdev_uninit(const char *name)
> > >  
> > >  int
> > >  rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> > > -			struct rte_pci_device *pci_dev)
> > > +			struct rte_pci_device *pci_dev,
> > > +			size_t private_data_size,
> > > +			eventdev_pmd_pci_callback_t devinit)
> > >  {
> > > -	struct rte_eventdev_driver *eventdrv;
> > >  	struct rte_eventdev *eventdev;
> > >  
> > >  	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
> > >  
> > >  	int retval;
> > >  
> > > -	eventdrv = (struct rte_eventdev_driver *)pci_drv;
> > > -	if (eventdrv == NULL)
> > > -		return -ENODEV;
> > > +	if (devinit == NULL)
> > > +		return -EINVAL;
> > >  
> > >  	rte_pci_device_name(&pci_dev->addr, eventdev_name,
> > >  			sizeof(eventdev_name));
> > > @@ -1275,7 +1273,7 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> > >  		eventdev->data->dev_private =
> > >  				rte_zmalloc_socket(
> > >  						"eventdev private structure",
> > > -						eventdrv->dev_private_size,
> > > +						private_data_size,
> > >  						RTE_CACHE_LINE_SIZE,
> > >  						rte_socket_id());
> > >  
> > > @@ -1285,10 +1283,9 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> > >  	}
> > >  
> > >  	eventdev->dev = &pci_dev->device;
> > > -	eventdev->driver = eventdrv;
> > >  
> > >  	/* Invoke PMD device initialization function */
> > > -	retval = (*eventdrv->eventdev_init)(eventdev);
> > > +	retval = devinit(eventdev);
> > >  	if (retval == 0)
> > >  		return 0;
> > >  
> > > @@ -1307,12 +1304,12 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> > >  }
> > >  
> > >  int
> > > -rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
> > > +rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
> > > +			 eventdev_pmd_pci_callback_t devuninit)
> > >  {
> > > -	const struct rte_eventdev_driver *eventdrv;
> > >  	struct rte_eventdev *eventdev;
> > >  	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
> > > -	int ret;
> > > +	int ret = 0;
> > >  
> > >  	if (pci_dev == NULL)
> > >  		return -EINVAL;
> > > @@ -1324,22 +1321,16 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
> > >  	if (eventdev == NULL)
> > >  		return -ENODEV;
> > >  
> > > -	eventdrv = (const struct rte_eventdev_driver *)pci_dev->driver;
> > > -	if (eventdrv == NULL)
> > > -		return -ENODEV;
> > > -
> > >  	/* Invoke PMD device un-init function */
> > > -	if (*eventdrv->eventdev_uninit) {
> > > -		ret = (*eventdrv->eventdev_uninit)(eventdev);
> > > -		if (ret)
> > > -			return ret;
> > > -	}
> > > +	if (devuninit)
> > > +		ret = devuninit(eventdev);
> > > +	if (ret)
> > > +		return ret;
> > >  
> > >  	/* Free event device */
> > >  	rte_event_pmd_release(eventdev);
> > >  
> > >  	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 20e7293e0..c5b2b7453 100644
> > > --- a/lib/librte_eventdev/rte_eventdev.h
> > > +++ b/lib/librte_eventdev/rte_eventdev.h
> > > @@ -1063,8 +1063,6 @@ struct rte_eventdev {
> > >  	/**< Functions exported by PMD */
> > >  	struct rte_device *dev;
> > >  	/**< Device info. supplied by probing */
> > > -	const struct rte_eventdev_driver *driver;
> > > -	/**< Driver for this device */
> > >  
> > >  	RTE_STD_C11
> > >  	uint8_t attached : 1;
> > > diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
> > > index 4005b3c98..faa6989b4 100644
> > > --- a/lib/librte_eventdev/rte_eventdev_pmd.h
> > > +++ b/lib/librte_eventdev/rte_eventdev_pmd.h
> > > @@ -87,60 +87,6 @@ extern "C" {
> > >  #define RTE_EVENTDEV_DETACHED  (0)
> > >  #define RTE_EVENTDEV_ATTACHED  (1)
> > >  
> > > -/**
> > > - * Initialisation function of a event driver invoked for each matching
> > > - * event PCI device detected during the PCI probing phase.
> > > - *
> > > - * @param dev
> > > - *   The dev pointer is the address of the *rte_eventdev* structure associated
> > > - *   with the matching device and which has been [automatically] allocated in
> > > - *   the *rte_event_devices* array.
> > > - *
> > > - * @return
> > > - *   - 0: Success, the device is properly initialised by the driver.
> > > - *        In particular, the driver MUST have set up the *dev_ops* pointer
> > > - *        of the *dev* structure.
> > > - *   - <0: Error code of the device initialisation failure.
> > > - */
> > > -typedef int (*eventdev_init_t)(struct rte_eventdev *dev);
> > > -
> > > -/**
> > > - * Finalisation function of a driver invoked for each matching
> > > - * PCI device detected during the PCI closing phase.
> > > - *
> > > - * @param dev
> > > - *   The dev pointer is the address of the *rte_eventdev* structure associated
> > > - *   with the matching device and which	has been [automatically] allocated in
> > > - *   the *rte_event_devices* array.
> > > - *
> > > - * @return
> > > - *   - 0: Success, the device is properly finalised by the driver.
> > > - *        In particular, the driver MUST free the *dev_ops* pointer
> > > - *        of the *dev* structure.
> > > - *   - <0: Error code of the device initialisation failure.
> > > - */
> > > -typedef int (*eventdev_uninit_t)(struct rte_eventdev *dev);
> > > -
> > > -/**
> > > - * The structure associated with a PMD driver.
> > > - *
> > > - * Each driver acts as a PCI driver and is represented by a generic
> > > - * *event_driver* structure that holds:
> > > - *
> > > - * - An *rte_pci_driver* structure (which must be the first field).
> > > - *
> > > - * - The *eventdev_init* function invoked for each matching PCI device.
> > > - *
> > > - * - The size of the private data to allocate for each matching device.
> > > - */
> > > -struct rte_eventdev_driver {
> > > -	struct rte_pci_driver pci_drv;	/**< The PMD is also a PCI driver. */
> > > -	unsigned int dev_private_size;	/**< Size of device private data. */
> > > -
> > > -	eventdev_init_t eventdev_init;	/**< Device init function. */
> > > -	eventdev_uninit_t eventdev_uninit; /**< Device uninit function. */
> > > -};
> > > -
> > >  /** Global structure used for maintaining state of allocated event devices */
> > >  struct rte_eventdev_global {
> > >  	uint8_t nb_devs;	/**< Number of devices found */
> > > @@ -579,18 +525,23 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
> > >  int
> > >  rte_event_pmd_vdev_uninit(const char *name);
> > >  
> > > +typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
> > > +
> > >  /**
> > >   * Wrapper for use by pci drivers as a .probe function to attach to a event
> > >   * interface.
> > >   */
> > >  int rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> > > -			    struct rte_pci_device *pci_dev);
> > > +			    struct rte_pci_device *pci_dev,
> > > +			    size_t private_data_size,
> > > +			    eventdev_pmd_pci_callback_t devinit);
> > >  
> > >  /**
> > >   * Wrapper for use by pci drivers as a .remove function to detach a event
> > >   * interface.
> > >   */
> > > -int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev);
> > > +int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
> > > +			     eventdev_pmd_pci_callback_t devuninit);
> > >  
> > >  #ifdef __cplusplus
> > >  }
> > > -- 
> > > 2.13.0
> > > 
> > 
> > -- 
> > Gaëtan Rivet
> > 6WIND

-- 
Gaëtan Rivet
6WIND

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH] eventdev: remove PCI dependency
  2017-06-06  8:09     ` Gaëtan Rivet
@ 2017-06-06  9:01       ` Jerin Jacob
  0 siblings, 0 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-06  9:01 UTC (permalink / raw)
  To: Gaëtan Rivet
  Cc: dev, bruce.richardson, harry.van.haaren, hemant.agrawal,
	gage.eads, nipun.gupta

-----Original Message-----
> Date: Tue, 6 Jun 2017 10:09:21 +0200
> From: Gaëtan Rivet <gaetan.rivet@6wind.com>
> To: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Cc: dev@dpdk.org, bruce.richardson@intel.com, harry.van.haaren@intel.com,
>  hemant.agrawal@nxp.com, gage.eads@intel.com, nipun.gupta@nxp.com
> Subject: Re: [dpdk-dev] [PATCH] eventdev: remove PCI dependency
> User-Agent: Mutt/1.5.23 (2014-03-12)
> 
> On Tue, Jun 06, 2017 at 08:35:48AM +0530, Jerin Jacob wrote:
> > -----Original Message-----
> > > Date: Mon, 5 Jun 2017 14:55:55 +0200
> > > From: Gaëtan Rivet <gaetan.rivet@6wind.com>
> > > To: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> > > Cc: dev@dpdk.org, bruce.richardson@intel.com, harry.van.haaren@intel.com,
> > >  hemant.agrawal@nxp.com, gage.eads@intel.com, nipun.gupta@nxp.com
> > > Subject: Re: [dpdk-dev] [PATCH] eventdev: remove PCI dependency
> > > User-Agent: Mutt/1.5.23 (2014-03-12)
> > > 
> > > Hi Jerin,
> > 
> > Hi Gaëtan,
> > 
> > > 
> > > On Thu, Jun 01, 2017 at 10:11:46PM +0530, Jerin Jacob wrote:
> > > > Remove the PCI dependency from generic data structures
> > > > and moved the PCI specific code to rte_event_pmd_pci*
> > > > 
> > > 
> > > Thanks for working on this.
> > > 
> > > Do you plan on removing rte_pci.h in rte_eventdev_pmd.h? Do you think it
> > > would be feasible?
> > 
> > That is for PCI PMD specific probe(rte_event_pmd_pci_probe() and rte_event_pmd_pci_remove()),
> > More like, lib/librte_ether/rte_ethdev_pci.h functions in ethdev.
> > So, I think, It is OK to keep rte_pci.h for PMD specific functions.
> > 
> > 
> 
> Ok, sure. However rte_eventdev.c includes both rte_pci.h and
> rte_eventdev_pmd.h. Can it be made independent from the PMD specific
> include?

Sure. I will remove rte_pci.h from rte_eventdev.c and send the v2.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev]  [PATCH v2] eventdev: remove PCI dependency
  2017-06-01 16:41 [dpdk-dev] [PATCH] eventdev: remove PCI dependency Jerin Jacob
  2017-06-05 12:55 ` Gaëtan Rivet
@ 2017-06-06 14:10 ` Jerin Jacob
  2017-06-06 14:51   ` Gaëtan Rivet
  2017-06-07  8:43   ` [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
  1 sibling, 2 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-06 14:10 UTC (permalink / raw)
  To: dev
  Cc: thomas, bruce.richardson, harry.van.haaren, hemant.agrawal,
	gage.eads, nipun.gupta, Jerin Jacob, Gaetan Rivet

Remove the PCI dependency from generic data structures
and moved the PCI specific code to rte_event_pmd_pci*

CC: Gaetan Rivet <gaetan.rivet@6wind.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
v2:
- Remove rte_pci.h from rte_eventdev.c(Gaetan)
---
 drivers/event/skeleton/skeleton_eventdev.c | 30 +++++++++-----
 lib/librte_eventdev/rte_eventdev.c         | 38 +++++++-----------
 lib/librte_eventdev/rte_eventdev.h         |  2 -
 lib/librte_eventdev/rte_eventdev_pmd.h     | 63 ++++--------------------------
 4 files changed, 41 insertions(+), 92 deletions(-)

diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c
index 800bd76e0..34684aba0 100644
--- a/drivers/event/skeleton/skeleton_eventdev.c
+++ b/drivers/event/skeleton/skeleton_eventdev.c
@@ -427,18 +427,28 @@ static const struct rte_pci_id pci_id_skeleton_map[] = {
 	},
 };
 
-static struct rte_eventdev_driver pci_eventdev_skeleton_pmd = {
-	.pci_drv = {
-		.id_table = pci_id_skeleton_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
-		.probe = rte_event_pmd_pci_probe,
-		.remove = rte_event_pmd_pci_remove,
-	},
-	.eventdev_init = skeleton_eventdev_init,
-	.dev_private_size = sizeof(struct skeleton_eventdev),
+static int
+event_skeleton_pci_probe(struct rte_pci_driver *pci_drv,
+			 struct rte_pci_device *pci_dev)
+{
+	return rte_event_pmd_pci_probe(pci_drv, pci_dev,
+		sizeof(struct skeleton_eventdev), skeleton_eventdev_init);
+}
+
+static int
+event_skeleton_pci_remove(struct rte_pci_device *pci_dev)
+{
+	return rte_event_pmd_pci_remove(pci_dev, NULL);
+}
+
+static struct rte_pci_driver pci_eventdev_skeleton_pmd = {
+	.id_table = pci_id_skeleton_map,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+	.probe = event_skeleton_pci_probe,
+	.remove = event_skeleton_pci_remove,
 };
 
-RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd.pci_drv);
+RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(event_skeleton_pci, pci_id_skeleton_map);
 
 /* VDEV based event device */
diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index 20afc3f0e..fd0406747 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -45,7 +45,6 @@
 #include <rte_log.h>
 #include <rte_debug.h>
 #include <rte_dev.h>
-#include <rte_pci.h>
 #include <rte_memory.h>
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
@@ -126,8 +125,6 @@ rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
 	dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
 
 	dev_info->dev = dev->dev;
-	if (dev->driver)
-		dev_info->driver_name = dev->driver->pci_drv.driver.name;
 	return 0;
 }
 
@@ -1250,18 +1247,18 @@ rte_event_pmd_vdev_uninit(const char *name)
 
 int
 rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
-			struct rte_pci_device *pci_dev)
+			struct rte_pci_device *pci_dev,
+			size_t private_data_size,
+			eventdev_pmd_pci_callback_t devinit)
 {
-	struct rte_eventdev_driver *eventdrv;
 	struct rte_eventdev *eventdev;
 
 	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
 
 	int retval;
 
-	eventdrv = (struct rte_eventdev_driver *)pci_drv;
-	if (eventdrv == NULL)
-		return -ENODEV;
+	if (devinit == NULL)
+		return -EINVAL;
 
 	rte_pci_device_name(&pci_dev->addr, eventdev_name,
 			sizeof(eventdev_name));
@@ -1275,7 +1272,7 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 		eventdev->data->dev_private =
 				rte_zmalloc_socket(
 						"eventdev private structure",
-						eventdrv->dev_private_size,
+						private_data_size,
 						RTE_CACHE_LINE_SIZE,
 						rte_socket_id());
 
@@ -1285,10 +1282,9 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 	}
 
 	eventdev->dev = &pci_dev->device;
-	eventdev->driver = eventdrv;
 
 	/* Invoke PMD device initialization function */
-	retval = (*eventdrv->eventdev_init)(eventdev);
+	retval = devinit(eventdev);
 	if (retval == 0)
 		return 0;
 
@@ -1307,12 +1303,12 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 }
 
 int
-rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
+rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
+			 eventdev_pmd_pci_callback_t devuninit)
 {
-	const struct rte_eventdev_driver *eventdrv;
 	struct rte_eventdev *eventdev;
 	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
-	int ret;
+	int ret = 0;
 
 	if (pci_dev == NULL)
 		return -EINVAL;
@@ -1324,22 +1320,16 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
 	if (eventdev == NULL)
 		return -ENODEV;
 
-	eventdrv = (const struct rte_eventdev_driver *)pci_dev->driver;
-	if (eventdrv == NULL)
-		return -ENODEV;
-
 	/* Invoke PMD device un-init function */
-	if (*eventdrv->eventdev_uninit) {
-		ret = (*eventdrv->eventdev_uninit)(eventdev);
-		if (ret)
-			return ret;
-	}
+	if (devuninit)
+		ret = devuninit(eventdev);
+	if (ret)
+		return ret;
 
 	/* Free event device */
 	rte_event_pmd_release(eventdev);
 
 	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 20e7293e0..c5b2b7453 100644
--- a/lib/librte_eventdev/rte_eventdev.h
+++ b/lib/librte_eventdev/rte_eventdev.h
@@ -1063,8 +1063,6 @@ struct rte_eventdev {
 	/**< Functions exported by PMD */
 	struct rte_device *dev;
 	/**< Device info. supplied by probing */
-	const struct rte_eventdev_driver *driver;
-	/**< Driver for this device */
 
 	RTE_STD_C11
 	uint8_t attached : 1;
diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
index 4005b3c98..faa6989b4 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd.h
@@ -87,60 +87,6 @@ extern "C" {
 #define RTE_EVENTDEV_DETACHED  (0)
 #define RTE_EVENTDEV_ATTACHED  (1)
 
-/**
- * Initialisation function of a event driver invoked for each matching
- * event PCI device detected during the PCI probing phase.
- *
- * @param dev
- *   The dev pointer is the address of the *rte_eventdev* structure associated
- *   with the matching device and which has been [automatically] allocated in
- *   the *rte_event_devices* array.
- *
- * @return
- *   - 0: Success, the device is properly initialised by the driver.
- *        In particular, the driver MUST have set up the *dev_ops* pointer
- *        of the *dev* structure.
- *   - <0: Error code of the device initialisation failure.
- */
-typedef int (*eventdev_init_t)(struct rte_eventdev *dev);
-
-/**
- * Finalisation function of a driver invoked for each matching
- * PCI device detected during the PCI closing phase.
- *
- * @param dev
- *   The dev pointer is the address of the *rte_eventdev* structure associated
- *   with the matching device and which	has been [automatically] allocated in
- *   the *rte_event_devices* array.
- *
- * @return
- *   - 0: Success, the device is properly finalised by the driver.
- *        In particular, the driver MUST free the *dev_ops* pointer
- *        of the *dev* structure.
- *   - <0: Error code of the device initialisation failure.
- */
-typedef int (*eventdev_uninit_t)(struct rte_eventdev *dev);
-
-/**
- * The structure associated with a PMD driver.
- *
- * Each driver acts as a PCI driver and is represented by a generic
- * *event_driver* structure that holds:
- *
- * - An *rte_pci_driver* structure (which must be the first field).
- *
- * - The *eventdev_init* function invoked for each matching PCI device.
- *
- * - The size of the private data to allocate for each matching device.
- */
-struct rte_eventdev_driver {
-	struct rte_pci_driver pci_drv;	/**< The PMD is also a PCI driver. */
-	unsigned int dev_private_size;	/**< Size of device private data. */
-
-	eventdev_init_t eventdev_init;	/**< Device init function. */
-	eventdev_uninit_t eventdev_uninit; /**< Device uninit function. */
-};
-
 /** Global structure used for maintaining state of allocated event devices */
 struct rte_eventdev_global {
 	uint8_t nb_devs;	/**< Number of devices found */
@@ -579,18 +525,23 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
 int
 rte_event_pmd_vdev_uninit(const char *name);
 
+typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
+
 /**
  * Wrapper for use by pci drivers as a .probe function to attach to a event
  * interface.
  */
 int rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
-			    struct rte_pci_device *pci_dev);
+			    struct rte_pci_device *pci_dev,
+			    size_t private_data_size,
+			    eventdev_pmd_pci_callback_t devinit);
 
 /**
  * Wrapper for use by pci drivers as a .remove function to detach a event
  * interface.
  */
-int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev);
+int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
+			     eventdev_pmd_pci_callback_t devuninit);
 
 #ifdef __cplusplus
 }
-- 
2.13.0

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eventdev: remove PCI dependency
  2017-06-06 14:10 ` [dpdk-dev] [PATCH v2] " Jerin Jacob
@ 2017-06-06 14:51   ` Gaëtan Rivet
  2017-06-07  8:43   ` [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
  1 sibling, 0 replies; 20+ messages in thread
From: Gaëtan Rivet @ 2017-06-06 14:51 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: dev, thomas, bruce.richardson, harry.van.haaren, hemant.agrawal,
	gage.eads, nipun.gupta

On Tue, Jun 06, 2017 at 07:40:46PM +0530, Jerin Jacob wrote:
> Remove the PCI dependency from generic data structures
> and moved the PCI specific code to rte_event_pmd_pci*
> 
> CC: Gaetan Rivet <gaetan.rivet@6wind.com>
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
> v2:
> - Remove rte_pci.h from rte_eventdev.c(Gaetan)

Unfortunately this is not sufficient. There is still
rte_eventdev_pmd.h including rte_pci.h. As you said, it should be
possible for the PMD API to include rte_pci.h, but this is at the
condition that this layer is only included by PMDs, not the library
itself.

make
rm build/include/rte_pci.h
make lib/librte_eventdev_sub

Should allow you to verify that everything is fine.

> ---
>  drivers/event/skeleton/skeleton_eventdev.c | 30 +++++++++-----
>  lib/librte_eventdev/rte_eventdev.c         | 38 +++++++-----------
>  lib/librte_eventdev/rte_eventdev.h         |  2 -
>  lib/librte_eventdev/rte_eventdev_pmd.h     | 63 ++++--------------------------
>  4 files changed, 41 insertions(+), 92 deletions(-)
> 
> diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c
> index 800bd76e0..34684aba0 100644
> --- a/drivers/event/skeleton/skeleton_eventdev.c
> +++ b/drivers/event/skeleton/skeleton_eventdev.c
> @@ -427,18 +427,28 @@ static const struct rte_pci_id pci_id_skeleton_map[] = {
>  	},
>  };
>  
> -static struct rte_eventdev_driver pci_eventdev_skeleton_pmd = {
> -	.pci_drv = {
> -		.id_table = pci_id_skeleton_map,
> -		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
> -		.probe = rte_event_pmd_pci_probe,
> -		.remove = rte_event_pmd_pci_remove,
> -	},
> -	.eventdev_init = skeleton_eventdev_init,
> -	.dev_private_size = sizeof(struct skeleton_eventdev),
> +static int
> +event_skeleton_pci_probe(struct rte_pci_driver *pci_drv,
> +			 struct rte_pci_device *pci_dev)
> +{
> +	return rte_event_pmd_pci_probe(pci_drv, pci_dev,
> +		sizeof(struct skeleton_eventdev), skeleton_eventdev_init);
> +}
> +
> +static int
> +event_skeleton_pci_remove(struct rte_pci_device *pci_dev)
> +{
> +	return rte_event_pmd_pci_remove(pci_dev, NULL);
> +}
> +
> +static struct rte_pci_driver pci_eventdev_skeleton_pmd = {
> +	.id_table = pci_id_skeleton_map,
> +	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
> +	.probe = event_skeleton_pci_probe,
> +	.remove = event_skeleton_pci_remove,
>  };
>  
> -RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd.pci_drv);
> +RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd);
>  RTE_PMD_REGISTER_PCI_TABLE(event_skeleton_pci, pci_id_skeleton_map);
>  
>  /* VDEV based event device */
> diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
> index 20afc3f0e..fd0406747 100644
> --- a/lib/librte_eventdev/rte_eventdev.c
> +++ b/lib/librte_eventdev/rte_eventdev.c
> @@ -45,7 +45,6 @@
>  #include <rte_log.h>
>  #include <rte_debug.h>
>  #include <rte_dev.h>
> -#include <rte_pci.h>
>  #include <rte_memory.h>
>  #include <rte_memcpy.h>
>  #include <rte_memzone.h>
> @@ -126,8 +125,6 @@ rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
>  	dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
>  
>  	dev_info->dev = dev->dev;
> -	if (dev->driver)
> -		dev_info->driver_name = dev->driver->pci_drv.driver.name;
>  	return 0;
>  }
>  
> @@ -1250,18 +1247,18 @@ rte_event_pmd_vdev_uninit(const char *name)
>  
>  int
>  rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> -			struct rte_pci_device *pci_dev)
> +			struct rte_pci_device *pci_dev,
> +			size_t private_data_size,
> +			eventdev_pmd_pci_callback_t devinit)
>  {
> -	struct rte_eventdev_driver *eventdrv;
>  	struct rte_eventdev *eventdev;
>  
>  	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
>  
>  	int retval;
>  
> -	eventdrv = (struct rte_eventdev_driver *)pci_drv;
> -	if (eventdrv == NULL)
> -		return -ENODEV;
> +	if (devinit == NULL)
> +		return -EINVAL;
>  
>  	rte_pci_device_name(&pci_dev->addr, eventdev_name,
>  			sizeof(eventdev_name));
> @@ -1275,7 +1272,7 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
>  		eventdev->data->dev_private =
>  				rte_zmalloc_socket(
>  						"eventdev private structure",
> -						eventdrv->dev_private_size,
> +						private_data_size,
>  						RTE_CACHE_LINE_SIZE,
>  						rte_socket_id());
>  
> @@ -1285,10 +1282,9 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
>  	}
>  
>  	eventdev->dev = &pci_dev->device;
> -	eventdev->driver = eventdrv;
>  
>  	/* Invoke PMD device initialization function */
> -	retval = (*eventdrv->eventdev_init)(eventdev);
> +	retval = devinit(eventdev);
>  	if (retval == 0)
>  		return 0;
>  
> @@ -1307,12 +1303,12 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
>  }
>  
>  int
> -rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
> +rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
> +			 eventdev_pmd_pci_callback_t devuninit)
>  {
> -	const struct rte_eventdev_driver *eventdrv;
>  	struct rte_eventdev *eventdev;
>  	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
> -	int ret;
> +	int ret = 0;
>  
>  	if (pci_dev == NULL)
>  		return -EINVAL;
> @@ -1324,22 +1320,16 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
>  	if (eventdev == NULL)
>  		return -ENODEV;
>  
> -	eventdrv = (const struct rte_eventdev_driver *)pci_dev->driver;
> -	if (eventdrv == NULL)
> -		return -ENODEV;
> -
>  	/* Invoke PMD device un-init function */
> -	if (*eventdrv->eventdev_uninit) {
> -		ret = (*eventdrv->eventdev_uninit)(eventdev);
> -		if (ret)
> -			return ret;
> -	}
> +	if (devuninit)
> +		ret = devuninit(eventdev);
> +	if (ret)
> +		return ret;
>  
>  	/* Free event device */
>  	rte_event_pmd_release(eventdev);
>  
>  	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 20e7293e0..c5b2b7453 100644
> --- a/lib/librte_eventdev/rte_eventdev.h
> +++ b/lib/librte_eventdev/rte_eventdev.h
> @@ -1063,8 +1063,6 @@ struct rte_eventdev {
>  	/**< Functions exported by PMD */
>  	struct rte_device *dev;
>  	/**< Device info. supplied by probing */
> -	const struct rte_eventdev_driver *driver;
> -	/**< Driver for this device */
>  
>  	RTE_STD_C11
>  	uint8_t attached : 1;
> diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
> index 4005b3c98..faa6989b4 100644
> --- a/lib/librte_eventdev/rte_eventdev_pmd.h
> +++ b/lib/librte_eventdev/rte_eventdev_pmd.h
> @@ -87,60 +87,6 @@ extern "C" {
>  #define RTE_EVENTDEV_DETACHED  (0)
>  #define RTE_EVENTDEV_ATTACHED  (1)
>  
> -/**
> - * Initialisation function of a event driver invoked for each matching
> - * event PCI device detected during the PCI probing phase.
> - *
> - * @param dev
> - *   The dev pointer is the address of the *rte_eventdev* structure associated
> - *   with the matching device and which has been [automatically] allocated in
> - *   the *rte_event_devices* array.
> - *
> - * @return
> - *   - 0: Success, the device is properly initialised by the driver.
> - *        In particular, the driver MUST have set up the *dev_ops* pointer
> - *        of the *dev* structure.
> - *   - <0: Error code of the device initialisation failure.
> - */
> -typedef int (*eventdev_init_t)(struct rte_eventdev *dev);
> -
> -/**
> - * Finalisation function of a driver invoked for each matching
> - * PCI device detected during the PCI closing phase.
> - *
> - * @param dev
> - *   The dev pointer is the address of the *rte_eventdev* structure associated
> - *   with the matching device and which	has been [automatically] allocated in
> - *   the *rte_event_devices* array.
> - *
> - * @return
> - *   - 0: Success, the device is properly finalised by the driver.
> - *        In particular, the driver MUST free the *dev_ops* pointer
> - *        of the *dev* structure.
> - *   - <0: Error code of the device initialisation failure.
> - */
> -typedef int (*eventdev_uninit_t)(struct rte_eventdev *dev);
> -
> -/**
> - * The structure associated with a PMD driver.
> - *
> - * Each driver acts as a PCI driver and is represented by a generic
> - * *event_driver* structure that holds:
> - *
> - * - An *rte_pci_driver* structure (which must be the first field).
> - *
> - * - The *eventdev_init* function invoked for each matching PCI device.
> - *
> - * - The size of the private data to allocate for each matching device.
> - */
> -struct rte_eventdev_driver {
> -	struct rte_pci_driver pci_drv;	/**< The PMD is also a PCI driver. */
> -	unsigned int dev_private_size;	/**< Size of device private data. */
> -
> -	eventdev_init_t eventdev_init;	/**< Device init function. */
> -	eventdev_uninit_t eventdev_uninit; /**< Device uninit function. */
> -};
> -
>  /** Global structure used for maintaining state of allocated event devices */
>  struct rte_eventdev_global {
>  	uint8_t nb_devs;	/**< Number of devices found */
> @@ -579,18 +525,23 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
>  int
>  rte_event_pmd_vdev_uninit(const char *name);
>  
> +typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
> +
>  /**
>   * Wrapper for use by pci drivers as a .probe function to attach to a event
>   * interface.
>   */
>  int rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
> -			    struct rte_pci_device *pci_dev);
> +			    struct rte_pci_device *pci_dev,
> +			    size_t private_data_size,
> +			    eventdev_pmd_pci_callback_t devinit);
>  
>  /**
>   * Wrapper for use by pci drivers as a .remove function to detach a event
>   * interface.
>   */
> -int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev);
> +int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
> +			     eventdev_pmd_pci_callback_t devuninit);
>  
>  #ifdef __cplusplus
>  }
> -- 
> 2.13.0
> 

-- 
Gaëtan Rivet
6WIND

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library
  2017-06-06 14:10 ` [dpdk-dev] [PATCH v2] " Jerin Jacob
  2017-06-06 14:51   ` Gaëtan Rivet
@ 2017-06-07  8:43   ` Jerin Jacob
  2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 1/4] eventdev: remove PCI dependency from generic data structures Jerin Jacob
                       ` (4 more replies)
  1 sibling, 5 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-07  8:43 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, harry.van.haaren, hemant.agrawal, gage.eads,
	nipun.gupta, narender.vangati, nikhil.rao, gaetan.rivet,
	Jerin Jacob

v3:
Removed the bus dependency by spliting lib/librte_eventdev/rte_eventdev_pmd_pci.h
and lib/librte_eventdev/rte_eventdev_pmd_vdev.h

Jerin Jacob (4):
  eventdev: remove PCI dependency from generic data structures
  eventdev: restructure event PMD release function
  eventdev: make PCI probe and remove functions optional
  eventdev: make vdev init and uninit functions optional

 drivers/event/octeontx/ssovf_evdev.h        |   2 +-
 drivers/event/octeontx/ssovf_worker.h       |   1 +
 drivers/event/skeleton/skeleton_eventdev.c  |  33 +++---
 drivers/event/skeleton/skeleton_eventdev.h  |   3 +-
 drivers/event/sw/sw_evdev.h                 |   2 +-
 lib/librte_eventdev/Makefile                |   2 +
 lib/librte_eventdev/rte_eventdev.c          | 148 -------------------------
 lib/librte_eventdev/rte_eventdev.h          |   2 -
 lib/librte_eventdev/rte_eventdev_pmd.h      | 101 +-----------------
 lib/librte_eventdev/rte_eventdev_pmd_pci.h  | 160 ++++++++++++++++++++++++++++
 lib/librte_eventdev/rte_eventdev_pmd_vdev.h | 133 +++++++++++++++++++++++
 11 files changed, 323 insertions(+), 264 deletions(-)
 create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_pci.h
 create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_vdev.h

-- 
2.13.0

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v2 1/4] eventdev: remove PCI dependency from generic data structures
  2017-06-07  8:43   ` [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
@ 2017-06-07  8:43     ` Jerin Jacob
  2017-06-09  8:37       ` [dpdk-dev] [PATCH v4 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
  2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 2/4] eventdev: restructure event PMD release function Jerin Jacob
                       ` (3 subsequent siblings)
  4 siblings, 1 reply; 20+ messages in thread
From: Jerin Jacob @ 2017-06-07  8:43 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, harry.van.haaren, hemant.agrawal, gage.eads,
	nipun.gupta, narender.vangati, nikhil.rao, gaetan.rivet,
	Jerin Jacob

Remove the PCI dependency from generic data structures
and moved the PCI specific code to rte_event_pmd_pci*

CC: Gaetan Rivet <gaetan.rivet@6wind.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 drivers/event/skeleton/skeleton_eventdev.c | 30 +++++++++-----
 lib/librte_eventdev/rte_eventdev.c         | 38 +++++++-----------
 lib/librte_eventdev/rte_eventdev.h         |  2 -
 lib/librte_eventdev/rte_eventdev_pmd.h     | 63 ++++--------------------------
 4 files changed, 41 insertions(+), 92 deletions(-)

diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c
index 800bd76e0..34684aba0 100644
--- a/drivers/event/skeleton/skeleton_eventdev.c
+++ b/drivers/event/skeleton/skeleton_eventdev.c
@@ -427,18 +427,28 @@ static const struct rte_pci_id pci_id_skeleton_map[] = {
 	},
 };
 
-static struct rte_eventdev_driver pci_eventdev_skeleton_pmd = {
-	.pci_drv = {
-		.id_table = pci_id_skeleton_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
-		.probe = rte_event_pmd_pci_probe,
-		.remove = rte_event_pmd_pci_remove,
-	},
-	.eventdev_init = skeleton_eventdev_init,
-	.dev_private_size = sizeof(struct skeleton_eventdev),
+static int
+event_skeleton_pci_probe(struct rte_pci_driver *pci_drv,
+			 struct rte_pci_device *pci_dev)
+{
+	return rte_event_pmd_pci_probe(pci_drv, pci_dev,
+		sizeof(struct skeleton_eventdev), skeleton_eventdev_init);
+}
+
+static int
+event_skeleton_pci_remove(struct rte_pci_device *pci_dev)
+{
+	return rte_event_pmd_pci_remove(pci_dev, NULL);
+}
+
+static struct rte_pci_driver pci_eventdev_skeleton_pmd = {
+	.id_table = pci_id_skeleton_map,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+	.probe = event_skeleton_pci_probe,
+	.remove = event_skeleton_pci_remove,
 };
 
-RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd.pci_drv);
+RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(event_skeleton_pci, pci_id_skeleton_map);
 
 /* VDEV based event device */
diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index 20afc3f0e..fd0406747 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -45,7 +45,6 @@
 #include <rte_log.h>
 #include <rte_debug.h>
 #include <rte_dev.h>
-#include <rte_pci.h>
 #include <rte_memory.h>
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
@@ -126,8 +125,6 @@ rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
 	dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
 
 	dev_info->dev = dev->dev;
-	if (dev->driver)
-		dev_info->driver_name = dev->driver->pci_drv.driver.name;
 	return 0;
 }
 
@@ -1250,18 +1247,18 @@ rte_event_pmd_vdev_uninit(const char *name)
 
 int
 rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
-			struct rte_pci_device *pci_dev)
+			struct rte_pci_device *pci_dev,
+			size_t private_data_size,
+			eventdev_pmd_pci_callback_t devinit)
 {
-	struct rte_eventdev_driver *eventdrv;
 	struct rte_eventdev *eventdev;
 
 	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
 
 	int retval;
 
-	eventdrv = (struct rte_eventdev_driver *)pci_drv;
-	if (eventdrv == NULL)
-		return -ENODEV;
+	if (devinit == NULL)
+		return -EINVAL;
 
 	rte_pci_device_name(&pci_dev->addr, eventdev_name,
 			sizeof(eventdev_name));
@@ -1275,7 +1272,7 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 		eventdev->data->dev_private =
 				rte_zmalloc_socket(
 						"eventdev private structure",
-						eventdrv->dev_private_size,
+						private_data_size,
 						RTE_CACHE_LINE_SIZE,
 						rte_socket_id());
 
@@ -1285,10 +1282,9 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 	}
 
 	eventdev->dev = &pci_dev->device;
-	eventdev->driver = eventdrv;
 
 	/* Invoke PMD device initialization function */
-	retval = (*eventdrv->eventdev_init)(eventdev);
+	retval = devinit(eventdev);
 	if (retval == 0)
 		return 0;
 
@@ -1307,12 +1303,12 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 }
 
 int
-rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
+rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
+			 eventdev_pmd_pci_callback_t devuninit)
 {
-	const struct rte_eventdev_driver *eventdrv;
 	struct rte_eventdev *eventdev;
 	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
-	int ret;
+	int ret = 0;
 
 	if (pci_dev == NULL)
 		return -EINVAL;
@@ -1324,22 +1320,16 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
 	if (eventdev == NULL)
 		return -ENODEV;
 
-	eventdrv = (const struct rte_eventdev_driver *)pci_dev->driver;
-	if (eventdrv == NULL)
-		return -ENODEV;
-
 	/* Invoke PMD device un-init function */
-	if (*eventdrv->eventdev_uninit) {
-		ret = (*eventdrv->eventdev_uninit)(eventdev);
-		if (ret)
-			return ret;
-	}
+	if (devuninit)
+		ret = devuninit(eventdev);
+	if (ret)
+		return ret;
 
 	/* Free event device */
 	rte_event_pmd_release(eventdev);
 
 	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 20e7293e0..c5b2b7453 100644
--- a/lib/librte_eventdev/rte_eventdev.h
+++ b/lib/librte_eventdev/rte_eventdev.h
@@ -1063,8 +1063,6 @@ struct rte_eventdev {
 	/**< Functions exported by PMD */
 	struct rte_device *dev;
 	/**< Device info. supplied by probing */
-	const struct rte_eventdev_driver *driver;
-	/**< Driver for this device */
 
 	RTE_STD_C11
 	uint8_t attached : 1;
diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
index 4005b3c98..faa6989b4 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd.h
@@ -87,60 +87,6 @@ extern "C" {
 #define RTE_EVENTDEV_DETACHED  (0)
 #define RTE_EVENTDEV_ATTACHED  (1)
 
-/**
- * Initialisation function of a event driver invoked for each matching
- * event PCI device detected during the PCI probing phase.
- *
- * @param dev
- *   The dev pointer is the address of the *rte_eventdev* structure associated
- *   with the matching device and which has been [automatically] allocated in
- *   the *rte_event_devices* array.
- *
- * @return
- *   - 0: Success, the device is properly initialised by the driver.
- *        In particular, the driver MUST have set up the *dev_ops* pointer
- *        of the *dev* structure.
- *   - <0: Error code of the device initialisation failure.
- */
-typedef int (*eventdev_init_t)(struct rte_eventdev *dev);
-
-/**
- * Finalisation function of a driver invoked for each matching
- * PCI device detected during the PCI closing phase.
- *
- * @param dev
- *   The dev pointer is the address of the *rte_eventdev* structure associated
- *   with the matching device and which	has been [automatically] allocated in
- *   the *rte_event_devices* array.
- *
- * @return
- *   - 0: Success, the device is properly finalised by the driver.
- *        In particular, the driver MUST free the *dev_ops* pointer
- *        of the *dev* structure.
- *   - <0: Error code of the device initialisation failure.
- */
-typedef int (*eventdev_uninit_t)(struct rte_eventdev *dev);
-
-/**
- * The structure associated with a PMD driver.
- *
- * Each driver acts as a PCI driver and is represented by a generic
- * *event_driver* structure that holds:
- *
- * - An *rte_pci_driver* structure (which must be the first field).
- *
- * - The *eventdev_init* function invoked for each matching PCI device.
- *
- * - The size of the private data to allocate for each matching device.
- */
-struct rte_eventdev_driver {
-	struct rte_pci_driver pci_drv;	/**< The PMD is also a PCI driver. */
-	unsigned int dev_private_size;	/**< Size of device private data. */
-
-	eventdev_init_t eventdev_init;	/**< Device init function. */
-	eventdev_uninit_t eventdev_uninit; /**< Device uninit function. */
-};
-
 /** Global structure used for maintaining state of allocated event devices */
 struct rte_eventdev_global {
 	uint8_t nb_devs;	/**< Number of devices found */
@@ -579,18 +525,23 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
 int
 rte_event_pmd_vdev_uninit(const char *name);
 
+typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
+
 /**
  * Wrapper for use by pci drivers as a .probe function to attach to a event
  * interface.
  */
 int rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
-			    struct rte_pci_device *pci_dev);
+			    struct rte_pci_device *pci_dev,
+			    size_t private_data_size,
+			    eventdev_pmd_pci_callback_t devinit);
 
 /**
  * Wrapper for use by pci drivers as a .remove function to detach a event
  * interface.
  */
-int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev);
+int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
+			     eventdev_pmd_pci_callback_t devuninit);
 
 #ifdef __cplusplus
 }
-- 
2.13.0

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v2 2/4] eventdev: restructure event PMD release function
  2017-06-07  8:43   ` [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
  2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 1/4] eventdev: remove PCI dependency from generic data structures Jerin Jacob
@ 2017-06-07  8:43     ` Jerin Jacob
  2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 3/4] eventdev: make PCI probe and remove functions optional Jerin Jacob
                       ` (2 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-07  8:43 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, harry.van.haaren, hemant.agrawal, gage.eads,
	nipun.gupta, narender.vangati, nikhil.rao, gaetan.rivet,
	Jerin Jacob

Remove rte_event_dev_close() from rte_event_pmd_release() function so
that  rte_event_pmd_release() can be used in stateless way. This will
enable rte_event_pmd_vdev_uninit() function to avoid using
eventdev_globals  global variable and the need for exposing the a
global variable to PMD.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 lib/librte_eventdev/rte_eventdev.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index fd0406747..74a2614c4 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -1171,10 +1171,6 @@ rte_event_pmd_release(struct rte_eventdev *eventdev)
 	if (eventdev == NULL)
 		return -EINVAL;
 
-	ret = rte_event_dev_close(eventdev->data->dev_id);
-	if (ret < 0)
-		return ret;
-
 	eventdev->attached = RTE_EVENTDEV_DETACHED;
 	eventdev_globals.nb_devs--;
 
@@ -1230,6 +1226,7 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
 int
 rte_event_pmd_vdev_uninit(const char *name)
 {
+	int ret;
 	struct rte_eventdev *eventdev;
 
 	if (name == NULL)
@@ -1239,6 +1236,10 @@ rte_event_pmd_vdev_uninit(const char *name)
 	if (eventdev == NULL)
 		return -ENODEV;
 
+	ret = rte_event_dev_close(eventdev->data->dev_id);
+	if (ret < 0)
+		return ret;
+
 	/* Free the event device */
 	rte_event_pmd_release(eventdev);
 
@@ -1293,11 +1294,7 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 			(unsigned int) pci_dev->id.vendor_id,
 			(unsigned int) pci_dev->id.device_id);
 
-	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
-		rte_free(eventdev->data->dev_private);
-
-	eventdev->attached = RTE_EVENTDEV_DETACHED;
-	eventdev_globals.nb_devs--;
+	rte_event_pmd_release(eventdev);
 
 	return -ENXIO;
 }
@@ -1320,6 +1317,10 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
 	if (eventdev == NULL)
 		return -ENODEV;
 
+	ret = rte_event_dev_close(eventdev->data->dev_id);
+	if (ret < 0)
+		return ret;
+
 	/* Invoke PMD device un-init function */
 	if (devuninit)
 		ret = devuninit(eventdev);
-- 
2.13.0

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v2 3/4] eventdev: make PCI probe and remove functions optional
  2017-06-07  8:43   ` [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
  2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 1/4] eventdev: remove PCI dependency from generic data structures Jerin Jacob
  2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 2/4] eventdev: restructure event PMD release function Jerin Jacob
@ 2017-06-07  8:43     ` Jerin Jacob
  2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 4/4] eventdev: make vdev init and uninit " Jerin Jacob
  2017-06-07  9:27     ` [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library Gaëtan Rivet
  4 siblings, 0 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-07  8:43 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, harry.van.haaren, hemant.agrawal, gage.eads,
	nipun.gupta, narender.vangati, nikhil.rao, gaetan.rivet,
	Jerin Jacob

Made libeventdev library independent of PCI bus by moving pci pmd
specific function to rte_eventdev_pmd_pci.h header file. Eventdev PCI
PMD can include that for generic eventdev PCI probe and remove function
enablement.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 drivers/event/octeontx/ssovf_worker.h      |   1 +
 drivers/event/skeleton/skeleton_eventdev.c |   3 +-
 drivers/event/skeleton/skeleton_eventdev.h |   2 +-
 lib/librte_eventdev/Makefile               |   1 +
 lib/librte_eventdev/rte_eventdev.c         |  89 ----------------
 lib/librte_eventdev/rte_eventdev_pmd.h     |  23 +----
 lib/librte_eventdev/rte_eventdev_pmd_pci.h | 160 +++++++++++++++++++++++++++++
 7 files changed, 166 insertions(+), 113 deletions(-)
 create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_pci.h

diff --git a/drivers/event/octeontx/ssovf_worker.h b/drivers/event/octeontx/ssovf_worker.h
index 300dfae83..50368ec32 100644
--- a/drivers/event/octeontx/ssovf_worker.h
+++ b/drivers/event/octeontx/ssovf_worker.h
@@ -32,6 +32,7 @@
 
 
 #include <rte_common.h>
+#include <rte_branch_prediction.h>
 
 #include "ssovf_evdev.h"
 
diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c
index 34684aba0..c69c2168e 100644
--- a/drivers/event/skeleton/skeleton_eventdev.c
+++ b/drivers/event/skeleton/skeleton_eventdev.c
@@ -43,10 +43,9 @@
 #include <rte_dev.h>
 #include <rte_eal.h>
 #include <rte_log.h>
+#include <rte_malloc.h>
 #include <rte_memory.h>
 #include <rte_memzone.h>
-#include <rte_malloc.h>
-#include <rte_pci.h>
 #include <rte_lcore.h>
 #include <rte_vdev.h>
 
diff --git a/drivers/event/skeleton/skeleton_eventdev.h b/drivers/event/skeleton/skeleton_eventdev.h
index 1ce62da7d..5b59fcbc0 100644
--- a/drivers/event/skeleton/skeleton_eventdev.h
+++ b/drivers/event/skeleton/skeleton_eventdev.h
@@ -33,7 +33,7 @@
 #ifndef __SKELETON_EVENTDEV_H__
 #define __SKELETON_EVENTDEV_H__
 
-#include <rte_eventdev_pmd.h>
+#include <rte_eventdev_pmd_pci.h>
 
 #ifdef RTE_LIBRTE_PMD_SKELETON_EVENTDEV_DEBUG
 #define PMD_DRV_LOG(level, fmt, args...) \
diff --git a/lib/librte_eventdev/Makefile b/lib/librte_eventdev/Makefile
index e06346a66..040556fc4 100644
--- a/lib/librte_eventdev/Makefile
+++ b/lib/librte_eventdev/Makefile
@@ -46,6 +46,7 @@ SRCS-y += rte_eventdev.c
 # export include files
 SYMLINK-y-include += rte_eventdev.h
 SYMLINK-y-include += rte_eventdev_pmd.h
+SYMLINK-y-include += rte_eventdev_pmd_pci.h
 
 # versioning export map
 EXPORT_MAP := rte_eventdev_version.map
diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index 74a2614c4..9328cda1b 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -1245,92 +1245,3 @@ rte_event_pmd_vdev_uninit(const char *name)
 
 	return 0;
 }
-
-int
-rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
-			struct rte_pci_device *pci_dev,
-			size_t private_data_size,
-			eventdev_pmd_pci_callback_t devinit)
-{
-	struct rte_eventdev *eventdev;
-
-	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
-
-	int retval;
-
-	if (devinit == NULL)
-		return -EINVAL;
-
-	rte_pci_device_name(&pci_dev->addr, eventdev_name,
-			sizeof(eventdev_name));
-
-	eventdev = rte_event_pmd_allocate(eventdev_name,
-			 pci_dev->device.numa_node);
-	if (eventdev == NULL)
-		return -ENOMEM;
-
-	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-		eventdev->data->dev_private =
-				rte_zmalloc_socket(
-						"eventdev private structure",
-						private_data_size,
-						RTE_CACHE_LINE_SIZE,
-						rte_socket_id());
-
-		if (eventdev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private "
-					"device data");
-	}
-
-	eventdev->dev = &pci_dev->device;
-
-	/* Invoke PMD device initialization function */
-	retval = devinit(eventdev);
-	if (retval == 0)
-		return 0;
-
-	RTE_EDEV_LOG_ERR("driver %s: (vendor_id=0x%x device_id=0x%x)"
-			" failed", pci_drv->driver.name,
-			(unsigned int) pci_dev->id.vendor_id,
-			(unsigned int) pci_dev->id.device_id);
-
-	rte_event_pmd_release(eventdev);
-
-	return -ENXIO;
-}
-
-int
-rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
-			 eventdev_pmd_pci_callback_t devuninit)
-{
-	struct rte_eventdev *eventdev;
-	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
-	int ret = 0;
-
-	if (pci_dev == NULL)
-		return -EINVAL;
-
-	rte_pci_device_name(&pci_dev->addr, eventdev_name,
-			sizeof(eventdev_name));
-
-	eventdev = rte_event_pmd_get_named_dev(eventdev_name);
-	if (eventdev == NULL)
-		return -ENODEV;
-
-	ret = rte_event_dev_close(eventdev->data->dev_id);
-	if (ret < 0)
-		return ret;
-
-	/* Invoke PMD device un-init function */
-	if (devuninit)
-		ret = devuninit(eventdev);
-	if (ret)
-		return ret;
-
-	/* Free event device */
-	rte_event_pmd_release(eventdev);
-
-	eventdev->dev = NULL;
-
-	return 0;
-}
diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
index faa6989b4..3686de549 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd.h
@@ -46,11 +46,10 @@ extern "C" {
 
 #include <string.h>
 
+#include <rte_common.h>
 #include <rte_dev.h>
-#include <rte_pci.h>
-#include <rte_malloc.h>
 #include <rte_log.h>
-#include <rte_common.h>
+#include <rte_malloc.h>
 
 #include "rte_eventdev.h"
 
@@ -525,24 +524,6 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
 int
 rte_event_pmd_vdev_uninit(const char *name);
 
-typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
-
-/**
- * Wrapper for use by pci drivers as a .probe function to attach to a event
- * interface.
- */
-int rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
-			    struct rte_pci_device *pci_dev,
-			    size_t private_data_size,
-			    eventdev_pmd_pci_callback_t devinit);
-
-/**
- * Wrapper for use by pci drivers as a .remove function to detach a event
- * interface.
- */
-int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
-			     eventdev_pmd_pci_callback_t devuninit);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eventdev/rte_eventdev_pmd_pci.h b/lib/librte_eventdev/rte_eventdev_pmd_pci.h
new file mode 100644
index 000000000..18028e36d
--- /dev/null
+++ b/lib/librte_eventdev/rte_eventdev_pmd_pci.h
@@ -0,0 +1,160 @@
+/*
+ *
+ *   Copyright(c) 2016-2017 Cavium networks. All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Cavium networks nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_EVENTDEV_PMD_PCI_H_
+#define _RTE_EVENTDEV_PMD_PCI_H_
+
+/** @file
+ * RTE Eventdev PCI PMD APIs
+ *
+ * @note
+ * These API are from event PCI PMD only and user applications should not call
+ * them directly.
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <string.h>
+
+#include <rte_pci.h>
+
+#include "rte_eventdev_pmd.h"
+
+typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
+
+/**
+ * @internal
+ * Wrapper for use by pci drivers as a .probe function to attach to a event
+ * interface.
+ */
+static int
+rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
+			    struct rte_pci_device *pci_dev,
+			    size_t private_data_size,
+			    eventdev_pmd_pci_callback_t devinit)
+{
+	struct rte_eventdev *eventdev;
+
+	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
+
+	int retval;
+
+	if (devinit == NULL)
+		return -EINVAL;
+
+	rte_pci_device_name(&pci_dev->addr, eventdev_name,
+			sizeof(eventdev_name));
+
+	eventdev = rte_event_pmd_allocate(eventdev_name,
+			 pci_dev->device.numa_node);
+	if (eventdev == NULL)
+		return -ENOMEM;
+
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		eventdev->data->dev_private =
+				rte_zmalloc_socket(
+						"eventdev private structure",
+						private_data_size,
+						RTE_CACHE_LINE_SIZE,
+						rte_socket_id());
+
+		if (eventdev->data->dev_private == NULL)
+			rte_panic("Cannot allocate memzone for private "
+					"device data");
+	}
+
+	eventdev->dev = &pci_dev->device;
+
+	/* Invoke PMD device initialization function */
+	retval = devinit(eventdev);
+	if (retval == 0)
+		return 0;
+
+	RTE_EDEV_LOG_ERR("driver %s: (vendor_id=0x%x device_id=0x%x)"
+			" failed", pci_drv->driver.name,
+			(unsigned int) pci_dev->id.vendor_id,
+			(unsigned int) pci_dev->id.device_id);
+
+	rte_event_pmd_release(eventdev);
+
+	return -ENXIO;
+}
+
+
+/**
+ * @internal
+ * Wrapper for use by pci drivers as a .remove function to detach a event
+ * interface.
+ */
+static inline int
+rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
+			     eventdev_pmd_pci_callback_t devuninit)
+{
+	struct rte_eventdev *eventdev;
+	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
+	int ret = 0;
+
+	if (pci_dev == NULL)
+		return -EINVAL;
+
+	rte_pci_device_name(&pci_dev->addr, eventdev_name,
+			sizeof(eventdev_name));
+
+	eventdev = rte_event_pmd_get_named_dev(eventdev_name);
+	if (eventdev == NULL)
+		return -ENODEV;
+
+	ret = rte_event_dev_close(eventdev->data->dev_id);
+	if (ret < 0)
+		return ret;
+
+	/* Invoke PMD device un-init function */
+	if (devuninit)
+		ret = devuninit(eventdev);
+	if (ret)
+		return ret;
+
+	/* Free event device */
+	rte_event_pmd_release(eventdev);
+
+	eventdev->dev = NULL;
+
+	return 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_EVENTDEV_PMD_PCI_H_ */
-- 
2.13.0

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v2 4/4] eventdev: make vdev init and uninit functions optional
  2017-06-07  8:43   ` [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
                       ` (2 preceding siblings ...)
  2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 3/4] eventdev: make PCI probe and remove functions optional Jerin Jacob
@ 2017-06-07  8:43     ` Jerin Jacob
  2017-06-07  9:27     ` [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library Gaëtan Rivet
  4 siblings, 0 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-07  8:43 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, harry.van.haaren, hemant.agrawal, gage.eads,
	nipun.gupta, narender.vangati, nikhil.rao, gaetan.rivet,
	Jerin Jacob

Made libeventdev library independent of VDEV bus by moving vdev pmd
specific function to rte_eventdev_pmd_vdev.h header file. Eventdev VDEV
PMD can include that for generic eventdev VDEV init and uninit function
enablement.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 drivers/event/octeontx/ssovf_evdev.h        |   2 +-
 drivers/event/skeleton/skeleton_eventdev.h  |   1 +
 drivers/event/sw/sw_evdev.h                 |   2 +-
 lib/librte_eventdev/Makefile                |   1 +
 lib/librte_eventdev/rte_eventdev.c          |  50 -----------
 lib/librte_eventdev/rte_eventdev_pmd.h      |  29 ------
 lib/librte_eventdev/rte_eventdev_pmd_vdev.h | 133 ++++++++++++++++++++++++++++
 7 files changed, 137 insertions(+), 81 deletions(-)
 create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_vdev.h

diff --git a/drivers/event/octeontx/ssovf_evdev.h b/drivers/event/octeontx/ssovf_evdev.h
index 6e0a35219..03902e41a 100644
--- a/drivers/event/octeontx/ssovf_evdev.h
+++ b/drivers/event/octeontx/ssovf_evdev.h
@@ -34,7 +34,7 @@
 #define __SSOVF_EVDEV_H__
 
 #include <rte_config.h>
-#include <rte_eventdev_pmd.h>
+#include <rte_eventdev_pmd_vdev.h>
 #include <rte_io.h>
 
 #include "rte_pmd_octeontx_ssovf.h"
diff --git a/drivers/event/skeleton/skeleton_eventdev.h b/drivers/event/skeleton/skeleton_eventdev.h
index 5b59fcbc0..a321a273e 100644
--- a/drivers/event/skeleton/skeleton_eventdev.h
+++ b/drivers/event/skeleton/skeleton_eventdev.h
@@ -34,6 +34,7 @@
 #define __SKELETON_EVENTDEV_H__
 
 #include <rte_eventdev_pmd_pci.h>
+#include <rte_eventdev_pmd_vdev.h>
 
 #ifdef RTE_LIBRTE_PMD_SKELETON_EVENTDEV_DEBUG
 #define PMD_DRV_LOG(level, fmt, args...) \
diff --git a/drivers/event/sw/sw_evdev.h b/drivers/event/sw/sw_evdev.h
index 61c671d62..0929d0576 100644
--- a/drivers/event/sw/sw_evdev.h
+++ b/drivers/event/sw/sw_evdev.h
@@ -34,7 +34,7 @@
 #define _SW_EVDEV_H_
 
 #include <rte_eventdev.h>
-#include <rte_eventdev_pmd.h>
+#include <rte_eventdev_pmd_vdev.h>
 #include <rte_atomic.h>
 
 #define SW_DEFAULT_CREDIT_QUANTA 32
diff --git a/lib/librte_eventdev/Makefile b/lib/librte_eventdev/Makefile
index 040556fc4..629069ad6 100644
--- a/lib/librte_eventdev/Makefile
+++ b/lib/librte_eventdev/Makefile
@@ -47,6 +47,7 @@ SRCS-y += rte_eventdev.c
 SYMLINK-y-include += rte_eventdev.h
 SYMLINK-y-include += rte_eventdev_pmd.h
 SYMLINK-y-include += rte_eventdev_pmd_pci.h
+SYMLINK-y-include += rte_eventdev_pmd_vdev.h
 
 # versioning export map
 EXPORT_MAP := rte_eventdev_version.map
diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index 9328cda1b..a246965e6 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -1195,53 +1195,3 @@ rte_event_pmd_release(struct rte_eventdev *eventdev)
 	eventdev->data = NULL;
 	return 0;
 }
-
-struct rte_eventdev *
-rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
-		int socket_id)
-{
-	struct rte_eventdev *eventdev;
-
-	/* Allocate device structure */
-	eventdev = rte_event_pmd_allocate(name, socket_id);
-	if (eventdev == NULL)
-		return NULL;
-
-	/* Allocate private device structure */
-	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-		eventdev->data->dev_private =
-				rte_zmalloc_socket("eventdev device private",
-						dev_private_size,
-						RTE_CACHE_LINE_SIZE,
-						socket_id);
-
-		if (eventdev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private device"
-					" data");
-	}
-
-	return eventdev;
-}
-
-int
-rte_event_pmd_vdev_uninit(const char *name)
-{
-	int ret;
-	struct rte_eventdev *eventdev;
-
-	if (name == NULL)
-		return -EINVAL;
-
-	eventdev = rte_event_pmd_get_named_dev(name);
-	if (eventdev == NULL)
-		return -ENODEV;
-
-	ret = rte_event_dev_close(eventdev->data->dev_id);
-	if (ret < 0)
-		return ret;
-
-	/* Free the event device */
-	rte_event_pmd_release(eventdev);
-
-	return 0;
-}
diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
index 3686de549..ecefb94d6 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd.h
@@ -495,35 +495,6 @@ rte_event_pmd_allocate(const char *name, int socket_id);
 int
 rte_event_pmd_release(struct rte_eventdev *eventdev);
 
-/**
- * Creates a new virtual event device and returns the pointer to that device.
- *
- * @param name
- *   PMD type name
- * @param dev_private_size
- *   Size of event PMDs private data
- * @param socket_id
- *   Socket to allocate resources on.
- *
- * @return
- *   - Eventdev pointer if device is successfully created.
- *   - NULL if device cannot be created.
- */
-struct rte_eventdev *
-rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
-		int socket_id);
-
-/**
- * Destroy the given virtual event device
- *
- * @param name
- *   PMD type name
- * @return
- *   - 0 on success, negative on error
- */
-int
-rte_event_pmd_vdev_uninit(const char *name);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eventdev/rte_eventdev_pmd_vdev.h b/lib/librte_eventdev/rte_eventdev_pmd_vdev.h
new file mode 100644
index 000000000..967605b80
--- /dev/null
+++ b/lib/librte_eventdev/rte_eventdev_pmd_vdev.h
@@ -0,0 +1,133 @@
+/*
+ *
+ *   Copyright(c) 2016-2017 Cavium networks. All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Cavium networks nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_EVENTDEV_PMD_VDEV_H_
+#define _RTE_EVENTDEV_PMD_VDEV_H_
+
+/** @file
+ * RTE Eventdev VDEV PMD APIs
+ *
+ * @note
+ * These API are from event VDEV PMD only and user applications should not call
+ * them directly.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <string.h>
+
+#include <rte_eal.h>
+#include <rte_vdev.h>
+
+#include "rte_eventdev_pmd.h"
+
+/**
+ * @internal
+ * Creates a new virtual event device and returns the pointer to that device.
+ *
+ * @param name
+ *   PMD type name
+ * @param dev_private_size
+ *   Size of event PMDs private data
+ * @param socket_id
+ *   Socket to allocate resources on.
+ *
+ * @return
+ *   - Eventdev pointer if device is successfully created.
+ *   - NULL if device cannot be created.
+ */
+static inline struct rte_eventdev *
+rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
+		int socket_id)
+{
+
+	struct rte_eventdev *eventdev;
+
+	/* Allocate device structure */
+	eventdev = rte_event_pmd_allocate(name, socket_id);
+	if (eventdev == NULL)
+		return NULL;
+
+	/* Allocate private device structure */
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		eventdev->data->dev_private =
+				rte_zmalloc_socket("eventdev device private",
+						dev_private_size,
+						RTE_CACHE_LINE_SIZE,
+						socket_id);
+
+		if (eventdev->data->dev_private == NULL)
+			rte_panic("Cannot allocate memzone for private device"
+					" data");
+	}
+
+	return eventdev;
+}
+
+/**
+ * @internal
+ * Destroy the given virtual event device
+ *
+ * @param name
+ *   PMD type name
+ * @return
+ *   - 0 on success, negative on error
+ */
+static inline int
+rte_event_pmd_vdev_uninit(const char *name)
+{
+	int ret;
+	struct rte_eventdev *eventdev;
+
+	if (name == NULL)
+		return -EINVAL;
+
+	eventdev = rte_event_pmd_get_named_dev(name);
+	if (eventdev == NULL)
+		return -ENODEV;
+
+	ret = rte_event_dev_close(eventdev->data->dev_id);
+	if (ret < 0)
+		return ret;
+
+	/* Free the event device */
+	rte_event_pmd_release(eventdev);
+
+	return 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_EVENTDEV_PMD_VDEV_H_ */
-- 
2.13.0

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library
  2017-06-07  8:43   ` [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
                       ` (3 preceding siblings ...)
  2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 4/4] eventdev: make vdev init and uninit " Jerin Jacob
@ 2017-06-07  9:27     ` Gaëtan Rivet
  2017-06-08 17:05       ` Jerin Jacob
  4 siblings, 1 reply; 20+ messages in thread
From: Gaëtan Rivet @ 2017-06-07  9:27 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: dev, bruce.richardson, harry.van.haaren, hemant.agrawal,
	gage.eads, nipun.gupta, narender.vangati, nikhil.rao

Hi Jerin,

On Wed, Jun 07, 2017 at 02:13:29PM +0530, Jerin Jacob wrote:
> v3:
> Removed the bus dependency by spliting lib/librte_eventdev/rte_eventdev_pmd_pci.h
> and lib/librte_eventdev/rte_eventdev_pmd_vdev.h
> 

It works with the PCI bus now, good job.
Small problem however: to compile drivers/event/sw/sw_evdev.c, two includes were
missing:

#include <inttypes.h>
#include <rte_debug.h>

I added both to rte_eventdev_pmd_vdev.h to quickly fix this and test the
compilation otherwise, but maybe this is only necessary for sw_evdev.c.

Thanks

> Jerin Jacob (4):
>   eventdev: remove PCI dependency from generic data structures
>   eventdev: restructure event PMD release function
>   eventdev: make PCI probe and remove functions optional
>   eventdev: make vdev init and uninit functions optional
> 
>  drivers/event/octeontx/ssovf_evdev.h        |   2 +-
>  drivers/event/octeontx/ssovf_worker.h       |   1 +
>  drivers/event/skeleton/skeleton_eventdev.c  |  33 +++---
>  drivers/event/skeleton/skeleton_eventdev.h  |   3 +-
>  drivers/event/sw/sw_evdev.h                 |   2 +-
>  lib/librte_eventdev/Makefile                |   2 +
>  lib/librte_eventdev/rte_eventdev.c          | 148 -------------------------
>  lib/librte_eventdev/rte_eventdev.h          |   2 -
>  lib/librte_eventdev/rte_eventdev_pmd.h      | 101 +-----------------
>  lib/librte_eventdev/rte_eventdev_pmd_pci.h  | 160 ++++++++++++++++++++++++++++
>  lib/librte_eventdev/rte_eventdev_pmd_vdev.h | 133 +++++++++++++++++++++++
>  11 files changed, 323 insertions(+), 264 deletions(-)
>  create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_pci.h
>  create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_vdev.h
> 
> -- 
> 2.13.0
> 

-- 
Gaëtan Rivet
6WIND

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library
  2017-06-07  9:27     ` [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library Gaëtan Rivet
@ 2017-06-08 17:05       ` Jerin Jacob
  0 siblings, 0 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-08 17:05 UTC (permalink / raw)
  To: Gaëtan Rivet
  Cc: dev, bruce.richardson, harry.van.haaren, hemant.agrawal,
	gage.eads, nipun.gupta, narender.vangati, nikhil.rao

-----Original Message-----
> Date: Wed, 7 Jun 2017 11:27:26 +0200
> From: Gaëtan Rivet <gaetan.rivet@6wind.com>
> To: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Cc: dev@dpdk.org, bruce.richardson@intel.com, harry.van.haaren@intel.com,
>  hemant.agrawal@nxp.com, gage.eads@intel.com, nipun.gupta@nxp.com,
>  narender.vangati@intel.com, nikhil.rao@intel.com
> Subject: Re: [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from
>  eventdev library
> User-Agent: Mutt/1.5.23 (2014-03-12)
> 
> Hi Jerin,
> 
> On Wed, Jun 07, 2017 at 02:13:29PM +0530, Jerin Jacob wrote:
> > v3:
> > Removed the bus dependency by spliting lib/librte_eventdev/rte_eventdev_pmd_pci.h
> > and lib/librte_eventdev/rte_eventdev_pmd_vdev.h
> > 
> 
> It works with the PCI bus now, good job.
> Small problem however: to compile drivers/event/sw/sw_evdev.c, two includes were
> missing:
> 
> #include <inttypes.h>
> #include <rte_debug.h>
> 
> I added both to rte_eventdev_pmd_vdev.h to quickly fix this and test the
> compilation otherwise, but maybe this is only necessary for sw_evdev.c.

I tested x86_64-native-linuxapp-gcc + dpdk.org master on following
versions of gcc. I couldn't see the compilation issue. Anyway, I will
send the next version with suggested header file changes.

gcc version 4.9.2 20150212 (Red Hat 4.9.2-6) (GCC) 
gcc version 4.8.3 20140911 (Red Hat 4.8.3-7) (GCC) 
gcc version 7.1.1 20170528 (GCC) 



> 
> Thanks
> 
> > Jerin Jacob (4):
> >   eventdev: remove PCI dependency from generic data structures
> >   eventdev: restructure event PMD release function
> >   eventdev: make PCI probe and remove functions optional
> >   eventdev: make vdev init and uninit functions optional
> > 
> >  drivers/event/octeontx/ssovf_evdev.h        |   2 +-
> >  drivers/event/octeontx/ssovf_worker.h       |   1 +
> >  drivers/event/skeleton/skeleton_eventdev.c  |  33 +++---
> >  drivers/event/skeleton/skeleton_eventdev.h  |   3 +-
> >  drivers/event/sw/sw_evdev.h                 |   2 +-
> >  lib/librte_eventdev/Makefile                |   2 +
> >  lib/librte_eventdev/rte_eventdev.c          | 148 -------------------------
> >  lib/librte_eventdev/rte_eventdev.h          |   2 -
> >  lib/librte_eventdev/rte_eventdev_pmd.h      | 101 +-----------------
> >  lib/librte_eventdev/rte_eventdev_pmd_pci.h  | 160 ++++++++++++++++++++++++++++
> >  lib/librte_eventdev/rte_eventdev_pmd_vdev.h | 133 +++++++++++++++++++++++
> >  11 files changed, 323 insertions(+), 264 deletions(-)
> >  create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_pci.h
> >  create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_vdev.h
> > 
> > -- 
> > 2.13.0
> > 
> 
> -- 
> Gaëtan Rivet
> 6WIND

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v4 0/4] Remove PCI and VDEV dependency from eventdev library
  2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 1/4] eventdev: remove PCI dependency from generic data structures Jerin Jacob
@ 2017-06-09  8:37       ` Jerin Jacob
  2017-06-09  8:37         ` [dpdk-dev] [PATCH v4 1/4] eventdev: remove PCI dependency from generic data structures Jerin Jacob
                           ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-09  8:37 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, harry.van.haaren, hemant.agrawal, gage.eads,
	nipun.gupta, gaetan.rivet, Jerin Jacob

v4:
Fix Gaëtan Rivet reported compilation issues

v3:
Removed the bus dependency by spliting lib/librte_eventdev/rte_eventdev_pmd_pci.h
and lib/librte_eventdev/rte_eventdev_pmd_vdev.h

Jerin Jacob (4):
  eventdev: remove PCI dependency from generic data structures
  eventdev: restructure event PMD release function
  eventdev: make PCI probe and remove functions optional
  eventdev: make vdev init and uninit functions optional

 drivers/event/octeontx/ssovf_evdev.c        |   2 +
 drivers/event/octeontx/ssovf_evdev.h        |   2 +-
 drivers/event/octeontx/ssovf_worker.h       |   1 +
 drivers/event/skeleton/skeleton_eventdev.c  |  33 +++---
 drivers/event/skeleton/skeleton_eventdev.h  |   3 +-
 drivers/event/sw/sw_evdev.c                 |   1 +
 drivers/event/sw/sw_evdev.h                 |   2 +-
 lib/librte_eventdev/Makefile                |   2 +
 lib/librte_eventdev/rte_eventdev.c          | 148 -------------------------
 lib/librte_eventdev/rte_eventdev.h          |   2 -
 lib/librte_eventdev/rte_eventdev_pmd.h      | 101 +-----------------
 lib/librte_eventdev/rte_eventdev_pmd_pci.h  | 160 ++++++++++++++++++++++++++++
 lib/librte_eventdev/rte_eventdev_pmd_vdev.h | 134 +++++++++++++++++++++++
 13 files changed, 327 insertions(+), 264 deletions(-)
 create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_pci.h
 create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_vdev.h

-- 
2.13.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v4 1/4] eventdev: remove PCI dependency from generic data structures
  2017-06-09  8:37       ` [dpdk-dev] [PATCH v4 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
@ 2017-06-09  8:37         ` Jerin Jacob
  2017-06-09  8:37         ` [dpdk-dev] [PATCH v4 2/4] eventdev: restructure event PMD release function Jerin Jacob
                           ` (3 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-09  8:37 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, harry.van.haaren, hemant.agrawal, gage.eads,
	nipun.gupta, gaetan.rivet, Jerin Jacob

Remove the PCI dependency from generic data structures
and moved the PCI specific code to rte_event_pmd_pci*

CC: Gaetan Rivet <gaetan.rivet@6wind.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 drivers/event/skeleton/skeleton_eventdev.c | 30 +++++++++-----
 lib/librte_eventdev/rte_eventdev.c         | 38 +++++++-----------
 lib/librte_eventdev/rte_eventdev.h         |  2 -
 lib/librte_eventdev/rte_eventdev_pmd.h     | 63 ++++--------------------------
 4 files changed, 41 insertions(+), 92 deletions(-)

diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c
index 800bd76e0..34684aba0 100644
--- a/drivers/event/skeleton/skeleton_eventdev.c
+++ b/drivers/event/skeleton/skeleton_eventdev.c
@@ -427,18 +427,28 @@ static const struct rte_pci_id pci_id_skeleton_map[] = {
 	},
 };
 
-static struct rte_eventdev_driver pci_eventdev_skeleton_pmd = {
-	.pci_drv = {
-		.id_table = pci_id_skeleton_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
-		.probe = rte_event_pmd_pci_probe,
-		.remove = rte_event_pmd_pci_remove,
-	},
-	.eventdev_init = skeleton_eventdev_init,
-	.dev_private_size = sizeof(struct skeleton_eventdev),
+static int
+event_skeleton_pci_probe(struct rte_pci_driver *pci_drv,
+			 struct rte_pci_device *pci_dev)
+{
+	return rte_event_pmd_pci_probe(pci_drv, pci_dev,
+		sizeof(struct skeleton_eventdev), skeleton_eventdev_init);
+}
+
+static int
+event_skeleton_pci_remove(struct rte_pci_device *pci_dev)
+{
+	return rte_event_pmd_pci_remove(pci_dev, NULL);
+}
+
+static struct rte_pci_driver pci_eventdev_skeleton_pmd = {
+	.id_table = pci_id_skeleton_map,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+	.probe = event_skeleton_pci_probe,
+	.remove = event_skeleton_pci_remove,
 };
 
-RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd.pci_drv);
+RTE_PMD_REGISTER_PCI(event_skeleton_pci, pci_eventdev_skeleton_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(event_skeleton_pci, pci_id_skeleton_map);
 
 /* VDEV based event device */
diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index 20afc3f0e..fd0406747 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -45,7 +45,6 @@
 #include <rte_log.h>
 #include <rte_debug.h>
 #include <rte_dev.h>
-#include <rte_pci.h>
 #include <rte_memory.h>
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
@@ -126,8 +125,6 @@ rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
 	dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
 
 	dev_info->dev = dev->dev;
-	if (dev->driver)
-		dev_info->driver_name = dev->driver->pci_drv.driver.name;
 	return 0;
 }
 
@@ -1250,18 +1247,18 @@ rte_event_pmd_vdev_uninit(const char *name)
 
 int
 rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
-			struct rte_pci_device *pci_dev)
+			struct rte_pci_device *pci_dev,
+			size_t private_data_size,
+			eventdev_pmd_pci_callback_t devinit)
 {
-	struct rte_eventdev_driver *eventdrv;
 	struct rte_eventdev *eventdev;
 
 	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
 
 	int retval;
 
-	eventdrv = (struct rte_eventdev_driver *)pci_drv;
-	if (eventdrv == NULL)
-		return -ENODEV;
+	if (devinit == NULL)
+		return -EINVAL;
 
 	rte_pci_device_name(&pci_dev->addr, eventdev_name,
 			sizeof(eventdev_name));
@@ -1275,7 +1272,7 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 		eventdev->data->dev_private =
 				rte_zmalloc_socket(
 						"eventdev private structure",
-						eventdrv->dev_private_size,
+						private_data_size,
 						RTE_CACHE_LINE_SIZE,
 						rte_socket_id());
 
@@ -1285,10 +1282,9 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 	}
 
 	eventdev->dev = &pci_dev->device;
-	eventdev->driver = eventdrv;
 
 	/* Invoke PMD device initialization function */
-	retval = (*eventdrv->eventdev_init)(eventdev);
+	retval = devinit(eventdev);
 	if (retval == 0)
 		return 0;
 
@@ -1307,12 +1303,12 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 }
 
 int
-rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
+rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
+			 eventdev_pmd_pci_callback_t devuninit)
 {
-	const struct rte_eventdev_driver *eventdrv;
 	struct rte_eventdev *eventdev;
 	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
-	int ret;
+	int ret = 0;
 
 	if (pci_dev == NULL)
 		return -EINVAL;
@@ -1324,22 +1320,16 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
 	if (eventdev == NULL)
 		return -ENODEV;
 
-	eventdrv = (const struct rte_eventdev_driver *)pci_dev->driver;
-	if (eventdrv == NULL)
-		return -ENODEV;
-
 	/* Invoke PMD device un-init function */
-	if (*eventdrv->eventdev_uninit) {
-		ret = (*eventdrv->eventdev_uninit)(eventdev);
-		if (ret)
-			return ret;
-	}
+	if (devuninit)
+		ret = devuninit(eventdev);
+	if (ret)
+		return ret;
 
 	/* Free event device */
 	rte_event_pmd_release(eventdev);
 
 	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 20e7293e0..c5b2b7453 100644
--- a/lib/librte_eventdev/rte_eventdev.h
+++ b/lib/librte_eventdev/rte_eventdev.h
@@ -1063,8 +1063,6 @@ struct rte_eventdev {
 	/**< Functions exported by PMD */
 	struct rte_device *dev;
 	/**< Device info. supplied by probing */
-	const struct rte_eventdev_driver *driver;
-	/**< Driver for this device */
 
 	RTE_STD_C11
 	uint8_t attached : 1;
diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
index 4005b3c98..faa6989b4 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd.h
@@ -87,60 +87,6 @@ extern "C" {
 #define RTE_EVENTDEV_DETACHED  (0)
 #define RTE_EVENTDEV_ATTACHED  (1)
 
-/**
- * Initialisation function of a event driver invoked for each matching
- * event PCI device detected during the PCI probing phase.
- *
- * @param dev
- *   The dev pointer is the address of the *rte_eventdev* structure associated
- *   with the matching device and which has been [automatically] allocated in
- *   the *rte_event_devices* array.
- *
- * @return
- *   - 0: Success, the device is properly initialised by the driver.
- *        In particular, the driver MUST have set up the *dev_ops* pointer
- *        of the *dev* structure.
- *   - <0: Error code of the device initialisation failure.
- */
-typedef int (*eventdev_init_t)(struct rte_eventdev *dev);
-
-/**
- * Finalisation function of a driver invoked for each matching
- * PCI device detected during the PCI closing phase.
- *
- * @param dev
- *   The dev pointer is the address of the *rte_eventdev* structure associated
- *   with the matching device and which	has been [automatically] allocated in
- *   the *rte_event_devices* array.
- *
- * @return
- *   - 0: Success, the device is properly finalised by the driver.
- *        In particular, the driver MUST free the *dev_ops* pointer
- *        of the *dev* structure.
- *   - <0: Error code of the device initialisation failure.
- */
-typedef int (*eventdev_uninit_t)(struct rte_eventdev *dev);
-
-/**
- * The structure associated with a PMD driver.
- *
- * Each driver acts as a PCI driver and is represented by a generic
- * *event_driver* structure that holds:
- *
- * - An *rte_pci_driver* structure (which must be the first field).
- *
- * - The *eventdev_init* function invoked for each matching PCI device.
- *
- * - The size of the private data to allocate for each matching device.
- */
-struct rte_eventdev_driver {
-	struct rte_pci_driver pci_drv;	/**< The PMD is also a PCI driver. */
-	unsigned int dev_private_size;	/**< Size of device private data. */
-
-	eventdev_init_t eventdev_init;	/**< Device init function. */
-	eventdev_uninit_t eventdev_uninit; /**< Device uninit function. */
-};
-
 /** Global structure used for maintaining state of allocated event devices */
 struct rte_eventdev_global {
 	uint8_t nb_devs;	/**< Number of devices found */
@@ -579,18 +525,23 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
 int
 rte_event_pmd_vdev_uninit(const char *name);
 
+typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
+
 /**
  * Wrapper for use by pci drivers as a .probe function to attach to a event
  * interface.
  */
 int rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
-			    struct rte_pci_device *pci_dev);
+			    struct rte_pci_device *pci_dev,
+			    size_t private_data_size,
+			    eventdev_pmd_pci_callback_t devinit);
 
 /**
  * Wrapper for use by pci drivers as a .remove function to detach a event
  * interface.
  */
-int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev);
+int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
+			     eventdev_pmd_pci_callback_t devuninit);
 
 #ifdef __cplusplus
 }
-- 
2.13.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v4 2/4] eventdev: restructure event PMD release function
  2017-06-09  8:37       ` [dpdk-dev] [PATCH v4 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
  2017-06-09  8:37         ` [dpdk-dev] [PATCH v4 1/4] eventdev: remove PCI dependency from generic data structures Jerin Jacob
@ 2017-06-09  8:37         ` Jerin Jacob
  2017-06-09  8:37         ` [dpdk-dev] [PATCH v4 3/4] eventdev: make PCI probe and remove functions optional Jerin Jacob
                           ` (2 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-09  8:37 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, harry.van.haaren, hemant.agrawal, gage.eads,
	nipun.gupta, gaetan.rivet, Jerin Jacob

Remove rte_event_dev_close() from rte_event_pmd_release() function so
that  rte_event_pmd_release() can be used in stateless way. This will
enable rte_event_pmd_vdev_uninit() function to avoid using
eventdev_globals  global variable and the need for exposing the a
global variable to PMD.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 lib/librte_eventdev/rte_eventdev.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index fd0406747..74a2614c4 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -1171,10 +1171,6 @@ rte_event_pmd_release(struct rte_eventdev *eventdev)
 	if (eventdev == NULL)
 		return -EINVAL;
 
-	ret = rte_event_dev_close(eventdev->data->dev_id);
-	if (ret < 0)
-		return ret;
-
 	eventdev->attached = RTE_EVENTDEV_DETACHED;
 	eventdev_globals.nb_devs--;
 
@@ -1230,6 +1226,7 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
 int
 rte_event_pmd_vdev_uninit(const char *name)
 {
+	int ret;
 	struct rte_eventdev *eventdev;
 
 	if (name == NULL)
@@ -1239,6 +1236,10 @@ rte_event_pmd_vdev_uninit(const char *name)
 	if (eventdev == NULL)
 		return -ENODEV;
 
+	ret = rte_event_dev_close(eventdev->data->dev_id);
+	if (ret < 0)
+		return ret;
+
 	/* Free the event device */
 	rte_event_pmd_release(eventdev);
 
@@ -1293,11 +1294,7 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
 			(unsigned int) pci_dev->id.vendor_id,
 			(unsigned int) pci_dev->id.device_id);
 
-	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
-		rte_free(eventdev->data->dev_private);
-
-	eventdev->attached = RTE_EVENTDEV_DETACHED;
-	eventdev_globals.nb_devs--;
+	rte_event_pmd_release(eventdev);
 
 	return -ENXIO;
 }
@@ -1320,6 +1317,10 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
 	if (eventdev == NULL)
 		return -ENODEV;
 
+	ret = rte_event_dev_close(eventdev->data->dev_id);
+	if (ret < 0)
+		return ret;
+
 	/* Invoke PMD device un-init function */
 	if (devuninit)
 		ret = devuninit(eventdev);
-- 
2.13.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v4 3/4] eventdev: make PCI probe and remove functions optional
  2017-06-09  8:37       ` [dpdk-dev] [PATCH v4 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
  2017-06-09  8:37         ` [dpdk-dev] [PATCH v4 1/4] eventdev: remove PCI dependency from generic data structures Jerin Jacob
  2017-06-09  8:37         ` [dpdk-dev] [PATCH v4 2/4] eventdev: restructure event PMD release function Jerin Jacob
@ 2017-06-09  8:37         ` Jerin Jacob
  2017-06-09  8:37         ` [dpdk-dev] [PATCH v4 4/4] eventdev: make vdev init and uninit " Jerin Jacob
  2017-06-20 14:14         ` [dpdk-dev] [PATCH v4 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
  4 siblings, 0 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-09  8:37 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, harry.van.haaren, hemant.agrawal, gage.eads,
	nipun.gupta, gaetan.rivet, Jerin Jacob

Made libeventdev library independent of PCI bus by moving pci pmd
specific function to rte_eventdev_pmd_pci.h header file. Eventdev PCI
PMD can include that for generic eventdev PCI probe and remove function
enablement.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 drivers/event/octeontx/ssovf_worker.h      |   1 +
 drivers/event/skeleton/skeleton_eventdev.c |   3 +-
 drivers/event/skeleton/skeleton_eventdev.h |   2 +-
 lib/librte_eventdev/Makefile               |   1 +
 lib/librte_eventdev/rte_eventdev.c         |  89 ----------------
 lib/librte_eventdev/rte_eventdev_pmd.h     |  23 +----
 lib/librte_eventdev/rte_eventdev_pmd_pci.h | 160 +++++++++++++++++++++++++++++
 7 files changed, 166 insertions(+), 113 deletions(-)
 create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_pci.h

diff --git a/drivers/event/octeontx/ssovf_worker.h b/drivers/event/octeontx/ssovf_worker.h
index 40c5c5531..b76a19925 100644
--- a/drivers/event/octeontx/ssovf_worker.h
+++ b/drivers/event/octeontx/ssovf_worker.h
@@ -32,6 +32,7 @@
 
 
 #include <rte_common.h>
+#include <rte_branch_prediction.h>
 
 #include "ssovf_evdev.h"
 
diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c
index 34684aba0..c69c2168e 100644
--- a/drivers/event/skeleton/skeleton_eventdev.c
+++ b/drivers/event/skeleton/skeleton_eventdev.c
@@ -43,10 +43,9 @@
 #include <rte_dev.h>
 #include <rte_eal.h>
 #include <rte_log.h>
+#include <rte_malloc.h>
 #include <rte_memory.h>
 #include <rte_memzone.h>
-#include <rte_malloc.h>
-#include <rte_pci.h>
 #include <rte_lcore.h>
 #include <rte_vdev.h>
 
diff --git a/drivers/event/skeleton/skeleton_eventdev.h b/drivers/event/skeleton/skeleton_eventdev.h
index 1ce62da7d..5b59fcbc0 100644
--- a/drivers/event/skeleton/skeleton_eventdev.h
+++ b/drivers/event/skeleton/skeleton_eventdev.h
@@ -33,7 +33,7 @@
 #ifndef __SKELETON_EVENTDEV_H__
 #define __SKELETON_EVENTDEV_H__
 
-#include <rte_eventdev_pmd.h>
+#include <rte_eventdev_pmd_pci.h>
 
 #ifdef RTE_LIBRTE_PMD_SKELETON_EVENTDEV_DEBUG
 #define PMD_DRV_LOG(level, fmt, args...) \
diff --git a/lib/librte_eventdev/Makefile b/lib/librte_eventdev/Makefile
index e06346a66..040556fc4 100644
--- a/lib/librte_eventdev/Makefile
+++ b/lib/librte_eventdev/Makefile
@@ -46,6 +46,7 @@ SRCS-y += rte_eventdev.c
 # export include files
 SYMLINK-y-include += rte_eventdev.h
 SYMLINK-y-include += rte_eventdev_pmd.h
+SYMLINK-y-include += rte_eventdev_pmd_pci.h
 
 # versioning export map
 EXPORT_MAP := rte_eventdev_version.map
diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index 74a2614c4..9328cda1b 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -1245,92 +1245,3 @@ rte_event_pmd_vdev_uninit(const char *name)
 
 	return 0;
 }
-
-int
-rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
-			struct rte_pci_device *pci_dev,
-			size_t private_data_size,
-			eventdev_pmd_pci_callback_t devinit)
-{
-	struct rte_eventdev *eventdev;
-
-	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
-
-	int retval;
-
-	if (devinit == NULL)
-		return -EINVAL;
-
-	rte_pci_device_name(&pci_dev->addr, eventdev_name,
-			sizeof(eventdev_name));
-
-	eventdev = rte_event_pmd_allocate(eventdev_name,
-			 pci_dev->device.numa_node);
-	if (eventdev == NULL)
-		return -ENOMEM;
-
-	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-		eventdev->data->dev_private =
-				rte_zmalloc_socket(
-						"eventdev private structure",
-						private_data_size,
-						RTE_CACHE_LINE_SIZE,
-						rte_socket_id());
-
-		if (eventdev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private "
-					"device data");
-	}
-
-	eventdev->dev = &pci_dev->device;
-
-	/* Invoke PMD device initialization function */
-	retval = devinit(eventdev);
-	if (retval == 0)
-		return 0;
-
-	RTE_EDEV_LOG_ERR("driver %s: (vendor_id=0x%x device_id=0x%x)"
-			" failed", pci_drv->driver.name,
-			(unsigned int) pci_dev->id.vendor_id,
-			(unsigned int) pci_dev->id.device_id);
-
-	rte_event_pmd_release(eventdev);
-
-	return -ENXIO;
-}
-
-int
-rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
-			 eventdev_pmd_pci_callback_t devuninit)
-{
-	struct rte_eventdev *eventdev;
-	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
-	int ret = 0;
-
-	if (pci_dev == NULL)
-		return -EINVAL;
-
-	rte_pci_device_name(&pci_dev->addr, eventdev_name,
-			sizeof(eventdev_name));
-
-	eventdev = rte_event_pmd_get_named_dev(eventdev_name);
-	if (eventdev == NULL)
-		return -ENODEV;
-
-	ret = rte_event_dev_close(eventdev->data->dev_id);
-	if (ret < 0)
-		return ret;
-
-	/* Invoke PMD device un-init function */
-	if (devuninit)
-		ret = devuninit(eventdev);
-	if (ret)
-		return ret;
-
-	/* Free event device */
-	rte_event_pmd_release(eventdev);
-
-	eventdev->dev = NULL;
-
-	return 0;
-}
diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
index faa6989b4..3686de549 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd.h
@@ -46,11 +46,10 @@ extern "C" {
 
 #include <string.h>
 
+#include <rte_common.h>
 #include <rte_dev.h>
-#include <rte_pci.h>
-#include <rte_malloc.h>
 #include <rte_log.h>
-#include <rte_common.h>
+#include <rte_malloc.h>
 
 #include "rte_eventdev.h"
 
@@ -525,24 +524,6 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
 int
 rte_event_pmd_vdev_uninit(const char *name);
 
-typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
-
-/**
- * Wrapper for use by pci drivers as a .probe function to attach to a event
- * interface.
- */
-int rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
-			    struct rte_pci_device *pci_dev,
-			    size_t private_data_size,
-			    eventdev_pmd_pci_callback_t devinit);
-
-/**
- * Wrapper for use by pci drivers as a .remove function to detach a event
- * interface.
- */
-int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
-			     eventdev_pmd_pci_callback_t devuninit);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eventdev/rte_eventdev_pmd_pci.h b/lib/librte_eventdev/rte_eventdev_pmd_pci.h
new file mode 100644
index 000000000..18028e36d
--- /dev/null
+++ b/lib/librte_eventdev/rte_eventdev_pmd_pci.h
@@ -0,0 +1,160 @@
+/*
+ *
+ *   Copyright(c) 2016-2017 Cavium networks. All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Cavium networks nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_EVENTDEV_PMD_PCI_H_
+#define _RTE_EVENTDEV_PMD_PCI_H_
+
+/** @file
+ * RTE Eventdev PCI PMD APIs
+ *
+ * @note
+ * These API are from event PCI PMD only and user applications should not call
+ * them directly.
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <string.h>
+
+#include <rte_pci.h>
+
+#include "rte_eventdev_pmd.h"
+
+typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
+
+/**
+ * @internal
+ * Wrapper for use by pci drivers as a .probe function to attach to a event
+ * interface.
+ */
+static int
+rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
+			    struct rte_pci_device *pci_dev,
+			    size_t private_data_size,
+			    eventdev_pmd_pci_callback_t devinit)
+{
+	struct rte_eventdev *eventdev;
+
+	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
+
+	int retval;
+
+	if (devinit == NULL)
+		return -EINVAL;
+
+	rte_pci_device_name(&pci_dev->addr, eventdev_name,
+			sizeof(eventdev_name));
+
+	eventdev = rte_event_pmd_allocate(eventdev_name,
+			 pci_dev->device.numa_node);
+	if (eventdev == NULL)
+		return -ENOMEM;
+
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		eventdev->data->dev_private =
+				rte_zmalloc_socket(
+						"eventdev private structure",
+						private_data_size,
+						RTE_CACHE_LINE_SIZE,
+						rte_socket_id());
+
+		if (eventdev->data->dev_private == NULL)
+			rte_panic("Cannot allocate memzone for private "
+					"device data");
+	}
+
+	eventdev->dev = &pci_dev->device;
+
+	/* Invoke PMD device initialization function */
+	retval = devinit(eventdev);
+	if (retval == 0)
+		return 0;
+
+	RTE_EDEV_LOG_ERR("driver %s: (vendor_id=0x%x device_id=0x%x)"
+			" failed", pci_drv->driver.name,
+			(unsigned int) pci_dev->id.vendor_id,
+			(unsigned int) pci_dev->id.device_id);
+
+	rte_event_pmd_release(eventdev);
+
+	return -ENXIO;
+}
+
+
+/**
+ * @internal
+ * Wrapper for use by pci drivers as a .remove function to detach a event
+ * interface.
+ */
+static inline int
+rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
+			     eventdev_pmd_pci_callback_t devuninit)
+{
+	struct rte_eventdev *eventdev;
+	char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
+	int ret = 0;
+
+	if (pci_dev == NULL)
+		return -EINVAL;
+
+	rte_pci_device_name(&pci_dev->addr, eventdev_name,
+			sizeof(eventdev_name));
+
+	eventdev = rte_event_pmd_get_named_dev(eventdev_name);
+	if (eventdev == NULL)
+		return -ENODEV;
+
+	ret = rte_event_dev_close(eventdev->data->dev_id);
+	if (ret < 0)
+		return ret;
+
+	/* Invoke PMD device un-init function */
+	if (devuninit)
+		ret = devuninit(eventdev);
+	if (ret)
+		return ret;
+
+	/* Free event device */
+	rte_event_pmd_release(eventdev);
+
+	eventdev->dev = NULL;
+
+	return 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_EVENTDEV_PMD_PCI_H_ */
-- 
2.13.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v4 4/4] eventdev: make vdev init and uninit functions optional
  2017-06-09  8:37       ` [dpdk-dev] [PATCH v4 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
                           ` (2 preceding siblings ...)
  2017-06-09  8:37         ` [dpdk-dev] [PATCH v4 3/4] eventdev: make PCI probe and remove functions optional Jerin Jacob
@ 2017-06-09  8:37         ` Jerin Jacob
  2017-06-20 14:14         ` [dpdk-dev] [PATCH v4 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
  4 siblings, 0 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-09  8:37 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, harry.van.haaren, hemant.agrawal, gage.eads,
	nipun.gupta, gaetan.rivet, Jerin Jacob

Made libeventdev library independent of VDEV bus by moving vdev pmd
specific function to rte_eventdev_pmd_vdev.h header file. Eventdev VDEV
PMD can include that for generic eventdev VDEV init and uninit function
enablement.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 drivers/event/octeontx/ssovf_evdev.c        |   2 +
 drivers/event/octeontx/ssovf_evdev.h        |   2 +-
 drivers/event/skeleton/skeleton_eventdev.h  |   1 +
 drivers/event/sw/sw_evdev.c                 |   1 +
 drivers/event/sw/sw_evdev.h                 |   2 +-
 lib/librte_eventdev/Makefile                |   1 +
 lib/librte_eventdev/rte_eventdev.c          |  50 -----------
 lib/librte_eventdev/rte_eventdev_pmd.h      |  29 ------
 lib/librte_eventdev/rte_eventdev_pmd_vdev.h | 134 ++++++++++++++++++++++++++++
 9 files changed, 141 insertions(+), 81 deletions(-)
 create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_vdev.h

diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c
index c80a44379..cf61137d9 100644
--- a/drivers/event/octeontx/ssovf_evdev.c
+++ b/drivers/event/octeontx/ssovf_evdev.c
@@ -30,6 +30,8 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <inttypes.h>
+
 #include <rte_common.h>
 #include <rte_debug.h>
 #include <rte_dev.h>
diff --git a/drivers/event/octeontx/ssovf_evdev.h b/drivers/event/octeontx/ssovf_evdev.h
index 6e0a35219..03902e41a 100644
--- a/drivers/event/octeontx/ssovf_evdev.h
+++ b/drivers/event/octeontx/ssovf_evdev.h
@@ -34,7 +34,7 @@
 #define __SSOVF_EVDEV_H__
 
 #include <rte_config.h>
-#include <rte_eventdev_pmd.h>
+#include <rte_eventdev_pmd_vdev.h>
 #include <rte_io.h>
 
 #include "rte_pmd_octeontx_ssovf.h"
diff --git a/drivers/event/skeleton/skeleton_eventdev.h b/drivers/event/skeleton/skeleton_eventdev.h
index 5b59fcbc0..a321a273e 100644
--- a/drivers/event/skeleton/skeleton_eventdev.h
+++ b/drivers/event/skeleton/skeleton_eventdev.h
@@ -34,6 +34,7 @@
 #define __SKELETON_EVENTDEV_H__
 
 #include <rte_eventdev_pmd_pci.h>
+#include <rte_eventdev_pmd_vdev.h>
 
 #ifdef RTE_LIBRTE_PMD_SKELETON_EVENTDEV_DEBUG
 #define PMD_DRV_LOG(level, fmt, args...) \
diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index a31aaa662..7f7a473ea 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -30,6 +30,7 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <inttypes.h>
 #include <string.h>
 
 #include <rte_vdev.h>
diff --git a/drivers/event/sw/sw_evdev.h b/drivers/event/sw/sw_evdev.h
index 61c671d62..0929d0576 100644
--- a/drivers/event/sw/sw_evdev.h
+++ b/drivers/event/sw/sw_evdev.h
@@ -34,7 +34,7 @@
 #define _SW_EVDEV_H_
 
 #include <rte_eventdev.h>
-#include <rte_eventdev_pmd.h>
+#include <rte_eventdev_pmd_vdev.h>
 #include <rte_atomic.h>
 
 #define SW_DEFAULT_CREDIT_QUANTA 32
diff --git a/lib/librte_eventdev/Makefile b/lib/librte_eventdev/Makefile
index 040556fc4..629069ad6 100644
--- a/lib/librte_eventdev/Makefile
+++ b/lib/librte_eventdev/Makefile
@@ -47,6 +47,7 @@ SRCS-y += rte_eventdev.c
 SYMLINK-y-include += rte_eventdev.h
 SYMLINK-y-include += rte_eventdev_pmd.h
 SYMLINK-y-include += rte_eventdev_pmd_pci.h
+SYMLINK-y-include += rte_eventdev_pmd_vdev.h
 
 # versioning export map
 EXPORT_MAP := rte_eventdev_version.map
diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index 9328cda1b..a246965e6 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -1195,53 +1195,3 @@ rte_event_pmd_release(struct rte_eventdev *eventdev)
 	eventdev->data = NULL;
 	return 0;
 }
-
-struct rte_eventdev *
-rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
-		int socket_id)
-{
-	struct rte_eventdev *eventdev;
-
-	/* Allocate device structure */
-	eventdev = rte_event_pmd_allocate(name, socket_id);
-	if (eventdev == NULL)
-		return NULL;
-
-	/* Allocate private device structure */
-	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-		eventdev->data->dev_private =
-				rte_zmalloc_socket("eventdev device private",
-						dev_private_size,
-						RTE_CACHE_LINE_SIZE,
-						socket_id);
-
-		if (eventdev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private device"
-					" data");
-	}
-
-	return eventdev;
-}
-
-int
-rte_event_pmd_vdev_uninit(const char *name)
-{
-	int ret;
-	struct rte_eventdev *eventdev;
-
-	if (name == NULL)
-		return -EINVAL;
-
-	eventdev = rte_event_pmd_get_named_dev(name);
-	if (eventdev == NULL)
-		return -ENODEV;
-
-	ret = rte_event_dev_close(eventdev->data->dev_id);
-	if (ret < 0)
-		return ret;
-
-	/* Free the event device */
-	rte_event_pmd_release(eventdev);
-
-	return 0;
-}
diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
index 3686de549..ecefb94d6 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd.h
@@ -495,35 +495,6 @@ rte_event_pmd_allocate(const char *name, int socket_id);
 int
 rte_event_pmd_release(struct rte_eventdev *eventdev);
 
-/**
- * Creates a new virtual event device and returns the pointer to that device.
- *
- * @param name
- *   PMD type name
- * @param dev_private_size
- *   Size of event PMDs private data
- * @param socket_id
- *   Socket to allocate resources on.
- *
- * @return
- *   - Eventdev pointer if device is successfully created.
- *   - NULL if device cannot be created.
- */
-struct rte_eventdev *
-rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
-		int socket_id);
-
-/**
- * Destroy the given virtual event device
- *
- * @param name
- *   PMD type name
- * @return
- *   - 0 on success, negative on error
- */
-int
-rte_event_pmd_vdev_uninit(const char *name);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eventdev/rte_eventdev_pmd_vdev.h b/lib/librte_eventdev/rte_eventdev_pmd_vdev.h
new file mode 100644
index 000000000..714a59924
--- /dev/null
+++ b/lib/librte_eventdev/rte_eventdev_pmd_vdev.h
@@ -0,0 +1,134 @@
+/*
+ *
+ *   Copyright(c) 2016-2017 Cavium networks. All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Cavium networks nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_EVENTDEV_PMD_VDEV_H_
+#define _RTE_EVENTDEV_PMD_VDEV_H_
+
+/** @file
+ * RTE Eventdev VDEV PMD APIs
+ *
+ * @note
+ * These API are from event VDEV PMD only and user applications should not call
+ * them directly.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <string.h>
+
+#include <rte_debug.h>
+#include <rte_eal.h>
+#include <rte_vdev.h>
+
+#include "rte_eventdev_pmd.h"
+
+/**
+ * @internal
+ * Creates a new virtual event device and returns the pointer to that device.
+ *
+ * @param name
+ *   PMD type name
+ * @param dev_private_size
+ *   Size of event PMDs private data
+ * @param socket_id
+ *   Socket to allocate resources on.
+ *
+ * @return
+ *   - Eventdev pointer if device is successfully created.
+ *   - NULL if device cannot be created.
+ */
+static inline struct rte_eventdev *
+rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
+		int socket_id)
+{
+
+	struct rte_eventdev *eventdev;
+
+	/* Allocate device structure */
+	eventdev = rte_event_pmd_allocate(name, socket_id);
+	if (eventdev == NULL)
+		return NULL;
+
+	/* Allocate private device structure */
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		eventdev->data->dev_private =
+				rte_zmalloc_socket("eventdev device private",
+						dev_private_size,
+						RTE_CACHE_LINE_SIZE,
+						socket_id);
+
+		if (eventdev->data->dev_private == NULL)
+			rte_panic("Cannot allocate memzone for private device"
+					" data");
+	}
+
+	return eventdev;
+}
+
+/**
+ * @internal
+ * Destroy the given virtual event device
+ *
+ * @param name
+ *   PMD type name
+ * @return
+ *   - 0 on success, negative on error
+ */
+static inline int
+rte_event_pmd_vdev_uninit(const char *name)
+{
+	int ret;
+	struct rte_eventdev *eventdev;
+
+	if (name == NULL)
+		return -EINVAL;
+
+	eventdev = rte_event_pmd_get_named_dev(name);
+	if (eventdev == NULL)
+		return -ENODEV;
+
+	ret = rte_event_dev_close(eventdev->data->dev_id);
+	if (ret < 0)
+		return ret;
+
+	/* Free the event device */
+	rte_event_pmd_release(eventdev);
+
+	return 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_EVENTDEV_PMD_VDEV_H_ */
-- 
2.13.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH v4 0/4] Remove PCI and VDEV dependency from eventdev library
  2017-06-09  8:37       ` [dpdk-dev] [PATCH v4 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
                           ` (3 preceding siblings ...)
  2017-06-09  8:37         ` [dpdk-dev] [PATCH v4 4/4] eventdev: make vdev init and uninit " Jerin Jacob
@ 2017-06-20 14:14         ` Jerin Jacob
  4 siblings, 0 replies; 20+ messages in thread
From: Jerin Jacob @ 2017-06-20 14:14 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, harry.van.haaren, hemant.agrawal, gage.eads,
	nipun.gupta, gaetan.rivet

-----Original Message-----
> Date: Fri,  9 Jun 2017 14:07:25 +0530
> From: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> To: dev@dpdk.org
> Cc: bruce.richardson@intel.com, harry.van.haaren@intel.com,
>  hemant.agrawal@nxp.com, gage.eads@intel.com, nipun.gupta@nxp.com,
>  gaetan.rivet@6wind.com, Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Subject: [dpdk-dev] [PATCH v4 0/4] Remove PCI and VDEV dependency from
>  eventdev library
> X-Mailer: git-send-email 2.13.1
> 
> v4:
> Fix Gaëtan Rivet reported compilation issues
> 
> v3:
> Removed the bus dependency by spliting lib/librte_eventdev/rte_eventdev_pmd_pci.h
> and lib/librte_eventdev/rte_eventdev_pmd_vdev.h

Applied the series to dpdk-next-eventdev/master. Thanks.

> 
> Jerin Jacob (4):
>   eventdev: remove PCI dependency from generic data structures
>   eventdev: restructure event PMD release function
>   eventdev: make PCI probe and remove functions optional
>   eventdev: make vdev init and uninit functions optional
> 
>  drivers/event/octeontx/ssovf_evdev.c        |   2 +
>  drivers/event/octeontx/ssovf_evdev.h        |   2 +-
>  drivers/event/octeontx/ssovf_worker.h       |   1 +
>  drivers/event/skeleton/skeleton_eventdev.c  |  33 +++---
>  drivers/event/skeleton/skeleton_eventdev.h  |   3 +-
>  drivers/event/sw/sw_evdev.c                 |   1 +
>  drivers/event/sw/sw_evdev.h                 |   2 +-
>  lib/librte_eventdev/Makefile                |   2 +
>  lib/librte_eventdev/rte_eventdev.c          | 148 -------------------------
>  lib/librte_eventdev/rte_eventdev.h          |   2 -
>  lib/librte_eventdev/rte_eventdev_pmd.h      | 101 +-----------------
>  lib/librte_eventdev/rte_eventdev_pmd_pci.h  | 160 ++++++++++++++++++++++++++++
>  lib/librte_eventdev/rte_eventdev_pmd_vdev.h | 134 +++++++++++++++++++++++
>  13 files changed, 327 insertions(+), 264 deletions(-)
>  create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_pci.h
>  create mode 100644 lib/librte_eventdev/rte_eventdev_pmd_vdev.h
> 
> -- 
> 2.13.1
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2017-06-20 14:15 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-01 16:41 [dpdk-dev] [PATCH] eventdev: remove PCI dependency Jerin Jacob
2017-06-05 12:55 ` Gaëtan Rivet
2017-06-06  3:05   ` Jerin Jacob
2017-06-06  8:09     ` Gaëtan Rivet
2017-06-06  9:01       ` Jerin Jacob
2017-06-06 14:10 ` [dpdk-dev] [PATCH v2] " Jerin Jacob
2017-06-06 14:51   ` Gaëtan Rivet
2017-06-07  8:43   ` [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 1/4] eventdev: remove PCI dependency from generic data structures Jerin Jacob
2017-06-09  8:37       ` [dpdk-dev] [PATCH v4 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
2017-06-09  8:37         ` [dpdk-dev] [PATCH v4 1/4] eventdev: remove PCI dependency from generic data structures Jerin Jacob
2017-06-09  8:37         ` [dpdk-dev] [PATCH v4 2/4] eventdev: restructure event PMD release function Jerin Jacob
2017-06-09  8:37         ` [dpdk-dev] [PATCH v4 3/4] eventdev: make PCI probe and remove functions optional Jerin Jacob
2017-06-09  8:37         ` [dpdk-dev] [PATCH v4 4/4] eventdev: make vdev init and uninit " Jerin Jacob
2017-06-20 14:14         ` [dpdk-dev] [PATCH v4 0/4] Remove PCI and VDEV dependency from eventdev library Jerin Jacob
2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 2/4] eventdev: restructure event PMD release function Jerin Jacob
2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 3/4] eventdev: make PCI probe and remove functions optional Jerin Jacob
2017-06-07  8:43     ` [dpdk-dev] [PATCH v2 4/4] eventdev: make vdev init and uninit " Jerin Jacob
2017-06-07  9:27     ` [dpdk-dev] [PATCH v2 0/4] Remove PCI and VDEV dependency from eventdev library Gaëtan Rivet
2017-06-08 17:05       ` Jerin Jacob

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).