2019-10-20 03:21:01

by Vivien Didelot

[permalink] [raw]
Subject: [PATCH net-next 08/16] net: dsa: use ports list to setup multiple master devices

Now that we have a potential list of CPU ports, make use of it instead
of only configuring the master device of an unique CPU port.

Signed-off-by: Vivien Didelot <[email protected]>
---
net/dsa/dsa2.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 8b038cc56769..3b8de155bc0b 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -501,19 +501,27 @@ static void dsa_tree_teardown_switches(struct dsa_switch_tree *dst)

static int dsa_tree_setup_master(struct dsa_switch_tree *dst)
{
- struct dsa_port *cpu_dp = dst->cpu_dp;
- struct net_device *master = cpu_dp->master;
+ struct dsa_port *dp;
+ int err;

- /* DSA currently supports a single pair of CPU port and master device */
- return dsa_master_setup(master, cpu_dp);
+ list_for_each_entry(dp, &dst->ports, list) {
+ if (dsa_port_is_cpu(dp)) {
+ err = dsa_master_setup(dp->master, dp);
+ if (err)
+ return err;
+ }
+ }
+
+ return 0;
}

static void dsa_tree_teardown_master(struct dsa_switch_tree *dst)
{
- struct dsa_port *cpu_dp = dst->cpu_dp;
- struct net_device *master = cpu_dp->master;
+ struct dsa_port *dp;

- return dsa_master_teardown(master);
+ list_for_each_entry(dp, &dst->ports, list)
+ if (dsa_port_is_cpu(dp))
+ dsa_master_teardown(dp->master);
}

static int dsa_tree_setup(struct dsa_switch_tree *dst)
--
2.23.0


2019-10-21 03:04:29

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH net-next 08/16] net: dsa: use ports list to setup multiple master devices



On 10/19/2019 8:19 PM, Vivien Didelot wrote:
> Now that we have a potential list of CPU ports, make use of it instead
> of only configuring the master device of an unique CPU port.

Out of your series, this is the only one that has possible side effects
to existing set-up in that if you had multiple CPU ports defined, today,
we would stop at the first one, whereas now, we will set them all up. I
believe this is right way to do it, but have not had time to fire up a
test on a BCM7278 w/ bcm_sf2 and this patch series to confirm that, will
do that first thing tomorrow morning.

Great stuff, thanks!
--
Florian

2019-10-21 14:18:09

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH net-next 08/16] net: dsa: use ports list to setup multiple master devices

On Sun, Oct 20, 2019 at 08:03:34PM -0700, Florian Fainelli wrote:
>
>
> On 10/19/2019 8:19 PM, Vivien Didelot wrote:
> > Now that we have a potential list of CPU ports, make use of it instead
> > of only configuring the master device of an unique CPU port.
>
> Out of your series, this is the only one that has possible side effects
> to existing set-up in that if you had multiple CPU ports defined, today,
> we would stop at the first one, whereas now, we will set them all up. I
> believe this is right way to do it, but have not had time to fire up a
> test on a BCM7278 w/ bcm_sf2 and this patch series to confirm that, will
> do that first thing tomorrow morning.

Hi Florian

The next patch might also change things, finding the first CPU port.
Is the order of the link list the same as searching the port array?

Andrew