Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753653AbdHORbe (ORCPT ); Tue, 15 Aug 2017 13:31:34 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:37917 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752167AbdHORbc (ORCPT ); Tue, 15 Aug 2017 13:31:32 -0400 Subject: Re: [PATCH net-next 04/11] net: dsa: debugfs: add tag_protocol To: Vivien Didelot , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com, "David S. Miller" , Andrew Lunn , Egil Hjelmeland , John Crispin , Woojung Huh , Sean Wang , Volodymyr Bendiuga , Nikita Yushchenko , Maxime Hadjinlian , Chris Healy , Maxim Uvarov , Stefan Eichenberger , Jason Cobham , Juergen Borleis , Tobias Waldekranz References: <20170814222242.10643-1-vivien.didelot@savoirfairelinux.com> <20170814222242.10643-5-vivien.didelot@savoirfairelinux.com> From: Florian Fainelli Message-ID: <43f9f204-a3aa-a194-90d8-1f8a42fdd83d@gmail.com> Date: Tue, 15 Aug 2017 10:31:30 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170814222242.10643-5-vivien.didelot@savoirfairelinux.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1338 Lines: 45 On 08/14/2017 03:22 PM, Vivien Didelot wrote: > Add a debug filesystem "tag_protocol" entry to query the switch tagging > protocol through the .get_tag_protocol operation. > > # cat switch1/tag_protocol > EDSA > > Signed-off-by: Vivien Didelot > --- > net/dsa/debugfs.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > > diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c > index 5607efdb924d..30a732e86161 100644 > --- a/net/dsa/debugfs.c > +++ b/net/dsa/debugfs.c > @@ -109,6 +109,55 @@ static int dsa_debugfs_create_file(struct dsa_switch *ds, struct dentry *dir, > return 0; > } > > +static int dsa_debugfs_tag_protocol_read(struct dsa_switch *ds, int id, > + struct seq_file *seq) > +{ > + enum dsa_tag_protocol proto; > + > + if (!ds->ops->get_tag_protocol) > + return -EOPNOTSUPP; > + > + proto = ds->ops->get_tag_protocol(ds); > + > + switch (proto) { > + case DSA_TAG_PROTO_NONE: > + seq_puts(seq, "NONE\n"); Might be worth adding a helper function: does dsa_tag_protocol_to_str() which is in include/net/dsa.h so it's easy to keep in sync when new taggers are added, then you can just do: seq_puts(seq, dsa_tag_protocol_to_str(proto)); and/or use a temporary buffer for adding the trailing newline. -- Florian