Skip to contentSkip to conversation

net/netvsc: force TX VLAN offload on 801.2Q packet

PATCH Applied [email protected] 3 participants 3 messages Oct 18, 2024 – Oct 26, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/netvsc: force TX VLAN offload on 801.2Q packet

From: Long Li <[email protected]>

The VSP assumes the packet doesn't have VLAN tags. When VLAN tag is present in a TX packet, always strip it and use PPI to send VLAN info through VSP packet.

Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
Cc Hui (Hui) Ling <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Wei Hu <[email protected]>
---
 drivers/net/netvsc/hn_rxtx.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/net/netvsc/hn_rxtx.c +19 -1
index 9bf1ec5509..e58efe793e 100644
@@ -1518,14 +1518,32 @@ hn_xmit_pkts(void *ptxq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
 		struct rte_mbuf *m = tx_pkts[nb_tx];
-		uint32_t pkt_size = m->pkt_len + HN_RNDIS_PKT_LEN;
 		struct rndis_packet_msg *pkt;
 		struct hn_txdesc *txd;
+		uint32_t pkt_size;
 
 		txd = hn_txd_get(txq);
 		if (txd == NULL)
 			break;
 
+		if (!(m->ol_flags & RTE_MBUF_F_TX_VLAN)) {
+			struct rte_ether_hdr *eh =
+				rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
+			struct rte_vlan_hdr *vh;
+
+			/* Force TX vlan offloading for 801.2Q packet */
+			if (eh->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN)) {
+				vh = (struct rte_vlan_hdr *)(eh + 1);
+				m->ol_flags |= RTE_MBUF_F_TX_VLAN;
+				m->vlan_tci = rte_be_to_cpu_16(vh->vlan_tci);
+
+				/* Copy ether header over */
+				memmove(rte_pktmbuf_adj(m, sizeof(struct rte_vlan_hdr)),
+					eh, 2 * RTE_ETHER_ADDR_LEN);
+			}
+		}
+		pkt_size = m->pkt_len + HN_RNDIS_PKT_LEN;
+
 		/* For small packets aggregate them in chimney buffer */
 		if (m->pkt_len <= hv->tx_copybreak &&
 		    pkt_size <= txq->agg_szmax) {
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · On Fri, 18 Oct 2024 11:13:50 -0700 [email protected] wrote:

icrosoft.com>

The VSP assumes the packet doesn't have VLAN tags. When VLAN tag is present in a TX packet, always strip it and use PPI to send VLAN info through VSP packet.

Quoted 6 lines
Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
Cc Hui (Hui) Ling <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Wei Hu <[email protected]>

This was discovered from an network application that was using VLAN's but not setting the offload bits in the mbuf.

Applied
#2 lore raw
Quoted 16 lines · Stephen Hemminger
Quoted 6 lines · On Fri, 18 Oct 2024 11:13:50 -0700 [email protected] wrote:

icrosoft.com>

The VSP assumes the packet doesn't have VLAN tags. When VLAN tag is present in a TX packet, always strip it and use PPI to send VLAN info through VSP packet.

Quoted 6 lines
Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
Cc Hui (Hui) Ling <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Wei Hu <[email protected]>
Quoted 6 lines

This was discovered from an network application that was using VLAN's but not setting the offload bits in the mbuf.

Applied to dpdk-next-net/main, thanks.