From: Elad Nachman <eladv6@gmail•com>
To: Jose Abreu <Jose.Abreu@synopsys•com>,
Florian Fainelli <f.fainelli@gmail•com>,
David Miller <davem@davemloft•net>
Cc: makita.toshiaki@lab•ntt.co.jp, netdev@vger•kernel.org,
peppe.cavallaro@st•com, alexandre.torgue@st•com
Subject: Re: [PATCH v2 net] stmmac: strip vlan tag on reception only for 8021q tagged frames
Date: Wed, 23 May 2018 18:00:23 +0300 [thread overview]
Message-ID: <cb8a0eaa-43c8-902c-ebd3-2aa90bf868b2@gmail.com> (raw)
In-Reply-To: <09c5b6b3-faa5-fd99-76bd-72a107122f2a@synopsys.com>
Jose,
I am not sure which drivers you have checked. I guess most non-networking embedded drivers never use 802.1AD
so they stay broken unknowingly.
Specifically, I have tested Intel e1000e based card which works correctly versus stmmac which works incorrectly.
If you check netdev.c in e1000e then the vlan strip is conditional upon checking of 802.1Q bit in the descriptor,
which does not happen in stmmac_main.c - the vlan stripping happens based on any tag header check.
Once I applied my patch things started working - did not have to patch e1000e. The problem is that ip link allows to create 802.1ad devices which are not 0x8100 tagged but stmmac and probably other drivers handles the non 0x8100 tag incorrectly and the vlan slave discards the frame.
Regarding the getting the tag from the descriptor - this is of course a possibility. My original patch handled stripping of all tags but then I was told here that I cannot strip 802.1ad tags without the NETIF_F_HW_VLAN_STAG_RX feature, which is probably correct regardless of the source of the vlan tag - skb or descriptor.
I can also add the NETIF_F_HW_VLAN_STAG_RX feature plus the following original v1 patch:
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 2018-04-11 17:04:00.586057300 +0300
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 2018-04-11 17:05:33.601992400 +0300
@@ -3293,17 +3293,19 @@ dma_map_err:
static void stmmac_rx_vlan(struct net_device *dev, struct sk_buff *skb)
{
- struct ethhdr *ehdr;
+ struct vlan_ethhdr *veth;
u16 vlanid;
+ __be16 vlan_proto;
if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) ==
NETIF_F_HW_VLAN_CTAG_RX &&
!__vlan_get_tag(skb, &vlanid)) {
/* pop the vlan tag */
- ehdr = (struct ethhdr *)skb->data;
- memmove(skb->data + VLAN_HLEN, ehdr, ETH_ALEN * 2);
+ veth = (struct vlan_ethhdr *)skb->data;
+ vlan_proto = veth->h_vlan_proto;
+ memmove(skb->data + VLAN_HLEN, veth, ETH_ALEN * 2);
skb_pull(skb, VLAN_HLEN);
- __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlanid);
+ __vlan_hwaccel_put_tag(skb, vlan_proto, vlanid);
}
}
There are three reasons why I prefer using this approach rather than the descriptor approach:
A. It is inline with the original driver code.
B. Using descriptor vlan will require to completely rewrite stmmac_rx_vlan and will result in at least 2-3 times line counts in the patch.
C. I have no idea if first silicon implementations of DWMAC IP had some kind of HW bug (for example AXI clock glitch) which caused sampling of the VLAN tag in the descriptors to be unstable, and since I have no access to such hardware for regression I risk breaking stmmac for such old SOCs in case they decide to jump kernel versions to the latest.
Thanks,
Elad.
On 22/05/18 11:56, Jose Abreu wrote:
> On 21-05-2018 17:42, Florian Fainelli wrote:
>> On 05/21/2018 08:48 AM, David Miller wrote:
>>> From: David Miller <davem@davemloft•net>
>>> Date: Thu, 17 May 2018 12:43:56 -0400 (EDT)
>>>
>>>> Giuseppe and Alexandre, please review this patch.
>>> If nobody thinks this patch is important enough to actually
>>> review, I'm tossing it.
>>>
>>> Sorry.
>>>
>> How about looping in Jose?
>
> Thanks for the cc Florian!
>
> Elad,
>
> Looking at this patch I have a couple of questions and suggestions:
>
> I see that most drivers use this pattern so, are they all broken?
> or is this a special case?
>
> You can also get the inner/outer vlan tag by reading desc0 of
> receive descriptor. Which can make this completely agnostic of
> VLAN tag.
>
> Thanks and Best Regards,
> Jose Miguel Abreu
>
next prev parent reply other threads:[~2018-05-23 15:00 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-08 6:01 [PATCH net] stmmac: fix reception of 802.1ad Ethernet tagged frames Elad Nachman
2018-05-08 6:43 ` Toshiaki Makita
2018-05-08 7:11 ` Elad Nachman
2018-05-08 7:34 ` Toshiaki Makita
2018-05-11 7:31 ` [PATCH v2 net] stmmac: strip vlan tag on reception only for 8021q " Elad Nachman
2018-05-17 16:43 ` David Miller
2018-05-21 15:48 ` David Miller
2018-05-21 16:42 ` Florian Fainelli
2018-05-22 8:56 ` Jose Abreu
2018-05-23 15:00 ` Elad Nachman [this message]
2018-05-24 12:56 ` Jose Abreu
2018-05-24 16:56 ` [PATCH v3 net] stmmac: Added support for 802.1ad S-TAG stripping Elad Nachman
2018-05-25 0:34 ` Toshiaki Makita
2018-05-26 19:24 ` [PATCH v4 net] stmmac: 802.1ad tag stripping support fix Elad Nachman
2018-05-28 0:44 ` Toshiaki Makita
2018-05-30 5:48 ` [PATCH v5 net] stmmac: 802.1ad tag stripping fix Elad Nachman
2018-05-30 6:08 ` Toshiaki Makita
2018-05-30 6:16 ` Elad Nachman
2018-05-30 6:26 ` Toshiaki Makita
2018-06-03 14:33 ` David Miller
2018-06-04 0:49 ` Toshiaki Makita
2018-06-08 9:19 ` [PATCH v6 net] stmmac: strip all VLAN tag types when kernel 802.1Q support is selected Elad Nachman
2018-06-10 19:29 ` David Miller
2018-06-11 0:50 ` Toshiaki Makita
2018-06-15 6:57 ` [PATCH v7 net] stmmac: added support for 802.1ad vlan stripping Elad Nachman
2018-06-15 7:19 ` Toshiaki Makita
2018-06-15 16:06 ` David Miller
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=cb8a0eaa-43c8-902c-ebd3-2aa90bf868b2@gmail.com \
--to=eladv6@gmail$(echo .)com \
--cc=Jose.Abreu@synopsys$(echo .)com \
--cc=alexandre.torgue@st$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=f.fainelli@gmail$(echo .)com \
--cc=makita.toshiaki@lab$(echo .)ntt.co.jp \
--cc=netdev@vger$(echo .)kernel.org \
--cc=peppe.cavallaro@st$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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