All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: linville@tuxdriver.com,
	Nicholas Nunley <nicholas.d.nunley@intel.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH v3 3/6] ethtool: introduce new ioctl for per-queue settings
Date: Fri, 1 Mar 2019 15:18:29 +0100	[thread overview]
Message-ID: <20190301141829.GI29992@unicorn.suse.cz> (raw)
In-Reply-To: <20190301081532.11771-3-jeffrey.t.kirsher@intel.com>

On Fri, Mar 01, 2019 at 12:15:29AM -0800, Jeff Kirsher wrote:
> From: Nicholas Nunley <nicholas.d.nunley@intel.com>
> 
> Introduce a new ioctl for applying per-queue parameters.
> Users can apply commands to specific queues by setting SUB_COMMAND and
> queue_mask with the following ethtool command:
> 
>  ethtool -Q|--per-queue DEVNAME [queue_mask %x] SUB_COMMAND
> 
> If queue_mask is not set, the SUB_COMMAND will be applied to all queues.
> 
> SUB_COMMANDs for per-queue settings will be implemented in following
> patches.
> 
> Based on patch by Kan Liang <kan.liang@intel.com>
> 
> Signed-off-by: Nicholas Nunley <nicholas.d.nunley@intel.com>
> ---

Reviewed-by: Michal Kubecek <mkubecek@suse.cz>

> diff --git a/ethtool.c b/ethtool.c
> index d9850f4..5f72741 100644
> --- a/ethtool.c
> +++ b/ethtool.c
> @@ -5051,6 +5051,8 @@ static int do_sfec(struct cmd_context *ctx)
>  	return 0;
>  }
>  
> +static int do_perqueue(struct cmd_context *ctx);
> +
>  #ifndef TEST_ETHTOOL
>  int send_ioctl(struct cmd_context *ctx, void *cmd)
>  {
> @@ -5246,6 +5248,8 @@ static const struct option {
>  	{ "--show-fec", 1, do_gfec, "Show FEC settings"},
>  	{ "--set-fec", 1, do_sfec, "Set FEC settings",
>  	  "		[ encoding auto|off|rs|baser [...]]\n"},
> +	{ "-Q|--per-queue", 1, do_perqueue, "Apply per-queue command",
> +	  "             [queue_mask %x] SUB_COMMAND\n"},
>  	{ "-h|--help", 0, show_usage, "Show this help" },
>  	{ "--version", 0, do_version, "Show version number" },
>  	{}
> @@ -5297,6 +5301,77 @@ static int find_option(int argc, char **argp)
>  	return -1;
>  }
>  
> +#define MAX(x, y) (x > y ? x : y)

The unparenthesised macro arguments give me goosebumps but I couldn't
come with an example where it would be wrong (without using assignment
operators in the arguments which would be bad idea on its own).

> +
> +static int find_max_num_queues(struct cmd_context *ctx)
> +{
> +	struct ethtool_channels echannels;
> +
> +	echannels.cmd = ETHTOOL_GCHANNELS;
> +	if (send_ioctl(ctx, &echannels))
> +		return -1;
> +
> +	return MAX(echannels.rx_count, echannels.tx_count) +
> +		echannels.combined_count;
> +}
> +
> +static int do_perqueue(struct cmd_context *ctx)
> +{
> +	__u32 queue_mask[__KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32)] = {0};
> +	int i, n_queues = 0;
> +
> +	if (ctx->argc == 0)
> +		exit_bad_args();
> +
> +	/*
> +	 * The sub commands will be applied to
> +	 * all queues if no queue_mask set
> +	 */
> +	if (strncmp(*ctx->argp, "queue_mask", 11)) {
> +		n_queues = find_max_num_queues(ctx);
> +		if (n_queues < 0) {
> +			perror("Cannot get number of queues");
> +			return -EFAULT;
> +		} else if (n_queues > MAX_NUM_QUEUE) {
> +			n_queues = MAX_NUM_QUEUE;
> +		}

Perhaps a warning should issued in such case (theoretical right now and
in near future) to tell user the settings are only a subset of queues
will be used.

Michal Kubecek

  reply	other threads:[~2019-03-01 14:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-01  8:15 [PATCH v3 1/6] ethtool: move option parsing related code into function Jeff Kirsher
2019-03-01  8:15 ` [PATCH v3 2/6] ethtool: move cmdline_coalesce out of do_scoalesce Jeff Kirsher
2019-03-01 13:50   ` Michal Kubecek
2019-03-01  8:15 ` [PATCH v3 3/6] ethtool: introduce new ioctl for per-queue settings Jeff Kirsher
2019-03-01 14:18   ` Michal Kubecek [this message]
2019-03-01 23:35     ` Nunley, Nicholas D
2019-03-01  8:15 ` [PATCH v3 4/6] ethtool: support per-queue sub command --show-coalesce Jeff Kirsher
2019-03-01 14:26   ` Michal Kubecek
2019-03-01  8:15 ` [PATCH v3 5/6] ethtool: support per-queue sub command --coalesce Jeff Kirsher
2019-03-01 14:28   ` Michal Kubecek
2019-03-01  8:15 ` [PATCH v3 6/6] ethtool: fix up dump_coalesce output to match actual option names Jeff Kirsher
2019-03-01 14:38   ` Michal Kubecek
2019-03-01 13:42 ` [PATCH v3 1/6] ethtool: move option parsing related code into function Michal Kubecek
2019-03-14 18:37 ` John W. Linville

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=20190301141829.GI29992@unicorn.suse.cz \
    --to=mkubecek@suse.cz \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=linville@tuxdriver.com \
    --cc=netdev@vger.kernel.org \
    --cc=nicholas.d.nunley@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.