igc: Enhance the tx-usecs coalesce setting implementation
Subsystems (3)
Tony Nguyen
maintainerMuhammad Husaini Zulkifli says:
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:
- Refactor the code, as Simon suggested, to make it more readable.
v1: https://lore.kernel.org/netdev/[email protected]/
The following are changes since commit 13d2618b48f15966d1adfe1ff6a1985f5eef40ba:
bpf: sockmap: Remove preempt_disable in sock_map_sk_acquire
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 1GbE
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 | 62 +++++++++++++------- 1 file changed, 41 insertions(+), 21 deletions(-)
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH v2 1/2 igc: Expose tx-usecs coalesce setting to user
From: Muhammad Husaini Zulkifli <[email protected]>
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
--- 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
@@ -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 · 1 line
2.38.1
Re: [PATCH net v2 1/2] igc: Expose tx-usecs coalesce setting to user
Quoted 78 lines · Tony Nguyen
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
From: Muhammad Husaini Zulkifli <[email protected]>
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_usecsdoes not return a value during theigc_ethtool_get_coalesce()callback process. The pair queue condition checking inigc_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/atx-usecs: 0
tx-frames: n/a
tx-usecs-irq: n/a
tx-frames-irq: n/aNew output:
rx-usecs: 3
rx-frames: n/a
rx-usecs-irq: n/a
rx-frames-irq: n/atx-usecs: 3
tx-frames: n/a
tx-usecs-irq: n/a
tx-frames-irq: n/aFixes 8c5ad0dae93c ("igc: Add ethtool support")Signed-off-by Muhammad Husaini Zulkifli <[email protected]>Tested-by Naama Meir <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- 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
-6@@ -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 ; }
drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct net_device *netdev, · line 915
Quoted 6 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 ; -
Should this be part of patch 2/2 or is it necessary to remove this for the get flow?
Quoted 7 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-1/* If ITR is disabled, disable DMAC */ if (ec->rx_coalesce_usecs ==0 ) {if (adapter->flags &IGC_FLAG_DMAC ) --2.38.1
RE: [PATCH net v2 1/2] igc: Expose tx-usecs coalesce setting to user
Hi Brett,
Thanks for the review.
Quoted 98 lines
-----Original Message-----
From: Brett Creeley <[email protected]>
Sent: Wednesday, 2 August, 2023 2:20 AM
To: Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: Zulkifli, Muhammad Husaini <[email protected]>; Neftin, Sasha <[email protected]>; Naama Meir <[email protected]>; Simon Horman <[email protected]>
Subject: Re: [PATCH net v2 1/2] igc: Expose tx-usecs coalesce setting to userQuoted 1 line · Tony Nguyen
Caution: This message originated from an External Source. Use proper caution
when opening attachments, clicking links, or responding.
drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_get_coalesce(struct
Quoted 62 lines
From: Muhammad Husaini Zulkifli <[email protected]>
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, hencetx_coalesce_usecsdoes not return a value during theigc_ethtool_get_coalesce()callback process. The pair queue condition checking inigc_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/atx-usecs: 0
tx-frames: n/a
tx-usecs-irq: n/a
tx-frames-irq: n/aNew output:
rx-usecs: 3
rx-frames: n/a
rx-usecs-irq: n/a
rx-frames-irq: n/atx-usecs: 3
tx-frames: n/a
tx-usecs-irq: n/a
tx-frames-irq: n/aFixes 8c5ad0dae93c ("igc: Add ethtool support")Signed-off-by Muhammad Husaini ZulkifliTested-by Naama Meir <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/igc/igc_ethtool.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-0@@ -880,12 +880,10 @@ static int igc_ethtool_get_coalesce(struct
net_device*netdev,drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct net_device
Quoted 17 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +4
-6else 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,
Quoted 3 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-0ec->tx_coalesce_usecs == 2)return -EINVAL ;
Quoted 7 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 ; -Should this be part of patch 2/2 or is it necessary to remove this for the get flow?
It should be part of 1/2.
You won't be able to set the rx-usecs if we don't remove this line since the tx-usec will begin to have value.
Thanks,
Husaini
Quoted 8 lines
Quoted 8 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)--
2.38.1
Tony Nguyen
maintainerPATCH v2 2/2 igc: Modify the tx-usecs coalesce setting
In reply to Tony NguyenFrom: Muhammad Husaini Zulkifli <[email protected]>
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
--- drivers/net/ethernet/intel/igc/igc_ethtool.c | 49 +++++++++++++++----- 1 file changed, 37 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/igc/igc_ethtool.c +37 -12
@@ -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];
Signature · 1 line
2.38.1
Re: [PATCH net v2 2/2] igc: Modify the tx-usecs coalesce setting
Quoted 60 lines · Tony Nguyen
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
From: Muhammad Husaini Zulkifli <[email protected]>
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 argumentNew 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/atx-usecs: 10
tx-frames: n/a
tx-usecs-irq: n/a
tx-frames-irq: n/aFixes 8c5ad0dae93c ("igc: Add ethtool support")Signed-off-by Muhammad Husaini Zulkifli <[email protected]>Tested-by Naama Meir <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/igc/igc_ethtool.c | 49 +++++++++++++++----- 1 file changed, 37 insertions(+), 12 deletions(-)drivers/net/ethernet/intel/igc/igc_ethtool.c +5
-5@@ -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) ?
drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct net_device *netdev, · line 931
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +10
-0+ 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 ;
It seems like this if/else flow is duplicated multiple times throughout this patch. Maybe it would be useful to introduce a helper function so you can just do the following:
adapter->tx_itr_setting =
igc_ethtool_coalesce_to_itr_setting(ec->tx_coalesce);
drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct net_device *netdev, · line 938
Quoted 7 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +7
-0+ + 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 ;
Seems like the helper function could work for both tx/rx:
adapter->rx_itr_setting =
igc_ethtool_coalsece_to_itr_setting(ec->rx_coalesce);
drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct net_device *netdev, · line 947
Quoted 9 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +9
-0+ + 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 ;
adapter->rx_itr_setting =
igc_ethtool_coalsece_to_itr_setting(ec->rx_coalesce);
drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct net_device *netdev, · line 953
Quoted 13 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +5
-7-/* 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 ;
adapter->tx_itr_setting =
igc_ethtool_coalesce_to_itr_setting(ec->tx_coalesce);
Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +1
-1+ }for (i =0 ; i < adapter->num_q_vectors; i++) {struct igc_q_vector *q_vector = adapter->q_vector[i]; --2.38.1
RE: [PATCH net v2 2/2] igc: Modify the tx-usecs coalesce setting
Dear Brett,
Sorry for the late reply. I truly miss these feedbacks. My bad ☹
Quoted 85 lines
-----Original Message-----
From: Brett Creeley <[email protected]>
Sent: Wednesday, 2 August, 2023 2:18 AM
To: Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: Zulkifli, Muhammad Husaini <[email protected]>; Neftin, Sasha <[email protected]>; Naama Meir <[email protected]>; Simon Horman <[email protected]>
Subject: Re: [PATCH net v2 2/2] igc: Modify the tx-usecs coalesce settingQuoted 1 line · Tony Nguyen
Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.
drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct
Quoted 48 lines
From: Muhammad Husaini Zulkifli <[email protected]>
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 argumentNew 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/atx-usecs: 10
tx-frames: n/a
tx-usecs-irq: n/a
tx-frames-irq: n/aFixes 8c5ad0dae93c ("igc: Add ethtool support")Signed-off-by Muhammad Husaini ZulkifliTested-by Naama Meir <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/igc/igc_ethtool.c | 49 +++++++++++++++----- 1 file changed, 37 insertions(+), 12 deletions(-)drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-0@@ -914,19 +914,44 @@ static int igc_ethtool_set_coalesce(struct
net_device*netdev,Quoted 22 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +14
-5adapter->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 )
Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct net_device *netdev,
Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +4
-0+ adapter->tx_itr_setting = ec->tx_coalesce_usecs; + else + adapter->tx_itr_setting = + ec->tx_coalesce_usecs <<2 ;It seems like this if/else flow is duplicated multiple times throughout this patch. Maybe it would be useful to introduce a helper function so you can just do the following:
Yeah that is a great suggestion. Will do that.
Quoted 13 lines
adapter->tx_itr_setting=igc_ethtool_coalesce_to_itr_setting(ec->tx_coalesce);drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct net_device *netdev,
Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +8
-0+ + 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 ;
Quoted 1 line
Seems like the helper function could work for both tx/rx:
Yup. Both are using same condition.
Quoted 14 lines
adapter->rx_itr_setting=igc_ethtool_coalsece_to_itr_setting(ec->rx_coalesce);drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct net_device *netdev,
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +10
-0+ + 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 ;
Quoted 2 lines
adapter->rx_itr_setting=igc_ethtool_coalsece_to_itr_setting(ec->rx_coalesce);
Noted.
Quoted 16 lines
Quoted 5 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-3-/* convert to rate of irq's per second */ -if (adapter->flags &IGC_FLAG_QUEUE_PAIRS ) - adapter->tx_itr_setting = adapter->rx_itr_setting;drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_coalesce(struct net_device *netdev,
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +6
-4-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 ;
Quoted 2 lines
adapter->tx_itr_setting=igc_ethtool_coalesce_to_itr_setting(ec->tx_coalesce);
Sure. 😊
Quoted 10 lines
Quoted 10 lines
+ }
for (i = 0; i < adapter->num_q_vectors; i++) { struct igc_q_vector *q_vector = adapter->q_vector[i];--
2.38.1
Quoted 11 lines · Tony Nguyen
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Muhammad Husaini Zulkifli says:
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
nit, s/colease/coalesce
Quoted 4 lines
the ethtool command. The previous value was 0.
Patch 2:
Give the user the ability to modify the tx-usecs colease setting's value.
nit, s/colease/coalesce
Quoted 23 lines
Previously, it was restricted to rx-usecs.
---
v2:
- Refactor the code, as Simon suggested, to make it more readable.v1: https://lore.kernel.org/netdev/[email protected]/
The following are changes since commit
13d2618b48f15966d1adfe1ff6a1985f5eef40ba:
bpf: sockmap: Removepreempt_disableinsock_map_sk_acquire
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue1GbEMuhammad Husaini Zulkifli (2):
igc: Expose tx-usecs coalesce setting to user
igc: Modify the tx-usecs coalesce settingdrivers/net/ethernet/intel/igc/igc_ethtool.c | 62 +++++++++++++------- 1 file changed, 41 insertions(+), 21 deletions(-)--
2.38.1
Quoted 21 lines
-----Original Message-----
From: Brett Creeley <[email protected]>
Sent: Wednesday, 2 August, 2023 2:20 AM
To: Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: Zulkifli, Muhammad Husaini <[email protected]>; Neftin, Sasha <[email protected]>; [email protected]
Subject: Re: [PATCH net v2 0/2][pull request] igc: Enhance the tx-usecs coalesce setting implementationQuoted 1 line · Tony Nguyen
Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.
Quoted 7 lines
Muhammad Husaini Zulkifli says:
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
Quoted 7 lines
i210.
Quoted 4 lines
Patch 1:
Allow the user to see the tx-usecs colease setting's current value when usingnit, s/colease/coalesce
Sure. Will fix this typos.
Quoted 7 lines
Quoted 5 lines
the ethtool command. The previous value was 0.
Patch 2:
Give the user the ability to modify the tx-usecs colease setting's value.nit, s/colease/coalesce
Noted.
Quoted 27 lines
Quoted 11 lines
Previously, it was restricted to rx-usecs.
---
v2:
- Refactor the code, as Simon suggested, to make it more readable.v1:
https://lore.kernel.org/netdev/20230728170954.2445592-1-anthony.l.nguy
[email protected]/The following are changes since commit
13d2618b48f15966d1adfe1ff6a1985f5eef40ba:Quoted 15 lines
bpf: sockmap: Remove
preempt_disableinsock_map_sk_acquireand are
available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue1GbEMuhammad Husaini Zulkifli (2):
igc: Expose tx-usecs coalesce setting to user
igc: Modify the tx-usecs coalesce settingdrivers/net/ethernet/intel/igc/igc_ethtool.c | 62 +++++++++++++------- 1 file changed, 41 insertions(+), 21 deletions(-)--
2.38.1