From: Nipun Gupta Date: Tue, 23 Jan 2018 12:27:06 +0000 (+0530) Subject: bus/dpaa: check portal presence in the caller function X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=5d944582d0282f0d133619cff7515d89bc4ed216;p=dpdk.git bus/dpaa: check portal presence in the caller function In the I/O path we were calling rte_dpaa_portal_init which internally checks if a portal is affined to the core. But this lead to calling of that non-static API in every call. Instead check the portal affinity in the caller itself for performance reasons Signed-off-by: Nipun Gupta Acked-by: Hemant Agrawal --- diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index 9baeac8edf..1946bbe619 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -55,7 +55,7 @@ pthread_key_t dpaa_portal_key; unsigned int dpaa_svr_family; -RTE_DEFINE_PER_LCORE(bool, _dpaa_io); +RTE_DEFINE_PER_LCORE(bool, dpaa_io); RTE_DEFINE_PER_LCORE(struct dpaa_portal_dqrr, held_bufs); static int @@ -225,9 +225,7 @@ dpaa_clean_device_list(void) } } -/** XXX move this function into a separate file */ -static int -_dpaa_portal_init(void *arg) +int rte_dpaa_portal_init(void *arg) { cpu_set_t cpuset; pthread_t id; @@ -298,25 +296,13 @@ _dpaa_portal_init(void *arg) return ret; } - RTE_PER_LCORE(_dpaa_io) = true; + RTE_PER_LCORE(dpaa_io) = true; DPAA_BUS_LOG(DEBUG, "QMAN thread initialized"); return 0; } -/* - * rte_dpaa_portal_init - Wrapper over _dpaa_portal_init with thread level check - * XXX Complete this - */ -int rte_dpaa_portal_init(void *arg) -{ - if (unlikely(!RTE_PER_LCORE(_dpaa_io))) - return _dpaa_portal_init(arg); - - return 0; -} - int rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq) { @@ -324,8 +310,8 @@ rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq) u32 sdqcr; struct qman_portal *qp; - if (unlikely(!RTE_PER_LCORE(_dpaa_io))) - _dpaa_portal_init(arg); + if (unlikely(!RTE_PER_LCORE(dpaa_io))) + rte_dpaa_portal_init(arg); /* Initialise qman specific portals */ qp = fsl_qman_portal_create(); @@ -363,7 +349,7 @@ dpaa_portal_finish(void *arg) rte_free(dpaa_io_portal); dpaa_io_portal = NULL; - RTE_PER_LCORE(_dpaa_io) = false; + RTE_PER_LCORE(dpaa_io) = false; } #define DPAA_DEV_PATH1 "/sys/devices/platform/soc/soc:fsl,dpaa" diff --git a/drivers/bus/dpaa/rte_bus_dpaa_version.map b/drivers/bus/dpaa/rte_bus_dpaa_version.map index 925cf91881..8d90285436 100644 --- a/drivers/bus/dpaa/rte_bus_dpaa_version.map +++ b/drivers/bus/dpaa/rte_bus_dpaa_version.map @@ -70,6 +70,7 @@ DPDK_18.02 { dpaa_logtype_eventdev; dpaa_svr_family; + per_lcore_dpaa_io; per_lcore_held_bufs; qm_channel_pool1; qman_alloc_cgrid_range; diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h index d613660927..718701b178 100644 --- a/drivers/bus/dpaa/rte_dpaa_bus.h +++ b/drivers/bus/dpaa/rte_dpaa_bus.h @@ -33,6 +33,8 @@ extern unsigned int dpaa_svr_family; +extern RTE_DEFINE_PER_LCORE(bool, dpaa_io); + struct rte_dpaa_device; struct rte_dpaa_driver; diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c index c880d4fb39..fb3b6ba0cd 100644 --- a/drivers/mempool/dpaa/dpaa_mempool.c +++ b/drivers/mempool/dpaa/dpaa_mempool.c @@ -139,11 +139,13 @@ dpaa_mbuf_free_bulk(struct rte_mempool *pool, DPAA_MEMPOOL_DPDEBUG("Request to free %d buffers in bpid = %d", n, bp_info->bpid); - ret = rte_dpaa_portal_init((void *)0); - if (ret) { - DPAA_MEMPOOL_ERR("rte_dpaa_portal_init failed with ret: %d", - ret); - return 0; + if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + ret = rte_dpaa_portal_init((void *)0); + if (ret) { + DPAA_MEMPOOL_ERR("rte_dpaa_portal_init failed with ret: %d", + ret); + return 0; + } } while (i < n) { @@ -193,11 +195,13 @@ dpaa_mbuf_alloc_bulk(struct rte_mempool *pool, return -1; } - ret = rte_dpaa_portal_init((void *)0); - if (ret) { - DPAA_MEMPOOL_ERR("rte_dpaa_portal_init failed with ret: %d", - ret); - return -1; + if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + ret = rte_dpaa_portal_init((void *)0); + if (ret) { + DPAA_MEMPOOL_ERR("rte_dpaa_portal_init failed with ret: %d", + ret); + return -1; + } } while (n < count) { diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 453c9f6c0a..a0978c154c 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -1333,10 +1333,12 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv, is_global_init = 1; } - ret = rte_dpaa_portal_init((void *)1); - if (ret) { - DPAA_PMD_ERR("Unable to initialize portal"); - return ret; + if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + ret = rte_dpaa_portal_init((void *)1); + if (ret) { + DPAA_PMD_ERR("Unable to initialize portal"); + return ret; + } } eth_dev = rte_eth_dev_allocate(dpaa_dev->name); diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c index b889d03053..f969ccfd18 100644 --- a/drivers/net/dpaa/dpaa_rxtx.c +++ b/drivers/net/dpaa/dpaa_rxtx.c @@ -503,10 +503,12 @@ uint16_t dpaa_eth_queue_rx(void *q, if (likely(fq->is_static)) return dpaa_eth_queue_portal_rx(fq, bufs, nb_bufs); - ret = rte_dpaa_portal_init((void *)0); - if (ret) { - DPAA_PMD_ERR("Failure in affining portal"); - return 0; + if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + ret = rte_dpaa_portal_init((void *)0); + if (ret) { + DPAA_PMD_ERR("Failure in affining portal"); + return 0; + } } ret = qman_set_vdq(fq, (nb_bufs > DPAA_MAX_DEQUEUE_NUM_FRAMES) ? @@ -777,10 +779,12 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) int ret; uint32_t seqn, index, flags[DPAA_TX_BURST_SIZE] = {0}; - ret = rte_dpaa_portal_init((void *)0); - if (ret) { - DPAA_PMD_ERR("Failure in affining portal"); - return 0; + if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + ret = rte_dpaa_portal_init((void *)0); + if (ret) { + DPAA_PMD_ERR("Failure in affining portal"); + return 0; + } } DPAA_DP_LOG(DEBUG, "Transmitting %d buffers on queue: %p", nb_bufs, q);