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 9187DA0547; Thu, 9 Sep 2021 13:15:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9FD2441155; Thu, 9 Sep 2021 13:15:33 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2078.outbound.protection.outlook.com [40.107.22.78]) by mails.dpdk.org (Postfix) with ESMTP id 9F0D241154 for ; Thu, 9 Sep 2021 13:15:32 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IqD3Knmy4atdoOYmOw3YaGfC9kCTvZD3CzybLYIdLJnzbxjkFdaXnc40s04t7vp6tX3v79DQmj3k0F/kAT7V5y2dMAWQdWhFHTR8LSSKGmNocMQ7JXIYPKcRGz51K4IwVuiAEpM8pE8wOTvO44vqrgc8gZqaRmBmIxEsPe/hgoGd3E60U5yYFIaInBYm/cfnVakGC/vvpWmtHlKlJ7dCVgjWAMKErK046zlfAkxnMj8buk+6cDcCzRbmu1vY28WTulHSvAKT11CAQGn9dBcR7njm3C3j8gQRo5WzudB9geIX38p1kCs1sMuVOgihoWi/OSnJOO8Z6UbtR5gaFnmVgg== 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; bh=DyUtW3L4INYMm4ubRUv7NpJw48lRoxkRztW5Jn/2VXQ=; b=Vcd+AftgU++H8PbIYWY2HgYsTakGRunI6XbwaNiJBprqdS4sR4KPRCcZPvD2RYKnD5zQ1SPQCrw0Qa6UUPPFXLK7cTP4Q1q24BbjYnSt70RtoYot/QamhNbvOjbtgGB8dgSN11D7epbv5lHY54+r7T7zyyCy09pdJ/9NyEKcuUivnz9rgiTOtTBY8Jns4ZipNh9HASVFa1nXITbYMlfPfj5fmurJCOxGO+d9I9WN8M4jvjSyO5WMTtZfhDSUlJDLkQWEom9BDQIyzU5pVGhhvRlVThv4erKd3E9k8jvp+sQjo2vk7GvdpKz8aMlh9haOEEse1L0D6yTtcNueBht8fQ== 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=DyUtW3L4INYMm4ubRUv7NpJw48lRoxkRztW5Jn/2VXQ=; b=HGxW8ssGrZD6aJrdQXoa5iAu3IoNUCpR1Z0h4qNjsRFSBUawBxBgo6a7yZYE0HWsu9wcSA77FKSc0HQh210/7TV4inhg7MewlEaMxPfZe5xmeK+5CFxAuARpyaFOLlDYaMyGO4puf7DWrqW5g4mSsx4hEJBuST5zHiP5X1XaWIA= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB6960.eurprd04.prod.outlook.com (2603:10a6:803:12d::10) by VI1PR0401MB2367.eurprd04.prod.outlook.com (2603:10a6:800:24::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Thu, 9 Sep 2021 11:15:31 +0000 Received: from VI1PR04MB6960.eurprd04.prod.outlook.com ([fe80::d496:fcce:f667:7aa7]) by VI1PR04MB6960.eurprd04.prod.outlook.com ([fe80::d496:fcce:f667:7aa7%8]) with mapi id 15.20.4500.015; Thu, 9 Sep 2021 11:15:31 +0000 From: Gagandeep Singh To: dev@dpdk.org Cc: nipun.gupta@nxp.com, thomas@monjalon.net, Gagandeep Singh Date: Thu, 9 Sep 2021 16:44:58 +0530 Message-Id: <20210909111500.3901706-5-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210909111500.3901706-1-g.singh@nxp.com> References: <20210909111500.3901706-1-g.singh@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR06CA0149.apcprd06.prod.outlook.com (2603:1096:1:1f::27) To VI1PR04MB6960.eurprd04.prod.outlook.com (2603:10a6:803:12d::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03457.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR06CA0149.apcprd06.prod.outlook.com (2603:1096:1:1f::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Thu, 9 Sep 2021 11:15:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 45382cc6-b807-4720-91df-08d9738322de X-MS-TrafficTypeDiagnostic: VI1PR0401MB2367: X-MS-Exchange-Transport-Forked: True 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: 6fMRBblvPvnV/M1Wj6bPOEJovVM55ujBYsXOPvVMAKJ73Lutw/5OChcd84r0J8rtqe+PfVymKFqD40hy+4TNEChyM2ewj3fXM4UhqREFUy/iWkRw74ZUKujStXs92X1RxjXhhRoElJcX5ZGfbuMAPUgnJzvQyaQrYHklJbqF5XLbtyrAZkP3HJZCOSS5zMDJj5HkxMt3qlm5+Sd8h7ViYa3hMN/MQ57vPvryVOJO/12vu/43IxuztJGMIraTTVQyj9creLptBV/RQJisr/b5qmvTX5mxsaqGgQ+Dc1LJu34If3n7IoDntWScSAmGwwLIcDjZONIfht7WFEyBgmjliu2218LRaGSXM0jbEA6CxyKS5fyLG7n0dGUFEe1FfUwbSTb16JICowMxo/tf/VmPnmitb7LU7R+mZAtkArMhLK3emQx1PTnE2vS364t1El0VHpFmL7H0OA4MwCUR3P/xdMhtOCO2e68DEKSFJSWRBDEiXl/R9VVMjlF0j0q1gQUsVhMx4fSBaKzc6OofeeIpxPKKyxsFbtbSsRKBIKl76dNpRXrP34xLqzARGWcEm1g+nNWCQrBmswKuInQXP4LlOL764A2OMK0qr4x+F+67wysBSLzrbRGN8GOV84p98Fcwe06ZgM9omAz0aJOY7nWUxLO3el8wt2ZzP5zIdtqHxyZbM5VmyPDZBHlrbWH71/Rem2mbviNTdzPP7KlljGuVqk8PUraB2+sY0CJGbIcf00c= 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)(136003)(346002)(396003)(39860400002)(376002)(366004)(66476007)(6486002)(7696005)(66556008)(186003)(52116002)(86362001)(36756003)(8676002)(1006002)(83380400001)(5660300002)(956004)(4326008)(6666004)(2616005)(66946007)(6916009)(478600001)(1076003)(38350700002)(8936002)(38100700002)(26005)(316002)(2906002)(55236004)(110426009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?skOKiHv+I0N4ldL+Nf/gm3a6hi+jG8gQHiCXdsmTqp3szr61j5kRrU68ZFsR?= =?us-ascii?Q?wfc93Ah96botd4vTTgVTFqjXXMvzG7OYeId+0EOKS+d1FVW1hEHL9KTxsP6n?= =?us-ascii?Q?hd0A7BlHPyXXHKy5FDTtAZ/Aw5M+LWH6CjBl2LiFBETYwIyBe72CCfRBmuIR?= =?us-ascii?Q?vro9uMGW+StHOXdM/KOS4ABJHe8gcmjPkHXUUqo1YLrgTPLE18RQ754L8QPE?= =?us-ascii?Q?vqTQBBK80ysoHHy2PIYr0aXHnFNbP/lZt0hpeIAuNrAu5w8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Pl1SWxKiHx+UPTLqdOOYNBzFNw6mINNfH/uub4U91ww+?= =?us-ascii?Q?WKf5O0bKsIfX9AUkzczmFx6SE+UCUAm3jhXsismCFF7YbdYMQMUu3TALCNJG?= =?us-ascii?Q?akHMX+fk5eTn6Py+58JVdnVEWlNng3XgIIW6okzr4kQq9mObkeaYq7xrbxG7?= =?us-ascii?Q?0kKUp2Fnc4JksBUSNSaq6YKr?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45382cc6-b807-4720-91df-08d9738322de X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB6960.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2021 11:15:31.7067 (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: S9L6N11eVbLiRA9fW2LwLAcRe/cxtAvNR5cgfeoIwVA04KagNxO1QZ7w5D5WLwNV X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2367 Subject: [dpdk-dev] [PATCH 4/6] 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 | 182 +++++++++++++++++++++++++++++++++++ drivers/dma/dpaa/dpaa_qdma.h | 6 ++ 2 files changed, 188 insertions(+) diff --git a/drivers/dma/dpaa/dpaa_qdma.c b/drivers/dma/dpaa/dpaa_qdma.c index 8b0454abce..0297166550 100644 --- a/drivers/dma/dpaa/dpaa_qdma.c +++ b/drivers/dma/dpaa/dpaa_qdma.c @@ -8,6 +8,18 @@ #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) { int log = 0; @@ -84,6 +96,64 @@ static void fsl_qdma_free_chan_resources(struct fsl_qdma_chan *fsl_chan) finally: 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; + 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); + return -ENOMEM; + } + + comp_temp->desc_virt_addr = + dma_pool_alloc(size, aligned, &comp_temp->desc_bus_addr); + if (!comp_temp->desc_virt_addr) + return -ENOMEM; + + 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; +} + + static struct fsl_qdma_queue *fsl_qdma_alloc_queue_resources(struct fsl_qdma_engine *fsl_qdma) { @@ -311,6 +381,79 @@ static int 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_dmadev *dev, struct rte_dmadev_info *dev_info, + uint32_t info_sz) +{ +#define DPAADMA_MAX_DESC 128 +#define DPAADMA_MIN_DESC 128 + + RTE_SET_USED(dev); + RTE_SET_USED(info_sz); + + dev_info->dev_capa = RTE_DMADEV_CAPA_MEM_TO_MEM | + RTE_DMADEV_CAPA_MEM_TO_DEV | + RTE_DMADEV_CAPA_DEV_TO_DEV | + RTE_DMADEV_CAPA_DEV_TO_MEM | + RTE_DMADEV_CAPA_SILENT | + RTE_DMADEV_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; + + 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; + fsl_qdma_alloc_chan_resources(fsl_chan); + fsl_qdma->vchan_map[vchan] = i; + return 0; + } + } + + return -1; +} + static void dma_release(void *fsl_chan) { @@ -318,6 +461,43 @@ 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_dmadev *dmadev, + __rte_unused const struct rte_dmadev_conf *dev_conf) +{ + return 0; +} + +static int +dpaa_qdma_start(__rte_unused struct rte_dmadev *dev) +{ + return 0; +} + +static int +dpaa_qdma_close(__rte_unused struct rte_dmadev *dev) +{ + return 0; +} + +static int +dpaa_qdma_queue_setup(struct rte_dmadev *dmadev, + uint16_t vchan, + __rte_unused const struct rte_dmadev_vchan_conf *conf) +{ + struct fsl_qdma_engine *fsl_qdma = dmadev->dev_private; + + return dpaa_get_channel(fsl_qdma, vchan); +} + +static struct rte_dmadev_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_dmadev *dmadev) { @@ -430,6 +610,8 @@ 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; /* 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 cc0d1f114e..f482b16334 100644 --- a/drivers/dma/dpaa/dpaa_qdma.h +++ b/drivers/dma/dpaa/dpaa_qdma.h @@ -8,6 +8,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