mempool/dpaa: allocate bp info for multiprocess
authorAkhil Goyal <akhil.goyal@nxp.com>
Tue, 26 Mar 2019 12:01:45 +0000 (12:01 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 29 Mar 2019 13:36:39 +0000 (14:36 +0100)
rte_dpaa_bpid_info shall be allocated with the hugepage memory
which can be shared across processes.

Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
drivers/bus/dpaa/include/fsl_qman.h
drivers/mempool/dpaa/dpaa_mempool.c
drivers/mempool/dpaa/dpaa_mempool.h
drivers/net/dpaa/dpaa_ethdev.c
drivers/net/dpaa/dpaa_rxtx.c

index ef598cc..e5cccbb 100644 (file)
@@ -1225,6 +1225,7 @@ struct qman_fq {
        struct rte_event ev;
        /* affined portal in case of static queue */
        struct qman_portal *qp;
+       struct dpaa_bp_info *bp_array;
 
        volatile unsigned long flags;
 
index 021b366..0030817 100644 (file)
@@ -35,7 +35,7 @@
 struct dpaa_memseg_list rte_dpaa_memsegs
        = TAILQ_HEAD_INITIALIZER(rte_dpaa_memsegs);
 
-struct dpaa_bp_info rte_dpaa_bpid_info[DPAA_MAX_BPOOLS];
+struct dpaa_bp_info *rte_dpaa_bpid_info;
 
 static int
 dpaa_mbuf_create_pool(struct rte_mempool *mp)
@@ -74,6 +74,14 @@ dpaa_mbuf_create_pool(struct rte_mempool *mp)
                DPAA_MEMPOOL_WARN("drained %u bufs from BPID %d",
                                  num_bufs, bpid);
 
+       if (rte_dpaa_bpid_info == NULL) {
+               rte_dpaa_bpid_info = (struct dpaa_bp_info *)rte_zmalloc(NULL,
+                               sizeof(struct dpaa_bp_info) * DPAA_MAX_BPOOLS,
+                               RTE_CACHE_LINE_SIZE);
+               if (rte_dpaa_bpid_info == NULL)
+                       return -ENOMEM;
+       }
+
        rte_dpaa_bpid_info[bpid].mp = mp;
        rte_dpaa_bpid_info[bpid].bpid = bpid;
        rte_dpaa_bpid_info[bpid].size = mp->elt_size;
index 533e1c6..f69e11f 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- *   Copyright 2017 NXP
+ *   Copyright 2017,2019 NXP
  *
  */
 #ifndef __DPAA_MEMPOOL_H__
@@ -54,7 +54,7 @@ DPAA_MEMPOOL_PTOV(struct dpaa_bp_info *bp_info __rte_unused, uint64_t addr)
 #define DPAA_MEMPOOL_TO_BPID(__mp) \
        (((struct dpaa_bp_info *)__mp->pool_data)->bpid)
 
-extern struct dpaa_bp_info rte_dpaa_bpid_info[DPAA_MAX_BPOOLS];
+extern struct dpaa_bp_info *rte_dpaa_bpid_info;
 
 #define DPAA_BPID_TO_POOL_INFO(__bpid) (&rte_dpaa_bpid_info[__bpid])
 
index d42ac62..d124169 100644 (file)
@@ -673,6 +673,7 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 
                rxq->is_static = true;
        }
+       rxq->bp_array = rte_dpaa_bpid_info;
        dev->data->rx_queues[queue_idx] = rxq;
 
        /* configure the CGR size as per the desc size */
index c4471c2..a4085f4 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2017 NXP
+ *   Copyright 2017,2019 NXP
  *
  */
 
@@ -598,6 +598,10 @@ uint16_t dpaa_eth_queue_rx(void *q,
        int num_rx_bufs, ret;
        uint32_t vdqcr_flags = 0;
 
+       if (unlikely(rte_dpaa_bpid_info == NULL &&
+                               rte_eal_process_type() == RTE_PROC_SECONDARY))
+               rte_dpaa_bpid_info = fq->bp_array;
+
        if (likely(fq->is_static))
                return dpaa_eth_queue_portal_rx(fq, bufs, nb_bufs);