aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa/dsa.c
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2014-09-15 13:00:19 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-15 17:24:20 -0400
commit5075314e4e4b559cc37675ad8a721a89bccd6284 (patch)
tree37d72bc57dd16717b15acbb14e5c98e7d36ced19 /net/dsa/dsa.c
parent6cca9adb786184be21f30be0982e3ea0281f75cb (diff)
dsa: Split ops up, and avoid assigning tag_protocol and receive separately
This change addresses several issues. First, it was possible to set tag_protocol without setting the ops pointer. To correct that I have reordered things so that rcv is now populated before we set tag_protocol. Second, it didn't make much sense to keep setting the device ops each time a new slave was registered. So by moving the receive portion out into root switch initialization that issue should be addressed. Third, I wanted to avoid sending tags if the rcv pointer was not registered so I changed the tag check to verify if the rcv function pointer is set on the root tree. If it is then we start sending DSA tagged frames. Finally I split the device ops pointer in the structures into two spots. I placed the rcv function pointer in the root switch since this makes it easiest to access from there, and I placed the xmit function pointer in the slave for the same reason. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/dsa.c')
-rw-r--r--net/dsa/dsa.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 61f145c44555..1df0a7cf1e9e 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -10,7 +10,6 @@
10 */ 10 */
11 11
12#include <linux/list.h> 12#include <linux/list.h>
13#include <linux/netdevice.h>
14#include <linux/platform_device.h> 13#include <linux/platform_device.h>
15#include <linux/slab.h> 14#include <linux/slab.h>
16#include <linux/module.h> 15#include <linux/module.h>
@@ -154,9 +153,34 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
154 * tagging protocol to the preferred tagging format of this 153 * tagging protocol to the preferred tagging format of this
155 * switch. 154 * switch.
156 */ 155 */
157 if (ds->dst->cpu_switch == index) 156 if (dst->cpu_switch == index) {
158 ds->dst->tag_protocol = drv->tag_protocol; 157 switch (drv->tag_protocol) {
158#ifdef CONFIG_NET_DSA_TAG_DSA
159 case DSA_TAG_PROTO_DSA:
160 dst->rcv = dsa_netdev_ops.rcv;
161 break;
162#endif
163#ifdef CONFIG_NET_DSA_TAG_EDSA
164 case DSA_TAG_PROTO_EDSA:
165 dst->rcv = edsa_netdev_ops.rcv;
166 break;
167#endif
168#ifdef CONFIG_NET_DSA_TAG_TRAILER
169 case DSA_TAG_PROTO_TRAILER:
170 dst->rcv = trailer_netdev_ops.rcv;
171 break;
172#endif
173#ifdef CONFIG_NET_DSA_TAG_BRCM
174 case DSA_TAG_PROTO_BRCM:
175 dst->rcv = brcm_netdev_ops.rcv;
176 break;
177#endif
178 default:
179 break;
180 }
159 181
182 dst->tag_protocol = drv->tag_protocol;
183 }
160 184
161 /* 185 /*
162 * Do basic register setup. 186 * Do basic register setup.
@@ -626,7 +650,7 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
626 return 0; 650 return 0;
627 } 651 }
628 652
629 return dst->ops->rcv(skb, dev, pt, orig_dev); 653 return dst->rcv(skb, dev, pt, orig_dev);
630} 654}
631 655
632static struct packet_type dsa_pack_type __read_mostly = { 656static struct packet_type dsa_pack_type __read_mostly = {