patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 23.11 1/2] net/hns3: fix CRC data segment
@ 2025-07-15  3:16 Dengdui Huang
  2025-07-15  3:16 ` [PATCH 23.11 2/2] net/hns3: fix Rx packet without CRC data Dengdui Huang
  0 siblings, 1 reply; 2+ messages in thread
From: Dengdui Huang @ 2025-07-15  3:16 UTC (permalink / raw)
  To: stable; +Cc: xuemingl

[ upstream commit 7a99b6ca9d079e9364ba61d3fe802a4761739c8f ]

When the packet is received into a multisegment mbuf and
the last segment contains only CRC data, the driver should
not release this segment. Otherwise, the application cannot
look the CRC data. This patch fixes it.

Fixes: 8973d7c4ca12 ("net/hns3: support keeping CRC")
Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index ab4789c2f1..58aa6edff4 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -2383,18 +2383,16 @@ hns3_rxd_to_vlan_tci(struct hns3_rx_queue *rxq, struct rte_mbuf *mb,
 }
 
 static inline void
-recalculate_data_len(struct rte_mbuf *first_seg, struct rte_mbuf *last_seg,
-		    struct rte_mbuf *rxm, struct hns3_rx_queue *rxq,
-		    uint16_t data_len)
+recalculate_data_len(struct rte_mbuf *last_seg, struct rte_mbuf *rxm,
+		     struct hns3_rx_queue *rxq)
 {
+	uint16_t data_len = rxm->data_len;
 	uint8_t crc_len = rxq->crc_len;
 
 	if (data_len <= crc_len) {
-		rte_pktmbuf_free_seg(rxm);
-		first_seg->nb_segs--;
+		rxm->data_len = 0;
 		last_seg->data_len = (uint16_t)(last_seg->data_len -
 			(crc_len - data_len));
-		last_seg->next = NULL;
 	} else
 		rxm->data_len = (uint16_t)(data_len - crc_len);
 }
@@ -2725,8 +2723,7 @@ hns3_recv_scattered_pkts(void *rx_queue,
 		rxm->next = NULL;
 		if (unlikely(rxq->crc_len > 0)) {
 			first_seg->pkt_len -= rxq->crc_len;
-			recalculate_data_len(first_seg, last_seg, rxm, rxq,
-				rxm->data_len);
+			recalculate_data_len(last_seg, rxm, rxq);
 		}
 
 		first_seg->port = rxq->port_id;
-- 
2.33.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-07-15  3:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-15  3:16 [PATCH 23.11 1/2] net/hns3: fix CRC data segment Dengdui Huang
2025-07-15  3:16 ` [PATCH 23.11 2/2] net/hns3: fix Rx packet without CRC data Dengdui Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).