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 8E9B34567F; Mon, 22 Jul 2024 13:59:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D7403402AE; Mon, 22 Jul 2024 13:59:20 +0200 (CEST) Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013012.outbound.protection.outlook.com [52.101.67.12]) by mails.dpdk.org (Postfix) with ESMTP id E4A77402D1 for ; Mon, 22 Jul 2024 13:59:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zC1e3qsRWVH1W6UjidpBO0ixriPno4pALdqKQCdRADRIm9RjphVqKguXncvExpPUhsdsY1z4EMnFEH5T/RuHkV91Jn1X+Rv5FbhR0OmFHPitH6CJ7c5HTGwQPCw2/O3doaUfSYUEz7aTY10BfQOzbXxbqrun3AXLjvw+5Z8Ftj8sSVE77uJ81XCdrMn/lIrGTuRsqFC6XYS/QwOdwfdXhVx0LzawTiFhSjeHjy2NTFqadTdTO1J51npSipqJKxANBq7P6mOC/JaK+M42HZoHZ9jtDuFLNubyHFyxP6GUmtNxu0Eq6zEdQQnQHNhG/RgX0ApDcFI7d5doUmVM71XipQ== 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=wrC9d/vCWiKusJC1WvvgXdLXfKL+EzvDi15qvtekvWg=; b=uKWsOIn+okW044TLQyo71v7estLltBXxoHdhgCwKh9yapH+cbVAKA1hzI/4h70ItEDt/b010XGFTIYtmQXz+W3B/DvpgmVjCYSc7jwWHLDlrcJIsni1cOr21+eKcnV5FryM5UqS1y/3X+Vvf6C1/d7B2A/qVT3X50H30HLNCHMeWkZqbHRAi0CcPJK3J5JRpUiorOXkxlkfA6zeBtgktdWD0uQBXFAz/7H/qxEqYb+QY5g3AWiclM5w6My7XzLlXE5+H9P55NGxMVNkvOeKE/jHItQMCagfYFoN9zZhTrrT+Z6btz7MRb2fFg0wtFxwySED3YRiV+e5jfqaqtB3X6Q== 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=wrC9d/vCWiKusJC1WvvgXdLXfKL+EzvDi15qvtekvWg=; b=OYwGahmYjoSlGc2EPhQO0+/+9ZE1EvvnPn2QuBJVWuK4PVtJLDrnQ9KWGCi5BmhrVyV7vPC5GKX93C1+/Wlug80AwODoa5C8o5v1ZNylQWYn8djCOxFq5UjraUZTIL7xyYcNSPl1eVJaur1v+ClZOGgFQNSj8/6MTGp6SNH4x5Q= 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 AM8PR04MB7970.eurprd04.prod.outlook.com (2603:10a6:20b:24f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Mon, 22 Jul 2024 11:59:16 +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 11:59:16 +0000 From: Gagandeep Singh To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena Cc: Jun Yang Subject: [v2 08/30] bus/fslmc: enhance the qbman dq storage logic Date: Mon, 22 Jul 2024 17:28:21 +0530 Message-Id: <20240722115843.1830105-9-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240722115843.1830105-1-g.singh@nxp.com> References: <20240719100126.1150373-1-g.singh@nxp.com> <20240722115843.1830105-1-g.singh@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR02CA0025.apcprd02.prod.outlook.com (2603:1096:4:195::21) To AS8SPR01MB0024.eurprd04.prod.outlook.com (2603:10a6:20b:3d0::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8SPR01MB0024:EE_|AM8PR04MB7970:EE_ X-MS-Office365-Filtering-Correlation-Id: b32a0686-a8c2-4a53-76b0-08dcaa45b5b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?niTqpS1cdE+b4ZUxnCEkP+4kP4k7hNuS4QLmmsDtoTDBjJNPXOBSJlF7IkTQ?= =?us-ascii?Q?u8eA//dQrlnlDUi4YYADdLlL8zbAajKgKPms2EW5uo7h8YG1tvlr/9D8n1xp?= =?us-ascii?Q?5maSFggjNma8nC9LGcW+4IJvE/Ybdgn7fLPL6MfwczfnctqhkXsdwgcj2oB7?= =?us-ascii?Q?PMFJ1f2izrZ53uZbl9nskdYwaKVJjt+L0yhdkr4O1a1ith9DCCYeIGTa+9ar?= =?us-ascii?Q?p/UEW+Fj+nh8yQEHbRxilXYZZxZahPfmBGiuzGzQoqFcv0+oNrVxAF9ZE2um?= =?us-ascii?Q?Hz8vRMYuK/IblkUCLUtAZcxaYIOVJD9gWI3Je6mYP+FLDHY++PUtZRsswJmJ?= =?us-ascii?Q?vnoaUAV/Ts3zcbma/JPstHvj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?us-ascii?Q?ItsYRaljCOqzI+8j6S1UkzdAbRflU1NTzyu4Kcd4vQwUmG14AsM2FY6oyJdj?= =?us-ascii?Q?Ffn43DQ/mO7HSdElBUJ1wBWLpwuqLOVbqu/t3D0L5cHqrWf/Bm19s9tdIZp+?= =?us-ascii?Q?7Cs9oXw9G8PuPVIIVZmodPAfZKHYqNRWAd6dC/A1Ts0isYZBpQ=3D=3D?= 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)(1800799024)(366016)(52116014)(376014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?nKggeV3WJm86Zw37IdXrf3XzXcd3sbTbje1kfK1L0cjpW6M1frA2LGnIT2BS?= =?us-ascii?Q?Ro0pFUVCgmbnGsbO7CsSVHzFN43bPwDKgY9AqQ97maBvEPtmDbasHUY/eZ4g?= =?us-ascii?Q?tm6w5GdIf0n8bdRIJSeivIvEDu2M2mP3Dl2ToehoJfQU7KJF/SqOaYaaKCCp?= =?us-ascii?Q?Gr+U2Zs5ROFziDvZd9F+U8O+XBK09aWC5Tt9sr2D/rtzSwhrikZDE8IC1Wi3?= =?us-ascii?Q?pH2Ikk2bYWhaZ4ZLYSLv6IHTLbWRsgFYxWSv7xBLc8kgmq8nhe2q4JSbOIJW?= =?us-ascii?Q?UYAFrgh+qohSl133p3g/Ng7mUrXwGFLeNsaPa7SZA2Q4aaZJrmM/tApR5Bt6?= =?us-ascii?Q?GHKU8kweUPkXfMsBvnyKiEItyAd+nXB+ItiGEdRxfktfRu/ZarrMGoi4mhB8?= =?us-ascii?Q?e6qcVxDxu1+wXWTJKtLYcByTSbHBd7ezbZ69MUTUTa8VgP0SelFLUm124slQ?= =?us-ascii?Q?whTMFiXrOeCO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jpCiZhpK?= =?us-ascii?Q?u4smuBOnqszc0VxpV6QHewqooEfNxuNSVJyyva7siHTwTL9MHVWU7QxosrUL?= =?us-ascii?Q?oKG+SVkZu8hCBffd6tXYkdxdgVBKIuiv/6SGLzFFcFYAOGrzQAB/6lZtr9VS?= =?us-ascii?Q?ZBi25C/MccxEIoOxOD1C6VggDMr2m2xGn9K4BK6oIF11ViyhfWT8We/IF8Tm?= =?us-ascii?Q?no818OvyISfSHSEmjRRBOxhxew5NdeNBRBik5NAV?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b32a0686-a8c2-4a53-76b0-08dcaa45b5b8 X-MS-Exchange-CrossTenant-AuthSource: AS8SPR01MB0024.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2024 11:59:16.0075 (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: ezABHDty/rL0guuTSRlLvoXk6X32xHuaK0GcWdtEHVVP0qoeQz79HwKCHX9N+OuU X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7970 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 | 43 ++--------- 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, 103 insertions(+), 141 deletions(-) diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpci.c index 07256ed7ec..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\n"); - 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\n"); - 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 169c7917ea..1ce481c88d 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; @@ -186,6 +188,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 c1f7181d55..7df208d004 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -1891,7 +1891,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, @@ -1982,10 +1982,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); @@ -2036,18 +2033,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 4754b9d6f8..c51e68f748 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 7de4894b35..53caccecd7 100644 --- a/drivers/dma/dpaa2/dpaa2_qdma.c +++ b/drivers/dma/dpaa2/dpaa2_qdma.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2018-2023 NXP + * Copyright 2018-2024 NXP */ #include @@ -824,7 +824,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; @@ -1032,13 +1032,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; @@ -1094,24 +1088,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; @@ -1122,11 +1101,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); @@ -1324,11 +1299,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 449bbda7ca..ac524d2964 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 23f7c4132d..a0c057d183 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 aeee4ac289..5f4d0c68a4 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