From: Jun Yang <jun.y...@nxp.com> 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.y...@nxp.com> --- drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 23 +++++++++++++++++++++++ drivers/mempool/dpaa2/rte_dpaa2_mempool.h | 15 +++++++++++++++ drivers/mempool/dpaa2/version.map | 1 + drivers/net/dpaa2/base/dpaa2_hw_dpni.c | 5 ++--- drivers/net/dpaa2/dpaa2_ethdev.c | 10 ++++++++-- drivers/net/dpaa2/dpaa2_ethdev.h | 3 ++- 6 files changed, 51 insertions(+), 6 deletions(-) diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c index 39c6252a63..56c629c681 100644 --- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c +++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c @@ -263,6 +263,29 @@ rte_dpaa2_mbuf_release(struct rte_mempool *pool __rte_unused, } } +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) { diff --git a/drivers/mempool/dpaa2/rte_dpaa2_mempool.h b/drivers/mempool/dpaa2/rte_dpaa2_mempool.h index 4a22b7c42e..28dea74326 100644 --- a/drivers/mempool/dpaa2/rte_dpaa2_mempool.h +++ b/drivers/mempool/dpaa2/rte_dpaa2_mempool.h @@ -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 diff --git a/drivers/mempool/dpaa2/version.map b/drivers/mempool/dpaa2/version.map index 49c460ec54..cfd4ae617a 100644 --- a/drivers/mempool/dpaa2/version.map +++ b/drivers/mempool/dpaa2/version.map @@ -11,5 +11,6 @@ INTERNAL { global: rte_dpaa2_bpid_info; + rte_dpaa2_bpid_info_init; rte_dpaa2_mbuf_alloc_bulk; }; diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c index 3170694841..9509f6e8a3 100644 --- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c +++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c @@ -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; diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index b91e773605..a45beed75f 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -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; } diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h index 1fc2fc367e..bd33a22a8e 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.h +++ b/drivers/net/dpaa2/dpaa2_ethdev.h @@ -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, -- 2.17.1