From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0074.outbound.protection.outlook.com [104.47.1.74]) by dpdk.org (Postfix) with ESMTP id 139DF49E1 for ; Wed, 2 May 2018 19:10:36 +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; bh=ybrS1jtnSf79WskvX2kunTroto8hXpLuRpj4WU7Ljis=; b=SslDo6LcHQZnbtC1lp7ii4hkD/vxow5C4ZmUNpg2y8UKP2wl8WxwtxDiWK2WEhtoPXbWpkAFRnXbbG6X31ACgg4qecM3Y1QDD8uu7smMQfTTogfP+aKig904J05FBphZi/6ADEDYx2R2eXbMrPh3Kc8qBw3H8/7IxpRwLgvi0Dw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=nipun.gupta@nxp.com; Received: from b27504-OptiPlex-790.ap.freescale.net (14.142.187.166) by VI1PR0401MB2431.eurprd04.prod.outlook.com (2603:10a6:800:2a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.13; Wed, 2 May 2018 17:10:33 +0000 From: Nipun Gupta To: thomas@monjalon.net, hemant.agrawal@nxp.com, shreyansh.jain@nxp.com Cc: dev@dpdk.org, Nipun Gupta Date: Wed, 2 May 2018 22:39:31 +0530 Message-Id: <1525280972-27736-8-git-send-email-nipun.gupta@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525280972-27736-1-git-send-email-nipun.gupta@nxp.com> References: <1525168731-30912-1-git-send-email-nipun.gupta@nxp.com> <1525280972-27736-1-git-send-email-nipun.gupta@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: MAXPR0101CA0016.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:c::26) To VI1PR0401MB2431.eurprd04.prod.outlook.com (2603:10a6:800:2a::24) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0401MB2431; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB2431; 3:Z90/gDPzUnv4fyZWrePjUBcghWrOGokJLV5OqMpFLmLG4Jn5w4xmZuTg1Pe4eayMIPEkMfFSNWqouBupBtUgn/CagrXinACNFFXtq5nRanOiB2c8QYrb2GKtJUkx5+DkcTEoOZWWRZSl640sd6NLXXQwIZ0OnLDFAAfuGpL9BZrS9N5eb/2PjtnBcTdoQjnKZp/O9VISxWes5E73T3B1FKFVXbUheOFz4ctT/feNTJ/crQwGvwWs+Bu75M+5x+81; 25:rl61/Y5jGB3oY6y7YDIxNcb8zYEUBmzJtxVx3JU3x5OkM1aMHzcGhQWprkUUC1p3jA4zqahfkb+xz5cwWmt9jgMkBIs2G+VlUBATemUOu4dRrKeNRCAGBwfrxFbFVG4PVCFIU+LuM4kj2VB2FC+vPtkHjCnXB8ILk8qaZL+tvW0ys3vG+yK6FORVUjM/0zh5aE0T9wqPDq9ksbPHlrsmBLHzNwaGm+sBpmbU3Uud5Qej5nt2yJF+i7ymuYSYNSOd+BnxGctnZCUOFtK+Wd3mCX0PbT65butVAK/XZ6GbnaAETPAFtF8rLZHDkigybY1cW8zZmp/oPrkpRjUNIK0GyA==; 31:MlVSrIxRWdnUkZGuLqjvdcVzCXpoNuYyZWZHsIgnjkxYrj+A7byh6d8QjPAYgr7naDZTY7Xac0qysxGoEa079t2p0sxpraOYK2k9P4Cw6Ouy2K8oLEz2PzAomHHw6C5ZjZaTJPyq82GJ9CDtf5hC8LOEVJR6bAYa1Va33mzlK8gZ38fS2dd/3m/+WC+qoixn6RfEJTuApJZQBusLnhWhI1W6RnKcKRSfZmBT6ev0HZI= X-MS-TrafficTypeDiagnostic: VI1PR0401MB2431: X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB2431; 20:clv3wgI49bNxJdfOcZV0N9HWO8M/w9QAEyBOgwNrabC8JHmpmveaowQ6PIIEe1tmfXsW8A0bZ6ZE34/KD63lJqw89sEbaqab4AXbE7St+lZIea0orMavrju2KeJunygh2QLbY67Nv0JuanOZ8pVilLMgS9C4ty9nap215Sq6E5NnT8MJlZYs0sjnufS4q+LYDKdtK/DSvCHDLYOaaKtJMAWekoozKMXBz3IglfFRGhpH2jUtw3C3RYc0375BZm6J2InpaDRf9XpHrRyMxylfsSAl9TVN+AWukMAv3Wox+XUeKNGwuw31ezLVZB/OV0hr7W2uXAqxMepQzGe7DHi2gy1H/GCkDLTUlUe3/I2ZvK75+TTUkMHojSqdzLBKNPfJdm2X+NSo/2Xmk0psTF2kTpzy8L+YwW7YUijEx+ztQc/Uc44nLZdp3FcUbxN65321O83mWKQk7wlohSh55rBGdkMI7mh+LSUQbyvn3EqGFo3ysnIqI92LXAqNDzMPy/TZ; 4:JRESAa+iZ73+A33RsgTd4UbGobk3AtYLq6zAteOt71D3qmxI+gRFI/fhW2LZI24O7MuEUeiu+Ce5IWrKk1nTakcjzhVysPATlSGf/83XzbN/g+doOnYo11irCLPWDVRqLTDtPZV7BHuSdlp4fOOakT5R+4fevHHf3jUDniu4I/Hh+DFQQvmJhiIcIOMuPtP2Dli/BKgq59YuUM+d5yymam0GB3sHARMWzC2wTM7Vx3gdW5JiE2Nc4lXh/vdfCUFW8JJhgv7nAXmdJKojTtoCVX5GFbrhsnn5pvsl/YLo/mLiqTk/6DHTavErTyAXa/k2Y0GIYUBtnS8JOjcbVuTaptgD6TpBjeWM/8KI6rHssac= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(6055026)(6041310)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:VI1PR0401MB2431; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0401MB2431; X-Forefront-PRVS: 06607E485E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(39860400002)(366004)(39380400002)(376002)(346002)(396003)(189003)(199004)(106356001)(2616005)(305945005)(6636002)(16526019)(50466002)(7736002)(5660300001)(48376002)(6486002)(25786009)(478600001)(53936002)(105586002)(97736004)(551934003)(4326008)(59450400001)(44832011)(186003)(26005)(47776003)(8676002)(956004)(52116002)(81156014)(5009440100003)(51416003)(386003)(486006)(476003)(6512007)(2906002)(8936002)(3846002)(6506007)(68736007)(6116002)(66066001)(446003)(11346002)(76176011)(36756003)(16586007)(316002)(55236004)(86362001)(81166006)(50226002)(110426005)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0401MB2431; H:b27504-OptiPlex-790.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0401MB2431; 23:PKzXDOF+1P9sry6wcdKakUUtiK8aXHKVT/Q3MsR?= =?us-ascii?Q?Gl4hZj/Hb8SXKECE4kdI+HnGgmXAWRWFCg7jkl4/P109vo3Hojwo+Uk1M0T0?= =?us-ascii?Q?CQpFg0/mGCOHImOlyYOU2+75WQx/Bsng5ECAhsxyt+6TVqZVIYfNO7UCkzyO?= =?us-ascii?Q?1V7D5nhZh4ibkU5R0xrhGm2lud9G8yvqHIc+pV2E4L34W0iztl/XgQBBUS97?= =?us-ascii?Q?Ig2dYhrFMERwU9MHzkaFtiqLkDFJ2GqefEW9RBNdO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:D+mc28+EGAuAsYiY61LNMhXqmE4MuYh4xYcPPc3SyrWyklg77R5AZ+lw+PeY7pnZrq1Xm7sLr1vrL3gOl8G0nlfl+wXbW4nI6ZJa8THWvfLKV1rOakJrji+kHSkr/tvRBl3n9W9vz4C0mSXBxEvwXdoNWeM196Zug0+SjRnh4GM=; 24:vTwVQZxlgaJHqNDvqtKHJIcJpxpJfHEbAnvKcLAK6YuB5bs7tzwgnhvM36ImCEvT1N+8CY1AUsBeNgAXfGGwa3lLc8fXuLpzRNymyzFhNuA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB2431; 7:3AtYT/D5MVebnCMG5N6rCfl1hQfqAyibTd+z53bzhX17HRQHzhiwHb20Yg0YXBJgMza/tisQ2UKAWkv+McdPN58MaszS5H1un3SoLOmJ4GYSWAbZxJzqBhQncd5jpb8dvOyx/Cc2FO4S0iifKHp6YHAurHQ9RrbxN/7rGRHXG4PP3D7cWfy0NUl1a8XEKYCOGrqWuuvWeI8uWqTFbBAltHZvIpWC0XwombgLrzAxFK+uR2uex2FGS25HwY8037Zh X-MS-Office365-Filtering-Correlation-Id: 4e7831b3-2034-4ac1-054f-08d5b04f9e54 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 May 2018 17:10:33.5191 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e7831b3-2034-4ac1-054f-08d5b04f9e54 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2431 Subject: [dpdk-dev] [PATCH v6 7/8] raw/dpaa2_qdma: support enq and deq operations 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: , X-List-Received-Date: Wed, 02 May 2018 17:10:36 -0000 Signed-off-by: Nipun Gupta Acked-by: Shreyansh Jain --- drivers/raw/dpaa2_qdma/dpaa2_qdma.c | 333 +++++++++++++++++++++ drivers/raw/dpaa2_qdma/dpaa2_qdma.h | 21 ++ drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h | 70 +++++ .../raw/dpaa2_qdma/rte_pmd_dpaa2_qdma_version.map | 4 + 4 files changed, 428 insertions(+) diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c index b38a282..1d15c30 100644 --- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c +++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c @@ -344,6 +344,339 @@ return i; } +static void +dpaa2_qdma_populate_fle(struct qbman_fle *fle, + uint64_t src, uint64_t dest, + size_t len, uint32_t flags) +{ + struct qdma_sdd *sdd; + + DPAA2_QDMA_FUNC_TRACE(); + + sdd = (struct qdma_sdd *)((uint8_t *)(fle) + + (DPAA2_QDMA_MAX_FLE * sizeof(struct qbman_fle))); + + /* first frame list to source descriptor */ + DPAA2_SET_FLE_ADDR(fle, DPAA2_VADDR_TO_IOVA(sdd)); + DPAA2_SET_FLE_LEN(fle, (2 * (sizeof(struct qdma_sdd)))); + + /* source and destination descriptor */ + DPAA2_SET_SDD_RD_COHERENT(sdd); /* source descriptor CMD */ + sdd++; + DPAA2_SET_SDD_WR_COHERENT(sdd); /* dest descriptor CMD */ + + fle++; + /* source frame list to source buffer */ + if (flags & RTE_QDMA_JOB_SRC_PHY) { + DPAA2_SET_FLE_ADDR(fle, src); + DPAA2_SET_FLE_BMT(fle); + } else { + DPAA2_SET_FLE_ADDR(fle, DPAA2_VADDR_TO_IOVA(src)); + } + DPAA2_SET_FLE_LEN(fle, len); + + fle++; + /* destination frame list to destination buffer */ + if (flags & RTE_QDMA_JOB_DEST_PHY) { + DPAA2_SET_FLE_BMT(fle); + DPAA2_SET_FLE_ADDR(fle, dest); + } else { + DPAA2_SET_FLE_ADDR(fle, DPAA2_VADDR_TO_IOVA(dest)); + } + DPAA2_SET_FLE_LEN(fle, len); + + /* Final bit: 1, for last frame list */ + 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) +{ + struct qdma_io_meta *io_meta; + struct qbman_fd fd; + struct dpaa2_queue *txq; + struct qbman_fle *fle; + struct qbman_eq_desc eqdesc; + struct qbman_swp *swp; + int ret; + + DPAA2_QDMA_FUNC_TRACE(); + + if (unlikely(!DPAA2_PER_LCORE_DPIO)) { + ret = dpaa2_affine_qbman_swp(); + if (ret) { + DPAA2_QDMA_ERR("Failure in affining portal"); + return 0; + } + } + swp = DPAA2_PER_LCORE_PORTAL; + + txq = &(dpdmai_dev->tx_queue[txq_id]); + + /* Prepare enqueue descriptor */ + qbman_eq_desc_clear(&eqdesc); + qbman_eq_desc_set_fq(&eqdesc, txq->fqid); + 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); + + /* Populate FLE */ + memset(fle, 0, QDMA_FLE_POOL_SIZE); + dpaa2_qdma_populate_fle(fle, job->src, job->dest, job->len, job->flags); + + /* 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); + + DPAA2_QDMA_DP_DEBUG("Successfully transmitted a packet"); + + return ret; +} + +int __rte_experimental +rte_qdma_vq_enqueue_multi(uint16_t vq_id, + struct rte_qdma_job **job, + uint16_t nb_jobs) +{ + int i, ret; + + DPAA2_QDMA_FUNC_TRACE(); + + for (i = 0; i < nb_jobs; i++) { + ret = rte_qdma_vq_enqueue(vq_id, job[i]); + if (ret < 0) + break; + } + + return i; +} + +int __rte_experimental +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); + 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, + uint16_t rxq_id, + uint16_t *vq_id, + struct rte_qdma_job **job) +{ + struct qdma_io_meta *io_meta; + struct dpaa2_queue *rxq; + struct qbman_result *dq_storage; + struct qbman_pull_desc pulldesc; + const struct qbman_fd *fd; + struct qbman_swp *swp; + struct qbman_fle *fle; + uint32_t fqid; + uint8_t status; + int ret; + + DPAA2_QDMA_FUNC_TRACE(); + + if (unlikely(!DPAA2_PER_LCORE_DPIO)) { + ret = dpaa2_affine_qbman_swp(); + if (ret) { + DPAA2_QDMA_ERR("Failure in affining portal"); + return 0; + } + } + swp = DPAA2_PER_LCORE_PORTAL; + + rxq = &(dpdmai_dev->rx_queue[rxq_id]); + dq_storage = rxq->q_storage->dq_storage[0]; + fqid = rxq->fqid; + + /* Prepare dequeue descriptor */ + qbman_pull_desc_clear(&pulldesc); + 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); + + while (1) { + if (qbman_swp_pull(swp, &pulldesc)) { + DPAA2_QDMA_DP_WARN("VDQ command not issued. QBMAN busy"); + continue; + } + break; + } + + /* Check if 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; + } + + /* Get the FD */ + 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; + + *job = (struct rte_qdma_job *)(size_t)io_meta->cnxt; + (*job)->status = DPAA2_GET_FD_ERR(fd); + + /* Free FLE to the pool */ + rte_mempool_put(qdma_dev.fle_pool, io_meta); + + DPAA2_QDMA_DP_DEBUG("packet received"); + + return 1; +} + +int __rte_experimental +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(); + + /* 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", + vq_id); + return NULL; + } + + /* Only dequeue when there are pending jobs on VQ */ + if (qdma_vq->num_enqueues == qdma_vq->num_dequeues) + return NULL; + + 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); + if (ret < 0) { + DPAA2_QDMA_ERR( + "Dequeue from DPDMAI device failed: %d", ret); + return NULL; + } + } else { + /* + * 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) { + /* 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]; + rte_ring_enqueue(temp_qdma_vq->status_ring, + (void *)(job)); + 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++; + } + + return job; +} + void __rte_experimental rte_qdma_vq_stats(uint16_t vq_id, struct rte_qdma_vq_stats *vq_status) diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.h b/drivers/raw/dpaa2_qdma/dpaa2_qdma.h index fe1da41..c6a0578 100644 --- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.h +++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.h @@ -18,10 +18,31 @@ /** FLE pool cache size */ #define QDMA_FLE_CACHE_SIZE(_num) (_num/(RTE_MAX_LCORE * 2)) +/** Notification by FQD_CTX[fqid] */ +#define QDMA_SER_CTX (1 << 8) + +/** + * Source descriptor command read transaction type for RBP=0: + * coherent copy of cacheable memory + */ +#define DPAA2_SET_SDD_RD_COHERENT(sdd) ((sdd)->cmd = (0xb << 28)) +/** + * Destination descriptor command write transaction type for RBP=0: + * coherent copy of cacheable memory + */ +#define DPAA2_SET_SDD_WR_COHERENT(sdd) ((sdd)->cmd = (0x6 << 28)) + /** Maximum possible H/W Queues on each core */ #define MAX_HW_QUEUE_PER_CORE 64 /** + * In case of Virtual Queue mode, this specifies the number of + * dequeue the 'qdma_vq_dequeue/multi' API does from the H/W Queue + * in case there is no job present on the Virtual Queue ring. + */ +#define QDMA_DEQUEUE_BUDGET 64 + +/** * Represents a QDMA device. * A single QDMA device exists which is combination of multiple DPDMAI rawdev's. */ diff --git a/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h b/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h index 29a1e4b..17fffcb 100644 --- a/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h +++ b/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h @@ -175,6 +175,76 @@ struct rte_qdma_job { rte_qdma_vq_create(uint32_t lcore_id, uint32_t flags); /** + * Enqueue multiple jobs to a Virtual Queue. + * If the enqueue is successful, the H/W will perform DMA operations + * on the basis of the QDMA jobs provided. + * + * @param vq_id + * Virtual Queue ID. + * @param job + * List of QDMA Jobs containing relevant information related to DMA. + * @param nb_jobs + * Number of QDMA jobs provided by the user. + * + * @returns + * - >=0: Number of jobs successfully submitted + * - <0: Error code. + */ +int __rte_experimental +rte_qdma_vq_enqueue_multi(uint16_t vq_id, + struct rte_qdma_job **job, + uint16_t nb_jobs); + +/** + * Enqueue a single job to a Virtual Queue. + * If the enqueue is successful, the H/W will perform DMA operations + * on the basis of the QDMA job provided. + * + * @param vq_id + * Virtual Queue ID. + * @param job + * A QDMA Job containing relevant information related to DMA. + * + * @returns + * - >=0: Number of jobs successfully submitted + * - <0: Error code. + */ +int __rte_experimental +rte_qdma_vq_enqueue(uint16_t vq_id, + struct rte_qdma_job *job); + +/** + * Dequeue multiple completed jobs from a Virtual Queue. + * Provides the list of completed jobs capped by nb_jobs. + * + * @param vq_id + * Virtual Queue ID. + * @param job + * List of QDMA Jobs returned from the API. + * @param nb_jobs + * Number of QDMA jobs requested for dequeue by the user. + * + * @returns + * Number of jobs actually dequeued. + */ +int __rte_experimental +rte_qdma_vq_dequeue_multi(uint16_t vq_id, + struct rte_qdma_job **job, + uint16_t nb_jobs); + +/** + * Dequeue a single completed jobs from a Virtual Queue. + * + * @param vq_id + * Virtual Queue ID. + * + * @returns + * - A completed job or NULL if no job is there. + */ +struct rte_qdma_job * __rte_experimental +rte_qdma_vq_dequeue(uint16_t vq_id); + +/** * Get a Virtual Queue statistics. * * @param vq_id diff --git a/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma_version.map b/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma_version.map index 7335c35..fe42a22 100644 --- a/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma_version.map +++ b/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma_version.map @@ -10,6 +10,10 @@ EXPERIMENTAL { rte_qdma_stop; rte_qdma_vq_create; rte_qdma_vq_destroy; + rte_qdma_vq_dequeue; + rte_qdma_vq_dequeue_multi; + rte_qdma_vq_enqueue; + rte_qdma_vq_enqueue_multi; rte_qdma_vq_stats; local: *; -- 1.9.1