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 5B23445644; Thu, 18 Jul 2024 13:48:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C8FC942E99; Thu, 18 Jul 2024 13:48:34 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 0A50A402A8 for ; Thu, 18 Jul 2024 13:48:31 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4WPrY427NPz1JCy2; Thu, 18 Jul 2024 19:43:36 +0800 (CST) Received: from kwepemf500004.china.huawei.com (unknown [7.202.181.242]) by mail.maildlp.com (Postfix) with ESMTPS id 6AC9B1800A3; Thu, 18 Jul 2024 19:48:29 +0800 (CST) Received: from localhost.huawei.com (10.90.30.45) by kwepemf500004.china.huawei.com (7.202.181.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 18 Jul 2024 19:48:28 +0800 From: Jie Hai To: , , , , , Yisen Zhuang , Ruifeng Wang , "Min Hu (Connor)" , "Wei Hu (Xavier)" CC: , , Subject: [PATCH v2 2/3] net/hns3: fix packet length do not contain CRC data length Date: Thu, 18 Jul 2024 19:48:04 +0800 Message-ID: <20240718114806.577298-3-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240718114806.577298-1-haijie1@huawei.com> References: <20240206011030.2007689-1-haijie1@huawei.com> <20240718114806.577298-1-haijie1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.90.30.45] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemf500004.china.huawei.com (7.202.181.242) 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: Dengdui Huang 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 --- 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 5941b966e0..39ba9080ea 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 0dc6b9f0a2..60ec501a2a 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 8aa4448558..67c87f570e 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