[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87h8zrmwde.fsf@weeman.i-did-not-set--mail-host-address--so-tickle-me>
Date: Wed, 07 Jun 2017 15:27:25 -0400
From: Vivien Didelot <vivien.didelot@...oirfairelinux.com>
To: Florian Fainelli <f.fainelli@...il.com>
Cc: netdev <netdev@...r.kernel.org>, Andrew Lunn <andrew@...n.ch>,
John Crispin <john@...ozen.org>,
David Miller <davem@...emloft.net>
Subject: Re: [PATCH net-next v2 5/5] net: dsa: Stop accessing ds->dst->cpu_dp in drivers
Florian Fainelli <f.fainelli@...il.com> writes:
> On 06/07/2017 10:15 AM, Vivien Didelot wrote:
>> Hi Florian,
>>
>> Florian Fainelli <f.fainelli@...il.com> writes:
>>
>>>> So as I said in v2, now that a driver is guaranteed that dp->cpu_dp is
>>>> correctly assigned at setup time, isn't better (especially for future
>>>> multi-CPU support) to provide an helper which returns the CPU port for a
>>>> given port? i.e. dsa_get_cpu_port(struct dsa_switch *ds, int port).
>>>>
>>>> Or is there something blocking? I might be wrong.
>>>
>>> mt7530.c needs access to the CPU port at ops->setup() time which is
>>> why this is still here.
>>
>> Yes, mt7530 is the only one doing this and has an hardcoded CPU port. So
>> what I meant was, shouldn't we have this instead:
>>
>> struct dsa_port *dsa_get_cpu_port(struct dsa_switch *ds, int port)
>> {
>> return ds->ports[port].cpu_dp;
>> }
>
> We don't actually have a CPU port point to itself:
>
> +
> + for (i = 0; i < ds->num_ports; i++) {
> + p = &ds->ports[i];
> + if (!dsa_port_is_valid(p) ||
> + i == index) <=============
> + continue;
> +
> + p->cpu_dp = port;
> + }
> }
>
>>
>> And:
>>
>> - dn = ds->dst->cpu_dp->netdev->dev.of_node->parent;
>> + cpu_dp = dsa_get_cpu_port(ds, MT7530_CPU_PORT);
>> + dn = cpu_dp->netdev->dev.of_node->parent;
>
> If we are giving the port number to get its cpu_dp pointer back, that
> seems a bit pointless.
>
> I still think the helper with fls(ds->cpu_port_mask) - 1 is better in
> that it will return what you have configured from Device Tree/platform
> data. MT7530 does allow the CPU port being arbitrary, and it would
> disable MTK tags in that case.
OK looks good then!
Powered by blists - more mailing lists