From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: linville@tuxdriver.com
Cc: Nicholas Nunley <nicholas.d.nunley@intel.com>,
netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [PATCH v2 4/6] ethtool: support per-queue sub command --show-coalesce
Date: Tue, 5 Feb 2019 16:01:04 -0800 [thread overview]
Message-ID: <20190206000106.24364-4-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <20190206000106.24364-1-jeffrey.t.kirsher@intel.com>
From: Nicholas Nunley <nicholas.d.nunley@intel.com>
Get all masked queues' coalesce settings from kernel and dump them one by
one.
Example:
$ sudo ./ethtool --set-perqueue-command eth5 queue_mask 0x11
--show-coalesce
Queue: 0
Adaptive RX: off TX: off
stats-block-usecs: 0
sample-interval: 0
pkt-rate-low: 0
pkt-rate-high: 0
rx-usecs: 222
rx-frames: 0
rx-usecs-irq: 0
rx-frames-irq: 256
tx-usecs: 222
tx-frames: 0
tx-usecs-irq: 0
tx-frames-irq: 256
rx-usecs-low: 0
rx-frame-low: 0
tx-usecs-low: 0
tx-frame-low: 0
rx-usecs-high: 0
rx-frame-high: 0
tx-usecs-high: 0
tx-frame-high: 0
Queue: 4
Adaptive RX: off TX: off
stats-block-usecs: 0
sample-interval: 0
pkt-rate-low: 0
pkt-rate-high: 0
rx-usecs: 222
rx-frames: 0
rx-usecs-irq: 0
rx-frames-irq: 256
tx-usecs: 222
tx-frames: 0
tx-usecs-irq: 0
tx-frames-irq: 256
rx-usecs-low: 0
rx-frame-low: 0
tx-usecs-low: 0
tx-frame-low: 0
rx-usecs-high: 0
rx-frame-high: 0
tx-usecs-high: 0
tx-frame-high: 0
Based on patch by Kan Liang <kan.liang@intel.com>
Signed-off-by: Nicholas Nunley <nicholas.d.nunley@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
ethtool.8.in | 2 +-
ethtool.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 63 insertions(+), 3 deletions(-)
diff --git a/ethtool.8.in b/ethtool.8.in
index 0aaca2c..71bb962 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -1153,7 +1153,7 @@ Sets the specific queues which the sub command is applied to.
If queue_mask is not set, the sub command will be applied to all queues.
.TP
.B sub_command
-Sets the sub command.
+Sets the sub command. The supported sub commands include --show-coalesce.
.RE
.SH BUGS
Not supported (in part or whole) on all network drivers.
diff --git a/ethtool.c b/ethtool.c
index 4dc725c..9a1b83b 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -1409,6 +1409,29 @@ static int dump_coalesce(const struct ethtool_coalesce *ecoal)
return 0;
}
+void dump_per_queue_coalesce(struct ethtool_per_queue_op *per_queue_opt,
+ __u32 *queue_mask)
+{
+ char *addr;
+ int i;
+
+ addr = (char *)per_queue_opt + sizeof(*per_queue_opt);
+ for (i = 0; i < __KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32); i++) {
+ int queue = i * 32;
+ __u32 mask = queue_mask[i];
+
+ while (mask > 0) {
+ if (mask & 0x1) {
+ fprintf(stdout, "Queue: %d\n", queue);
+ dump_coalesce((struct ethtool_coalesce *)addr);
+ addr += sizeof(struct ethtool_coalesce);
+ }
+ mask = mask >> 1;
+ queue++;
+ }
+ }
+}
+
struct feature_state {
u32 off_flags;
struct ethtool_gfeatures features;
@@ -5245,7 +5268,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"},
- { "--set-perqueue-command", 1, do_perqueue, "Set per queue command",
+ { "--set-perqueue-command", 1, do_perqueue, "Set per queue command. "
+ "The supported sub commands include --show-coalesce",
" [queue_mask %x] SUB_COMMAND\n"},
{ "-h|--help", 0, show_usage, "Show this help" },
{ "--version", 0, do_version, "Show version number" },
@@ -5350,8 +5374,32 @@ static int find_max_num_queues(struct cmd_context *ctx)
echannels.combined_count);
}
+static struct ethtool_per_queue_op *
+get_per_queue_coalesce(struct cmd_context *ctx, __u32 *queue_mask, int n_queues)
+{
+ struct ethtool_per_queue_op *per_queue_opt;
+
+ per_queue_opt = malloc(sizeof(*per_queue_opt) + n_queues *
+ sizeof(struct ethtool_coalesce));
+ if (!per_queue_opt)
+ return NULL;
+
+ memcpy(per_queue_opt->queue_mask, queue_mask,
+ __KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32) * sizeof(__u32));
+ per_queue_opt->cmd = ETHTOOL_PERQUEUE;
+ per_queue_opt->sub_command = ETHTOOL_GCOALESCE;
+ if (send_ioctl(ctx, per_queue_opt)) {
+ free(per_queue_opt);
+ perror("Cannot get device per queue parameters");
+ return NULL;
+ }
+
+ return per_queue_opt;
+}
+
static int do_perqueue(struct cmd_context *ctx)
{
+ struct ethtool_per_queue_op *per_queue_opt;
__u32 queue_mask[__KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32)] = {0};
int i, n_queues = 0;
@@ -5390,7 +5438,19 @@ static int do_perqueue(struct cmd_context *ctx)
if (i < 0)
exit_bad_args();
- /* no sub_command support yet */
+ if (strstr(args[i].opts, "--show-coalesce") != NULL) {
+ per_queue_opt = get_per_queue_coalesce(ctx, queue_mask,
+ n_queues);
+ if (per_queue_opt == NULL) {
+ perror("Cannot get device per queue parameters");
+ return -EFAULT;
+ }
+ dump_per_queue_coalesce(per_queue_opt, queue_mask);
+ free(per_queue_opt);
+ } else {
+ perror("The subcommand is not supported yet");
+ return -EOPNOTSUPP;
+ }
return 0;
}
--
2.20.1
next prev parent reply other threads:[~2019-02-06 0:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-06 0:01 [PATCH v2 1/6] ethtool: move option parsing related code into function Jeff Kirsher
2019-02-06 0:01 ` [PATCH v2 2/6] ethtool: move cmdline_coalesce out of do_scoalesce Jeff Kirsher
2019-02-06 0:01 ` [PATCH v2 3/6] ethtool: introduce new ioctl for per-queue settings Jeff Kirsher
2019-02-06 9:18 ` Michal Kubecek
2019-02-07 23:37 ` Nunley, Nicholas D
2019-02-08 7:02 ` Michal Kubecek
2019-02-08 13:56 ` Willem de Bruijn
2019-02-06 10:32 ` Michal Kubecek
2019-02-07 23:41 ` Nunley, Nicholas D
2019-02-06 12:43 ` Michal Kubecek
2019-02-07 23:43 ` Nunley, Nicholas D
2019-02-06 0:01 ` Jeff Kirsher [this message]
2019-02-06 13:22 ` [PATCH v2 4/6] ethtool: support per-queue sub command --show-coalesce Michal Kubecek
2019-02-07 23:53 ` Nunley, Nicholas D
2019-02-08 7:10 ` Michal Kubecek
2019-02-06 0:01 ` [PATCH v2 5/6] ethtool: support per-queue sub command --coalesce Jeff Kirsher
2019-02-06 0:01 ` [PATCH v2 6/6] ethtool: fix up dump_coalesce output to match actual option names Jeff Kirsher
2019-02-06 9:56 ` [PATCH v2 1/6] ethtool: move option parsing related code into function Michal Kubecek
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=20190206000106.24364-4-jeffrey.t.kirsher@intel.com \
--to=jeffrey.t.kirsher@intel.com \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@redhat.com \
--cc=nicholas.d.nunley@intel.com \
--cc=sassmann@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox