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 <nipun.gupta@nxp.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
This commit is contained in:
Nipun Gupta 2018-01-23 17:57:06 +05:30 committed by Thomas Monjalon
parent 41c9ee8d11
commit 5d944582d0
6 changed files with 41 additions and 42 deletions

View 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"

View 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;

View 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;

View 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) {

View 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);

View 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);