From: Xingui Yang <yangxingui@huawei.com>
To: <dev@dpdk.org>
Cc: <stephen@networkplumber.org>, <david.marchand@redhat.com>,
<liuyonglong@huawei.com>, <kangfenglong@huawei.com>,
<fengchengwen@huawei.com>, <lihuisong@huawei.com>
Subject: [PATCH 1/2] net/hns3: fix VLAN tag loss for short tunnel frame
Date: Mon, 29 Sep 2025 19:35:53 +0800 [thread overview]
Message-ID: <20250929113554.2443832-2-yangxingui@huawei.com> (raw)
In-Reply-To: <20250929113554.2443832-1-yangxingui@huawei.com>
When the hardware handles short tunnel frames below 65 bytes, the VLAN tag
will be lost if VLAN insert or QinQ insert is enabled. Therefore, the
packet size of the tunnel frame is padded to 65 bytes to fix this issue.
Fixes: de620754a109 ("net/hns3: fix sending packets less than 60 bytes")
Cc: stable@dpdk.org
Signed-off-by: Xingui Yang <yangxingui@huawei.com>
---
drivers/net/hns3/hns3_ethdev.h | 1 +
drivers/net/hns3/hns3_rxtx.c | 48 +++++++++++++++++++++++-----------
2 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index f6bb1b5d43..209b042816 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -75,6 +75,7 @@
#define HNS3_DEFAULT_MTU 1500UL
#define HNS3_DEFAULT_FRAME_LEN (HNS3_DEFAULT_MTU + HNS3_ETH_OVERHEAD)
#define HNS3_HIP08_MIN_TX_PKT_LEN 33
+#define HNS3_MIN_TUN_PKT_LEN 65
#define HNS3_BITS_PER_BYTE 8
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index aa7ee6f3e8..df703134be 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4219,6 +4219,37 @@ hns3_tx_fill_hw_ring(struct hns3_tx_queue *txq,
}
}
+static bool
+hns3_tx_pktmbuf_append(struct hns3_tx_queue *txq,
+ struct rte_mbuf *tx_pkt)
+{
+ uint16_t add_len = 0;
+ uint32_t ptype;
+ char *appended;
+
+ if (unlikely(tx_pkt->ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ) &&
+ rte_pktmbuf_pkt_len(tx_pkt) < HNS3_MIN_TUN_PKT_LEN)) {
+ ptype = rte_net_get_ptype(tx_pkt, NULL, RTE_PTYPE_L2_MASK |
+ RTE_PTYPE_L3_MASK | RTE_PTYPE_L4_MASK |
+ RTE_PTYPE_TUNNEL_MASK);
+ if (ptype & RTE_PTYPE_TUNNEL_MASK)
+ add_len = HNS3_MIN_TUN_PKT_LEN - rte_pktmbuf_pkt_len(tx_pkt);
+ } else if (unlikely(rte_pktmbuf_pkt_len(tx_pkt) < txq->min_tx_pkt_len)) {
+ add_len = txq->min_tx_pkt_len - rte_pktmbuf_pkt_len(tx_pkt);
+ }
+
+ if (unlikely(add_len > 0)) {
+ appended = rte_pktmbuf_append(tx_pkt, add_len);
+ if (appended == NULL) {
+ txq->dfx_stats.pkt_padding_fail_cnt++;
+ return false;
+ }
+ memset(appended, 0, add_len);
+ }
+
+ return true;
+}
+
uint16_t
hns3_xmit_pkts_simple(void *tx_queue,
struct rte_mbuf **tx_pkts,
@@ -4296,21 +4327,8 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
* by hardware in Tx direction, driver need to pad it to avoid
* error.
*/
- if (unlikely(rte_pktmbuf_pkt_len(tx_pkt) <
- txq->min_tx_pkt_len)) {
- uint16_t add_len;
- char *appended;
-
- add_len = txq->min_tx_pkt_len -
- rte_pktmbuf_pkt_len(tx_pkt);
- appended = rte_pktmbuf_append(tx_pkt, add_len);
- if (appended == NULL) {
- txq->dfx_stats.pkt_padding_fail_cnt++;
- break;
- }
-
- memset(appended, 0, add_len);
- }
+ if (!hns3_tx_pktmbuf_append(txq, tx_pkt))
+ break;
m_seg = tx_pkt;
--
2.33.0
next prev parent reply other threads:[~2025-09-29 11:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 11:35 [PATCH 0/2] bugfix for hns3 Xingui Yang
2025-09-29 11:35 ` Xingui Yang [this message]
2025-09-29 11:35 ` [PATCH 2/2] net/hns3: print invalid MAC address from firmware Xingui Yang
2025-09-29 23:57 ` [PATCH 0/2] bugfix for hns3 Stephen Hemminger
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=20250929113554.2443832-2-yangxingui@huawei.com \
--to=yangxingui@huawei.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=kangfenglong@huawei.com \
--cc=lihuisong@huawei.com \
--cc=liuyonglong@huawei.com \
--cc=stephen@networkplumber.org \
/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).