aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/netdevice.h7
-rw-r--r--include/net/dsa.h10
-rw-r--r--net/dsa/dsa.c32
-rw-r--r--net/dsa/dsa_priv.h11
-rw-r--r--net/dsa/slave.c37
-rw-r--r--net/dsa/tag_brcm.c1
-rw-r--r--net/dsa/tag_dsa.c1
-rw-r--r--net/dsa/tag_edsa.c1
-rw-r--r--net/dsa/tag_trailer.c1
9 files changed, 59 insertions, 42 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f9e81d10a3b9..28d4378615e5 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1928,13 +1928,6 @@ struct udp_offload {
1928 struct offload_callbacks callbacks; 1928 struct offload_callbacks callbacks;
1929}; 1929};
1930 1930
1931struct dsa_device_ops {
1932 netdev_tx_t (*xmit)(struct sk_buff *skb, struct net_device *dev);
1933 int (*rcv)(struct sk_buff *skb, struct net_device *dev,
1934 struct packet_type *pt, struct net_device *orig_dev);
1935};
1936
1937
1938/* often modified stats are per cpu, other are shared (netdev->stats) */ 1931/* often modified stats are per cpu, other are shared (netdev->stats) */
1939struct pcpu_sw_netstats { 1932struct pcpu_sw_netstats {
1940 u64 rx_packets; 1933 u64 rx_packets;
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 8a8a5d976f97..a55c4e6a4f0f 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -77,7 +77,7 @@ struct dsa_platform_data {
77 struct dsa_chip_data *chip; 77 struct dsa_chip_data *chip;
78}; 78};
79 79
80struct dsa_device_ops; 80struct packet_type;
81 81
82struct dsa_switch_tree { 82struct dsa_switch_tree {
83 /* 83 /*
@@ -91,7 +91,10 @@ struct dsa_switch_tree {
91 * protocol to use. 91 * protocol to use.
92 */ 92 */
93 struct net_device *master_netdev; 93 struct net_device *master_netdev;
94 const struct dsa_device_ops *ops; 94 int (*rcv)(struct sk_buff *skb,
95 struct net_device *dev,
96 struct packet_type *pt,
97 struct net_device *orig_dev);
95 enum dsa_tag_protocol tag_protocol; 98 enum dsa_tag_protocol tag_protocol;
96 99
97 /* 100 /*
@@ -218,7 +221,6 @@ static inline void *ds_to_priv(struct dsa_switch *ds)
218 221
219static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst) 222static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst)
220{ 223{
221 return dst->tag_protocol != DSA_TAG_PROTO_NONE; 224 return dst->rcv != NULL;
222} 225}
223
224#endif 226#endif
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 = {
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 98afed4d92ba..f90899e8ab5a 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -12,7 +12,13 @@
12#define __DSA_PRIV_H 12#define __DSA_PRIV_H
13 13
14#include <linux/phy.h> 14#include <linux/phy.h>
15#include <net/dsa.h> 15#include <linux/netdevice.h>
16
17struct dsa_device_ops {
18 netdev_tx_t (*xmit)(struct sk_buff *skb, struct net_device *dev);
19 int (*rcv)(struct sk_buff *skb, struct net_device *dev,
20 struct packet_type *pt, struct net_device *orig_dev);
21};
16 22
17struct dsa_slave_priv { 23struct dsa_slave_priv {
18 /* 24 /*
@@ -20,6 +26,8 @@ struct dsa_slave_priv {
20 * switch port. 26 * switch port.
21 */ 27 */
22 struct net_device *dev; 28 struct net_device *dev;
29 netdev_tx_t (*xmit)(struct sk_buff *skb,
30 struct net_device *dev);
23 31
24 /* 32 /*
25 * Which switch this port is a part of, and the port index 33 * Which switch this port is a part of, and the port index
@@ -43,6 +51,7 @@ struct dsa_slave_priv {
43extern char dsa_driver_version[]; 51extern char dsa_driver_version[];
44 52
45/* slave.c */ 53/* slave.c */
54extern const struct dsa_device_ops notag_netdev_ops;
46void dsa_slave_mii_bus_init(struct dsa_switch *ds); 55void dsa_slave_mii_bus_init(struct dsa_switch *ds);
47struct net_device *dsa_slave_create(struct dsa_switch *ds, 56struct net_device *dsa_slave_create(struct dsa_switch *ds,
48 struct device *parent, 57 struct device *parent,
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 809eeb13eb12..e38a331111c0 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -9,7 +9,6 @@
9 */ 9 */
10 10
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/netdevice.h>
13#include <linux/etherdevice.h> 12#include <linux/etherdevice.h>
14#include <linux/phy.h> 13#include <linux/phy.h>
15#include <linux/of_net.h> 14#include <linux/of_net.h>
@@ -176,9 +175,8 @@ static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
176static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev) 175static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
177{ 176{
178 struct dsa_slave_priv *p = netdev_priv(dev); 177 struct dsa_slave_priv *p = netdev_priv(dev);
179 struct dsa_switch_tree *dst = p->parent->dst;
180 178
181 return dst->ops->xmit(skb, dev); 179 return p->xmit(skb, dev);
182} 180}
183 181
184static netdev_tx_t dsa_slave_notag_xmit(struct sk_buff *skb, 182static netdev_tx_t dsa_slave_notag_xmit(struct sk_buff *skb,
@@ -325,11 +323,6 @@ static const struct net_device_ops dsa_slave_netdev_ops = {
325 .ndo_do_ioctl = dsa_slave_ioctl, 323 .ndo_do_ioctl = dsa_slave_ioctl,
326}; 324};
327 325
328static const struct dsa_device_ops notag_netdev_ops = {
329 .xmit = dsa_slave_notag_xmit,
330 .rcv = NULL,
331};
332
333static void dsa_slave_adjust_link(struct net_device *dev) 326static void dsa_slave_adjust_link(struct net_device *dev)
334{ 327{
335 struct dsa_slave_priv *p = netdev_priv(dev); 328 struct dsa_slave_priv *p = netdev_priv(dev);
@@ -435,41 +428,41 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
435 slave_dev->tx_queue_len = 0; 428 slave_dev->tx_queue_len = 0;
436 slave_dev->netdev_ops = &dsa_slave_netdev_ops; 429 slave_dev->netdev_ops = &dsa_slave_netdev_ops;
437 430
431 SET_NETDEV_DEV(slave_dev, parent);
432 slave_dev->dev.of_node = ds->pd->port_dn[port];
433 slave_dev->vlan_features = master->vlan_features;
434
435 p = netdev_priv(slave_dev);
436 p->dev = slave_dev;
437 p->parent = ds;
438 p->port = port;
439
438 switch (ds->dst->tag_protocol) { 440 switch (ds->dst->tag_protocol) {
439#ifdef CONFIG_NET_DSA_TAG_DSA 441#ifdef CONFIG_NET_DSA_TAG_DSA
440 case DSA_TAG_PROTO_DSA: 442 case DSA_TAG_PROTO_DSA:
441 ds->dst->ops = &dsa_netdev_ops; 443 p->xmit = dsa_netdev_ops.xmit;
442 break; 444 break;
443#endif 445#endif
444#ifdef CONFIG_NET_DSA_TAG_EDSA 446#ifdef CONFIG_NET_DSA_TAG_EDSA
445 case DSA_TAG_PROTO_EDSA: 447 case DSA_TAG_PROTO_EDSA:
446 ds->dst->ops = &edsa_netdev_ops; 448 p->xmit = edsa_netdev_ops.xmit;
447 break; 449 break;
448#endif 450#endif
449#ifdef CONFIG_NET_DSA_TAG_TRAILER 451#ifdef CONFIG_NET_DSA_TAG_TRAILER
450 case DSA_TAG_PROTO_TRAILER: 452 case DSA_TAG_PROTO_TRAILER:
451 ds->dst->ops = &trailer_netdev_ops; 453 p->xmit = trailer_netdev_ops.xmit;
452 break; 454 break;
453#endif 455#endif
454#ifdef CONFIG_NET_DSA_TAG_BRCM 456#ifdef CONFIG_NET_DSA_TAG_BRCM
455 case DSA_TAG_PROTO_BRCM: 457 case DSA_TAG_PROTO_BRCM:
456 ds->dst->ops = &brcm_netdev_ops; 458 p->xmit = brcm_netdev_ops.xmit;
457 break; 459 break;
458#endif 460#endif
459 default: 461 default:
460 ds->dst->ops = &notag_netdev_ops; 462 p->xmit = dsa_slave_notag_xmit;
461 break; 463 break;
462 } 464 }
463 465
464 SET_NETDEV_DEV(slave_dev, parent);
465 slave_dev->dev.of_node = ds->pd->port_dn[port];
466 slave_dev->vlan_features = master->vlan_features;
467
468 p = netdev_priv(slave_dev);
469 p->dev = slave_dev;
470 p->parent = ds;
471 p->port = port;
472
473 p->old_pause = -1; 466 p->old_pause = -1;
474 p->old_link = -1; 467 p->old_link = -1;
475 p->old_duplex = -1; 468 p->old_duplex = -1;
diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c
index 8fbc21c0de78..83d3572cdb20 100644
--- a/net/dsa/tag_brcm.c
+++ b/net/dsa/tag_brcm.c
@@ -11,7 +11,6 @@
11 11
12#include <linux/etherdevice.h> 12#include <linux/etherdevice.h>
13#include <linux/list.h> 13#include <linux/list.h>
14#include <linux/netdevice.h>
15#include <linux/slab.h> 14#include <linux/slab.h>
16#include "dsa_priv.h" 15#include "dsa_priv.h"
17 16
diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c
index d7dbc5bda5c0..ce90c8bdc658 100644
--- a/net/dsa/tag_dsa.c
+++ b/net/dsa/tag_dsa.c
@@ -10,7 +10,6 @@
10 10
11#include <linux/etherdevice.h> 11#include <linux/etherdevice.h>
12#include <linux/list.h> 12#include <linux/list.h>
13#include <linux/netdevice.h>
14#include <linux/slab.h> 13#include <linux/slab.h>
15#include "dsa_priv.h" 14#include "dsa_priv.h"
16 15
diff --git a/net/dsa/tag_edsa.c b/net/dsa/tag_edsa.c
index 6b30abe89183..94fcce778679 100644
--- a/net/dsa/tag_edsa.c
+++ b/net/dsa/tag_edsa.c
@@ -10,7 +10,6 @@
10 10
11#include <linux/etherdevice.h> 11#include <linux/etherdevice.h>
12#include <linux/list.h> 12#include <linux/list.h>
13#include <linux/netdevice.h>
14#include <linux/slab.h> 13#include <linux/slab.h>
15#include "dsa_priv.h" 14#include "dsa_priv.h"
16 15
diff --git a/net/dsa/tag_trailer.c b/net/dsa/tag_trailer.c
index 5fe9444842c5..115fdca34077 100644
--- a/net/dsa/tag_trailer.c
+++ b/net/dsa/tag_trailer.c
@@ -10,7 +10,6 @@
10 10
11#include <linux/etherdevice.h> 11#include <linux/etherdevice.h>
12#include <linux/list.h> 12#include <linux/list.h>
13#include <linux/netdevice.h>
14#include <linux/slab.h> 13#include <linux/slab.h>
15#include "dsa_priv.h" 14#include "dsa_priv.h"
16 15