Commit 86dd9868 authored by Linus Walleij's avatar Linus Walleij Committed by David S. Miller

net: dsa: tag_rtl4_a: Support also egress tags

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: default avatarDENG Qingfang <dqfext@gmail.com>
Fixes: efd7fe68 ("net: dsa: tag_rtl4_a: Implement Realtek 4 byte A tag")
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c544fcb4
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* *
* The 2 bytes tag form a 16 bit big endian word. The exact * The 2 bytes tag form a 16 bit big endian word. The exact
* meaning has been guessed from packet dumps from ingress * meaning has been guessed from packet dumps from ingress
* frames, as no working egress traffic has been available * frames.
* we do not know the format of the egress tags or if they
* are even supported.
*/ */
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
...@@ -36,17 +34,34 @@ ...@@ -36,17 +34,34 @@
static struct sk_buff *rtl4a_tag_xmit(struct sk_buff *skb, static struct sk_buff *rtl4a_tag_xmit(struct sk_buff *skb,
struct net_device *dev) struct net_device *dev)
{ {
/* struct dsa_port *dp = dsa_slave_to_port(dev);
* Just let it pass thru, we don't know if it is possible u8 *tag;
* to tag a frame with the 0x8899 ethertype and direct it u16 *p;
* to a specific port, all attempts at reverse-engineering have u16 out;
* ended up with the frames getting dropped.
* /* Pad out to at least 60 bytes */
* The VLAN set-up needs to restrict the frames to the right port. if (unlikely(eth_skb_pad(skb)))
* return NULL;
* If you have documentation on the tagging format for RTL8366RB if (skb_cow_head(skb, RTL4_A_HDR_LEN) < 0)
* (tag type A) then please contribute. return NULL;
*/
netdev_dbg(dev, "add realtek tag to package to port %d\n",
dp->index);
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);
/* The lower bits is the port numer */
out |= (u8)dp->index;
p = (u16 *)(tag + 2);
*p = htons(out);
return skb; return skb;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment