From: Jie Hai <haijie1@huawei.com>
To: <dev@dpdk.org>, <stephen@networkplumber.org>,
<ferruh.yigit@amd.com>, <mb@smartsharesystems.com>,
<andrew.rybchenko@oktetlabs.ru>,
Yisen Zhuang <yisen.zhuang@huawei.com>,
Wathsala Vithanage <wathsala.vithanage@arm.com>,
"Wei Hu (Xavier)" <xavier.huwei@huawei.com>,
"Min Hu (Connor)" <humin29@huawei.com>
Cc: <huangdengdui@huawei.com>, <fengchengwen@huawei.com>,
<lihuisong@huawei.com>
Subject: [PATCH v3 2/3] net/hns3: fix packet length do not contain CRC data length
Date: Fri, 19 Jul 2024 17:04:14 +0800 [thread overview]
Message-ID: <20240719090415.1513301-3-haijie1@huawei.com> (raw)
In-Reply-To: <20240719090415.1513301-1-haijie1@huawei.com>
From: Dengdui Huang <huangdengdui@huawei.com>
In the HNS3 driver, pkt_len in mbuf do not contain the CRC length.
This patch fix it.
Fixes: 8973d7c4ca12 ("net/hns3: support keeping CRC")
Cc: stable@dpdk.org
Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Acked-by: Huisong Li <lihuisong@huawei.com>
Acked-by: Jie Hai <haijie1@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 53 +++------------------------
drivers/net/hns3/hns3_rxtx_vec_neon.h | 19 ----------
drivers/net/hns3/hns3_rxtx_vec_sve.c | 3 +-
3 files changed, 7 insertions(+), 68 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 5941b966e094..39ba9080ea15 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -1951,7 +1951,6 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc,
memset(&rxq->err_stats, 0, sizeof(struct hns3_rx_bd_errors_stats));
memset(&rxq->dfx_stats, 0, sizeof(struct hns3_rx_dfx_stats));
- /* CRC len set here is used for amending packet length */
if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
rxq->crc_len = RTE_ETHER_CRC_LEN;
else
@@ -2383,23 +2382,6 @@ 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)
-{
- uint8_t crc_len = rxq->crc_len;
-
- if (data_len <= crc_len) {
- rte_pktmbuf_free_seg(rxm);
- first_seg->nb_segs--;
- 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);
-}
-
static inline struct rte_mbuf *
hns3_rx_alloc_buffer(struct hns3_rx_queue *rxq)
{
@@ -2503,8 +2485,7 @@ hns3_recv_pkts_simple(void *rx_queue,
rxdp->rx.bd_base_info = 0;
rxm->data_off = RTE_PKTMBUF_HEADROOM;
- rxm->pkt_len = (uint16_t)(rte_le_to_cpu_16(rxd.rx.pkt_len)) -
- rxq->crc_len;
+ rxm->pkt_len = (uint16_t)(rte_le_to_cpu_16(rxd.rx.pkt_len));
rxm->data_len = rxm->pkt_len;
rxm->port = rxq->port_id;
rxm->hash.rss = rte_le_to_cpu_32(rxd.rx.rss_hash);
@@ -2531,8 +2512,8 @@ hns3_recv_pkts_simple(void *rx_queue,
hns3_rxd_to_vlan_tci(rxq, rxm, l234_info, &rxd);
- /* Increment bytes counter */
- rxq->basic_stats.bytes += rxm->pkt_len;
+ /* All byte-related statistics do not include Ethernet FCS */
+ rxq->basic_stats.bytes += rxm->pkt_len - rxq->crc_len;
rx_pkts[nb_rx++] = rxm;
continue;
@@ -2695,10 +2676,10 @@ hns3_recv_scattered_pkts(void *rx_queue,
rxm->data_off = RTE_PKTMBUF_HEADROOM;
rxm->data_len = rte_le_to_cpu_16(rxd.rx.size);
+ rxm->next = NULL;
if (!(bd_base_info & BIT(HNS3_RXD_FE_B))) {
last_seg = rxm;
- rxm->next = NULL;
continue;
}
@@ -2706,30 +2687,8 @@ hns3_recv_scattered_pkts(void *rx_queue,
if (unlikely(bd_base_info & BIT(HNS3_RXD_TS_VLD_B)))
hns3_rx_ptp_timestamp_handle(rxq, first_seg, timestamp);
- /*
- * The last buffer of the received packet. packet len from
- * buffer description may contains CRC len, packet len should
- * subtract it, same as data len.
- */
first_seg->pkt_len = rte_le_to_cpu_16(rxd.rx.pkt_len);
- /*
- * This is the last buffer of the received packet. If the CRC
- * is not stripped by the hardware:
- * - Subtract the CRC length from the total packet length.
- * - If the last buffer only contains the whole CRC or a part
- * of it, free the mbuf associated to the last buffer. If part
- * of the CRC is also contained in the previous mbuf, subtract
- * the length of that CRC part from the data length of the
- * previous mbuf.
- */
- 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);
- }
-
first_seg->port = rxq->port_id;
first_seg->hash.rss = rte_le_to_cpu_32(rxd.rx.rss_hash);
first_seg->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
@@ -2761,8 +2720,8 @@ hns3_recv_scattered_pkts(void *rx_queue,
hns3_rxd_to_vlan_tci(rxq, first_seg, l234_info, &rxd);
- /* Increment bytes counter */
- rxq->basic_stats.bytes += first_seg->pkt_len;
+ /* All byte-related statistics do not include Ethernet FCS */
+ rxq->basic_stats.bytes += first_seg->pkt_len - rxq->crc_len;
rx_pkts[nb_rx++] = first_seg;
first_seg = NULL;
diff --git a/drivers/net/hns3/hns3_rxtx_vec_neon.h b/drivers/net/hns3/hns3_rxtx_vec_neon.h
index 0dc6b9f0a22d..60ec501a2ab6 100644
--- a/drivers/net/hns3/hns3_rxtx_vec_neon.h
+++ b/drivers/net/hns3/hns3_rxtx_vec_neon.h
@@ -148,14 +148,6 @@ hns3_recv_burst_vec(struct hns3_rx_queue *__restrict rxq,
8, 9, 10, 11, /* rx.rss_hash to rte_mbuf.hash.rss */
};
- uint16x8_t crc_adjust = {
- 0, 0, /* ignore pkt_type field */
- rxq->crc_len, /* sub crc on pkt_len */
- 0, /* ignore high-16bits of pkt_len */
- rxq->crc_len, /* sub crc on data_len */
- 0, 0, 0, /* ignore non-length fields */
- };
-
/* compile-time verifies the shuffle mask */
RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
@@ -171,7 +163,6 @@ hns3_recv_burst_vec(struct hns3_rx_queue *__restrict rxq,
uint8x16_t pkt_mb1, pkt_mb2, pkt_mb3, pkt_mb4;
uint64x2_t mbp1, mbp2;
uint16x4_t bd_vld = {0};
- uint16x8_t tmp;
uint64_t stat;
/* calc how many bd valid */
@@ -225,16 +216,6 @@ hns3_recv_burst_vec(struct hns3_rx_queue *__restrict rxq,
pkt_mb3 = vqtbl2q_u8(pkt_mbuf3, shuf_desc_fields_msk);
pkt_mb4 = vqtbl2q_u8(pkt_mbuf4, shuf_desc_fields_msk);
- /* 4 packets remove crc */
- tmp = vsubq_u16(vreinterpretq_u16_u8(pkt_mb1), crc_adjust);
- pkt_mb1 = vreinterpretq_u8_u16(tmp);
- tmp = vsubq_u16(vreinterpretq_u16_u8(pkt_mb2), crc_adjust);
- pkt_mb2 = vreinterpretq_u8_u16(tmp);
- tmp = vsubq_u16(vreinterpretq_u16_u8(pkt_mb3), crc_adjust);
- pkt_mb3 = vreinterpretq_u8_u16(tmp);
- tmp = vsubq_u16(vreinterpretq_u16_u8(pkt_mb4), crc_adjust);
- pkt_mb4 = vreinterpretq_u8_u16(tmp);
-
/* save packet info to rx_pkts mbuf */
vst1q_u8((void *)&sw_ring[pos + 0].mbuf->rx_descriptor_fields1,
pkt_mb1);
diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c
index 8aa4448558cf..67c87f570e8a 100644
--- a/drivers/net/hns3/hns3_rxtx_vec_sve.c
+++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c
@@ -36,8 +36,7 @@ hns3_desc_parse_field_sve(struct hns3_rx_queue *rxq,
/* init rte_mbuf.rearm_data last 64-bit */
rx_pkts[i]->ol_flags = RTE_MBUF_F_RX_RSS_HASH;
rx_pkts[i]->hash.rss = rxdp[i].rx.rss_hash;
- rx_pkts[i]->pkt_len = rte_le_to_cpu_16(rxdp[i].rx.pkt_len) -
- rxq->crc_len;
+ rx_pkts[i]->pkt_len = rte_le_to_cpu_16(rxdp[i].rx.pkt_len);
rx_pkts[i]->data_len = rx_pkts[i]->pkt_len;
l234_info = rxdp[i].rx.l234_info;
--
2.33.0
next prev parent reply other threads:[~2024-07-19 9:11 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-06 1:10 [PATCH] net/hns3: fix Rx packet truncation when KEEP CRC enabled Jie Hai
2024-02-07 14:15 ` Ferruh Yigit
2024-02-20 3:58 ` Jie Hai
2024-02-23 13:53 ` Ferruh Yigit
2024-02-26 3:16 ` Jie Hai
2024-02-26 16:43 ` Ferruh Yigit
2024-02-28 2:27 ` huangdengdui
2024-02-28 13:07 ` Ferruh Yigit
2024-02-29 3:58 ` huangdengdui
2024-02-29 9:25 ` Ferruh Yigit
2024-03-01 6:55 ` huangdengdui
2024-03-01 11:10 ` Ferruh Yigit
2024-03-08 11:36 ` Jie Hai
2024-03-22 6:28 ` Jie Hai
2024-06-03 1:38 ` Jie Hai
2024-06-03 2:33 ` Stephen Hemminger
2024-06-03 5:24 ` Morten Brørup
2024-06-03 7:07 ` Andrew Rybchenko
2024-07-18 11:48 ` [PATCH v2 0/3] bugfix about KEEP CRC offload Jie Hai
2024-07-18 11:48 ` [PATCH v2 1/3] ethdev: add description for " Jie Hai
2024-07-18 11:57 ` Morten Brørup
2024-07-18 11:48 ` [PATCH v2 2/3] net/hns3: fix packet length do not contain CRC data length Jie Hai
2024-07-18 11:48 ` [PATCH v2 3/3] net/hns3: fix Rx packet without CRC data Jie Hai
2024-07-18 12:35 ` [PATCH v2 0/3] bugfix about KEEP CRC offload lihuisong (C)
2024-07-19 9:04 ` [PATCH v3 " Jie Hai
2024-07-19 9:04 ` [PATCH v3 1/3] ethdev: add description for " Jie Hai
2024-09-05 6:33 ` Andrew Rybchenko
2024-07-19 9:04 ` Jie Hai [this message]
2024-07-19 9:04 ` [PATCH v3 3/3] net/hns3: fix Rx packet without CRC data Jie Hai
2024-07-19 9:49 ` [PATCH v3 0/3] bugfix about KEEP CRC offload fengchengwen
2024-08-09 9:21 ` Jie Hai
2024-09-05 2:53 ` Jie Hai
2024-10-18 1:39 ` Jie Hai
2024-11-06 2:19 ` Jie Hai
2024-11-13 3:14 ` Jie Hai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240719090415.1513301-3-haijie1@huawei.com \
--to=haijie1@huawei.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=ferruh.yigit@amd.com \
--cc=huangdengdui@huawei.com \
--cc=humin29@huawei.com \
--cc=lihuisong@huawei.com \
--cc=mb@smartsharesystems.com \
--cc=stephen@networkplumber.org \
--cc=wathsala.vithanage@arm.com \
--cc=xavier.huwei@huawei.com \
--cc=yisen.zhuang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).