Skip to content

Commit 2f657a6

Browse files
viviendavem330
authored andcommitted
net: dsa: change dsa_ptr for a dsa_port
With DSA, a master net device (CPU facing interface) has a dsa_ptr pointer to which hangs a dsa_switch_tree. This is not correct because a master interface is wired to a dedicated switch port, and because we can theoretically have several master interfaces pointing to several CPU ports of the same switch fabric. Change the master interface's dsa_ptr for the CPU dsa_port pointer. This is a step towards supporting multiple CPU ports. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3e41f93 commit 2f657a6

6 files changed

Lines changed: 14 additions & 18 deletions

File tree

‎include/linux/netdevice.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
struct netpoll_info;
5656
struct device;
5757
struct phy_device;
58-
struct dsa_switch_tree;
58+
struct dsa_port;
5959

6060
/* 802.11 specific */
6161
struct wireless_dev;
@@ -1752,7 +1752,7 @@ struct net_device {
17521752
struct vlan_info __rcu *vlan_info;
17531753
#endif
17541754
#if IS_ENABLED(CONFIG_NET_DSA)
1755-
struct dsa_switch_tree *dsa_ptr;
1755+
struct dsa_port *dsa_ptr;
17561756
#endif
17571757
#if IS_ENABLED(CONFIG_TIPC)
17581758
struct tipc_bearer __rcu *tipc_ptr;

‎net/dsa/dsa.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ EXPORT_SYMBOL_GPL(dsa_dev_to_net_device);
160160
static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
161161
struct packet_type *pt, struct net_device *unused)
162162
{
163-
struct dsa_switch_tree *dst = dev->dsa_ptr;
163+
struct dsa_port *cpu_dp = dev->dsa_ptr;
164164
struct sk_buff *nskb = NULL;
165165
struct pcpu_sw_netstats *s;
166166
struct dsa_slave_priv *p;
167167

168-
if (unlikely(dst == NULL)) {
168+
if (unlikely(!cpu_dp)) {
169169
kfree_skb(skb);
170170
return 0;
171171
}
@@ -174,7 +174,7 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
174174
if (!skb)
175175
return 0;
176176

177-
nskb = dst->rcv(skb, dev, pt);
177+
nskb = cpu_dp->rcv(skb, dev, pt);
178178
if (!nskb) {
179179
kfree_skb(skb);
180180
return 0;

‎net/dsa/dsa2.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)
438438
* sent to the tag format's receive function.
439439
*/
440440
wmb();
441-
dst->cpu_dp->netdev->dsa_ptr = dst;
441+
dst->cpu_dp->netdev->dsa_ptr = dst->cpu_dp;
442442

443443
err = dsa_master_ethtool_setup(dst->cpu_dp->netdev);
444444
if (err)

‎net/dsa/dsa_priv.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ void dsa_master_ethtool_restore(struct net_device *dev);
116116
static inline struct net_device *dsa_master_get_slave(struct net_device *dev,
117117
int device, int port)
118118
{
119-
struct dsa_switch_tree *dst = dev->dsa_ptr;
119+
struct dsa_port *cpu_dp = dev->dsa_ptr;
120+
struct dsa_switch_tree *dst = cpu_dp->dst;
120121
struct dsa_switch *ds;
121122

122123
if (device < 0 || device >= DSA_MAX_SWITCHES)

‎net/dsa/legacy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
607607
* sent to the tag format's receive function.
608608
*/
609609
wmb();
610-
dev->dsa_ptr = dst;
610+
dev->dsa_ptr = dst->cpu_dp;
611611

612612
return dsa_master_ethtool_setup(dst->cpu_dp->netdev);
613613
}

‎net/dsa/master.c‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ static void dsa_master_get_ethtool_stats(struct net_device *dev,
1616
struct ethtool_stats *stats,
1717
uint64_t *data)
1818
{
19-
struct dsa_switch_tree *dst = dev->dsa_ptr;
20-
struct dsa_port *cpu_dp = dst->cpu_dp;
19+
struct dsa_port *cpu_dp = dev->dsa_ptr;
2120
const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops;
2221
struct dsa_switch *ds = cpu_dp->ds;
2322
int port = cpu_dp->index;
@@ -34,8 +33,7 @@ static void dsa_master_get_ethtool_stats(struct net_device *dev,
3433

3534
static int dsa_master_get_sset_count(struct net_device *dev, int sset)
3635
{
37-
struct dsa_switch_tree *dst = dev->dsa_ptr;
38-
struct dsa_port *cpu_dp = dst->cpu_dp;
36+
struct dsa_port *cpu_dp = dev->dsa_ptr;
3937
const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops;
4038
struct dsa_switch *ds = cpu_dp->ds;
4139
int count = 0;
@@ -52,8 +50,7 @@ static int dsa_master_get_sset_count(struct net_device *dev, int sset)
5250
static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset,
5351
uint8_t *data)
5452
{
55-
struct dsa_switch_tree *dst = dev->dsa_ptr;
56-
struct dsa_port *cpu_dp = dst->cpu_dp;
53+
struct dsa_port *cpu_dp = dev->dsa_ptr;
5754
const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops;
5855
struct dsa_switch *ds = cpu_dp->ds;
5956
int port = cpu_dp->index;
@@ -90,8 +87,7 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset,
9087

9188
int dsa_master_ethtool_setup(struct net_device *dev)
9289
{
93-
struct dsa_switch_tree *dst = dev->dsa_ptr;
94-
struct dsa_port *cpu_dp = dst->cpu_dp;
90+
struct dsa_port *cpu_dp = dev->dsa_ptr;
9591
struct dsa_switch *ds = cpu_dp->ds;
9692
struct ethtool_ops *ops;
9793

@@ -114,8 +110,7 @@ int dsa_master_ethtool_setup(struct net_device *dev)
114110

115111
void dsa_master_ethtool_restore(struct net_device *dev)
116112
{
117-
struct dsa_switch_tree *dst = dev->dsa_ptr;
118-
struct dsa_port *cpu_dp = dst->cpu_dp;
113+
struct dsa_port *cpu_dp = dev->dsa_ptr;
119114

120115
dev->ethtool_ops = cpu_dp->orig_ethtool_ops;
121116
cpu_dp->orig_ethtool_ops = NULL;

0 commit comments

Comments
 (0)