Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp41797ybh; Mon, 20 Jul 2020 09:50:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmJWFKK9AP2BewAyzpATnWnKEw6tkCj81eqV69NeG+GhP7NHz+q4u9sfGZ5S3jAbqI1n59 X-Received: by 2002:a05:6402:706:: with SMTP id w6mr21717652edx.326.1595263805405; Mon, 20 Jul 2020 09:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595263805; cv=none; d=google.com; s=arc-20160816; b=SfmuNZ6pmPZMkKIutZU182IfzqRvzYadVw1ytPbi5efiUF3ltTctNiHdKcU/ouksG3 8AQqeOqbDoyxXOiHXLXnPMX4bylbyJxXVdu5XhVVsxt4IocGbahHqOyj+ws6muZ7Ji/q zuW4b2SneAqIvrSqGmb8F0d/lZ968Lsxn8SsjY3p48lotU8g1mMPSCpCxPCvHspeJICH 9M1RHYUn2vQbf+gG8zdZyYNnqqVmcPh7Ez4vEsJAKRlp1nLT3mZN2d9WRiYOsT4N5P0A sPbwZLqsq+2iqFEZatUbqd0wIpgx4VLXENJcnQn1QUklgh2yTnBFQLMCH2G/3eMX6rqc olGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Z3uvwXcOkYVctC63aGiHvUQD7n8r/bognzF25//WV1c=; b=ktmcwZ63EAxLr9aaTOFRHMsi35+sPy9ER14aHTS3hFhyxytbF5puVXSazsi+D739tm e2ZO1qh7QVDAhZVSjIjsUmIju1bFSwBWPbZMwUMFZJFcX3o6X5ic6xOJZLGy/1jTfZcn 5ATQhHknfBQ3XXqksknnrs7jFCYjINlgJuUnfQikQioF5AIT9R9CI2ECKC9sauLwhPmv nr9kCPuVs5+rZcuaKxj3k5la08aZIr1WD+u2ruOfwPxq1PpOw+bccBTUPck/3ozxkCqi fcwl4CbNUMtR3BF9GxtkTgsd78ZNv4g7IY7TEEmz3ym6NM2LI/9zCMEDqL5GnYQsFu15 wPew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=iER91zsD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cisco.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si10903862ejc.7.2020.07.20.09.49.41; Mon, 20 Jul 2020 09:50:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=iER91zsD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cisco.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730272AbgGTQqO (ORCPT + 99 others); Mon, 20 Jul 2020 12:46:14 -0400 Received: from bgl-iport-3.cisco.com ([72.163.197.27]:30487 "EHLO bgl-iport-3.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730328AbgGTQp6 (ORCPT ); Mon, 20 Jul 2020 12:45:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=3119; q=dns/txt; s=iport; t=1595263557; x=1596473157; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Vdjo6hmqo0zLm1DR6bYASgDhovS0RKIR/PWgbRmhkv4=; b=iER91zsDStYg6kxHzwcD/cI4oCz7yFlYn5ocbodVe1PUwFXKUPd0DBSA Vn4egPYEMb3/lZGwCukCXzmUaO4g2Ng1odQfZxel8WM8tLHjLPmOR2yGi odSSvUqupb5zK2hA7IO6zbX2bwZm/G5SPMpqMqaPrFbceuwhE9cmzmNvS 4=; X-IronPort-AV: E=Sophos;i="5.75,375,1589241600"; d="scan'208";a="126215549" Received: from vla196-nat.cisco.com (HELO bgl-core-4.cisco.com) ([72.163.197.24]) by bgl-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 20 Jul 2020 16:45:52 +0000 Received: from SRIRAKR2-M-R0A8.cisco.com ([10.65.70.250]) by bgl-core-4.cisco.com (8.15.2/8.15.2) with ESMTP id 06KGjq3j001338; Mon, 20 Jul 2020 16:45:52 GMT From: Sriram Krishnan To: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu Cc: mbumgard@cisco.com, ugm@cisco.com, nimm@cisco.com, xe-linux-external@cisco.com, "David S. Miller" , Jakub Kicinski , linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] net: hyperv: add support for vlans in netvsc driver Date: Mon, 20 Jul 2020 22:15:51 +0530 Message-Id: <20200720164551.14153-1-srirakr2@cisco.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Auto-Response-Suppress: DR, OOF, AutoReply X-Outbound-SMTP-Client: 10.65.70.250, [10.65.70.250] X-Outbound-Node: bgl-core-4.cisco.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Vlan tagged packets are getting dropped when used with DPDK that uses the AF_PACKET interface on a hyperV guest. The packet layer uses the tpacket interface to communicate the vlans information to the upper layers. On Rx path, these drivers can read the vlan info from the tpacket header but on the Tx path, this information is still within the packet frame and requires the paravirtual drivers to push this back into the NDIS header which is then used by the host OS to form the packet. This transition from the packet frame to NDIS header is currently missing hence causing the host OS to drop the all vlan tagged packets sent by the drivers that use AF_PACKET (ETH_P_ALL) such as DPDK. Here is an overview of the changes in the vlan header in the packet path: The RX path (userspace handles everything): 1. RX VLAN packet is stripped by HOST OS and placed in NDIS header 2. Guest Kernel RX hv_netvsc packets and moves VLAN info from NDIS header into kernel SKB 3. Kernel shares packets with user space application with PACKET_MMAP. The SKB VLAN info is copied to tpacket layer and indication set TP_STATUS_VLAN_VALID. 4. The user space application will re-insert the VLAN info into the frame. The TX path: 1. The user space application has the VLAN info in the frame. 2. Guest kernel gets packets from the application with PACKET_MMAP. 3. The kernel later sends the frame to the hv_netvsc driver. The only way to send VLANs is when the SKB is setup & the VLAN is is stripped from the frame. 4. TX VLAN is re-inserted by HOST OS based on the NDIS header. If it sees a VLAN in the frame the packet is dropped. Cc: xe-linux-external@cisco.com Cc: Sriram Krishnan Signed-off-by: Sriram Krishnan --- drivers/net/hyperv/netvsc_drv.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 6267f706e8ee..2a25b4352369 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -605,6 +605,29 @@ static int netvsc_xmit(struct sk_buff *skb, struct net_device *net, bool xdp_tx) *hash_info = hash; } + /* When using AF_PACKET we need to remove VLAN from frame + * and indicate VLAN information in SKB so HOST OS will + * transmit the VLAN frame + */ + if (skb->protocol == htons(ETH_P_8021Q)) { + u16 vlan_tci = 0; + skb_reset_mac_header(skb); + if (eth_type_vlan(eth_hdr(skb)->h_proto)) { + int pop_err; + pop_err = __skb_vlan_pop(skb, &vlan_tci); + if (likely(pop_err == 0)) { + __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci); + + /* Update the NDIS header pkt lengths */ + packet->total_data_buflen -= VLAN_HLEN; + rndis_msg->msg_len = packet->total_data_buflen; + rndis_msg->msg.pkt.data_len = packet->total_data_buflen; + + } else { + netdev_err(net,"Pop vlan err %x\n",pop_err); + } + } + } if (skb_vlan_tag_present(skb)) { struct ndis_pkt_8021q_info *vlan; -- 2.24.0