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 8D268A00C2 for ; Wed, 28 Sep 2022 07:25:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 73FF842B90; Wed, 28 Sep 2022 07:25:57 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60040.outbound.protection.outlook.com [40.107.6.40]) by mails.dpdk.org (Postfix) with ESMTP id 3A2F1427EE; Wed, 28 Sep 2022 07:25:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j3VD/7XxmS80OTS4XXC4a8awLrI9z3D3c+E+FQaqwxT46AC+BgML8ElIm9UQPMfWzOysf+tY3exyUj2byNSH3zecaHE5diWTNT/G9O4WUSK0ZyTeHYD9IS3MxsoYgjei4oRDyWrYJD85PQfCOBW9k9Dv5Jb9ILBh4CkbCt1FNOymkalx5girujkWNrCafb9YAEcTJk2O8BYfzgkggP1Kj1nAerJO4lqOo/Mnexo17nqAoyzbnOw7ztrxgXC7az2aZ+PVd31hchGIe6RssNOeyIQbNwW4+e6y1muKLryFRYv23KSYvNfnBKduaRvOUdFT6snBJttDAV5OhIFybNbFSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0toi+zGgVxHR3LmBeUSPbc12NKbonwlCGpLNPWhb3Lg=; b=LYpobcy+ZelgixxXo/Mq2Qkqvwys2M1vv21NgokBKRfDfJca1ld/XqE+VpHAvGbdvFfrpu6sFz3KfKT3H3Usi7PNp3UEOjm0ogiWcUAWq0gV+KLvzDXK1s9AT5VDXhBDDhtjTRd/SH095U2L8GwLFFOHBWT+rrLiFdAyPbEw9FqFkidaqWvjZQhFzQNICL9cY5iwuhNW0+7NebEwkjaBzpqgqlPY78NnDcsyN5OoowrSepnnVIgtn+s1sN242RYs8Qp12MHHgDmCXmh8LFayruZRpEjjovVGzE3znI51j5LHHPr8nokkY1HUWXEJHVrA4y1exiKkqRZrNjLUPWcsXg== 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=0toi+zGgVxHR3LmBeUSPbc12NKbonwlCGpLNPWhb3Lg=; b=alTKX3ToBr1qpa8R9YgowY8oATcmwTArqwLeEU/MHhu4/G2dnHIXLFXgn22f5OIecXD1cPL2ctPl27zU82zpJMfgycRthJWQAfOGaWh/z1K/5MRMNxc3/Orke5TNGa+tyNQfOHQU2l1u2itE6BZ2SLmKkYeR+CNznz8X3MdVriQ= 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 PA4PR04MB7504.eurprd04.prod.outlook.com (2603:10a6:102:e6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Wed, 28 Sep 2022 05:25:51 +0000 Received: from AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::14d0:4458:d6ec:b8b1]) by AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::14d0:4458:d6ec:b8b1%7]) with mapi id 15.20.5676.017; Wed, 28 Sep 2022 05:25:51 +0000 From: Gagandeep Singh To: ferruh.yigit@amd.com, dev@dpdk.org Cc: Gagandeep Singh , stable@dpdk.org Subject: [PATCH 08/15] net/dpaa2: fix buffer free on transmit SG packets Date: Wed, 28 Sep 2022 10:55:09 +0530 Message-Id: <20220928052516.1279442-9-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220928052516.1279442-1-g.singh@nxp.com> References: <20220928052516.1279442-1-g.singh@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SGBP274CA0015.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::27) To AS8PR04MB8198.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8198:EE_|PA4PR04MB7504:EE_ X-MS-Office365-Filtering-Correlation-Id: 8721dede-4490-408d-7bd3-08daa111e879 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Fr3LGEJ0mjdYxgseB7kqaaaEgLhYPckNUMbFFxwiRwzh1LuQHPGIyUhfU08iV52WPuEU6hXEvVWsZTGwEN4808S/uHg+MD1uxoP/5WK4qXpPFa8WA2iWUFy2LTMqNrduoepEtBTbA72NsIOyG02CQyLbHnB3gYK+BXc6Kqzjk7sAXvY+rylevv8Y5g3hQAiwN9H5RzcDKyXLXhfm9ARttaFQeFzDGynZY5NwIu4qXdj0uIITrAhIoABMWCz2ek0xBHTNEf1C+KmE2bY06fN0rSFlE7sj2Rbcke7tCv2M7NejCtaRwmlpA+K40bQzDMYALXA1w/cAuhIifif7+pXtDsm5/unpSyH89p7KDb5IwfLB9ALKpi4zz/Hf+UOqI0kVtIEqRHL/0OuFmL/Ab9tG5jmDOzrygULDgqCjaOeGRhJ2RcT5K5CHdrw4Gkugt60bxtG+zXoZ3AjMZvrlzbQ/S9E7mzLY6VbZGHBfGXnbz0EqjdWPiGaNo6e1Bm8O3A86FQcjgc5D9vJ1VRpgjne1DC3rXK9Ow6RAQtUVbbMkim6d8SZMM1h+H8tmL9wNl4fhYpPIjls0zE/Kn23c9pffVKCLts1eSYyBfZAwj374B3uzlsXtM+aHoi3TyDdUfy/tPD7ItGarffNyzLBx+TdNhQJoOY8tYI2bBLKTyLBvjJJu2yiizccsNjR7fqyki4v5i3um4ogA45CCj8Tp5buAVMTXTQCUBg5K36DC/SFWPCWbBGAZFIW1acMisKM2HrWTFjFkTXm9Qa39DQK0uJFhIA== 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:(13230022)(4636009)(346002)(366004)(376002)(396003)(136003)(39860400002)(451199015)(1076003)(186003)(2616005)(8676002)(83380400001)(38350700002)(8936002)(6506007)(38100700002)(26005)(86362001)(6512007)(6666004)(2906002)(5660300002)(52116002)(478600001)(66556008)(66476007)(66946007)(316002)(36756003)(41300700001)(4326008)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?/WI98kd482SBOxw88RkDSrXx71PeOIIKMgKVbBj480q2fu2pgdeew2mz5zxk?= =?us-ascii?Q?q0CkTttQKxr0fWddm6Op3oMoOJp/sRpeehYke+uVxbRyBpbyMcT/65X4BvyR?= =?us-ascii?Q?Vkap7i6RPzfeD5pW5oaZkNMUQlipU9gcHWyh04/lwtqFRCj39wsn1bAp5YNu?= =?us-ascii?Q?FRd/b4AhtlE2f6piTUXu6wtlPM2kjsdk+iYowpD/tPT5pPa1Gh6WEbVM2Ox0?= =?us-ascii?Q?SEY7hciQp6M4Vq1I8+DniPzNGdFJaF7LXyUhyzNwAh9NdxIllnI6mNj+ixKu?= =?us-ascii?Q?uAle1T5YcU3Tzx9iuh+FqmBRaVfsp1o4FNac/3dGGjf0sJc05LALQ+7OA+Gt?= =?us-ascii?Q?5AN7JuhYDihU8E8tVY0X1d8jYieSgKdqIAB+PIz7mBRpuoyPvmerfTtM6MxU?= =?us-ascii?Q?SlQiAjNyUdBBf9CouUlcfGmQ29TcfMeIC/rRwp9ABQQQNVwx7xRV44lDKUyA?= =?us-ascii?Q?IBCd9KzeCwxHBCiK5xjYXKK0qOLKx6jJ1bGnJL+53LH8GmZpmyUD2KDntWtH?= =?us-ascii?Q?hRNLD+b3olqASe8VO6GgM9RE60vgIMP3z3pJmmc8L4xazt+NXljFKAoMOu/c?= =?us-ascii?Q?h5oInRrFe3qfMfvwuTEqle+XzXSgGKvVIUo/Tg7KIvxkFGG1UsfqK5g+ibqE?= =?us-ascii?Q?dEqP2FlDSC+LO86oRJf4rrI30aNzUcsbRC8xLp6VLRWLX++SdMuAsGK77W3D?= =?us-ascii?Q?ddECgjhVbBNyPwcXN6ue0O84435IPylIGzB6UjUoYBPA8slV6ydKO8KC17K1?= =?us-ascii?Q?EIMuI20OgKQxVd5Ro+5axXevaYlqRC7FnxnZZviRlHNfbXn8YV1tloN31Xbp?= =?us-ascii?Q?k80pgmpHfpSwd/7w/37ZIOrZ8+JVhoNHp9MDrUTfxiwjeOFgOp3n0Djswl6L?= =?us-ascii?Q?o7F+ePjYmP6bKnJ28c1E1DBz7HKbK4Gqcs+wpngFttSa4WyP4l5se6jsZvgg?= =?us-ascii?Q?CmvZGU8o1OH8Qx5i8oWYSLsYUwfsP0Gd045xSsMixRSBFBDbrpRc4RekOtu2?= =?us-ascii?Q?eg7b6DUKgnYea7lL+d4GsXPoL1VEhFLxVja6Y7Ohz1a+L/3RUVno9tBuxKkB?= =?us-ascii?Q?Lr8X/ogTEPF1oxoOfJTLK0dxH+mtOjjiHBLLBXoNGvlvK39lMng1u1eQE9qB?= =?us-ascii?Q?lc9GgFigQ9rNx+oyVkGN3TXMIA/YnMT2tf64hZJ0iyYJyotBUU/pKKomYvYI?= =?us-ascii?Q?tBOARqAlaIDR49dbMWRO580oYALT6z0X1c2gyTto2jD5M/RJlz8FQHCsh1mH?= =?us-ascii?Q?jvWOzHuCHITB1PLbfITg36/OYB+IVVijTXr8XISfV1ODWJmxiHBBvFG1jJ4J?= =?us-ascii?Q?T5ggTYgQyZR3En67zlMzIoiq0r0HzDjilnkruJRX5wxOSMY9KlDQOrJuZhGa?= =?us-ascii?Q?KSWtEl80pMyCl0bQuqsL+epNyYbdJh0mKMCKD9ucuH05AA02mEeE3scMTdUS?= =?us-ascii?Q?BZFL9u6hBJkyWQCYL1VoRoIAo82PpeKqIA5y4QH7/vh8bH1hYPXUNQCVoORQ?= =?us-ascii?Q?RyzTaFlwOjXpTOhTxIRRXcYItEpFafFw1B5rBKzbfvdCi90ND3VW+78yyh3y?= =?us-ascii?Q?qt3jcLf8AJPvmS/pNaJeLTDSCdyM8ppvvEj0i+gH?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8721dede-4490-408d-7bd3-08daa111e879 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8198.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 05:25:51.6575 (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: Rx+Djp/cCFO84e0jeuxOCgZ+7a873gt0wrpapZUfgSxbkQ9wZDLXps1F7ivtDUM3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7504 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org When using SG list to TX with external and direct buffers, HW free the direct buffers and driver free the external buffers. Software scans the complete SG mbuf list to find the external buffers to free, but this is wrong as hardware can free the direct buffers if any present in the list and same can be re-allocated for other purpose in multi thread or high spead running traffic environment with new data in it. So the software which is scanning the SG mbuf list, if that list has any direct buffer present then that direct buffer's next pointor can give wrong pointer value, if already freed by hardware which can do the mempool corruption or memory leak. In this patch instead of relying on user given SG mbuf list we are storing the buffers in an internal list which will be scanned by driver after transmit to free non-direct buffers. This patch also fixes 2 more memory leak issues. Driver is freeing complete SG list by checking external buffer flag in first segment only, but external buffer can be attached to any of the segment. Because of which driver either can double free buffers or there can be memory leak. In case of indirect buffers, driver is modifying the original buffer list to free the indirect buffers but this orginal buffer list is being used even after transmit packets for software buffer cleanup. This can cause the buffer leak issue. Fixes: 6bfbafe18d15 ("net/dpaa2: support external buffers in Tx") Cc: stable@dpdk.org Signed-off-by: Gagandeep Singh --- drivers/net/dpaa2/dpaa2_ethdev.h | 9 +++ drivers/net/dpaa2/dpaa2_rxtx.c | 111 +++++++++++++++++++++++-------- 2 files changed, 92 insertions(+), 28 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h index 872dced517..c88c8146dc 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.h +++ b/drivers/net/dpaa2/dpaa2_ethdev.h @@ -129,6 +129,15 @@ extern struct rte_mempool *dpaa2_tx_sg_pool; #define DPAA2_POOL_SIZE 2048 /* SG pool cache size */ #define DPAA2_POOL_CACHE_SIZE 256 +/* structure to free external and indirect + * buffers. + */ +struct sw_buf_free { + /* To which packet this segment belongs */ + uint16_t pkt_id; + /* The actual segment */ + struct rte_mbuf *seg; +}; /* enable timestamp in mbuf*/ extern bool dpaa2_enable_ts[]; diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c index dcd86c4056..94815485b8 100644 --- a/drivers/net/dpaa2/dpaa2_rxtx.c +++ b/drivers/net/dpaa2/dpaa2_rxtx.c @@ -403,9 +403,12 @@ eth_fd_to_mbuf(const struct qbman_fd *fd, static int __rte_noinline __rte_hot eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf, struct qbman_fd *fd, + struct sw_buf_free *free_buf, + uint32_t *free_count, + uint32_t pkt_id, uint16_t bpid) { - struct rte_mbuf *cur_seg = mbuf, *prev_seg, *mi, *temp; + struct rte_mbuf *cur_seg = mbuf, *mi, *temp; struct qbman_sge *sgt, *sge = NULL; int i, offset = 0; @@ -486,10 +489,11 @@ eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf, #endif } } - cur_seg = cur_seg->next; } else if (RTE_MBUF_HAS_EXTBUF(cur_seg)) { + free_buf[*free_count].seg = cur_seg; + free_buf[*free_count].pkt_id = pkt_id; + ++*free_count; DPAA2_SET_FLE_IVP(sge); - cur_seg = cur_seg->next; } else { /* Get owner MBUF from indirect buffer */ mi = rte_mbuf_from_indirect(cur_seg); @@ -503,11 +507,11 @@ eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf, mempool_to_bpid(mi->pool)); rte_mbuf_refcnt_update(mi, 1); } - prev_seg = cur_seg; - cur_seg = cur_seg->next; - prev_seg->next = NULL; - rte_pktmbuf_free(prev_seg); + free_buf[*free_count].seg = cur_seg; + free_buf[*free_count].pkt_id = pkt_id; + ++*free_count; } + cur_seg = cur_seg->next; } DPAA2_SG_SET_FINAL(sge, true); return 0; @@ -515,11 +519,19 @@ eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf, static void eth_mbuf_to_fd(struct rte_mbuf *mbuf, - struct qbman_fd *fd, uint16_t bpid) __rte_unused; + struct qbman_fd *fd, + struct sw_buf_free *buf_to_free, + uint32_t *free_count, + uint32_t pkt_id, + uint16_t bpid) __rte_unused; static void __rte_noinline __rte_hot eth_mbuf_to_fd(struct rte_mbuf *mbuf, - struct qbman_fd *fd, uint16_t bpid) + struct qbman_fd *fd, + struct sw_buf_free *buf_to_free, + uint32_t *free_count, + uint32_t pkt_id, + uint16_t bpid) { DPAA2_MBUF_TO_CONTIG_FD(mbuf, fd, bpid); @@ -540,6 +552,9 @@ eth_mbuf_to_fd(struct rte_mbuf *mbuf, (void **)&mbuf, 1, 0); #endif } else if (RTE_MBUF_HAS_EXTBUF(mbuf)) { + buf_to_free[*free_count].seg = mbuf; + buf_to_free[*free_count].pkt_id = pkt_id; + ++*free_count; DPAA2_SET_FD_IVP(fd); } else { struct rte_mbuf *mi; @@ -549,7 +564,10 @@ eth_mbuf_to_fd(struct rte_mbuf *mbuf, DPAA2_SET_FD_IVP(fd); else rte_mbuf_refcnt_update(mi, 1); - rte_pktmbuf_free(mbuf); + + buf_to_free[*free_count].seg = mbuf; + buf_to_free[*free_count].pkt_id = pkt_id; + ++*free_count; } } @@ -1226,7 +1244,8 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data; struct dpaa2_dev_priv *priv = eth_data->dev_private; uint32_t flags[MAX_TX_RING_SLOTS] = {0}; - struct rte_mbuf **orig_bufs = bufs; + struct sw_buf_free buf_to_free[DPAA2_MAX_SGS * dpaa2_dqrr_size]; + uint32_t free_count = 0; if (unlikely(!DPAA2_PER_LCORE_DPIO)) { ret = dpaa2_affine_qbman_swp(); @@ -1324,11 +1343,17 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mp = (*bufs)->pool; if (eth_mbuf_to_sg_fd(*bufs, &fd_arr[loop], + buf_to_free, + &free_count, + loop, mempool_to_bpid(mp))) goto send_n_return; } else { eth_mbuf_to_fd(*bufs, - &fd_arr[loop], 0); + &fd_arr[loop], + buf_to_free, + &free_count, + loop, 0); } bufs++; #ifdef RTE_LIBRTE_IEEE1588 @@ -1373,11 +1398,17 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) if (unlikely((*bufs)->nb_segs > 1)) { if (eth_mbuf_to_sg_fd(*bufs, &fd_arr[loop], + buf_to_free, + &free_count, + loop, bpid)) goto send_n_return; } else { eth_mbuf_to_fd(*bufs, - &fd_arr[loop], bpid); + &fd_arr[loop], + buf_to_free, + &free_count, + loop, bpid); } } #ifdef RTE_LIBRTE_IEEE1588 @@ -1410,12 +1441,9 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } dpaa2_q->tx_pkts += num_tx; - loop = 0; - while (loop < num_tx) { - if (unlikely(RTE_MBUF_HAS_EXTBUF(*orig_bufs))) - rte_pktmbuf_free(*orig_bufs); - orig_bufs++; - loop++; + for (loop = 0; loop < free_count; loop++) { + if (buf_to_free[loop].pkt_id < num_tx) + rte_pktmbuf_free_seg(buf_to_free[loop].seg); } return num_tx; @@ -1445,12 +1473,9 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) skip_tx: dpaa2_q->tx_pkts += num_tx; - loop = 0; - while (loop < num_tx) { - if (unlikely(RTE_MBUF_HAS_EXTBUF(*orig_bufs))) - rte_pktmbuf_free(*orig_bufs); - orig_bufs++; - loop++; + for (loop = 0; loop < free_count; loop++) { + if (buf_to_free[loop].pkt_id < num_tx) + rte_pktmbuf_free_seg(buf_to_free[loop].seg); } return num_tx; @@ -1523,7 +1548,7 @@ dpaa2_dev_tx_multi_txq_ordered(void **queue, struct rte_mbuf **bufs, uint16_t nb_pkts) { /* Function to transmit the frames to multiple queues respectively.*/ - uint32_t loop, retry_count; + uint32_t loop, i, retry_count; int32_t ret; struct qbman_fd fd_arr[MAX_TX_RING_SLOTS]; uint32_t frames_to_send, num_free_eq_desc = 0; @@ -1536,6 +1561,8 @@ dpaa2_dev_tx_multi_txq_ordered(void **queue, struct rte_eth_dev_data *eth_data; struct dpaa2_dev_priv *priv; struct dpaa2_queue *order_sendq; + struct sw_buf_free buf_to_free[DPAA2_MAX_SGS * dpaa2_dqrr_size]; + uint32_t free_count = 0; if (unlikely(!DPAA2_PER_LCORE_DPIO)) { ret = dpaa2_affine_qbman_swp(); @@ -1647,11 +1674,17 @@ dpaa2_dev_tx_multi_txq_ordered(void **queue, if (unlikely((*bufs)->nb_segs > 1)) { if (eth_mbuf_to_sg_fd(*bufs, &fd_arr[loop], + buf_to_free, + &free_count, + loop, bpid)) goto send_frames; } else { eth_mbuf_to_fd(*bufs, - &fd_arr[loop], bpid); + &fd_arr[loop], + buf_to_free, + &free_count, + loop, bpid); } } @@ -1676,6 +1709,10 @@ dpaa2_dev_tx_multi_txq_ordered(void **queue, } } + for (i = 0; i < free_count; i++) { + if (buf_to_free[i].pkt_id < loop) + rte_pktmbuf_free_seg(buf_to_free[i].seg); + } return loop; } @@ -1698,6 +1735,8 @@ dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) int32_t ret; uint16_t num_tx = 0; uint16_t bpid; + struct sw_buf_free buf_to_free[DPAA2_MAX_SGS * dpaa2_dqrr_size]; + uint32_t free_count = 0; if (unlikely(!DPAA2_PER_LCORE_DPIO)) { ret = dpaa2_affine_qbman_swp(); @@ -1810,11 +1849,17 @@ dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) if (unlikely((*bufs)->nb_segs > 1)) { if (eth_mbuf_to_sg_fd(*bufs, &fd_arr[loop], + buf_to_free, + &free_count, + loop, bpid)) goto send_n_return; } else { eth_mbuf_to_fd(*bufs, - &fd_arr[loop], bpid); + &fd_arr[loop], + buf_to_free, + &free_count, + loop, bpid); } } bufs++; @@ -1843,6 +1888,11 @@ dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) nb_pkts -= loop; } dpaa2_q->tx_pkts += num_tx; + for (loop = 0; loop < free_count; loop++) { + if (buf_to_free[loop].pkt_id < num_tx) + rte_pktmbuf_free_seg(buf_to_free[loop].seg); + } + return num_tx; send_n_return: @@ -1867,6 +1917,11 @@ dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } skip_tx: dpaa2_q->tx_pkts += num_tx; + for (loop = 0; loop < free_count; loop++) { + if (buf_to_free[loop].pkt_id < num_tx) + rte_pktmbuf_free_seg(buf_to_free[loop].seg); + } + return num_tx; } -- 2.25.1