Commit da4561cd authored by Vivien Didelot's avatar Vivien Didelot Committed by Jakub Kicinski

net: dsa: use ports list to setup default CPU port

Use the new ports list instead of iterating over switches and their
ports when setting up the default CPU port. Unassign it on teardown.

Now that we can iterate over multiple CPU ports, remove dst->cpu_dp.

At the same time, provide a better error message for CPU-less tree.
Signed-off-by: default avatarVivien Didelot <vivien.didelot@gmail.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
parent c0b73628
...@@ -120,11 +120,6 @@ struct dsa_switch_tree { ...@@ -120,11 +120,6 @@ struct dsa_switch_tree {
*/ */
struct dsa_platform_data *pd; struct dsa_platform_data *pd;
/*
* The switch port to which the CPU is attached.
*/
struct dsa_port *cpu_dp;
/* List of switch ports */ /* List of switch ports */
struct list_head ports; struct list_head ports;
......
...@@ -197,38 +197,29 @@ static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst) ...@@ -197,38 +197,29 @@ static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst)
static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst) static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst)
{ {
struct dsa_switch *ds; struct dsa_port *cpu_dp, *dp;
struct dsa_port *dp;
int device, port;
/* DSA currently only supports a single CPU port */ cpu_dp = dsa_tree_find_first_cpu(dst);
dst->cpu_dp = dsa_tree_find_first_cpu(dst); if (!cpu_dp) {
if (!dst->cpu_dp) { pr_err("DSA: tree %d has no CPU port\n", dst->index);
pr_warn("Tree has no master device\n");
return -EINVAL; return -EINVAL;
} }
/* Assign the default CPU port to all ports of the fabric */ /* Assign the default CPU port to all ports of the fabric */
for (device = 0; device < DSA_MAX_SWITCHES; device++) { list_for_each_entry(dp, &dst->ports, list)
ds = dst->ds[device]; if (dsa_port_is_user(dp) || dsa_port_is_dsa(dp))
if (!ds) dp->cpu_dp = cpu_dp;
continue;
for (port = 0; port < ds->num_ports; port++) {
dp = &ds->ports[port];
if (dsa_port_is_user(dp) || dsa_port_is_dsa(dp))
dp->cpu_dp = dst->cpu_dp;
}
}
return 0; return 0;
} }
static void dsa_tree_teardown_default_cpu(struct dsa_switch_tree *dst) static void dsa_tree_teardown_default_cpu(struct dsa_switch_tree *dst)
{ {
/* DSA currently only supports a single CPU port */ struct dsa_port *dp;
dst->cpu_dp = NULL;
list_for_each_entry(dp, &dst->ports, list)
if (dsa_port_is_user(dp) || dsa_port_is_dsa(dp))
dp->cpu_dp = NULL;
} }
static int dsa_port_setup(struct dsa_port *dp) static int dsa_port_setup(struct dsa_port *dp)
......
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