From patchwork Sat Aug 19 13:50:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zulkifli, Muhammad Husaini" X-Patchwork-Id: 13358630 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B38F733FA for ; Sat, 19 Aug 2023 13:52:21 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A3DB27804 for ; Sat, 19 Aug 2023 06:52:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692453135; x=1723989135; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=iNbzwRMjAEvSzQbxsOi+KU8F2Wyrzf5JNrk8JE3lgeI=; b=NzQSo3pJ4AOR2OPU/TYQGmPFt4aLNvc9YJn/hQBC2ojlJUOJTg3iAP7b ZSATX25M3jQXcU3VhBj3RClTpkExlLPP0t4bBuUZ0nmqQJlLOmQG/usL0 dkOWJU5bpcVod1BUS5SyrIRB6PSxF9ZadCUaMHzvKAfkeM/o4liP0QA6V SrkI1PHKxr8jalyT6vF5ZL81CvNaF5t0kfl3rtZQeT+wyD4vxYsuO6Qg0 Nlq5MMHA4ziMRvJTn7lYyJiczB6PK2GG+CSqLHB3XAPYkYZHcyFNe/WDU ca6x5pFA3ifA754KiButWxl5PAYUGJrcTW+ohloSyb36ml1Wzi+6nbiKZ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10807"; a="363463626" X-IronPort-AV: E=Sophos;i="6.01,186,1684825200"; d="scan'208";a="363463626" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2023 06:52:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10807"; a="805452177" X-IronPort-AV: E=Sophos;i="6.01,186,1684825200"; d="scan'208";a="805452177" Received: from zulkifl3-ilbpg0.png.intel.com ([10.88.229.82]) by fmsmga004.fm.intel.com with ESMTP; 19 Aug 2023 06:52:11 -0700 From: Muhammad Husaini Zulkifli To: intel-wired-lan@osuosl.org Cc: sasha.neftin@intel.com, bcreeley@amd.com, horms@kernel.org, davem@davemloft.net, kuba@kernel.org, muhammad.husaini.zulkifli@intel.com, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org, naamax.meir@linux.intel.com, anthony.l.nguyen@intel.com Subject: [PATCH iwl-net v4 1/2] igc: Expose tx-usecs coalesce setting to user Date: Sat, 19 Aug 2023 21:50:50 +0800 Message-Id: <20230819135051.29390-2-muhammad.husaini.zulkifli@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230819135051.29390-1-muhammad.husaini.zulkifli@intel.com> References: <20230819135051.29390-1-muhammad.husaini.zulkifli@intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-Patchwork-Delegate: kuba@kernel.org When users attempt to obtain the coalesce setting using the ethtool command, current code always returns 0 for tx-usecs. This is because I225/6 always uses a queue pair setting, hence tx_coalesce_usecs does not return a value during the igc_ethtool_get_coalesce() callback process. The pair queue condition checking in igc_ethtool_get_coalesce() is removed by this patch so that the user gets information of the value of tx-usecs. Even if i225/6 is using queue pair setting, there is no harm in notifying the user of the tx-usecs. The implementation of the current code may have previously been a copy of the legacy code i210. How to test: User can get the coalesce value using ethtool command. Example command: Get: ethtool -c Previous output: rx-usecs: 3 rx-frames: n/a rx-usecs-irq: n/a rx-frames-irq: n/a tx-usecs: 0 tx-frames: n/a tx-usecs-irq: n/a tx-frames-irq: n/a New output: rx-usecs: 3 rx-frames: n/a rx-usecs-irq: n/a rx-frames-irq: n/a tx-usecs: 3 tx-frames: n/a tx-usecs-irq: n/a tx-frames-irq: n/a Fixes: 8c5ad0dae93c ("igc: Add ethtool support") Signed-off-by: Muhammad Husaini Zulkifli Tested-by: Naama Meir --- drivers/net/ethernet/intel/igc/igc_ethtool.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index 93bce729be76..62d925b26f2c 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -880,12 +880,10 @@ static int igc_ethtool_get_coalesce(struct net_device *netdev, else ec->rx_coalesce_usecs = adapter->rx_itr_setting >> 2; - if (!(adapter->flags & IGC_FLAG_QUEUE_PAIRS)) { - if (adapter->tx_itr_setting <= 3) - ec->tx_coalesce_usecs = adapter->tx_itr_setting; - else - ec->tx_coalesce_usecs = adapter->tx_itr_setting >> 2; - } + if (adapter->tx_itr_setting <= 3) + ec->tx_coalesce_usecs = adapter->tx_itr_setting; + else + ec->tx_coalesce_usecs = adapter->tx_itr_setting >> 2; return 0; } @@ -910,9 +908,6 @@ static int igc_ethtool_set_coalesce(struct net_device *netdev, ec->tx_coalesce_usecs == 2) return -EINVAL; - if ((adapter->flags & IGC_FLAG_QUEUE_PAIRS) && ec->tx_coalesce_usecs) - return -EINVAL; - /* If ITR is disabled, disable DMAC */ if (ec->rx_coalesce_usecs == 0) { if (adapter->flags & IGC_FLAG_DMAC) From patchwork Sat Aug 19 13:50:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zulkifli, Muhammad Husaini" X-Patchwork-Id: 13358632 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6F1B125A0 for ; Sat, 19 Aug 2023 13:53:19 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03CAA22A14 for ; Sat, 19 Aug 2023 06:52:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692453139; x=1723989139; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=yde9xJhaTEZD+38PelDCp44E5kb3nUKVR/tKJEve7W0=; b=PGMSCIEsGSd9AbauUfBOA6kgKxSZcEZBsmx1vbEpe/6UItyezQMJVSZ9 pz9VCQcEqM7izSt9e8Yon9Kf9Fj9FhFv6tvcUrY9+2O3h1u16/5KtOZG5 /cTPrkQsny7/vvm7memGJIrqdjW0isjCyv0SN2hWD9ZFmQHd8wXVYuQdA YTA+nl0Uda7Aj+zX6WFTDyBpw/obEhaIZIcrWGMndEbjzhjfScds5Nags 2s7VijQJcU2Jur8kb3BGCvENnK3gsh1VjbjLxZoHGn94LCelqpWgZ5NLX PXz9v6pXExgpcaHfgesGDzW7cPwsLsyspw+JeDIAXsowppzjfePd6SaTI w==; X-IronPort-AV: E=McAfee;i="6600,9927,10807"; a="363463634" X-IronPort-AV: E=Sophos;i="6.01,186,1684825200"; d="scan'208";a="363463634" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2023 06:52:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10807"; a="805452183" X-IronPort-AV: E=Sophos;i="6.01,186,1684825200"; d="scan'208";a="805452183" Received: from zulkifl3-ilbpg0.png.intel.com ([10.88.229.82]) by fmsmga004.fm.intel.com with ESMTP; 19 Aug 2023 06:52:14 -0700 From: Muhammad Husaini Zulkifli To: intel-wired-lan@osuosl.org Cc: sasha.neftin@intel.com, bcreeley@amd.com, horms@kernel.org, davem@davemloft.net, kuba@kernel.org, muhammad.husaini.zulkifli@intel.com, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org, naamax.meir@linux.intel.com, anthony.l.nguyen@intel.com Subject: [PATCH iwl-net v4 2/2] igc: Modify the tx-usecs coalesce setting Date: Sat, 19 Aug 2023 21:50:51 +0800 Message-Id: <20230819135051.29390-3-muhammad.husaini.zulkifli@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230819135051.29390-1-muhammad.husaini.zulkifli@intel.com> References: <20230819135051.29390-1-muhammad.husaini.zulkifli@intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-Patchwork-Delegate: kuba@kernel.org This patch enables users to modify the tx-usecs parameter. The rx-usecs value will adhere to the same value as tx-usecs if the queue pair setting is enabled. How to test: User can set the coalesce value using ethtool command. Example command: Set: ethtool -C Previous output: root@P12DYHUSAINI:~# ethtool -C enp170s0 tx-usecs 10 netlink error: Invalid argument New output: root@P12DYHUSAINI:~# ethtool -C enp170s0 tx-usecs 10 rx-usecs: 10 rx-frames: n/a rx-usecs-irq: n/a rx-frames-irq: n/a tx-usecs: 10 tx-frames: n/a tx-usecs-irq: n/a tx-frames-irq: n/a Fixes: 8c5ad0dae93c ("igc: Add ethtool support") Signed-off-by: Muhammad Husaini Zulkifli Tested-by: Naama Meir --- drivers/net/ethernet/intel/igc/igc_ethtool.c | 45 ++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index 62d925b26f2c..40ec6ebc0843 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -888,6 +888,11 @@ static int igc_ethtool_get_coalesce(struct net_device *netdev, return 0; } +static int igc_ethtool_coalesce_to_itr_setting(u32 coalesce_usecs) +{ + return coalesce_usecs <= 3 ? coalesce_usecs : coalesce_usecs << 2; +} + static int igc_ethtool_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *ec, struct kernel_ethtool_coalesce *kernel_coal, @@ -914,19 +919,35 @@ static int igc_ethtool_set_coalesce(struct net_device *netdev, adapter->flags &= ~IGC_FLAG_DMAC; } - /* convert to rate of irq's per second */ - if (ec->rx_coalesce_usecs && ec->rx_coalesce_usecs <= 3) - adapter->rx_itr_setting = ec->rx_coalesce_usecs; - else - adapter->rx_itr_setting = ec->rx_coalesce_usecs << 2; + if (adapter->flags & IGC_FLAG_QUEUE_PAIRS) { + u32 old_tx_itr, old_rx_itr; + + /* This is to get back the original value before byte shifting */ + old_tx_itr = (adapter->tx_itr_setting <= 3) ? + adapter->tx_itr_setting : adapter->tx_itr_setting >> 2; + + old_rx_itr = (adapter->rx_itr_setting <= 3) ? + adapter->rx_itr_setting : adapter->rx_itr_setting >> 2; + + /* convert to rate of irq's per second */ + if (old_tx_itr != ec->tx_coalesce_usecs) { + adapter->tx_itr_setting = + igc_ethtool_coalesce_to_itr_setting(ec->tx_coalesce_usecs); + adapter->rx_itr_setting = adapter->tx_itr_setting; + } else if (old_rx_itr != ec->rx_coalesce_usecs) { + adapter->rx_itr_setting = + igc_ethtool_coalesce_to_itr_setting(ec->rx_coalesce_usecs); + adapter->tx_itr_setting = adapter->rx_itr_setting; + } + } else { + /* convert to rate of irq's per second */ + adapter->rx_itr_setting = + igc_ethtool_coalesce_to_itr_setting(ec->rx_coalesce_usecs); - /* convert to rate of irq's per second */ - if (adapter->flags & IGC_FLAG_QUEUE_PAIRS) - adapter->tx_itr_setting = adapter->rx_itr_setting; - else if (ec->tx_coalesce_usecs && ec->tx_coalesce_usecs <= 3) - adapter->tx_itr_setting = ec->tx_coalesce_usecs; - else - adapter->tx_itr_setting = ec->tx_coalesce_usecs << 2; + /* convert to rate of irq's per second */ + adapter->tx_itr_setting = + igc_ethtool_coalesce_to_itr_setting(ec->tx_coalesce_usecs); + } for (i = 0; i < adapter->num_q_vectors; i++) { struct igc_q_vector *q_vector = adapter->q_vector[i];