Commit 19aeeb9f authored by David S. Miller's avatar David S. Miller

Merge branch 'dsa-setup-stage'

Vivien Didelot says:

====================
net: dsa: setup stage

When probing a DSA switch, there is basically two stages.

The first stage is the parsing of the switch device, from either device
tree or platform data. It fetches the DSA tree to which it belongs, and
validates its ports. The switch device is then added to the tree, and
the second stage is called if this was the last switch of the tree.

The second stage is the setup of the tree, which validates that the tree
is complete, sets up the routing tables, the default CPU port for user
ports, sets up the switch drivers and finally the master interfaces,
which makes the whole switch fabric functional.

This patch series covers the second setup stage. The setup and teardown
of a switch tree have been separated into logical steps, and the probing
of a switch now simply parses and adds a switch to a tree.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents b2d0f5d5 b4fbb347
......@@ -122,7 +122,7 @@ struct dsa_switch_tree {
struct kref refcount;
/* Has this tree been applied to the hardware? */
bool applied;
bool setup;
/*
* Configuration data for the platform device that owns
......@@ -190,7 +190,7 @@ struct dsa_port {
struct dsa_switch *ds;
unsigned int index;
const char *name;
struct dsa_port *cpu_dp;
const struct dsa_port *cpu_dp;
struct device_node *dn;
unsigned int ageing_time;
u8 stp_state;
......
This diff is collapsed.
......@@ -108,8 +108,8 @@ int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
const unsigned char *addr, u16 vid);
/* master.c */
int dsa_master_ethtool_setup(struct net_device *dev);
void dsa_master_ethtool_restore(struct net_device *dev);
int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp);
void dsa_master_teardown(struct net_device *dev);
static inline struct net_device *dsa_master_find_slave(struct net_device *dev,
int device, int port)
......
......@@ -593,15 +593,7 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
if (!configured)
return -EPROBE_DEFER;
/*
* If we use a tagging format that doesn't have an ethertype
* field, make sure that all packets from this point on get
* sent to the tag format's receive function.
*/
wmb();
dev->dsa_ptr = dst->cpu_dp;
return dsa_master_ethtool_setup(dst->cpu_dp->master);
return dsa_master_setup(dst->cpu_dp->master, dst->cpu_dp);
}
static int dsa_probe(struct platform_device *pdev)
......@@ -666,15 +658,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
{
int i;
dsa_master_ethtool_restore(dst->cpu_dp->master);
dst->cpu_dp->master->dsa_ptr = NULL;
/* If we used a tagging format that doesn't have an ethertype
* field, make sure that all packets from this point get sent
* without the tag and go through the regular receive path.
*/
wmb();
dsa_master_teardown(dst->cpu_dp->master);
for (i = 0; i < dst->pd->nr_chips; i++) {
struct dsa_switch *ds = dst->ds[i];
......
......@@ -85,7 +85,7 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset,
}
}
int dsa_master_ethtool_setup(struct net_device *dev)
static int dsa_master_ethtool_setup(struct net_device *dev)
{
struct dsa_port *cpu_dp = dev->dsa_ptr;
struct dsa_switch *ds = cpu_dp->ds;
......@@ -108,10 +108,36 @@ int dsa_master_ethtool_setup(struct net_device *dev)
return 0;
}
void dsa_master_ethtool_restore(struct net_device *dev)
static void dsa_master_ethtool_teardown(struct net_device *dev)
{
struct dsa_port *cpu_dp = dev->dsa_ptr;
dev->ethtool_ops = cpu_dp->orig_ethtool_ops;
cpu_dp->orig_ethtool_ops = NULL;
}
int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
{
/* If we use a tagging format that doesn't have an ethertype
* field, make sure that all packets from this point on get
* sent to the tag format's receive function.
*/
wmb();
dev->dsa_ptr = cpu_dp;
return dsa_master_ethtool_setup(dev);
}
void dsa_master_teardown(struct net_device *dev)
{
dsa_master_ethtool_teardown(dev);
dev->dsa_ptr = NULL;
/* If we used a tagging format that doesn't have an ethertype
* field, make sure that all packets from this point get sent
* without the tag and go through the regular receive path.
*/
wmb();
}
......@@ -1147,7 +1147,7 @@ static void dsa_slave_notify(struct net_device *dev, unsigned long val)
int dsa_slave_create(struct dsa_port *port)
{
struct dsa_port *cpu_dp = port->cpu_dp;
const struct dsa_port *cpu_dp = port->cpu_dp;
struct net_device *master = cpu_dp->master;
struct dsa_switch *ds = port->ds;
const char *name = port->name;
......
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