From patchwork Thu Apr 4 11:50:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 161789 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1496631jan; Thu, 4 Apr 2019 04:50:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxAFmsHZwbE2wXeoJx8GyU1URn/95cBKLLmtwFhWjLtMN8zuNavHVd3mu5Zf+DeZaivrHpr X-Received: by 2002:aa7:dada:: with SMTP id x26mr3480728eds.77.1554378652942; Thu, 04 Apr 2019 04:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554378652; cv=none; d=google.com; s=arc-20160816; b=cO85Rj8d22OmyO5Bgm3en6Cyf6k7t4SVJBLuLBiSfGXHKyuQ0TZJPLxiI8sshwO3AI Cxxg0wchJxJy7ENleLsZx32BP/A0u4i03+LgK2PvC2dsEtnZJnU0zeC5hmYXDcrl7qCK 4tzALToFd9WhvJSlGM/sxVfjPamqvEfsjnDer5VhtQOfNi+6mv1110aAKRPP2qalnhiN 4COE2lcrPjz7tGoFOQ16A7QmLY9eE17JD7DYDkiD0HEHkW3nVHO1W7dSrUgnFmixhXYx HUrIDbUfsjEg1cdho2CJZLTmT/j2o3bkvmDjXT21Ye0lEQevq+L4GLjKibrOJ7ROgZAr 4t+A== 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:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic:cc :to:from:dkim-signature; bh=KO9LUO99ZWhjrHunjS0vv1O1Q2xt40sziIusmTPAW9s=; b=QdcdSowA8qbdERH+1Ddc009rLKObeq/MEzaxKyidAyXXX6k1E26ZtHdeej5vnwAIBZ hG24tRATaeFX3Aopx45gLcb2VTl/NWwU7Psyou1aLQFm18nklBlhg9MZ/D8wrHAN83u+ KIE7408WcihjbfsPCp++CXr+UB4APTuRMub1JgvF7njHiRb/bFEwgBPkpg6u8eJM2dsJ wpfjO3nOW2tVVn/OA1LNncynxroM37xJT61oaqKF2Kl0B5sIkHAMFUOuI8ke32hqTaz7 sHMT8PcgBKHvg5FYeN9Vh2+qHtIatxr49243UZ0uOv03ZFtHBJkdGyCGq8HqO4l/lLjE YwlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nxp.com header.s=selector1 header.b=hy6+1l2R; 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 e11si176273edd.399.2019.04.04.04.50.52; Thu, 04 Apr 2019 04:50:52 -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; dkim=fail header.i=@nxp.com header.s=selector1 header.b=hy6+1l2R; 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 8415D1B3B4; Thu, 4 Apr 2019 13:50:32 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00084.outbound.protection.outlook.com [40.107.0.84]) by dpdk.org (Postfix) with ESMTP id 4D4131B3A0 for ; Thu, 4 Apr 2019 13:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KO9LUO99ZWhjrHunjS0vv1O1Q2xt40sziIusmTPAW9s=; b=hy6+1l2RT0koeGJqK/QecnAck3ow7s5BKh3qoKAIQCPlig3J44B1jTzW7mUPrf0N8suqfMlS022rkcf08ZgxNLutjAzwMkTp/QK1nzc+2yHuM+5J/AgvUJBjwK6V5F32Nsqw00GtXG+wDMN9FhuaH3ubl8fImmpctGTvGNrD5BY= Received: from VI1PR0401MB2541.eurprd04.prod.outlook.com (10.168.65.19) by VI1PR0401MB1965.eurprd04.prod.outlook.com (10.166.140.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.15; Thu, 4 Apr 2019 11:50:23 +0000 Received: from VI1PR0401MB2541.eurprd04.prod.outlook.com ([fe80::18e3:39b6:c61d:3f18]) by VI1PR0401MB2541.eurprd04.prod.outlook.com ([fe80::18e3:39b6:c61d:3f18%12]) with mapi id 15.20.1750.017; Thu, 4 Apr 2019 11:50:23 +0000 From: Hemant Agrawal To: "dev@dpdk.org" CC: "thomas@monjalon.net" , Shreyansh Jain , Yi Liu Thread-Topic: [PATCH v3 4/7] raw/dpaa2_qdma: add burst mode support Thread-Index: AQHU6tyWXpVpqW8KnU6cQegR5Ngujw== Date: Thu, 4 Apr 2019 11:50:23 +0000 Message-ID: <20190404114818.21286-4-hemant.agrawal@nxp.com> References: <20190404110215.14410-1-hemant.agrawal@nxp.com> <20190404114818.21286-1-hemant.agrawal@nxp.com> In-Reply-To: <20190404114818.21286-1-hemant.agrawal@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [92.120.1.72] x-mailer: git-send-email 2.17.1 x-clientproxiedby: LO2P265CA0082.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8::22) To VI1PR0401MB2541.eurprd04.prod.outlook.com (2603:10a6:800:56::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=hemant.agrawal@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d25e1d8d-6a7f-40f5-da9d-08d6b8f3b84f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VI1PR0401MB1965; x-ms-traffictypediagnostic: VI1PR0401MB1965: x-microsoft-antispam-prvs: x-forefront-prvs: 0997523C40 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(136003)(39860400002)(396003)(366004)(199004)(189003)(44832011)(8936002)(71190400001)(25786009)(305945005)(6512007)(52116002)(478600001)(68736007)(105586002)(4326008)(30864003)(7736002)(486006)(53936002)(2906002)(1076003)(5660300002)(102836004)(5640700003)(76176011)(446003)(186003)(476003)(386003)(66066001)(11346002)(26005)(316002)(106356001)(2616005)(6916009)(2501003)(14454004)(3846002)(81166006)(6486002)(71200400001)(6436002)(99286004)(6116002)(6506007)(81156014)(8676002)(97736004)(50226002)(54906003)(1730700003)(86362001)(256004)(14444005)(36756003)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0401MB1965; H:VI1PR0401MB2541.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ne1mvQ6iLsuv5q8+/4XeDDTZHjJ/8RE5CB6J3VxgeT8XSAzTYwCVoe84jHiWBed2Uy9oRnv2P2dOReWWa0fBOZRux43P+RZ/jrz08t9qqi77q9Lal0jlUPQxGkCBG10810eB2fzeUM66StDBK6kWAglA0omjlRbe9Orr+KtKYapLOFLC0rYPj5Btfcj9KV7Qy9L9yryFVvxxpdu+lghQWYSvG9VThL2ssse/X+N25GUOYWaLRN7JS5ijd91eWmUINNmJnfAAFCsPS+DWSS416hhZoCoGFqGgeqrCD5cMLQY5gpvxcdw2w/VJTeUx+J29uqBP8t5mdhOsVFJsOiLxoMlS+S/iZI+h5rWQxcrp6LuIEqVgzbmFhj3fcOMYVYscXyZUIDdJNL2Msz0clph0Ad3YyDjGLDNaUgz9Ixu8O6o= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d25e1d8d-6a7f-40f5-da9d-08d6b8f3b84f X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Apr 2019 11:50:23.4023 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB1965 Subject: [dpdk-dev] [PATCH v3 4/7] raw/dpaa2_qdma: add burst mode support 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" This patch adds support the batch processing for the qdma jobs Signed-off-by: Hemant Agrawal Signed-off-by: Yi Liu --- drivers/raw/dpaa2_qdma/dpaa2_qdma.c | 305 ++++++++++---------- drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h | 6 +- 2 files changed, 164 insertions(+), 147 deletions(-) -- 2.17.1 diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c index 88c11a3d2..a1351e648 100644 --- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c +++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -395,21 +396,31 @@ dpaa2_qdma_populate_fle(struct qbman_fle *fle, DPAA2_SET_FLE_FIN(fle); } -static int -dpdmai_dev_enqueue(struct dpaa2_dpdmai_dev *dpdmai_dev, - uint16_t txq_id, - uint16_t vq_id, - struct rte_qdma_job *job) +int +rte_qdma_vq_enqueue_multi(uint16_t vq_id, + struct rte_qdma_job **job, + uint16_t nb_jobs) { + struct qdma_virt_queue *qdma_vq = &qdma_vqs[vq_id]; + struct qdma_hw_queue *qdma_pq = qdma_vq->hw_queue; + struct dpaa2_dpdmai_dev *dpdmai_dev = qdma_pq->dpdmai_dev; struct qdma_io_meta *io_meta; - struct qbman_fd fd; + struct qbman_fd fd_arr[MAX_TX_RING_SLOTS]; struct dpaa2_queue *txq; struct qbman_fle *fle; struct qbman_eq_desc eqdesc; struct qbman_swp *swp; int ret; + uint32_t num_to_send = 0; + uint16_t num_tx = 0; + uint16_t num_txed = 0; - DPAA2_QDMA_FUNC_TRACE(); + /* Return error in case of wrong lcore_id */ + if (rte_lcore_id() != qdma_vq->lcore_id) { + DPAA2_QDMA_ERR("QDMA enqueue for vqid %d on wrong core", + vq_id); + return -1; + } if (unlikely(!DPAA2_PER_LCORE_DPIO)) { ret = dpaa2_affine_qbman_swp(); @@ -420,7 +431,7 @@ dpdmai_dev_enqueue(struct dpaa2_dpdmai_dev *dpdmai_dev, } swp = DPAA2_PER_LCORE_PORTAL; - txq = &(dpdmai_dev->tx_queue[txq_id]); + txq = &(dpdmai_dev->tx_queue[qdma_pq->queue_id]); /* Prepare enqueue descriptor */ qbman_eq_desc_clear(&eqdesc); @@ -428,97 +439,86 @@ dpdmai_dev_enqueue(struct dpaa2_dpdmai_dev *dpdmai_dev, qbman_eq_desc_set_no_orp(&eqdesc, 0); qbman_eq_desc_set_response(&eqdesc, 0, 0); - /* - * Get an FLE/SDD from FLE pool. - * Note: IO metadata is before the FLE and SDD memory. - */ - ret = rte_mempool_get(qdma_dev.fle_pool, (void **)(&io_meta)); - if (ret) { - DPAA2_QDMA_DP_WARN("Memory alloc failed for FLE"); - return ret; - } - - /* Set the metadata */ - io_meta->cnxt = (size_t)job; - io_meta->id = vq_id; - - fle = (struct qbman_fle *)(io_meta + 1); - - /* populate Frame descriptor */ - memset(&fd, 0, sizeof(struct qbman_fd)); - DPAA2_SET_FD_ADDR(&fd, DPAA2_VADDR_TO_IOVA(fle)); - DPAA2_SET_FD_COMPOUND_FMT(&fd); - DPAA2_SET_FD_FRC(&fd, QDMA_SER_CTX); + while (nb_jobs > 0) { + uint32_t loop; + + num_to_send = (nb_jobs > dpaa2_eqcr_size) ? + dpaa2_eqcr_size : nb_jobs; + + for (loop = 0; loop < num_to_send; loop++) { + /* + * Get an FLE/SDD from FLE pool. + * Note: IO metadata is before the FLE and SDD memory. + */ + ret = rte_mempool_get(qdma_dev.fle_pool, + (void **)(&io_meta)); + if (ret) { + DPAA2_QDMA_DP_WARN("Me alloc failed for FLE"); + return ret; + } - /* Populate FLE */ - memset(fle, 0, QDMA_FLE_POOL_SIZE); - dpaa2_qdma_populate_fle(fle, job->src, job->dest, job->len, job->flags); + /* Set the metadata */ + io_meta->cnxt = (size_t)job[num_tx]; + io_meta->id = vq_id; - /* Enqueue the packet to the QBMAN */ - do { - ret = qbman_swp_enqueue_multiple(swp, &eqdesc, &fd, NULL, 1); - if (ret < 0 && ret != -EBUSY) - DPAA2_QDMA_ERR("Transmit failure with err: %d", ret); - } while (ret == -EBUSY); + fle = (struct qbman_fle *)(io_meta + 1); - DPAA2_QDMA_DP_DEBUG("Successfully transmitted a packet"); + /* populate Frame descriptor */ + memset(&fd_arr[loop], 0, sizeof(struct qbman_fd)); + DPAA2_SET_FD_ADDR(&fd_arr[loop], + DPAA2_VADDR_TO_IOVA(fle)); + DPAA2_SET_FD_COMPOUND_FMT(&fd_arr[loop]); + DPAA2_SET_FD_FRC(&fd_arr[loop], QDMA_SER_CTX); - return ret; -} + /* Populate FLE */ + memset(fle, 0, QDMA_FLE_POOL_SIZE); + dpaa2_qdma_populate_fle(fle, job[num_tx]->src, + job[num_tx]->dest, + job[num_tx]->len, + job[num_tx]->flags); -int __rte_experimental -rte_qdma_vq_enqueue_multi(uint16_t vq_id, - struct rte_qdma_job **job, - uint16_t nb_jobs) -{ - int i, ret; + num_tx++; + } - DPAA2_QDMA_FUNC_TRACE(); + /* Enqueue the packet to the QBMAN */ + uint32_t enqueue_loop = 0; + while (enqueue_loop < num_to_send) { + enqueue_loop += qbman_swp_enqueue_multiple(swp, + &eqdesc, + &fd_arr[enqueue_loop], + NULL, + num_to_send - enqueue_loop); + } - for (i = 0; i < nb_jobs; i++) { - ret = rte_qdma_vq_enqueue(vq_id, job[i]); - if (ret < 0) - break; + num_txed += num_to_send; + nb_jobs -= num_to_send; } - - return i; + qdma_vq->num_enqueues += num_txed; + return num_txed; } -int __rte_experimental +int rte_qdma_vq_enqueue(uint16_t vq_id, struct rte_qdma_job *job) { - struct qdma_virt_queue *qdma_vq = &qdma_vqs[vq_id]; - struct qdma_hw_queue *qdma_pq = qdma_vq->hw_queue; - struct dpaa2_dpdmai_dev *dpdmai_dev = qdma_pq->dpdmai_dev; int ret; - DPAA2_QDMA_FUNC_TRACE(); - - /* Return error in case of wrong lcore_id */ - if (rte_lcore_id() != qdma_vq->lcore_id) { - DPAA2_QDMA_ERR("QDMA enqueue for vqid %d on wrong core", - vq_id); - return -EINVAL; - } - - ret = dpdmai_dev_enqueue(dpdmai_dev, qdma_pq->queue_id, vq_id, job); + ret = rte_qdma_vq_enqueue_multi(vq_id, &job, 1); if (ret < 0) { DPAA2_QDMA_ERR("DPDMAI device enqueue failed: %d", ret); return ret; } - qdma_vq->num_enqueues++; - return 1; } /* Function to receive a QDMA job for a given device and queue*/ static int -dpdmai_dev_dequeue(struct dpaa2_dpdmai_dev *dpdmai_dev, +dpdmai_dev_dequeue_multijob(struct dpaa2_dpdmai_dev *dpdmai_dev, uint16_t rxq_id, uint16_t *vq_id, - struct rte_qdma_job **job) + struct rte_qdma_job **job, + uint16_t nb_jobs) { struct qdma_io_meta *io_meta; struct dpaa2_queue *rxq; @@ -531,8 +531,6 @@ dpdmai_dev_dequeue(struct dpaa2_dpdmai_dev *dpdmai_dev, uint8_t status; int ret; - DPAA2_QDMA_FUNC_TRACE(); - if (unlikely(!DPAA2_PER_LCORE_DPIO)) { ret = dpaa2_affine_qbman_swp(); if (ret) { @@ -541,7 +539,6 @@ dpdmai_dev_dequeue(struct dpaa2_dpdmai_dev *dpdmai_dev, } } swp = DPAA2_PER_LCORE_PORTAL; - rxq = &(dpdmai_dev->rx_queue[rxq_id]); dq_storage = rxq->q_storage->dq_storage[0]; fqid = rxq->fqid; @@ -551,7 +548,10 @@ dpdmai_dev_dequeue(struct dpaa2_dpdmai_dev *dpdmai_dev, qbman_pull_desc_set_fq(&pulldesc, fqid); qbman_pull_desc_set_storage(&pulldesc, dq_storage, (uint64_t)(DPAA2_VADDR_TO_IOVA(dq_storage)), 1); - qbman_pull_desc_set_numframes(&pulldesc, 1); + if (nb_jobs > dpaa2_dqrr_size) + qbman_pull_desc_set_numframes(&pulldesc, dpaa2_dqrr_size); + else + qbman_pull_desc_set_numframes(&pulldesc, nb_jobs); while (1) { if (qbman_swp_pull(swp, &pulldesc)) { @@ -561,125 +561,138 @@ dpdmai_dev_dequeue(struct dpaa2_dpdmai_dev *dpdmai_dev, break; } - /* Check if previous issued command is completed. */ + rte_prefetch0((void *)((size_t)(dq_storage + 1))); + /* Check if the previous issued command is completed. */ while (!qbman_check_command_complete(dq_storage)) ; - /* Loop until dq_storage is updated with new token by QBMAN */ - while (!qbman_check_new_result(dq_storage)) - ; - /* Check for valid frame. */ - status = qbman_result_DQ_flags(dq_storage); - if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0)) { - DPAA2_QDMA_DP_DEBUG("No frame is delivered"); - return 0; - } + int num_pulled = 0; + int pending = 1; + do { + /* Loop until the dq_storage is updated with + * new token by QBMAN + */ + while (!qbman_check_new_result(dq_storage)) + ; - /* Get the FD */ - fd = qbman_result_DQ_fd(dq_storage); + rte_prefetch0((void *)((size_t)(dq_storage + 2))); + /* Check whether Last Pull command is Expired and + * setting Condition for Loop termination + */ + if (qbman_result_DQ_is_pull_complete(dq_storage)) { + pending = 0; + /* Check for valid frame. */ + status = qbman_result_DQ_flags(dq_storage); + if (unlikely((status & + QBMAN_DQ_STAT_VALIDFRAME) == 0)) + continue; + } + fd = qbman_result_DQ_fd(dq_storage); - /* - * Fetch metadata from FLE. job and vq_id were set - * in metadata in the enqueue operation. - */ - fle = (struct qbman_fle *)DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd)); - io_meta = (struct qdma_io_meta *)(fle) - 1; - if (vq_id) - *vq_id = io_meta->id; + /* + * Fetch metadata from FLE. job and vq_id were set + * in metadata in the enqueue operation. + */ + fle = (struct qbman_fle *) + DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd)); + io_meta = (struct qdma_io_meta *)(fle) - 1; + if (vq_id) + vq_id[num_pulled] = io_meta->id; - *job = (struct rte_qdma_job *)(size_t)io_meta->cnxt; - (*job)->status = DPAA2_GET_FD_ERR(fd); + job[num_pulled] = (struct rte_qdma_job *)(size_t)io_meta->cnxt; + job[num_pulled]->status = DPAA2_GET_FD_ERR(fd); - /* Free FLE to the pool */ - rte_mempool_put(qdma_dev.fle_pool, io_meta); + /* Free FLE to the pool */ + rte_mempool_put(qdma_dev.fle_pool, io_meta); - DPAA2_QDMA_DP_DEBUG("packet received"); + dq_storage++; + num_pulled++; + } while (pending && (num_pulled <= dpaa2_dqrr_size)); - return 1; + return num_pulled; } -int __rte_experimental +int rte_qdma_vq_dequeue_multi(uint16_t vq_id, struct rte_qdma_job **job, uint16_t nb_jobs) -{ - int i; - - DPAA2_QDMA_FUNC_TRACE(); - - for (i = 0; i < nb_jobs; i++) { - job[i] = rte_qdma_vq_dequeue(vq_id); - if (!job[i]) - break; - } - - return i; -} - -struct rte_qdma_job * __rte_experimental -rte_qdma_vq_dequeue(uint16_t vq_id) { struct qdma_virt_queue *qdma_vq = &qdma_vqs[vq_id]; struct qdma_hw_queue *qdma_pq = qdma_vq->hw_queue; - struct dpaa2_dpdmai_dev *dpdmai_dev = qdma_pq->dpdmai_dev; - struct rte_qdma_job *job = NULL; struct qdma_virt_queue *temp_qdma_vq; - int dequeue_budget = QDMA_DEQUEUE_BUDGET; - int ring_count, ret, i; - uint16_t temp_vq_id; - - DPAA2_QDMA_FUNC_TRACE(); + struct dpaa2_dpdmai_dev *dpdmai_dev = qdma_pq->dpdmai_dev; + int ring_count, ret = 0, i; /* Return error in case of wrong lcore_id */ if (rte_lcore_id() != (unsigned int)(qdma_vq->lcore_id)) { - DPAA2_QDMA_ERR("QDMA dequeue for vqid %d on wrong core", + DPAA2_QDMA_WARN("QDMA dequeue for vqid %d on wrong core", vq_id); - return NULL; + return -1; } /* Only dequeue when there are pending jobs on VQ */ if (qdma_vq->num_enqueues == qdma_vq->num_dequeues) - return NULL; + return 0; + + if (qdma_vq->num_enqueues < (qdma_vq->num_dequeues + nb_jobs)) + nb_jobs = (qdma_vq->num_enqueues - qdma_vq->num_dequeues); if (qdma_vq->exclusive_hw_queue) { /* In case of exclusive queue directly fetch from HW queue */ - ret = dpdmai_dev_dequeue(dpdmai_dev, qdma_pq->queue_id, - NULL, &job); + ret = dpdmai_dev_dequeue_multijob(dpdmai_dev, qdma_pq->queue_id, + NULL, job, nb_jobs); if (ret < 0) { DPAA2_QDMA_ERR( "Dequeue from DPDMAI device failed: %d", ret); - return NULL; + return ret; } + qdma_vq->num_dequeues += ret; } else { + uint16_t temp_vq_id[RTE_QDMA_BURST_NB_MAX]; /* * Get the QDMA completed jobs from the software ring. * In case they are not available on the ring poke the HW * to fetch completed jobs from corresponding HW queues */ ring_count = rte_ring_count(qdma_vq->status_ring); - if (ring_count == 0) { + if (ring_count < nb_jobs) { /* TODO - How to have right budget */ - for (i = 0; i < dequeue_budget; i++) { - ret = dpdmai_dev_dequeue(dpdmai_dev, - qdma_pq->queue_id, &temp_vq_id, &job); - if (ret == 0) - break; - temp_qdma_vq = &qdma_vqs[temp_vq_id]; + ret = dpdmai_dev_dequeue_multijob(dpdmai_dev, + qdma_pq->queue_id, + temp_vq_id, job, nb_jobs); + for (i = 0; i < ret; i++) { + temp_qdma_vq = &qdma_vqs[temp_vq_id[i]]; rte_ring_enqueue(temp_qdma_vq->status_ring, - (void *)(job)); + (void *)(job[i])); ring_count = rte_ring_count( qdma_vq->status_ring); - if (ring_count) - break; } } - /* Dequeue job from the software ring to provide to the user */ - rte_ring_dequeue(qdma_vq->status_ring, (void **)&job); - if (job) - qdma_vq->num_dequeues++; + if (ring_count) { + /* Dequeue job from the software ring + * to provide to the user + */ + ret = rte_ring_dequeue_bulk(qdma_vq->status_ring, + (void **)job, ring_count, NULL); + if (ret) + qdma_vq->num_dequeues += ret; + } } + return ret; +} + +struct rte_qdma_job * +rte_qdma_vq_dequeue(uint16_t vq_id) +{ + int ret; + struct rte_qdma_job *job = NULL; + + ret = rte_qdma_vq_dequeue_multi(vq_id, &job, 1); + if (ret < 0) + DPAA2_QDMA_DP_WARN("DPDMAI device dequeue failed: %d", ret); + return job; } diff --git a/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h b/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h index c9697b4d7..e1ccc19e8 100644 --- a/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h +++ b/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h @@ -12,6 +12,9 @@ * */ +/** Maximum qdma burst size */ +#define RTE_QDMA_BURST_NB_MAX 32 + /** Determines the mode of operation */ enum { /** @@ -225,7 +228,8 @@ rte_qdma_vq_enqueue(uint16_t vq_id, * Number of QDMA jobs requested for dequeue by the user. * * @returns - * Number of jobs actually dequeued. + * - >=0: Number of jobs successfully received + * - <0: Error code. */ int rte_qdma_vq_dequeue_multi(uint16_t vq_id,