Skip to contentSkip to conversation

igc: Expose tx-usecs coalesce setting to user

PATCH In review Muhammad Husaini Zulkifli 3 participants 5 messages Sep 8, 2023 – Sep 20, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 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. Since I225 has the queue pair setting enabled, tx-usecs will always adhere to the user-set rx-usecs value. An error message will appear when the user attempts to set the tx-usecs value for the input parameters because, by default, they should only set the rx-usecs value.

This patch also adds the helper function to get the previous rx coalesce value similar to tx coalesce.

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

---
V4 -> V5:
- Squash patch for set/get together as recommended by Jakub.
- Fix unstabilize value when user insert both tx and rx params together.
- Add error message for unsupported config.

V3 -> V4:
- Implement the helper function, as recommended by Brett Creely.
- Fix typo in cover letter.

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

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

---
 drivers/net/ethernet/intel/igc/igc_ethtool.c | 31 ++++++++++++--------
 1 file changed, 19 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/igc/igc_ethtool.c +19 -12
index 93bce729be76..7ab6dd58e400 100644
@@ -868,6 +868,18 @@ static void igc_ethtool_get_stats(struct net_device *netdev,
 	spin_unlock(&adapter->stats64_lock);
 }
 
+static int igc_ethtool_get_previous_rx_coalesce(struct igc_adapter *adapter)
+{
+	return (adapter->rx_itr_setting <= 3) ?
+		adapter->rx_itr_setting : adapter->rx_itr_setting >> 2;
+}
+
+static int igc_ethtool_get_previous_tx_coalesce(struct igc_adapter *adapter)
+{
+	return (adapter->tx_itr_setting <= 3) ?
+		adapter->tx_itr_setting : adapter->tx_itr_setting >> 2;
+}
+
 static int igc_ethtool_get_coalesce(struct net_device *netdev,
 				    struct ethtool_coalesce *ec,
 				    struct kernel_ethtool_coalesce *kernel_coal,
@@ -875,17 +887,8 @@ static int igc_ethtool_get_coalesce(struct net_device *netdev,
 {
 	struct igc_adapter *adapter = netdev_priv(netdev);
 
-	if (adapter->rx_itr_setting <= 3)
-		ec->rx_coalesce_usecs = adapter->rx_itr_setting;
-	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;
-	}
+	ec->rx_coalesce_usecs = igc_ethtool_get_previous_rx_coalesce(adapter);
+	ec->tx_coalesce_usecs = igc_ethtool_get_previous_tx_coalesce(adapter);
 
 	return 0;
 }
@@ -910,8 +913,12 @@ 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)
+	if ((adapter->flags & IGC_FLAG_QUEUE_PAIRS) &&
+	    ec->tx_coalesce_usecs != igc_ethtool_get_previous_tx_coalesce(adapter)) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "Queue Pair mode enabled, both Rx and Tx coalescing controlled by rx-usecs");
 		return -EINVAL;
+	}
 
 	/* If ITR is disabled, disable DMAC */
 	if (ec->rx_coalesce_usecs == 0) {
Signature · 6 lines
2.17.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
reviewer
#1 lore raw
Quoted 8 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.

Quoted 7 lines

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. Since I225 has the queue pair setting enabled, tx-usecs will always adhere to the user-set rx-usecs value. An error message will appear when the user attempts to set the tx-usecs value for the input parameters because, by default, they should only set the rx-usecs value.

Hi Muhammad,

Most likely I'm misunderstanding things. And even if that is not the case perhaps this is as good as it gets. But my reading is that an error will not be raised if a user provides an input value for tx-usecs that matches the current value of tx-usecs, even if a different value is provided for rx-usecs (which will also be applied to tx-usecs).

e.g. (untested!)

  # ethool -c <interface>
  ...
  rx-usecs: 3
  ...
  tx-usecs: 3
  ...
  # ethool -C <interface> tx-usecs 3 rx-usecs 4
  # ethool -c <interface>
  ...
  rx-usecs: 4
  ...
  tx-usecs: 4
  ...

...

#2 lore raw

Dear Simon,

Thanks for reviewing. Replied inline

Quoted 28 lines

-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Sunday, 10 September, 2023 10:24 PM
To: Zulkifli, Muhammad Husaini <[email protected]>
Cc: [email protected]; Neftin, Sasha <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; [email protected]
Subject: Re: [PATCH iwl-net v5] igc: Expose tx-usecs coalesce setting to user

Quoted 8 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.

Quoted 7 lines

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. Since I225 has the queue pair setting enabled, tx-usecs will always adhere to the user-set rx-usecs value. An error message will appear when the user attempts to set the tx-usecs value for the input parameters because, by default, they should only set the rx-usecs value.

Quoted 7 lines

Hi Muhammad,

Most likely I'm misunderstanding things. And even if that is not the case perhaps this is as good as it gets. But my reading is that an error will not be raised if a user provides an input value for tx-usecs that matches the current value of tx-usecs, even if a different value is provided for rx-usecs (which will also be applied to tx-usecs).

Yes you are right. This is what I mentioned in previous version discussion.
https://lore.kernel.org/netdev/[email protected]/
But at least IMHO, better than current or my previous design submission.

Previously, I had considered changing the ".supported_coalesce_params" during ethtool set ops to only set ETHTOOL_COALESCE_RX_USECS with a new define of ETHTOOL_QUEUE_PAIR_COALESCE_USECS. But, if we change the queue/cpu during runtime setting, I believe this ".supported_coalesce_params" need to change as well...

Quoted 20 lines

e.g. (untested!)

  # ethool -c <interface>
  ...
  rx-usecs: 3
  ...
  tx-usecs: 3
  ...
  # ethool -C <interface> tx-usecs 3 rx-usecs 4
  # ethool -c <interface>
  ...
  rx-usecs: 4
  ...
  tx-usecs: 4
  ...

...

reviewer Reviewed-by
#3 lore raw
Quoted 44 lines · Muhammad Husaini

Dear Simon,

Thanks for reviewing. Replied inline

Quoted 28 lines

-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Sunday, 10 September, 2023 10:24 PM
To: Zulkifli, Muhammad Husaini <[email protected]>
Cc: [email protected]; Neftin, Sasha <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; [email protected]
Subject: Re: [PATCH iwl-net v5] igc: Expose tx-usecs coalesce setting to user

Quoted 8 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.

Quoted 7 lines

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. Since I225 has the queue pair setting enabled, tx-usecs will always adhere to the user-set rx-usecs value. An error message will appear when the user attempts to set the tx-usecs value for the input parameters because, by default, they should only set the rx-usecs value.

Quoted 7 lines

Hi Muhammad,

Most likely I'm misunderstanding things. And even if that is not the case perhaps this is as good as it gets. But my reading is that an error will not be raised if a user provides an input value for tx-usecs that matches the current value of tx-usecs, even if a different value is provided for rx-usecs (which will also be applied to tx-usecs).

Yes you are right. This is what I mentioned in previous version discussion.
https://lore.kernel.org/netdev/[email protected]/
But at least IMHO, better than current or my previous design submission.

Quoted 5 lines

Previously, I had considered changing the ".supported_coalesce_params" during ethtool set ops to only set ETHTOOL_COALESCE_RX_USECS with a new define of ETHTOOL_QUEUE_PAIR_COALESCE_USECS. But, if we change the queue/cpu during runtime setting, I believe this ".supported_coalesce_params" need to change as well...

Thanks Muhammad, and sorry for missing that thread.

With that discussion in mind, I think that what this patch does is as good as it gets with the current uAPI, and changes to the uAPI is a follow-up topic.

So, FWIIW, I am happy with this patch as it is.

Tested-by on v5 1/1
#4 lore raw
In reply to Muhammad Husaini Zulkifli
Quoted 63 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. Since I225 has the queue pair setting enabled, tx-usecs will always adhere to the user-set rx-usecs value. An error message will appear when the user attempts to set the tx-usecs value for the input parameters because, by default, they should only set the rx-usecs value.

This patch also adds the helper function to get the previous rx coalesce value similar to tx coalesce.

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

---
V4 -> V5:
- Squash patch for set/get together as recommended by Jakub.
- Fix unstabilize value when user insert both tx and rx params together.
- Add error message for unsupported config.

V3 -> V4:
- Implement the helper function, as recommended by Brett Creely.
- Fix typo in cover letter.

Quoted 8 lines

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

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

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