Commit b74b70c44986dee87881fbed3d912e02c5dcf78c
Committed by
David S. Miller
1 parent
f7c39e3d1e
net: dsa: Support prepended Broadcom tag
Add a new type: DSA_TAG_PROTO_PREPEND which allows us to support for the 4-bytes Broadcom tag that we already support, but in a format where it is pre-pended to the packet instead of located between the MAC SA and the Ethertyper (DSA_TAG_PROTO_BRCM). Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 6 changed files with 41 additions and 7 deletions Side-by-side Diff
include/net/dsa.h
net/dsa/Kconfig
net/dsa/Makefile
... | ... | @@ -5,6 +5,7 @@ |
5 | 5 | |
6 | 6 | # tagging formats |
7 | 7 | dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o |
8 | +dsa_core-$(CONFIG_NET_DSA_TAG_BRCM_PREPEND) += tag_brcm.o | |
8 | 9 | dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o |
9 | 10 | dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o |
10 | 11 | dsa_core-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o |
net/dsa/dsa.c
... | ... | @@ -44,6 +44,9 @@ |
44 | 44 | #ifdef CONFIG_NET_DSA_TAG_BRCM |
45 | 45 | [DSA_TAG_PROTO_BRCM] = &brcm_netdev_ops, |
46 | 46 | #endif |
47 | +#ifdef CONFIG_NET_DSA_TAG_BRCM_PREPEND | |
48 | + [DSA_TAG_PROTO_BRCM_PREPEND] = &brcm_prepend_netdev_ops, | |
49 | +#endif | |
47 | 50 | #ifdef CONFIG_NET_DSA_TAG_DSA |
48 | 51 | [DSA_TAG_PROTO_DSA] = &dsa_netdev_ops, |
49 | 52 | #endif |
net/dsa/dsa_priv.h
net/dsa/tag_brcm.c
... | ... | @@ -96,13 +96,6 @@ |
96 | 96 | return skb; |
97 | 97 | } |
98 | 98 | |
99 | -static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb, | |
100 | - struct net_device *dev) | |
101 | -{ | |
102 | - /* Build the tag after the MAC Source Address */ | |
103 | - return brcm_tag_xmit_ll(skb, dev, 2 * ETH_ALEN); | |
104 | -} | |
105 | - | |
106 | 99 | static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb, |
107 | 100 | struct net_device *dev, |
108 | 101 | struct packet_type *pt, |
... | ... | @@ -139,6 +132,15 @@ |
139 | 132 | return skb; |
140 | 133 | } |
141 | 134 | |
135 | +#ifdef CONFIG_NET_DSA_TAG_BRCM | |
136 | +static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb, | |
137 | + struct net_device *dev) | |
138 | +{ | |
139 | + /* Build the tag after the MAC Source Address */ | |
140 | + return brcm_tag_xmit_ll(skb, dev, 2 * ETH_ALEN); | |
141 | +} | |
142 | + | |
143 | + | |
142 | 144 | static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev, |
143 | 145 | struct packet_type *pt) |
144 | 146 | { |
... | ... | @@ -161,4 +163,27 @@ |
161 | 163 | .xmit = brcm_tag_xmit, |
162 | 164 | .rcv = brcm_tag_rcv, |
163 | 165 | }; |
166 | +#endif | |
167 | + | |
168 | +#ifdef CONFIG_NET_DSA_TAG_BRCM_PREPEND | |
169 | +static struct sk_buff *brcm_tag_xmit_prepend(struct sk_buff *skb, | |
170 | + struct net_device *dev) | |
171 | +{ | |
172 | + /* tag is prepended to the packet */ | |
173 | + return brcm_tag_xmit_ll(skb, dev, 0); | |
174 | +} | |
175 | + | |
176 | +static struct sk_buff *brcm_tag_rcv_prepend(struct sk_buff *skb, | |
177 | + struct net_device *dev, | |
178 | + struct packet_type *pt) | |
179 | +{ | |
180 | + /* tag is prepended to the packet */ | |
181 | + return brcm_tag_rcv_ll(skb, dev, pt, ETH_HLEN); | |
182 | +} | |
183 | + | |
184 | +const struct dsa_device_ops brcm_prepend_netdev_ops = { | |
185 | + .xmit = brcm_tag_xmit_prepend, | |
186 | + .rcv = brcm_tag_rcv_prepend, | |
187 | +}; | |
188 | +#endif |