From patchwork Mon Jul 22 16:39:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 142628 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3BA0445683; Mon, 22 Jul 2024 18:41:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C6D640E2C; Mon, 22 Jul 2024 18:40:06 +0200 (CEST) Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012002.outbound.protection.outlook.com [52.101.66.2]) by mails.dpdk.org (Postfix) with ESMTP id 756CC40E20 for ; Mon, 22 Jul 2024 18:40:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=buBXmtk3Lys9d6a30jzdAwmdurxbZalq6gbUGl/jWQzEqo9uSbeZu83kRzRO+c7/nNgK32S8mRVi/EpjR9S15+RkVhZrTCjHjhP6cT3C79tLCf8vM6uC0j6p3DMjcd6mqP43t100efZtsrEXr54IDBJBoDmPfKLPno32NWpWl2hDWqedFHfY0UM2FoDG8IUwHBfPTkG8ltAJCrub8VF0KWIYyBsbqnCrVVy0PYVSbxwd2PcyckEpBKoZEQYy/udgl1NGWuhV6HIS7rNsI74tvkiFr1eFBYArA5jGSRsa2hxeAb2HJucCafe9O11dOXrSRJHC2/xswA0Fq6+BPD56Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LU9FT4mFj1QQZtQFAKBe2mKYbfNtZlunXwAQEAtHGHc=; b=KftQyfOOt1pLhJDvM37HkkgyQKVA2jWAuXEpE34bKR2uLGhkhrjy6fj2HYEMnOPVlHdziho8lDxrBitNMR5mJviTmXC/tezNDs6sAfrsSIrAE+u973E9rCacQCzS7baGgRj2dhpMUvMqx0j7105rkPKeijPHGH6hTqALoQO08yDX0QEP2ISHyZrWK2r2ExNcHpblxvXWN8NUVGaoYC648xEZDwPDOxR0p+8rqq/QdaSjfUJjTpeSIBVZjyVH+Pm3U130RsjHY+LOaKIIy3N0rTlg7o3UwBSj0XpJ1mjgRnhsgyFcSWrcr/VtVto73idaFpcVSc0wqDztZdrnQPww9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LU9FT4mFj1QQZtQFAKBe2mKYbfNtZlunXwAQEAtHGHc=; b=AU62uy8znzsZxqSiTJqArQUIaYaApkcAtH4a6Ri3zhp5xupOpO1MVdTvrh3m/ICX85TEUumLR0MrBKv3W4cWO0+NK/ePTHMWU5B/cB8KIpSvG8nXvR951bOhzf3jKiXf6o2CBNcfmamct/JNP9oYn/9lDSuONxCcbz+Eqy8I30k= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8SPR01MB0024.eurprd04.prod.outlook.com (2603:10a6:20b:3d0::24) by VI1PR04MB6798.eurprd04.prod.outlook.com (2603:10a6:803:131::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16; Mon, 22 Jul 2024 16:40:02 +0000 Received: from AS8SPR01MB0024.eurprd04.prod.outlook.com ([fe80::c634:479e:8f8a:a325]) by AS8SPR01MB0024.eurprd04.prod.outlook.com ([fe80::c634:479e:8f8a:a325%7]) with mapi id 15.20.7784.017; Mon, 22 Jul 2024 16:40:02 +0000 From: Gagandeep Singh To: dev@dpdk.org, Hemant Agrawal Cc: Jun Yang Subject: [v3 09/30] dma/dpaa2: add short FD support Date: Mon, 22 Jul 2024 22:09:09 +0530 Message-Id: <20240722163930.2171568-10-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240722163930.2171568-1-g.singh@nxp.com> References: <20240722115843.1830105-1-g.singh@nxp.com> <20240722163930.2171568-1-g.singh@nxp.com> X-ClientProxiedBy: SG3P274CA0014.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::26) To AS8SPR01MB0024.eurprd04.prod.outlook.com (2603:10a6:20b:3d0::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8SPR01MB0024:EE_|VI1PR04MB6798:EE_ X-MS-Office365-Filtering-Correlation-Id: 730288b2-6193-456d-cf43-08dcaa6ceeac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: Fd+xnHbFv4B1vpeSCE+2257XAOgUduFEPLe5ORAMTvd7aRno1FhYlCsDiAW79o+2i/3JETNUpKLxVgs1D+iQno0aI3Ut4PjzO3hDTySB1gJj4t/z1eUxIiCLUefh8s8lA8A7uI9wmyLYxzCy1TyxwEE8IjCeFDBJw+rz0kQh6/OSyAYKdio6vbj9f3BySXsx1o9oUQ7xlVBh1c3PR84YVySJvtVhri7up5qu3llmRZ8/8f90jGn6JhQEl2LsVu5hG+Df7b6cvlxt3GSGcGuChEDlrtIC4z0FTc0uNIf/melPrzoLHJzYBBjADh/9JzUE/AwjH9ddWUy7Ni4jY8HeVZ75ADlCjDY3KPSRtNcoTxTh+EzIa26yd4gZqdIBiZcx4+vcgcip30uQhGH3UNaKFJODXo0v+PqPxcpmlkCdZdhLW1c85P7JiMe1oq3ORy96ujLTOlWTDMExpLKtHtK4c12AfYvbvOzk2866scalsIWsK5Yfto1h+0WTNATtsyNQ6WFStoZWw10fAC1QmcmlAkUX2feeKCxa2MTdN2olIz9pq/kWkvvsun00YpoE+0+4lSKAe1cYuX6yJM7HMUg9kQn4H1r9XPsG1M3BW56y4xiu70j+UB4A9Eo52kgTEV0bM826x5l3sH1DbXJRPt4QS9Bqq9Tfyg/6PKy2OL1YydbA+ge7mxCSqCsX6DoLkNO/1EWu+ZQN2vFvJHJcVWnwOZqCoDsn+/ivGaAfxUu/k1NAdOMz4PeNf8fAMSs1w4XVTLQzuBUhAwKJ4TkhoeQmWTLWNpSgGulr9h898UJ4d6kowfPkQVCcbN9LhRdcKXVhsoXcQ7aamPyTaI7BDiXdj2KiaxS1P8fhCDaOZAMBNmFgwsL0HXEp0s3GRrX5uZnEGxeEX+7+W2se8q/AgBUJRPfskAWz8CPvTgVHxpFSKYJpFZX3t6O+MtFMBJN2eLfbTLyHAUr0PG0kN2lEUiPGpO7dqfyGwUWrPeGe8DzzfXC+XIIh3x1P7dLyhtiEk6XHuVQb+Mp/Ze0x7wS/vnRBax93FfmZ+eVV+niG0yAaOPHmb+OE3Cp4oOG0DCt1NLc+r5weP/+7roRZUYZsYeCrvnr2WPqJLcK9PpBKzwYbpKFHui8ILsF8Poi7D1LJGy5oQMpzfMPi9eOC7z3MhY6ppQd6TIDGZvQAEUinRzGulYezUskGTO+rZJ2BKMJ1NopENcPfYfyJ5FPEpYCUBVg0ETOwwRXww/Y/CrZ8VJ3/hkjN6+3mItFejG253CAe9ijovkq0mtRl8W2ANi8SuVv3whEEeHOJEIvMWn8wYD+fnpo0WZq0G0nqaJZW6bVV+rJ+GuoyuhnozDX/kSnYLsSAk6HyVyPRcKmk0Y+V6d0RrF0LBoddssA/CZ6ZgYSHHf+ncKMA5yBMgKtMN0oObeNOkA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8SPR01MB0024.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(52116014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kaLew6SMrxlaXXlXE8jFOfDHY15ZnCXFzk2BJzU4CPyQ7ebDBHxqPAVSAhUWn3j6GWQtIDLM9KlWXRu1fcntbaM7X/u7nKacXkxk9Q32FAaOXZ+u4IUngyMsw/uW6Qj5zTAXPDk4oMXeUvmLnGs1YLycR30O8czF3uX4tR7zL2qQZTa+fS5E0N1jh2NqTWRIGrkIRIwTutKumpdHSwPWqZvRIHg/EWz1LwZRSRHR1ps5mTEoMz35yiDPQN2ypsFKZQUYwEignaGIcN2ngVxH6ljYVdpJXitLCVCipWcq9BIZIMl8XRbDSTJlqSBwiZ3aozuvQs9weSuNIZmcKKcMpsijRXuHA5m2SxTwbR+4QrYm1wvtqZ/Uvq8LKzw21NNKt+2OURuIuTFkEBGbxjXvg9+O2BdMolMAFIxjhMUozjwUu6AgW2xBapDb3+CnIpAqwK/TtiEDeDh5ofxf4YgeQ67y9hx7+bj9hlTiQ11WYTHmgct55z1+hNsyWmV2EPrs8PlBAYuFhPBKNMKJgbd78KeaaK6JB2V8gCeox80va8dRN2kbszesazbEdXfa+4CbADLXIWv+Yil7bRa4Mk5Q/qTsfkwd6SeDqAEIZqrepcNZD8mory+2AphGGR3a0rs6Jjm9WA6bA7e/FiYc3YNLveMYYrEBkdflrg0XhBX9qj55XIrMcVXC25SHAVylTnPAIKt2YwdwJzwQTRs9H7KFZlAQBlgJrqtp1W6BvdFIX3uGxAhB0W+Lp8Yi3Z9NhkfJHY0gDEJWAYoCJb3Dmb3c+iv35q6oHe0ORGhQU2pAGBiGZtwQLIOjjSJYNkfzid66cl0w8wzSo+eFUEHzIHwrk7uPEKvPLudV9QpZ/bs06r/TpmGfMAw88PCIexVz/vHtixCXkOMKXULthsoxTJsBtbC5DqpW/iG/VVnL7ecCjvjBLSRMat1ps+G0XPSr8bGUneIB4g8dHtjpocJ6qAc+Iz9BQ6vpV96TMIcd/EZ8gvRQQwq7VUdeRz5rDbc0VWGoLbfqyxE7EbeIMZGLK0AKnWMPGLAvY1j+JphKKgVprqVYgVW9fmKTC0FB13mA6lLX86vMgeRYvVAwTMhN3cptZUZjSVDg4RyzVtDb5pABFR73AEV4Zgl3JdSEthDeNaZFX6i3GSP9qSv93WbtYiT20+/9taLwrXt3C2Dkeny8bDoPS/hcRlTT1W4RpMgPH7sv87JZs3tz4IUDmGZ2wSw0aWEvMeoyeIMI2LJdBf+JsSLtZzHs6/Qqg9dGmRNor/8+/dFQmtdnoVkJWhMFwy0G+MdrZlCOUNrm1NnFOBXyA5DajbYseKf9x7pqGybM9qpScCGHI8vsslxlVfB7zo0N3qUuW8aTiudlgXF/O97nB+qsdYmYPTB5qvQ/cb1zwZzk5uytjfkLVeQs60KtM/Yv5KvNc+XtxpQc5GVyLTFZa61n5/JuWSRaavZQKOXK7/UTDZqtkXdkUdXzLNOzyAontkWbg7f3EMO73CLB5fSaAQSgxPDxHId1JcIHdlgqMfJPSvwAJ8zyho6uw5utM4KdTVMOncESieK1wQf4V5kIFJkL+dFSS2sWI2TvUj9p5Axs X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 730288b2-6193-456d-cf43-08dcaa6ceeac X-MS-Exchange-CrossTenant-AuthSource: AS8SPR01MB0024.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2024 16:40:01.9809 (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-CrossTenant-UserPrincipalName: imkt3L+RRZrSG5oO8y6t8KNEpgZr/g5XPaHoIy18xMGW0W/5IQJzUwey01XOYSF6 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6798 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Jun Yang Short FD can be used for single transfer scenario which shows higher performance than FLE. 1) Save index context in FD att field for short and FLE(NonSG). 2) Identify FD type by att of FD. 3) Force 48 bits address for source address and fle according to spec. Signed-off-by: Jun Yang --- drivers/dma/dpaa2/dpaa2_qdma.c | 314 +++++++++++++++++++------ drivers/dma/dpaa2/dpaa2_qdma.h | 69 ++++-- drivers/dma/dpaa2/rte_pmd_dpaa2_qdma.h | 13 - 3 files changed, 285 insertions(+), 111 deletions(-) diff --git a/drivers/dma/dpaa2/dpaa2_qdma.c b/drivers/dma/dpaa2/dpaa2_qdma.c index 53caccecd7..d1358b686c 100644 --- a/drivers/dma/dpaa2/dpaa2_qdma.c +++ b/drivers/dma/dpaa2/dpaa2_qdma.c @@ -522,7 +522,6 @@ dpaa2_qdma_long_fmt_dump(const struct qbman_fle *fle) const struct qdma_cntx_fle_sdd *fle_sdd; const struct qdma_sdd *sdd; const struct qdma_cntx_sg *cntx_sg = NULL; - const struct qdma_cntx_long *cntx_long = NULL; fle_sdd = container_of(fle, const struct qdma_cntx_fle_sdd, fle[0]); sdd = fle_sdd->sdd; @@ -545,11 +544,8 @@ dpaa2_qdma_long_fmt_dump(const struct qbman_fle *fle) QBMAN_FLE_WORD4_FMT_SGE) { cntx_sg = container_of(fle_sdd, const struct qdma_cntx_sg, fle_sdd); - } else if (fle[DPAA2_QDMA_SRC_FLE].word4.fmt == + } else if (fle[DPAA2_QDMA_SRC_FLE].word4.fmt != QBMAN_FLE_WORD4_FMT_SBF) { - cntx_long = container_of(fle_sdd, const struct qdma_cntx_long, - fle_sdd); - } else { DPAA2_QDMA_ERR("Unsupported fle format:%d", fle[DPAA2_QDMA_SRC_FLE].word4.fmt); return; @@ -560,11 +556,6 @@ dpaa2_qdma_long_fmt_dump(const struct qbman_fle *fle) dpaa2_qdma_sdd_dump(&sdd[i]); } - if (cntx_long) { - DPAA2_QDMA_INFO("long format/Single buffer cntx idx:%d", - cntx_long->cntx_idx); - } - if (cntx_sg) { DPAA2_QDMA_INFO("long format/SG format, job number:%d", cntx_sg->job_nb); @@ -582,6 +573,8 @@ dpaa2_qdma_long_fmt_dump(const struct qbman_fle *fle) DPAA2_QDMA_INFO("cntx_idx[%d]:%d", i, cntx_sg->cntx_idx[i]); } + } else { + DPAA2_QDMA_INFO("long format/Single buffer cntx"); } } @@ -644,7 +637,7 @@ dpaa2_qdma_copy_sg(void *dev_private, offsetof(struct qdma_cntx_sg, fle_sdd) + offsetof(struct qdma_cntx_fle_sdd, fle); - DPAA2_SET_FD_ADDR(fd, fle_iova); + dpaa2_qdma_fd_set_addr(fd, fle_iova); DPAA2_SET_FD_COMPOUND_FMT(fd); DPAA2_SET_FD_FLC(fd, (uint64_t)cntx_sg); @@ -680,6 +673,7 @@ dpaa2_qdma_copy_sg(void *dev_private, if (unlikely(qdma_vq->flags & DPAA2_QDMA_DESC_DEBUG_FLAG)) dpaa2_qdma_long_fmt_dump(cntx_sg->fle_sdd.fle); + dpaa2_qdma_fd_save_att(fd, 0, DPAA2_QDMA_FD_SG); qdma_vq->fd_idx++; qdma_vq->silent_idx = (qdma_vq->silent_idx + 1) & (DPAA2_QDMA_MAX_DESC - 1); @@ -696,74 +690,178 @@ dpaa2_qdma_copy_sg(void *dev_private, return ret; } +static inline void +qdma_populate_fd_pci(uint64_t src, uint64_t dest, + uint32_t len, struct qbman_fd *fd, + struct dpaa2_qdma_rbp *rbp, int ser) +{ + fd->simple_pci.saddr_lo = lower_32_bits(src); + fd->simple_pci.saddr_hi = upper_32_bits(src); + + fd->simple_pci.len_sl = len; + + fd->simple_pci.bmt = DPAA2_QDMA_BMT_DISABLE; + fd->simple_pci.fmt = DPAA2_QDMA_FD_SHORT_FORMAT; + fd->simple_pci.sl = 1; + fd->simple_pci.ser = ser; + if (ser) + fd->simple.frc |= QDMA_SER_CTX; + + fd->simple_pci.sportid = rbp->sportid; + + fd->simple_pci.svfid = rbp->svfid; + fd->simple_pci.spfid = rbp->spfid; + fd->simple_pci.svfa = rbp->svfa; + fd->simple_pci.dvfid = rbp->dvfid; + fd->simple_pci.dpfid = rbp->dpfid; + fd->simple_pci.dvfa = rbp->dvfa; + + fd->simple_pci.srbp = rbp->srbp; + if (rbp->srbp) + fd->simple_pci.rdttype = 0; + else + fd->simple_pci.rdttype = dpaa2_coherent_alloc_cache; + + /*dest is pcie memory */ + fd->simple_pci.dportid = rbp->dportid; + fd->simple_pci.drbp = rbp->drbp; + if (rbp->drbp) + fd->simple_pci.wrttype = 0; + else + fd->simple_pci.wrttype = dpaa2_coherent_no_alloc_cache; + + fd->simple_pci.daddr_lo = lower_32_bits(dest); + fd->simple_pci.daddr_hi = upper_32_bits(dest); +} + +static inline void +qdma_populate_fd_ddr(uint64_t src, uint64_t dest, + uint32_t len, struct qbman_fd *fd, int ser) +{ + fd->simple_ddr.saddr_lo = lower_32_bits(src); + fd->simple_ddr.saddr_hi = upper_32_bits(src); + + fd->simple_ddr.len = len; + + fd->simple_ddr.bmt = DPAA2_QDMA_BMT_DISABLE; + fd->simple_ddr.fmt = DPAA2_QDMA_FD_SHORT_FORMAT; + fd->simple_ddr.sl = 1; + fd->simple_ddr.ser = ser; + if (ser) + fd->simple.frc |= QDMA_SER_CTX; + /** + * src If RBP=0 {NS,RDTTYPE[3:0]}: 0_1011 + * Coherent copy of cacheable memory, + * lookup in downstream cache, no allocate + * on miss. + */ + fd->simple_ddr.rns = 0; + fd->simple_ddr.rdttype = dpaa2_coherent_alloc_cache; + /** + * dest If RBP=0 {NS,WRTTYPE[3:0]}: 0_0111 + * Coherent write of cacheable memory, + * lookup in downstream cache, no allocate on miss + */ + fd->simple_ddr.wns = 0; + fd->simple_ddr.wrttype = dpaa2_coherent_no_alloc_cache; + + fd->simple_ddr.daddr_lo = lower_32_bits(dest); + fd->simple_ddr.daddr_hi = upper_32_bits(dest); +} + static int -dpaa2_qdma_copy(void *dev_private, uint16_t vchan, - rte_iova_t src, rte_iova_t dst, - uint32_t length, uint64_t flags) +dpaa2_qdma_short_copy(struct qdma_virt_queue *qdma_vq, + rte_iova_t src, rte_iova_t dst, uint32_t length, + int is_silent, uint64_t flags) { - struct dpaa2_dpdmai_dev *dpdmai_dev = dev_private; - struct qdma_device *qdma_dev = dpdmai_dev->qdma_dev; - struct qdma_virt_queue *qdma_vq = &qdma_dev->vqs[vchan]; int ret = 0, expected; struct qbman_fd *fd = &qdma_vq->fd[qdma_vq->fd_idx]; - struct qdma_cntx_long *cntx_long = NULL; - rte_iova_t cntx_iova, fle_iova, sdd_iova; + + memset(fd, 0, sizeof(struct qbman_fd)); + + if (qdma_vq->rbp.drbp || qdma_vq->rbp.srbp) { + /** PCIe EP*/ + qdma_populate_fd_pci(src, + dst, length, + fd, &qdma_vq->rbp, + is_silent ? 0 : 1); + } else { + /** DDR or PCIe RC*/ + qdma_populate_fd_ddr(src, + dst, length, + fd, is_silent ? 0 : 1); + } + dpaa2_qdma_fd_save_att(fd, DPAA2_QDMA_IDX_FROM_FLAG(flags), + DPAA2_QDMA_FD_SHORT); + qdma_vq->fd_idx++; + + if (flags & RTE_DMA_OP_FLAG_SUBMIT) { + expected = qdma_vq->fd_idx; + ret = dpaa2_qdma_multi_eq(qdma_vq); + if (likely(ret == expected)) { + qdma_vq->copy_num++; + return (qdma_vq->copy_num - 1) & UINT16_MAX; + } + } else { + qdma_vq->copy_num++; + return (qdma_vq->copy_num - 1) & UINT16_MAX; + } + + return ret; +} + +static int +dpaa2_qdma_long_copy(struct qdma_virt_queue *qdma_vq, + rte_iova_t src, rte_iova_t dst, uint32_t length, + int is_silent, uint64_t flags) +{ + int ret = 0, expected; + struct qbman_fd *fd = &qdma_vq->fd[qdma_vq->fd_idx]; + struct qdma_cntx_fle_sdd *fle_sdd = NULL; + rte_iova_t fle_iova, sdd_iova; struct qbman_fle *fle; struct qdma_sdd *sdd; memset(fd, 0, sizeof(struct qbman_fd)); - if (qdma_dev->is_silent) { - cntx_long = qdma_vq->cntx_long[qdma_vq->silent_idx]; + if (is_silent) { + fle_sdd = qdma_vq->cntx_fle_sdd[qdma_vq->silent_idx]; } else { ret = rte_mempool_get(qdma_vq->fle_pool, - (void **)&cntx_long); + (void **)&fle_sdd); if (ret) return ret; DPAA2_SET_FD_FRC(fd, QDMA_SER_CTX); - cntx_long->cntx_idx = DPAA2_QDMA_IDX_FROM_FLAG(flags); } -#ifdef RTE_LIBRTE_DPAA2_USE_PHYS_IOVA - cntx_iova = rte_mempool_virt2iova(cntx_long); -#else - cntx_iova = DPAA2_VADDR_TO_IOVA(cntx_long); -#endif - - fle = cntx_long->fle_sdd.fle; - fle_iova = cntx_iova + - offsetof(struct qdma_cntx_long, fle_sdd) + - offsetof(struct qdma_cntx_fle_sdd, fle); + fle = fle_sdd->fle; + fle_iova = (uint64_t)fle - qdma_vq->fle_iova2va_offset; - DPAA2_SET_FD_ADDR(fd, fle_iova); + dpaa2_qdma_fd_set_addr(fd, fle_iova); DPAA2_SET_FD_COMPOUND_FMT(fd); - DPAA2_SET_FD_FLC(fd, (uint64_t)cntx_long); + DPAA2_SET_FD_FLC(fd, (uint64_t)fle); if (qdma_vq->fle_pre_populate) { if (unlikely(!fle[DPAA2_QDMA_SRC_FLE].length)) { - fle_sdd_pre_populate(&cntx_long->fle_sdd, + fle_sdd_pre_populate(fle_sdd, &qdma_vq->rbp, 0, 0, QBMAN_FLE_WORD4_FMT_SBF); - if (!qdma_dev->is_silent && cntx_long) { - cntx_long->cntx_idx = - DPAA2_QDMA_IDX_FROM_FLAG(flags); - } } fle_post_populate(fle, src, dst, length); } else { - sdd = cntx_long->fle_sdd.sdd; - sdd_iova = cntx_iova + - offsetof(struct qdma_cntx_long, fle_sdd) + - offsetof(struct qdma_cntx_fle_sdd, sdd); + sdd = fle_sdd->sdd; + sdd_iova = (uint64_t)sdd - qdma_vq->fle_iova2va_offset; fle_populate(fle, sdd, sdd_iova, &qdma_vq->rbp, src, dst, length, QBMAN_FLE_WORD4_FMT_SBF); } if (unlikely(qdma_vq->flags & DPAA2_QDMA_DESC_DEBUG_FLAG)) - dpaa2_qdma_long_fmt_dump(cntx_long->fle_sdd.fle); + dpaa2_qdma_long_fmt_dump(fle); + dpaa2_qdma_fd_save_att(fd, DPAA2_QDMA_IDX_FROM_FLAG(flags), + DPAA2_QDMA_FD_LONG); qdma_vq->fd_idx++; qdma_vq->silent_idx = (qdma_vq->silent_idx + 1) & (DPAA2_QDMA_MAX_DESC - 1); @@ -771,15 +869,89 @@ dpaa2_qdma_copy(void *dev_private, uint16_t vchan, if (flags & RTE_DMA_OP_FLAG_SUBMIT) { expected = qdma_vq->fd_idx; ret = dpaa2_qdma_multi_eq(qdma_vq); - if (likely(ret == expected)) - return 0; + if (likely(ret == expected)) { + qdma_vq->copy_num++; + return (qdma_vq->copy_num - 1) & UINT16_MAX; + } } else { - return 0; + qdma_vq->copy_num++; + return (qdma_vq->copy_num - 1) & UINT16_MAX; } return ret; } +static int +dpaa2_qdma_copy(void *dev_private, uint16_t vchan, + rte_iova_t src, rte_iova_t dst, + uint32_t length, uint64_t flags) +{ + struct dpaa2_dpdmai_dev *dpdmai_dev = dev_private; + struct qdma_device *qdma_dev = dpdmai_dev->qdma_dev; + struct qdma_virt_queue *qdma_vq = &qdma_dev->vqs[vchan]; + + if (qdma_vq->using_short_fd) + return dpaa2_qdma_short_copy(qdma_vq, src, dst, + length, qdma_dev->is_silent, flags); + else + return dpaa2_qdma_long_copy(qdma_vq, src, dst, + length, qdma_dev->is_silent, flags); +} + +static inline int +dpaa2_qdma_dq_fd(const struct qbman_fd *fd, + struct qdma_virt_queue *qdma_vq, + uint16_t *free_space, uint16_t *fle_elem_nb) +{ + uint16_t idx, att; + enum dpaa2_qdma_fd_type type; + int ret; + struct qdma_cntx_sg *cntx_sg; + struct qdma_cntx_fle_sdd *fle_sdd; + + att = dpaa2_qdma_fd_get_att(fd); + type = DPAA2_QDMA_FD_ATT_TYPE(att); + if (type == DPAA2_QDMA_FD_SHORT) { + idx = DPAA2_QDMA_FD_ATT_CNTX(att); + ret = qdma_cntx_idx_ring_eq(qdma_vq->ring_cntx_idx, + &idx, 1, free_space); + if (unlikely(ret != 1)) + return -ENOSPC; + + return 0; + } + if (type == DPAA2_QDMA_FD_LONG) { + idx = DPAA2_QDMA_FD_ATT_CNTX(att); + fle_sdd = (void *)(uintptr_t)DPAA2_GET_FD_FLC(fd); + qdma_vq->fle_elem[*fle_elem_nb] = fle_sdd; + (*fle_elem_nb)++; + ret = qdma_cntx_idx_ring_eq(qdma_vq->ring_cntx_idx, + &idx, 1, free_space); + if (unlikely(ret != 1)) + return -ENOSPC; + + return 0; + } + if (type == DPAA2_QDMA_FD_SG) { + fle_sdd = (void *)(uintptr_t)DPAA2_GET_FD_FLC(fd); + qdma_vq->fle_elem[*fle_elem_nb] = fle_sdd; + (*fle_elem_nb)++; + cntx_sg = container_of(fle_sdd, + struct qdma_cntx_sg, fle_sdd); + ret = qdma_cntx_idx_ring_eq(qdma_vq->ring_cntx_idx, + cntx_sg->cntx_idx, + cntx_sg->job_nb, free_space); + if (unlikely(ret < cntx_sg->job_nb)) + return -ENOSPC; + + return 0; + } + + DPAA2_QDMA_ERR("Invalid FD type, ATT=0x%04x", + fd->simple_ddr.rsv1_att); + return -EIO; +} + static uint16_t dpaa2_qdma_dequeue(void *dev_private, uint16_t vchan, const uint16_t nb_cpls, @@ -799,10 +971,6 @@ dpaa2_qdma_dequeue(void *dev_private, uint8_t num_rx = 0; const struct qbman_fd *fd; int ret, pull_size; - struct qbman_fle *fle; - struct qdma_cntx_fle_sdd *fle_sdd; - struct qdma_cntx_sg *cntx_sg; - struct qdma_cntx_long *cntx_long; uint16_t free_space = 0, fle_elem_nb = 0; if (unlikely(qdma_dev->is_silent)) @@ -901,25 +1069,8 @@ dpaa2_qdma_dequeue(void *dev_private, continue; } fd = qbman_result_DQ_fd(dq_storage); - fle_sdd = (void *)(uintptr_t)DPAA2_GET_FD_FLC(fd); - fle = fle_sdd->fle; - qdma_vq->fle_elem[fle_elem_nb] = fle_sdd; - fle_elem_nb++; - if (fle[DPAA2_QDMA_SRC_FLE].word4.fmt == - QBMAN_FLE_WORD4_FMT_SGE) { - cntx_sg = container_of(fle_sdd, - struct qdma_cntx_sg, fle_sdd); - ret = qdma_cntx_idx_ring_eq(qdma_vq->ring_cntx_idx, - cntx_sg->cntx_idx, - cntx_sg->job_nb, &free_space); - } else { - cntx_long = container_of(fle_sdd, - struct qdma_cntx_long, fle_sdd); - ret = qdma_cntx_idx_ring_eq(qdma_vq->ring_cntx_idx, - &cntx_long->cntx_idx, - 1, &free_space); - } - if (!ret || free_space < RTE_DPAA2_QDMA_JOB_SUBMIT_MAX) + ret = dpaa2_qdma_dq_fd(fd, qdma_vq, &free_space, &fle_elem_nb); + if (ret || free_space < RTE_DPAA2_QDMA_JOB_SUBMIT_MAX) pending = 0; dq_storage++; @@ -944,8 +1095,10 @@ dpaa2_qdma_dequeue(void *dev_private, q_storage->active_dpio_id = DPAA2_PER_LCORE_DPIO->index; set_swp_active_dqs(DPAA2_PER_LCORE_DPIO->index, dq_storage1); - rte_mempool_put_bulk(qdma_vq->fle_pool, - qdma_vq->fle_elem, fle_elem_nb); + if (fle_elem_nb > 0) { + rte_mempool_put_bulk(qdma_vq->fle_pool, + qdma_vq->fle_elem, fle_elem_nb); + } num_rx = qdma_cntx_idx_ring_dq(qdma_vq->ring_cntx_idx, cntx_idx, nb_cpls); @@ -1178,11 +1331,18 @@ dpaa2_qdma_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan, else qdma_dev->vqs[vchan].flags &= (~DPAA2_QDMA_DESC_DEBUG_FLAG); + /** Default Enable Short FD for nonSG format. + * Short FD has higher perf than FLE. + */ + env = getenv("DPAA2_QDMA_USING_SHORT_FD"); + if (env) + qdma_dev->vqs[vchan].using_short_fd = atoi(env); + else + qdma_dev->vqs[vchan].using_short_fd = 1; + snprintf(pool_name, sizeof(pool_name), "qdma_fle_pool_dev%d_qid%d", dpdmai_dev->dpdmai_id, vchan); - pool_size = RTE_MAX(sizeof(struct qdma_cntx_sg), - sizeof(struct qdma_cntx_long)); - + pool_size = sizeof(struct qdma_cntx_sg); qdma_dev->vqs[vchan].fle_pool = rte_mempool_create(pool_name, DPAA2_QDMA_MAX_DESC * 2, pool_size, 512, 0, NULL, NULL, NULL, NULL, @@ -1202,7 +1362,7 @@ dpaa2_qdma_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan, return ret; } ret = rte_mempool_get_bulk(qdma_dev->vqs[vchan].fle_pool, - (void **)qdma_dev->vqs[vchan].cntx_long, + (void **)qdma_dev->vqs[vchan].cntx_fle_sdd, DPAA2_QDMA_MAX_DESC); if (ret) { DPAA2_QDMA_ERR("long cntx get from %s for silent mode", diff --git a/drivers/dma/dpaa2/dpaa2_qdma.h b/drivers/dma/dpaa2/dpaa2_qdma.h index 371393cb85..0be65e1cc6 100644 --- a/drivers/dma/dpaa2/dpaa2_qdma.h +++ b/drivers/dma/dpaa2/dpaa2_qdma.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2018-2023 NXP + * Copyright 2018-2024 NXP */ #ifndef _DPAA2_QDMA_H_ @@ -12,17 +12,8 @@ #define DPAA2_QDMA_MIN_DESC 1 #define DPAA2_QDMA_MAX_VHANS 64 -#define DPAA2_QDMA_VQ_FD_SHORT_FORMAT (1ULL << 0) -#define DPAA2_QDMA_VQ_FD_SG_FORMAT (1ULL << 1) -#define DPAA2_QDMA_VQ_NO_RESPONSE (1ULL << 2) - #define DPAA2_DPDMAI_MAX_QUEUES 16 -#define QDMA_JOB_HW_CNTX_IDX (RTE_DPAA2_QDMA_JOB_USR_CNTX_IDX + 1) - -/** 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) #define DPAA2_RBP_MEM_RW 0x0 @@ -40,9 +31,14 @@ #define DPAA2_LX2_COHERENT_ALLOCATE_CACHE 0xb /** Maximum possible H/W Queues on each core */ -#define MAX_HW_QUEUE_PER_CORE 64 +#define MAX_HW_QUEUE_PER_CORE 64 + +#define DPAA2_QDMA_FD_FLUSH_FORMAT 0x0 +#define DPAA2_QDMA_FD_LONG_FORMAT 0x1 +#define DPAA2_QDMA_FD_SHORT_FORMAT 0x3 -#define QDMA_RBP_UPPER_ADDRESS_MASK (0xfff0000000000) +#define DPAA2_QDMA_BMT_ENABLE 0x1 +#define DPAA2_QDMA_BMT_DISABLE 0x0 /** Source/Destination Descriptor */ struct qdma_sdd { @@ -99,8 +95,8 @@ struct qdma_sdd { #define QDMA_SG_SL_SHORT 0x1 /* short length */ #define QDMA_SG_SL_LONG 0x0 /* long length */ #define QDMA_SG_F 0x1 /* last sg entry */ -#define QDMA_SG_BMT_ENABLE 0x1 -#define QDMA_SG_BMT_DISABLE 0x0 +#define QDMA_SG_BMT_ENABLE DPAA2_QDMA_BMT_ENABLE +#define QDMA_SG_BMT_DISABLE DPAA2_QDMA_BMT_DISABLE struct qdma_sg_entry { uint32_t addr_lo; /* address 0:31 */ @@ -166,6 +162,40 @@ struct dpaa2_qdma_rbp { uint32_t rsv:2; }; +enum dpaa2_qdma_fd_type { + DPAA2_QDMA_FD_SHORT = 1, + DPAA2_QDMA_FD_LONG = 2, + DPAA2_QDMA_FD_SG = 3 +}; + +#define DPAA2_QDMA_FD_ATT_TYPE_OFFSET 13 +#define DPAA2_QDMA_FD_ATT_TYPE(att) \ + (att >> DPAA2_QDMA_FD_ATT_TYPE_OFFSET) +#define DPAA2_QDMA_FD_ATT_CNTX(att) \ + (att & ((1 << DPAA2_QDMA_FD_ATT_TYPE_OFFSET) - 1)) + +static inline void +dpaa2_qdma_fd_set_addr(struct qbman_fd *fd, + uint64_t addr) +{ + fd->simple_ddr.saddr_lo = lower_32_bits(addr); + fd->simple_ddr.saddr_hi = upper_32_bits(addr); +} + +static inline void +dpaa2_qdma_fd_save_att(struct qbman_fd *fd, + uint16_t job_idx, enum dpaa2_qdma_fd_type type) +{ + fd->simple_ddr.rsv1_att = job_idx | + (type << DPAA2_QDMA_FD_ATT_TYPE_OFFSET); +} + +static inline uint16_t +dpaa2_qdma_fd_get_att(const struct qbman_fd *fd) +{ + return fd->simple_ddr.rsv1_att; +} + enum { DPAA2_QDMA_SDD_FLE, DPAA2_QDMA_SRC_FLE, @@ -193,12 +223,6 @@ struct qdma_cntx_sg { uint16_t rsv[3]; } __rte_packed; -struct qdma_cntx_long { - struct qdma_cntx_fle_sdd fle_sdd; - uint16_t cntx_idx; - uint16_t rsv[3]; -} __rte_packed; - #define DPAA2_QDMA_IDXADDR_FROM_SG_FLAG(flag) \ ((void *)(uintptr_t)((flag) - ((flag) & RTE_DPAA2_QDMA_SG_IDX_ADDR_MASK))) @@ -241,6 +265,7 @@ struct qdma_virt_queue { struct dpaa2_dpdmai_dev *dpdmai_dev; /** FLE pool for the queue */ struct rte_mempool *fle_pool; + uint64_t fle_iova2va_offset; void **fle_elem; /** Route by port */ struct dpaa2_qdma_rbp rbp; @@ -252,6 +277,7 @@ struct qdma_virt_queue { uint64_t num_enqueues; /* Total number of dequeues from this VQ */ uint64_t num_dequeues; + uint64_t copy_num; uint16_t vq_id; uint32_t flags; @@ -261,10 +287,11 @@ struct qdma_virt_queue { /**Used for silent enabled*/ struct qdma_cntx_sg *cntx_sg[DPAA2_QDMA_MAX_DESC]; - struct qdma_cntx_long *cntx_long[DPAA2_QDMA_MAX_DESC]; + struct qdma_cntx_fle_sdd *cntx_fle_sdd[DPAA2_QDMA_MAX_DESC]; uint16_t silent_idx; int num_valid_jobs; + int using_short_fd; struct rte_dma_stats stats; }; diff --git a/drivers/dma/dpaa2/rte_pmd_dpaa2_qdma.h b/drivers/dma/dpaa2/rte_pmd_dpaa2_qdma.h index e49604c8fc..df21b39cae 100644 --- a/drivers/dma/dpaa2/rte_pmd_dpaa2_qdma.h +++ b/drivers/dma/dpaa2/rte_pmd_dpaa2_qdma.h @@ -7,19 +7,6 @@ #include -#define RTE_DPAA2_QDMA_IDX_SHIFT_POS 20 -#define RTE_DPAA2_QDMA_LEN_MASK \ - (~((~0u) << RTE_DPAA2_QDMA_IDX_SHIFT_POS)) - -#define RTE_DPAA2_QDMA_IDX_LEN(idx, len) \ - ((uint32_t)((idx << RTE_DPAA2_QDMA_IDX_SHIFT_POS) | (len & RTE_DPAA2_QDMA_LEN_MASK))) - -#define RTE_DPAA2_QDMA_IDX_FROM_LENGTH(length) \ - ((uint16_t)((length) >> RTE_DPAA2_QDMA_IDX_SHIFT_POS)) - -#define RTE_DPAA2_QDMA_LEN_FROM_LENGTH(length) \ - ((length) & RTE_DPAA2_QDMA_LEN_MASK) - #define RTE_DPAA2_QDMA_COPY_IDX_OFFSET 8 #define RTE_DPAA2_QDMA_SG_IDX_ADDR_ALIGN \ RTE_BIT64(RTE_DPAA2_QDMA_COPY_IDX_OFFSET)