From patchwork Mon Jul 22 16:39:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 142627 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 51E4E45683; Mon, 22 Jul 2024 18:40:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C014440E22; Mon, 22 Jul 2024 18:40:03 +0200 (CEST) Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012028.outbound.protection.outlook.com [52.101.66.28]) by mails.dpdk.org (Postfix) with ESMTP id C08A140E1B for ; Mon, 22 Jul 2024 18:40:01 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eYRw3a3ECmgD3Eh8tT5b1we3mAMyif2+CkU8+xl3LjIabSdojuS1W07ietOLd157Fj/OZl+5g7uzNp4PejxyqhfM+hkb/5KxsKcqZK4sKmihIwkMtk4QaZDSaZfbm4pSAb0WB7ky/AacZHq3oDQlkY7jdMIznzpX3xDSIHqCROIprkbS6J2ty9V+WZSfk6ezOgCSXidAMf154wIfuToPaaUIfHEiqIh7Ytas2FF/67/yLL6IAQ6ptL95oYGIjf2/rWraDWaLf8z+Kw6pB/DZdLIzG1fKlW1moymkWwhiXRgongGwa7m+R6Ag5naS0Tif/TfYbbEPkz3MzSCNarSLlQ== 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=g4XXFVvsE8QlpHpfUl9DlHFXjbcyA5JRvyK+/TYHvcAmJBB8m9YfJEN9H8pzvH1xSt1nnVHU3AHNCsQAK+buiQnc4ex+dH/AKSqJxG2keS8bpTa4JzTT0s7YCooMEdJQljswaR2/9BfMTzLUS8QyWk+5ZIV4jF1C2oz192rGs8to3fQKQqrns6Jf5R7AMw5CqJQNjm4EWpale1iG+r6b7pkAFdI0oZ56hil0gmcTSdb0ZxE3iGPxZf/jPuvGIq7rkRFPdWpGmMJBBhoDge1z0GAJu+GclPjZUYhlVEYrlXkcTD9baO3PDRBId181naYWRsZeAlbPnnyHqwbkFVvs1Q== 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=haSLFrTKoZLV8N1apeKfrKm76CKQ+i8bYLIBXSwajs7cqP4c2Yn9CQYBrl5Lw5RQiDn1NxPMlybLHGeEBHldX6nT4gN5LmFDLNnaBeE+/H6LEXIPxitRq/AYpBQ+e0Khx63aS25oLJ7utgtcupT45UEiT+aSpwRp/IxYbxFo7nM= 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 VI1PR04MB6798.eurprd04.prod.outlook.com (2603:10a6:803:131::19) 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:00 +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:00 +0000 From: Gagandeep Singh To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena Cc: Jun Yang Subject: [v3 08/30] bus/fslmc: enhance the qbman dq storage logic Date: Mon, 22 Jul 2024 22:09:08 +0530 Message-Id: <20240722163930.2171568-9-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_|VI1PR04MB6798:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e97e7e4-b29f-4fe4-7c3c-08dcaa6ceda0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: Oymw4I+ACTgDIM0rd7MVwT1lnPrNYqVXdBvWgchye6Bnp/fujYW+UStZ96EV1giwj5NFuB4a+MpCn48/HgUK/uElunpsKL05v5Ge3Z0XJvcD28Lipoq51biWtww/FjalnXrjUGQqxcLBk+OSXqViXvh3WOrk63D+bGFBV3SCiCW8z4PipPMDaZe2qgwGDJEqLEAeYPLnHxjKEo6W1hYDO2FES/8Z0h0lv0+GUOj/oTi/Osa6hP2oeLnHu5hdOZILULKCfM7lS+h5TphPwJxkuEUxQOjw59G5hheVmCD5mdjG6Kob/YszNhbIgP8JbGw3hJMJvtugbj0yWgUjygOm0jGdZegUyrJJXduA9mjzzhBVXZKSm3CR+gOT+1QEHLFDjBcsfvm6RN54eyW2QovCN0Fn1wQ3oFDzGE7zma1op2UnFskxsU7TfIdK1DM/ghfr6MlTk/0/S/gqcgSkzUBWAEH++zsWLbVO3DevFCDYU62FBBhNh4TuVhaH2SbX+XcwByu+88JGmHqmDjBQepCm26A/FS2pGH/UEdbvzb677pA9bm2wSJQ8jDdg2fC3WXdvuE8s8Op9+4cDMceNvULI4am10dHdEBMjO/RpIwiJt0w7PSXm/05FBMuC7LPcBUqH6IRrMLJV0K1XkloFAfzvcnoxoIZGFe5Etz/lRyjCFfH6GVWQKOySJK7fcFqhypXsAUr1oIMD5cuK/+7M5EmhdaQkYaBcQAJ6X4NoUS/mtgiroiePUwHTWME6RnxNV0yDS55lUEALJc7j6w77xDvTyPXxYKi+2AYo/uEiw7gRpNE6Ki/1/hFIiXkd2ct2CBw0sil1PQW1A1IxRIJCBA9q6CeLbUZBadYPOxjGt1ybOYwHudki/Atly4x1tQvAvX6mzNFi4cPFRuUlJHl5Pzqc+m02i5Gqd7b+uyIjMqvDk1/NqJHCfoAzebHEDA5P/RO5UKRWuLx/uEjCjLXA3pmAiAvspZXb3bKAeD/slkHtv/8Mv15JGPU/Ae5lReOnMIylZcaplTMWN8dZfGYcbJkx/p7q646cfx+U5TujZsmTgD5/efR3X/Ro90OYXtwzbg9UawMeidvy/3s1MHAvApqUGN8XOWT1D5w1Vjq918v7QsZ3daBEdB9vK9ONBxnRnFdFiaR9g0kVNoA5fFDDxCQHJshC/aKvh6nIRUj676lmJJJTbFA4mmKYki7BsDpk75hQXlHhIoilS3imdQWTsETCLUqNRXUHOpNthZ/hVDcvAAkOcPgJL3zW3knFGRhUQ7b7WU0kd4L0hgJqgubiOGnSJYyOLfJ0kD17R6+7iLWYyfRznHx7ai0YEAUy8J3wLO/ci3GyFUdvnM3oNFYevlHLhgUpetRHcu5w8KGg9X9z9QjB7XCSvhb5DYAv6jX++mwO5RFYY2VRImOUNfLQA588Lw== 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)(376014)(52116014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Xf18dyIROYzzbENarG4ybw2z8omlLAiTLijyQEgWM/Bf+Ccs7st7gxVIaevg7gwg6s2LvS407SGrmD8NMIf4zMuy7ypN7W47s42Qhq0oQ6gzPfuCth6lk0tdYYF+0I0bs3lu9DbY4cf3qe5aJrzFMudiJM2bYU6RGG6L5jj7qjv6H051wmeF4wuMjzlGsuNPPW7a5OZ1uXYT34Yp78NXSPI8Our7Ap82el2rxnnZd6pxBK7ZX5l+v9xx+r/Sw1E4gUlmIQC5hFhdDH0gLhPpV5cFlzFeWI2crY2N/kdk4h6hqgCeZK42K38EAvButgt6bKwnFsdYvATjR1DI+/RokBmiJH+7OADLDcmuiogDsfo/+fi2dwJwDFbK7igZyLxq6NA4Oc7aAzCpceTeZbgGJy7KDwFjCEcyEvXxtWFarTwM/rxTr2JdhRTGtTUzy6+sH70CZ1bEKr/bJ9Ch2ztuoLUlzgrABinpkeSX1WPhkG3LhGSWwcwdm+7FA089rE4TJmoSacMNV1+guLIydFrmUy/s3Cd26k5KTFs+wI8OmLXY4REANUJxsBF4ttNKCnvMcCJE9ZLWIx6R8ZOJkpzs8ncEZZbzTU3/N4KGj8dMZ92k1wxF4BoOHf4J7eFyu/pv9VtB5VBoLlTYYa4Y6hfuQtmowweXPjoxLDYFGzDOQtDb9t0oWQtdeKnqKNBmevz/rkvv250J0qzCNHg26nsWtpcLmYq2SyN2GoWlqrrC7PmAzFzPoEti+9l33AAOUycqfMsu1RB1PFwiqC7jRvkYka7uVCtExgU35Aq83n0Q4+C8O0FXrMc+0txx/1kaUsC9IjxHL0xg5x2L8HZ1wqhG5a8YfkbVJJmOE+EEZrO9F9j7ybqhfYR8WKAfILHFeANhwtJuyYTAz/2w/c1wm58n9PjmZNxOG1BM2ZLqD+jLGf3kgnqPH/wIByMy9/OQifQRuic6fEPL8znfILWpHHVSVwfI31K66tMIC7AXdsl3pHuJJvrX9VIFstoihMpYjs1lgCIU/txHIkFVOqgc85hiiiOVE4IdpdAwB2wmn4L8J52IuHGkYS2M4VKHdZlfgR3g8xVnYBuC6a+nKENAC0dj/hNavi2771cITk2QLkWg7j5BvRNJ/ERdbR+SvsBAILWDU+RpCXv+FmQkSftuCl+ch6KaIy9Sri1utKIru56gBzjPAXBYB02kwCoEzN1hDayQDoicISSe+MpUVr/c6EU+fnnW+EP1c5T9Zt0a/uO7aHCFkWOi+JxT973Qt4LTowB9hlF+ihiXNLpLNMQDBftkhd+D/HTgPG3zD5twlg0jmwF7OK2rqX2R0L9fPjNzrvHrjokH9qDdAwhAGVFHMWegqy3R9d48I8sQWhavNYLAWfIe4iMGsiu1WqyNkhaOExeqtif7HW2whUn/2N/cQhUaiq5k/RKyS1q8ofLYeQ8kV6M/M/TBJWxT+z45ArbztjM6eM+E2K+1oz1mdEDEwh5DMUxsZM64xX0qEiZJbmgkWY1WEay2J4lLN91ZKcRi1LnL11ubYGTZCtFdoY5AH2DWL9RzS51IHDm6qd3nehV8FUa5rGoWUtMTb/p/pgTNOtL8 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e97e7e4-b29f-4fe4-7c3c-08dcaa6ceda0 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:00.1650 (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: ZhWeFfyx3n3eDdxnZ18cAApQBpt/Kuhlp36KVjmo7ob/8V1LUk6ZXj8DYbP+VAQW X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6798 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);