From patchwork Tue Aug 27 07:07:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Saxena X-Patchwork-Id: 172252 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp5396567ily; Tue, 27 Aug 2019 00:09:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2p2/pe5oPjKCL3V0y20Vt6Cd2y9m2G5Z9qmbh0wUdKqdkTcqcdFw9fBoEf1ovr9SQLCVS X-Received: by 2002:a17:906:2310:: with SMTP id l16mr20319428eja.0.1566889789957; Tue, 27 Aug 2019 00:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566889789; cv=none; d=google.com; s=arc-20160816; b=Ftz1WswAqv73iEWCG/PBoUzikrqI1/IeeaizQrO2/be8CBSaK+X81hAZqf8pK3QIB7 yj4TGPJ8OR/H5V20BjbE+QjxFWJCK1qjjOta2eM0QCseE5RHbQMuldTqrUHJXF7S0D3V YGTgGgHUIHN2mt8orYCWbGejpMMK0v36GeiiMcsajZLqRTuwzXeXyiDjNAC16FSETgbz /xnQ2HWqw9JCBWp9C1K6FqfpR4R7HNQQykPDeF43TkLg/QrCHqsX3iukKlW3O6iA++qf AC2jVoLB4nRfxOSyCChCLGWRVP4CmI57lRP2FZnHQg9DDxMah/UAjILu6cyQRcMU8Vtm +9Pg== 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=KjOiZO/lW5qWOFhfj4+hYL7TaIwlN/JajoEdobd+KEk=; b=0wVqFNEqKbkkM4bMVM3XsEDosPqw578k7rwEUahB9zktUtI8/3/V8DUQQZh4i0qPEj fKZK8gT5nI8n1977IypLzlXtL/TLzD440KRvMYl8E4/96bplk/VYkyqj2t0l7l73gwm+ US0AjIZiMLRZTiYG7X1rFV9IsKEUDzL4rCDhm3diO6OOTvga0ukClrNMNHBR/Jf3V7OU xiJBQ+SxADm6wC5cWexpgQeAvF8BsHLxzvnlLYY0N8S9giDnUHS0pNzMINAXAJE7TLFg snGZsciFYgpigYbsNFobeoa6gnxMMDN5TkPyfIy9k3DYoV7kLVUauws1YNCxNyhQp2Ij 44MA== 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 s47si8127239edm.38.2019.08.27.00.09.49; Tue, 27 Aug 2019 00:09:49 -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 D8F261BFED; Tue, 27 Aug 2019 09:09:24 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 349B21BF91 for ; Tue, 27 Aug 2019 09:09:17 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 0F35C1A020A; Tue, 27 Aug 2019 09:09:17 +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 C76D81A059B; Tue, 27 Aug 2019 09:09:14 +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 DA78E402F0; Tue, 27 Aug 2019 15:09:10 +0800 (SGT) From: Sachin Saxena To: dev@dpdk.org Cc: thomas@monjalon.net, Nipun Gupta Date: Tue, 27 Aug 2019 12:37:04 +0530 Message-Id: <20190827070730.11206-5-sachin.saxena@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190827070730.11206-1-sachin.saxena@nxp.com> References: <20190827070730.11206-1-sachin.saxena@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v1 04/30] bus/dpaa: decouple fq portal alloc and init 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: Nipun Gupta The decoupling of FQ portal allocation is required as a pre-requisite to support Rx interrupts as we need to have event FD's at portal allocation i.e. before the initialization of the Frame Queues. This change will help us get the event fd once the portals have been allocated for static FQ's. Signed-off-by: Nipun Gupta --- drivers/bus/dpaa/base/qbman/qman.c | 35 ++++++++--------- drivers/bus/dpaa/base/qbman/qman_driver.c | 46 ++++++++++++++++------- drivers/bus/dpaa/base/qbman/qman_priv.h | 13 +++++-- drivers/bus/dpaa/dpaa_bus.c | 13 +++---- drivers/bus/dpaa/include/fsl_qman.h | 3 +- drivers/bus/dpaa/include/fsl_usd.h | 6 ++- drivers/bus/dpaa/rte_bus_dpaa_version.map | 7 ++++ drivers/net/dpaa/dpaa_ethdev.c | 10 +++++ drivers/net/dpaa/dpaa_rxtx.c | 3 +- 9 files changed, 90 insertions(+), 46 deletions(-) -- 2.17.1 diff --git a/drivers/bus/dpaa/base/qbman/qman.c b/drivers/bus/dpaa/base/qbman/qman.c index c6f7d7bb3..79017f7f2 100644 --- a/drivers/bus/dpaa/base/qbman/qman.c +++ b/drivers/bus/dpaa/base/qbman/qman.c @@ -498,11 +498,10 @@ static inline void qm_mr_pvb_update(struct qm_portal *portal) dcbit_ro(res); } -static inline -struct qman_portal *qman_create_portal( - struct qman_portal *portal, - const struct qm_portal_config *c, - const struct qman_cgrs *cgrs) +struct qman_portal * +qman_init_portal(struct qman_portal *portal, + const struct qm_portal_config *c, + const struct qman_cgrs *cgrs) { struct qm_portal *p; char buf[16]; @@ -511,6 +510,9 @@ struct qman_portal *qman_create_portal( p = &portal->p; + if (!c) + c = portal->config; + if (dpaa_svr_family == SVR_LS1043A_FAMILY) portal->use_eqcr_ci_stashing = 3; else @@ -632,21 +634,23 @@ struct qman_portal *qman_create_portal( static struct qman_portal global_portals[MAX_GLOBAL_PORTALS]; static rte_atomic16_t global_portals_used[MAX_GLOBAL_PORTALS]; -static struct qman_portal * -qman_alloc_global_portal(void) +struct qman_portal * +qman_alloc_global_portal(struct qm_portal_config *q_pcfg) { unsigned int i; for (i = 0; i < MAX_GLOBAL_PORTALS; i++) { - if (rte_atomic16_test_and_set(&global_portals_used[i])) + if (rte_atomic16_test_and_set(&global_portals_used[i])) { + global_portals[i].config = q_pcfg; return &global_portals[i]; + } } pr_err("No portal available (%x)\n", MAX_GLOBAL_PORTALS); return NULL; } -static int +int qman_free_global_portal(struct qman_portal *portal) { unsigned int i; @@ -661,22 +665,15 @@ qman_free_global_portal(struct qman_portal *portal) } struct qman_portal *qman_create_affine_portal(const struct qm_portal_config *c, - const struct qman_cgrs *cgrs, - int alloc) + const struct qman_cgrs *cgrs) { struct qman_portal *res; - struct qman_portal *portal; - - if (alloc) - portal = qman_alloc_global_portal(); - else - portal = get_affine_portal(); + struct qman_portal *portal = get_affine_portal(); /* A criteria for calling this function (from qman_driver.c) is that * we're already affine to the cpu and won't schedule onto another cpu. */ - - res = qman_create_portal(portal, c, cgrs); + res = qman_init_portal(portal, c, cgrs); if (res) { spin_lock(&affine_mask_lock); CPU_SET(c->cpu, &affine_mask); diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c b/drivers/bus/dpaa/base/qbman/qman_driver.c index 5c773669a..06ed814e1 100644 --- a/drivers/bus/dpaa/base/qbman/qman_driver.c +++ b/drivers/bus/dpaa/base/qbman/qman_driver.c @@ -62,7 +62,7 @@ static int fsl_qman_portal_init(uint32_t index, int is_shared) qpcfg.node = NULL; qpcfg.irq = qmfd; - portal = qman_create_affine_portal(&qpcfg, NULL, 0); + portal = qman_create_affine_portal(&qpcfg, NULL); if (!portal) { pr_err("Qman portal initialisation failed (%d)\n", qpcfg.cpu); @@ -121,13 +121,13 @@ void qman_thread_irq(void) out_be32(qpcfg.addr_virt[DPAA_PORTAL_CI] + 0x36C0, 0); } -struct qman_portal *fsl_qman_portal_create(void) +struct qman_portal *fsl_qman_fq_portal_create(void) { - struct qman_portal *res; + struct qman_portal *portal = NULL; struct qm_portal_config *q_pcfg; struct dpaa_ioctl_irq_map irq_map; struct dpaa_ioctl_portal_map q_map = {0}; - int q_fd, ret; + int q_fd = 0, ret; q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0); if (!q_pcfg) { @@ -155,38 +155,58 @@ struct qman_portal *fsl_qman_portal_create(void) q_fd = open(QMAN_PORTAL_IRQ_PATH, O_RDONLY); if (q_fd == -1) { pr_err("QMan irq init failed\n"); - goto err1; + goto err; } q_pcfg->irq = q_fd; - res = qman_create_affine_portal(q_pcfg, NULL, true); - if (!res) { + portal = qman_alloc_global_portal(q_pcfg); + if (!portal) { pr_err("Qman portal initialisation failed (%d)\n", q_pcfg->cpu); - goto err2; + goto err; } irq_map.type = dpaa_portal_qman; irq_map.portal_cinh = q_map.addr.cinh; process_portal_irq_map(q_fd, &irq_map); - return res; -err2: - close(q_fd); -err1: + return portal; +err: + if (portal) + qman_free_global_portal(portal); + if (q_fd) + close(q_fd); process_portal_unmap(&q_map.addr); kfree(q_pcfg); return NULL; } -int fsl_qman_portal_destroy(struct qman_portal *qp) +int fsl_qman_fq_portal_init(struct qman_portal *qp) +{ + struct qman_portal *res; + + res = qman_init_portal(qp, NULL, NULL); + if (!res) { + pr_err("Qman portal initialisation failed\n"); + return -1; + } + + return 0; +} + +int fsl_qman_fq_portal_destroy(struct qman_portal *qp) { const struct qm_portal_config *cfg; struct dpaa_portal_map addr; int ret; cfg = qman_destroy_affine_portal(qp); + + ret = qman_free_global_portal(qp); + if (ret) + pr_err("qman_free_global_portal() (%d)\n", ret); + kfree(qp); process_portal_irq_unmap(cfg->irq); diff --git a/drivers/bus/dpaa/base/qbman/qman_priv.h b/drivers/bus/dpaa/base/qbman/qman_priv.h index 02f6301f0..97d5521a8 100644 --- a/drivers/bus/dpaa/base/qbman/qman_priv.h +++ b/drivers/bus/dpaa/base/qbman/qman_priv.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) * * Copyright 2008-2016 Freescale Semiconductor Inc. - * Copyright 2017 NXP + * Copyright 2017,2019 NXP * */ @@ -145,11 +145,18 @@ int qm_get_wpm(int *wpm); struct qman_portal *qman_create_affine_portal( const struct qm_portal_config *config, - const struct qman_cgrs *cgrs, - int alloc); + const struct qman_cgrs *cgrs); const struct qm_portal_config * qman_destroy_affine_portal(struct qman_portal *q); +struct qman_portal * +qman_init_portal(struct qman_portal *portal, + const struct qm_portal_config *c, + const struct qman_cgrs *cgrs); + +struct qman_portal *qman_alloc_global_portal(struct qm_portal_config *q_pcfg); +int qman_free_global_portal(struct qman_portal *portal); + struct qm_portal_config *qm_get_unused_portal(void); struct qm_portal_config *qm_get_unused_portal_idx(uint32_t idx); diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index b0e68c4a4..1d8a294b1 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -321,7 +321,6 @@ rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq) { /* Affine above created portal with channel*/ u32 sdqcr; - struct qman_portal *qp; int ret; if (unlikely(!RTE_PER_LCORE(dpaa_io))) { @@ -333,21 +332,21 @@ rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq) } /* Initialise qman specific portals */ - qp = fsl_qman_portal_create(); - if (!qp) { - DPAA_BUS_LOG(ERR, "Unable to alloc fq portal"); + ret = fsl_qman_fq_portal_init(fq->qp); + if (ret) { + DPAA_BUS_LOG(ERR, "Unable to init fq portal"); return -1; } - fq->qp = qp; + sdqcr = QM_SDQCR_CHANNELS_POOL_CONV(fq->ch_id); - qman_static_dequeue_add(sdqcr, qp); + qman_static_dequeue_add(sdqcr, fq->qp); return 0; } int rte_dpaa_portal_fq_close(struct qman_fq *fq) { - return fsl_qman_portal_destroy(fq->qp); + return fsl_qman_fq_portal_destroy(fq->qp); } void diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h index e5cccbbea..5f13a5544 100644 --- a/drivers/bus/dpaa/include/fsl_qman.h +++ b/drivers/bus/dpaa/include/fsl_qman.h @@ -1217,7 +1217,8 @@ struct qman_fq { u32 fqid_le; u16 ch_id; u8 cgr_groupid; - u8 is_static; + u8 is_static:4; + u8 qp_initialized:4; /* DPDK Interface */ void *dpaa_intf; diff --git a/drivers/bus/dpaa/include/fsl_usd.h b/drivers/bus/dpaa/include/fsl_usd.h index ec1ab7cee..ea7be38af 100644 --- a/drivers/bus/dpaa/include/fsl_usd.h +++ b/drivers/bus/dpaa/include/fsl_usd.h @@ -2,6 +2,7 @@ * * Copyright 2010-2011 Freescale Semiconductor, Inc. * All rights reserved. + * Copyright 2019 NXP * */ @@ -74,8 +75,9 @@ int qman_global_init(void); int bman_global_init(void); /* Direct portal create and destroy */ -struct qman_portal *fsl_qman_portal_create(void); -int fsl_qman_portal_destroy(struct qman_portal *qp); +struct qman_portal *fsl_qman_fq_portal_create(void); +int fsl_qman_fq_portal_destroy(struct qman_portal *qp); +int fsl_qman_fq_portal_init(struct qman_portal *qp); #ifdef __cplusplus } diff --git a/drivers/bus/dpaa/rte_bus_dpaa_version.map b/drivers/bus/dpaa/rte_bus_dpaa_version.map index c88deaf7f..f779469f9 100644 --- a/drivers/bus/dpaa/rte_bus_dpaa_version.map +++ b/drivers/bus/dpaa/rte_bus_dpaa_version.map @@ -123,3 +123,10 @@ DPDK_19.05 { local: *; } DPDK_18.11; + +DPDK_19.11 { + global: + fsl_qman_fq_portal_create; + + local: *; +} DPDK_19.05; diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 7f5a8ac3b..4e2c9471e 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -629,6 +629,8 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, dev->data->dev_conf.rxmode.max_rx_pkt_len); /* checking if push mode only, no error check for now */ if (dpaa_push_mode_max_queue > dpaa_push_queue_idx) { + struct qman_portal *qp; + dpaa_push_queue_idx++; opts.we_mask = QM_INITFQ_WE_FQCTRL | QM_INITFQ_WE_CONTEXTA; opts.fqd.fq_ctrl = QM_FQCTRL_AVOIDBLOCK | @@ -672,6 +674,14 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, } rxq->is_static = true; + + /* Allocate qman specific portals */ + qp = fsl_qman_fq_portal_create(); + if (!qp) { + DPAA_PMD_ERR("Unable to alloc fq portal"); + return -1; + } + rxq->qp = qp; } rxq->bp_array = rte_dpaa_bpid_info; dev->data->rx_queues[queue_idx] = rxq; diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c index 30b183607..220c3477d 100644 --- a/drivers/net/dpaa/dpaa_rxtx.c +++ b/drivers/net/dpaa/dpaa_rxtx.c @@ -517,12 +517,13 @@ dpaa_eth_queue_portal_rx(struct qman_fq *fq, { int ret; - if (unlikely(fq->qp == NULL)) { + if (unlikely(!fq->qp_initialized)) { ret = rte_dpaa_portal_fq_init((void *)0, fq); if (ret) { DPAA_PMD_ERR("Failure in affining portal %d", ret); return 0; } + fq->qp_initialized = 1; } return qman_portal_poll_rx(nb_bufs, (void **)bufs, fq->qp);