From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0087.outbound.protection.outlook.com [104.47.2.87]) by dpdk.org (Postfix) with ESMTP id 5F22B34EF for ; Thu, 3 May 2018 18:06:56 +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=GQoHA4fUGFVkhSCwBWewXKVlmqXh2Uyq0AE5hrJ8zrZaFbD77wfh+lhUyWoOhZJd0aEaTM0MD43Ln0x2yep77BADwbbBK0+Fwcm4+O9lOQH928eA8xzneG/Wkr0+XOU9P1PBgvtRXSVVTdsJF62s5UzxbiNIFgF3jyhDF7xVvr0= 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 HE1PR0401MB2427.eurprd04.prod.outlook.com (2603:10a6:3:25::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.715.23; Thu, 3 May 2018 16:06:53 +0000 From: Nipun Gupta To: thomas@monjalon.net, hemant.agrawal@nxp.com, shreyansh.jain@nxp.com Cc: dev@dpdk.org, Nipun Gupta Date: Thu, 3 May 2018 21:36:09 +0530 Message-Id: <1525363570-23542-8-git-send-email-nipun.gupta@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525363570-23542-1-git-send-email-nipun.gupta@nxp.com> References: <1525280972-27736-1-git-send-email-nipun.gupta@nxp.com> <1525363570-23542-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: MA1PR01CA0105.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::21) To HE1PR0401MB2427.eurprd04.prod.outlook.com (2603:10a6:3:25::24) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(5600026)(2017052603328)(7153060)(7193020); SRVR:HE1PR0401MB2427; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0401MB2427; 3:BhZF8yc83MhlfpQ457fh1buWI12MKUiVYkNrdrTIsE4dOPbZAstIqsLjcnL4mtlLNX1agqfJOBuKmv0Z17R1BQ4oATHdCK4SLJ0jfl0xR1RuD/8vJ02oSVKsE1zA54pMq1B7s1TCmmBgvYGLzmvbNZtz0Ehpa5/MTLvnIIaXXa33bK2QFFe0AiCLXFa82efVOG1giJf6V9LoAVqTAahLEGcFO6jCPrP8r7xVcPseLqthXxq6KN6qO1eYXn6rZJga; 25:Ge3iIfsf05vLRM9mjKGDZRpZhi3hiCY6oOu4VEuSaC3vJ5DssJgn8MiAaoVUiWfSjApVR3TuAGUR19nJfrNI+3rlrDExXG1ngAxrh92+qZTaHlEQXSo+8V9EzldcIlri1vbkXR2RzooRGa2VXTCSEzkTlGGWFiecYXm2Au9Posi+d4d6LVB2iTxjYJheptrEQiQ+XRJ5aDkA6KHaLu5+33aYc0THvynBcPUJcwry3iwM8N6e0QB9UuatzKEy4Wh46LDNa6SzQ6E7lV8Q298AHLITXgjN7oTEpg1WqKR7t+V86QX0hW9ewAtgNiAgyPMY5ftWZ4sLhu3pdJ0jI+PbRw==; 31:KTlthgY0ZWcgjut825j6RZ5nHl6iyZqF7vA6kJXn+1ec/5Y92RNyDA1Z8daSPo9dobypwmM32XDtmbcOQo/3VavjcSQSCH4bEUqNEeoIRWy9CMuFx+2Os22rk7mj39bvbCkumC2z76Avi2bPL0IcwtipApcli41tOk3sELTU+Nob6Y8CFELlMYzkAPb3MlBe5Lol9GC962MKRP9N8jOwmmbsS/4mmFy6QEyje0jUQqg= X-MS-TrafficTypeDiagnostic: HE1PR0401MB2427: X-Microsoft-Exchange-Diagnostics: 1; HE1PR0401MB2427; 20:qsAEafY5I/f35pqEP1sdR3khGJ8GBUddpL+cI61iiHEBFwQEi25Wc9SqzvlaFFRqGaGJCxM3SGMjnElvVrwRgJCISNQxGatM46J57MQqgTViCjxRQ+OHuB8lB5Ui7g6O8U8tbccHb26dyG54p3w38NXZaVWneTg8AQ1Z4H0AjSz1gvwRPquCuHx5YPpQjCK6ygJzYjbNzfprWWLDnisKCjYhIQupyX1Guo0oPMadB9QBR2pga9VZmjpdvqit3AYADZRdBuBp1/Xl1qnpfgdirZqxensruEL31/BiDy+gw8A3Z08zTwb3gkH0Dc2XXaG4se/PHR/ARAMOq/Wsn0OKttHxEu8bfxSgLgj5AMvj5M8U+1b90+3/sGXm6ThkEsG046PcFWb/MQQzahhR9IV6VLHSvTyzFpy9HYnqLKH46zDeTkpv6WlKj2HRTPrvW3F3yjRL3NICMp/kXEkw449pFcp0gusucZFjLh5w1G21Gf7VTFyQFJx+zyugb7BIThcl; 4:D093F+HFVFCMphkj+weXqnKB64C0JTC4x4Hie5UPIsar2cd1eha8t0eoLH+5NSy76WAbGrjokvTyaosr1isyC3Qc9saYwXRQWfejVPH4yd+Y7LizqTjRRVdWFywqWMUFZvEApRv8TrRcOSj3jqHdS3HZ9Bw4Z9qOmcuu4abiZ8aDyodgh4IhtnDH1siRKv94wZwGW7fSxtDsZYzpP0DjJNDktH3G0PnvAQ2gnmFKmgUL1fwppfhs6akSVxVGEAnMiZGwFuHmZ8Gy2JKvGLIuUWYYsynuD0XaaW5TSUEHsyjbFjPpdOkL4/cz357lkuB0ycMl3oWqXFJh1mDWl4xtvU5U1IIXa3g5BGemmWQE01g= 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)(93006095)(93001095)(10201501046)(3002001)(3231254)(944501410)(52105095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:HE1PR0401MB2427; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0401MB2427; X-Forefront-PRVS: 066153096A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(39380400002)(39860400002)(346002)(396003)(199004)(189003)(5660300001)(26005)(186003)(47776003)(16526019)(6506007)(386003)(51416003)(55236004)(52116002)(2906002)(50226002)(59450400001)(97736004)(486006)(105586002)(25786009)(44832011)(106356001)(76176011)(81156014)(86362001)(68736007)(36756003)(6636002)(6512007)(2616005)(11346002)(53936002)(956004)(50466002)(7736002)(81166006)(8676002)(16586007)(6116002)(478600001)(446003)(5009440100003)(48376002)(6666003)(316002)(476003)(3846002)(305945005)(4326008)(551934003)(66066001)(8936002)(6486002)(110426005)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0401MB2427; 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; HE1PR0401MB2427; 23:IbOa2f/H8qWFg9gfJe8b/OpBR07yQONXiJRX9T7?= =?us-ascii?Q?8KvqnW3egh2ZUpoTvCesZ4QSvsthc2zXxOrQIK9L0H0vs+LSx3DNaREhhQOH?= =?us-ascii?Q?/WmLluPZNPsT7doSMbuqFrklEI2PWVJnBFyIfV/8+olSbGZtWZcbWjGOdr8M?= =?us-ascii?Q?+NgaZ1RqjGk131MN+V3ssGpgr3y1udUB1a589wNS7KO1pSYKKqPM6W9tsFbn?= =?us-ascii?Q?jRPxhS8SJ2pwz/yWbisHRj/5y59MVlsW1cSqGXIXgGOGPVSvnFHOxKtkTdjf?= =?us-ascii?Q?c4I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2/T9V7x4WY55Qi1ZfDg219FKZppmJPTscaBTDIXvZhTMe2i5r/0IaiVJPyyzQg2XWb49qP0YMsXCpL04FMZ3huGnglEN4iVJ7X+U=; 24:x7FLSz+DNnWLmexaqReO19GvDj4AmVHGnKbk3xquZ8/zjlFSQ1kUiwf5xBPUBhKKxVJCZZg7X5B29Qs/2OTwMde81s1zbWFnj4LdniU1qZE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0401MB2427; 7:4S82W3lMhT8ub6Q6NKbILijtmBROP6QtxwGtATr6p7KkZdF4IE2dI6s081zv7kynSuEyyQ/meREcAPqFqUjRKFD7MQ0mtstMtVngFlGslLFFFpQ81rPOF+ThZg6GKH+RKuzXRovHs6nUlQ+NRE5fwx6u+kuTJDj0rDI7sq47uEaBXh6OWiIOaDpbhcz0yMDdBHIsKyxr57fu+nWaD4NwyNHLNh+WogmDm8dXAj0wEET56VcKInc/CzODkymC2Ttc X-MS-Office365-Filtering-Correlation-Id: 07805588-c38b-4de7-a6c3-08d5b10fe3fc X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2018 16:06:53.5560 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07805588-c38b-4de7-a6c3-08d5b10fe3fc X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0401MB2427 Subject: [dpdk-dev] [PATCH RESEND v7 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: Thu, 03 May 2018 16:06:56 -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