DPDK patches and discussions
 help / color / mirror / Atom feed
From: Shreyansh Jain <shreyansh.jain@nxp.com>
To: <dev@dpdk.org>
Cc: <hemant.agrawal@nxp.com>, <thomas@monjalon.net>,
	Shreyansh Jain <shreyansh.jain@nxp.com>
Subject: [dpdk-dev] [PATCH 5/6] drivers: refactor DPAA2 object definition
Date: Fri, 18 Aug 2017 18:21:26 +0530	[thread overview]
Message-ID: <20170818125127.22346-6-shreyansh.jain@nxp.com> (raw)
In-Reply-To: <20170818125127.22346-1-shreyansh.jain@nxp.com>

Initially, DPAA2 objects (except ETH and CRYPTO) were defined from VFIO
layer. This patch moves that into Bus definition.
This patch also realigns the object types with the new device types.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/fslmc_vfio.c           | 11 +++++-----
 drivers/bus/fslmc/fslmc_vfio.h           | 37 --------------------------------
 drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c |  6 +++---
 drivers/bus/fslmc/portal/dpaa2_hw_dpci.c |  8 +++----
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c |  7 +++---
 drivers/bus/fslmc/rte_fslmc.h            | 36 +++++++++++++++++++++++++++++++
 drivers/event/dpaa2/dpaa2_hw_dpcon.c     |  8 +++----
 7 files changed, 57 insertions(+), 56 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 3b452e1..f0d69a9 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -76,8 +76,9 @@ static uint32_t *msi_intr_vaddr;
 void *(*rte_mcp_ptr_list);
 static uint32_t mcp_id;
 static int is_dma_done;
-static struct rte_fslmc_object_list fslmc_obj_list =
-	TAILQ_HEAD_INITIALIZER(fslmc_obj_list);
+
+static struct rte_dpaa2_object_list dpaa2_obj_list =
+	TAILQ_HEAD_INITIALIZER(dpaa2_obj_list);
 
 /*register a fslmc bus based dpaa2 driver */
 void
@@ -85,7 +86,7 @@ rte_fslmc_object_register(struct rte_dpaa2_object *object)
 {
 	RTE_VERIFY(object);
 
-	TAILQ_INSERT_TAIL(&fslmc_obj_list, object, next);
+	TAILQ_INSERT_TAIL(&dpaa2_obj_list, object, next);
 }
 
 static int vfio_connect_container(void)
@@ -517,9 +518,9 @@ int fslmc_vfio_process_group(void)
 			/* Parse all other objects */
 			struct rte_dpaa2_object *object;
 
-			TAILQ_FOREACH(object, &fslmc_obj_list, next) {
+			TAILQ_FOREACH(object, &dpaa2_obj_list, next) {
 				if (!strcmp(object_type, object->name))
-					object->create(vdev, &device_info,
+					object->create(dev_fd, &device_info,
 						       object_id);
 				else
 					continue;
diff --git a/drivers/bus/fslmc/fslmc_vfio.h b/drivers/bus/fslmc/fslmc_vfio.h
index 942a33c..60a5743 100644
--- a/drivers/bus/fslmc/fslmc_vfio.h
+++ b/drivers/bus/fslmc/fslmc_vfio.h
@@ -66,24 +66,6 @@ typedef struct fslmc_vfio_container {
 	struct fslmc_vfio_group *group;
 } fslmc_vfio_container;
 
-struct rte_dpaa2_object;
-
-TAILQ_HEAD(rte_fslmc_object_list, rte_dpaa2_object);
-
-typedef int (*rte_fslmc_obj_create_t)(struct fslmc_vfio_device *vdev,
-					 struct vfio_device_info *obj_info,
-					 int object_id);
-
-/**
- * A structure describing a DPAA2 driver.
- */
-struct rte_dpaa2_object {
-	TAILQ_ENTRY(rte_dpaa2_object) next; /**< Next in list. */
-	const char *name;            /**< Name of Object. */
-	uint16_t object_id;             /**< DPAA2 Object ID */
-	rte_fslmc_obj_create_t create;
-};
-
 int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle,
 			  uint32_t index);
 
@@ -91,23 +73,4 @@ int fslmc_vfio_setup_group(void);
 int fslmc_vfio_process_group(void);
 int rte_fslmc_vfio_dmamap(void);
 
-/**
- * Register a DPAA2 MC Object driver.
- *
- * @param mc_object
- *   A pointer to a rte_dpaa_object structure describing the mc object
- *   to be registered.
- */
-void rte_fslmc_object_register(struct rte_dpaa2_object *object);
-
-/** Helper for DPAA2 object registration */
-#define RTE_PMD_REGISTER_DPAA2_OBJECT(nm, dpaa2_obj) \
-RTE_INIT(dpaa2objinitfn_ ##nm); \
-static void dpaa2objinitfn_ ##nm(void) \
-{\
-	(dpaa2_obj).name = RTE_STR(nm);\
-	rte_fslmc_object_register(&dpaa2_obj); \
-} \
-RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
-
 #endif /* _FSLMC_VFIO_H_ */
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c
index 33f9eed..1ddd280 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c
@@ -48,7 +48,7 @@
 #include <rte_ethdev.h>
 
 #include <fslmc_logs.h>
-#include <fslmc_vfio.h>
+#include <rte_fslmc.h>
 #include <mc/fsl_dpbp.h>
 #include "portal/dpaa2_hw_pvt.h"
 #include "portal/dpaa2_hw_dpio.h"
@@ -58,7 +58,7 @@ static struct dpbp_dev_list dpbp_dev_list
 	= TAILQ_HEAD_INITIALIZER(dpbp_dev_list); /*!< DPBP device list */
 
 static int
-dpaa2_create_dpbp_device(struct fslmc_vfio_device *vdev __rte_unused,
+dpaa2_create_dpbp_device(int vdev_fd __rte_unused,
 			 struct vfio_device_info *obj_info __rte_unused,
 			 int dpbp_id)
 {
@@ -130,7 +130,7 @@ void dpaa2_free_dpbp_dev(struct dpaa2_dpbp_dev *dpbp)
 }
 
 static struct rte_dpaa2_object rte_dpaa2_dpbp_obj = {
-	.object_id = DPAA2_MC_DPBP_DEVID,
+	.dev_type = DPAA2_BPOOL,
 	.create = dpaa2_create_dpbp_device,
 };
 
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c
index 478e4f7..b60a745 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c
@@ -47,7 +47,7 @@
 #include <rte_ethdev.h>
 
 #include <fslmc_logs.h>
-#include <fslmc_vfio.h>
+#include <rte_fslmc.h>
 #include <mc/fsl_dpci.h>
 #include "portal/dpaa2_hw_pvt.h"
 #include "portal/dpaa2_hw_dpio.h"
@@ -57,9 +57,9 @@ static struct dpci_dev_list dpci_dev_list
 	= TAILQ_HEAD_INITIALIZER(dpci_dev_list); /*!< DPCI device list */
 
 static int
-rte_dpaa2_create_dpci_device(struct fslmc_vfio_device *vdev __rte_unused,
+rte_dpaa2_create_dpci_device(int vdev_fd __rte_unused,
 			     struct vfio_device_info *obj_info __rte_unused,
-				int dpci_id)
+			     int dpci_id)
 {
 	struct dpaa2_dpci_dev *dpci_node;
 	struct dpci_attr attr;
@@ -172,7 +172,7 @@ void rte_dpaa2_free_dpci_dev(struct dpaa2_dpci_dev *dpci)
 }
 
 static struct rte_dpaa2_object rte_dpaa2_dpci_obj = {
-	.object_id = DPAA2_MC_DPCI_DEVID,
+	.dev_type = DPAA2_CI,
 	.create = rte_dpaa2_create_dpci_device,
 };
 
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 283441b..da41849 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -60,6 +60,7 @@
 
 #include <fslmc_logs.h>
 #include <fslmc_vfio.h>
+#include <rte_fslmc.h>
 #include "dpaa2_hw_pvt.h"
 #include "dpaa2_hw_dpio.h"
 #include <mc/fsl_dpmng.h>
@@ -428,7 +429,7 @@ dpaa2_affine_qbman_swp_sec(void)
 }
 
 static int
-dpaa2_create_dpio_device(struct fslmc_vfio_device *vdev,
+dpaa2_create_dpio_device(int vdev_fd,
 			 struct vfio_device_info *obj_info,
 			 int object_id)
 {
@@ -451,7 +452,7 @@ dpaa2_create_dpio_device(struct fslmc_vfio_device *vdev,
 
 	dpio_dev->dpio = NULL;
 	dpio_dev->hw_id = object_id;
-	dpio_dev->intr_handle.vfio_dev_fd = vdev->fd;
+	dpio_dev->intr_handle.vfio_dev_fd = vdev_fd;
 	rte_atomic16_init(&dpio_dev->ref_count);
 	/* Using single portal  for all devices */
 	dpio_dev->mc_portal = rte_mcp_ptr_list[MC_PORTAL_INDEX];
@@ -529,7 +530,7 @@ dpaa2_alloc_dq_storage(struct queue_storage_info_t *q_storage)
 }
 
 static struct rte_dpaa2_object rte_dpaa2_dpio_obj = {
-	.object_id = DPAA2_MC_DPIO_DEVID,
+	.dev_type = DPAA2_IO,
 	.create = dpaa2_create_dpio_device,
 };
 
diff --git a/drivers/bus/fslmc/rte_fslmc.h b/drivers/bus/fslmc/rte_fslmc.h
index ff7a49e..2f684d9 100644
--- a/drivers/bus/fslmc/rte_fslmc.h
+++ b/drivers/bus/fslmc/rte_fslmc.h
@@ -50,6 +50,7 @@ extern "C" {
 #include <sys/queue.h>
 #include <stdint.h>
 #include <inttypes.h>
+#include <linux/vfio.h>
 
 #include <rte_debug.h>
 #include <rte_interrupts.h>
@@ -80,6 +81,22 @@ enum rte_dpaa2_dev_type {
 	DPAA2_UNKNOWN
 };
 
+TAILQ_HEAD(rte_dpaa2_object_list, rte_dpaa2_object);
+
+typedef int (*rte_dpaa2_obj_create_t)(int vdev_fd,
+				      struct vfio_device_info *obj_info,
+				      int object_id);
+
+/**
+ * A structure describing a DPAA2 object.
+ */
+struct rte_dpaa2_object {
+	TAILQ_ENTRY(rte_dpaa2_object) next; /**< Next in list. */
+	const char *name;                   /**< Name of Object. */
+	enum rte_dpaa2_dev_type dev_type;   /**< Type of device */
+	rte_dpaa2_obj_create_t create;
+};
+
 /**
  * A structure describing a DPAA2 device.
  */
@@ -159,4 +176,23 @@ RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
 }
 #endif
 
+/**
+ * Register a DPAA2 MC Object driver.
+ *
+ * @param mc_object
+ *   A pointer to a rte_dpaa_object structure describing the mc object
+ *   to be registered.
+ */
+void rte_fslmc_object_register(struct rte_dpaa2_object *object);
+
+/** Helper for DPAA2 object registration */
+#define RTE_PMD_REGISTER_DPAA2_OBJECT(nm, dpaa2_obj) \
+RTE_INIT(dpaa2objinitfn_ ##nm); \
+static void dpaa2objinitfn_ ##nm(void) \
+{\
+	(dpaa2_obj).name = RTE_STR(nm);\
+	rte_fslmc_object_register(&dpaa2_obj); \
+} \
+RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
+
 #endif /* _RTE_FSLMC_H_ */
diff --git a/drivers/event/dpaa2/dpaa2_hw_dpcon.c b/drivers/event/dpaa2/dpaa2_hw_dpcon.c
index d3e73f9..2c416b5 100644
--- a/drivers/event/dpaa2/dpaa2_hw_dpcon.c
+++ b/drivers/event/dpaa2/dpaa2_hw_dpcon.c
@@ -46,7 +46,7 @@
 #include <rte_dev.h>
 #include <rte_ethdev.h>
 
-#include <fslmc_vfio.h>
+#include <rte_fslmc.h>
 #include <mc/fsl_dpcon.h>
 #include <portal/dpaa2_hw_pvt.h>
 #include "dpaa2_eventdev.h"
@@ -56,9 +56,9 @@ static struct dpcon_dev_list dpcon_dev_list
 	= TAILQ_HEAD_INITIALIZER(dpcon_dev_list); /*!< DPCON device list */
 
 static int
-rte_dpaa2_create_dpcon_device(struct fslmc_vfio_device *vdev __rte_unused,
+rte_dpaa2_create_dpcon_device(int dev_fd __rte_unused,
 			      struct vfio_device_info *obj_info __rte_unused,
-			 int dpcon_id)
+			      int dpcon_id)
 {
 	struct dpaa2_dpcon_dev *dpcon_node;
 	struct dpcon_attr attr;
@@ -132,7 +132,7 @@ void rte_dpaa2_free_dpcon_dev(struct dpaa2_dpcon_dev *dpcon)
 }
 
 static struct rte_dpaa2_object rte_dpaa2_dpcon_obj = {
-	.object_id = DPAA2_MC_DPCON_DEVID,
+	.dev_type = DPAA2_CON,
 	.create = rte_dpaa2_create_dpcon_device,
 };
 
-- 
2.9.3

  parent reply	other threads:[~2017-08-18 12:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-18 12:51 [dpdk-dev] [PATCH 0/6] NXP DPAA2: Refactor bus scan/probe code Shreyansh Jain
2017-08-18 12:51 ` [dpdk-dev] [PATCH 1/6] bus/fslmc: support only single group and container Shreyansh Jain
2017-08-18 12:51 ` [dpdk-dev] [PATCH 2/6] bus/fslmc: introduce new device type enumerator Shreyansh Jain
2017-08-18 12:51 ` [dpdk-dev] [PATCH 3/6] net/dpaa2: update driver type field Shreyansh Jain
2017-08-18 12:51 ` [dpdk-dev] [PATCH 4/6] crypto/dpaa2_sec: " Shreyansh Jain
2017-08-18 12:51 ` Shreyansh Jain [this message]
2017-08-18 12:51 ` [dpdk-dev] [PATCH 6/6] bus/fslmc: refactor scan and probe functions Shreyansh Jain
2017-08-25 10:19 ` [dpdk-dev] [PATCH v2 0/6] NXP DPAA2: Refactor bus scan/probe code Shreyansh Jain
2017-08-25 10:19   ` [dpdk-dev] [PATCH v2 1/6] bus/fslmc: support only single group and container Shreyansh Jain
2017-09-18 11:15     ` santosh
2017-08-25 10:19   ` [dpdk-dev] [PATCH v2 2/6] bus/fslmc: introduce new device type enumerator Shreyansh Jain
2017-08-25 10:19   ` [dpdk-dev] [PATCH v2 3/6] crypto/dpaa2_sec: update driver type field Shreyansh Jain
2017-08-25 10:19   ` [dpdk-dev] [PATCH v2 4/6] net/dpaa2: " Shreyansh Jain
2017-08-25 10:19   ` [dpdk-dev] [PATCH v2 5/6] drivers: refactor DPAA2 object definition Shreyansh Jain
2017-08-25 10:19   ` [dpdk-dev] [PATCH v2 6/6] bus/fslmc: refactor scan and probe functions Shreyansh Jain
2017-09-11 14:06   ` [dpdk-dev] [PATCH v2 0/6] NXP DPAA2: Refactor bus scan/probe code Ferruh Yigit
2017-09-11 14:25     ` Shreyansh Jain
2017-09-25  7:07       ` Hemant Agrawal
2017-09-18 14:36     ` santosh
2017-10-05 23:09     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170818125127.22346-6-shreyansh.jain@nxp.com \
    --to=shreyansh.jain@nxp.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).