netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: Edward Cree <ecree@solarflare.com>
Cc: "John W. Linville" <linville@tuxdriver.com>,
	netdev <netdev@vger.kernel.org>,
	Ganesh Goudar <ganeshgr@chelsio.com>,
	Jakub Kicinski <jakub.kicinski@netronome.com>,
	Dustin Byford <dustin@cumulusnetworks.com>,
	Dirk van der Merwe <dirk.vandermerwe@netronome.com>
Subject: Re: [PATCH ethtool] ethtool: support combinations of FEC modes
Date: Wed, 19 Sep 2018 16:41:17 +0200	[thread overview]
Message-ID: <20180919144117.GF3876@unicorn.suse.cz> (raw)
In-Reply-To: <518b8b8b-0151-1053-3798-6009044ed53a@solarflare.com>

On Wed, Sep 05, 2018 at 06:54:57PM +0100, Edward Cree wrote:
> Of the three drivers that currently support FEC configuration, two (sfc
>  and cxgb4[vf]) accept configurations with more than one bit set in the
>  feccmd.fec bitmask.  (The precise semantics of these combinations vary.)
> Thus, this patch adds the ability to specify such combinations through a
>  comma-separated list of FEC modes in the 'encoding' argument on the
>  command line.
> 
> Also adds --set-fec tests to test-cmdline.c, and corrects the man page
>  (the encoding argument is not optional) while updating it.
> 
> Signed-off-by: Edward Cree <ecree@solarflare.com>
...
> +/* Takes a comma-separated list of FEC modes, returns the bitwise OR of their
> + * corresponding ETHTOOL_FEC_* constants.
> + * Accepts repetitions (e.g. 'auto,auto') and trailing comma (e.g. 'off,').
> + */
> +static int parse_fecmode(const char *str)
> +{
>  	int fecmode = 0;
> +	char buf[6];
>  
>  	if (!str)
> -		return fecmode;
> -
> -	if (!strcasecmp(str, "auto"))
> -		fecmode |= ETHTOOL_FEC_AUTO;
> -	else if (!strcasecmp(str, "off"))
> -		fecmode |= ETHTOOL_FEC_OFF;
> -	else if (!strcasecmp(str, "rs"))
> -		fecmode |= ETHTOOL_FEC_RS;
> -	else if (!strcasecmp(str, "baser"))
> -		fecmode |= ETHTOOL_FEC_BASER;
> +		return 0;
> +	while (*str) {
> +		size_t next;
> +		int mode;
>  
> +		next = strcspn(str, ",");
> +		if (next >= 6) /* Bad mode, longest name is 5 chars */
> +			return 0;
> +		/* Copy into temp buffer and nul-terminate */
> +		memcpy(buf, str, next);
> +		buf[next] = 0;
> +		mode = fecmode_str_to_type(buf);
> +		if (!mode) /* Bad mode encountered */
> +			return 0;
> +		fecmode |= mode;
> +		str += next;
> +		/* Skip over ',' (but not nul) */
> +		if (*str)
> +			str++;
> +	}
>  	return fecmode;
>  }
>  

I'm sorry I didn't notice this before the patch was accepted but as it's
not in a release yet, maybe it's still not too late.

Could I suggest to make the syntax consistent with other options? I mean 
rather than a comma separated list to use either

  ethtool --set-fec <dev> encoding enc1 enc2 ...

(as we have for --reset) or

  ethtool --set-fec <dev> encoding enc1 on|off enc2 on|off ...

(as we have e.g. for msglvl, -K or --set-eee)?

Second option seems more appropriate to me but it would require special
handling of the case when there is only one argument after "encoding" to
maintain backward compatibility with already released versions.

One loosely related question: how sure can we be that we are never going
to need more than 32 bits for FEC encodings? Is it something completely
hypothetical or is it something that could happen in the future?

Michal Kubecek

  parent reply	other threads:[~2018-09-19 20:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05 17:54 [PATCH ethtool] ethtool: support combinations of FEC modes Edward Cree
2018-09-17 19:52 ` John W. Linville
2018-09-19 14:41 ` Michal Kubecek [this message]
2018-09-19 15:33   ` Andrew Lunn
2018-09-19 15:49     ` Michal Kubecek
2018-09-19 15:38   ` Edward Cree
2018-09-19 15:56     ` Michal Kubecek
2018-09-19 16:06   ` [RFC PATCH ethtool] ethtool: better syntax for " Edward Cree
2018-09-20 13:46     ` Michal Kubecek
2018-10-01 18:59     ` John W. Linville
2018-10-04 14:08       ` John W. Linville
2018-10-04 14:43         ` Michal Kubecek
2018-10-04 16:06         ` Edward Cree
2018-10-04 19:41           ` John W. Linville
     [not found] ` <811cf92b-51ed-4a8f-4b69-113cdd8473df@mellanox.com>
2018-09-26  8:47   ` [PATCH ethtool] ethtool: support " Ariel Almog
2018-09-28 12:58     ` Edward Cree
2018-09-28 15:39       ` Andrew Lunn
2018-09-28 16:11         ` Edward Cree
2018-09-28 16:45           ` Andrew Lunn
2018-09-28 17:30             ` Edward Cree

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=20180919144117.GF3876@unicorn.suse.cz \
    --to=mkubecek@suse.cz \
    --cc=dirk.vandermerwe@netronome.com \
    --cc=dustin@cumulusnetworks.com \
    --cc=ecree@solarflare.com \
    --cc=ganeshgr@chelsio.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=linville@tuxdriver.com \
    --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;
as well as URLs for NNTP newsgroup(s).