Commit b217566a authored by David S. Miller's avatar David S. Miller

Merge branch 'net-dsa-Multi-CPU-ground-work'

Florian Fainelli says:

====================
net: dsa: Multi-CPU ground work (v4)

This patch series prepares the ground for adding mutliple CPU port support to
DSA, and starts by removing redundant pieces of information such as
master_netdev which is cpu_dp->ethernet. Finally drivers are moved away from
directly accessing ds->dst->cpu_dp and use appropriate helper functions.

Note that if you have Device Tree blobs/platform configurations that are
currently listing multiple CPU ports, the proposed behavior in
dsa_ds_get_cpu_dp() will be to return the last bit set in ds->cpu_port_mask.

Future plans include:
- making dst->cpu_dp a flexible data structure (array, list, you name it)
- having the ability for drivers to return a default/preferred CPU port (if
  necessary)

Changes in v4:

- fixed build warning with NETPOLL enabled

Changes in v3:

- removed the last patch since it causes problems with bcm_sf2/b53 in a
  dual-CPU case (root cause known, proper fix underway)

- removed dsa_ds_get_cpu_dp()

Changes in v2:

- added Reviewed-by tags
- assign port->cpu_dp earlier before ops->setup() has run
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 38b6ec50 3cc9f257
...@@ -806,7 +806,7 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds) ...@@ -806,7 +806,7 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds)
static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port, static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port,
struct ethtool_wolinfo *wol) struct ethtool_wolinfo *wol)
{ {
struct net_device *p = ds->dst[ds->index].master_netdev; struct net_device *p = ds->dst[ds->index].cpu_dp->netdev;
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
struct ethtool_wolinfo pwol; struct ethtool_wolinfo pwol;
...@@ -829,7 +829,7 @@ static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port, ...@@ -829,7 +829,7 @@ static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port,
static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int port, static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int port,
struct ethtool_wolinfo *wol) struct ethtool_wolinfo *wol)
{ {
struct net_device *p = ds->dst[ds->index].master_netdev; struct net_device *p = ds->dst[ds->index].cpu_dp->netdev;
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
s8 cpu_port = ds->dst->cpu_dp->index; s8 cpu_port = ds->dst->cpu_dp->index;
struct ethtool_wolinfo pwol; struct ethtool_wolinfo pwol;
......
...@@ -912,11 +912,11 @@ mt7530_setup(struct dsa_switch *ds) ...@@ -912,11 +912,11 @@ mt7530_setup(struct dsa_switch *ds)
struct device_node *dn; struct device_node *dn;
struct mt7530_dummy_poll p; struct mt7530_dummy_poll p;
/* The parent node of master_netdev which holds the common system /* The parent node of cpu_dp->netdev which holds the common system
* controller also is the container for two GMACs nodes representing * controller also is the container for two GMACs nodes representing
* as two netdev instances. * as two netdev instances.
*/ */
dn = ds->master_netdev->dev.of_node->parent; dn = ds->dst->cpu_dp->netdev->dev.of_node->parent;
priv->ethernet = syscon_node_to_regmap(dn); priv->ethernet = syscon_node_to_regmap(dn);
if (IS_ERR(priv->ethernet)) if (IS_ERR(priv->ethernet))
return PTR_ERR(priv->ethernet); return PTR_ERR(priv->ethernet);
......
...@@ -122,24 +122,12 @@ struct dsa_switch_tree { ...@@ -122,24 +122,12 @@ struct dsa_switch_tree {
*/ */
struct dsa_platform_data *pd; struct dsa_platform_data *pd;
/*
* Reference to network device to use, and which tagging
* protocol to use.
*/
struct net_device *master_netdev;
/* Copy of tag_ops->rcv for faster access in hot path */ /* Copy of tag_ops->rcv for faster access in hot path */
struct sk_buff * (*rcv)(struct sk_buff *skb, struct sk_buff * (*rcv)(struct sk_buff *skb,
struct net_device *dev, struct net_device *dev,
struct packet_type *pt, struct packet_type *pt,
struct net_device *orig_dev); struct net_device *orig_dev);
/*
* Original copy of the master netdev ethtool_ops
*/
struct ethtool_ops master_ethtool_ops;
const struct ethtool_ops *master_orig_ethtool_ops;
/* /*
* The switch port to which the CPU is attached. * The switch port to which the CPU is attached.
*/ */
...@@ -183,12 +171,18 @@ struct dsa_port { ...@@ -183,12 +171,18 @@ struct dsa_port {
struct dsa_switch *ds; struct dsa_switch *ds;
unsigned int index; unsigned int index;
const char *name; const char *name;
struct dsa_port *cpu_dp;
struct net_device *netdev; struct net_device *netdev;
struct device_node *dn; struct device_node *dn;
unsigned int ageing_time; unsigned int ageing_time;
u8 stp_state; u8 stp_state;
struct net_device *bridge_dev; struct net_device *bridge_dev;
struct devlink_port devlink_port; struct devlink_port devlink_port;
/*
* Original copy of the master netdev ethtool_ops
*/
struct ethtool_ops ethtool_ops;
const struct ethtool_ops *orig_ethtool_ops;
}; };
struct dsa_switch { struct dsa_switch {
...@@ -226,11 +220,6 @@ struct dsa_switch { ...@@ -226,11 +220,6 @@ struct dsa_switch {
*/ */
s8 rtable[DSA_MAX_SWITCHES]; s8 rtable[DSA_MAX_SWITCHES];
/*
* The lower device this switch uses to talk to the host
*/
struct net_device *master_netdev;
/* /*
* Slave mii_bus and devices for the individual ports. * Slave mii_bus and devices for the individual ports.
*/ */
......
...@@ -118,18 +118,16 @@ int dsa_cpu_port_ethtool_setup(struct dsa_port *cpu_dp) ...@@ -118,18 +118,16 @@ int dsa_cpu_port_ethtool_setup(struct dsa_port *cpu_dp)
struct net_device *master; struct net_device *master;
struct ethtool_ops *cpu_ops; struct ethtool_ops *cpu_ops;
master = ds->dst->master_netdev; master = cpu_dp->netdev;
if (ds->master_netdev)
master = ds->master_netdev;
cpu_ops = devm_kzalloc(ds->dev, sizeof(*cpu_ops), GFP_KERNEL); cpu_ops = devm_kzalloc(ds->dev, sizeof(*cpu_ops), GFP_KERNEL);
if (!cpu_ops) if (!cpu_ops)
return -ENOMEM; return -ENOMEM;
memcpy(&ds->dst->master_ethtool_ops, master->ethtool_ops, memcpy(&cpu_dp->ethtool_ops, master->ethtool_ops,
sizeof(struct ethtool_ops)); sizeof(struct ethtool_ops));
ds->dst->master_orig_ethtool_ops = master->ethtool_ops; cpu_dp->orig_ethtool_ops = master->ethtool_ops;
memcpy(cpu_ops, &ds->dst->master_ethtool_ops, memcpy(cpu_ops, &cpu_dp->ethtool_ops,
sizeof(struct ethtool_ops)); sizeof(struct ethtool_ops));
dsa_cpu_port_ethtool_init(cpu_ops); dsa_cpu_port_ethtool_init(cpu_ops);
master->ethtool_ops = cpu_ops; master->ethtool_ops = cpu_ops;
...@@ -139,14 +137,7 @@ int dsa_cpu_port_ethtool_setup(struct dsa_port *cpu_dp) ...@@ -139,14 +137,7 @@ int dsa_cpu_port_ethtool_setup(struct dsa_port *cpu_dp)
void dsa_cpu_port_ethtool_restore(struct dsa_port *cpu_dp) void dsa_cpu_port_ethtool_restore(struct dsa_port *cpu_dp)
{ {
struct dsa_switch *ds = cpu_dp->ds; cpu_dp->netdev->ethtool_ops = cpu_dp->orig_ethtool_ops;
struct net_device *master;
master = ds->dst->master_netdev;
if (ds->master_netdev)
master = ds->master_netdev;
master->ethtool_ops = ds->dst->master_orig_ethtool_ops;
} }
void dsa_cpu_dsa_destroy(struct dsa_port *port) void dsa_cpu_dsa_destroy(struct dsa_port *port)
......
...@@ -337,7 +337,7 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds) ...@@ -337,7 +337,7 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
return err; return err;
if (ds->ops->set_addr) { if (ds->ops->set_addr) {
err = ds->ops->set_addr(ds, dst->master_netdev->dev_addr); err = ds->ops->set_addr(ds, dst->cpu_dp->netdev->dev_addr);
if (err < 0) if (err < 0)
return err; return err;
} }
...@@ -444,7 +444,7 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst) ...@@ -444,7 +444,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->master_netdev->dsa_ptr = dst; dst->cpu_dp->netdev->dsa_ptr = dst;
dst->applied = true; dst->applied = true;
return 0; return 0;
...@@ -458,7 +458,7 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst) ...@@ -458,7 +458,7 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
if (!dst->applied) if (!dst->applied)
return; return;
dst->master_netdev->dsa_ptr = NULL; dst->cpu_dp->netdev->dsa_ptr = NULL;
/* If we used a tagging format that doesn't have an ethertype /* If we used a tagging format that doesn't have an ethertype
* field, make sure that all packets from this point get sent * field, make sure that all packets from this point get sent
...@@ -490,6 +490,8 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index, ...@@ -490,6 +490,8 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
enum dsa_tag_protocol tag_protocol; enum dsa_tag_protocol tag_protocol;
struct net_device *ethernet_dev; struct net_device *ethernet_dev;
struct device_node *ethernet; struct device_node *ethernet;
struct dsa_port *p;
unsigned int i;
if (port->dn) { if (port->dn) {
ethernet = of_parse_phandle(port->dn, "ethernet", 0); ethernet = of_parse_phandle(port->dn, "ethernet", 0);
...@@ -504,14 +506,19 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index, ...@@ -504,14 +506,19 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
if (!ethernet_dev) if (!ethernet_dev)
return -EPROBE_DEFER; return -EPROBE_DEFER;
if (!ds->master_netdev) if (!dst->cpu_dp) {
ds->master_netdev = ethernet_dev; dst->cpu_dp = port;
dst->cpu_dp->netdev = ethernet_dev;
if (!dst->master_netdev) for (i = 0; i < ds->num_ports; i++) {
dst->master_netdev = ethernet_dev; p = &ds->ports[i];
if (!dsa_port_is_valid(p) ||
i == index)
continue;
if (!dst->cpu_dp) p->cpu_dp = port;
dst->cpu_dp = port; }
}
tag_protocol = ds->ops->get_tag_protocol(ds); tag_protocol = ds->ops->get_tag_protocol(ds);
dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol); dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol);
...@@ -578,7 +585,7 @@ static int dsa_dst_parse(struct dsa_switch_tree *dst) ...@@ -578,7 +585,7 @@ static int dsa_dst_parse(struct dsa_switch_tree *dst)
return err; return err;
} }
if (!dst->master_netdev) { if (!dst->cpu_dp->netdev) {
pr_warn("Tree has no master device\n"); pr_warn("Tree has no master device\n");
return -EINVAL; return -EINVAL;
} }
......
...@@ -183,4 +183,14 @@ extern const struct dsa_device_ops qca_netdev_ops; ...@@ -183,4 +183,14 @@ extern const struct dsa_device_ops qca_netdev_ops;
/* tag_trailer.c */ /* tag_trailer.c */
extern const struct dsa_device_ops trailer_netdev_ops; extern const struct dsa_device_ops trailer_netdev_ops;
static inline struct net_device *dsa_master_netdev(struct dsa_slave_priv *p)
{
return p->dp->cpu_dp->netdev;
}
static inline struct dsa_port *dsa_get_cpu_port(struct dsa_switch_tree *dst)
{
return dst->cpu_dp;
}
#endif #endif
...@@ -101,9 +101,12 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) ...@@ -101,9 +101,12 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
struct dsa_switch_tree *dst = ds->dst; struct dsa_switch_tree *dst = ds->dst;
struct dsa_chip_data *cd = ds->cd; struct dsa_chip_data *cd = ds->cd;
bool valid_name_found = false; bool valid_name_found = false;
struct net_device *master;
int index = ds->index; int index = ds->index;
int i, ret; int i, ret;
master = dst->cpu_dp->netdev;
/* /*
* Validate supplied switch configuration. * Validate supplied switch configuration.
*/ */
...@@ -116,7 +119,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) ...@@ -116,7 +119,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
if (!strcmp(name, "cpu")) { if (!strcmp(name, "cpu")) {
if (dst->cpu_dp) { if (dst->cpu_dp) {
netdev_err(dst->master_netdev, netdev_err(master,
"multiple cpu ports?!\n"); "multiple cpu ports?!\n");
return -EINVAL; return -EINVAL;
} }
...@@ -126,6 +129,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) ...@@ -126,6 +129,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
ds->dsa_port_mask |= 1 << i; ds->dsa_port_mask |= 1 << i;
} else { } else {
ds->enabled_port_mask |= 1 << i; ds->enabled_port_mask |= 1 << i;
ds->ports[i].cpu_dp = dst->cpu_dp;
} }
valid_name_found = true; valid_name_found = true;
} }
...@@ -168,7 +172,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) ...@@ -168,7 +172,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
return ret; return ret;
if (ops->set_addr) { if (ops->set_addr) {
ret = ops->set_addr(ds, dst->master_netdev->dev_addr); ret = ops->set_addr(ds, master->dev_addr);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
...@@ -195,14 +199,14 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) ...@@ -195,14 +199,14 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
ret = dsa_slave_create(ds, parent, i, cd->port_names[i]); ret = dsa_slave_create(ds, parent, i, cd->port_names[i]);
if (ret < 0) if (ret < 0)
netdev_err(dst->master_netdev, "[%d]: can't create dsa slave device for port %d(%s): %d\n", netdev_err(master, "[%d]: can't create dsa slave device for port %d(%s): %d\n",
index, i, cd->port_names[i], ret); index, i, cd->port_names[i], ret);
} }
/* Perform configuration of the CPU and DSA ports */ /* Perform configuration of the CPU and DSA ports */
ret = dsa_cpu_dsa_setups(ds, parent); ret = dsa_cpu_dsa_setups(ds, parent);
if (ret < 0) if (ret < 0)
netdev_err(dst->master_netdev, "[%d] : can't configure CPU and DSA ports\n", netdev_err(master, "[%d] : can't configure CPU and DSA ports\n",
index); index);
ret = dsa_cpu_port_ethtool_setup(ds->dst->cpu_dp); ret = dsa_cpu_port_ethtool_setup(ds->dst->cpu_dp);
...@@ -217,6 +221,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, ...@@ -217,6 +221,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
struct device *parent, struct device *host_dev) struct device *parent, struct device *host_dev)
{ {
struct dsa_chip_data *cd = dst->pd->chip + index; struct dsa_chip_data *cd = dst->pd->chip + index;
struct net_device *master = dst->cpu_dp->netdev;
const struct dsa_switch_ops *ops; const struct dsa_switch_ops *ops;
struct dsa_switch *ds; struct dsa_switch *ds;
int ret; int ret;
...@@ -228,11 +233,11 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, ...@@ -228,11 +233,11 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
*/ */
ops = dsa_switch_probe(parent, host_dev, cd->sw_addr, &name, &priv); ops = dsa_switch_probe(parent, host_dev, cd->sw_addr, &name, &priv);
if (!ops) { if (!ops) {
netdev_err(dst->master_netdev, "[%d]: could not detect attached switch\n", netdev_err(master, "[%d]: could not detect attached switch\n",
index); index);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
netdev_info(dst->master_netdev, "[%d]: detected a %s switch\n", netdev_info(master, "[%d]: detected a %s switch\n",
index, name); index, name);
...@@ -575,7 +580,7 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev, ...@@ -575,7 +580,7 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
unsigned configured = 0; unsigned configured = 0;
dst->pd = pd; dst->pd = pd;
dst->master_netdev = dev; dst->cpu_dp->netdev = dev;
for (i = 0; i < pd->nr_chips; i++) { for (i = 0; i < pd->nr_chips; i++) {
struct dsa_switch *ds; struct dsa_switch *ds;
...@@ -671,7 +676,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst) ...@@ -671,7 +676,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
{ {
int i; int i;
dst->master_netdev->dsa_ptr = NULL; dst->cpu_dp->netdev->dsa_ptr = NULL;
/* If we used a tagging format that doesn't have an ethertype /* If we used a tagging format that doesn't have an ethertype
* field, make sure that all packets from this point get sent * field, make sure that all packets from this point get sent
...@@ -688,7 +693,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst) ...@@ -688,7 +693,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
dsa_cpu_port_ethtool_restore(dst->cpu_dp); dsa_cpu_port_ethtool_restore(dst->cpu_dp);
dev_put(dst->master_netdev); dev_put(dst->cpu_dp->netdev);
} }
static int dsa_remove(struct platform_device *pdev) static int dsa_remove(struct platform_device *pdev)
......
...@@ -66,7 +66,7 @@ static int dsa_slave_get_iflink(const struct net_device *dev) ...@@ -66,7 +66,7 @@ static int dsa_slave_get_iflink(const struct net_device *dev)
{ {
struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_slave_priv *p = netdev_priv(dev);
return p->dp->ds->dst->master_netdev->ifindex; return dsa_master_netdev(p)->ifindex;
} }
static int dsa_slave_open(struct net_device *dev) static int dsa_slave_open(struct net_device *dev)
...@@ -74,7 +74,7 @@ static int dsa_slave_open(struct net_device *dev) ...@@ -74,7 +74,7 @@ static int dsa_slave_open(struct net_device *dev)
struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp; struct dsa_port *dp = p->dp;
struct dsa_switch *ds = dp->ds; struct dsa_switch *ds = dp->ds;
struct net_device *master = ds->dst->master_netdev; struct net_device *master = dsa_master_netdev(p);
u8 stp_state = dp->bridge_dev ? BR_STATE_BLOCKING : BR_STATE_FORWARDING; u8 stp_state = dp->bridge_dev ? BR_STATE_BLOCKING : BR_STATE_FORWARDING;
int err; int err;
...@@ -127,7 +127,7 @@ static int dsa_slave_open(struct net_device *dev) ...@@ -127,7 +127,7 @@ static int dsa_slave_open(struct net_device *dev)
static int dsa_slave_close(struct net_device *dev) static int dsa_slave_close(struct net_device *dev)
{ {
struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_slave_priv *p = netdev_priv(dev);
struct net_device *master = p->dp->ds->dst->master_netdev; struct net_device *master = dsa_master_netdev(p);
struct dsa_switch *ds = p->dp->ds; struct dsa_switch *ds = p->dp->ds;
if (p->phy) if (p->phy)
...@@ -154,7 +154,7 @@ static int dsa_slave_close(struct net_device *dev) ...@@ -154,7 +154,7 @@ static int dsa_slave_close(struct net_device *dev)
static void dsa_slave_change_rx_flags(struct net_device *dev, int change) static void dsa_slave_change_rx_flags(struct net_device *dev, int change)
{ {
struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_slave_priv *p = netdev_priv(dev);
struct net_device *master = p->dp->ds->dst->master_netdev; struct net_device *master = dsa_master_netdev(p);
if (change & IFF_ALLMULTI) if (change & IFF_ALLMULTI)
dev_set_allmulti(master, dev->flags & IFF_ALLMULTI ? 1 : -1); 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) ...@@ -165,7 +165,7 @@ static void dsa_slave_change_rx_flags(struct net_device *dev, int change)
static void dsa_slave_set_rx_mode(struct net_device *dev) static void dsa_slave_set_rx_mode(struct net_device *dev)
{ {
struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_slave_priv *p = netdev_priv(dev);
struct net_device *master = p->dp->ds->dst->master_netdev; struct net_device *master = dsa_master_netdev(p);
dev_mc_sync(master, dev); dev_mc_sync(master, dev);
dev_uc_sync(master, dev); dev_uc_sync(master, dev);
...@@ -174,7 +174,7 @@ static void dsa_slave_set_rx_mode(struct net_device *dev) ...@@ -174,7 +174,7 @@ static void dsa_slave_set_rx_mode(struct net_device *dev)
static int dsa_slave_set_mac_address(struct net_device *dev, void *a) static int dsa_slave_set_mac_address(struct net_device *dev, void *a)
{ {
struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_slave_priv *p = netdev_priv(dev);
struct net_device *master = p->dp->ds->dst->master_netdev; struct net_device *master = dsa_master_netdev(p);
struct sockaddr *addr = a; struct sockaddr *addr = a;
int err; int err;
...@@ -375,7 +375,7 @@ static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -375,7 +375,7 @@ static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
/* Queue the SKB for transmission on the parent interface, but /* Queue the SKB for transmission on the parent interface, but
* do not modify its EtherType * do not modify its EtherType
*/ */
nskb->dev = p->dp->ds->dst->master_netdev; nskb->dev = dsa_master_netdev(p);
dev_queue_xmit(nskb); dev_queue_xmit(nskb);
return NETDEV_TX_OK; return NETDEV_TX_OK;
...@@ -520,14 +520,14 @@ static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev, ...@@ -520,14 +520,14 @@ static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev,
uint64_t *data) uint64_t *data)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_switch_tree *dst = dev->dsa_ptr;
struct dsa_switch *ds = dst->cpu_dp->ds; struct dsa_port *cpu_dp = dsa_get_cpu_port(dst);
s8 cpu_port = dst->cpu_dp->index; struct dsa_switch *ds = cpu_dp->ds;
s8 cpu_port = cpu_dp->index;
int count = 0; int count = 0;
if (dst->master_ethtool_ops.get_sset_count) { if (cpu_dp->ethtool_ops.get_sset_count) {
count = dst->master_ethtool_ops.get_sset_count(dev, count = cpu_dp->ethtool_ops.get_sset_count(dev, ETH_SS_STATS);
ETH_SS_STATS); cpu_dp->ethtool_ops.get_ethtool_stats(dev, stats, data);
dst->master_ethtool_ops.get_ethtool_stats(dev, stats, data);
} }
if (ds->ops->get_ethtool_stats) if (ds->ops->get_ethtool_stats)
...@@ -537,11 +537,12 @@ static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev, ...@@ -537,11 +537,12 @@ static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev,
static int dsa_cpu_port_get_sset_count(struct net_device *dev, int sset) static int dsa_cpu_port_get_sset_count(struct net_device *dev, int sset)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_switch_tree *dst = dev->dsa_ptr;
struct dsa_switch *ds = dst->cpu_dp->ds; struct dsa_port *cpu_dp = dsa_get_cpu_port(dst);
struct dsa_switch *ds = cpu_dp->ds;
int count = 0; int count = 0;
if (dst->master_ethtool_ops.get_sset_count) if (cpu_dp->ethtool_ops.get_sset_count)
count += dst->master_ethtool_ops.get_sset_count(dev, sset); count += cpu_dp->ethtool_ops.get_sset_count(dev, sset);
if (sset == ETH_SS_STATS && ds->ops->get_sset_count) if (sset == ETH_SS_STATS && ds->ops->get_sset_count)
count += ds->ops->get_sset_count(ds); count += ds->ops->get_sset_count(ds);
...@@ -553,8 +554,9 @@ static void dsa_cpu_port_get_strings(struct net_device *dev, ...@@ -553,8 +554,9 @@ static void dsa_cpu_port_get_strings(struct net_device *dev,
uint32_t stringset, uint8_t *data) uint32_t stringset, uint8_t *data)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_switch_tree *dst = dev->dsa_ptr;
struct dsa_switch *ds = dst->cpu_dp->ds; struct dsa_port *cpu_dp = dsa_get_cpu_port(dst);
s8 cpu_port = dst->cpu_dp->index; struct dsa_switch *ds = cpu_dp->ds;
s8 cpu_port = cpu_dp->index;
int len = ETH_GSTRING_LEN; int len = ETH_GSTRING_LEN;
int mcount = 0, count; int mcount = 0, count;
unsigned int i; unsigned int i;
...@@ -565,10 +567,9 @@ static void dsa_cpu_port_get_strings(struct net_device *dev, ...@@ -565,10 +567,9 @@ static void dsa_cpu_port_get_strings(struct net_device *dev,
/* We do not want to be NULL-terminated, since this is a prefix */ /* We do not want to be NULL-terminated, since this is a prefix */
pfx[sizeof(pfx) - 1] = '_'; pfx[sizeof(pfx) - 1] = '_';
if (dst->master_ethtool_ops.get_sset_count) { if (cpu_dp->ethtool_ops.get_sset_count) {
mcount = dst->master_ethtool_ops.get_sset_count(dev, mcount = cpu_dp->ethtool_ops.get_sset_count(dev, ETH_SS_STATS);
ETH_SS_STATS); cpu_dp->ethtool_ops.get_strings(dev, stringset, data);
dst->master_ethtool_ops.get_strings(dev, stringset, data);
} }
if (stringset == ETH_SS_STATS && ds->ops->get_strings) { if (stringset == ETH_SS_STATS && ds->ops->get_strings) {
...@@ -684,8 +685,7 @@ static int dsa_slave_netpoll_setup(struct net_device *dev, ...@@ -684,8 +685,7 @@ static int dsa_slave_netpoll_setup(struct net_device *dev,
struct netpoll_info *ni) struct netpoll_info *ni)
{ {
struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds; struct net_device *master = dsa_master_netdev(p);
struct net_device *master = ds->dst->master_netdev;
struct netpoll *netpoll; struct netpoll *netpoll;
int err = 0; int err = 0;
...@@ -1141,11 +1141,11 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent, ...@@ -1141,11 +1141,11 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
struct net_device *master; struct net_device *master;
struct net_device *slave_dev; struct net_device *slave_dev;
struct dsa_slave_priv *p; struct dsa_slave_priv *p;
struct dsa_port *cpu_dp;
int ret; int ret;
master = ds->dst->master_netdev; cpu_dp = ds->dst->cpu_dp;
if (ds->master_netdev) master = cpu_dp->netdev;
master = ds->master_netdev;
slave_dev = alloc_netdev(sizeof(struct dsa_slave_priv), name, slave_dev = alloc_netdev(sizeof(struct dsa_slave_priv), name,
NET_NAME_UNKNOWN, ether_setup); NET_NAME_UNKNOWN, ether_setup);
......
...@@ -93,12 +93,11 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -93,12 +93,11 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
struct net_device *orig_dev) struct net_device *orig_dev)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_switch_tree *dst = dev->dsa_ptr;
struct dsa_switch *ds; struct dsa_port *cpu_dp = dsa_get_cpu_port(dst);
struct dsa_switch *ds = cpu_dp->ds;
int source_port; int source_port;
u8 *brcm_tag; u8 *brcm_tag;
ds = dst->cpu_dp->ds;
if (unlikely(!pskb_may_pull(skb, BRCM_TAG_LEN))) if (unlikely(!pskb_may_pull(skb, BRCM_TAG_LEN)))
return NULL; return NULL;
......
...@@ -75,12 +75,11 @@ static struct sk_buff *ksz_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -75,12 +75,11 @@ static struct sk_buff *ksz_rcv(struct sk_buff *skb, struct net_device *dev,
struct net_device *orig_dev) struct net_device *orig_dev)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_switch_tree *dst = dev->dsa_ptr;
struct dsa_switch *ds; struct dsa_port *cpu_dp = dsa_get_cpu_port(dst);
struct dsa_switch *ds = cpu_dp->ds;
u8 *tag; u8 *tag;
int source_port; int source_port;
ds = dst->cpu_dp->ds;
tag = skb_tail_pointer(skb) - KSZ_EGRESS_TAG_LEN; tag = skb_tail_pointer(skb) - KSZ_EGRESS_TAG_LEN;
source_port = tag[0] & 7; source_port = tag[0] & 7;
......
...@@ -67,6 +67,7 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -67,6 +67,7 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,
struct net_device *orig_dev) struct net_device *orig_dev)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_switch_tree *dst = dev->dsa_ptr;
struct dsa_port *cpu_dp = dsa_get_cpu_port(dst);
struct dsa_switch *ds; struct dsa_switch *ds;
u8 ver; u8 ver;
int port; int port;
...@@ -95,7 +96,7 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -95,7 +96,7 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,
/* This protocol doesn't support cascading multiple switches so it's /* This protocol doesn't support cascading multiple switches so it's
* safe to assume the switch is first in the tree * safe to assume the switch is first in the tree
*/ */
ds = dst->cpu_dp->ds; ds = cpu_dp->ds;
if (!ds) if (!ds)
return NULL; return NULL;
......
...@@ -61,12 +61,11 @@ static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -61,12 +61,11 @@ static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev,
struct net_device *orig_dev) struct net_device *orig_dev)
{ {
struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_switch_tree *dst = dev->dsa_ptr;
struct dsa_switch *ds; struct dsa_port *cpu_dp = dsa_get_cpu_port(dst);
struct dsa_switch *ds = cpu_dp->ds;
u8 *trailer; u8 *trailer;
int source_port; int source_port;
ds = dst->cpu_dp->ds;
if (skb_linearize(skb)) if (skb_linearize(skb))
return NULL; return 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