From: Haiyang Zhang <haiyangz@microsoft.com>
To: Sriram Krishnan <srirakr2@cisco.com>,
KY Srinivasan <kys@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
Wei Liu <wei.liu@kernel.org>
Cc: "mbumgard@cisco.com" <mbumgard@cisco.com>,
"ugm@cisco.com" <ugm@cisco.com>,
"nimm@cisco.com" <nimm@cisco.com>,
"xe-linux-external@cisco.com" <xe-linux-external@cisco.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v3] net: hyperv: add support for vlans in netvsc driver
Date: Mon, 20 Jul 2020 17:45:18 +0000 [thread overview]
Message-ID: <BL0PR2101MB09304B3A612EBB45127CFCEDCA7B0@BL0PR2101MB0930.namprd21.prod.outlook.com> (raw)
In-Reply-To: <20200720164551.14153-1-srirakr2@cisco.com>
> -----Original Message-----
> From: Sriram Krishnan <srirakr2@cisco.com>
> Sent: Monday, July 20, 2020 12:46 PM
> To: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang
> <haiyangz@microsoft.com>; Stephen Hemminger <sthemmin@microsoft.com>;
> Wei Liu <wei.liu@kernel.org>
> Cc: mbumgard@cisco.com; ugm@cisco.com; nimm@cisco.com; xe-linux-
> external@cisco.com; David S. Miller <davem@davemloft.net>; Jakub Kicinski
> <kuba@kernel.org>; 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
>
> 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 <srirakr2@cisco.com>
> Signed-off-by: Sriram Krishnan <srirakr2@cisco.com>
> ---
> 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;
packet->total_bytes should be updated too.
Thanks,
- Haiyang
next prev parent reply other threads:[~2020-07-20 17:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-20 16:45 [PATCH v3] net: hyperv: add support for vlans in netvsc driver Sriram Krishnan
2020-07-20 17:34 ` Stephen Hemminger
2020-07-20 17:45 ` Haiyang Zhang [this message]
2020-07-20 17:51 ` Haiyang Zhang
2020-07-20 23:27 ` David Miller
2020-07-21 7:09 ` Sriram Krishnan (srirakr2)
2020-07-21 22:18 ` Haiyang Zhang
2020-07-22 10:44 ` Sriram Krishnan (srirakr2)
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=BL0PR2101MB09304B3A612EBB45127CFCEDCA7B0@BL0PR2101MB0930.namprd21.prod.outlook.com \
--to=haiyangz@microsoft.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbumgard@cisco.com \
--cc=netdev@vger.kernel.org \
--cc=nimm@cisco.com \
--cc=srirakr2@cisco.com \
--cc=sthemmin@microsoft.com \
--cc=ugm@cisco.com \
--cc=wei.liu@kernel.org \
--cc=xe-linux-external@cisco.com \
/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).