Skip to contentSkip to conversation

Enhance the tx-usecs coalesce setting implementation

PATCH Superseded Muhammad Husaini Zulkifli 3 participants 7 messages Jul 11, 2023 – Jul 26, 2023

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Enhance the tx-usecs coalesce setting implementation

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.

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

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#1 lore raw

PATCH v2 1/2 igc: Expose tx-usecs coalesce setting to user

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")
---
 drivers/net/ethernet/intel/igc/igc_ethtool.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/igc/igc_ethtool.c +4 -9
index 93bce729be76..62d925b26f2c 100644
@@ -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)
Signature · 6 lines
2.17.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
maintainer
#2 lore raw

Re: [Intel-wired-lan] [PATCH iwl-net v2 1/2] igc: Expose tx-usecs coalesce setting to user

On 7/10/2023 5:34 PM, Muhammad Husaini Zulkifli wrote:

...

drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct net_device *netdev, · line 915

Quoted 8 lines
  }
drivers/net/ethernet/intel/igc/igc_ethtool.c +0 -3
@@ -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;
-

Seems like this belongs in patch 2?

drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct net_device *netdev, · line 913

Quoted 3 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0 -0
  	/* If ITR is disabled, disable DMAC */
  	if (ec->rx_coalesce_usecs == 0) {
  		if (adapter->flags & IGC_FLAG_DMAC)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#3 lore raw

Re: [Intel-wired-lan] [PATCH iwl-net v2 1/2] igc: Expose tx-usecs coalesce setting to user

Dear Anthony,

Quoted 18 lines

-----Original Message-----
From: Nguyen, Anthony L <[email protected]>
Sent: Thursday, 13 July, 2023 4:39 AM
To: Zulkifli, Muhammad Husaini <[email protected]>; intel- [email protected]
Cc: Neftin, Sasha <[email protected]>; [email protected]
Subject: Re: [PATCH iwl-net v2 1/2] igc: Expose tx-usecs coalesce setting to user

On 7/10/2023 5:34 PM, Muhammad Husaini Zulkifli wrote:

...

Review static int igc_ethtool_set_coalesce(struct net_device

Quoted 2 lines
  }
(quoted diff) +0 -0
@@ -910,9 +908,6 @@ static int igc_ethtool_set_coalesce(struct net_device

*netdev,

Quoted 3 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0 -0
  	    ec->tx_coalesce_usecs == 2)
  		return -EINVAL;
 
Quoted 6 lines

drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct net_device *netdev, · line 915

Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0 -3
-	if ((adapter->flags & IGC_FLAG_QUEUE_PAIRS) && ec-
 tx_coalesce_usecs)
-		return -EINVAL;
-

Seems like this belongs in patch 2?

The first patch should have this. Without this line, we would be unable to configure rx-usecs at all.

Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0 -0
  	/* If ITR is disabled, disable DMAC */
  	if (ec->rx_coalesce_usecs == 0) {

if (adapter->flags & IGC_FLAG_DMAC)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Tested-by on v2 1/2
#4 lore raw

Re: [Intel-wired-lan] [PATCH iwl-net v2 1/2] igc: Expose tx-usecs coalesce setting to user

In reply to Muhammad Husaini Zulkifli
Quoted 42 lines · Muhammad Husaini Zulkifli

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

Quoted 5 lines
Fixes 8c5ad0dae93c ("igc: Add ethtool support")
---
  drivers/net/ethernet/intel/igc/igc_ethtool.c | 13 ++++---------
  1 file changed, 4 insertions(+), 9 deletions(-)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#5 lore raw

PATCH v2 2/2 igc: Modify the tx-usecs coalesce setting

In reply to Muhammad Husaini Zulkifli

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")
---
 drivers/net/ethernet/intel/igc/igc_ethtool.c | 33 ++++++++++++++++++--
 1 file changed, 30 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/igc/igc_ethtool.c +30 -3
index 62d925b26f2c..1cf7131a82c5 100644
@@ -914,6 +914,34 @@ static int igc_ethtool_set_coalesce(struct net_device *netdev,
 			adapter->flags &= ~IGC_FLAG_DMAC;
 	}
 
+	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;
+		}
+		goto program_itr;
+	}
+
 	/* 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;
@@ -921,13 +949,12 @@ static int igc_ethtool_set_coalesce(struct net_device *netdev,
 		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)
+	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;
 
+program_itr:
 	for (i = 0; i < adapter->num_q_vectors; i++) {
 		struct igc_q_vector *q_vector = adapter->q_vector[i];
 
Signature · 6 lines
2.17.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Tested-by on v2 2/2
#6 lore raw

Re: [Intel-wired-lan] [PATCH iwl-net v2 2/2] igc: Modify the tx-usecs coalesce setting

Quoted 28 lines · Muhammad Husaini Zulkifli

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

Quoted 5 lines
Fixes 8c5ad0dae93c ("igc: Add ethtool support")
---
  drivers/net/ethernet/intel/igc/igc_ethtool.c | 33 ++++++++++++++++++--
  1 file changed, 30 insertions(+), 3 deletions(-)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan