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 7568E45B6C for ; Fri, 18 Oct 2024 20:13:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6B735402EB; Fri, 18 Oct 2024 20:13:54 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 7DBEE4025C; Fri, 18 Oct 2024 20:13:52 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1202) id B306120FFC9C; Fri, 18 Oct 2024 11:13:51 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B306120FFC9C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1729275231; bh=qHSYF+QEv9/cytB8fY6pfxnoBXwQlfmXXUwPEAmJcxE=; h=From:To:Cc:Subject:Date:Reply-To:From; b=e/OieyVB/ERYRSv60DXNcnVCGqq7hFLW1DxFXCJ206LbFT/OnBcuTJNLBEljvsaEX JnLtM33k52eFWqs6u/tooyDafUzunAQOiwSnp0Mck00WxUqvvKzotfYvAWEhIX0siN b/mz3FtjSXZ1Wyvkr/TLgFkMSnMpmhtt04vRJDBo= From: longli@linuxonhyperv.com To: Ferruh Yigit , Andrew Rybchenko Cc: dev@dpdk.org, Long Li , "Hui (Hui) Ling" , Stephen Hemminger , Wei Hu , stable@dpdk.org Subject: [PATCH] net/netvsc: force TX VLAN offload on 801.2Q packet Date: Fri, 18 Oct 2024 11:13:50 -0700 Message-Id: <1729275230-16011-1-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: longli@microsoft.com Errors-To: stable-bounces@dpdk.org From: Long Li 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 Cc: Stephen Hemminger Cc: Wei Hu Cc: stable@dpdk.org Signed-off-by: Long Li --- drivers/net/netvsc/hn_rxtx.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c index 9bf1ec5509..e58efe793e 100644 --- a/drivers/net/netvsc/hn_rxtx.c +++ b/drivers/net/netvsc/hn_rxtx.c @@ -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) { -- 2.25.1