]> git.droids-corp.org - dpdk.git/commitdiff
net/dpaa2: handle secondary process for DPNI
authorJun Yang <jun.yang@nxp.com>
Mon, 3 Jan 2022 10:01:22 +0000 (15:31 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 20 Jan 2022 15:24:08 +0000 (16:24 +0100)
This change uses 'dev->process_private' instead of 'priv->hw'
to get dpmcp per process while setting flow distribution,
as priv->hw is only valid for primary process.
It also initialize rte_dpaa2_bpid_info in secondary process.

Signed-off-by: Jun Yang <jun.yang@nxp.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
drivers/mempool/dpaa2/dpaa2_hw_mempool.c
drivers/mempool/dpaa2/rte_dpaa2_mempool.h
drivers/mempool/dpaa2/version.map
drivers/net/dpaa2/base/dpaa2_hw_dpni.c
drivers/net/dpaa2/dpaa2_ethdev.c
drivers/net/dpaa2/dpaa2_ethdev.h

index 39c6252a633c41d636b2f294ea9604de47b50578..56c629c6814c4f1b8d551eba843bd5162023b7e6 100644 (file)
@@ -263,6 +263,29 @@ aligned:
        }
 }
 
+int rte_dpaa2_bpid_info_init(struct rte_mempool *mp)
+{
+       struct dpaa2_bp_info *bp_info = mempool_to_bpinfo(mp);
+       uint32_t bpid = bp_info->bpid;
+
+       if (!rte_dpaa2_bpid_info) {
+               rte_dpaa2_bpid_info = (struct dpaa2_bp_info *)rte_malloc(NULL,
+                                     sizeof(struct dpaa2_bp_info) * MAX_BPID,
+                                     RTE_CACHE_LINE_SIZE);
+               if (rte_dpaa2_bpid_info == NULL)
+                       return -ENOMEM;
+               memset(rte_dpaa2_bpid_info, 0,
+                      sizeof(struct dpaa2_bp_info) * MAX_BPID);
+       }
+
+       rte_dpaa2_bpid_info[bpid].meta_data_size = sizeof(struct rte_mbuf)
+                               + rte_pktmbuf_priv_size(mp);
+       rte_dpaa2_bpid_info[bpid].bp_list = bp_info->bp_list;
+       rte_dpaa2_bpid_info[bpid].bpid = bpid;
+
+       return 0;
+}
+
 uint16_t
 rte_dpaa2_mbuf_pool_bpid(struct rte_mempool *mp)
 {
index 4a22b7c42ed4cdd1af87f6b1a40d853c2eb91ea8..28dea743260527179e13a1bf03d6ae7ed17086b4 100644 (file)
@@ -46,6 +46,21 @@ rte_dpaa2_mbuf_pool_bpid(struct rte_mempool *mp);
 struct rte_mbuf *
 rte_dpaa2_mbuf_from_buf_addr(struct rte_mempool *mp, void *buf_addr);
 
+/**
+ * Initialize the rte_dpaa2_bpid_info
+ * In generial, it is called in the secondary process and
+ * mp has been created in the primary process.
+ *
+ * @param mp
+ *   memory pool
+ *
+ * @return
+ *  - 0 on success.
+ *  - (<0) on failure.
+ */
+__rte_internal
+int rte_dpaa2_bpid_info_init(struct rte_mempool *mp);
+
 #ifdef __cplusplus
 }
 #endif
index 49c460ec54d392262e0a4e7e8ffcf23f02aa4e86..cfd4ae617a20299025ef4be3494348d32e8a3331 100644 (file)
@@ -11,5 +11,6 @@ INTERNAL {
        global:
 
        rte_dpaa2_bpid_info;
+       rte_dpaa2_bpid_info_init;
        rte_dpaa2_mbuf_alloc_bulk;
 };
index 3170694841df887634326618eb29a86564c89d95..9509f6e8a3213ee7c75ba1671e93c15b3096365e 100644 (file)
@@ -95,7 +95,7 @@ dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev,
        uint64_t req_dist_set, int tc_index)
 {
        struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
-       struct fsl_mc_io *dpni = priv->hw;
+       struct fsl_mc_io *dpni = eth_dev->process_private;
        struct dpni_rx_dist_cfg tc_cfg;
        struct dpkg_profile_cfg kg_cfg;
        void *p_params;
@@ -457,13 +457,12 @@ dpaa2_distset_to_dpkg_profile_cfg(
 
 int
 dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv,
-                    void *blist)
+       struct fsl_mc_io *dpni, void *blist)
 {
        /* Function to attach a DPNI with a buffer pool list. Buffer pool list
         * handle is passed in blist.
         */
        int32_t retcode;
-       struct fsl_mc_io *dpni = priv->hw;
        struct dpni_pools_cfg bpool_cfg;
        struct dpaa2_bp_list *bp_list = (struct dpaa2_bp_list *)blist;
        struct dpni_buffer_layout layout;
index efb2feb7c32dea1322e8c437f107f06fe278ed22..361fd9f2249c086886a06cf7eeff9f1e1cacb772 100644 (file)
@@ -18,6 +18,7 @@
 #include <rte_dev.h>
 #include <rte_fslmc.h>
 #include <rte_flow_driver.h>
+#include "rte_dpaa2_mempool.h"
 
 #include "dpaa2_pmd_logs.h"
 #include <fslmc_vfio.h>
@@ -712,9 +713,14 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
        }
 
        if (!priv->bp_list || priv->bp_list->mp != mb_pool) {
+               if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+                       ret = rte_dpaa2_bpid_info_init(mb_pool);
+                       if (ret)
+                               return ret;
+               }
                bpid = mempool_to_bpid(mb_pool);
-               ret = dpaa2_attach_bp_list(priv,
-                                          rte_dpaa2_bpid_info[bpid].bp_list);
+               ret = dpaa2_attach_bp_list(priv, dpni,
+                               rte_dpaa2_bpid_info[bpid].bp_list);
                if (ret)
                        return ret;
        }
index 641a51b51a8418eaa69b4861ae5205065ef51a5b..528bcff5af141cf09b32ffabfa6d445a3219c075 100644 (file)
@@ -208,7 +208,8 @@ int dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev,
 int dpaa2_remove_flow_dist(struct rte_eth_dev *eth_dev,
                           uint8_t tc_index);
 
-int dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv, void *blist);
+int dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv,
+       struct fsl_mc_io *dpni, void *blist);
 
 __rte_internal
 int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev,