From patchwork Tue Jul 7 09:22:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 234965 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp737211ilg; Tue, 7 Jul 2020 02:29:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVs6KZZmnv4L6OYnjSdTGyBs1fuwxwRZITDciKsD18+8HvEGJl34H1NHJLB9eiS7XkU0vq X-Received: by 2002:a25:c083:: with SMTP id c125mr36540768ybf.323.1594114156935; Tue, 07 Jul 2020 02:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594114156; cv=none; d=google.com; s=arc-20160816; b=hcqYtMYNHPSrUAdAMs6D18btyYSZ7FAg3aTgWNgGy25rwEBb8H5tWBfzrBm6h2pKYJ rdc8IsjgWTlo0Ho5zQnavXGGF0c3M3EXBfLGj/TutvsqPamgzpyTReNU4NWxHVCr3ySc 3uJlp2ld43lSLeCSnKiXdttRBTE/LD8yZAREOoX/7rGqbhPpDHB35qbSlB4bQGUXE3V7 nghJu7jTgvxH0zdQCbVtwc4Ed+KIYH5j2wopSLcCKS6Rti67/CS6xU8CQnxAIg2zfbLE 1c67N8gbcLCgc3Xp/lZigE92XZTu44aIVnpPw1btV+MP6ByvlGdNnfaN5yGSkbtpXchm 74lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=Q4iEeQsdKvzmH1AGVLWi5TaqHsYHsLfG4sw9xEqDBQI=; b=PtSTHMOtdr5xT3tPBmITbf9ySSVYd2QeDXJGdJ/9ILhhsXZUpAvXaAKOE3MJwJ3pXs rKkV1+SELjP3bi+49RX4QWcBEucNyC38USkNNfDeP02sUXc3WmhLS1xVFiFTfJojEb/s XZED0c059nWpI8sAsjIjD5oWrW3cCghPWOEPiAnfXvSgbOj/dJB9jufX8yPBD77Yv1GF uDiMFSVXzcnTEtch59bhQcpm9CLPfzhU+VzFr6BG1unEILK/tuyM9QF/mFFW3dBOIape fa+10XqQAj1JErs13yEUkWxNr9AjFLH7eY/Z0v4FvA84r96po7CQwPCMdHO33GbTDbtv CKWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id y9si6399358ybn.123.2020.07.07.02.29.16; Tue, 07 Jul 2020 02:29:16 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A83471DD73; Tue, 7 Jul 2020 11:27:18 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 5AAF21DCE9 for ; Tue, 7 Jul 2020 11:27:06 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 3C7171A0A4F; Tue, 7 Jul 2020 11:27:06 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 54BD51A0A30; Tue, 7 Jul 2020 11:27:04 +0200 (CEST) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 191EE402FA; Tue, 7 Jul 2020 17:27:02 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Rohit Raj Date: Tue, 7 Jul 2020 14:52:27 +0530 Message-Id: <20200707092244.12791-13-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707092244.12791-1-hemant.agrawal@nxp.com> References: <20200527132326.1382-1-hemant.agrawal@nxp.com> <20200707092244.12791-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 12/29] drivers: optimize thread local storage for dpaa X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Rohit Raj Minimize the number of different thread variables Add all the thread specific variables in dpaa_portal structure to optimize TLS Usage. Signed-off-by: Rohit Raj Acked-by: Akhil Goyal --- doc/guides/rel_notes/release_20_08.rst | 6 ++++ drivers/bus/dpaa/dpaa_bus.c | 24 ++++++------- drivers/bus/dpaa/rte_bus_dpaa_version.map | 1 - drivers/bus/dpaa/rte_dpaa_bus.h | 42 ++++++++++++++--------- drivers/crypto/dpaa_sec/dpaa_sec.c | 11 +++--- drivers/event/dpaa/dpaa_eventdev.c | 4 +-- drivers/mempool/dpaa/dpaa_mempool.c | 6 ++-- drivers/net/dpaa/dpaa_ethdev.c | 2 +- drivers/net/dpaa/dpaa_rxtx.c | 4 +-- 9 files changed, 54 insertions(+), 46 deletions(-) -- 2.17.1 diff --git a/doc/guides/rel_notes/release_20_08.rst b/doc/guides/rel_notes/release_20_08.rst index d915fce12..b1e039d03 100644 --- a/doc/guides/rel_notes/release_20_08.rst +++ b/doc/guides/rel_notes/release_20_08.rst @@ -119,6 +119,12 @@ New Features See the :doc:`../sample_app_ug/l2_forward_real_virtual` for more details of this parameter usage. +* **Updated NXP dpaa ethdev PMD.** + + Updated the NXP dpaa ethdev with new features and improvements, including: + + * Added support to use datapath APIs from non-EAL pthread + * **Updated NXP dpaa2 ethdev PMD.** Updated the NXP dpaa2 ethdev with new features and improvements, including: diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index 6770fbc52..aa906c34e 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -52,8 +52,7 @@ unsigned int dpaa_svr_family; #define FSL_DPAA_BUS_NAME dpaa_bus -RTE_DEFINE_PER_LCORE(bool, dpaa_io); -RTE_DEFINE_PER_LCORE(struct dpaa_portal_dqrr, held_bufs); +RTE_DEFINE_PER_LCORE(struct dpaa_portal *, dpaa_io); struct fm_eth_port_cfg * dpaa_get_eth_port_cfg(int dev_id) @@ -253,7 +252,6 @@ int rte_dpaa_portal_init(void *arg) { unsigned int cpu, lcore = rte_lcore_id(); int ret; - struct dpaa_portal *dpaa_io_portal; BUS_INIT_FUNC_TRACE(); @@ -288,20 +286,21 @@ int rte_dpaa_portal_init(void *arg) DPAA_BUS_LOG(DEBUG, "QMAN thread initialized - CPU=%d lcore=%d", cpu, lcore); - dpaa_io_portal = rte_malloc(NULL, sizeof(struct dpaa_portal), + DPAA_PER_LCORE_PORTAL = rte_malloc(NULL, sizeof(struct dpaa_portal), RTE_CACHE_LINE_SIZE); - if (!dpaa_io_portal) { + if (!DPAA_PER_LCORE_PORTAL) { DPAA_BUS_LOG(ERR, "Unable to allocate memory"); bman_thread_finish(); qman_thread_finish(); return -ENOMEM; } - dpaa_io_portal->qman_idx = qman_get_portal_index(); - dpaa_io_portal->bman_idx = bman_get_portal_index(); - dpaa_io_portal->tid = syscall(SYS_gettid); + DPAA_PER_LCORE_PORTAL->qman_idx = qman_get_portal_index(); + DPAA_PER_LCORE_PORTAL->bman_idx = bman_get_portal_index(); + DPAA_PER_LCORE_PORTAL->tid = syscall(SYS_gettid); - ret = pthread_setspecific(dpaa_portal_key, (void *)dpaa_io_portal); + ret = pthread_setspecific(dpaa_portal_key, + (void *)DPAA_PER_LCORE_PORTAL); if (ret) { DPAA_BUS_LOG(ERR, "pthread_setspecific failed on core %u" " (lcore=%u) with ret: %d", cpu, lcore, ret); @@ -310,8 +309,6 @@ int rte_dpaa_portal_init(void *arg) return ret; } - RTE_PER_LCORE(dpaa_io) = true; - DPAA_BUS_LOG(DEBUG, "QMAN thread initialized"); return 0; @@ -324,7 +321,7 @@ rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq) u32 sdqcr; int ret; - if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + if (unlikely(!DPAA_PER_LCORE_PORTAL)) { ret = rte_dpaa_portal_init(arg); if (ret < 0) { DPAA_BUS_LOG(ERR, "portal initialization failure"); @@ -367,8 +364,7 @@ dpaa_portal_finish(void *arg) rte_free(dpaa_io_portal); dpaa_io_portal = NULL; - - RTE_PER_LCORE(dpaa_io) = false; + DPAA_PER_LCORE_PORTAL = NULL; } static int diff --git a/drivers/bus/dpaa/rte_bus_dpaa_version.map b/drivers/bus/dpaa/rte_bus_dpaa_version.map index 8069b05af..2defa7992 100644 --- a/drivers/bus/dpaa/rte_bus_dpaa_version.map +++ b/drivers/bus/dpaa/rte_bus_dpaa_version.map @@ -48,7 +48,6 @@ INTERNAL { netcfg_acquire; netcfg_release; per_lcore_dpaa_io; - per_lcore_held_bufs; qman_alloc_cgrid_range; qman_alloc_pool_range; qman_clear_irq; diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h index 2a186d83f..25aff2d30 100644 --- a/drivers/bus/dpaa/rte_dpaa_bus.h +++ b/drivers/bus/dpaa/rte_dpaa_bus.h @@ -35,8 +35,6 @@ extern unsigned int dpaa_svr_family; -extern RTE_DEFINE_PER_LCORE(bool, dpaa_io); - struct rte_dpaa_device; struct rte_dpaa_driver; @@ -90,12 +88,38 @@ struct rte_dpaa_driver { rte_dpaa_remove_t remove; }; +/* Create storage for dqrr entries per lcore */ +#define DPAA_PORTAL_DEQUEUE_DEPTH 16 +struct dpaa_portal_dqrr { + void *mbuf[DPAA_PORTAL_DEQUEUE_DEPTH]; + uint64_t dqrr_held; + uint8_t dqrr_size; +}; + struct dpaa_portal { uint32_t bman_idx; /**< BMAN Portal ID*/ uint32_t qman_idx; /**< QMAN Portal ID*/ + struct dpaa_portal_dqrr dpaa_held_bufs; + struct rte_crypto_op **dpaa_sec_ops; + int dpaa_sec_op_nb; uint64_t tid;/**< Parent Thread id for this portal */ }; +RTE_DECLARE_PER_LCORE(struct dpaa_portal *, dpaa_io); + +#define DPAA_PER_LCORE_PORTAL \ + RTE_PER_LCORE(dpaa_io) +#define DPAA_PER_LCORE_DQRR_SIZE \ + RTE_PER_LCORE(dpaa_io)->dpaa_held_bufs.dqrr_size +#define DPAA_PER_LCORE_DQRR_HELD \ + RTE_PER_LCORE(dpaa_io)->dpaa_held_bufs.dqrr_held +#define DPAA_PER_LCORE_DQRR_MBUF(i) \ + RTE_PER_LCORE(dpaa_io)->dpaa_held_bufs.mbuf[i] +#define DPAA_PER_LCORE_RTE_CRYPTO_OP \ + RTE_PER_LCORE(dpaa_io)->dpaa_sec_ops +#define DPAA_PER_LCORE_DPAA_SEC_OP_NB \ + RTE_PER_LCORE(dpaa_io)->dpaa_sec_op_nb + /* Various structures representing contiguous memory maps */ struct dpaa_memseg { TAILQ_ENTRY(dpaa_memseg) next; @@ -200,20 +224,6 @@ RTE_INIT(dpaainitfn_ ##nm) \ } \ RTE_PMD_EXPORT_NAME(nm, __COUNTER__) -/* Create storage for dqrr entries per lcore */ -#define DPAA_PORTAL_DEQUEUE_DEPTH 16 -struct dpaa_portal_dqrr { - void *mbuf[DPAA_PORTAL_DEQUEUE_DEPTH]; - uint64_t dqrr_held; - uint8_t dqrr_size; -}; - -RTE_DECLARE_PER_LCORE(struct dpaa_portal_dqrr, held_bufs); - -#define DPAA_PER_LCORE_DQRR_SIZE RTE_PER_LCORE(held_bufs).dqrr_size -#define DPAA_PER_LCORE_DQRR_HELD RTE_PER_LCORE(held_bufs).dqrr_held -#define DPAA_PER_LCORE_DQRR_MBUF(i) RTE_PER_LCORE(held_bufs).mbuf[i] - __rte_internal struct fm_eth_port_cfg *dpaa_get_eth_port_cfg(int dev_id); diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index d9fa8bb36..8fcd57373 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -45,9 +45,6 @@ static uint8_t cryptodev_driver_id; -static __thread struct rte_crypto_op **dpaa_sec_ops; -static __thread int dpaa_sec_op_nb; - static int dpaa_sec_attach_sess_q(struct dpaa_sec_qp *qp, dpaa_sec_session *sess); @@ -143,7 +140,7 @@ dqrr_out_fq_cb_rx(struct qman_portal *qm __always_unused, struct dpaa_sec_job *job; struct dpaa_sec_op_ctx *ctx; - if (dpaa_sec_op_nb >= DPAA_SEC_BURST) + if (DPAA_PER_LCORE_DPAA_SEC_OP_NB >= DPAA_SEC_BURST) return qman_cb_dqrr_defer; if (!(dqrr->stat & QM_DQRR_STAT_FD_VALID)) @@ -174,7 +171,7 @@ dqrr_out_fq_cb_rx(struct qman_portal *qm __always_unused, } mbuf->data_len = len; } - dpaa_sec_ops[dpaa_sec_op_nb++] = ctx->op; + DPAA_PER_LCORE_RTE_CRYPTO_OP[DPAA_PER_LCORE_DPAA_SEC_OP_NB++] = ctx->op; dpaa_sec_op_ending(ctx); return qman_cb_dqrr_consume; @@ -2301,7 +2298,7 @@ dpaa_sec_attach_sess_q(struct dpaa_sec_qp *qp, dpaa_sec_session *sess) DPAA_SEC_ERR("Unable to prepare sec cdb"); return ret; } - if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + if (unlikely(!DPAA_PER_LCORE_PORTAL)) { ret = rte_dpaa_portal_init((void *)0); if (ret) { DPAA_SEC_ERR("Failure in affining portal"); @@ -3463,7 +3460,7 @@ cryptodev_dpaa_sec_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused, } } - if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + if (unlikely(!DPAA_PER_LCORE_PORTAL)) { retval = rte_dpaa_portal_init((void *)1); if (retval) { DPAA_SEC_ERR("Unable to initialize portal"); diff --git a/drivers/event/dpaa/dpaa_eventdev.c b/drivers/event/dpaa/dpaa_eventdev.c index e78728b7e..a3c138b7a 100644 --- a/drivers/event/dpaa/dpaa_eventdev.c +++ b/drivers/event/dpaa/dpaa_eventdev.c @@ -179,7 +179,7 @@ dpaa_event_dequeue_burst(void *port, struct rte_event ev[], struct dpaa_port *portal = (struct dpaa_port *)port; struct rte_mbuf *mbuf; - if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + if (unlikely(!DPAA_PER_LCORE_PORTAL)) { /* Affine current thread context to a qman portal */ ret = rte_dpaa_portal_init((void *)0); if (ret) { @@ -251,7 +251,7 @@ dpaa_event_dequeue_burst_intr(void *port, struct rte_event ev[], struct dpaa_port *portal = (struct dpaa_port *)port; struct rte_mbuf *mbuf; - if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + if (unlikely(!DPAA_PER_LCORE_PORTAL)) { /* Affine current thread context to a qman portal */ ret = rte_dpaa_portal_init((void *)0); if (ret) { diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c index 8d1da8028..e6b06f057 100644 --- a/drivers/mempool/dpaa/dpaa_mempool.c +++ b/drivers/mempool/dpaa/dpaa_mempool.c @@ -53,7 +53,7 @@ dpaa_mbuf_create_pool(struct rte_mempool *mp) MEMPOOL_INIT_FUNC_TRACE(); - if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + if (unlikely(!DPAA_PER_LCORE_PORTAL)) { ret = rte_dpaa_portal_init((void *)0); if (ret) { DPAA_MEMPOOL_ERR( @@ -169,7 +169,7 @@ dpaa_mbuf_free_bulk(struct rte_mempool *pool, DPAA_MEMPOOL_DPDEBUG("Request to free %d buffers in bpid = %d", n, bp_info->bpid); - if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + if (unlikely(!DPAA_PER_LCORE_PORTAL)) { ret = rte_dpaa_portal_init((void *)0); if (ret) { DPAA_MEMPOOL_ERR("rte_dpaa_portal_init failed with ret: %d", @@ -224,7 +224,7 @@ dpaa_mbuf_alloc_bulk(struct rte_mempool *pool, return -1; } - if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + if (unlikely(!DPAA_PER_LCORE_PORTAL)) { ret = rte_dpaa_portal_init((void *)0); if (ret) { DPAA_MEMPOOL_ERR("rte_dpaa_portal_init failed with ret: %d", diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 6c94fd396..c9f828a7c 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -1707,7 +1707,7 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused, is_global_init = 1; } - if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + if (unlikely(!DPAA_PER_LCORE_PORTAL)) { ret = rte_dpaa_portal_init((void *)1); if (ret) { DPAA_PMD_ERR("Unable to initialize portal"); diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c index 819cad7c6..5303c9b76 100644 --- a/drivers/net/dpaa/dpaa_rxtx.c +++ b/drivers/net/dpaa/dpaa_rxtx.c @@ -670,7 +670,7 @@ uint16_t dpaa_eth_queue_rx(void *q, if (likely(fq->is_static)) return dpaa_eth_queue_portal_rx(fq, bufs, nb_bufs); - if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + if (unlikely(!DPAA_PER_LCORE_PORTAL)) { ret = rte_dpaa_portal_init((void *)0); if (ret) { DPAA_PMD_ERR("Failure in affining portal"); @@ -970,7 +970,7 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) int ret, realloc_mbuf = 0; uint32_t seqn, index, flags[DPAA_TX_BURST_SIZE] = {0}; - if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + if (unlikely(!DPAA_PER_LCORE_PORTAL)) { ret = rte_dpaa_portal_init((void *)0); if (ret) { DPAA_PMD_ERR("Failure in affining portal");