bus/fslmc: add accessor for MCP
authorHemant Agrawal <hemant.agrawal@nxp.com>
Fri, 15 May 2020 09:47:51 +0000 (15:17 +0530)
committerDavid Marchand <david.marchand@redhat.com>
Tue, 19 May 2020 13:49:53 +0000 (15:49 +0200)
Currently rte_mcp_ptr_list is being shared as a variable
across libs. This is only used in control path.
This patch change it to a exported function based access.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Acked-by: Ray Kinsella <mdr@ashroe.eu>
12 files changed:
drivers/bus/fslmc/fslmc_vfio.c
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/portal/dpaa2_hw_pvt.h
drivers/bus/fslmc/rte_bus_fslmc_version.map
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
drivers/event/dpaa2/dpaa2_hw_dpcon.c
drivers/net/dpaa2/dpaa2_ethdev.c
drivers/net/dpaa2/dpaa2_mux.c
drivers/net/dpaa2/dpaa2_ptp.c
drivers/raw/dpaa2_qdma/dpaa2_qdma.c

index 970969d..efe2c43 100644 (file)
@@ -51,6 +51,15 @@ static int fslmc_iommu_type;
 static uint32_t *msi_intr_vaddr;
 void *(*rte_mcp_ptr_list);
 
+void *
+dpaa2_get_mcp_ptr(int portal_idx)
+{
+       if (rte_mcp_ptr_list)
+               return rte_mcp_ptr_list[portal_idx];
+       else
+               return NULL;
+}
+
 static struct rte_dpaa2_object_list dpaa2_obj_list =
        TAILQ_HEAD_INITIALIZER(dpaa2_obj_list);
 
@@ -734,7 +743,7 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev)
        struct fsl_mc_io dpmng  = {0};
        struct mc_version mc_ver_info = {0};
 
-       rte_mcp_ptr_list = malloc(sizeof(void *) * 1);
+       rte_mcp_ptr_list = malloc(sizeof(void *) * (MC_PORTAL_INDEX + 1));
        if (!rte_mcp_ptr_list) {
                DPAA2_BUS_ERR("Unable to allocate MC portal memory");
                ret = -ENOMEM;
@@ -762,7 +771,7 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev)
         * required.
         */
        if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
-               rte_mcp_ptr_list[0] = (void *)v_addr;
+               rte_mcp_ptr_list[MC_PORTAL_INDEX] = (void *)v_addr;
                return 0;
        }
 
@@ -782,7 +791,7 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev)
                ret = -1;
                goto cleanup;
        }
-       rte_mcp_ptr_list[0] = (void *)v_addr;
+       rte_mcp_ptr_list[MC_PORTAL_INDEX] = (void *)v_addr;
 
        free(dev_name);
        return 0;
index db49d63..79b148f 100644 (file)
@@ -56,7 +56,7 @@ dpaa2_create_dpbp_device(int vdev_fd __rte_unused,
        }
 
        /* Open the dpbp object */
-       dpbp_node->dpbp.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX];
+       dpbp_node->dpbp.regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX);
        ret = dpbp_open(&dpbp_node->dpbp,
                        CMD_PRI_LOW, dpbp_id, &dpbp_node->token);
        if (ret) {
index 5ad0374..d393ce6 100644 (file)
@@ -50,7 +50,7 @@ rte_dpaa2_create_dpci_device(int vdev_fd __rte_unused,
        }
 
        /* Open the dpci object */
-       dpci_node->dpci.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX];
+       dpci_node->dpci.regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX);
        ret = dpci_open(&dpci_node->dpci,
                        CMD_PRI_LOW, dpci_id, &dpci_node->token);
        if (ret) {
index 739ce43..21c535f 100644 (file)
@@ -416,7 +416,7 @@ dpaa2_create_dpio_device(int vdev_fd,
        dpio_dev->hw_id = object_id;
        rte_atomic16_init(&dpio_dev->ref_count);
        /* Using single portal  for all devices */
-       dpio_dev->mc_portal = rte_mcp_ptr_list[MC_PORTAL_INDEX];
+       dpio_dev->mc_portal = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX);
 
        if (!check_lcore_cpuset) {
                check_lcore_cpuset = 1;
index 9b3b980..4074995 100644 (file)
@@ -198,9 +198,6 @@ struct dpaa2_dpcon_dev {
        uint8_t channel_index;
 };
 
-/*! Global MCP list */
-extern void *(*rte_mcp_ptr_list);
-
 /* Refer to Table 7-3 in SEC BG */
 struct qbman_fle {
        uint32_t addr_lo;
@@ -442,4 +439,8 @@ struct dpaa2_dpci_dev *rte_dpaa2_alloc_dpci_dev(void);
 __rte_internal
 void rte_dpaa2_free_dpci_dev(struct dpaa2_dpci_dev *dpci);
 
+/* Global MCP pointer */
+__rte_internal
+void *dpaa2_get_mcp_ptr(int portal_idx);
+
 #endif
index 1b7a5a4..80da19a 100644 (file)
@@ -21,6 +21,7 @@ INTERNAL {
        dpaa2_free_dpbp_dev;
        dpaa2_free_dq_storage;
        dpaa2_free_eq_descriptors;
+       dpaa2_get_mcp_ptr;
        dpaa2_io_portal;
        dpaa2_svr_family;
        dpaa2_virt_mode;
@@ -111,5 +112,4 @@ INTERNAL {
        rte_fslmc_get_device_count;
        rte_fslmc_object_register;
        rte_global_active_dqs_list;
-       rte_mcp_ptr_list;
 };
index 6459a02..63e7d93 100644 (file)
@@ -3786,7 +3786,7 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)
                        "Error in allocating the memory for dpsec object");
                return -ENOMEM;
        }
-       dpseci->regs = rte_mcp_ptr_list[0];
+       dpseci->regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX);
 
        retcode = dpseci_open(dpseci, CMD_PRI_LOW, hw_id, &token);
        if (retcode != 0) {
index d64e588..200b716 100644 (file)
@@ -48,7 +48,7 @@ rte_dpaa2_create_dpcon_device(int dev_fd __rte_unused,
        }
 
        /* Open the dpcon object */
-       dpcon_node->dpcon.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX];
+       dpcon_node->dpcon.regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX);
        ret = dpcon_open(&dpcon_node->dpcon,
                         CMD_PRI_LOW, dpcon_id, &dpcon_node->token);
        if (ret) {
index 1bab3b0..2f031ec 100644 (file)
@@ -2343,7 +2343,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
                DPAA2_PMD_ERR("Memory allocation failed for dpni device");
                return -1;
        }
-       dpni_dev->regs = rte_mcp_ptr_list[0];
+       dpni_dev->regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX);
        eth_dev->process_private = (void *)dpni_dev;
 
        /* For secondary processes, the primary has done all the work */
index 9ac8806..f8366e8 100644 (file)
@@ -224,7 +224,7 @@ dpaa2_create_dpdmux_device(int vdev_fd __rte_unused,
        }
 
        /* Open the dpdmux object */
-       dpdmux_dev->dpdmux.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX];
+       dpdmux_dev->dpdmux.regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX);
        ret = dpdmux_open(&dpdmux_dev->dpdmux, CMD_PRI_LOW, dpdmux_id,
                          &dpdmux_dev->token);
        if (ret) {
index 316912f..f58eedb 100644 (file)
@@ -147,7 +147,7 @@ dpaa2_create_dprtc_device(int vdev_fd __rte_unused,
        }
 
        /* Open the dprtc object */
-       dprtc_dev->dprtc.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX];
+       dprtc_dev->dprtc.regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX);
        ret = dprtc_open(&dprtc_dev->dprtc, CMD_PRI_LOW, dprtc_id,
                          &dprtc_dev->token);
        if (ret) {
index d5202d6..1be1b6d 100644 (file)
@@ -1315,7 +1315,7 @@ dpaa2_dpdmai_dev_init(struct rte_rawdev *rawdev, int dpdmai_id)
 
        /* Open DPDMAI device */
        dpdmai_dev->dpdmai_id = dpdmai_id;
-       dpdmai_dev->dpdmai.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX];
+       dpdmai_dev->dpdmai.regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX);
        ret = dpdmai_open(&dpdmai_dev->dpdmai, CMD_PRI_LOW,
                          dpdmai_dev->dpdmai_id, &dpdmai_dev->token);
        if (ret) {