Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1712389

Re: [PATCH net-next 04/11] net: dsa: debugfs: add tag_protocol

From Florian Fainelli <f.fainelli@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH net-next 04/11] net: dsa: debugfs: add tag_protocol
Date 2017-08-15 19:40 +0200
Message-ID <ueNYS-4hU-31@gated-at.bofh.it> (permalink)
References <uew1Y-1pG-9@gated-at.bofh.it> <uew1Y-1pG-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



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 <vivien.didelot@savoirfairelinux.com>
> ---
>  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

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH net-next 04/11] net: dsa: debugfs: add tag_protocol Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-15 00:30 +0200
  Re: [PATCH net-next 04/11] net: dsa: debugfs: add tag_protocol Andrew Lunn <andrew@lunn.ch> - 2017-08-15 00:50 +0200
  Re: [PATCH net-next 04/11] net: dsa: debugfs: add tag_protocol Florian Fainelli <f.fainelli@gmail.com> - 2017-08-15 19:40 +0200

csiph-web