* [PATCH 1/5] ethtool: move option parsing related codes into function @ 2016-05-15 7:14 kan.liang 2016-05-15 7:14 ` [PATCH 2/5] ethtool: move cmdline_coalesce out of do_scoalesce kan.liang ` (3 more replies) 0 siblings, 4 replies; 7+ messages in thread From: kan.liang @ 2016-05-15 7:14 UTC (permalink / raw) To: bwh; +Cc: netdev, davem, nicolas.dichtel, ben, jesse.brandeburg, andi, Kan Liang From: Kan Liang <kan.liang@intel.com> Move option parsing code into find_option function. No behavior changes. Signed-off-by: Kan Liang <kan.liang@intel.com> --- ethtool.c | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/ethtool.c b/ethtool.c index 0cd0d4f..bd0583c 100644 --- a/ethtool.c +++ b/ethtool.c @@ -4223,6 +4223,29 @@ static int show_usage(struct cmd_context *ctx) return 0; } +static int find_option(int argc, char **argp) +{ + const char *opt; + size_t len; + int k; + + for (k = 0; args[k].opts; k++) { + opt = args[k].opts; + for (;;) { + len = strcspn(opt, "|"); + if (strncmp(*argp, opt, len) == 0 && + (*argp)[len] == 0) + return k; + + if (opt[len] == 0) + break; + opt += len + 1; + } + } + + return -1; +} + int main(int argc, char **argp) { int (*func)(struct cmd_context *); @@ -4240,24 +4263,14 @@ int main(int argc, char **argp) */ if (argc == 0) exit_bad_args(); - for (k = 0; args[k].opts; k++) { - const char *opt; - size_t len; - opt = args[k].opts; - for (;;) { - len = strcspn(opt, "|"); - if (strncmp(*argp, opt, len) == 0 && - (*argp)[len] == 0) { - argp++; - argc--; - func = args[k].func; - want_device = args[k].want_device; - goto opt_found; - } - if (opt[len] == 0) - break; - opt += len + 1; - } + + k = find_option(argc, argp); + if (k > 0) { + argp++; + argc--; + func = args[k].func; + want_device = args[k].want_device; + goto opt_found; } if ((*argp)[0] == '-') exit_bad_args(); -- 2.5.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] ethtool: move cmdline_coalesce out of do_scoalesce 2016-05-15 7:14 [PATCH 1/5] ethtool: move option parsing related codes into function kan.liang @ 2016-05-15 7:14 ` kan.liang 2016-06-26 15:05 ` Ben Hutchings 2016-05-15 7:14 ` [PATCH 3/5] ethtool: introduce new ioctl for per queue setting kan.liang ` (2 subsequent siblings) 3 siblings, 1 reply; 7+ messages in thread From: kan.liang @ 2016-05-15 7:14 UTC (permalink / raw) To: bwh; +Cc: netdev, davem, nicolas.dichtel, ben, jesse.brandeburg, andi, Kan Liang From: Kan Liang <kan.liang@intel.com> Moving cmdline_coalesce out of do_scoalesce, so it can be shared with other functions. No behavior change. Signed-off-by: Kan Liang <kan.liang@intel.com> --- ethtool.c | 147 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 74 insertions(+), 73 deletions(-) diff --git a/ethtool.c b/ethtool.c index bd0583c..86724a2 100644 --- a/ethtool.c +++ b/ethtool.c @@ -1883,85 +1883,86 @@ static int do_gcoalesce(struct cmd_context *ctx) return 0; } +static struct ethtool_coalesce s_ecoal; +static s32 coal_stats_wanted = -1; +static int coal_adaptive_rx_wanted = -1; +static int coal_adaptive_tx_wanted = -1; +static s32 coal_sample_rate_wanted = -1; +static s32 coal_pkt_rate_low_wanted = -1; +static s32 coal_pkt_rate_high_wanted = -1; +static s32 coal_rx_usec_wanted = -1; +static s32 coal_rx_frames_wanted = -1; +static s32 coal_rx_usec_irq_wanted = -1; +static s32 coal_rx_frames_irq_wanted = -1; +static s32 coal_tx_usec_wanted = -1; +static s32 coal_tx_frames_wanted = -1; +static s32 coal_tx_usec_irq_wanted = -1; +static s32 coal_tx_frames_irq_wanted = -1; +static s32 coal_rx_usec_low_wanted = -1; +static s32 coal_rx_frames_low_wanted = -1; +static s32 coal_tx_usec_low_wanted = -1; +static s32 coal_tx_frames_low_wanted = -1; +static s32 coal_rx_usec_high_wanted = -1; +static s32 coal_rx_frames_high_wanted = -1; +static s32 coal_tx_usec_high_wanted = -1; +static s32 coal_tx_frames_high_wanted = -1; + +static struct cmdline_info cmdline_coalesce[] = { + { "adaptive-rx", CMDL_BOOL, &coal_adaptive_rx_wanted, + &s_ecoal.use_adaptive_rx_coalesce }, + { "adaptive-tx", CMDL_BOOL, &coal_adaptive_tx_wanted, + &s_ecoal.use_adaptive_tx_coalesce }, + { "sample-interval", CMDL_S32, &coal_sample_rate_wanted, + &s_ecoal.rate_sample_interval }, + { "stats-block-usecs", CMDL_S32, &coal_stats_wanted, + &s_ecoal.stats_block_coalesce_usecs }, + { "pkt-rate-low", CMDL_S32, &coal_pkt_rate_low_wanted, + &s_ecoal.pkt_rate_low }, + { "pkt-rate-high", CMDL_S32, &coal_pkt_rate_high_wanted, + &s_ecoal.pkt_rate_high }, + { "rx-usecs", CMDL_S32, &coal_rx_usec_wanted, + &s_ecoal.rx_coalesce_usecs }, + { "rx-frames", CMDL_S32, &coal_rx_frames_wanted, + &s_ecoal.rx_max_coalesced_frames }, + { "rx-usecs-irq", CMDL_S32, &coal_rx_usec_irq_wanted, + &s_ecoal.rx_coalesce_usecs_irq }, + { "rx-frames-irq", CMDL_S32, &coal_rx_frames_irq_wanted, + &s_ecoal.rx_max_coalesced_frames_irq }, + { "tx-usecs", CMDL_S32, &coal_tx_usec_wanted, + &s_ecoal.tx_coalesce_usecs }, + { "tx-frames", CMDL_S32, &coal_tx_frames_wanted, + &s_ecoal.tx_max_coalesced_frames }, + { "tx-usecs-irq", CMDL_S32, &coal_tx_usec_irq_wanted, + &s_ecoal.tx_coalesce_usecs_irq }, + { "tx-frames-irq", CMDL_S32, &coal_tx_frames_irq_wanted, + &s_ecoal.tx_max_coalesced_frames_irq }, + { "rx-usecs-low", CMDL_S32, &coal_rx_usec_low_wanted, + &s_ecoal.rx_coalesce_usecs_low }, + { "rx-frames-low", CMDL_S32, &coal_rx_frames_low_wanted, + &s_ecoal.rx_max_coalesced_frames_low }, + { "tx-usecs-low", CMDL_S32, &coal_tx_usec_low_wanted, + &s_ecoal.tx_coalesce_usecs_low }, + { "tx-frames-low", CMDL_S32, &coal_tx_frames_low_wanted, + &s_ecoal.tx_max_coalesced_frames_low }, + { "rx-usecs-high", CMDL_S32, &coal_rx_usec_high_wanted, + &s_ecoal.rx_coalesce_usecs_high }, + { "rx-frames-high", CMDL_S32, &coal_rx_frames_high_wanted, + &s_ecoal.rx_max_coalesced_frames_high }, + { "tx-usecs-high", CMDL_S32, &coal_tx_usec_high_wanted, + &s_ecoal.tx_coalesce_usecs_high }, + { "tx-frames-high", CMDL_S32, &coal_tx_frames_high_wanted, + &s_ecoal.tx_max_coalesced_frames_high }, +}; static int do_scoalesce(struct cmd_context *ctx) { - struct ethtool_coalesce ecoal; int gcoalesce_changed = 0; - s32 coal_stats_wanted = -1; - int coal_adaptive_rx_wanted = -1; - int coal_adaptive_tx_wanted = -1; - s32 coal_sample_rate_wanted = -1; - s32 coal_pkt_rate_low_wanted = -1; - s32 coal_pkt_rate_high_wanted = -1; - s32 coal_rx_usec_wanted = -1; - s32 coal_rx_frames_wanted = -1; - s32 coal_rx_usec_irq_wanted = -1; - s32 coal_rx_frames_irq_wanted = -1; - s32 coal_tx_usec_wanted = -1; - s32 coal_tx_frames_wanted = -1; - s32 coal_tx_usec_irq_wanted = -1; - s32 coal_tx_frames_irq_wanted = -1; - s32 coal_rx_usec_low_wanted = -1; - s32 coal_rx_frames_low_wanted = -1; - s32 coal_tx_usec_low_wanted = -1; - s32 coal_tx_frames_low_wanted = -1; - s32 coal_rx_usec_high_wanted = -1; - s32 coal_rx_frames_high_wanted = -1; - s32 coal_tx_usec_high_wanted = -1; - s32 coal_tx_frames_high_wanted = -1; - struct cmdline_info cmdline_coalesce[] = { - { "adaptive-rx", CMDL_BOOL, &coal_adaptive_rx_wanted, - &ecoal.use_adaptive_rx_coalesce }, - { "adaptive-tx", CMDL_BOOL, &coal_adaptive_tx_wanted, - &ecoal.use_adaptive_tx_coalesce }, - { "sample-interval", CMDL_S32, &coal_sample_rate_wanted, - &ecoal.rate_sample_interval }, - { "stats-block-usecs", CMDL_S32, &coal_stats_wanted, - &ecoal.stats_block_coalesce_usecs }, - { "pkt-rate-low", CMDL_S32, &coal_pkt_rate_low_wanted, - &ecoal.pkt_rate_low }, - { "pkt-rate-high", CMDL_S32, &coal_pkt_rate_high_wanted, - &ecoal.pkt_rate_high }, - { "rx-usecs", CMDL_S32, &coal_rx_usec_wanted, - &ecoal.rx_coalesce_usecs }, - { "rx-frames", CMDL_S32, &coal_rx_frames_wanted, - &ecoal.rx_max_coalesced_frames }, - { "rx-usecs-irq", CMDL_S32, &coal_rx_usec_irq_wanted, - &ecoal.rx_coalesce_usecs_irq }, - { "rx-frames-irq", CMDL_S32, &coal_rx_frames_irq_wanted, - &ecoal.rx_max_coalesced_frames_irq }, - { "tx-usecs", CMDL_S32, &coal_tx_usec_wanted, - &ecoal.tx_coalesce_usecs }, - { "tx-frames", CMDL_S32, &coal_tx_frames_wanted, - &ecoal.tx_max_coalesced_frames }, - { "tx-usecs-irq", CMDL_S32, &coal_tx_usec_irq_wanted, - &ecoal.tx_coalesce_usecs_irq }, - { "tx-frames-irq", CMDL_S32, &coal_tx_frames_irq_wanted, - &ecoal.tx_max_coalesced_frames_irq }, - { "rx-usecs-low", CMDL_S32, &coal_rx_usec_low_wanted, - &ecoal.rx_coalesce_usecs_low }, - { "rx-frames-low", CMDL_S32, &coal_rx_frames_low_wanted, - &ecoal.rx_max_coalesced_frames_low }, - { "tx-usecs-low", CMDL_S32, &coal_tx_usec_low_wanted, - &ecoal.tx_coalesce_usecs_low }, - { "tx-frames-low", CMDL_S32, &coal_tx_frames_low_wanted, - &ecoal.tx_max_coalesced_frames_low }, - { "rx-usecs-high", CMDL_S32, &coal_rx_usec_high_wanted, - &ecoal.rx_coalesce_usecs_high }, - { "rx-frames-high", CMDL_S32, &coal_rx_frames_high_wanted, - &ecoal.rx_max_coalesced_frames_high }, - { "tx-usecs-high", CMDL_S32, &coal_tx_usec_high_wanted, - &ecoal.tx_coalesce_usecs_high }, - { "tx-frames-high", CMDL_S32, &coal_tx_frames_high_wanted, - &ecoal.tx_max_coalesced_frames_high }, - }; int err, changed = 0; parse_generic_cmdline(ctx, &gcoalesce_changed, cmdline_coalesce, ARRAY_SIZE(cmdline_coalesce)); - ecoal.cmd = ETHTOOL_GCOALESCE; - err = send_ioctl(ctx, &ecoal); + s_ecoal.cmd = ETHTOOL_GCOALESCE; + err = send_ioctl(ctx, &s_ecoal); if (err) { perror("Cannot get device coalesce settings"); return 76; @@ -1975,8 +1976,8 @@ static int do_scoalesce(struct cmd_context *ctx) return 80; } - ecoal.cmd = ETHTOOL_SCOALESCE; - err = send_ioctl(ctx, &ecoal); + s_ecoal.cmd = ETHTOOL_SCOALESCE; + err = send_ioctl(ctx, &s_ecoal); if (err) { perror("Cannot set device coalesce parameters"); return 81; -- 2.5.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/5] ethtool: move cmdline_coalesce out of do_scoalesce 2016-05-15 7:14 ` [PATCH 2/5] ethtool: move cmdline_coalesce out of do_scoalesce kan.liang @ 2016-06-26 15:05 ` Ben Hutchings 0 siblings, 0 replies; 7+ messages in thread From: Ben Hutchings @ 2016-06-26 15:05 UTC (permalink / raw) To: kan.liang, bwh; +Cc: netdev, davem, nicolas.dichtel, jesse.brandeburg, andi [-- Attachment #1: Type: text/plain, Size: 8412 bytes --] On Sun, 2016-05-15 at 00:14 -0700, kan.liang@intel.com wrote: > From: Kan Liang <kan.liang@intel.com> > > Moving cmdline_coalesce out of do_scoalesce, so it can be shared with > other functions. > No behavior change. I spent some time getting rid of static variables, and I think the only ones left are (at least logically) constant. I won't accept a change that reverses this. There's really no need to pass information around this way. Ben. > Signed-off-by: Kan Liang <kan.liang@intel.com> > --- > ethtool.c | 147 +++++++++++++++++++++++++++++++------------------------------- > 1 file changed, 74 insertions(+), 73 deletions(-) > > diff --git a/ethtool.c b/ethtool.c > index bd0583c..86724a2 100644 > --- a/ethtool.c > +++ b/ethtool.c > @@ -1883,85 +1883,86 @@ static int do_gcoalesce(struct cmd_context *ctx) > return 0; > } > > +static struct ethtool_coalesce s_ecoal; > +static s32 coal_stats_wanted = -1; > +static int coal_adaptive_rx_wanted = -1; > +static int coal_adaptive_tx_wanted = -1; > +static s32 coal_sample_rate_wanted = -1; > +static s32 coal_pkt_rate_low_wanted = -1; > +static s32 coal_pkt_rate_high_wanted = -1; > +static s32 coal_rx_usec_wanted = -1; > +static s32 coal_rx_frames_wanted = -1; > +static s32 coal_rx_usec_irq_wanted = -1; > +static s32 coal_rx_frames_irq_wanted = -1; > +static s32 coal_tx_usec_wanted = -1; > +static s32 coal_tx_frames_wanted = -1; > +static s32 coal_tx_usec_irq_wanted = -1; > +static s32 coal_tx_frames_irq_wanted = -1; > +static s32 coal_rx_usec_low_wanted = -1; > +static s32 coal_rx_frames_low_wanted = -1; > +static s32 coal_tx_usec_low_wanted = -1; > +static s32 coal_tx_frames_low_wanted = -1; > +static s32 coal_rx_usec_high_wanted = -1; > +static s32 coal_rx_frames_high_wanted = -1; > +static s32 coal_tx_usec_high_wanted = -1; > +static s32 coal_tx_frames_high_wanted = -1; > + > +static struct cmdline_info cmdline_coalesce[] = { > + { "adaptive-rx", CMDL_BOOL, &coal_adaptive_rx_wanted, > + &s_ecoal.use_adaptive_rx_coalesce }, > + { "adaptive-tx", CMDL_BOOL, &coal_adaptive_tx_wanted, > + &s_ecoal.use_adaptive_tx_coalesce }, > + { "sample-interval", CMDL_S32, &coal_sample_rate_wanted, > + &s_ecoal.rate_sample_interval }, > + { "stats-block-usecs", CMDL_S32, &coal_stats_wanted, > + &s_ecoal.stats_block_coalesce_usecs }, > + { "pkt-rate-low", CMDL_S32, &coal_pkt_rate_low_wanted, > + &s_ecoal.pkt_rate_low }, > + { "pkt-rate-high", CMDL_S32, &coal_pkt_rate_high_wanted, > + &s_ecoal.pkt_rate_high }, > + { "rx-usecs", CMDL_S32, &coal_rx_usec_wanted, > + &s_ecoal.rx_coalesce_usecs }, > + { "rx-frames", CMDL_S32, &coal_rx_frames_wanted, > + &s_ecoal.rx_max_coalesced_frames }, > + { "rx-usecs-irq", CMDL_S32, &coal_rx_usec_irq_wanted, > + &s_ecoal.rx_coalesce_usecs_irq }, > + { "rx-frames-irq", CMDL_S32, &coal_rx_frames_irq_wanted, > + &s_ecoal.rx_max_coalesced_frames_irq }, > + { "tx-usecs", CMDL_S32, &coal_tx_usec_wanted, > + &s_ecoal.tx_coalesce_usecs }, > + { "tx-frames", CMDL_S32, &coal_tx_frames_wanted, > + &s_ecoal.tx_max_coalesced_frames }, > + { "tx-usecs-irq", CMDL_S32, &coal_tx_usec_irq_wanted, > + &s_ecoal.tx_coalesce_usecs_irq }, > + { "tx-frames-irq", CMDL_S32, &coal_tx_frames_irq_wanted, > + &s_ecoal.tx_max_coalesced_frames_irq }, > + { "rx-usecs-low", CMDL_S32, &coal_rx_usec_low_wanted, > + &s_ecoal.rx_coalesce_usecs_low }, > + { "rx-frames-low", CMDL_S32, &coal_rx_frames_low_wanted, > + &s_ecoal.rx_max_coalesced_frames_low }, > + { "tx-usecs-low", CMDL_S32, &coal_tx_usec_low_wanted, > + &s_ecoal.tx_coalesce_usecs_low }, > + { "tx-frames-low", CMDL_S32, &coal_tx_frames_low_wanted, > + &s_ecoal.tx_max_coalesced_frames_low }, > + { "rx-usecs-high", CMDL_S32, &coal_rx_usec_high_wanted, > + &s_ecoal.rx_coalesce_usecs_high }, > + { "rx-frames-high", CMDL_S32, &coal_rx_frames_high_wanted, > + &s_ecoal.rx_max_coalesced_frames_high }, > + { "tx-usecs-high", CMDL_S32, &coal_tx_usec_high_wanted, > + &s_ecoal.tx_coalesce_usecs_high }, > + { "tx-frames-high", CMDL_S32, &coal_tx_frames_high_wanted, > + &s_ecoal.tx_max_coalesced_frames_high }, > +}; > static int do_scoalesce(struct cmd_context *ctx) > { > - struct ethtool_coalesce ecoal; > int gcoalesce_changed = 0; > - s32 coal_stats_wanted = -1; > - int coal_adaptive_rx_wanted = -1; > - int coal_adaptive_tx_wanted = -1; > - s32 coal_sample_rate_wanted = -1; > - s32 coal_pkt_rate_low_wanted = -1; > - s32 coal_pkt_rate_high_wanted = -1; > - s32 coal_rx_usec_wanted = -1; > - s32 coal_rx_frames_wanted = -1; > - s32 coal_rx_usec_irq_wanted = -1; > - s32 coal_rx_frames_irq_wanted = -1; > - s32 coal_tx_usec_wanted = -1; > - s32 coal_tx_frames_wanted = -1; > - s32 coal_tx_usec_irq_wanted = -1; > - s32 coal_tx_frames_irq_wanted = -1; > - s32 coal_rx_usec_low_wanted = -1; > - s32 coal_rx_frames_low_wanted = -1; > - s32 coal_tx_usec_low_wanted = -1; > - s32 coal_tx_frames_low_wanted = -1; > - s32 coal_rx_usec_high_wanted = -1; > - s32 coal_rx_frames_high_wanted = -1; > - s32 coal_tx_usec_high_wanted = -1; > - s32 coal_tx_frames_high_wanted = -1; > - struct cmdline_info cmdline_coalesce[] = { > - { "adaptive-rx", CMDL_BOOL, &coal_adaptive_rx_wanted, > - &ecoal.use_adaptive_rx_coalesce }, > - { "adaptive-tx", CMDL_BOOL, &coal_adaptive_tx_wanted, > - &ecoal.use_adaptive_tx_coalesce }, > - { "sample-interval", CMDL_S32, &coal_sample_rate_wanted, > - &ecoal.rate_sample_interval }, > - { "stats-block-usecs", CMDL_S32, &coal_stats_wanted, > - &ecoal.stats_block_coalesce_usecs }, > - { "pkt-rate-low", CMDL_S32, &coal_pkt_rate_low_wanted, > - &ecoal.pkt_rate_low }, > - { "pkt-rate-high", CMDL_S32, &coal_pkt_rate_high_wanted, > - &ecoal.pkt_rate_high }, > - { "rx-usecs", CMDL_S32, &coal_rx_usec_wanted, > - &ecoal.rx_coalesce_usecs }, > - { "rx-frames", CMDL_S32, &coal_rx_frames_wanted, > - &ecoal.rx_max_coalesced_frames }, > - { "rx-usecs-irq", CMDL_S32, &coal_rx_usec_irq_wanted, > - &ecoal.rx_coalesce_usecs_irq }, > - { "rx-frames-irq", CMDL_S32, &coal_rx_frames_irq_wanted, > - &ecoal.rx_max_coalesced_frames_irq }, > - { "tx-usecs", CMDL_S32, &coal_tx_usec_wanted, > - &ecoal.tx_coalesce_usecs }, > - { "tx-frames", CMDL_S32, &coal_tx_frames_wanted, > - &ecoal.tx_max_coalesced_frames }, > - { "tx-usecs-irq", CMDL_S32, &coal_tx_usec_irq_wanted, > - &ecoal.tx_coalesce_usecs_irq }, > - { "tx-frames-irq", CMDL_S32, &coal_tx_frames_irq_wanted, > - &ecoal.tx_max_coalesced_frames_irq }, > - { "rx-usecs-low", CMDL_S32, &coal_rx_usec_low_wanted, > - &ecoal.rx_coalesce_usecs_low }, > - { "rx-frames-low", CMDL_S32, &coal_rx_frames_low_wanted, > - &ecoal.rx_max_coalesced_frames_low }, > - { "tx-usecs-low", CMDL_S32, &coal_tx_usec_low_wanted, > - &ecoal.tx_coalesce_usecs_low }, > - { "tx-frames-low", CMDL_S32, &coal_tx_frames_low_wanted, > - &ecoal.tx_max_coalesced_frames_low }, > - { "rx-usecs-high", CMDL_S32, &coal_rx_usec_high_wanted, > - &ecoal.rx_coalesce_usecs_high }, > - { "rx-frames-high", CMDL_S32, &coal_rx_frames_high_wanted, > - &ecoal.rx_max_coalesced_frames_high }, > - { "tx-usecs-high", CMDL_S32, &coal_tx_usec_high_wanted, > - &ecoal.tx_coalesce_usecs_high }, > - { "tx-frames-high", CMDL_S32, &coal_tx_frames_high_wanted, > - &ecoal.tx_max_coalesced_frames_high }, > - }; > int err, changed = 0; > > parse_generic_cmdline(ctx, &gcoalesce_changed, > cmdline_coalesce, ARRAY_SIZE(cmdline_coalesce)); > > - ecoal.cmd = ETHTOOL_GCOALESCE; > - err = send_ioctl(ctx, &ecoal); > + s_ecoal.cmd = ETHTOOL_GCOALESCE; > + err = send_ioctl(ctx, &s_ecoal); > if (err) { > perror("Cannot get device coalesce settings"); > return 76; > @@ -1975,8 +1976,8 @@ static int do_scoalesce(struct cmd_context *ctx) > return 80; > } > > - ecoal.cmd = ETHTOOL_SCOALESCE; > - err = send_ioctl(ctx, &ecoal); > + s_ecoal.cmd = ETHTOOL_SCOALESCE; > + err = send_ioctl(ctx, &s_ecoal); > if (err) { > perror("Cannot set device coalesce parameters"); > return 81; -- Ben Hutchings compatible: Gracefully accepts erroneous data from any source [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/5] ethtool: introduce new ioctl for per queue setting 2016-05-15 7:14 [PATCH 1/5] ethtool: move option parsing related codes into function kan.liang 2016-05-15 7:14 ` [PATCH 2/5] ethtool: move cmdline_coalesce out of do_scoalesce kan.liang @ 2016-05-15 7:14 ` kan.liang 2016-05-15 7:14 ` [PATCH 4/5] ethtool: support per queue sub command --show-coalesce kan.liang 2016-05-15 7:14 ` [PATCH 5/5] ethtool: support per queue sub command --coalesce kan.liang 3 siblings, 0 replies; 7+ messages in thread From: kan.liang @ 2016-05-15 7:14 UTC (permalink / raw) To: bwh; +Cc: netdev, davem, nicolas.dichtel, ben, jesse.brandeburg, andi, Kan Liang From: Kan Liang <kan.liang@intel.com> Introduce a new ioctl for per queue parameters setting. Users can apply commands to specific queues by setting SUB_COMMAND and queue_mask as following command. ethtool --set-perqueue-command DEVNAME [queue_mask %x] SUB_COMMAND If queue_mask is not set, the SUB_COMMAND will be applied to all queues. The following patches will enable SUB_COMMANDs for per queue setting. Signed-off-by: Kan Liang <kan.liang@intel.com> --- ethtool.8.in | 19 ++++++++++++ ethtool.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) diff --git a/ethtool.8.in b/ethtool.8.in index 009711d..26d01cb 100644 --- a/ethtool.8.in +++ b/ethtool.8.in @@ -339,6 +339,13 @@ ethtool \- query or control network driver and hardware settings .B2 tx-lpi on off .BN tx-timer .BN advertise +.HP +.B ethtool \-\-set\-perqueue\-command +.I devname +.RB [ queue_mask +.IR %x ] +.I sub_command +.RB ... . .\" Adjust lines (i.e. full justification) and hyphenate. .ad @@ -920,6 +927,18 @@ Values are as for Sets the amount of time the device should stay in idle mode prior to asserting its Tx LPI (in microseconds). This has meaning only when Tx LPI is enabled. .RE +.TP +.B \-\-set\-perqueue\-command +Sets sub command to specific queues. +.RS 4 +.TP +.B queue_mask %x +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. +.RE .SH BUGS Not supported (in part or whole) on all network drivers. .SH AUTHOR diff --git a/ethtool.c b/ethtool.c index 86724a2..ba741f0 100644 --- a/ethtool.c +++ b/ethtool.c @@ -4037,6 +4037,8 @@ static int do_seee(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) { @@ -4196,6 +4198,8 @@ static const struct option { " [ advertise %x ]\n" " [ tx-lpi on|off ]\n" " [ tx-timer %d ]\n"}, + { "--set-perqueue-command", 1, do_perqueue, "Set per queue command", + " [queue_mask %x] SUB_COMMAND\n"}, { "-h|--help", 0, show_usage, "Show this help" }, { "--version", 0, do_version, "Show version number" }, {} @@ -4247,6 +4251,102 @@ static int find_option(int argc, char **argp) return -1; } +static int set_queue_mask(u32 *queue_mask, char *str) +{ + int len = strlen(str); + int index = __KERNEL_DIV_ROUND_UP(len * 4, 32); + char tmp[9]; + char *end = str + len; + int i, num; + __u32 mask; + int n_queues = 0; + + if (len > MAX_NUM_QUEUE) + return -EINVAL; + + for (i = 0; i < index; i++) { + num = end - str; + + if (num >= 8) { + end -= 8; + num = 8; + } else { + end = str; + } + strncpy(tmp, end, num); + tmp[num] = '\0'; + + queue_mask[i] = strtoul(tmp, NULL, 16); + + mask = queue_mask[i]; + while (mask > 0) { + if (mask & 0x1) + n_queues++; + mask = mask >> 1; + } + } + + return n_queues; +} + +#define MAX(x, y) (x > y ? x : y) + +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(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", 10)) { + n_queues = find_max_num_queues(ctx); + if (n_queues < 0) { + perror("Cannot get number of queues"); + return -EFAULT; + } + for (i = 0; i < n_queues / 32; i++) + queue_mask[i] = ~0; + queue_mask[i] = (1 << (n_queues - i * 32)) - 1; + fprintf(stdout, "The sub commands will be applied" + " to all %d queues\n", n_queues); + } else { + ctx->argc--; + ctx->argp++; + n_queues = set_queue_mask(queue_mask, *ctx->argp); + if (n_queues < 0) { + perror("Invalid queue mask"); + return n_queues; + } + ctx->argc--; + ctx->argp++; + + } + + i = find_option(ctx->argc, ctx->argp); + if (i < 0) + exit_bad_args(); + + /* no sub_command support yet */ + + return 0; +} + int main(int argc, char **argp) { int (*func)(struct cmd_context *); -- 2.5.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] ethtool: support per queue sub command --show-coalesce 2016-05-15 7:14 [PATCH 1/5] ethtool: move option parsing related codes into function kan.liang 2016-05-15 7:14 ` [PATCH 2/5] ethtool: move cmdline_coalesce out of do_scoalesce kan.liang 2016-05-15 7:14 ` [PATCH 3/5] ethtool: introduce new ioctl for per queue setting kan.liang @ 2016-05-15 7:14 ` kan.liang 2016-05-15 7:14 ` [PATCH 5/5] ethtool: support per queue sub command --coalesce kan.liang 3 siblings, 0 replies; 7+ messages in thread From: kan.liang @ 2016-05-15 7:14 UTC (permalink / raw) To: bwh; +Cc: netdev, davem, nicolas.dichtel, ben, jesse.brandeburg, andi, Kan Liang From: Kan Liang <kan.liang@intel.com> Get all masked queues' coalesce 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 Signed-off-by: Kan Liang <kan.liang@intel.com> --- ethtool.8.in | 2 +- ethtool.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/ethtool.8.in b/ethtool.8.in index 26d01cb..210ec8c 100644 --- a/ethtool.8.in +++ b/ethtool.8.in @@ -937,7 +937,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 ba741f0..a966bf8 100644 --- a/ethtool.c +++ b/ethtool.c @@ -1219,6 +1219,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; @@ -4198,7 +4221,8 @@ static const struct option { " [ advertise %x ]\n" " [ tx-lpi on|off ]\n" " [ tx-timer %d ]\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" }, @@ -4302,8 +4326,31 @@ static int find_max_num_queues(struct cmd_context *ctx) return MAX(MAX(echannels.rx_count, echannels.tx_count), 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; @@ -4342,7 +4389,18 @@ 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.5.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] ethtool: support per queue sub command --coalesce 2016-05-15 7:14 [PATCH 1/5] ethtool: move option parsing related codes into function kan.liang ` (2 preceding siblings ...) 2016-05-15 7:14 ` [PATCH 4/5] ethtool: support per queue sub command --show-coalesce kan.liang @ 2016-05-15 7:14 ` kan.liang 3 siblings, 0 replies; 7+ messages in thread From: kan.liang @ 2016-05-15 7:14 UTC (permalink / raw) To: bwh; +Cc: netdev, davem, nicolas.dichtel, ben, jesse.brandeburg, andi, Kan Liang From: Kan Liang <kan.liang@intel.com> This patch uses a similar way as do_scoalesce to set coalesce per queue. It reads the current settings, change them, and write them back to the kernel for each masked queue. Example: $ sudo ./ethtool --set-perqueue-command eth5 queue_mask 0x1 --coalesce rx-usecs 10 tx-usecs 5 $ sudo ./ethtool --set-perqueue-command eth5 queue_mask 0x1 --show-coalesce Queue: 0 Adaptive RX: on TX: on stats-block-usecs: 0 sample-interval: 0 pkt-rate-low: 0 pkt-rate-high: 0 rx-usecs: 10 rx-frames: 0 rx-usecs-irq: 0 rx-frames-irq: 256 tx-usecs: 5 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 Signed-off-by: Kan Liang <kan.liang@intel.com> --- ethtool.8.in | 2 +- ethtool.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/ethtool.8.in b/ethtool.8.in index 210ec8c..0e42180 100644 --- a/ethtool.8.in +++ b/ethtool.8.in @@ -937,7 +937,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. The supported sub commands include --show-coalesce. +Sets the sub command. The supported sub commands include --show-coalesce and --coalesce. .RE .SH BUGS Not supported (in part or whole) on all network drivers. diff --git a/ethtool.c b/ethtool.c index a966bf8..55ba26c 100644 --- a/ethtool.c +++ b/ethtool.c @@ -4222,7 +4222,7 @@ static const struct option { " [ tx-lpi on|off ]\n" " [ tx-timer %d ]\n"}, { "--set-perqueue-command", 1, do_perqueue, "Set per queue command. " - "The supported sub commands include --show-coalesce", + "The supported sub commands include --show-coalesce, --coalesce", " [queue_mask %x] SUB_COMMAND\n"}, { "-h|--help", 0, show_usage, "Show this help" }, { "--version", 0, do_version, "Show version number" }, @@ -4348,6 +4348,52 @@ get_per_queue_coalesce(struct cmd_context *ctx, return per_queue_opt; } +static void __set_per_queue_coalesce(int queue) +{ + int changed = 0; + + do_generic_set(cmdline_coalesce, ARRAY_SIZE(cmdline_coalesce), + &changed); + + if (!changed) + fprintf(stderr, "Queue %d, no coalesce parameters changed\n", queue); +} + +static void set_per_queue_coalesce(struct cmd_context *ctx, + struct ethtool_per_queue_op *per_queue_opt) +{ + __u32 *queue_mask = per_queue_opt->queue_mask; + char *addr = (char *)per_queue_opt + sizeof(*per_queue_opt); + int gcoalesce_changed = 0; + int i; + + parse_generic_cmdline(ctx, &gcoalesce_changed, + cmdline_coalesce, ARRAY_SIZE(cmdline_coalesce)); + + 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) { + memcpy(&s_ecoal, addr, sizeof(struct ethtool_coalesce)); + __set_per_queue_coalesce(queue); + memcpy(addr, &s_ecoal, sizeof(struct ethtool_coalesce)); + addr += sizeof(struct ethtool_coalesce); + } + mask = mask >> 1; + queue++; + } + } + + per_queue_opt->cmd = ETHTOOL_PERQUEUE; + per_queue_opt->sub_command = ETHTOOL_SCOALESCE; + + if (send_ioctl(ctx, per_queue_opt)) + perror("Cannot set device per queue parameters"); + +} + static int do_perqueue(struct cmd_context *ctx) { struct ethtool_per_queue_op *per_queue_opt; @@ -4397,6 +4443,16 @@ static int do_perqueue(struct cmd_context *ctx) } dump_per_queue_coalesce(per_queue_opt, queue_mask); free(per_queue_opt); + } else if (strstr(args[i].opts, "--coalesce") != NULL) { + ctx->argc--; + ctx->argp++; + 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; + } + set_per_queue_coalesce(ctx, per_queue_opt); + free(per_queue_opt); } else { perror("The subcommand is not supported yet"); return -EOPNOTSUPP; -- 2.5.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 1/5] ethtool: move option parsing related codes into function @ 2016-03-14 9:30 kan.liang 2016-03-14 9:30 ` [PATCH 2/5] ethtool: move cmdline_coalesce out of do_scoalesce kan.liang 0 siblings, 1 reply; 7+ messages in thread From: kan.liang @ 2016-03-14 9:30 UTC (permalink / raw) To: bwh; +Cc: davem, nicolas.dichtel, ben, jesse.brandeburg, andi, netdev, Kan Liang From: Kan Liang <kan.liang@intel.com> Move option parsing code into find_option function. No behavior changes. Signed-off-by: Kan Liang <kan.liang@intel.com> --- ethtool.c | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/ethtool.c b/ethtool.c index 0cd0d4f..bd0583c 100644 --- a/ethtool.c +++ b/ethtool.c @@ -4223,6 +4223,29 @@ static int show_usage(struct cmd_context *ctx) return 0; } +static int find_option(int argc, char **argp) +{ + const char *opt; + size_t len; + int k; + + for (k = 0; args[k].opts; k++) { + opt = args[k].opts; + for (;;) { + len = strcspn(opt, "|"); + if (strncmp(*argp, opt, len) == 0 && + (*argp)[len] == 0) + return k; + + if (opt[len] == 0) + break; + opt += len + 1; + } + } + + return -1; +} + int main(int argc, char **argp) { int (*func)(struct cmd_context *); @@ -4240,24 +4263,14 @@ int main(int argc, char **argp) */ if (argc == 0) exit_bad_args(); - for (k = 0; args[k].opts; k++) { - const char *opt; - size_t len; - opt = args[k].opts; - for (;;) { - len = strcspn(opt, "|"); - if (strncmp(*argp, opt, len) == 0 && - (*argp)[len] == 0) { - argp++; - argc--; - func = args[k].func; - want_device = args[k].want_device; - goto opt_found; - } - if (opt[len] == 0) - break; - opt += len + 1; - } + + k = find_option(argc, argp); + if (k > 0) { + argp++; + argc--; + func = args[k].func; + want_device = args[k].want_device; + goto opt_found; } if ((*argp)[0] == '-') exit_bad_args(); -- 2.5.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] ethtool: move cmdline_coalesce out of do_scoalesce 2016-03-14 9:30 [PATCH 1/5] ethtool: move option parsing related codes into function kan.liang @ 2016-03-14 9:30 ` kan.liang 0 siblings, 0 replies; 7+ messages in thread From: kan.liang @ 2016-03-14 9:30 UTC (permalink / raw) To: bwh; +Cc: davem, nicolas.dichtel, ben, jesse.brandeburg, andi, netdev, Kan Liang From: Kan Liang <kan.liang@intel.com> Moving cmdline_coalesce out of do_scoalesce, so it can be shared with other functions. No behavior change. Signed-off-by: Kan Liang <kan.liang@intel.com> --- ethtool.c | 147 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 74 insertions(+), 73 deletions(-) diff --git a/ethtool.c b/ethtool.c index bd0583c..86724a2 100644 --- a/ethtool.c +++ b/ethtool.c @@ -1883,85 +1883,86 @@ static int do_gcoalesce(struct cmd_context *ctx) return 0; } +static struct ethtool_coalesce s_ecoal; +static s32 coal_stats_wanted = -1; +static int coal_adaptive_rx_wanted = -1; +static int coal_adaptive_tx_wanted = -1; +static s32 coal_sample_rate_wanted = -1; +static s32 coal_pkt_rate_low_wanted = -1; +static s32 coal_pkt_rate_high_wanted = -1; +static s32 coal_rx_usec_wanted = -1; +static s32 coal_rx_frames_wanted = -1; +static s32 coal_rx_usec_irq_wanted = -1; +static s32 coal_rx_frames_irq_wanted = -1; +static s32 coal_tx_usec_wanted = -1; +static s32 coal_tx_frames_wanted = -1; +static s32 coal_tx_usec_irq_wanted = -1; +static s32 coal_tx_frames_irq_wanted = -1; +static s32 coal_rx_usec_low_wanted = -1; +static s32 coal_rx_frames_low_wanted = -1; +static s32 coal_tx_usec_low_wanted = -1; +static s32 coal_tx_frames_low_wanted = -1; +static s32 coal_rx_usec_high_wanted = -1; +static s32 coal_rx_frames_high_wanted = -1; +static s32 coal_tx_usec_high_wanted = -1; +static s32 coal_tx_frames_high_wanted = -1; + +static struct cmdline_info cmdline_coalesce[] = { + { "adaptive-rx", CMDL_BOOL, &coal_adaptive_rx_wanted, + &s_ecoal.use_adaptive_rx_coalesce }, + { "adaptive-tx", CMDL_BOOL, &coal_adaptive_tx_wanted, + &s_ecoal.use_adaptive_tx_coalesce }, + { "sample-interval", CMDL_S32, &coal_sample_rate_wanted, + &s_ecoal.rate_sample_interval }, + { "stats-block-usecs", CMDL_S32, &coal_stats_wanted, + &s_ecoal.stats_block_coalesce_usecs }, + { "pkt-rate-low", CMDL_S32, &coal_pkt_rate_low_wanted, + &s_ecoal.pkt_rate_low }, + { "pkt-rate-high", CMDL_S32, &coal_pkt_rate_high_wanted, + &s_ecoal.pkt_rate_high }, + { "rx-usecs", CMDL_S32, &coal_rx_usec_wanted, + &s_ecoal.rx_coalesce_usecs }, + { "rx-frames", CMDL_S32, &coal_rx_frames_wanted, + &s_ecoal.rx_max_coalesced_frames }, + { "rx-usecs-irq", CMDL_S32, &coal_rx_usec_irq_wanted, + &s_ecoal.rx_coalesce_usecs_irq }, + { "rx-frames-irq", CMDL_S32, &coal_rx_frames_irq_wanted, + &s_ecoal.rx_max_coalesced_frames_irq }, + { "tx-usecs", CMDL_S32, &coal_tx_usec_wanted, + &s_ecoal.tx_coalesce_usecs }, + { "tx-frames", CMDL_S32, &coal_tx_frames_wanted, + &s_ecoal.tx_max_coalesced_frames }, + { "tx-usecs-irq", CMDL_S32, &coal_tx_usec_irq_wanted, + &s_ecoal.tx_coalesce_usecs_irq }, + { "tx-frames-irq", CMDL_S32, &coal_tx_frames_irq_wanted, + &s_ecoal.tx_max_coalesced_frames_irq }, + { "rx-usecs-low", CMDL_S32, &coal_rx_usec_low_wanted, + &s_ecoal.rx_coalesce_usecs_low }, + { "rx-frames-low", CMDL_S32, &coal_rx_frames_low_wanted, + &s_ecoal.rx_max_coalesced_frames_low }, + { "tx-usecs-low", CMDL_S32, &coal_tx_usec_low_wanted, + &s_ecoal.tx_coalesce_usecs_low }, + { "tx-frames-low", CMDL_S32, &coal_tx_frames_low_wanted, + &s_ecoal.tx_max_coalesced_frames_low }, + { "rx-usecs-high", CMDL_S32, &coal_rx_usec_high_wanted, + &s_ecoal.rx_coalesce_usecs_high }, + { "rx-frames-high", CMDL_S32, &coal_rx_frames_high_wanted, + &s_ecoal.rx_max_coalesced_frames_high }, + { "tx-usecs-high", CMDL_S32, &coal_tx_usec_high_wanted, + &s_ecoal.tx_coalesce_usecs_high }, + { "tx-frames-high", CMDL_S32, &coal_tx_frames_high_wanted, + &s_ecoal.tx_max_coalesced_frames_high }, +}; static int do_scoalesce(struct cmd_context *ctx) { - struct ethtool_coalesce ecoal; int gcoalesce_changed = 0; - s32 coal_stats_wanted = -1; - int coal_adaptive_rx_wanted = -1; - int coal_adaptive_tx_wanted = -1; - s32 coal_sample_rate_wanted = -1; - s32 coal_pkt_rate_low_wanted = -1; - s32 coal_pkt_rate_high_wanted = -1; - s32 coal_rx_usec_wanted = -1; - s32 coal_rx_frames_wanted = -1; - s32 coal_rx_usec_irq_wanted = -1; - s32 coal_rx_frames_irq_wanted = -1; - s32 coal_tx_usec_wanted = -1; - s32 coal_tx_frames_wanted = -1; - s32 coal_tx_usec_irq_wanted = -1; - s32 coal_tx_frames_irq_wanted = -1; - s32 coal_rx_usec_low_wanted = -1; - s32 coal_rx_frames_low_wanted = -1; - s32 coal_tx_usec_low_wanted = -1; - s32 coal_tx_frames_low_wanted = -1; - s32 coal_rx_usec_high_wanted = -1; - s32 coal_rx_frames_high_wanted = -1; - s32 coal_tx_usec_high_wanted = -1; - s32 coal_tx_frames_high_wanted = -1; - struct cmdline_info cmdline_coalesce[] = { - { "adaptive-rx", CMDL_BOOL, &coal_adaptive_rx_wanted, - &ecoal.use_adaptive_rx_coalesce }, - { "adaptive-tx", CMDL_BOOL, &coal_adaptive_tx_wanted, - &ecoal.use_adaptive_tx_coalesce }, - { "sample-interval", CMDL_S32, &coal_sample_rate_wanted, - &ecoal.rate_sample_interval }, - { "stats-block-usecs", CMDL_S32, &coal_stats_wanted, - &ecoal.stats_block_coalesce_usecs }, - { "pkt-rate-low", CMDL_S32, &coal_pkt_rate_low_wanted, - &ecoal.pkt_rate_low }, - { "pkt-rate-high", CMDL_S32, &coal_pkt_rate_high_wanted, - &ecoal.pkt_rate_high }, - { "rx-usecs", CMDL_S32, &coal_rx_usec_wanted, - &ecoal.rx_coalesce_usecs }, - { "rx-frames", CMDL_S32, &coal_rx_frames_wanted, - &ecoal.rx_max_coalesced_frames }, - { "rx-usecs-irq", CMDL_S32, &coal_rx_usec_irq_wanted, - &ecoal.rx_coalesce_usecs_irq }, - { "rx-frames-irq", CMDL_S32, &coal_rx_frames_irq_wanted, - &ecoal.rx_max_coalesced_frames_irq }, - { "tx-usecs", CMDL_S32, &coal_tx_usec_wanted, - &ecoal.tx_coalesce_usecs }, - { "tx-frames", CMDL_S32, &coal_tx_frames_wanted, - &ecoal.tx_max_coalesced_frames }, - { "tx-usecs-irq", CMDL_S32, &coal_tx_usec_irq_wanted, - &ecoal.tx_coalesce_usecs_irq }, - { "tx-frames-irq", CMDL_S32, &coal_tx_frames_irq_wanted, - &ecoal.tx_max_coalesced_frames_irq }, - { "rx-usecs-low", CMDL_S32, &coal_rx_usec_low_wanted, - &ecoal.rx_coalesce_usecs_low }, - { "rx-frames-low", CMDL_S32, &coal_rx_frames_low_wanted, - &ecoal.rx_max_coalesced_frames_low }, - { "tx-usecs-low", CMDL_S32, &coal_tx_usec_low_wanted, - &ecoal.tx_coalesce_usecs_low }, - { "tx-frames-low", CMDL_S32, &coal_tx_frames_low_wanted, - &ecoal.tx_max_coalesced_frames_low }, - { "rx-usecs-high", CMDL_S32, &coal_rx_usec_high_wanted, - &ecoal.rx_coalesce_usecs_high }, - { "rx-frames-high", CMDL_S32, &coal_rx_frames_high_wanted, - &ecoal.rx_max_coalesced_frames_high }, - { "tx-usecs-high", CMDL_S32, &coal_tx_usec_high_wanted, - &ecoal.tx_coalesce_usecs_high }, - { "tx-frames-high", CMDL_S32, &coal_tx_frames_high_wanted, - &ecoal.tx_max_coalesced_frames_high }, - }; int err, changed = 0; parse_generic_cmdline(ctx, &gcoalesce_changed, cmdline_coalesce, ARRAY_SIZE(cmdline_coalesce)); - ecoal.cmd = ETHTOOL_GCOALESCE; - err = send_ioctl(ctx, &ecoal); + s_ecoal.cmd = ETHTOOL_GCOALESCE; + err = send_ioctl(ctx, &s_ecoal); if (err) { perror("Cannot get device coalesce settings"); return 76; @@ -1975,8 +1976,8 @@ static int do_scoalesce(struct cmd_context *ctx) return 80; } - ecoal.cmd = ETHTOOL_SCOALESCE; - err = send_ioctl(ctx, &ecoal); + s_ecoal.cmd = ETHTOOL_SCOALESCE; + err = send_ioctl(ctx, &s_ecoal); if (err) { perror("Cannot set device coalesce parameters"); return 81; -- 2.5.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-06-26 15:05 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-05-15 7:14 [PATCH 1/5] ethtool: move option parsing related codes into function kan.liang 2016-05-15 7:14 ` [PATCH 2/5] ethtool: move cmdline_coalesce out of do_scoalesce kan.liang 2016-06-26 15:05 ` Ben Hutchings 2016-05-15 7:14 ` [PATCH 3/5] ethtool: introduce new ioctl for per queue setting kan.liang 2016-05-15 7:14 ` [PATCH 4/5] ethtool: support per queue sub command --show-coalesce kan.liang 2016-05-15 7:14 ` [PATCH 5/5] ethtool: support per queue sub command --coalesce kan.liang -- strict thread matches above, loose matches on Subject: below -- 2016-03-14 9:30 [PATCH 1/5] ethtool: move option parsing related codes into function kan.liang 2016-03-14 9:30 ` [PATCH 2/5] ethtool: move cmdline_coalesce out of do_scoalesce kan.liang
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).