Skip to content

Commit 9520ed8

Browse files
viviendavem330
authored andcommitted
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 <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b22de49 commit 9520ed8

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

net/dsa/dsa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
868868
dsa_switch_destroy(ds);
869869
}
870870

871-
dsa_cpu_port_ethtool_restore(dst->ds[0]);
871+
dsa_cpu_port_ethtool_restore(dst->cpu_switch);
872872

873873
dev_put(dst->master_netdev);
874874
}

net/dsa/dsa2.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)
377377
return err;
378378
}
379379

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);
382382
if (err)
383383
return err;
384384
}
@@ -418,8 +418,8 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
418418
dsa_ds_unapply(dst, ds);
419419
}
420420

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);
423423

424424
pr_info("DSA: tree %d unapplied\n", dst->tree);
425425
dst->applied = false;

net/dsa/slave.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev,
781781
uint64_t *data)
782782
{
783783
struct dsa_switch_tree *dst = dev->dsa_ptr;
784-
struct dsa_switch *ds = dst->ds[0];
784+
struct dsa_switch *ds = dst->cpu_switch;
785785
s8 cpu_port = dst->cpu_port;
786786
int count = 0;
787787

@@ -798,7 +798,7 @@ static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev,
798798
static int dsa_cpu_port_get_sset_count(struct net_device *dev, int sset)
799799
{
800800
struct dsa_switch_tree *dst = dev->dsa_ptr;
801-
struct dsa_switch *ds = dst->ds[0];
801+
struct dsa_switch *ds = dst->cpu_switch;
802802
int count = 0;
803803

804804
if (dst->master_ethtool_ops.get_sset_count)
@@ -814,7 +814,7 @@ static void dsa_cpu_port_get_strings(struct net_device *dev,
814814
uint32_t stringset, uint8_t *data)
815815
{
816816
struct dsa_switch_tree *dst = dev->dsa_ptr;
817-
struct dsa_switch *ds = dst->ds[0];
817+
struct dsa_switch *ds = dst->cpu_switch;
818818
s8 cpu_port = dst->cpu_port;
819819
int len = ETH_GSTRING_LEN;
820820
int mcount = 0, count;

net/dsa/tag_brcm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
102102
if (unlikely(dst == NULL))
103103
goto out_drop;
104104

105-
ds = dst->ds[0];
105+
ds = dst->cpu_switch;
106106

107107
skb = skb_unshare(skb, GFP_ATOMIC);
108108
if (skb == NULL)

net/dsa/tag_qca.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static int qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,
104104
/* This protocol doesn't support cascading multiple switches so it's
105105
* safe to assume the switch is first in the tree
106106
*/
107-
ds = dst->ds[0];
107+
ds = dst->cpu_switch;
108108
if (!ds)
109109
goto out_drop;
110110

net/dsa/tag_trailer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static int trailer_rcv(struct sk_buff *skb, struct net_device *dev,
6767

6868
if (unlikely(dst == NULL))
6969
goto out_drop;
70-
ds = dst->ds[0];
70+
ds = dst->cpu_switch;
7171

7272
skb = skb_unshare(skb, GFP_ATOMIC);
7373
if (skb == NULL)

0 commit comments

Comments
 (0)