summaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/dsa.c9
-rw-r--r--net/dsa/dsa2.c18
-rw-r--r--net/dsa/dsa_priv.h5
-rw-r--r--net/dsa/legacy.c22
-rw-r--r--net/dsa/slave.c21
5 files changed, 36 insertions, 39 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 517215391514..6aacc2314a8f 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -118,10 +118,7 @@ int dsa_cpu_port_ethtool_setup(struct dsa_port *cpu_dp)
118 struct net_device *master; 118 struct net_device *master;
119 struct ethtool_ops *cpu_ops; 119 struct ethtool_ops *cpu_ops;
120 120
121 master = ds->dst->master_netdev; 121 master = ds->dst->cpu_dp->netdev;
122 if (ds->master_netdev)
123 master = ds->master_netdev;
124
125 cpu_ops = devm_kzalloc(ds->dev, sizeof(*cpu_ops), GFP_KERNEL); 122 cpu_ops = devm_kzalloc(ds->dev, sizeof(*cpu_ops), GFP_KERNEL);
126 if (!cpu_ops) 123 if (!cpu_ops)
127 return -ENOMEM; 124 return -ENOMEM;
@@ -142,9 +139,7 @@ void dsa_cpu_port_ethtool_restore(struct dsa_port *cpu_dp)
142 struct dsa_switch *ds = cpu_dp->ds; 139 struct dsa_switch *ds = cpu_dp->ds;
143 struct net_device *master; 140 struct net_device *master;
144 141
145 master = ds->dst->master_netdev; 142 master = ds->dst->cpu_dp->netdev;
146 if (ds->master_netdev)
147 master = ds->master_netdev;
148 143
149 master->ethtool_ops = ds->dst->master_orig_ethtool_ops; 144 master->ethtool_ops = ds->dst->master_orig_ethtool_ops;
150} 145}
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index f88e1dddb74a..ab48c4f989da 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -337,7 +337,7 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
337 return err; 337 return err;
338 338
339 if (ds->ops->set_addr) { 339 if (ds->ops->set_addr) {
340 err = ds->ops->set_addr(ds, dst->master_netdev->dev_addr); 340 err = ds->ops->set_addr(ds, dst->cpu_dp->netdev->dev_addr);
341 if (err < 0) 341 if (err < 0)
342 return err; 342 return err;
343 } 343 }
@@ -444,7 +444,7 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)
444 * sent to the tag format's receive function. 444 * sent to the tag format's receive function.
445 */ 445 */
446 wmb(); 446 wmb();
447 dst->master_netdev->dsa_ptr = dst; 447 dst->cpu_dp->netdev->dsa_ptr = dst;
448 dst->applied = true; 448 dst->applied = true;
449 449
450 return 0; 450 return 0;
@@ -458,7 +458,7 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
458 if (!dst->applied) 458 if (!dst->applied)
459 return; 459 return;
460 460
461 dst->master_netdev->dsa_ptr = NULL; 461 dst->cpu_dp->netdev->dsa_ptr = NULL;
462 462
463 /* If we used a tagging format that doesn't have an ethertype 463 /* If we used a tagging format that doesn't have an ethertype
464 * field, make sure that all packets from this point get sent 464 * field, make sure that all packets from this point get sent
@@ -504,14 +504,10 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
504 if (!ethernet_dev) 504 if (!ethernet_dev)
505 return -EPROBE_DEFER; 505 return -EPROBE_DEFER;
506 506
507 if (!ds->master_netdev) 507 if (!dst->cpu_dp) {
508 ds->master_netdev = ethernet_dev;
509
510 if (!dst->master_netdev)
511 dst->master_netdev = ethernet_dev;
512
513 if (!dst->cpu_dp)
514 dst->cpu_dp = port; 508 dst->cpu_dp = port;
509 dst->cpu_dp->netdev = ethernet_dev;
510 }
515 511
516 tag_protocol = ds->ops->get_tag_protocol(ds); 512 tag_protocol = ds->ops->get_tag_protocol(ds);
517 dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol); 513 dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol);
@@ -578,7 +574,7 @@ static int dsa_dst_parse(struct dsa_switch_tree *dst)
578 return err; 574 return err;
579 } 575 }
580 576
581 if (!dst->master_netdev) { 577 if (!dst->cpu_dp->netdev) {
582 pr_warn("Tree has no master device\n"); 578 pr_warn("Tree has no master device\n");
583 return -EINVAL; 579 return -EINVAL;
584 } 580 }
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 66ee248796c8..5c510f4ba0ce 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -183,4 +183,9 @@ extern const struct dsa_device_ops qca_netdev_ops;
183/* tag_trailer.c */ 183/* tag_trailer.c */
184extern const struct dsa_device_ops trailer_netdev_ops; 184extern const struct dsa_device_ops trailer_netdev_ops;
185 185
186static inline struct net_device *dsa_master_netdev(struct dsa_slave_priv *p)
187{
188 return p->dp->ds->dst->cpu_dp->netdev;
189}
190
186#endif 191#endif
diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c
index 3a56de8f51a8..5d4f6ffa3424 100644
--- a/net/dsa/legacy.c
+++ b/net/dsa/legacy.c
@@ -101,9 +101,12 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
101 struct dsa_switch_tree *dst = ds->dst; 101 struct dsa_switch_tree *dst = ds->dst;
102 struct dsa_chip_data *cd = ds->cd; 102 struct dsa_chip_data *cd = ds->cd;
103 bool valid_name_found = false; 103 bool valid_name_found = false;
104 struct net_device *master;
104 int index = ds->index; 105 int index = ds->index;
105 int i, ret; 106 int i, ret;
106 107
108 master = dst->cpu_dp->netdev;
109
107 /* 110 /*
108 * Validate supplied switch configuration. 111 * Validate supplied switch configuration.
109 */ 112 */
@@ -116,7 +119,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
116 119
117 if (!strcmp(name, "cpu")) { 120 if (!strcmp(name, "cpu")) {
118 if (dst->cpu_dp) { 121 if (dst->cpu_dp) {
119 netdev_err(dst->master_netdev, 122 netdev_err(master,
120 "multiple cpu ports?!\n"); 123 "multiple cpu ports?!\n");
121 return -EINVAL; 124 return -EINVAL;
122 } 125 }
@@ -168,7 +171,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
168 return ret; 171 return ret;
169 172
170 if (ops->set_addr) { 173 if (ops->set_addr) {
171 ret = ops->set_addr(ds, dst->master_netdev->dev_addr); 174 ret = ops->set_addr(ds, master->dev_addr);
172 if (ret < 0) 175 if (ret < 0)
173 return ret; 176 return ret;
174 } 177 }
@@ -195,14 +198,14 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
195 198
196 ret = dsa_slave_create(ds, parent, i, cd->port_names[i]); 199 ret = dsa_slave_create(ds, parent, i, cd->port_names[i]);
197 if (ret < 0) 200 if (ret < 0)
198 netdev_err(dst->master_netdev, "[%d]: can't create dsa slave device for port %d(%s): %d\n", 201 netdev_err(master, "[%d]: can't create dsa slave device for port %d(%s): %d\n",
199 index, i, cd->port_names[i], ret); 202 index, i, cd->port_names[i], ret);
200 } 203 }
201 204
202 /* Perform configuration of the CPU and DSA ports */ 205 /* Perform configuration of the CPU and DSA ports */
203 ret = dsa_cpu_dsa_setups(ds, parent); 206 ret = dsa_cpu_dsa_setups(ds, parent);
204 if (ret < 0) 207 if (ret < 0)
205 netdev_err(dst->master_netdev, "[%d] : can't configure CPU and DSA ports\n", 208 netdev_err(master, "[%d] : can't configure CPU and DSA ports\n",
206 index); 209 index);
207 210
208 ret = dsa_cpu_port_ethtool_setup(ds->dst->cpu_dp); 211 ret = dsa_cpu_port_ethtool_setup(ds->dst->cpu_dp);
@@ -217,6 +220,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
217 struct device *parent, struct device *host_dev) 220 struct device *parent, struct device *host_dev)
218{ 221{
219 struct dsa_chip_data *cd = dst->pd->chip + index; 222 struct dsa_chip_data *cd = dst->pd->chip + index;
223 struct net_device *master = dst->cpu_dp->netdev;
220 const struct dsa_switch_ops *ops; 224 const struct dsa_switch_ops *ops;
221 struct dsa_switch *ds; 225 struct dsa_switch *ds;
222 int ret; 226 int ret;
@@ -228,11 +232,11 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
228 */ 232 */
229 ops = dsa_switch_probe(parent, host_dev, cd->sw_addr, &name, &priv); 233 ops = dsa_switch_probe(parent, host_dev, cd->sw_addr, &name, &priv);
230 if (!ops) { 234 if (!ops) {
231 netdev_err(dst->master_netdev, "[%d]: could not detect attached switch\n", 235 netdev_err(master, "[%d]: could not detect attached switch\n",
232 index); 236 index);
233 return ERR_PTR(-EINVAL); 237 return ERR_PTR(-EINVAL);
234 } 238 }
235 netdev_info(dst->master_netdev, "[%d]: detected a %s switch\n", 239 netdev_info(master, "[%d]: detected a %s switch\n",
236 index, name); 240 index, name);
237 241
238 242
@@ -575,7 +579,7 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
575 unsigned configured = 0; 579 unsigned configured = 0;
576 580
577 dst->pd = pd; 581 dst->pd = pd;
578 dst->master_netdev = dev; 582 dst->cpu_dp->netdev = dev;
579 583
580 for (i = 0; i < pd->nr_chips; i++) { 584 for (i = 0; i < pd->nr_chips; i++) {
581 struct dsa_switch *ds; 585 struct dsa_switch *ds;
@@ -671,7 +675,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
671{ 675{
672 int i; 676 int i;
673 677
674 dst->master_netdev->dsa_ptr = NULL; 678 dst->cpu_dp->netdev->dsa_ptr = NULL;
675 679
676 /* If we used a tagging format that doesn't have an ethertype 680 /* If we used a tagging format that doesn't have an ethertype
677 * field, make sure that all packets from this point get sent 681 * field, make sure that all packets from this point get sent
@@ -688,7 +692,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
688 692
689 dsa_cpu_port_ethtool_restore(dst->cpu_dp); 693 dsa_cpu_port_ethtool_restore(dst->cpu_dp);
690 694
691 dev_put(dst->master_netdev); 695 dev_put(dst->cpu_dp->netdev);
692} 696}
693 697
694static int dsa_remove(struct platform_device *pdev) 698static int dsa_remove(struct platform_device *pdev)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 5e45ae5c3f71..658bc67c5320 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -66,7 +66,7 @@ static int dsa_slave_get_iflink(const struct net_device *dev)
66{ 66{
67 struct dsa_slave_priv *p = netdev_priv(dev); 67 struct dsa_slave_priv *p = netdev_priv(dev);
68 68
69 return p->dp->ds->dst->master_netdev->ifindex; 69 return dsa_master_netdev(p)->ifindex;
70} 70}
71 71
72static int dsa_slave_open(struct net_device *dev) 72static int dsa_slave_open(struct net_device *dev)
@@ -74,7 +74,7 @@ static int dsa_slave_open(struct net_device *dev)
74 struct dsa_slave_priv *p = netdev_priv(dev); 74 struct dsa_slave_priv *p = netdev_priv(dev);
75 struct dsa_port *dp = p->dp; 75 struct dsa_port *dp = p->dp;
76 struct dsa_switch *ds = dp->ds; 76 struct dsa_switch *ds = dp->ds;
77 struct net_device *master = ds->dst->master_netdev; 77 struct net_device *master = dsa_master_netdev(p);
78 u8 stp_state = dp->bridge_dev ? BR_STATE_BLOCKING : BR_STATE_FORWARDING; 78 u8 stp_state = dp->bridge_dev ? BR_STATE_BLOCKING : BR_STATE_FORWARDING;
79 int err; 79 int err;
80 80
@@ -127,7 +127,7 @@ out:
127static int dsa_slave_close(struct net_device *dev) 127static int dsa_slave_close(struct net_device *dev)
128{ 128{
129 struct dsa_slave_priv *p = netdev_priv(dev); 129 struct dsa_slave_priv *p = netdev_priv(dev);
130 struct net_device *master = p->dp->ds->dst->master_netdev; 130 struct net_device *master = dsa_master_netdev(p);
131 struct dsa_switch *ds = p->dp->ds; 131 struct dsa_switch *ds = p->dp->ds;
132 132
133 if (p->phy) 133 if (p->phy)
@@ -154,7 +154,7 @@ static int dsa_slave_close(struct net_device *dev)
154static void dsa_slave_change_rx_flags(struct net_device *dev, int change) 154static void dsa_slave_change_rx_flags(struct net_device *dev, int change)
155{ 155{
156 struct dsa_slave_priv *p = netdev_priv(dev); 156 struct dsa_slave_priv *p = netdev_priv(dev);
157 struct net_device *master = p->dp->ds->dst->master_netdev; 157 struct net_device *master = dsa_master_netdev(p);
158 158
159 if (change & IFF_ALLMULTI) 159 if (change & IFF_ALLMULTI)
160 dev_set_allmulti(master, dev->flags & IFF_ALLMULTI ? 1 : -1); 160 dev_set_allmulti(master, dev->flags & IFF_ALLMULTI ? 1 : -1);
@@ -165,7 +165,7 @@ static void dsa_slave_change_rx_flags(struct net_device *dev, int change)
165static void dsa_slave_set_rx_mode(struct net_device *dev) 165static void dsa_slave_set_rx_mode(struct net_device *dev)
166{ 166{
167 struct dsa_slave_priv *p = netdev_priv(dev); 167 struct dsa_slave_priv *p = netdev_priv(dev);
168 struct net_device *master = p->dp->ds->dst->master_netdev; 168 struct net_device *master = dsa_master_netdev(p);
169 169
170 dev_mc_sync(master, dev); 170 dev_mc_sync(master, dev);
171 dev_uc_sync(master, dev); 171 dev_uc_sync(master, dev);
@@ -174,7 +174,7 @@ static void dsa_slave_set_rx_mode(struct net_device *dev)
174static int dsa_slave_set_mac_address(struct net_device *dev, void *a) 174static int dsa_slave_set_mac_address(struct net_device *dev, void *a)
175{ 175{
176 struct dsa_slave_priv *p = netdev_priv(dev); 176 struct dsa_slave_priv *p = netdev_priv(dev);
177 struct net_device *master = p->dp->ds->dst->master_netdev; 177 struct net_device *master = dsa_master_netdev(p);
178 struct sockaddr *addr = a; 178 struct sockaddr *addr = a;
179 int err; 179 int err;
180 180
@@ -375,7 +375,7 @@ static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
375 /* Queue the SKB for transmission on the parent interface, but 375 /* Queue the SKB for transmission on the parent interface, but
376 * do not modify its EtherType 376 * do not modify its EtherType
377 */ 377 */
378 nskb->dev = p->dp->ds->dst->master_netdev; 378 nskb->dev = dsa_master_netdev(p);
379 dev_queue_xmit(nskb); 379 dev_queue_xmit(nskb);
380 380
381 return NETDEV_TX_OK; 381 return NETDEV_TX_OK;
@@ -684,8 +684,7 @@ static int dsa_slave_netpoll_setup(struct net_device *dev,
684 struct netpoll_info *ni) 684 struct netpoll_info *ni)
685{ 685{
686 struct dsa_slave_priv *p = netdev_priv(dev); 686 struct dsa_slave_priv *p = netdev_priv(dev);
687 struct dsa_switch *ds = p->dp->ds; 687 struct net_device *master = dsa_master_netdev(p);
688 struct net_device *master = ds->dst->master_netdev;
689 struct netpoll *netpoll; 688 struct netpoll *netpoll;
690 int err = 0; 689 int err = 0;
691 690
@@ -1143,9 +1142,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
1143 struct dsa_slave_priv *p; 1142 struct dsa_slave_priv *p;
1144 int ret; 1143 int ret;
1145 1144
1146 master = ds->dst->master_netdev; 1145 master = ds->dst->cpu_dp->netdev;
1147 if (ds->master_netdev)
1148 master = ds->master_netdev;
1149 1146
1150 slave_dev = alloc_netdev(sizeof(struct dsa_slave_priv), name, 1147 slave_dev = alloc_netdev(sizeof(struct dsa_slave_priv), name,
1151 NET_NAME_UNKNOWN, ether_setup); 1148 NET_NAME_UNKNOWN, ether_setup);