bus/dpaa: check portal presence in the caller function
authorNipun Gupta <nipun.gupta@nxp.com>
Tue, 23 Jan 2018 12:27:06 +0000 (17:57 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 31 Jan 2018 12:44:54 +0000 (13:44 +0100)
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 <nipun.gupta@nxp.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
drivers/bus/dpaa/dpaa_bus.c
drivers/bus/dpaa/rte_bus_dpaa_version.map
drivers/bus/dpaa/rte_dpaa_bus.h
drivers/mempool/dpaa/dpaa_mempool.c
drivers/net/dpaa/dpaa_ethdev.c
drivers/net/dpaa/dpaa_rxtx.c

index 9baeac8..1946bbe 100644 (file)
@@ -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"
index 925cf91..8d90285 100644 (file)
@@ -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;
index d613660..718701b 100644 (file)
@@ -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;
 
index c880d4f..fb3b6ba 100644 (file)
@@ -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) {
index 453c9f6..a0978c1 100644 (file)
@@ -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);
index b889d03..f969ccf 100644 (file)
@@ -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);