Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: use cpu_switch instead of ds[0]

Now that the DSA Ethernet switches are true Linux devices, the CPU
switch is not necessarily the first one. If its address is higher than
the second switch on the same MDIO bus, its index will be 1, not 0.

Avoid any confusion by using dst->cpu_switch instead of dst->ds[0].

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vivien Didelot and committed by
David S. Miller
9520ed8f b22de490

+11 -11
+1 -1
net/dsa/dsa.c
··· 868 868 dsa_switch_destroy(ds); 869 869 } 870 870 871 - dsa_cpu_port_ethtool_restore(dst->ds[0]); 871 + dsa_cpu_port_ethtool_restore(dst->cpu_switch); 872 872 873 873 dev_put(dst->master_netdev); 874 874 }
+4 -4
net/dsa/dsa2.c
··· 377 377 return err; 378 378 } 379 379 380 - if (dst->ds[0]) { 381 - err = dsa_cpu_port_ethtool_setup(dst->ds[0]); 380 + if (dst->cpu_switch) { 381 + err = dsa_cpu_port_ethtool_setup(dst->cpu_switch); 382 382 if (err) 383 383 return err; 384 384 } ··· 418 418 dsa_ds_unapply(dst, ds); 419 419 } 420 420 421 - if (dst->ds[0]) 422 - dsa_cpu_port_ethtool_restore(dst->ds[0]); 421 + if (dst->cpu_switch) 422 + dsa_cpu_port_ethtool_restore(dst->cpu_switch); 423 423 424 424 pr_info("DSA: tree %d unapplied\n", dst->tree); 425 425 dst->applied = false;
+3 -3
net/dsa/slave.c
··· 781 781 uint64_t *data) 782 782 { 783 783 struct dsa_switch_tree *dst = dev->dsa_ptr; 784 - struct dsa_switch *ds = dst->ds[0]; 784 + struct dsa_switch *ds = dst->cpu_switch; 785 785 s8 cpu_port = dst->cpu_port; 786 786 int count = 0; 787 787 ··· 798 798 static int dsa_cpu_port_get_sset_count(struct net_device *dev, int sset) 799 799 { 800 800 struct dsa_switch_tree *dst = dev->dsa_ptr; 801 - struct dsa_switch *ds = dst->ds[0]; 801 + struct dsa_switch *ds = dst->cpu_switch; 802 802 int count = 0; 803 803 804 804 if (dst->master_ethtool_ops.get_sset_count) ··· 814 814 uint32_t stringset, uint8_t *data) 815 815 { 816 816 struct dsa_switch_tree *dst = dev->dsa_ptr; 817 - struct dsa_switch *ds = dst->ds[0]; 817 + struct dsa_switch *ds = dst->cpu_switch; 818 818 s8 cpu_port = dst->cpu_port; 819 819 int len = ETH_GSTRING_LEN; 820 820 int mcount = 0, count;
+1 -1
net/dsa/tag_brcm.c
··· 102 102 if (unlikely(dst == NULL)) 103 103 goto out_drop; 104 104 105 - ds = dst->ds[0]; 105 + ds = dst->cpu_switch; 106 106 107 107 skb = skb_unshare(skb, GFP_ATOMIC); 108 108 if (skb == NULL)
+1 -1
net/dsa/tag_qca.c
··· 104 104 /* This protocol doesn't support cascading multiple switches so it's 105 105 * safe to assume the switch is first in the tree 106 106 */ 107 - ds = dst->ds[0]; 107 + ds = dst->cpu_switch; 108 108 if (!ds) 109 109 goto out_drop; 110 110
+1 -1
net/dsa/tag_trailer.c
··· 67 67 68 68 if (unlikely(dst == NULL)) 69 69 goto out_drop; 70 - ds = dst->ds[0]; 70 + ds = dst->cpu_switch; 71 71 72 72 skb = skb_unshare(skb, GFP_ATOMIC); 73 73 if (skb == NULL)