From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BB1C645ADE; Tue, 8 Oct 2024 12:59:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F2BF40E19; Tue, 8 Oct 2024 12:58:36 +0200 (CEST) Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2065.outbound.protection.outlook.com [40.107.103.65]) by mails.dpdk.org (Postfix) with ESMTP id C9AC3402A9 for ; Tue, 8 Oct 2024 12:58:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xw3PPU5vk6PiidWEFv8G+O0Zz3Ml4OqC/Ryltz3Yjw4hod7JbcRiq1ohmzbTW+fzvvx7KK25uQ+4Oe7LQQLsY1xvgHWPnN0ywQX7bBNAGShBj5CxD7/UiZ0EVL0aFzQnlWc9ln/2I2I0su+yg43hopxCH6QGNIiPv3GKQzPAyGkXMA6J4WkQaFZzbMD5IOqz4naRC0++bkOWDmX2cPrUinDRI1AK7hCixrSKD5E5KrPoNs94P+Le+E2AoiKJwnaJPxXJQH2z3zPNhHlL3UWeH0M1FGLvIUGwPkugSL+EBsx2FbZJd/y0cgiQh+o80MjE+3tmUcKB7Przvtyl5wtMaA== 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=7PT92SsuNpw9I+qSU58BMzRZUXLygCczOmuqbaR6ufM=; b=VGYYgiWxV+Ed1Qkv3EyX9CwJ5gGFJuFWARsfnpFILe2nVQt+h4C5URNZXZyht/hdKl9ABAHFahV/W1QhEnS7VeUDmmknjxynMNdBU13oTN4sfrXWUmDr5MqW4oQo786vosv1/yNIY1ICkkCNCkwF42SxioLiWscTx3mD7ZyDiDeRLqgoH6jZbHvOa6MA3XzU5lnKm1/BoVypxKySFHOr8K8xSZ391Ztq120UHJf6rnosSm2i5WO9o3xwm/nx8f1wMVASaE24gNhjLUtElxEmCLae8CUAfY8n23SjugU7w7JY/GNWI1gSCmzzERb/8pN5/DH4B5UYlOQBi2cY44taYA== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7PT92SsuNpw9I+qSU58BMzRZUXLygCczOmuqbaR6ufM=; b=WhqzDONPV5phPVaPRg/sMF9TWWCQ+1hsULUl4KFt3+1eTPEFoFHFponfCQR8WrtTUbOyn711nSD8j/HhjsY6zWy2tBo3869bR9h5QxtcBXAbStnvFjF9Y9disq2S4+qAmn02watPlhIghN4/HReK52HUcciS9HlQESDNeu8ivRWXhq6GY0gRdnuEpg8q2mbNZuxXqXh0uyzv45fpoyJguPLxRIsbXxqNt1RpwmoxkI3gWL3lM0vMOh7gKiIOytIpvFyxUs5+YlGeYfMviVm8JN6IanxWDadVcPKzo9wobVU8im0DoqRg14AFsXj9LP7c245JhZ51gYhCYh9xVHbUzw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8198.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::14) by AM0PR04MB6932.eurprd04.prod.outlook.com (2603:10a6:208:182::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Tue, 8 Oct 2024 10:58:31 +0000 Received: from AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::2e32:1a4a:7d29:195]) by AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::2e32:1a4a:7d29:195%4]) with mapi id 15.20.8026.020; Tue, 8 Oct 2024 10:58:31 +0000 From: Gagandeep Singh To: dev@dpdk.org, Hemant Agrawal Cc: Jun Yang Subject: [v5 04/15] dma/dpaa2: add short FD support Date: Tue, 8 Oct 2024 16:27:59 +0530 Message-Id: <20241008105810.1454133-5-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241008105810.1454133-1-g.singh@nxp.com> References: <20241008072306.1256445-2-g.singh@nxp.com> <20241008105810.1454133-1-g.singh@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR03CA0123.apcprd03.prod.outlook.com (2603:1096:4:91::27) To AS8PR04MB8198.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8198:EE_|AM0PR04MB6932:EE_ X-MS-Office365-Filtering-Correlation-Id: be59b3f1-fea9-4fff-dbec-08dce78825ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ErQ2TU/B2ywlIzDoiGlewvENZoqy0c55yVWpPjtUgjQ/GBhSm2Cz4h9WEN9B?= =?us-ascii?Q?RDXQI6S48yddj2D9I5UhqwOcoUvuywEnDnOCOwTfWNNXpRKKlvcUVOIG/d92?= =?us-ascii?Q?K5b68FGc7BNSzTOdUHcvlZp5W6ixx8lKJ96iyEEdDOTtYm2+IXHIMdsTBlQe?= =?us-ascii?Q?KYN6Kzps5R7IvTPK833kYzbKa1qRb4R0OgdbMzuE0sXSfu79ZxKCbMAN91Gz?= =?us-ascii?Q?aB4NGB5EaczRc6GTgV3lH7msRyMEKmwJW/B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LQP9chl3WZh2K2wrPzwoAFDUobHVKacJ0ikNX+zCw+jDcBKb12nIS?= =?us-ascii?Q?whkQOnUuC94CWuBFVEXwSeiLU2IlvISQEVhoZZm//irQaapMoMcvc270jC3V?= =?us-ascii?Q?Zl9kCGz11A4VZ0W/XK1bzN5XH+oc8wngkotSQuU/2ObPLRf6QI291oZZqpzs?= =?us-ascii?Q?Y5iTjXVchJdcTHrSCjS+sF9BAKJJKWEzHJOAkf/ZONVlFw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8198.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?D6FPJeqCyxBRxTwQSMyGyCMy6Va3ONE4puuPYM4VcraHEPbCJdUDd2GhMROQ?= =?us-ascii?Q?vyo/diYR1qA52t6Kyfyjx0my7/Jk2XLdgs9BSrJKgl+qkxxw71KJqmwhyrMl?= =?us-ascii?Q?qEmziZBDtEu2zqD+AVq2hOl+nzSsZ36zI2KONA8dJmogM7o/vnmzZz1SKGUl?= =?us-ascii?Q?jc2SYEBiJMOb5btSY5zRhLd1k/jUVuVBkVQIwAuEDI0kPnZlKPR8lnhXeX2z?= =?us-ascii?Q?h62nvjHG5AICBVq6eUfdVy8JmAnWBTE5PR+VVWik+bjnuFbhUnSqIqQ688q6?= =?us-ascii?Q?QZY8WkszAsg9PlR3+txSl0OvFa/Dx7C3Dywv9X5uPTMar+WvEf2+MNxbHiYi?= =?us-ascii?Q?xpfSACxJDj8eqlLXghXyUFUQ8o7bWt688VCQri4I20kcDW5bzpO2K3h+79Km?= =?us-ascii?Q?t5Rlz2itOjux7knbFQHFEVgxCpKdk73YqvF7K5/TZqMn/jgtVu4DV9jGU52p?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wUwfKbv9L4h+HD6h3DH/GrUG/NemtuI0St9zMu?= =?us-ascii?Q?I1FD70/L3gqJLCShvhyCFsq0tHKonUWBc2BPDNy5Mc5JsHDr191maA2DoCPj?= =?us-ascii?Q?CCAn9oHfLSRR2u69S7CAUYbzNiA41uXCsDZOTLESVDFmpo/PZAqROxOiVM5j?= =?us-ascii?Q?Im3ck0135E1fUOD/WbYw45yM0eNK1iLjh4CzeMyT5CkCYwU8rzu1DPB53O5s?= =?us-ascii?Q?eE0UZKHE3k6JKDiLofc=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: be59b3f1-fea9-4fff-dbec-08dce78825ab X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8198.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2024 10:58:31.6597 (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: H2n+ULILwDVTUrEeUaFppRz4iHzo00eeSOcsjg3kVb0F1yIyLEDDstxKSsfv8E2H X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6932 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 --- doc/guides/dmadevs/dpaa2.rst | 2 + drivers/dma/dpaa2/dpaa2_qdma.c | 314 +++++++++++++++++++------ drivers/dma/dpaa2/dpaa2_qdma.h | 69 ++++-- drivers/dma/dpaa2/rte_pmd_dpaa2_qdma.h | 13 - 4 files changed, 286 insertions(+), 112 deletions(-) diff --git a/doc/guides/dmadevs/dpaa2.rst b/doc/guides/dmadevs/dpaa2.rst index eeeb5d52a8..6ebf7ac030 100644 --- a/doc/guides/dmadevs/dpaa2.rst +++ b/doc/guides/dmadevs/dpaa2.rst @@ -81,3 +81,5 @@ Device Arguments usage example: ``fslmc:dpdmai.1,fle_pre_populate=1`` * Use dev arg option ``desc_debug=1`` to enable descriptor debugs. usage example: ``fslmc:dpdmai.1,desc_debug=1`` +* Use dev arg option ``short_fd=1`` to enable short FDs. + usage example: ``fslmc:dpdmai.1,short_fd=1`` diff --git a/drivers/dma/dpaa2/dpaa2_qdma.c b/drivers/dma/dpaa2/dpaa2_qdma.c index 3a6aa69e8b..23ecf4c5ac 100644 --- a/drivers/dma/dpaa2/dpaa2_qdma.c +++ b/drivers/dma/dpaa2/dpaa2_qdma.c @@ -16,6 +16,7 @@ #define DPAA2_QDMA_FLE_PRE_POPULATE "fle_pre_populate" #define DPAA2_QDMA_DESC_DEBUG "desc_debug" +#define DPAA2_QDMA_USING_SHORT_FD "short_fd" static uint32_t dpaa2_coherent_no_alloc_cache; static uint32_t dpaa2_coherent_alloc_cache; @@ -560,7 +561,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; @@ -583,11 +583,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; @@ -598,11 +595,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); @@ -620,6 +612,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"); } } @@ -682,7 +676,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); @@ -718,6 +712,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); @@ -734,74 +729,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 = fle_sdd->fle; + fle_iova = (uint64_t)fle - qdma_vq->fle_iova2va_offset; - fle = cntx_long->fle_sdd.fle; - fle_iova = cntx_iova + - offsetof(struct qdma_cntx_long, 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_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); @@ -809,15 +908,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, @@ -837,10 +1010,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)) @@ -939,25 +1108,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++; @@ -982,8 +1134,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); @@ -1212,11 +1366,14 @@ dpaa2_qdma_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan, else qdma_dev->vqs[vchan].flags &= (~DPAA2_QDMA_DESC_DEBUG_FLAG); + if (dpaa2_qdma_get_devargs(dev->device->devargs, DPAA2_QDMA_USING_SHORT_FD)) + qdma_dev->vqs[vchan].using_short_fd = 1; + else + qdma_dev->vqs[vchan].using_short_fd = 0; + 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, @@ -1236,7 +1393,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", @@ -1603,5 +1760,6 @@ static struct rte_dpaa2_driver rte_dpaa2_qdma_pmd = { RTE_PMD_REGISTER_DPAA2(dpaa2_qdma, rte_dpaa2_qdma_pmd); RTE_PMD_REGISTER_PARAM_STRING(dpaa2_qdma, DPAA2_QDMA_FLE_PRE_POPULATE "=" - DPAA2_QDMA_DESC_DEBUG"="); + DPAA2_QDMA_DESC_DEBUG"=" + DPAA2_QDMA_USING_SHORT_FD"="); RTE_LOG_REGISTER_DEFAULT(dpaa2_qdma_logtype, INFO); 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) -- 2.25.1