From patchwork Mon Feb 11 19:22:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nunley, Nicholas D" X-Patchwork-Id: 1040126 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43yx1G0zk7z9sCh for ; Tue, 12 Feb 2019 06:38:58 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id B726D834EE; Mon, 11 Feb 2019 19:38:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yw7OpRRFTRCn; Mon, 11 Feb 2019 19:38:53 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id F29D281BE1; Mon, 11 Feb 2019 19:38:52 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 78EF81BF388 for ; Mon, 11 Feb 2019 19:38:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7642A81A5A for ; Mon, 11 Feb 2019 19:38:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bR0Z88OkmVez for ; Mon, 11 Feb 2019 19:38:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by fraxinus.osuosl.org (Postfix) with ESMTPS id D9F7880CEC for ; Mon, 11 Feb 2019 19:38:48 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Feb 2019 11:38:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,359,1544515200"; d="scan'208";a="298925698" Received: from possum.jf.intel.com (HELO localhost) ([10.166.17.58]) by orsmga005.jf.intel.com with ESMTP; 11 Feb 2019 11:38:48 -0800 From: Nicholas Nunley To: intel-wired-lan@lists.osuosl.org Date: Mon, 11 Feb 2019 11:22:23 -0800 Message-Id: <20190211192227.34960-2-nicholas.d.nunley@intel.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20190211192227.34960-1-nicholas.d.nunley@intel.com> References: <20190211192227.34960-1-nicholas.d.nunley@intel.com> Subject: [Intel-wired-lan] [PATCH v3 2/6] ethtool: move cmdline_coalesce out of do_scoalesce X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Move the definition of cmdline_coalesce out of do_scoalesce and into a macro so it can be resused across functions. No behavior change. Based on patch by Kan Liang Signed-off-by: Nicholas Nunley --- ethtool.c | 142 ++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 74 insertions(+), 68 deletions(-) diff --git a/ethtool.c b/ethtool.c index 917626f..d9850f4 100644 --- a/ethtool.c +++ b/ethtool.c @@ -2101,78 +2101,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,