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 4BB1BA0C4B; Tue, 9 Nov 2021 05:40:02 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EEE8041134; Tue, 9 Nov 2021 05:39:48 +0100 (CET) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40063.outbound.protection.outlook.com [40.107.4.63]) by mails.dpdk.org (Postfix) with ESMTP id DA2664111B for ; Tue, 9 Nov 2021 05:39:45 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CZ56hjI45cC9kwiJbTLsJtogUuDBbMxlz2h1fFAKRovK14NaNPYiGrMpk3Q3ilVmpWkkh7jA/dTtFrxVIQY7QZlaq7qgCbL5PQhu2+JQEBA1DYEHjQEpKrI6ScYKfdQ7z0HFSEQ7JrNgIqK6pYLAuYxURb5Dhb0M8L3Eyy4V/PV2hgmUFkHOGvN+BF8BeTxrdhk4ZiwZsOdomOq/+jBc3ueLOiW6wccRbXWQZzFQygpcqZMNoBKOp9z+ZUPlcK6AjdUbaK/XY7Zuw9Dvu/geiqE3TRK0EBDgQ/Pna2syJm+VLQqlLiD4W/5tnc7ZzzooxLpr6zHJSkdl3CjIg8m/6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=wsoLu2PL226AIUi7WWksGB/ct6gznHPGCEHOSa3hcyo=; b=QKMVLNOuOjP2q9Oiqhr7tBcz6EWklpfu5+M9wFty+B7QF3gl4WL9APe6Jy6V6HwnD2ZGjMuR6GvlB3HPk/ji4E0G0012H7R/G80flDWrOOOwVxSeMvYCaiJHStv2jRVjSU6bYGRE+Dguykmu0M+/de2U+SRXNIVRNDkUL3fSA7J+LhF/HGt/2PFxfAj5dQyS+OrBOJgAydJe+9Lv9d8bbUqcThUwOezrj6Obn3jxzKSnvc/IAa5cPaH06i5hwNY8BYn+xXqNYGyL0Cphk9+9L/u06pCplWGNDiJsHuV/UcS7HMpons8vodbsmeuQaoCaw/iOj5A4MhL9HNM63prjtg== 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=wsoLu2PL226AIUi7WWksGB/ct6gznHPGCEHOSa3hcyo=; b=MvZJKvPEoriqbmFTOS70O724yDKHAWWHAQ3ZFW+nUmJjeiQ9jviWMSm9krN30D21iL2YquIblFQGgU3GgaTvGwwghRUzr0ZQMQlTab6TaEfuuG2nq3J5aEze+uTja5TkIbOCD3zMFG76N93G4Zhd2WfMiTr9l1hK+lXcYdu2I1A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB6960.eurprd04.prod.outlook.com (2603:10a6:803:12d::10) by VI1PR04MB5630.eurprd04.prod.outlook.com (2603:10a6:803:e6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Tue, 9 Nov 2021 04:39:44 +0000 Received: from VI1PR04MB6960.eurprd04.prod.outlook.com ([fe80::11d9:6f32:90e:80c1]) by VI1PR04MB6960.eurprd04.prod.outlook.com ([fe80::11d9:6f32:90e:80c1%7]) with mapi id 15.20.4669.016; Tue, 9 Nov 2021 04:39:44 +0000 From: Gagandeep Singh To: dev@dpdk.org Cc: nipun.gupta@nxp.com, thomas@monjalon.net, Gagandeep Singh Date: Tue, 9 Nov 2021 10:09:08 +0530 Message-Id: <20211109043910.4016824-4-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211109043910.4016824-1-g.singh@nxp.com> References: <20211108090704.3585175-2-g.singh@nxp.com> <20211109043910.4016824-1-g.singh@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2P153CA0002.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::16) To VI1PR04MB6960.eurprd04.prod.outlook.com (2603:10a6:803:12d::10) MIME-Version: 1.0 Received: from lsv03457.swis.in-blr01.nxp.com (14.142.151.118) by SI2P153CA0002.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.5 via Frontend Transport; Tue, 9 Nov 2021 04:39:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 41ade81e-553b-4382-6377-08d9a33af3e0 X-MS-TrafficTypeDiagnostic: VI1PR04MB5630: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cdsBekmZknTzzP9qpfyzIIhST5yvUuC5gGbPOVilbae0eiZg3QRPqksvgz9k6w1399VaMGSqOj2AUci1Gwk4sjO3RREmrMoUKUg6cwEEb7VpXBhGv4A0VK9gx2qlIsMRVKdUakTcAUyz+C6l/e1ocCvw0qIcfQr0+bEioJt1RBCogV5LVlfgCy6A8iupyJ9q1POTZkzCgd72drhxTFH5qZFMFHuA3xHK+Ivo7eu4jb3RYRH7vAFwQhqO9Kr5IvJUkqZ2gCZs8/lQsDNrHsx3WAEvDBI7KID/N9jPIgrbkN3oGqogNUQTXaTdLwdFsKoldlnZbyijcQLe1eXS98OqW4wcRFg0lotfxDJS5HrdjkL99jQJDlcP82eQOfLLd+2r+dGIp3/oqt/hW0XikOiwknf6KLIf8aTVJOTVBBkjXq4eAZLyNtdwGgXNRcqSieeSvSwXr76JfeM+n+4Up/q+pmYZmsvHx/zryd9y3CbKGDMTuFmEEdDYyu39683CkNmfj2VDdmyxRD28E5Z0sgkMOk08NtHs2U2Mx4BdpgOAPqoMMvzur0RdxhbEHlkE4CxZdUId31pPAVGpvI/L/ryhzdPKTfJSz+8Uf05t+MBKDRkqwKDORGohk0MtXPS6xJdZfeARQ9d3vyPPVbJiQQGrVige4yFBCUD8lKe2mM7tit/134EsEyM5KXP5uKE2xMoupDx6n+8wTNteCy+04WAQSC2BdWE8SFpcZYTLraf4vfM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB6960.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(55236004)(1006002)(6666004)(66946007)(26005)(52116002)(7696005)(186003)(316002)(508600001)(1076003)(66556008)(2616005)(5660300002)(66476007)(8936002)(86362001)(956004)(4326008)(6916009)(2906002)(38350700002)(8676002)(36756003)(6486002)(83380400001)(38100700002)(110426009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?J7win58ZrB0IYQDL1vGBWcmEhoUOaY/cXNXxEarPQ0IlFmCW3QnXg9UKTkyq?= =?us-ascii?Q?6xq1jMo0PViPxLRAi0A/IHKKO1xmukFwtE/dZL0UGXx5hLrZKwBoM6G83mCb?= =?us-ascii?Q?QYj3EMm45iwxJCgwFqT6nfkytYana95fLAmOdMaJ0wuQjw95PgEXbsPwywUJ?= =?us-ascii?Q?LETUZUNwJindbHlDcpB6aY4mLhGv3MJUZJ7Omm2Q/6YNlUGoOa2DirgBhFjm?= =?us-ascii?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5yC3uiQKmCLZOYAaLeWmEh?= =?us-ascii?Q?F1IkvG3kzJIavj2Toshk4G8VbpnZB2b7x+76N3qXWwjWXw98rK7EsTpm6jmp?= =?us-ascii?Q?PDIvDOiyMuv8rURpVlwflpmRhcAee7NCUrR+EDgCsj15ewdwJB/w9e5aAzjS?= =?us-ascii?Q?j8LsWbhAItlVhvUF6EuS5suKS57/IF0IL8A9RbfWQyZMFMggOSMjbizlYRox?= =?us-ascii?Q?J2m2xnExZytFIlwA8iRpxwtmRIKl+RFK6lT4JYrM/KvfCcR5PDyxd+KKy2fW?= =?us-ascii?Q?iVC34psfprE+EN+pPBIfbFCFLrI3esEFXCsnvTolet2Z04S0K5RYgkEa6MBF?= =?us-ascii?Q?Trm4DO5OnpzHRfNkJwNWwcxv4Sj/e6JH6iwpC3FHwNwcZfGk6HMof1H6fjAS?= =?us-ascii?Q?hnbqHYo/lS5F5NLsd/4FvpACqyaEAZR48pQizST0Urw+smejdy4X9CekySBI?= =?us-ascii?Q?25NeMs0mjqBEtCD1be4=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41ade81e-553b-4382-6377-08d9a33af3e0 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB6960.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 04:39:44.7114 (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: Au7PpXLLbRhSFrZev6AISViZM3g3bJDzRUSLkNlkGeND+TQsUNKKv6IyAnr/rZtX X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5630 Subject: [dpdk-dev] [PATCH v4 3/5] dma/dpaa: support basic operations 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 Sender: "dev" This patch support basic DMA operations which includes device capability and channel setup. Signed-off-by: Gagandeep Singh --- drivers/dma/dpaa/dpaa_qdma.c | 204 +++++++++++++++++++++++++++++++++++ drivers/dma/dpaa/dpaa_qdma.h | 6 ++ 2 files changed, 210 insertions(+) diff --git a/drivers/dma/dpaa/dpaa_qdma.c b/drivers/dma/dpaa/dpaa_qdma.c index c3255dc0c7..e59cd36872 100644 --- a/drivers/dma/dpaa/dpaa_qdma.c +++ b/drivers/dma/dpaa/dpaa_qdma.c @@ -8,6 +8,19 @@ #include "dpaa_qdma.h" #include "dpaa_qdma_logs.h" +static inline void +qdma_desc_addr_set64(struct fsl_qdma_format *ccdf, u64 addr) +{ + ccdf->addr_hi = upper_32_bits(addr); + ccdf->addr_lo = rte_cpu_to_le_32(lower_32_bits(addr)); +} + +static inline void +qdma_csgf_set_len(struct fsl_qdma_format *csgf, int len) +{ + csgf->cfg = rte_cpu_to_le_32(len & QDMA_SG_LEN_MASK); +} + static inline int ilog2(int x) { @@ -91,6 +104,77 @@ fsl_qdma_free_chan_resources(struct fsl_qdma_chan *fsl_chan) fsl_qdma->desc_allocated--; } +/* + * Pre-request command descriptor and compound S/G for enqueue. + */ +static int +fsl_qdma_pre_request_enqueue_comp_sd_desc( + struct fsl_qdma_queue *queue, + int size, int aligned) +{ + struct fsl_qdma_comp *comp_temp, *_comp_temp; + struct fsl_qdma_sdf *sdf; + struct fsl_qdma_ddf *ddf; + struct fsl_qdma_format *csgf_desc; + int i; + + for (i = 0; i < (int)(queue->n_cq + COMMAND_QUEUE_OVERFLLOW); i++) { + comp_temp = rte_zmalloc("qdma: comp temp", + sizeof(*comp_temp), 0); + if (!comp_temp) + return -ENOMEM; + + comp_temp->virt_addr = + dma_pool_alloc(size, aligned, &comp_temp->bus_addr); + if (!comp_temp->virt_addr) { + rte_free(comp_temp); + goto fail; + } + + comp_temp->desc_virt_addr = + dma_pool_alloc(size, aligned, &comp_temp->desc_bus_addr); + if (!comp_temp->desc_virt_addr) { + rte_free(comp_temp->virt_addr); + rte_free(comp_temp); + goto fail; + } + + memset(comp_temp->virt_addr, 0, FSL_QDMA_COMMAND_BUFFER_SIZE); + memset(comp_temp->desc_virt_addr, 0, + FSL_QDMA_DESCRIPTOR_BUFFER_SIZE); + + csgf_desc = (struct fsl_qdma_format *)comp_temp->virt_addr + 1; + sdf = (struct fsl_qdma_sdf *)comp_temp->desc_virt_addr; + ddf = (struct fsl_qdma_ddf *)comp_temp->desc_virt_addr + 1; + /* Compound Command Descriptor(Frame List Table) */ + qdma_desc_addr_set64(csgf_desc, comp_temp->desc_bus_addr); + /* It must be 32 as Compound S/G Descriptor */ + qdma_csgf_set_len(csgf_desc, 32); + /* Descriptor Buffer */ + sdf->cmd = rte_cpu_to_le_32(FSL_QDMA_CMD_RWTTYPE << + FSL_QDMA_CMD_RWTTYPE_OFFSET); + ddf->cmd = rte_cpu_to_le_32(FSL_QDMA_CMD_RWTTYPE << + FSL_QDMA_CMD_RWTTYPE_OFFSET); + ddf->cmd |= rte_cpu_to_le_32(FSL_QDMA_CMD_LWC << + FSL_QDMA_CMD_LWC_OFFSET); + + list_add_tail(&comp_temp->list, &queue->comp_free); + } + + return 0; + +fail: + list_for_each_entry_safe(comp_temp, _comp_temp, + &queue->comp_free, list) { + list_del(&comp_temp->list); + rte_free(comp_temp->virt_addr); + rte_free(comp_temp->desc_virt_addr); + rte_free(comp_temp); + } + + return -ENOMEM; +} + static struct fsl_qdma_queue *fsl_qdma_alloc_queue_resources(struct fsl_qdma_engine *fsl_qdma) { @@ -335,6 +419,84 @@ fsl_qdma_reg_init(struct fsl_qdma_engine *fsl_qdma) return 0; } +static int +fsl_qdma_alloc_chan_resources(struct fsl_qdma_chan *fsl_chan) +{ + struct fsl_qdma_queue *fsl_queue = fsl_chan->queue; + struct fsl_qdma_engine *fsl_qdma = fsl_chan->qdma; + int ret; + + if (fsl_queue->count++) + goto finally; + + INIT_LIST_HEAD(&fsl_queue->comp_free); + INIT_LIST_HEAD(&fsl_queue->comp_used); + + ret = fsl_qdma_pre_request_enqueue_comp_sd_desc(fsl_queue, + FSL_QDMA_COMMAND_BUFFER_SIZE, 64); + if (ret) { + DPAA_QDMA_ERR( + "failed to alloc dma buffer for comp descriptor\n"); + goto exit; + } + +finally: + return fsl_qdma->desc_allocated++; + +exit: + return -ENOMEM; +} + +static int +dpaa_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *dev_info, + uint32_t info_sz) +{ +#define DPAADMA_MAX_DESC 64 +#define DPAADMA_MIN_DESC 64 + + RTE_SET_USED(dev); + RTE_SET_USED(info_sz); + + dev_info->dev_capa = RTE_DMA_CAPA_MEM_TO_MEM | + RTE_DMA_CAPA_MEM_TO_DEV | + RTE_DMA_CAPA_DEV_TO_DEV | + RTE_DMA_CAPA_DEV_TO_MEM | + RTE_DMA_CAPA_SILENT | + RTE_DMA_CAPA_OPS_COPY; + dev_info->max_vchans = 1; + dev_info->max_desc = DPAADMA_MAX_DESC; + dev_info->min_desc = DPAADMA_MIN_DESC; + + return 0; +} + +static int +dpaa_get_channel(struct fsl_qdma_engine *fsl_qdma, uint16_t vchan) +{ + u32 i, start, end; + int ret; + + start = fsl_qdma->free_block_id * QDMA_QUEUES; + fsl_qdma->free_block_id++; + + end = start + 1; + for (i = start; i < end; i++) { + struct fsl_qdma_chan *fsl_chan = &fsl_qdma->chans[i]; + + if (fsl_chan->free) { + fsl_chan->free = false; + ret = fsl_qdma_alloc_chan_resources(fsl_chan); + if (ret) + return ret; + + fsl_qdma->vchan_map[vchan] = i; + return 0; + } + } + + return -1; +} + static void dma_release(void *fsl_chan) { @@ -342,6 +504,45 @@ dma_release(void *fsl_chan) fsl_qdma_free_chan_resources((struct fsl_qdma_chan *)fsl_chan); } +static int +dpaa_qdma_configure(__rte_unused struct rte_dma_dev *dmadev, + __rte_unused const struct rte_dma_conf *dev_conf, + __rte_unused uint32_t conf_sz) +{ + return 0; +} + +static int +dpaa_qdma_start(__rte_unused struct rte_dma_dev *dev) +{ + return 0; +} + +static int +dpaa_qdma_close(__rte_unused struct rte_dma_dev *dev) +{ + return 0; +} + +static int +dpaa_qdma_queue_setup(struct rte_dma_dev *dmadev, + uint16_t vchan, + __rte_unused const struct rte_dma_vchan_conf *conf, + __rte_unused uint32_t conf_sz) +{ + struct fsl_qdma_engine *fsl_qdma = dmadev->data->dev_private; + + return dpaa_get_channel(fsl_qdma, vchan); +} + +static struct rte_dma_dev_ops dpaa_qdma_ops = { + .dev_info_get = dpaa_info_get, + .dev_configure = dpaa_qdma_configure, + .dev_start = dpaa_qdma_start, + .dev_close = dpaa_qdma_close, + .vchan_setup = dpaa_qdma_queue_setup, +}; + static int dpaa_qdma_init(struct rte_dma_dev *dmadev) { @@ -448,6 +649,9 @@ dpaa_qdma_probe(__rte_unused struct rte_dpaa_driver *dpaa_drv, } dpaa_dev->dmadev = dmadev; + dmadev->dev_ops = &dpaa_qdma_ops; + dmadev->device = &dpaa_dev->device; + dmadev->fp_obj->dev_private = dmadev->data->dev_private; /* Invoke PMD device initialization function */ ret = dpaa_qdma_init(dmadev); diff --git a/drivers/dma/dpaa/dpaa_qdma.h b/drivers/dma/dpaa/dpaa_qdma.h index c05620b740..f046167108 100644 --- a/drivers/dma/dpaa/dpaa_qdma.h +++ b/drivers/dma/dpaa/dpaa_qdma.h @@ -10,6 +10,12 @@ #define CORE_NUMBER 4 #define RETRIES 5 +#ifndef GENMASK +#define BITS_PER_LONG (__SIZEOF_LONG__ * 8) +#define GENMASK(h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) +#endif + #define FSL_QDMA_DMR 0x0 #define FSL_QDMA_DSR 0x4 #define FSL_QDMA_DEIER 0xe00 -- 2.25.1