Subject: Re: [patch net-next RFC 04/12] dsa: set devlink port attrs for dsa ports

From: Jiri Pirko <[email-masked]>
Date: Fri, 23 Mar 2018 15:49:14 +0100

Fri, Mar 23, 2018 at 02:30:02PM CET, [email-masked] wrote:
>On Thu, Mar 22, 2018 at 11:55:14AM +0100, Jiri Pirko wrote:
>> From: Jiri Pirko <[email-masked]>
>> 
>> Set the attrs and allow to expose port flavour to user via devlink.
>> 
>> Signed-off-by: Jiri Pirko <[email-masked]>
>> ---
>>  net/dsa/dsa2.c | 23 +++++++++++++++++++++++
>>  1 file changed, 23 insertions(+)
>> 
>> diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
>> index adf50fbc4c13..49453690696d 100644
>> --- a/net/dsa/dsa2.c
>> +++ b/net/dsa/dsa2.c
>> @@ -270,7 +270,27 @@ static int dsa_port_setup(struct dsa_port *dp)
>>  	case DSA_PORT_TYPE_UNUSED:
>>  		break;
>>  	case DSA_PORT_TYPE_CPU:
>> +		/* dp->index is used now as port_number. However
>> +		 * CPU ports should have separate numbering
>> +		 * independent from front panel port numbers.
>> +		 */
>> +		devlink_port_attrs_set(&dp->devlink_port,
>> +				       DEVLINK_PORT_FLAVOUR_CPU,
>> +				       dp->index, false, 0);
>> +		err = dsa_port_link_register_of(dp);
>> +		if (err) {
>> +			dev_err(ds->dev, "failed to setup link for port %d.%d\n",
>> +				ds->index, dp->index);
>> +			return err;
>> +		}
>
>Ah, i get it. These used to be two case statements with one code
>block. But you split them apart, so needed to duplicate the
>dsa_port_link_register.
>
>Unfortunately, you forgot to add a 'break;', so it still falls
>through, and overwrites the port flavour to DSA.

ah, crap. Don't have hw to test this :/
Will fix. Thanks!

>
>>  	case DSA_PORT_TYPE_DSA:
>> +		/* dp->index is used now as port_number. However
>> +		 * DSA ports should have separate numbering
>> +		 * independent from front panel port numbers.
>> +		 */
>> +		devlink_port_attrs_set(&dp->devlink_port,
>> +				       DEVLINK_PORT_FLAVOUR_DSA,
>> +				       dp->index, false, 0);
>
>  Andrew