diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2017-11-10 18:22:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-11-12 20:34:54 -0500 |
commit | b74b70c44986dee87881fbed3d912e02c5dcf78c (patch) | |
tree | c3d9d3d5577243c258d27153fdf114f1a7e73ba8 | |
parent | f7c39e3d1e094af1c3e0676b76c00d8c1f8e7774 (diff) |
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>
-rw-r--r-- | include/net/dsa.h | 1 | ||||
-rw-r--r-- | net/dsa/Kconfig | 3 | ||||
-rw-r--r-- | net/dsa/Makefile | 1 | ||||
-rw-r--r-- | net/dsa/dsa.c | 3 | ||||
-rw-r--r-- | net/dsa/dsa_priv.h | 1 | ||||
-rw-r--r-- | net/dsa/tag_brcm.c | 39 |
6 files changed, 41 insertions, 7 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h index 68e232fd4b0f..2a05738570d8 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h | |||
@@ -29,6 +29,7 @@ struct fixed_phy_status; | |||
29 | enum dsa_tag_protocol { | 29 | enum dsa_tag_protocol { |
30 | DSA_TAG_PROTO_NONE = 0, | 30 | DSA_TAG_PROTO_NONE = 0, |
31 | DSA_TAG_PROTO_BRCM, | 31 | DSA_TAG_PROTO_BRCM, |
32 | DSA_TAG_PROTO_BRCM_PREPEND, | ||
32 | DSA_TAG_PROTO_DSA, | 33 | DSA_TAG_PROTO_DSA, |
33 | DSA_TAG_PROTO_EDSA, | 34 | DSA_TAG_PROTO_EDSA, |
34 | DSA_TAG_PROTO_KSZ, | 35 | DSA_TAG_PROTO_KSZ, |
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig index cc5f8f971689..2fed892094bc 100644 --- a/net/dsa/Kconfig +++ b/net/dsa/Kconfig | |||
@@ -19,6 +19,9 @@ if NET_DSA | |||
19 | config NET_DSA_TAG_BRCM | 19 | config NET_DSA_TAG_BRCM |
20 | bool | 20 | bool |
21 | 21 | ||
22 | config NET_DSA_TAG_BRCM_PREPEND | ||
23 | bool | ||
24 | |||
22 | config NET_DSA_TAG_DSA | 25 | config NET_DSA_TAG_DSA |
23 | bool | 26 | bool |
24 | 27 | ||
diff --git a/net/dsa/Makefile b/net/dsa/Makefile index e9a4a0f33e86..0e13c1f95d13 100644 --- a/net/dsa/Makefile +++ b/net/dsa/Makefile | |||
@@ -5,6 +5,7 @@ dsa_core-y += dsa.o dsa2.o legacy.o master.o port.o slave.o switch.o | |||
5 | 5 | ||
6 | # tagging formats | 6 | # tagging formats |
7 | dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o | 7 | dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o |
8 | dsa_core-$(CONFIG_NET_DSA_TAG_BRCM_PREPEND) += tag_brcm.o | ||
8 | dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o | 9 | dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o |
9 | dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o | 10 | dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o |
10 | dsa_core-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o | 11 | dsa_core-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o |
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index b8f2d9f7c3ed..6a9d0f50fbee 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c | |||
@@ -44,6 +44,9 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = { | |||
44 | #ifdef CONFIG_NET_DSA_TAG_BRCM | 44 | #ifdef CONFIG_NET_DSA_TAG_BRCM |
45 | [DSA_TAG_PROTO_BRCM] = &brcm_netdev_ops, | 45 | [DSA_TAG_PROTO_BRCM] = &brcm_netdev_ops, |
46 | #endif | 46 | #endif |
47 | #ifdef CONFIG_NET_DSA_TAG_BRCM_PREPEND | ||
48 | [DSA_TAG_PROTO_BRCM_PREPEND] = &brcm_prepend_netdev_ops, | ||
49 | #endif | ||
47 | #ifdef CONFIG_NET_DSA_TAG_DSA | 50 | #ifdef CONFIG_NET_DSA_TAG_DSA |
48 | [DSA_TAG_PROTO_DSA] = &dsa_netdev_ops, | 51 | [DSA_TAG_PROTO_DSA] = &dsa_netdev_ops, |
49 | #endif | 52 | #endif |
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 507e1ce4d4d2..7d036696e8c4 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h | |||
@@ -191,6 +191,7 @@ void dsa_switch_unregister_notifier(struct dsa_switch *ds); | |||
191 | 191 | ||
192 | /* tag_brcm.c */ | 192 | /* tag_brcm.c */ |
193 | extern const struct dsa_device_ops brcm_netdev_ops; | 193 | extern const struct dsa_device_ops brcm_netdev_ops; |
194 | extern const struct dsa_device_ops brcm_prepend_netdev_ops; | ||
194 | 195 | ||
195 | /* tag_dsa.c */ | 196 | /* tag_dsa.c */ |
196 | extern const struct dsa_device_ops dsa_netdev_ops; | 197 | extern const struct dsa_device_ops dsa_netdev_ops; |
diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c index 771409a1e65c..e6e0b7b6025c 100644 --- a/net/dsa/tag_brcm.c +++ b/net/dsa/tag_brcm.c | |||
@@ -96,13 +96,6 @@ static struct sk_buff *brcm_tag_xmit_ll(struct sk_buff *skb, | |||
96 | return skb; | 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 | static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb, | 99 | static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb, |
107 | struct net_device *dev, | 100 | struct net_device *dev, |
108 | struct packet_type *pt, | 101 | struct packet_type *pt, |
@@ -139,6 +132,15 @@ static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb, | |||
139 | return skb; | 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 | static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev, | 144 | static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev, |
143 | struct packet_type *pt) | 145 | struct packet_type *pt) |
144 | { | 146 | { |
@@ -161,3 +163,26 @@ const struct dsa_device_ops brcm_netdev_ops = { | |||
161 | .xmit = brcm_tag_xmit, | 163 | .xmit = brcm_tag_xmit, |
162 | .rcv = brcm_tag_rcv, | 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 | ||