From patchwork Wed Feb 6 00:01:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirsher, Jeffrey T" X-Patchwork-Id: 1037276 X-Patchwork-Delegate: linville@tuxdriver.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43vM6k62lTz9sDr for ; Wed, 6 Feb 2019 11:01:18 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbfBFABR (ORCPT ); Tue, 5 Feb 2019 19:01:17 -0500 Received: from mga09.intel.com ([134.134.136.24]:8499 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726456AbfBFABO (ORCPT ); Tue, 5 Feb 2019 19:01:14 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2019 16:01:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,337,1544515200"; d="scan'208";a="113999006" Received: from jtkirshe-desk1.jf.intel.com ([134.134.177.96]) by orsmga006.jf.intel.com with ESMTP; 05 Feb 2019 16:01:12 -0800 From: Jeff Kirsher To: linville@tuxdriver.com Cc: Nicholas Nunley , netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com, Jeff Kirsher Subject: [PATCH v2 2/6] ethtool: move cmdline_coalesce out of do_scoalesce Date: Tue, 5 Feb 2019 16:01:02 -0800 Message-Id: <20190206000106.24364-2-jeffrey.t.kirsher@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190206000106.24364-1-jeffrey.t.kirsher@intel.com> References: <20190206000106.24364-1-jeffrey.t.kirsher@intel.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Nicholas Nunley Move the definition of cmdline_coalesce out of do_scoalesce and into a macro so it can be reused across functions. No behavior change. Based on patch by Kan Liang Signed-off-by: Nicholas Nunley Signed-off-by: Jeff Kirsher --- ethtool.c | 142 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 74 insertions(+), 68 deletions(-) diff --git a/ethtool.c b/ethtool.c index 8b7c224..af266c5 100644 --- a/ethtool.c +++ b/ethtool.c @@ -2098,78 +2098,84 @@ static int do_gcoalesce(struct cmd_context *ctx) return 0; } +#define DECLARE_COALESCE_OPTION_VARS() \ + 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 + +#define COALESCE_CMDLINE_INFO(__ecoal) \ +{ \ + { "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 }, \ +} + 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 }, - }; + DECLARE_COALESCE_OPTION_VARS(); + struct cmdline_info cmdline_coalesce[] = COALESCE_CMDLINE_INFO(ecoal); int err, changed = 0; parse_generic_cmdline(ctx, &gcoalesce_changed,