aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2014-09-12 00:18:09 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-13 17:04:35 -0400
commitac7a04c33dd7f8e429df4b929ba3a3e8e729cc89 (patch)
tree5b1e76c258c08ef39fdcf5e469a05e0322ffb228
parentc55542983e572bcac813fd9a393e725e158074be (diff)
net: dsa: change tag_protocol to an enum
Now that we introduced an additional multiplexing/demultiplexing layer with commit 3e8a72d1dae37 ("net: dsa: reduce number of protocol hooks") that lives within the DSA code, we no longer need to have a given switch driver tag_protocol be an actual ethertype value, instead, we can replace it with an enum: dsa_tag_protocol. Do this replacement in the drivers, which allows us to get rid of the cpu_to_be16()/htons() dance, and remove ETH_P_BRCMTAG since we do not need it anymore. Suggested-by: Alexander Duyck <alexander.duyck@gmail.com> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/dsa/bcm_sf2.c2
-rw-r--r--drivers/net/dsa/mv88e6060.c2
-rw-r--r--drivers/net/dsa/mv88e6123_61_65.c4
-rw-r--r--drivers/net/dsa/mv88e6131.c2
-rw-r--r--include/net/dsa.h17
-rw-r--r--net/dsa/slave.c8
-rw-r--r--net/dsa/tag_brcm.c1
7 files changed, 19 insertions, 17 deletions
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index bb7cb8e283b1..e9918c7f1792 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -592,7 +592,7 @@ static void bcm_sf2_sw_fixed_link_update(struct dsa_switch *ds, int port,
592} 592}
593 593
594static struct dsa_switch_driver bcm_sf2_switch_driver = { 594static struct dsa_switch_driver bcm_sf2_switch_driver = {
595 .tag_protocol = htons(ETH_P_BRCMTAG), 595 .tag_protocol = DSA_TAG_PROTO_BRCM,
596 .priv_size = sizeof(struct bcm_sf2_priv), 596 .priv_size = sizeof(struct bcm_sf2_priv),
597 .probe = bcm_sf2_sw_probe, 597 .probe = bcm_sf2_sw_probe,
598 .setup = bcm_sf2_sw_setup, 598 .setup = bcm_sf2_sw_setup,
diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index 7a54ec04b418..d8037c1055ac 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -258,7 +258,7 @@ static void mv88e6060_poll_link(struct dsa_switch *ds)
258} 258}
259 259
260static struct dsa_switch_driver mv88e6060_switch_driver = { 260static struct dsa_switch_driver mv88e6060_switch_driver = {
261 .tag_protocol = htons(ETH_P_TRAILER), 261 .tag_protocol = DSA_TAG_PROTO_TRAILER,
262 .probe = mv88e6060_probe, 262 .probe = mv88e6060_probe,
263 .setup = mv88e6060_setup, 263 .setup = mv88e6060_setup,
264 .set_addr = mv88e6060_set_addr, 264 .set_addr = mv88e6060_set_addr,
diff --git a/drivers/net/dsa/mv88e6123_61_65.c b/drivers/net/dsa/mv88e6123_61_65.c
index 69c42513dd72..975774f338c2 100644
--- a/drivers/net/dsa/mv88e6123_61_65.c
+++ b/drivers/net/dsa/mv88e6123_61_65.c
@@ -207,7 +207,7 @@ static int mv88e6123_61_65_setup_port(struct dsa_switch *ds, int p)
207 */ 207 */
208 val = 0x0433; 208 val = 0x0433;
209 if (dsa_is_cpu_port(ds, p)) { 209 if (dsa_is_cpu_port(ds, p)) {
210 if (ds->dst->tag_protocol == htons(ETH_P_EDSA)) 210 if (ds->dst->tag_protocol == DSA_TAG_PROTO_EDSA)
211 val |= 0x3300; 211 val |= 0x3300;
212 else 212 else
213 val |= 0x0100; 213 val |= 0x0100;
@@ -391,7 +391,7 @@ static int mv88e6123_61_65_get_sset_count(struct dsa_switch *ds)
391} 391}
392 392
393struct dsa_switch_driver mv88e6123_61_65_switch_driver = { 393struct dsa_switch_driver mv88e6123_61_65_switch_driver = {
394 .tag_protocol = cpu_to_be16(ETH_P_EDSA), 394 .tag_protocol = DSA_TAG_PROTO_EDSA,
395 .priv_size = sizeof(struct mv88e6xxx_priv_state), 395 .priv_size = sizeof(struct mv88e6xxx_priv_state),
396 .probe = mv88e6123_61_65_probe, 396 .probe = mv88e6123_61_65_probe,
397 .setup = mv88e6123_61_65_setup, 397 .setup = mv88e6123_61_65_setup,
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index 953bc6a49e59..35541f2ceca3 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -379,7 +379,7 @@ static int mv88e6131_get_sset_count(struct dsa_switch *ds)
379} 379}
380 380
381struct dsa_switch_driver mv88e6131_switch_driver = { 381struct dsa_switch_driver mv88e6131_switch_driver = {
382 .tag_protocol = cpu_to_be16(ETH_P_DSA), 382 .tag_protocol = DSA_TAG_PROTO_DSA,
383 .priv_size = sizeof(struct mv88e6xxx_priv_state), 383 .priv_size = sizeof(struct mv88e6xxx_priv_state),
384 .probe = mv88e6131_probe, 384 .probe = mv88e6131_probe,
385 .setup = mv88e6131_setup, 385 .setup = mv88e6131_setup,
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 97712927a9d2..8a8a5d976f97 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -19,10 +19,13 @@
19#include <linux/phy.h> 19#include <linux/phy.h>
20#include <linux/phy_fixed.h> 20#include <linux/phy_fixed.h>
21 21
22/* Not an official ethertype value, used only internally for DSA 22enum dsa_tag_protocol {
23 * demultiplexing 23 DSA_TAG_PROTO_NONE = 0,
24 */ 24 DSA_TAG_PROTO_DSA,
25#define ETH_P_BRCMTAG (ETH_P_XDSA + 1) 25 DSA_TAG_PROTO_TRAILER,
26 DSA_TAG_PROTO_EDSA,
27 DSA_TAG_PROTO_BRCM,
28};
26 29
27#define DSA_MAX_SWITCHES 4 30#define DSA_MAX_SWITCHES 4
28#define DSA_MAX_PORTS 12 31#define DSA_MAX_PORTS 12
@@ -89,7 +92,7 @@ struct dsa_switch_tree {
89 */ 92 */
90 struct net_device *master_netdev; 93 struct net_device *master_netdev;
91 const struct dsa_device_ops *ops; 94 const struct dsa_device_ops *ops;
92 __be16 tag_protocol; 95 enum dsa_tag_protocol tag_protocol;
93 96
94 /* 97 /*
95 * The switch and port to which the CPU is attached. 98 * The switch and port to which the CPU is attached.
@@ -166,7 +169,7 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
166struct dsa_switch_driver { 169struct dsa_switch_driver {
167 struct list_head list; 170 struct list_head list;
168 171
169 __be16 tag_protocol; 172 enum dsa_tag_protocol tag_protocol;
170 int priv_size; 173 int priv_size;
171 174
172 /* 175 /*
@@ -215,7 +218,7 @@ static inline void *ds_to_priv(struct dsa_switch *ds)
215 218
216static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst) 219static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst)
217{ 220{
218 return dst->tag_protocol != 0; 221 return dst->tag_protocol != DSA_TAG_PROTO_NONE;
219} 222}
220 223
221#endif 224#endif
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 7333a4aebb7d..809eeb13eb12 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -437,22 +437,22 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
437 437
438 switch (ds->dst->tag_protocol) { 438 switch (ds->dst->tag_protocol) {
439#ifdef CONFIG_NET_DSA_TAG_DSA 439#ifdef CONFIG_NET_DSA_TAG_DSA
440 case htons(ETH_P_DSA): 440 case DSA_TAG_PROTO_DSA:
441 ds->dst->ops = &dsa_netdev_ops; 441 ds->dst->ops = &dsa_netdev_ops;
442 break; 442 break;
443#endif 443#endif
444#ifdef CONFIG_NET_DSA_TAG_EDSA 444#ifdef CONFIG_NET_DSA_TAG_EDSA
445 case htons(ETH_P_EDSA): 445 case DSA_TAG_PROTO_EDSA:
446 ds->dst->ops = &edsa_netdev_ops; 446 ds->dst->ops = &edsa_netdev_ops;
447 break; 447 break;
448#endif 448#endif
449#ifdef CONFIG_NET_DSA_TAG_TRAILER 449#ifdef CONFIG_NET_DSA_TAG_TRAILER
450 case htons(ETH_P_TRAILER): 450 case DSA_TAG_PROTO_TRAILER:
451 ds->dst->ops = &trailer_netdev_ops; 451 ds->dst->ops = &trailer_netdev_ops;
452 break; 452 break;
453#endif 453#endif
454#ifdef CONFIG_NET_DSA_TAG_BRCM 454#ifdef CONFIG_NET_DSA_TAG_BRCM
455 case htons(ETH_P_BRCMTAG): 455 case DSA_TAG_PROTO_BRCM:
456 ds->dst->ops = &brcm_netdev_ops; 456 ds->dst->ops = &brcm_netdev_ops;
457 break; 457 break;
458#endif 458#endif
diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c
index e0b759ec209e..8fbc21c0de78 100644
--- a/net/dsa/tag_brcm.c
+++ b/net/dsa/tag_brcm.c
@@ -91,7 +91,6 @@ static netdev_tx_t brcm_tag_xmit(struct sk_buff *skb, struct net_device *dev)
91 /* Queue the SKB for transmission on the parent interface, but 91 /* Queue the SKB for transmission on the parent interface, but
92 * do not modify its EtherType 92 * do not modify its EtherType
93 */ 93 */
94 skb->protocol = htons(ETH_P_BRCMTAG);
95 skb->dev = p->parent->dst->master_netdev; 94 skb->dev = p->parent->dst->master_netdev;
96 dev_queue_xmit(skb); 95 dev_queue_xmit(skb);
97 96