Subject: Re: [PATCH net v3 2/2] igc: Modify the tx-usecs coalesce setting

From: Jakub Kicinski <[email-masked]>
Date: Wed, 23 Aug 2023 19:19:28 -0700

On Tue, 22 Aug 2023 15:16:20 -0700 Tony Nguyen wrote:
> root@P12DYHUSAINI:~# ethtool -C enp170s0 tx-usecs 10
> netlink error: Invalid argument

Why was it returning an error previously? It's not clear from just 
this patch.

> -	/* 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;
> +
> +		/* convert to rate of irq's per second */
> +		if (old_tx_itr != ec->tx_coalesce_usecs) {
> +			adapter->tx_itr_setting =
> +				igc_ethtool_coalesce_to_itr_setting(ec->tx_coalesce_usecs);
> +			adapter->rx_itr_setting = adapter->tx_itr_setting;
> +		} else if (old_rx_itr != ec->rx_coalesce_usecs) {
> +			adapter->rx_itr_setting =
> +				igc_ethtool_coalesce_to_itr_setting(ec->rx_coalesce_usecs);
> +			adapter->tx_itr_setting = adapter->rx_itr_setting;
> +		}

I'm not sure about this fix. Systems which try to converge
configuration like chef will keep issuing: 

ethtool -C enp170s0 tx-usecs 20 rx-usecs 10

and AFAICT the values will flip back and froth between 10 and 20, 
and never stabilize. Returning an error for unsupported config
sounds right to me. This function takes extack, you can tell 
the user what the problem is.
-- 
pw-bot: cr