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 362EA45B40; Tue, 15 Oct 2024 09:14:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5623540664; Tue, 15 Oct 2024 09:14:35 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2084.outbound.protection.outlook.com [40.107.21.84]) by mails.dpdk.org (Postfix) with ESMTP id CC418402EF for ; Tue, 15 Oct 2024 09:14:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EtEkbr6nlJfeOkQFx9Z1uvBsZV/CmWiEsUJK4nCTPjFJ0qz7wCC0P5plCRdGbbt48lM+nuqbKkfsaUOXNVuaF/KpXNBXeBgxeXoNmMOJGDnPZGZTfcV55/SaYntWU9M+CyxVWG+iVPZmlHe9sQL9nNo8nK69vGI9AXpqRGjYUKQ3f9Jg2muEnMtGQfKgvzSYC0iwRaRIJaU3qjjoIdOE5qdyHqYZlj2RSOqVXc7syr+hTyu7QhSuktXUfUyP/aPyDVH5OCWN1hSjVj2sp4VyelMmeeve5rX/U5ib3Qlpv6bEsKLLc95j6jC7aNzjbDIXIGNYJbqYx742rlrEeXn3sw== 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=khJMspZI6PELwtZOsWD+9VUUrYJhCVbECO3Zx182C7I=; b=qS/rZFKKIdwhYoghxWxPmPHzlexl29n5Ac8KaVX+4gHgq7SZWP4v1aIsxW7qCCE5OOeEO4u4icNqduBzOkrrk3fcqMKlDv/j3jbzxpNcyftlB4hIdGcBHfQ10zZlHKxeGox/xnYGLQ6/RUF2Mz0L/q5wfNLN4jb9Z+0b+V5yuGzBXyRsHNbujXF7I9ouZP0pOH8wSUXRui0j2+M+zP3ocm4LfXNVXGbXiCjcPJt7pdCjBWvdt2uZ9iSjwBcjFAbQpDwKTfXfIO3K91IIaP1P2jL+kVOd28iSn2ni9K1ZiTcLhsfAFOxnA8b2LnzDrjoxNDq4+j/LMlovBKu4ZngSHg== 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=khJMspZI6PELwtZOsWD+9VUUrYJhCVbECO3Zx182C7I=; b=d+r3zMC1GpRPhRafyYZMRJck+cw9X50PXX23g1nEw19WzmRR1xxK4+pVNPnzi8MsEWsyqVxEr59SZ6i2G8VlDN+GkQgNd2lmWzPLbvltT5/mC4EGz2Rt6/KfKe9nF5esO1dVHtLJK9ycr4d7lUm/HP5SX+QIvx9f9zE7bghI5R8j+EPTgLWieYBgL/+1i4Sq1pa5norSA2jPmJn4myennCC9dwekguLHBN+qqpoB+dN38uhVHWJtQSiAj6HxG3RuVPKteioNhDzI/P5gikHniw2t/W/ae5MsDSZK/UujCWAGL4Be0rjLblBms6UtBrWtFe6qhpryoL+Y2eRi5EW6Bg== 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 AM9PR04MB7522.eurprd04.prod.outlook.com (2603:10a6:20b:282::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.22; Tue, 15 Oct 2024 07:14:25 +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.8048.020; Tue, 15 Oct 2024 07:14:25 +0000 From: Gagandeep Singh To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena Cc: Jun Yang Subject: [v7 03/15] bus/fslmc: enhance the qbman dq storage logic Date: Tue, 15 Oct 2024 12:43:51 +0530 Message-Id: <20241015071403.1940833-4-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241015071403.1940833-1-g.singh@nxp.com> References: <20241014093639.553467-1-g.singh@nxp.com> <20241015071403.1940833-1-g.singh@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR02CA0058.apcprd02.prod.outlook.com (2603:1096:4:54::22) To AS8PR04MB8198.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8198:EE_|AM9PR04MB7522:EE_ X-MS-Office365-Filtering-Correlation-Id: 8914e5a7-d05f-454e-b8e9-08dcece90025 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?KxhaSuPGR4fU0IUEUR0eXBo9uRRYvQPiVBRLiEAKM5ZOgo4jrQ3rOIha7CpN?= =?us-ascii?Q?CZqR02sGU8nnIuBDstCoY0DL9FsYNMXJ59rf772+rnuOcktsdhK54SkLgsnB?= =?us-ascii?Q?aVVAZS4MG0W9y6ynvqJWiF6QHB1ekS8Q7UR6gRrHBzucM9lW2xegURKyODm9?= =?us-ascii?Q?pwSWoAG/J4lanBvnDs94th5GjKsXF6uCAKqUuYpxx2VDD00SFT/g9g+U1eq4?= =?us-ascii?Q?zJ+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yi75RiypTv37rT?= =?us-ascii?Q?WIt4WVNggTtoA7lhgiUgnC+jLBhfZmSJ3+BMkme78B3Gwj7CguddcUmP8olj?= =?us-ascii?Q?eyhKzWsg70rio5Ul39sePBQS5/1vcl2S6BCN4jK+GfVhl/WWktcWCVV8rcms?= =?us-ascii?Q?1d0iRYObyBwERWKtrpYN4+ht5YbEJBtptl5xKvrpp33aEi5TTJbOB5ru0RL/?= =?us-ascii?Q?q82dgYd2kzXOsF7GkXFPwnypo0GMiX9sP6yTkH1t0yGrSw=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)(52116014)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?I9W3mJU/VNnL8EnaGMaHQ2dc5a6eF1cJkPlxKKxDyrf6+v2W+JHPEzuuAa6s?= =?us-ascii?Q?+OUEeDfYZoXhbxvl8VZqr3dHolXH7FuUnRdXwI94PwZF8sXmkf5SGdExzIoo?= =?us-ascii?Q?44CCLU8F3PqtyoyqrJrJEK/8Rq9+VpnFEQ0D67Dv61i53YV+GOGUTkX0yNCH?= =?us-ascii?Q?7C2v+gn8sYipyqg+nf6XWua2RYGZy8F5k96Yz4N6dq8/lHdi9WRITu/6A57F?= =?us-ascii?Q?c3+uYfdB1K7GArJWqczCMrUjMSWjuo+ir82P2zWF01Q/EHWRSwuMhuVDLKEe?= =?us-ascii?Q?/zB14TIbDr58QVqBcDHKC2/iaYAdWajty/wg2r77veIUaevzeNMYYzbb7XsY?= =?us-ascii?Q?XRdgD2luVnWF+ArhGfL924lzx0wj9X2R1OmjxC9d9P0KCTBZsHEHsqPbvJ/k?= =?us-ascii?Q?smbbYNeJAint8E1Gt4lvxHc5iIE0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BGL4kcgPQb3oOMOJpEUVB6waBDcR/WuddlOV1FhH5n6lPuJtgFWHcQ8/49aF?= =?us-ascii?Q?MPnLWbT6pAZnfVSeYMIP9imnwYvyRW/w0eHNy2kEOo1/SXuvJL68N1iXitNh?= =?us-ascii?Q?IcmQB3W3Q4O5wM4BuRs4ToTxeitZ9sX/MmhWTfV+V+Xy4k956GuE2TJwD/jj?= =?us-ascii?Q?ZsrDButq2kiE+ctVzUq1IRgiMB/Mp+XV0TZqk9nFzUNWRzhfOLwKNZHc/4+x?= =?us-ascii?Q?46JdFSsEVL9HeWg+zJKhxWEAPDTd9VBi700Cgz70?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8914e5a7-d05f-454e-b8e9-08dcece90025 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8198.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 07:14:25.5544 (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: xdNNbb8HmUaK7wqKQA5yGQJSOzZMh/zxMR2GvklnZ/ZyAkbwxlycoP/rKu+nby0t X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7522 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 Multiple DQ storages are used among multiple cores, the single dq storage of first union is leak if multiple storages are allocated. It does not make sense to keep the single dq storage of union, remove it and reuse the first dq storage of multiple storages for this case. Signed-off-by: Jun Yang --- drivers/bus/fslmc/portal/dpaa2_hw_dpci.c | 25 ++----- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 7 +- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 38 +++++++++- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 23 ++---- drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c | 4 +- drivers/dma/dpaa2/dpaa2_qdma.c | 41 ++--------- drivers/net/dpaa2/dpaa2_ethdev.c | 81 ++++++++------------- drivers/net/dpaa2/dpaa2_rxtx.c | 19 +++-- drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c | 4 +- 9 files changed, 102 insertions(+), 140 deletions(-) diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c index 7e858a113f..160126f6d6 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c @@ -81,22 +81,10 @@ rte_dpaa2_create_dpci_device(int vdev_fd __rte_unused, } /* Allocate DQ storage for the DPCI Rx queues */ - rxq = &(dpci_node->rx_queue[i]); - rxq->q_storage = rte_malloc("dq_storage", - sizeof(struct queue_storage_info_t), - RTE_CACHE_LINE_SIZE); - if (!rxq->q_storage) { - DPAA2_BUS_ERR("q_storage allocation failed"); - ret = -ENOMEM; + rxq = &dpci_node->rx_queue[i]; + ret = dpaa2_queue_storage_alloc(rxq, 1); + if (ret) goto err; - } - - memset(rxq->q_storage, 0, sizeof(struct queue_storage_info_t)); - ret = dpaa2_alloc_dq_storage(rxq->q_storage); - if (ret) { - DPAA2_BUS_ERR("dpaa2_alloc_dq_storage failed"); - goto err; - } } /* Enable the device */ @@ -141,12 +129,9 @@ rte_dpaa2_create_dpci_device(int vdev_fd __rte_unused, err: for (i = 0; i < DPAA2_DPCI_MAX_QUEUES; i++) { - struct dpaa2_queue *rxq = &(dpci_node->rx_queue[i]); + struct dpaa2_queue *rxq = &dpci_node->rx_queue[i]; - if (rxq->q_storage) { - dpaa2_free_dq_storage(rxq->q_storage); - rte_free(rxq->q_storage); - } + dpaa2_queue_storage_free(rxq, 1); } rte_free(dpci_node); diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c index 4aec7b2cd8..a8afc772fd 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c @@ -574,6 +574,7 @@ dpaa2_free_dq_storage(struct queue_storage_info_t *q_storage) for (i = 0; i < NUM_DQS_PER_QUEUE; i++) { rte_free(q_storage->dq_storage[i]); + q_storage->dq_storage[i] = NULL; } } @@ -583,7 +584,7 @@ dpaa2_alloc_dq_storage(struct queue_storage_info_t *q_storage) int i = 0; for (i = 0; i < NUM_DQS_PER_QUEUE; i++) { - q_storage->dq_storage[i] = rte_malloc(NULL, + q_storage->dq_storage[i] = rte_zmalloc(NULL, dpaa2_dqrr_size * sizeof(struct qbman_result), RTE_CACHE_LINE_SIZE); if (!q_storage->dq_storage[i]) @@ -591,8 +592,10 @@ dpaa2_alloc_dq_storage(struct queue_storage_info_t *q_storage) } return 0; fail: - while (--i >= 0) + while (--i >= 0) { rte_free(q_storage->dq_storage[i]); + q_storage->dq_storage[i] = NULL; + } return -1; } diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h index 4c30e6db18..0e53ab9d8f 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2016-2021 NXP + * Copyright 2016-2024 NXP * */ @@ -165,7 +165,9 @@ struct __rte_cache_aligned dpaa2_queue { uint64_t tx_pkts; uint64_t err_pkts; union { - struct queue_storage_info_t *q_storage; + /**Ingress*/ + struct queue_storage_info_t *q_storage[RTE_MAX_LCORE]; + /**Egress*/ struct qbman_result *cscn; }; struct rte_event ev; @@ -187,6 +189,38 @@ struct swp_active_dqs { uint64_t reserved[7]; }; +#define dpaa2_queue_storage_alloc(q, num) \ +({ \ + int ret = 0, i; \ + \ + for (i = 0; i < (num); i++) { \ + (q)->q_storage[i] = rte_zmalloc(NULL, \ + sizeof(struct queue_storage_info_t), \ + RTE_CACHE_LINE_SIZE); \ + if (!(q)->q_storage[i]) { \ + ret = -ENOBUFS; \ + break; \ + } \ + ret = dpaa2_alloc_dq_storage((q)->q_storage[i]); \ + if (ret) \ + break; \ + } \ + ret; \ +}) + +#define dpaa2_queue_storage_free(q, num) \ +({ \ + int i; \ + \ + for (i = 0; i < (num); i++) { \ + if ((q)->q_storage[i]) { \ + dpaa2_free_dq_storage((q)->q_storage[i]); \ + rte_free((q)->q_storage[i]); \ + (q)->q_storage[i] = NULL; \ + } \ + } \ +}) + #define NUM_MAX_SWP 64 extern struct swp_active_dqs rte_global_active_dqs_list[NUM_MAX_SWP]; diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index b34183d594..fda08ba0b1 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -1932,7 +1932,7 @@ dpaa2_sec_dequeue_burst(void *qp, struct rte_crypto_op **ops, } } swp = DPAA2_PER_LCORE_PORTAL; - dq_storage = dpaa2_qp->rx_vq.q_storage->dq_storage[0]; + dq_storage = dpaa2_qp->rx_vq.q_storage[0]->dq_storage[0]; qbman_pull_desc_clear(&pulldesc); qbman_pull_desc_set_numframes(&pulldesc, @@ -2023,10 +2023,7 @@ dpaa2_sec_queue_pair_release(struct rte_cryptodev *dev, uint16_t queue_pair_id) PMD_INIT_FUNC_TRACE(); - if (qp->rx_vq.q_storage) { - dpaa2_free_dq_storage(qp->rx_vq.q_storage); - rte_free(qp->rx_vq.q_storage); - } + dpaa2_queue_storage_free(&qp->rx_vq, 1); rte_mempool_free(qp->fle_pool); rte_free(qp); @@ -2077,18 +2074,10 @@ dpaa2_sec_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id, qp->rx_vq.crypto_data = dev->data; qp->tx_vq.crypto_data = dev->data; - qp->rx_vq.q_storage = rte_malloc("sec dq storage", - sizeof(struct queue_storage_info_t), - RTE_CACHE_LINE_SIZE); - if (!qp->rx_vq.q_storage) { - DPAA2_SEC_ERR("malloc failed for q_storage"); - return -ENOMEM; - } - memset(qp->rx_vq.q_storage, 0, sizeof(struct queue_storage_info_t)); - - if (dpaa2_alloc_dq_storage(qp->rx_vq.q_storage)) { - DPAA2_SEC_ERR("Unable to allocate dequeue storage"); - return -ENOMEM; + retcode = dpaa2_queue_storage_alloc((&qp->rx_vq), 1); + if (retcode) { + dpaa2_queue_storage_free((&qp->rx_vq), 1); + return retcode; } dev->data->queue_pairs[qp_id] = qp; diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c index 883584a6e2..fb0408f8ad 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2021-2022 NXP + * Copyright 2021-2022, 2024 NXP */ #include @@ -853,7 +853,7 @@ dpaa2_sec_raw_dequeue_burst(void *qp_data, uint8_t *drv_ctx, } } swp = DPAA2_PER_LCORE_PORTAL; - dq_storage = dpaa2_qp->rx_vq.q_storage->dq_storage[0]; + dq_storage = dpaa2_qp->rx_vq.q_storage[0]->dq_storage[0]; qbman_pull_desc_clear(&pulldesc); qbman_pull_desc_set_numframes(&pulldesc, diff --git a/drivers/dma/dpaa2/dpaa2_qdma.c b/drivers/dma/dpaa2/dpaa2_qdma.c index e364cc8f3d..ee110741b7 100644 --- a/drivers/dma/dpaa2/dpaa2_qdma.c +++ b/drivers/dma/dpaa2/dpaa2_qdma.c @@ -854,7 +854,7 @@ dpaa2_qdma_dequeue(void *dev_private, dpaa2_dqrr_size : nb_cpls; rxq = &(dpdmai_dev->rx_queue[qdma_vq->vq_id]); fqid = rxq->fqid; - q_storage = rxq->q_storage; + q_storage = rxq->q_storage[0]; if (unlikely(!q_storage->active_dqs)) { q_storage->toggle = 0; @@ -1062,13 +1062,7 @@ dpaa2_qdma_configure(struct rte_dma_dev *dev, qdma_dev->vqs[i].ring_cntx_idx = NULL; } rxq = &dpdmai_dev->rx_queue[i]; - if (rxq->q_storage) { - DPAA2_QDMA_DEBUG("%s rxq[%d] re-configure", - dev->data->dev_name, i); - dpaa2_free_dq_storage(rxq->q_storage); - rte_free(rxq->q_storage); - rxq->q_storage = NULL; - } + dpaa2_queue_storage_free(rxq, 1); } rte_free(qdma_dev->vqs); qdma_dev->vqs = NULL; @@ -1124,24 +1118,9 @@ dpaa2_qdma_configure(struct rte_dma_dev *dev, qdma_dev->vqs[i].vq_id = i; rxq = &dpdmai_dev->rx_queue[i]; /* Allocate DQ storage for the DPDMAI Rx queues */ - rxq->q_storage = rte_zmalloc(NULL, - sizeof(struct queue_storage_info_t), - RTE_CACHE_LINE_SIZE); - if (!rxq->q_storage) { - DPAA2_QDMA_ERR("%s Q[%d] storage alloc failed", - dev->data->dev_name, i); - ret = -ENOMEM; - goto alloc_failed; - } - - memset(rxq->q_storage, 0, sizeof(struct queue_storage_info_t)); - ret = dpaa2_alloc_dq_storage(rxq->q_storage); - if (ret) { - DPAA2_QDMA_ERR("%s Q[%d] dq storage alloc failed", - dev->data->dev_name, i); - ret = -ENOMEM; + ret = dpaa2_queue_storage_alloc(rxq, 1); + if (ret) goto alloc_failed; - } } qdma_dev->num_vqs = dev_conf->nb_vchans; @@ -1152,11 +1131,7 @@ dpaa2_qdma_configure(struct rte_dma_dev *dev, alloc_failed: for (i = 0; i < dev_conf->nb_vchans; i++) { rxq = &dpdmai_dev->rx_queue[i]; - if (rxq->q_storage) { - dpaa2_free_dq_storage(rxq->q_storage); - rte_free(rxq->q_storage); - rxq->q_storage = NULL; - } + dpaa2_queue_storage_free(rxq, 1); } rte_free(qdma_dev->vqs); @@ -1350,11 +1325,7 @@ dpaa2_qdma_close(struct rte_dma_dev *dev) /* Free RXQ storages */ for (i = 0; i < qdma_dev->num_vqs; i++) { rxq = &dpdmai_dev->rx_queue[i]; - if (rxq->q_storage) { - dpaa2_free_dq_storage(rxq->q_storage); - rte_free(rxq->q_storage); - rxq->q_storage = NULL; - } + dpaa2_queue_storage_free(rxq, 1); } if (qdma_dev->vqs) { diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 7b3e587a8d..93b88acef8 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2016-2021 NXP + * Copyright 2016-2024 NXP * */ @@ -366,7 +366,7 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev) uint8_t num_rxqueue_per_tc; struct dpaa2_queue *mc_q, *mcq; uint32_t tot_queues; - int i; + int i, ret = 0; struct dpaa2_queue *dpaa2_q; PMD_INIT_FUNC_TRACE(); @@ -386,16 +386,10 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev) for (i = 0; i < priv->nb_rx_queues; i++) { mc_q->eth_data = dev->data; priv->rx_vq[i] = mc_q++; - dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i]; - dpaa2_q->q_storage = rte_malloc("dq_storage", - sizeof(struct queue_storage_info_t), - RTE_CACHE_LINE_SIZE); - if (!dpaa2_q->q_storage) - goto fail; - - memset(dpaa2_q->q_storage, 0, - sizeof(struct queue_storage_info_t)); - if (dpaa2_alloc_dq_storage(dpaa2_q->q_storage)) + dpaa2_q = priv->rx_vq[i]; + ret = dpaa2_queue_storage_alloc(dpaa2_q, + RTE_MAX_LCORE); + if (ret) goto fail; } @@ -405,19 +399,11 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev) if (!priv->rx_err_vq) goto fail; - dpaa2_q = (struct dpaa2_queue *)priv->rx_err_vq; - dpaa2_q->q_storage = rte_malloc("err_dq_storage", - sizeof(struct queue_storage_info_t) * - RTE_MAX_LCORE, - RTE_CACHE_LINE_SIZE); - if (!dpaa2_q->q_storage) + dpaa2_q = priv->rx_err_vq; + ret = dpaa2_queue_storage_alloc(dpaa2_q, + RTE_MAX_LCORE); + if (ret) goto fail; - - memset(dpaa2_q->q_storage, 0, - sizeof(struct queue_storage_info_t)); - for (i = 0; i < RTE_MAX_LCORE; i++) - if (dpaa2_alloc_dq_storage(&dpaa2_q->q_storage[i])) - goto fail; } for (i = 0; i < priv->nb_tx_queues; i++) { @@ -438,24 +424,17 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev) mc_q->tc_index = i; mc_q->flow_id = 0; priv->tx_conf_vq[i] = mc_q++; - dpaa2_q = (struct dpaa2_queue *)priv->tx_conf_vq[i]; - dpaa2_q->q_storage = - rte_malloc("dq_storage", - sizeof(struct queue_storage_info_t), - RTE_CACHE_LINE_SIZE); - if (!dpaa2_q->q_storage) - goto fail_tx_conf; - - memset(dpaa2_q->q_storage, 0, - sizeof(struct queue_storage_info_t)); - if (dpaa2_alloc_dq_storage(dpaa2_q->q_storage)) + dpaa2_q = priv->tx_conf_vq[i]; + ret = dpaa2_queue_storage_alloc(dpaa2_q, + RTE_MAX_LCORE); + if (ret) goto fail_tx_conf; } } vq_id = 0; for (dist_idx = 0; dist_idx < priv->nb_rx_queues; dist_idx++) { - mcq = (struct dpaa2_queue *)priv->rx_vq[vq_id]; + mcq = priv->rx_vq[vq_id]; mcq->tc_index = dist_idx / num_rxqueue_per_tc; mcq->flow_id = dist_idx % num_rxqueue_per_tc; vq_id++; @@ -465,15 +444,15 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev) fail_tx_conf: i -= 1; while (i >= 0) { - dpaa2_q = (struct dpaa2_queue *)priv->tx_conf_vq[i]; - rte_free(dpaa2_q->q_storage); + dpaa2_q = priv->tx_conf_vq[i]; + dpaa2_queue_storage_free(dpaa2_q, RTE_MAX_LCORE); priv->tx_conf_vq[i--] = NULL; } i = priv->nb_tx_queues; fail_tx: i -= 1; while (i >= 0) { - dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i]; + dpaa2_q = priv->tx_vq[i]; rte_free(dpaa2_q->cscn); priv->tx_vq[i--] = NULL; } @@ -482,17 +461,14 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev) i -= 1; mc_q = priv->rx_vq[0]; while (i >= 0) { - dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i]; - dpaa2_free_dq_storage(dpaa2_q->q_storage); - rte_free(dpaa2_q->q_storage); + dpaa2_q = priv->rx_vq[i]; + dpaa2_queue_storage_free(dpaa2_q, RTE_MAX_LCORE); priv->rx_vq[i--] = NULL; } if (dpaa2_enable_err_queue) { - dpaa2_q = (struct dpaa2_queue *)priv->rx_err_vq; - if (dpaa2_q->q_storage) - dpaa2_free_dq_storage(dpaa2_q->q_storage); - rte_free(dpaa2_q->q_storage); + dpaa2_q = priv->rx_err_vq; + dpaa2_queue_storage_free(dpaa2_q, RTE_MAX_LCORE); } rte_free(mc_q); @@ -512,20 +488,21 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev) if (priv->rx_vq[0]) { /* cleaning up queue storage */ for (i = 0; i < priv->nb_rx_queues; i++) { - dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i]; - rte_free(dpaa2_q->q_storage); + dpaa2_q = priv->rx_vq[i]; + dpaa2_queue_storage_free(dpaa2_q, + RTE_MAX_LCORE); } /* cleanup tx queue cscn */ for (i = 0; i < priv->nb_tx_queues; i++) { - dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i]; + dpaa2_q = priv->tx_vq[i]; rte_free(dpaa2_q->cscn); } if (priv->flags & DPAA2_TX_CONF_ENABLE) { /* cleanup tx conf queue storage */ for (i = 0; i < priv->nb_tx_queues; i++) { - dpaa2_q = (struct dpaa2_queue *) - priv->tx_conf_vq[i]; - rte_free(dpaa2_q->q_storage); + dpaa2_q = priv->tx_conf_vq[i]; + dpaa2_queue_storage_free(dpaa2_q, + RTE_MAX_LCORE); } } /*free memory for all queues (RX+TX) */ diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c index 92e9dd40dc..376291af04 100644 --- a/drivers/net/dpaa2/dpaa2_rxtx.c +++ b/drivers/net/dpaa2/dpaa2_rxtx.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2016-2021 NXP + * Copyright 2016-2024 NXP * */ @@ -647,7 +647,7 @@ dump_err_pkts(struct dpaa2_queue *dpaa2_q) } swp = DPAA2_PER_LCORE_PORTAL; - dq_storage = dpaa2_q->q_storage[lcore_id].dq_storage[0]; + dq_storage = dpaa2_q->q_storage[lcore_id]->dq_storage[0]; qbman_pull_desc_clear(&pulldesc); qbman_pull_desc_set_fq(&pulldesc, fqid); qbman_pull_desc_set_storage(&pulldesc, dq_storage, @@ -716,7 +716,7 @@ uint16_t dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) { /* Function receive frames for a given device and VQ*/ - struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue; + struct dpaa2_queue *dpaa2_q = queue; struct qbman_result *dq_storage, *dq_storage1 = NULL; uint32_t fqid = dpaa2_q->fqid; int ret, num_rx = 0, pull_size; @@ -724,10 +724,12 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) struct qbman_swp *swp; const struct qbman_fd *fd; struct qbman_pull_desc pulldesc; - struct queue_storage_info_t *q_storage = dpaa2_q->q_storage; + struct queue_storage_info_t *q_storage; struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data; struct dpaa2_dev_priv *priv = eth_data->dev_private; + q_storage = dpaa2_q->q_storage[rte_lcore_id()]; + if (unlikely(dpaa2_enable_err_queue)) dump_err_pkts(priv->rx_err_vq); @@ -958,7 +960,7 @@ uint16_t dpaa2_dev_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) { /* Function receive frames for a given device and VQ */ - struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue; + struct dpaa2_queue *dpaa2_q = queue; struct qbman_result *dq_storage; uint32_t fqid = dpaa2_q->fqid; int ret, num_rx = 0, next_pull = nb_pkts, num_pulled; @@ -984,7 +986,7 @@ dpaa2_dev_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) swp = DPAA2_PER_LCORE_PORTAL; do { - dq_storage = dpaa2_q->q_storage->dq_storage[0]; + dq_storage = dpaa2_q->q_storage[0]->dq_storage[0]; qbman_pull_desc_clear(&pulldesc); qbman_pull_desc_set_fq(&pulldesc, fqid); qbman_pull_desc_set_storage(&pulldesc, dq_storage, @@ -1115,7 +1117,7 @@ uint16_t dpaa2_dev_tx_conf(void *queue) swp = DPAA2_PER_LCORE_PORTAL; do { - dq_storage = dpaa2_q->q_storage->dq_storage[0]; + dq_storage = dpaa2_q->q_storage[0]->dq_storage[0]; qbman_pull_desc_clear(&pulldesc); qbman_pull_desc_set_fq(&pulldesc, fqid); qbman_pull_desc_set_storage(&pulldesc, dq_storage, @@ -1954,12 +1956,13 @@ dpaa2_dev_loopback_rx(void *queue, struct qbman_fd *fd[DPAA2_LX2_DQRR_RING_SIZE]; struct qbman_pull_desc pulldesc; struct qbman_eq_desc eqdesc; - struct queue_storage_info_t *q_storage = dpaa2_q->q_storage; + struct queue_storage_info_t *q_storage; struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data; struct dpaa2_dev_priv *priv = eth_data->dev_private; struct dpaa2_queue *tx_q = priv->tx_vq[0]; /* todo - currently we are using 1st TX queue only for loopback*/ + q_storage = dpaa2_q->q_storage[rte_lcore_id()]; if (unlikely(!DPAA2_PER_LCORE_ETHRX_DPIO)) { ret = dpaa2_affine_qbman_ethrx_swp(); if (ret) { diff --git a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c index de8c024abb..34a3c4f6af 100644 --- a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c +++ b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2018-2019 NXP + * Copyright 2018-2019, 2024 NXP */ #include @@ -142,7 +142,7 @@ dpaa2_cmdif_dequeue_bufs(struct rte_rawdev *dev, cmdif_rcv_cnxt = (struct rte_dpaa2_cmdif_context *)(context); rxq = &(cidev->rx_queue[cmdif_rcv_cnxt->priority]); - dq_storage = rxq->q_storage->dq_storage[0]; + dq_storage = rxq->q_storage[0]->dq_storage[0]; qbman_pull_desc_clear(&pulldesc); qbman_pull_desc_set_fq(&pulldesc, rxq->fqid); -- 2.25.1