From patchwork Mon Jul 22 16:39:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 142637 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 633D545683; Mon, 22 Jul 2024 18:42:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 446D640E4D; Mon, 22 Jul 2024 18:40:22 +0200 (CEST) Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011019.outbound.protection.outlook.com [52.101.65.19]) by mails.dpdk.org (Postfix) with ESMTP id 3F95840E4A for ; Mon, 22 Jul 2024 18:40:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WCDITe/PXqyYPq+JXbCY+/+Je5BRGXTjZUpuxWrPiGZl8JKGabr9Y6TvvYeN1nb5fKBuKGfhRGh2fjYur8sVD5BfR+KgPXh8ttDJ1Uv9YUPQk4Pwmd/7Qvgju4S2kYsdc3oyHGrel/0wgk4rJ4EU+Vqt731djY6a4yyEZky8QNgH3twKTygWxwOyXpsexSS5fkQ5IUjZPwP4wrLbSPW/RaygioKcLkWiPOphdBnRtBWutxCN5zM26Tv/UEw08Q8m6xJfG+VZKotaHxubq5Tlb/K7sINtnsKaP2KDxb5fB/paxMl7HyIcgPJ4KgMUpGk6Up5xXezhdlrPXBQhv98cTw== 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=daxQGNrfcyClhOeqasg/HjklJgMAOaSxjkk0365TURc=; b=dr3SdOI00aBmshQyt98tCu0X+adO3wAD7jHvIeS0p0nY7CDZm5mjfGexOLmQcWMiBoNAgcq4hhIUzBOIoDkr6THDTS77rRYM+P8Qm0NpuGXpPphX/TeS2CXfubvMKRO5hk7m6dCJ9tTZf8qw2oLjmr1WLVOfhLc0WrqjJp3kwvTHCpZpd/uwP9RbWIgcXs8ERN0mDoC1zHmBGJ5fKZX2GV+TkZ1XbFWycPoWLNYaG0xGMDZvW3PNea9MerRxk5Ju4hUIw06BMftBTGgaCkP3VPKo8579gBI4nSwXlgcKJ3ftSxRvJx5pjasnUl4LaVpO65Wah9SWrdAwHLv7GqV0ng== 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=daxQGNrfcyClhOeqasg/HjklJgMAOaSxjkk0365TURc=; b=ARQK0Zk3glCaorQ4EmC8/kXn4y/objG4eTaQwAPPMGQuTdHaiJrMnz14UkxM5ozvgb4vi/T+L+GlD8V0dMViRZu38sS25YXAg9Q0Jp8EfQy2jgxsilBY8ICfL43ryN84ULkO46RVtqvu++UZN29VGshQs13tUWldootkCvy3NrU= 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 PA1PR04MB10652.eurprd04.prod.outlook.com (2603:10a6:102:491::5) 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:18 +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:18 +0000 From: Gagandeep Singh To: dev@dpdk.org, Sachin Saxena Subject: [v3 18/30] dma/dpaa: remove unwanted desc Date: Mon, 22 Jul 2024 22:09:18 +0530 Message-Id: <20240722163930.2171568-19-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_|PA1PR04MB10652:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e68de42-e493-4614-d25f-08dcaa6cf87a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|52116014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: qOjaYYxatwBczNb0XEjX1c7erPAE+9N/pS2+IMceDz4AGxmUUkZDFoGYueSiiiiLQlGEG5ArlnQ+vBmbwhzcl+OsYQPSfLWWyxnGIlo5fJ/mULuD0yTzb45rNI2KfVU7PhSCF90CdXZqYgQSWZlmkep/YP2OZKaLdBQLcACSFUjnZa/pzUgg5HrcxGvPEek5Ce8FzNCf2FH8MKTSxGW5fUr/dGV36Us7Mpm5y2nq3tIHv7932wofFq/2a3hPfAu7oyG3qXsNlNC0SwHYbz92lrP/GQ8qDghtDunK8JkoaWR5x5OdTLYJOyFiJJoiwptUngJymMplTBALgsvqUw79b9GcAtx6FtrmroDg1YoY2yOEnTqxun5rU0gkHwJrdCk0GQXjoD98Ba+2Wiu+rBv+Oci/6XJKkaGJC0hE6po+SKZOvsIWDts8f03lZcsdrR2SfSX19rbE8F4v79lh4wA0R6ZiuOrLBnIYnUXMdftqRIaGA8Gbm2+nbZ8lMTmbrmrXryUCuvOtQ2KHcJe1UrID56baRbYt5Q4fL3bpgnXX+JcjwAmv0mONd0KdiPWN4SQmQ5yXzok1ASzflc1XpsM21hFvZD7VNC/JlLNfVQ2GCzN23yLdukIlrxwOdaX59kOOpuxsM3Em/dTaHN8LbQuc/Mi/sbN8HqezmHEygkC2SFDday8/9j+YqzGCuM+bOGF7JU6PXow/aQpi7Bfv0zwxBXd6C3CYOvzmHE0FcvPwaw0DOnbwT/FokfW7caRaL6jb5kravPc8744S3Penm8eAHZf0cUXYaqIeKh65xWgO9dzpAe65IgmubAZQQkqpM2b8aG3u31wdZd9ZdnJ6Jmx7mZ+Uotk3QPaQZKiCx6XcyhGydTTxXscpdf1Z6gVlna8Oiv0lcLRT8PKoxVRUD9I7klyD0MtGFwvYVq9uM61pGEPbov/tTueM585COUvN9QG8B0FXCtxld5kvARXp7TUj29oJsw0eHNLuV0UG9Zvn/DuttC0p0uh5j2QdkbzVs3IHV129at1TlId3+aaI9xjqy/8P8PmwMEwSaH8m2r4rcqQa6qLqPi0LPlVS5qQDnkZQEFW5vcYHIQvmC81A3IFdbMN0+tXFvjzLiqFO14mBXZRuQnqmfwOh/dVVNsR03gDKKZU8GIWMejYOHCjKwUndD3a6gYqwo1RiejqK6L5L/iqBrV5rjXfKyInAoUsIsHonvtbUJ+UhXKs0Ig2VDQ3hTVX24+xofGZkYq9uqDaeTDK6KV31l3BbojC9n2wnOmP8ONhHn5W1pnodzwy/i+/siFJD1bOSuLioyIpcekiXJbjWcu6zJw1J3iJvBr2iwl+YoSUP3ZVnc3BRSnTYWBeFxgPGl/bcCgftZC5PIlO2i+j+h/9kOOXfsnYHdW0rjbs8lAcJ/7ndSnkCxSxly0DKcg== 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)(366016)(52116014)(376014)(1800799024)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: o8vZ78TEmWIJwgxWR+s4UjTylV0Sl4dm4QqEB5Z//iSGAp8Rnmv//KNL5ATH+ig2JKHBT4zSZzDAVnxeU2Q2UqzKdesZBANtfitavDlSPrXhuqmQmdKAYHYMqfwzLQHpgZLeE0QtrE8p4M7OTom8hi2f87rVRNuJ5WseCwC/ve1yt8nWblFdGZUAc58PCgkK7OEy6KjNay7eZao/uOYIzFJODBi5ZalEKfveWQChkNLZCDJrAPxS9ur9OolvcavVcqmWu0FmzJycDDzrz0nqLZuHmNXRSqFytplMDqKPAcOBdsVyMn5jG1G7XygOHqjEg7kQrZLsPlo8y1gsPrBWCwmVUvnVijPObUS2z7mRp4IK/20lrJINtgAfkXXwy0ICpYb4WuEIWRdGRy2rQqHPRBpGgc1QcrbtBQuapaOciX+a38u6ZuY5TkfKJHaHVD+uNuaesdI4ex3eWUpUp2n/Y7997hjMYGWtA4HNCc3lQ776CnFhOCuYwjqDxIXRoBfw4b7zU8xvRz5JyQARjA6pHytn54b3ZhGYWQ/cARBzGW72uSnSVms9lfts+ZPYiIYmWDVgOu6CUg87A3jShDcv3ATSo2LTN81xXPLPQJVPK12fpQKRSJXV+yYN49CqJ7WB6jweEL2aWHDhyGQTisFaQvn7rbw68jxaPIgPXLH7sfDRWzuncYKUkHEbqMq9MMIeroNvhg3F8JB6iSnMY1wppDrv9sNJS+jh5InhoBvyFvbxZDmnAgkinHS/gPmpv1mh5ck14YVdtxuenKwI9K2vMR9XYt46xdbEjMkEMLoxKOC+uog2Nn4fIT9AhIemp0gu6jrbSh7yrXQ6T3FWWLajX0wKv6eR0Nmg2O0vXYQrJ1j2zoJWS8AXJ2KMBS5q3SXSxZSsyL1/sc6sbtryzyvf2qm7gDpmyZCflM+PLEQ2N0y0V4JggSXDeQY9T3E3WELyL+NAI7C5x0+3D5G1aop8SzDjGyCObtn/ocfQx4ClrBU4iv1FBA6x0pMnEo0Kzd9UYZ3k4E5jiaySgNcITLvFDlw6Iw+8QsXq5cSMl4mQ7UxZNktWuNL3qDyzi9Fl1RbBe4Dp+EUIIsleMy8BCeg5qm1bBacoT772kuJUYqXGEJUV9bNPsM3JRC9bUConth1/RMW7zmlurzlQXCRTdAknGiv74Sk8H/fcBY/P952oxJLFArFQyhe3FBnQfthwOuKijtI9aEaTOuKz0gkZlyQY0tduNhBzL3NkU+qmUJt0kJDpucJu2cjZeh+gkEuTdZinKN/RmZd9JExg97Tc8N8E7+0AiwJfLdakjpVpOBnUn9mgOdzhPXMgrw8VqMJdanxM6/TEV3XCUtmUz0Y4pYFIN2cH8oeM8pA0tnlz6fJMGe4kWAMDX6xmaOpcAUs9yEXOzUeTbDzZgDRU2p6p2acDAgk5ip4ZDdpIaRT9saChF3OJ2cZxJT3m2bD6spJsrJGEhKbCi2tWIARpCnmAtQkWhSSVwIR7KPrg1inzxtfAcMfXfRSDMIcRPiu1wSmSUv7wwvZNU5HZWBStqKV43tLpDOP/E/jtLBPEg5+NmFZ+e4W2saaqKt9BOj8Pl3dBRjmm X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e68de42-e493-4614-d25f-08dcaa6cf87a 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:18.4002 (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: 3bszkqUdZtDBgis2NRe6FChGfXoNJGgDi0QSynijEr0CZaoCzrH62zS3x3+R/wxe X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10652 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 remove unwanted descriptor list maintenance and channels overhead. Signed-off-by: Gagandeep Singh --- drivers/dma/dpaa/dpaa_qdma.c | 594 +++++++++++++---------------------- drivers/dma/dpaa/dpaa_qdma.h | 43 +-- 2 files changed, 221 insertions(+), 416 deletions(-) diff --git a/drivers/dma/dpaa/dpaa_qdma.c b/drivers/dma/dpaa/dpaa_qdma.c index f1878879af..8e8426b88d 100644 --- a/drivers/dma/dpaa/dpaa_qdma.c +++ b/drivers/dma/dpaa/dpaa_qdma.c @@ -111,96 +111,6 @@ static void return virt_addr; } -static void -dma_pool_free(void *addr) -{ - rte_free(addr); -} - -static void -fsl_qdma_free_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; - struct fsl_qdma_comp *comp_temp, *_comp_temp; - int id; - - if (--fsl_queue->count) - goto finally; - - id = (fsl_qdma->block_base - fsl_queue->block_base) / - fsl_qdma->block_offset; - - while (rte_atomic32_read(&wait_task[id]) == 1) - rte_delay_us(QDMA_DELAY); - - list_for_each_entry_safe(comp_temp, _comp_temp, - &fsl_queue->comp_used, list) { - list_del(&comp_temp->list); - dma_pool_free(comp_temp->virt_addr); - dma_pool_free(comp_temp->desc_virt_addr); - rte_free(comp_temp); - } - - list_for_each_entry_safe(comp_temp, _comp_temp, - &fsl_queue->comp_free, list) { - list_del(&comp_temp->list); - dma_pool_free(comp_temp->virt_addr); - dma_pool_free(comp_temp->desc_virt_addr); - rte_free(comp_temp); - } - -finally: - fsl_qdma->desc_allocated--; -} - -static void -fsl_qdma_comp_fill_memcpy(struct fsl_qdma_comp *fsl_comp, - dma_addr_t dst, dma_addr_t src, u32 len) -{ - struct fsl_qdma_format *csgf_src, *csgf_dest; -#ifdef RTE_DMA_DPAA_ERRATA_ERR050757 - struct fsl_qdma_sdf *sdf; - u32 cfg = 0; -#endif - - /* Note: command table (fsl_comp->virt_addr) is getting filled - * directly in cmd descriptors of queues while enqueuing the descriptor - * please refer fsl_qdma_enqueue_desc - * frame list table (virt_addr) + 1) and source, - * destination descriptor table - * (fsl_comp->desc_virt_addr and fsl_comp->desc_virt_addr+1) move to - * the control path to fsl_qdma_pre_request_enqueue_comp_sd_desc - */ - csgf_src = (struct fsl_qdma_format *)fsl_comp->virt_addr + 2; - csgf_dest = (struct fsl_qdma_format *)fsl_comp->virt_addr + 3; - -#ifdef RTE_DMA_DPAA_ERRATA_ERR050757 - sdf = (struct fsl_qdma_sdf *)fsl_comp->desc_virt_addr; - sdf->cmd = rte_cpu_to_le_32(FSL_QDMA_CMD_RWTTYPE << - FSL_QDMA_CMD_RWTTYPE_OFFSET); -#ifdef RTE_DMA_DPAA_ERRATA_ERR050265 - sdf->cmd |= rte_cpu_to_le_32(FSL_QDMA_CMD_PF); -#endif - if (len > FSL_QDMA_CMD_SSS_DISTANCE) { - sdf->cmd |= rte_cpu_to_le_32(FSL_QDMA_CMD_SSEN); - cfg |= rte_cpu_to_le_32(FSL_QDMA_CMD_SSS_STRIDE << - FSL_QDMA_CFG_SSS_OFFSET | - FSL_QDMA_CMD_SSS_DISTANCE); - sdf->cfg = cfg; - } else - sdf->cfg = 0; -#endif - - /* Status notification is enqueued to status queue. */ - qdma_desc_addr_set64(csgf_src, src); - qdma_csgf_set_len(csgf_src, len); - qdma_desc_addr_set64(csgf_dest, dst); - qdma_csgf_set_len(csgf_dest, len); - /* This entry is the last entry. */ - qdma_csgf_set_f(csgf_dest, len); -} - /* * Pre-request command descriptor and compound S/G for enqueue. */ @@ -209,42 +119,41 @@ 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_OVERFLOW); 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); + struct fsl_qdma_format *ccdf; + int i, j; + struct fsl_qdma_format *head; + + head = queue->virt_head; + + for (i = 0; i < (int)(queue->n_cq); i++) { + dma_addr_t bus_addr = 0, desc_bus_addr = 0; + + queue->virt_addr[i] = + dma_pool_alloc(size, aligned, &bus_addr); + if (!queue->virt_addr[i]) 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); + queue->desc_virt_addr[i] = + dma_pool_alloc(size, aligned, &desc_bus_addr); + if (!queue->desc_virt_addr[i]) { + rte_free(queue->virt_addr[i]); goto fail; } - memset(comp_temp->virt_addr, 0, FSL_QDMA_COMMAND_BUFFER_SIZE); - memset(comp_temp->desc_virt_addr, 0, + memset(queue->virt_addr[i], 0, FSL_QDMA_COMMAND_BUFFER_SIZE); + memset(queue->desc_virt_addr[i], 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; + csgf_desc = (struct fsl_qdma_format *)queue->virt_addr[i] + + QDMA_DESC_OFF; + sdf = (struct fsl_qdma_sdf *)queue->desc_virt_addr[i]; + ddf = (struct fsl_qdma_ddf *)sdf + QDMA_DESC_OFF; /* Compound Command Descriptor(Frame List Table) */ - qdma_desc_addr_set64(csgf_desc, comp_temp->desc_bus_addr); + qdma_desc_addr_set64(csgf_desc, desc_bus_addr); + /* It must be 32 as Compound S/G Descriptor */ qdma_csgf_set_len(csgf_desc, 32); /* Descriptor Buffer */ @@ -258,106 +167,84 @@ fsl_qdma_pre_request_enqueue_comp_sd_desc( 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); + ccdf = (struct fsl_qdma_format *)queue->virt_head; + qdma_desc_addr_set64(ccdf, bus_addr + 16); + qdma_ccdf_set_format(ccdf, qdma_ccdf_get_offset(queue->virt_addr[i])); + qdma_ccdf_set_ser(ccdf, qdma_ccdf_get_status(queue->virt_addr[i])); + queue->virt_head++; } + queue->virt_head = head; + queue->ci = 0; 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); + for (j = 0; j < i; j++) { + rte_free(queue->virt_addr[j]); + rte_free(queue->desc_virt_addr[j]); } return -ENOMEM; } -/* - * Request a command descriptor for enqueue. - */ -static struct fsl_qdma_comp * -fsl_qdma_request_enqueue_desc(struct fsl_qdma_chan *fsl_chan) +static struct fsl_qdma_queue +*fsl_qdma_alloc_queue_resources(struct fsl_qdma_engine *fsl_qdma, int k, int b) { - struct fsl_qdma_queue *queue = fsl_chan->queue; - struct fsl_qdma_comp *comp_temp; - - if (!list_empty(&queue->comp_free)) { - comp_temp = list_first_entry(&queue->comp_free, - struct fsl_qdma_comp, - list); - list_del(&comp_temp->list); - return comp_temp; + struct fsl_qdma_queue *queue_temp; + + queue_temp = rte_zmalloc("qdma: queue head", sizeof(*queue_temp), 0); + if (!queue_temp) { + printf("no memory to allocate queues\n"); + return NULL; } - return NULL; -} + queue_temp->cq = + dma_pool_alloc(sizeof(struct fsl_qdma_format) * + QDMA_QUEUE_SIZE, + sizeof(struct fsl_qdma_format) * + QDMA_QUEUE_SIZE, &queue_temp->bus_addr); -static struct fsl_qdma_queue -*fsl_qdma_alloc_queue_resources(struct fsl_qdma_engine *fsl_qdma) -{ - struct fsl_qdma_queue *queue_head, *queue_temp; - int len, i, j; - int queue_num; - int blocks; - unsigned int queue_size[FSL_QDMA_QUEUE_MAX]; - - queue_num = fsl_qdma->n_queues; - blocks = fsl_qdma->num_blocks; - - len = sizeof(*queue_head) * queue_num * blocks; - queue_head = rte_zmalloc("qdma: queue head", len, 0); - if (!queue_head) + if (!queue_temp->cq) { + rte_free(queue_temp); return NULL; - - for (i = 0; i < FSL_QDMA_QUEUE_MAX; i++) - queue_size[i] = QDMA_QUEUE_SIZE; - - for (j = 0; j < blocks; j++) { - for (i = 0; i < queue_num; i++) { - if (queue_size[i] > FSL_QDMA_CIRCULAR_DESC_SIZE_MAX || - queue_size[i] < FSL_QDMA_CIRCULAR_DESC_SIZE_MIN) { - DPAA_QDMA_ERR("Get wrong queue-sizes.\n"); - goto fail; - } - queue_temp = queue_head + i + (j * queue_num); - - queue_temp->cq = - dma_pool_alloc(sizeof(struct fsl_qdma_format) * - queue_size[i], - sizeof(struct fsl_qdma_format) * - queue_size[i], &queue_temp->bus_addr); - - if (!queue_temp->cq) - goto fail; - - memset(queue_temp->cq, 0x0, queue_size[i] * - sizeof(struct fsl_qdma_format)); - - queue_temp->block_base = fsl_qdma->block_base + - FSL_QDMA_BLOCK_BASE_OFFSET(fsl_qdma, j); - queue_temp->n_cq = queue_size[i]; - queue_temp->id = i; - queue_temp->count = 0; - queue_temp->pending = 0; - queue_temp->virt_head = queue_temp->cq; - queue_temp->stats = (struct rte_dma_stats){0}; - } } - return queue_head; -fail: - for (j = 0; j < blocks; j++) { - for (i = 0; i < queue_num; i++) { - queue_temp = queue_head + i + (j * queue_num); - dma_pool_free(queue_temp->cq); - } + memset(queue_temp->cq, 0x0, QDMA_QUEUE_SIZE * + sizeof(struct fsl_qdma_format)); + + queue_temp->queue_base = fsl_qdma->block_base + + FSL_QDMA_BLOCK_BASE_OFFSET(fsl_qdma, b); + queue_temp->n_cq = QDMA_QUEUE_SIZE; + queue_temp->id = k; + queue_temp->pending = 0; + queue_temp->virt_head = queue_temp->cq; + queue_temp->virt_addr = rte_malloc("queue virt addr", + sizeof(void *) * QDMA_QUEUE_SIZE, 0); + if (!queue_temp->virt_addr) { + rte_free(queue_temp->cq); + rte_free(queue_temp); + return NULL; } - rte_free(queue_head); + queue_temp->desc_virt_addr = rte_malloc("queue desc virt addr", + sizeof(void *) * QDMA_QUEUE_SIZE, 0); + if (!queue_temp->desc_virt_addr) { + rte_free(queue_temp->virt_addr); + rte_free(queue_temp->cq); + rte_free(queue_temp); + return NULL; + } + queue_temp->stats = (struct rte_dma_stats){0}; + + return queue_temp; +} - return NULL; +static void +fsl_qdma_free_queue_resources(struct fsl_qdma_queue *queue) +{ + rte_free(queue->desc_virt_addr); + rte_free(queue->virt_addr); + rte_free(queue->cq); + rte_free(queue); } static struct @@ -367,11 +254,6 @@ fsl_qdma_queue *fsl_qdma_prep_status_queue(void) unsigned int status_size; status_size = QDMA_STATUS_SIZE; - if (status_size > FSL_QDMA_CIRCULAR_DESC_SIZE_MAX || - status_size < FSL_QDMA_CIRCULAR_DESC_SIZE_MIN) { - DPAA_QDMA_ERR("Get wrong status_size.\n"); - return NULL; - } status_head = rte_zmalloc("qdma: status head", sizeof(*status_head), 0); if (!status_head) @@ -399,6 +281,13 @@ fsl_qdma_queue *fsl_qdma_prep_status_queue(void) return status_head; } +static void +fsl_qdma_free_status_queue(struct fsl_qdma_queue *status) +{ + rte_free(status->cq); + rte_free(status); +} + static int fsl_qdma_halt(struct fsl_qdma_engine *fsl_qdma) { @@ -449,12 +338,9 @@ fsl_qdma_queue_transfer_complete(struct fsl_qdma_engine *fsl_qdma, void *block, int id, const uint16_t nb_cpls, enum rte_dma_status_code *status) { - struct fsl_qdma_queue *fsl_queue = fsl_qdma->queue; struct fsl_qdma_queue *fsl_status = fsl_qdma->status[id]; - struct fsl_qdma_queue *temp_queue; struct fsl_qdma_format *status_addr; - struct fsl_qdma_comp *fsl_comp = NULL; - u32 reg, i; + u32 reg; int count = 0; while (count < nb_cpls) { @@ -464,14 +350,6 @@ fsl_qdma_queue_transfer_complete(struct fsl_qdma_engine *fsl_qdma, status_addr = fsl_status->virt_head; - i = qdma_ccdf_get_queue(status_addr) + - id * fsl_qdma->n_queues; - temp_queue = fsl_queue + i; - fsl_comp = list_first_entry(&temp_queue->comp_used, - struct fsl_qdma_comp, - list); - list_del(&fsl_comp->list); - reg = qdma_readl_be(block + FSL_QDMA_BSQMR); reg |= FSL_QDMA_BSQMR_DI_BE; @@ -483,7 +361,6 @@ fsl_qdma_queue_transfer_complete(struct fsl_qdma_engine *fsl_qdma, if (status != NULL) status[count] = RTE_DMA_STATUS_SUCCESSFUL; - list_add_tail(&fsl_comp->list, &temp_queue->comp_free); count++; } @@ -493,7 +370,6 @@ fsl_qdma_queue_transfer_complete(struct fsl_qdma_engine *fsl_qdma, static int fsl_qdma_reg_init(struct fsl_qdma_engine *fsl_qdma) { - struct fsl_qdma_queue *fsl_queue = fsl_qdma->queue; struct fsl_qdma_queue *temp; void *ctrl = fsl_qdma->ctrl_base; void *block; @@ -508,11 +384,13 @@ fsl_qdma_reg_init(struct fsl_qdma_engine *fsl_qdma) return ret; } + int k = 0; for (j = 0; j < fsl_qdma->num_blocks; j++) { block = fsl_qdma->block_base + FSL_QDMA_BLOCK_BASE_OFFSET(fsl_qdma, j); - for (i = 0; i < fsl_qdma->n_queues; i++) { - temp = fsl_queue + i + (j * fsl_qdma->n_queues); + k = 0; + for (i = (j * QDMA_QUEUES); i < ((j * QDMA_QUEUES) + QDMA_QUEUES); i++) { + temp = fsl_qdma->queue[i]; /* * Initialize Command Queue registers to * point to the first @@ -522,19 +400,20 @@ fsl_qdma_reg_init(struct fsl_qdma_engine *fsl_qdma) */ qdma_writel(lower_32_bits(temp->bus_addr), - block + FSL_QDMA_BCQDPA_SADDR(i)); + block + FSL_QDMA_BCQDPA_SADDR(k)); qdma_writel(upper_32_bits(temp->bus_addr), - block + FSL_QDMA_BCQEDPA_SADDR(i)); + block + FSL_QDMA_BCQEDPA_SADDR(k)); qdma_writel(lower_32_bits(temp->bus_addr), - block + FSL_QDMA_BCQEPA_SADDR(i)); + block + FSL_QDMA_BCQEPA_SADDR(k)); qdma_writel(upper_32_bits(temp->bus_addr), - block + FSL_QDMA_BCQEEPA_SADDR(i)); + block + FSL_QDMA_BCQEEPA_SADDR(k)); /* Initialize the queue mode. */ reg = FSL_QDMA_BCQMR_EN; reg |= FSL_QDMA_BCQMR_CD_THLD(ilog2(temp->n_cq) - 4); reg |= FSL_QDMA_BCQMR_CQ_SIZE(ilog2(temp->n_cq) - 6); - qdma_writel(reg, block + FSL_QDMA_BCQMR(i)); + qdma_writel(reg, block + FSL_QDMA_BCQMR(k)); + k++; } /* @@ -585,36 +464,19 @@ fsl_qdma_reg_init(struct fsl_qdma_engine *fsl_qdma) return 0; } -static void * -fsl_qdma_prep_memcpy(void *fsl_chan, dma_addr_t dst, - dma_addr_t src, size_t len, - void *call_back, - void *param) -{ - struct fsl_qdma_comp *fsl_comp; - - fsl_comp = - fsl_qdma_request_enqueue_desc((struct fsl_qdma_chan *)fsl_chan); - if (!fsl_comp) - return NULL; - - fsl_comp->qchan = fsl_chan; - fsl_comp->call_back_func = call_back; - fsl_comp->params = param; - - fsl_qdma_comp_fill_memcpy(fsl_comp, dst, src, len); - return (void *)fsl_comp; -} static int -fsl_qdma_enqueue_desc(struct fsl_qdma_chan *fsl_chan, - struct fsl_qdma_comp *fsl_comp, - uint64_t flags) +fsl_qdma_enqueue_desc(struct fsl_qdma_queue *fsl_queue, + uint64_t flags, dma_addr_t dst, + dma_addr_t src, size_t len) { - struct fsl_qdma_queue *fsl_queue = fsl_chan->queue; - void *block = fsl_queue->block_base; - struct fsl_qdma_format *ccdf; + void *block = fsl_queue->queue_base; + struct fsl_qdma_format *csgf_src, *csgf_dest; u32 reg; +#ifdef RTE_DMA_DPAA_ERRATA_ERR050757 + struct fsl_qdma_sdf *sdf; + u32 cfg = 0; +#endif /* retrieve and store the register value in big endian * to avoid bits swap @@ -624,17 +486,40 @@ fsl_qdma_enqueue_desc(struct fsl_qdma_chan *fsl_chan, if (reg & (FSL_QDMA_BCQSR_QF_XOFF_BE)) return -1; - /* filling descriptor command table */ - ccdf = (struct fsl_qdma_format *)fsl_queue->virt_head; - qdma_desc_addr_set64(ccdf, fsl_comp->bus_addr + 16); - qdma_ccdf_set_format(ccdf, qdma_ccdf_get_offset(fsl_comp->virt_addr)); - qdma_ccdf_set_ser(ccdf, qdma_ccdf_get_status(fsl_comp->virt_addr)); + csgf_src = (struct fsl_qdma_format *)fsl_queue->virt_addr[fsl_queue->ci] + + QDMA_SGF_SRC_OFF; + csgf_dest = (struct fsl_qdma_format *)fsl_queue->virt_addr[fsl_queue->ci] + + QDMA_SGF_DST_OFF; +#ifdef RTE_DMA_DPAA_ERRATA_ERR050757 + sdf = (struct fsl_qdma_sdf *)fsl_queue->desc_virt_addr[fsl_queue->ci]; + sdf->cmd = rte_cpu_to_le_32(FSL_QDMA_CMD_RWTTYPE << + FSL_QDMA_CMD_RWTTYPE_OFFSET); +#ifdef RTE_DMA_DPAA_ERRATA_ERR050265 + sdf->cmd |= rte_cpu_to_le_32(FSL_QDMA_CMD_PF); +#endif + if (len > FSL_QDMA_CMD_SSS_DISTANCE) { + sdf->cmd |= rte_cpu_to_le_32(FSL_QDMA_CMD_SSEN); + cfg |= rte_cpu_to_le_32(FSL_QDMA_CMD_SSS_STRIDE << + FSL_QDMA_CFG_SSS_OFFSET | + FSL_QDMA_CMD_SSS_DISTANCE); + sdf->cfg = cfg; + } else + sdf->cfg = 0; +#endif + qdma_desc_addr_set64(csgf_src, src); + qdma_csgf_set_len(csgf_src, len); + qdma_desc_addr_set64(csgf_dest, dst); + qdma_csgf_set_len(csgf_dest, len); + /* This entry is the last entry. */ + qdma_csgf_set_f(csgf_dest, len); fsl_queue->virt_head++; + fsl_queue->ci++; - if (fsl_queue->virt_head == fsl_queue->cq + fsl_queue->n_cq) + if (fsl_queue->virt_head == fsl_queue->cq + fsl_queue->n_cq) { fsl_queue->virt_head = fsl_queue->cq; + fsl_queue->ci = 0; + } - list_add_tail(&fsl_comp->list, &fsl_queue->comp_used); if (flags & RTE_DMA_OP_FLAG_SUBMIT) { reg = qdma_readl_be(block + FSL_QDMA_BCQMR(fsl_queue->id)); @@ -647,34 +532,6 @@ fsl_qdma_enqueue_desc(struct fsl_qdma_chan *fsl_chan, 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: - fsl_qdma->desc_allocated++; - return 0; -exit: - return -ENOMEM; -} - static int dpaa_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *dev_info, uint32_t info_sz) @@ -701,35 +558,26 @@ dpaa_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *dev_info, static int dpaa_get_channel(struct fsl_qdma_engine *fsl_qdma, uint16_t vchan) { - u32 i, start, end; + u32 i; int ret; + struct fsl_qdma_queue *fsl_queue; - 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; - } + if (fsl_qdma->free_block_id == QDMA_BLOCKS) { + DPAA_QDMA_ERR("Maximum 4 queues can be configured\n"); + return -1; } - return -1; -} + i = fsl_qdma->free_block_id * QDMA_QUEUES; -static void -dma_release(void *fsl_chan) -{ - ((struct fsl_qdma_chan *)fsl_chan)->free = true; - fsl_qdma_free_chan_resources((struct fsl_qdma_chan *)fsl_chan); + fsl_queue = fsl_qdma->queue[i]; + ret = fsl_qdma_pre_request_enqueue_comp_sd_desc(fsl_queue, + FSL_QDMA_COMMAND_BUFFER_SIZE, 64); + if (ret) + return ret; + + fsl_qdma->vchan_map[vchan] = i; + fsl_qdma->free_block_id++; + return 0; } static int @@ -767,10 +615,9 @@ static int dpaa_qdma_submit(void *dev_private, uint16_t vchan) { struct fsl_qdma_engine *fsl_qdma = (struct fsl_qdma_engine *)dev_private; - struct fsl_qdma_chan *fsl_chan = - &fsl_qdma->chans[fsl_qdma->vchan_map[vchan]]; - struct fsl_qdma_queue *fsl_queue = fsl_chan->queue; - void *block = fsl_queue->block_base; + struct fsl_qdma_queue *fsl_queue = + fsl_qdma->queue[fsl_qdma->vchan_map[vchan]]; + void *block = fsl_queue->queue_base; u32 reg; while (fsl_queue->pending) { @@ -790,22 +637,13 @@ dpaa_qdma_enqueue(void *dev_private, uint16_t vchan, uint32_t length, uint64_t flags) { struct fsl_qdma_engine *fsl_qdma = (struct fsl_qdma_engine *)dev_private; - struct fsl_qdma_chan *fsl_chan = - &fsl_qdma->chans[fsl_qdma->vchan_map[vchan]]; - struct fsl_qdma_queue *fsl_queue = fsl_chan->queue; + struct fsl_qdma_queue *fsl_queue = + fsl_qdma->queue[fsl_qdma->vchan_map[vchan]]; int ret, idx; idx = (uint16_t)(fsl_queue->stats.submitted + fsl_queue->pending); - void *fsl_comp = NULL; - fsl_comp = fsl_qdma_prep_memcpy(fsl_chan, - (dma_addr_t)dst, (dma_addr_t)src, - length, NULL, NULL); - if (!fsl_comp) { - DPAA_QDMA_DP_DEBUG("fsl_comp is NULL\n"); - return -1; - } - ret = fsl_qdma_enqueue_desc(fsl_chan, fsl_comp, flags); + ret = fsl_qdma_enqueue_desc(fsl_queue, flags, (dma_addr_t)dst, (dma_addr_t)src, length); if (ret < 0) return ret; @@ -822,9 +660,8 @@ dpaa_qdma_dequeue_status(void *dev_private, uint16_t vchan, void *block; int intr; void *status = fsl_qdma->status_base; - struct fsl_qdma_chan *fsl_chan = - &fsl_qdma->chans[fsl_qdma->vchan_map[vchan]]; - struct fsl_qdma_queue *fsl_queue = fsl_chan->queue; + struct fsl_qdma_queue *fsl_queue = + fsl_qdma->queue[fsl_qdma->vchan_map[vchan]]; intr = qdma_readl_be(status + FSL_QDMA_DEDR); if (intr) { @@ -870,9 +707,8 @@ dpaa_qdma_dequeue(void *dev_private, void *block; int intr; void *status = fsl_qdma->status_base; - struct fsl_qdma_chan *fsl_chan = - &fsl_qdma->chans[fsl_qdma->vchan_map[vchan]]; - struct fsl_qdma_queue *fsl_queue = fsl_chan->queue; + struct fsl_qdma_queue *fsl_queue = + fsl_qdma->queue[fsl_qdma->vchan_map[vchan]]; intr = qdma_readl_be(status + FSL_QDMA_DEDR); if (intr) { @@ -912,9 +748,8 @@ dpaa_qdma_stats_get(const struct rte_dma_dev *dmadev, uint16_t vchan, struct rte_dma_stats *rte_stats, uint32_t size) { struct fsl_qdma_engine *fsl_qdma = dmadev->data->dev_private; - struct fsl_qdma_chan *fsl_chan = - &fsl_qdma->chans[fsl_qdma->vchan_map[vchan]]; - struct fsl_qdma_queue *fsl_queue = fsl_chan->queue; + struct fsl_qdma_queue *fsl_queue = + fsl_qdma->queue[fsl_qdma->vchan_map[vchan]]; struct rte_dma_stats *stats = &fsl_queue->stats; if (size < sizeof(rte_stats)) @@ -931,9 +766,8 @@ static int dpaa_qdma_stats_reset(struct rte_dma_dev *dmadev, uint16_t vchan) { struct fsl_qdma_engine *fsl_qdma = dmadev->data->dev_private; - struct fsl_qdma_chan *fsl_chan = - &fsl_qdma->chans[fsl_qdma->vchan_map[vchan]]; - struct fsl_qdma_queue *fsl_queue = fsl_chan->queue; + struct fsl_qdma_queue *fsl_queue = + fsl_qdma->queue[fsl_qdma->vchan_map[vchan]]; fsl_queue->stats = (struct rte_dma_stats){0}; @@ -944,9 +778,8 @@ static uint16_t dpaa_qdma_burst_capacity(const void *dev_private, uint16_t vchan) { const struct fsl_qdma_engine *fsl_qdma = dev_private; - struct fsl_qdma_chan *fsl_chan = - &fsl_qdma->chans[fsl_qdma->vchan_map[vchan]]; - struct fsl_qdma_queue *fsl_queue = fsl_chan->queue; + struct fsl_qdma_queue *fsl_queue = + fsl_qdma->queue[fsl_qdma->vchan_map[vchan]]; return fsl_queue->n_cq - fsl_queue->pending; } @@ -965,43 +798,21 @@ static int dpaa_qdma_init(struct rte_dma_dev *dmadev) { struct fsl_qdma_engine *fsl_qdma = dmadev->data->dev_private; - struct fsl_qdma_chan *fsl_chan; uint64_t phys_addr; - unsigned int len; int ccsr_qdma_fd; int regs_size; int ret; - u32 i; + u32 i, k = 0; + int j; - fsl_qdma->desc_allocated = 0; - fsl_qdma->n_chans = VIRT_CHANNELS; - fsl_qdma->n_queues = QDMA_QUEUES; + fsl_qdma->n_queues = QDMA_QUEUES * QDMA_BLOCKS; fsl_qdma->num_blocks = QDMA_BLOCKS; fsl_qdma->block_offset = QDMA_BLOCK_OFFSET; - len = sizeof(*fsl_chan) * fsl_qdma->n_chans; - fsl_qdma->chans = rte_zmalloc("qdma: fsl chans", len, 0); - if (!fsl_qdma->chans) - return -1; - - len = sizeof(struct fsl_qdma_queue *) * fsl_qdma->num_blocks; - fsl_qdma->status = rte_zmalloc("qdma: fsl status", len, 0); - if (!fsl_qdma->status) { - rte_free(fsl_qdma->chans); - return -1; - } - - for (i = 0; i < fsl_qdma->num_blocks; i++) { - rte_atomic32_init(&wait_task[i]); - fsl_qdma->status[i] = fsl_qdma_prep_status_queue(); - if (!fsl_qdma->status[i]) - goto err; - } - ccsr_qdma_fd = open("/dev/mem", O_RDWR); if (unlikely(ccsr_qdma_fd < 0)) { DPAA_QDMA_ERR("Can not open /dev/mem for qdma CCSR map"); - goto err; + return -1; } regs_size = fsl_qdma->block_offset * (fsl_qdma->num_blocks + 2); @@ -1014,39 +825,55 @@ dpaa_qdma_init(struct rte_dma_dev *dmadev) if (fsl_qdma->ctrl_base == MAP_FAILED) { DPAA_QDMA_ERR("Can not map CCSR base qdma: Phys: %08" PRIx64 "size %d\n", phys_addr, regs_size); - goto err; + return -1; } fsl_qdma->status_base = fsl_qdma->ctrl_base + QDMA_BLOCK_OFFSET; fsl_qdma->block_base = fsl_qdma->status_base + QDMA_BLOCK_OFFSET; - fsl_qdma->queue = fsl_qdma_alloc_queue_resources(fsl_qdma); + fsl_qdma->status = rte_malloc("status queue", sizeof(struct fsl_qdma_queue) * 4, 0); + if (!fsl_qdma->status) + goto err; + + fsl_qdma->queue = rte_malloc("cmd queue", sizeof(struct fsl_qdma_queue) * 32, 0); if (!fsl_qdma->queue) { - munmap(fsl_qdma->ctrl_base, regs_size); + rte_free(fsl_qdma->status); goto err; } - for (i = 0; i < fsl_qdma->n_chans; i++) { - struct fsl_qdma_chan *fsl_chan = &fsl_qdma->chans[i]; + for (i = 0; i < fsl_qdma->num_blocks; i++) { + fsl_qdma->status[i] = fsl_qdma_prep_status_queue(); + if (!fsl_qdma->status[i]) + goto mem_free; + j = 0; + for (k = (i * QDMA_QUEUES); k < ((i * QDMA_QUEUES) + QDMA_QUEUES); k++) { + fsl_qdma->queue[k] = fsl_qdma_alloc_queue_resources(fsl_qdma, j, i); + if (!fsl_qdma->queue[k]) + goto mem_free; + j++; + } - fsl_chan->qdma = fsl_qdma; - fsl_chan->queue = fsl_qdma->queue + i % (fsl_qdma->n_queues * - fsl_qdma->num_blocks); - fsl_chan->free = true; } ret = fsl_qdma_reg_init(fsl_qdma); if (ret) { DPAA_QDMA_ERR("Can't Initialize the qDMA engine.\n"); - munmap(fsl_qdma->ctrl_base, regs_size); - goto err; + rte_free(fsl_qdma->status); + goto mem_free; } return 0; -err: - rte_free(fsl_qdma->chans); +mem_free: + for (i = 0; i < fsl_qdma->num_blocks; i++) { + for (k = (i * QDMA_QUEUES); k < ((i * QDMA_QUEUES) + QDMA_QUEUES); k++) + fsl_qdma_free_queue_resources(fsl_qdma->queue[k]); + fsl_qdma_free_status_queue(fsl_qdma->status[i]); + } rte_free(fsl_qdma->status); +err: + rte_free(fsl_qdma->queue); + munmap(fsl_qdma->ctrl_base, regs_size); return -1; } @@ -1092,17 +919,16 @@ dpaa_qdma_remove(struct rte_dpaa_device *dpaa_dev) { struct rte_dma_dev *dmadev = dpaa_dev->dmadev; struct fsl_qdma_engine *fsl_qdma = dmadev->data->dev_private; - int i = 0, max = QDMA_QUEUES * QDMA_BLOCKS; + uint32_t i, k; - for (i = 0; i < max; i++) { - struct fsl_qdma_chan *fsl_chan = &fsl_qdma->chans[i]; - - if (fsl_chan->free == false) - dma_release(fsl_chan); + for (i = 0; i < fsl_qdma->num_blocks; i++) { + for (k = (i * QDMA_QUEUES); k < ((i * QDMA_QUEUES) + QDMA_QUEUES); k++) + fsl_qdma_free_queue_resources(fsl_qdma->queue[k]); + fsl_qdma_free_status_queue(fsl_qdma->status[i]); } + rte_free(fsl_qdma->queue); rte_free(fsl_qdma->status); - rte_free(fsl_qdma->chans); (void)rte_dma_pmd_release(dpaa_dev->device.name); diff --git a/drivers/dma/dpaa/dpaa_qdma.h b/drivers/dma/dpaa/dpaa_qdma.h index 8cb4042bd0..80366ce890 100644 --- a/drivers/dma/dpaa/dpaa_qdma.h +++ b/drivers/dma/dpaa/dpaa_qdma.h @@ -107,6 +107,9 @@ #define QDMA_BLOCKS 4 #define QDMA_QUEUES 8 #define QDMA_DELAY 1000 +#define QDMA_SGF_SRC_OFF 2 +#define QDMA_SGF_DST_OFF 3 +#define QDMA_DESC_OFF 1 #define QDMA_BIG_ENDIAN 1 #ifdef QDMA_BIG_ENDIAN @@ -157,55 +160,31 @@ struct fsl_qdma_ddf { __le32 cmd; }; -struct fsl_qdma_chan { - struct fsl_qdma_engine *qdma; - struct fsl_qdma_queue *queue; - bool free; - struct list_head list; -}; - struct fsl_qdma_queue { struct fsl_qdma_format *virt_head; - struct list_head comp_used; - struct list_head comp_free; - dma_addr_t bus_addr; - u32 n_cq; - u32 id; - u32 count; - u32 pending; + void **virt_addr; + u8 ci; + u8 n_cq; + u8 id; + void *queue_base; struct fsl_qdma_format *cq; - void *block_base; struct rte_dma_stats stats; -}; - -struct fsl_qdma_comp { + u8 pending; dma_addr_t bus_addr; - dma_addr_t desc_bus_addr; - void *virt_addr; - void *desc_virt_addr; - struct fsl_qdma_chan *qchan; - dma_call_back call_back_func; - void *params; - struct list_head list; + void **desc_virt_addr; }; struct fsl_qdma_engine { - int desc_allocated; void *ctrl_base; void *status_base; void *block_base; - u32 n_chans; u32 n_queues; - int error_irq; - struct fsl_qdma_queue *queue; + struct fsl_qdma_queue **queue; struct fsl_qdma_queue **status; - struct fsl_qdma_chan *chans; u32 num_blocks; u8 free_block_id; u32 vchan_map[4]; int block_offset; }; -static rte_atomic32_t wait_task[CORE_NUMBER]; - #endif /* _DPAA_QDMA_H_ */