Commit 2f657a60 authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller

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: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3e41f93b
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
struct netpoll_info; struct netpoll_info;
struct device; struct device;
struct phy_device; struct phy_device;
struct dsa_switch_tree; struct dsa_port;
/* 802.11 specific */ /* 802.11 specific */
struct wireless_dev; struct wireless_dev;
...@@ -1752,7 +1752,7 @@ struct net_device { ...@@ -1752,7 +1752,7 @@ struct net_device {
struct vlan_info __rcu *vlan_info; struct vlan_info __rcu *vlan_info;
#endif #endif
#if IS_ENABLED(CONFIG_NET_DSA) #if IS_ENABLED(CONFIG_NET_DSA)
struct dsa_switch_tree *dsa_ptr; struct dsa_port *dsa_ptr;
#endif #endif
#if IS_ENABLED(CONFIG_TIPC) #if IS_ENABLED(CONFIG_TIPC)
struct tipc_bearer __rcu *tipc_ptr; struct tipc_bearer __rcu *tipc_ptr;
......
...@@ -160,12 +160,12 @@ EXPORT_SYMBOL_GPL(dsa_dev_to_net_device); ...@@ -160,12 +160,12 @@ EXPORT_SYMBOL_GPL(dsa_dev_to_net_device);
static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev, static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *unused) struct packet_type *pt, struct net_device *unused)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_port *cpu_dp = dev->dsa_ptr;
struct sk_buff *nskb = NULL; struct sk_buff *nskb = NULL;
struct pcpu_sw_netstats *s; struct pcpu_sw_netstats *s;
struct dsa_slave_priv *p; struct dsa_slave_priv *p;
if (unlikely(dst == NULL)) { if (unlikely(!cpu_dp)) {
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
} }
...@@ -174,7 +174,7 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -174,7 +174,7 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
if (!skb) if (!skb)
return 0; return 0;
nskb = dst->rcv(skb, dev, pt); nskb = cpu_dp->rcv(skb, dev, pt);
if (!nskb) { if (!nskb) {
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
......
...@@ -438,7 +438,7 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst) ...@@ -438,7 +438,7 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)
* sent to the tag format's receive function. * sent to the tag format's receive function.
*/ */
wmb(); wmb();
dst->cpu_dp->netdev->dsa_ptr = dst; dst->cpu_dp->netdev->dsa_ptr = dst->cpu_dp;
err = dsa_master_ethtool_setup(dst->cpu_dp->netdev); err = dsa_master_ethtool_setup(dst->cpu_dp->netdev);
if (err) if (err)
......
...@@ -116,7 +116,8 @@ void dsa_master_ethtool_restore(struct net_device *dev); ...@@ -116,7 +116,8 @@ void dsa_master_ethtool_restore(struct net_device *dev);
static inline struct net_device *dsa_master_get_slave(struct net_device *dev, static inline struct net_device *dsa_master_get_slave(struct net_device *dev,
int device, int port) int device, int port)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_port *cpu_dp = dev->dsa_ptr;
struct dsa_switch_tree *dst = cpu_dp->dst;
struct dsa_switch *ds; struct dsa_switch *ds;
if (device < 0 || device >= DSA_MAX_SWITCHES) if (device < 0 || device >= DSA_MAX_SWITCHES)
......
...@@ -607,7 +607,7 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev, ...@@ -607,7 +607,7 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
* sent to the tag format's receive function. * sent to the tag format's receive function.
*/ */
wmb(); wmb();
dev->dsa_ptr = dst; dev->dsa_ptr = dst->cpu_dp;
return dsa_master_ethtool_setup(dst->cpu_dp->netdev); return dsa_master_ethtool_setup(dst->cpu_dp->netdev);
} }
......
...@@ -16,8 +16,7 @@ static void dsa_master_get_ethtool_stats(struct net_device *dev, ...@@ -16,8 +16,7 @@ static void dsa_master_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats, struct ethtool_stats *stats,
uint64_t *data) uint64_t *data)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_port *cpu_dp = dev->dsa_ptr;
struct dsa_port *cpu_dp = dst->cpu_dp;
const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops; const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops;
struct dsa_switch *ds = cpu_dp->ds; struct dsa_switch *ds = cpu_dp->ds;
int port = cpu_dp->index; int port = cpu_dp->index;
...@@ -34,8 +33,7 @@ static void dsa_master_get_ethtool_stats(struct net_device *dev, ...@@ -34,8 +33,7 @@ static void dsa_master_get_ethtool_stats(struct net_device *dev,
static int dsa_master_get_sset_count(struct net_device *dev, int sset) static int dsa_master_get_sset_count(struct net_device *dev, int sset)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_port *cpu_dp = dev->dsa_ptr;
struct dsa_port *cpu_dp = dst->cpu_dp;
const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops; const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops;
struct dsa_switch *ds = cpu_dp->ds; struct dsa_switch *ds = cpu_dp->ds;
int count = 0; int count = 0;
...@@ -52,8 +50,7 @@ static int dsa_master_get_sset_count(struct net_device *dev, int sset) ...@@ -52,8 +50,7 @@ static int dsa_master_get_sset_count(struct net_device *dev, int sset)
static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset, static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset,
uint8_t *data) uint8_t *data)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_port *cpu_dp = dev->dsa_ptr;
struct dsa_port *cpu_dp = dst->cpu_dp;
const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops; const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops;
struct dsa_switch *ds = cpu_dp->ds; struct dsa_switch *ds = cpu_dp->ds;
int port = cpu_dp->index; int port = cpu_dp->index;
...@@ -90,8 +87,7 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset, ...@@ -90,8 +87,7 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset,
int dsa_master_ethtool_setup(struct net_device *dev) int dsa_master_ethtool_setup(struct net_device *dev)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_port *cpu_dp = dev->dsa_ptr;
struct dsa_port *cpu_dp = dst->cpu_dp;
struct dsa_switch *ds = cpu_dp->ds; struct dsa_switch *ds = cpu_dp->ds;
struct ethtool_ops *ops; struct ethtool_ops *ops;
...@@ -114,8 +110,7 @@ int dsa_master_ethtool_setup(struct net_device *dev) ...@@ -114,8 +110,7 @@ int dsa_master_ethtool_setup(struct net_device *dev)
void dsa_master_ethtool_restore(struct net_device *dev) void dsa_master_ethtool_restore(struct net_device *dev)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_port *cpu_dp = dev->dsa_ptr;
struct dsa_port *cpu_dp = dst->cpu_dp;
dev->ethtool_ops = cpu_dp->orig_ethtool_ops; dev->ethtool_ops = cpu_dp->orig_ethtool_ops;
cpu_dp->orig_ethtool_ops = NULL; cpu_dp->orig_ethtool_ops = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment