|
12 | 12 | *
|
13 | 13 | * The 2 bytes tag form a 16 bit big endian word. The exact
|
14 | 14 | * meaning has been guessed from packet dumps from ingress
|
15 |
| - * frames, as no working egress traffic has been available |
16 |
| - * we do not know the format of the egress tags or if they |
17 |
| - * are even supported. |
| 15 | + * frames. |
18 | 16 | */
|
19 | 17 |
|
20 | 18 | #include <linux/etherdevice.h>
|
|
36 | 34 | static struct sk_buff *rtl4a_tag_xmit(struct sk_buff *skb,
|
37 | 35 | struct net_device *dev)
|
38 | 36 | {
|
39 |
| - /* |
40 |
| - * Just let it pass thru, we don't know if it is possible |
41 |
| - * to tag a frame with the 0x8899 ethertype and direct it |
42 |
| - * to a specific port, all attempts at reverse-engineering have |
43 |
| - * ended up with the frames getting dropped. |
44 |
| - * |
45 |
| - * The VLAN set-up needs to restrict the frames to the right port. |
46 |
| - * |
47 |
| - * If you have documentation on the tagging format for RTL8366RB |
48 |
| - * (tag type A) then please contribute. |
49 |
| - */ |
| 37 | + struct dsa_port *dp = dsa_slave_to_port(dev); |
| 38 | + u8 *tag; |
| 39 | + u16 *p; |
| 40 | + u16 out; |
| 41 | + |
| 42 | + /* Pad out to at least 60 bytes */ |
| 43 | + if (unlikely(eth_skb_pad(skb))) |
| 44 | + return NULL; |
| 45 | + if (skb_cow_head(skb, RTL4_A_HDR_LEN) < 0) |
| 46 | + return NULL; |
| 47 | + |
| 48 | + netdev_dbg(dev, "add realtek tag to package to port %d\n", |
| 49 | + dp->index); |
| 50 | + skb_push(skb, RTL4_A_HDR_LEN); |
| 51 | + |
| 52 | + memmove(skb->data, skb->data + RTL4_A_HDR_LEN, 2 * ETH_ALEN); |
| 53 | + tag = skb->data + 2 * ETH_ALEN; |
| 54 | + |
| 55 | + /* Set Ethertype */ |
| 56 | + p = (u16 *)tag; |
| 57 | + *p = htons(RTL4_A_ETHERTYPE); |
| 58 | + |
| 59 | + out = (RTL4_A_PROTOCOL_RTL8366RB << 12) | (2 << 8); |
| 60 | + /* The lower bits is the port numer */ |
| 61 | + out |= (u8)dp->index; |
| 62 | + p = (u16 *)(tag + 2); |
| 63 | + *p = htons(out); |
| 64 | + |
50 | 65 | return skb;
|
51 | 66 | }
|
52 | 67 |
|
|
0 commit comments