public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: netdev <netdev@vger.kernel.org>, David <davem@davemloft.net>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Guenter Roeck <linux@roeck-us.net>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	kernel <kernel@savoirfairelinux.com>
Subject: Re: [PATCH 2/3] net: dsa: mv88e6xxx: add support to dump VLANs
Date: Fri, 26 Jun 2015 10:36:01 -0400 (EDT)	[thread overview]
Message-ID: <1696086829.305314.1435329361028.JavaMail.zimbra@savoirfairelinux.com> (raw)
In-Reply-To: <20150626141025.GC9469@lunn.ch>

Hi Andrew,

On Jun 26, 2015, at 10:10 AM, Andrew Lunn andrew@lunn.ch wrote:

> On Tue, Jun 23, 2015 at 05:46:09PM -0400, Vivien Didelot wrote:
>> This commit implements the port_vlan_dump function in the
>> dsa_switch_driver structure for Marvell 88E6xxx compatible switches.
>> 
>> This allows to access a switch VLAN Table Unit from standard userspace
>> commands such as "bridge vlan show".
>> 
>> A populated VTU can give the following output:
>> 
>>     # bridge vlan
>>     port	vlan ids
>>     swp0	None
>>     swp0
>>     swp1	None
>>     swp1
>>     swp2	1000
>> 		1200
>> 
>>     swp2	1000
>> 		1200
>> 
>>     swp3	550 PVID Egress Untagged
>> 
>>     swp3	550 PVID Egress Untagged
>> 
>>     swp4	1200
>> 
>>     swp4	1200
>> 
>>     br0	None
>> 
>> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
>> ---
>>  drivers/net/dsa/mv88e6xxx.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>>  drivers/net/dsa/mv88e6xxx.h |  2 ++
>>  2 files changed, 46 insertions(+)
>> 
>> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
>> index 0dce8e8..0d63bf6 100644
>> --- a/drivers/net/dsa/mv88e6xxx.c
>> +++ b/drivers/net/dsa/mv88e6xxx.c
>> @@ -1441,6 +1441,50 @@ static int _mv88e6xxx_vtu_getnext(struct dsa_switch *ds,
>> u16 vid,
>>  	return 0;
>>  }
>>  
>> +int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port, u16 vid,
>> +			     u16 *bridge_flags)
>> +{
>> +	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
>> +	struct mv88e6xxx_vtu_entry entry = { 0 };
>> +	int prev_vid = vid ? vid - 1 : 4095;
>> +	int ret;
>> +
>> +	mutex_lock(&ps->smi_mutex);
>> +	ret = _mv88e6xxx_vtu_getnext(ds, prev_vid, &entry);
>> +	if (ret < 0)
>> +		goto unlock;
>> +
>> +	if (entry.vid != vid || !entry.valid) {
>> +		ret = -ENOENT;
>> +		goto unlock;
>> +	}
>> +
>> +	switch (entry.tags[port]) {
>> +	case GLOBAL_VTU_DATA_MEMBER_TAG_UNTAGGED:
>> +		*bridge_flags |= BRIDGE_VLAN_INFO_UNTAGGED;
>> +		/* fall through... */
>> +	case GLOBAL_VTU_DATA_MEMBER_TAG_TAGGED:
>> +		break;
> 
> A nit pick, but fall through catches people out. Having a fall through
> to a break statements seems like a trap for future coders to fall
> into. I would replace the comment with a break, and let the compiler
> do the optimisation.
> 
>    Andrew

Done.

Thanks,
-v

  reply	other threads:[~2015-06-26 14:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-23 21:46 [PATCH 0/3] net: dsa: mv88e6xxx: dump hardware VLANs Vivien Didelot
2015-06-23 21:46 ` [PATCH 1/3] net: dsa: mv88e6xxx: add debugfs interface for VTU Vivien Didelot
2015-06-26 14:04   ` Andrew Lunn
2015-06-26 15:04     ` Vivien Didelot
2015-06-26 15:23       ` Andrew Lunn
2015-06-26 15:42         ` Vivien Didelot
2015-06-23 21:46 ` [PATCH 2/3] net: dsa: mv88e6xxx: add support to dump VLANs Vivien Didelot
2015-06-26 14:10   ` Andrew Lunn
2015-06-26 14:36     ` Vivien Didelot [this message]
2015-06-23 21:46 ` [PATCH 3/3] net: dsa: mv88e6352: add support for port_vlan_dump Vivien Didelot
2015-06-24  9:22   ` David Miller
2015-06-26 14:12   ` Andrew Lunn
2015-06-26 14:33     ` Vivien Didelot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1696086829.305314.1435329361028.JavaMail.zimbra@savoirfairelinux.com \
    --to=vivien.didelot@savoirfairelinux.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kernel@savoirfairelinux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox