drivers: refactor DPAA2 object definition
authorShreyansh Jain <shreyansh.jain@nxp.com>
Fri, 25 Aug 2017 10:19:53 +0000 (15:49 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 5 Oct 2017 23:08:46 +0000 (01:08 +0200)
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>
Reviewed-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/bus/fslmc/fslmc_vfio.c
drivers/bus/fslmc/fslmc_vfio.h
drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c
drivers/bus/fslmc/portal/dpaa2_hw_dpci.c
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
drivers/bus/fslmc/rte_fslmc.h
drivers/event/dpaa2/dpaa2_hw_dpcon.c

index 3b452e1..f0d69a9 100644 (file)
@@ -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;
index 942a33c..60a5743 100644 (file)
@@ -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_ */
index 33f9eed..1ddd280 100644 (file)
@@ -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,
 };
 
index 478e4f7..b60a745 100644 (file)
@@ -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,
 };
 
index 283441b..da41849 100644 (file)
@@ -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 @@ fail:
 }
 
 static struct rte_dpaa2_object rte_dpaa2_dpio_obj = {
-       .object_id = DPAA2_MC_DPIO_DEVID,
+       .dev_type = DPAA2_IO,
        .create = dpaa2_create_dpio_device,
 };
 
index ff7a49e..2f684d9 100644 (file)
@@ -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_ */
index d3e73f9..2c416b5 100644 (file)
@@ -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,
 };