From: Andrew Lunn <andrew@lunn.ch>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, Mauri Sandberg <sandberg@mailfence.com>,
DENG Qingfang <dqfext@gmail.com>
Subject: Re: [PATCH] net: dsa: tag_rtl4_a: Support also egress tags
Date: Wed, 17 Feb 2021 04:29:16 +0100 [thread overview]
Message-ID: <YCyNjB5PpYomt4Re@lunn.ch> (raw)
In-Reply-To: <20210216235542.2718128-1-linus.walleij@linaro.org>
On Wed, Feb 17, 2021 at 12:55:42AM +0100, Linus Walleij wrote:
> Support also transmitting frames using the custom "8899 A"
> 4 byte tag.
>
> Qingfang came up with the solution: we need to pad the
> ethernet frame to 60 bytes using eth_skb_pad(), then the
> switch will happily accept frames with custom tags.
>
> Cc: Mauri Sandberg <sandberg@mailfence.com>
> Reported-by: DENG Qingfang <dqfext@gmail.com>
> Fixes: efd7fe68f0c6 ("net: dsa: tag_rtl4_a: Implement Realtek 4 byte A tag")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> net/dsa/tag_rtl4_a.c | 43 +++++++++++++++++++++++++++++--------------
> 1 file changed, 29 insertions(+), 14 deletions(-)
>
> diff --git a/net/dsa/tag_rtl4_a.c b/net/dsa/tag_rtl4_a.c
> index 2646abe5a69e..c17d39b4a1a0 100644
> --- a/net/dsa/tag_rtl4_a.c
> +++ b/net/dsa/tag_rtl4_a.c
> @@ -12,9 +12,7 @@
> *
> * The 2 bytes tag form a 16 bit big endian word. The exact
> * meaning has been guessed from packet dumps from ingress
> - * frames, as no working egress traffic has been available
> - * we do not know the format of the egress tags or if they
> - * are even supported.
> + * frames.
> */
>
> #include <linux/etherdevice.h>
> @@ -36,17 +34,34 @@
> static struct sk_buff *rtl4a_tag_xmit(struct sk_buff *skb,
> struct net_device *dev)
> {
> - /*
> - * Just let it pass thru, we don't know if it is possible
> - * to tag a frame with the 0x8899 ethertype and direct it
> - * to a specific port, all attempts at reverse-engineering have
> - * ended up with the frames getting dropped.
> - *
> - * The VLAN set-up needs to restrict the frames to the right port.
> - *
> - * If you have documentation on the tagging format for RTL8366RB
> - * (tag type A) then please contribute.
> - */
> + struct dsa_port *dp = dsa_slave_to_port(dev);
> + u8 *tag;
> + u16 *p;
> + u16 out;
Reverse Christmass tree.
> +
> + /* Pad out to at least 60 bytes */
> + if (unlikely(eth_skb_pad(skb)))
> + return NULL;
The core will do the padding for you. Turn on .tail_tag in
dsa_device_ops.
> + if (skb_cow_head(skb, RTL4_A_HDR_LEN) < 0)
> + return NULL;
> +
> + netdev_dbg(dev, "add realtek tag to package to port %d\n",
> + dp->index);
You can remove this, now that it works.
> + skb_push(skb, RTL4_A_HDR_LEN);
> +
> + memmove(skb->data, skb->data + RTL4_A_HDR_LEN, 2 * ETH_ALEN);
> + tag = skb->data + 2 * ETH_ALEN;
> +
> + /* Set Ethertype */
> + p = (u16 *)tag;
> + *p = htons(RTL4_A_ETHERTYPE);
> +
> + out = (RTL4_A_PROTOCOL_RTL8366RB << 12) | (2 << 8);
Do we know what bit 9 means?
Andrew
next prev parent reply other threads:[~2021-02-17 3:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-16 23:55 [PATCH] net: dsa: tag_rtl4_a: Support also egress tags Linus Walleij
2021-02-17 1:00 ` patchwork-bot+netdevbpf
2021-02-17 1:04 ` Florian Fainelli
2021-02-17 3:29 ` Andrew Lunn [this message]
2021-02-17 5:37 ` DENG Qingfang
2021-02-17 11:41 ` Vladimir Oltean
2021-02-17 5:40 ` DENG Qingfang
2021-02-17 11:33 ` Vladimir Oltean
2021-02-17 12:38 ` DENG Qingfang
2021-02-17 12:42 ` Vladimir Oltean
2021-02-17 14:19 ` Heiner Kallweit
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=YCyNjB5PpYomt4Re@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=dqfext@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=sandberg@mailfence.com \
--cc=vivien.didelot@gmail.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).