From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0074.outbound.protection.outlook.com [104.47.2.74]) by dpdk.org (Postfix) with ESMTP id B0F713572 for ; Tue, 24 Apr 2018 13:50:41 +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=DVwj4mdcg2Bj98lqc9+cFiiEtoN5yZ+KlnteOEP0oRc=; b=bxu+Ut+t8f77xEb5VmSwo90oRCcWgx+qGqsIQ9A7z4V6ktQsuspzZAIFRpbV5XUmADnFKBwGYJQquBiQPNeD3ONgJuK6W4+7437KKJONKJz818igRMa8KOeGzPYFjCiaLUa3EVD2H/1rkGnsZlgM2RUdXQxTDN7DzYdjNncmKdQ= 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 DB6PR0401MB2424.eurprd04.prod.outlook.com (2603:10a6:4:4a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.15; Tue, 24 Apr 2018 11:50:39 +0000 From: Nipun Gupta To: shreyansh.jain@nxp.com, thomas@monjalon.net, hemant.agrawal@nxp.com Cc: dev@dpdk.org, Nipun Gupta Date: Tue, 24 Apr 2018 17:19:48 +0530 Message-Id: <1524570589-20148-8-git-send-email-nipun.gupta@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524570589-20148-1-git-send-email-nipun.gupta@nxp.com> References: <1523114224-9852-1-git-send-email-nipun.gupta@nxp.com> <1524570589-20148-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: PN1PR01CA0085.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:1::25) To DB6PR0401MB2424.eurprd04.prod.outlook.com (2603:10a6:4:4a::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(2017052603328)(7153060)(7193020); SRVR:DB6PR0401MB2424; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0401MB2424; 3:IAel0C+JdIo1X8q0Ij75tYaD41uGK1BiIXv70hu8ye4LlxvvpModkdy/Be5FGLGIUdl25RjtgryB1IIIVn5pZB3qCDn8XD/2fXAvf4IMU9o4YXUlv1R6VujSHCRL7+07G3e9Lf2UHCfJcpLuEGlx/cMCdlzva/8aT5HKkgoW+hpHDvuUYXGD4swZypD+qmw8Vo+UHmacKBimCo3hlMmlnwH/5akZnq7x3EFdlxHRInDxD9uKnPDQyPj3/i8gbGMB; 25:2rWAXljQEpEXonOuPBK63ouRz+kRNdR2YFrdEb7g/cWmy+l66oCt73v4q2HxywAlh96Dq4WoBFPd1JgqwhgAnbQPFjVZRvTO9d3b3ClZkunZpbM0eI0oR5dRPC+0Mx74u9ayvELFNPu32QbL7gzHRNJU6xwi449JUSTfch3TPNNCQxc8/T4/Xi65su6waXyIYOr0dvsXNAe8WApzPw2fDK8LOlwEycNbliuMcfg+TKJKWT9ZBuzd3bUIQCahOM4CCHlL2mTdtUKWhaiHeyHqR5NW1n3FbJXVPuhAweqou6hufNcqmrj78c1212tzMAKIMdBNc1+K03j0oneSf13vVQ==; 31:7nd4Is5k1U9Eo1lcY4jIiQkM55k6ZMjusD7LmtOp3R06qxx+sL49PqjIHKCry2UBm307PU6uIsgpIpMoi97gehe2IqHh9lA/fvfhCvj+s0No9UeKKRssbWQJldZhyplO1v5tLsN7/xL6rHmkikUTkZLego4PIx33rIASEvCQkoJgW5xEgmU86pfLO8+PhNFkhji+gojiO4VzmFfQNBPv68gEB1hT9ARKrPMrsmjyIXo= X-MS-TrafficTypeDiagnostic: DB6PR0401MB2424: X-Microsoft-Exchange-Diagnostics: 1; DB6PR0401MB2424; 20:nYge1ea7XE2ljw8Ahn2AQjHg3In/wWPzF/lUncmR5UYLIXN2vGorAu5aoUucF+BTlKXJJoFmaxi4eVNf/u84yPubGhrCZ+dtM89osld81lcywN6IM/XTBMY21oPnSmUG26LjMC6/RUkAX9JoUGSVoF1YUCMEqC8qIpUrfUSl9RV9UXXK0jjZfbSvdZT4Byxcn2E04r4pTJUHjGIhexGt3qeM2CzCTWM7MoiKKD7A1lGBV8f/FZ/Q2/zyPwxgRMvPv83Np2P156GPfSKYKPkvRw+pwmgaQSAWidl8OAZZXGHiyMZ/uJrYhfMQktPAgT8YpoQLG/7JslSjl4ruOlCQQ7bnhhfxENZX/yal5JLLMHA8Me0Sw1IleMw885GpIxe2GCmUzJBL7sMHiHJjqJF1luuFsd5bZkZ0qSm5KlhrwjnTOk38TFdytpVZCMDOHvhjySxwsbaDV659i6WcDMfF9Uc3uM9Tdb3AnoDDV2qHKsKdDPTxM3WeVBnTrWJc9VNz; 4:gWzpli/DPURnECI8U/ZKCNtKOwscDYsMqEfffHHm0S3hM9DV/i6hBj/d0EvGhlV+Jo/ia1rDXyvYyPDXtcwTSiWIPOsYwX3SxJot/PTGd5y/EaDrim9JJHwsSTcyPOxYCBPdEtbu3eMXyPebmivAmlHWuESykvY8Ddp9b6jh4LbJPy7PDLiwFd8X4MtSfcMRcB4k1l3OjQ0WHO8kdMTRM3ilx1gUgNQNh69DN9tBvoCMDZv++6BZIIDnyWVj+gRS5UbQxMMUK+UkkNv+ZsTrpVW14Z7ykyzEoMN3+Ht42qwBzu4kq4KLi2pbCAR1I9Hdp3viD+mrGzh9hqZ3xpu50RVXlfwucWObTMOoTEGeiwM= 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)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231232)(944501410)(52105095)(6055026)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(6072148)(201708071742011); SRVR:DB6PR0401MB2424; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0401MB2424; X-Forefront-PRVS: 0652EA5565 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(346002)(39860400002)(396003)(39380400002)(366004)(199004)(189003)(3846002)(97736004)(316002)(486006)(305945005)(6486002)(6636002)(476003)(2616005)(956004)(4326008)(25786009)(5009440100003)(446003)(86362001)(6512007)(6666003)(11346002)(5660300001)(478600001)(44832011)(53936002)(52116002)(16526019)(76176011)(551934003)(68736007)(7736002)(47776003)(51416003)(6506007)(106356001)(66066001)(26005)(36756003)(386003)(59450400001)(50466002)(81166006)(8676002)(6116002)(105586002)(16586007)(48376002)(50226002)(81156014)(8936002)(2906002)(110426005); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0401MB2424; H:b27504-OptiPlex-790.ap.freescale.net; 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-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0401MB2424; 23:5dZSHasi7ajh3Cbzn/R9NVkTYQYWwHgvZar+UIr?= =?us-ascii?Q?VB/FqTdx2CQIcX8JZ8djoh9NcVhA5APIy2fI7bkojTvxTvRhOnLFgw9KbzZQ?= =?us-ascii?Q?ksQX3WaALE9LZfLWIRF09OanqTMKUKICjQ9k9lA7kRtENHIOAhFrQWqw3/D5?= =?us-ascii?Q?J0Qmll4G0F76kfrcGO3w4jKclo3BQ6vyrU6QUHHWsIbAFU4QxrBZKj7NyCWb?= =?us-ascii?Q?r0CDSZEaWvIwzyeHz2ZKNjEX5QQCVTNMSx3DJ5DnwbdI3wEHWptA3wL2PMCb?= =?us-ascii?Q?sbpGDazMAhVK9iKUOLqiQdg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eUlh3TThnlyJgZjoXNfpMdN4z+pQg3z/k/wlXSVOd32SLQMd7YXljJFjmPMB5ruJncEuJTivnZx/Wcx++OMShwZw779VkeO5MNuEGuw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0401MB2424; 7:I0TZfPYIPbxt3N/NxFM/Hl0k6QT4uolXwXfh05uKootDyv+9U4qZeUi3t93+jQNYM7JJxh3tAQSZGMNIZncq0l8tLvnCIkmjfq+Tf+WOlIgCg3qK2nKdH21ccMdegWhOWMC8yTRsJQkRORbGLHVFE/IkkX9+oiy/qwAjA/mE/yRaiP1iYMs2LLCAgu6beonHTvmHXGoLGEYenqNYXEoZs6Aordj+5sF+lOFP5NA4H9VQvgRD+Q3ZX+bER7h3F5Ke X-MS-Office365-Filtering-Correlation-Id: c809857b-e3cf-4524-b8c9-08d5a9d99a18 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2018 11:50:39.0164 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c809857b-e3cf-4524-b8c9-08d5a9d99a18 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2424 Subject: [dpdk-dev] [PATCH 7/8 v4] 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: Tue, 24 Apr 2018 11:50:42 -0000 Signed-off-by: Nipun Gupta --- 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