netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iwl-net v3 0/2] Enhance the tx-usecs coalesce setting implementation
@ 2023-08-01  1:15 Muhammad Husaini Zulkifli
  2023-08-01  1:15 ` [PATCH iwl-net v3 1/2] igc: Expose tx-usecs coalesce setting to user Muhammad Husaini Zulkifli
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Muhammad Husaini Zulkifli @ 2023-08-01  1:15 UTC (permalink / raw)
  To: intel-wired-lan
  Cc: horms, davem, kuba, muhammad.husaini.zulkifli, pabeni, edumazet,
	netdev, naamax.meir, anthony.l.nguyen

The current tx-usecs coalesce setting implementation in the driver code is
improved by this patch series. The implementation of the current driver
code may have previously been a copy of the legacy code i210.

Patch 1:
Allow the user to see the tx-usecs colease setting's current value when
using the ethtool command. The previous value was 0.

Patch 2:
Give the user the ability to modify the tx-usecs colease setting's value.
Previously, it was restricted to rx-usecs.

V2 -> V3:
- Refactor the code, as Simon suggested, to make it more readable.

V1 -> V2:
- Split the patch file into two, like Anthony suggested.

Muhammad Husaini Zulkifli (2):
  igc: Expose tx-usecs coalesce setting to user
  igc: Modify the tx-usecs coalesce setting

 drivers/net/ethernet/intel/igc/igc_ethtool.c | 46 +++++++++++++++-----
 1 file changed, 34 insertions(+), 12 deletions(-)

--
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH iwl-net v3 1/2] igc: Expose tx-usecs coalesce setting to user
  2023-08-01  1:15 [PATCH iwl-net v3 0/2] Enhance the tx-usecs coalesce setting implementation Muhammad Husaini Zulkifli
@ 2023-08-01  1:15 ` Muhammad Husaini Zulkifli
  2023-08-01  1:15 ` [PATCH iwl-net v3 2/2] igc: Modify the tx-usecs coalesce setting Muhammad Husaini Zulkifli
  2023-08-01  9:57 ` [PATCH iwl-net v3 0/2] Enhance the tx-usecs coalesce setting implementation Simon Horman
  2 siblings, 0 replies; 4+ messages in thread
From: Muhammad Husaini Zulkifli @ 2023-08-01  1:15 UTC (permalink / raw)
  To: intel-wired-lan
  Cc: horms, davem, kuba, muhammad.husaini.zulkifli, pabeni, edumazet,
	netdev, naamax.meir, anthony.l.nguyen

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 <interface>

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 <muhammad.husaini.zulkifli@intel.com>
Tested-by: Naama Meir <naamax.meir@linux.intel.com>
---
 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)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH iwl-net v3 2/2] igc: Modify the tx-usecs coalesce setting
  2023-08-01  1:15 [PATCH iwl-net v3 0/2] Enhance the tx-usecs coalesce setting implementation Muhammad Husaini Zulkifli
  2023-08-01  1:15 ` [PATCH iwl-net v3 1/2] igc: Expose tx-usecs coalesce setting to user Muhammad Husaini Zulkifli
@ 2023-08-01  1:15 ` Muhammad Husaini Zulkifli
  2023-08-01  9:57 ` [PATCH iwl-net v3 0/2] Enhance the tx-usecs coalesce setting implementation Simon Horman
  2 siblings, 0 replies; 4+ messages in thread
From: Muhammad Husaini Zulkifli @ 2023-08-01  1:15 UTC (permalink / raw)
  To: intel-wired-lan
  Cc: horms, davem, kuba, muhammad.husaini.zulkifli, pabeni, edumazet,
	netdev, naamax.meir, anthony.l.nguyen

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 <interface>

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 <muhammad.husaini.zulkifli@intel.com>
Tested-by: Naama Meir <naamax.meir@linux.intel.com>
---
 drivers/net/ethernet/intel/igc/igc_ethtool.c | 49 +++++++++++++++-----
 1 file changed, 37 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..ed67d9061452 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -914,19 +914,44 @@ 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;
+
+		if (old_tx_itr != ec->tx_coalesce_usecs) {
+			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;
+
+			adapter->rx_itr_setting = adapter->tx_itr_setting;
+		} else if (old_rx_itr != ec->rx_coalesce_usecs) {
+			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;
+
+			adapter->tx_itr_setting = adapter->rx_itr_setting;
+		}
+	} else {
+		/* 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;
 
-	/* 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 */
+		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;
+	}
 
 	for (i = 0; i < adapter->num_q_vectors; i++) {
 		struct igc_q_vector *q_vector = adapter->q_vector[i];
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH iwl-net v3 0/2] Enhance the tx-usecs coalesce setting implementation
  2023-08-01  1:15 [PATCH iwl-net v3 0/2] Enhance the tx-usecs coalesce setting implementation Muhammad Husaini Zulkifli
  2023-08-01  1:15 ` [PATCH iwl-net v3 1/2] igc: Expose tx-usecs coalesce setting to user Muhammad Husaini Zulkifli
  2023-08-01  1:15 ` [PATCH iwl-net v3 2/2] igc: Modify the tx-usecs coalesce setting Muhammad Husaini Zulkifli
@ 2023-08-01  9:57 ` Simon Horman
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-08-01  9:57 UTC (permalink / raw)
  To: Muhammad Husaini Zulkifli
  Cc: intel-wired-lan, davem, kuba, pabeni, edumazet, netdev,
	naamax.meir, anthony.l.nguyen

On Tue, Aug 01, 2023 at 09:15:16AM +0800, Muhammad Husaini Zulkifli wrote:
> The current tx-usecs coalesce setting implementation in the driver code is
> improved by this patch series. The implementation of the current driver
> code may have previously been a copy of the legacy code i210.
> 
> Patch 1:
> Allow the user to see the tx-usecs colease setting's current value when
> using the ethtool command. The previous value was 0.
> 
> Patch 2:
> Give the user the ability to modify the tx-usecs colease setting's value.
> Previously, it was restricted to rx-usecs.
> 
> V2 -> V3:
> - Refactor the code, as Simon suggested, to make it more readable.
> 
> V1 -> V2:
> - Split the patch file into two, like Anthony suggested.

Thanks for the refactoring.

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-01  9:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-01  1:15 [PATCH iwl-net v3 0/2] Enhance the tx-usecs coalesce setting implementation Muhammad Husaini Zulkifli
2023-08-01  1:15 ` [PATCH iwl-net v3 1/2] igc: Expose tx-usecs coalesce setting to user Muhammad Husaini Zulkifli
2023-08-01  1:15 ` [PATCH iwl-net v3 2/2] igc: Modify the tx-usecs coalesce setting Muhammad Husaini Zulkifli
2023-08-01  9:57 ` [PATCH iwl-net v3 0/2] Enhance the tx-usecs coalesce setting implementation Simon Horman

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).