[PATCH v5 1/2] net/hns3: fix cannot look the CRC data

Dengdui Huang huangdengdui at huawei.com
Fri May 16 09:15:18 CEST 2025


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 at dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui at 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 bb7ffee12c..49b6f16ccd 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -2386,18 +2386,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);
 }
@@ -2728,8 +2726,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



More information about the dev mailing list