Skip to content

Commit 1703b2e

Browse files
zulkifl3Paolo Abeni
authored andcommitted
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: 8c5ad0d ("igc: Add ethtool support") Signed-off-by: Muhammad Husaini Zulkifli <muhammad.husaini.zulkifli@intel.com> Tested-by: Naama Meir <naamax.meir@linux.intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Link: https://lore.kernel.org/r/20230919170331.1581031-1-anthony.l.nguyen@intel.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 49dcffe commit 1703b2e

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

drivers/net/ethernet/intel/igc/igc_ethtool.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -868,24 +868,27 @@ static void igc_ethtool_get_stats(struct net_device *netdev,
868868
spin_unlock(&adapter->stats64_lock);
869869
}
870870

871+
static int igc_ethtool_get_previous_rx_coalesce(struct igc_adapter *adapter)
872+
{
873+
return (adapter->rx_itr_setting <= 3) ?
874+
adapter->rx_itr_setting : adapter->rx_itr_setting >> 2;
875+
}
876+
877+
static int igc_ethtool_get_previous_tx_coalesce(struct igc_adapter *adapter)
878+
{
879+
return (adapter->tx_itr_setting <= 3) ?
880+
adapter->tx_itr_setting : adapter->tx_itr_setting >> 2;
881+
}
882+
871883
static int igc_ethtool_get_coalesce(struct net_device *netdev,
872884
struct ethtool_coalesce *ec,
873885
struct kernel_ethtool_coalesce *kernel_coal,
874886
struct netlink_ext_ack *extack)
875887
{
876888
struct igc_adapter *adapter = netdev_priv(netdev);
877889

878-
if (adapter->rx_itr_setting <= 3)
879-
ec->rx_coalesce_usecs = adapter->rx_itr_setting;
880-
else
881-
ec->rx_coalesce_usecs = adapter->rx_itr_setting >> 2;
882-
883-
if (!(adapter->flags & IGC_FLAG_QUEUE_PAIRS)) {
884-
if (adapter->tx_itr_setting <= 3)
885-
ec->tx_coalesce_usecs = adapter->tx_itr_setting;
886-
else
887-
ec->tx_coalesce_usecs = adapter->tx_itr_setting >> 2;
888-
}
890+
ec->rx_coalesce_usecs = igc_ethtool_get_previous_rx_coalesce(adapter);
891+
ec->tx_coalesce_usecs = igc_ethtool_get_previous_tx_coalesce(adapter);
889892

890893
return 0;
891894
}
@@ -910,8 +913,12 @@ static int igc_ethtool_set_coalesce(struct net_device *netdev,
910913
ec->tx_coalesce_usecs == 2)
911914
return -EINVAL;
912915

913-
if ((adapter->flags & IGC_FLAG_QUEUE_PAIRS) && ec->tx_coalesce_usecs)
916+
if ((adapter->flags & IGC_FLAG_QUEUE_PAIRS) &&
917+
ec->tx_coalesce_usecs != igc_ethtool_get_previous_tx_coalesce(adapter)) {
918+
NL_SET_ERR_MSG_MOD(extack,
919+
"Queue Pair mode enabled, both Rx and Tx coalescing controlled by rx-usecs");
914920
return -EINVAL;
921+
}
915922

916923
/* If ITR is disabled, disable DMAC */
917924
if (ec->rx_coalesce_usecs == 0) {

0 commit comments

Comments
 (0)