On Fri, Nov 13, 2026 at 12:44:04PM -0800, Haiyang Zhang wrote:
> From: Haiyang Zhang <[email protected]>
> 
> The existing code sets interrupt moderation defaults to 0 usec and 0
> completions, which may cause CQ starvation of our NIC HW, and TX time
> out error like:
> mana 7870:00:00.0 ens1: NETDEV WATCHDOG: CPU: 14: transmit queue 4 timed out 
> 63434 ms
> 
> To fix, change the default and minimal rx/tx usecs and frames to 1.
> When the HW supports interrupt moderation, reject ethtool rx/tx usecs
> and frames below 1.
> Also clamp the values written by mana_gd_ring_dim() to [1, max], so
> no caller, including the DIM work, programs a zero value.
> On the HW without interrupt moderation support, do not request CQ
> moderation, the usecs and frames stay at 0, and cannot be modified by
> ethtool.
> The PF capability is queried again when the device resumes from a
> reset or suspend, so re-initialize these settings before re-attaching
> the vPorts.
> 
> Advertise this change to the PF with the new driver capability flag
> GDMA_DRV_CAP_FLAG_1_SET_MIN_INTR_MOD_VALUE.
> 
> Cc: [email protected]
> Fixes: 433f482add31 ("net: mana: Add Interrupt Moderation support")
> Signed-off-by: Haiyang Zhang <[email protected]>
> ---
>  .../net/ethernet/microsoft/mana/gdma_main.c   |  5 ++
>  drivers/net/ethernet/microsoft/mana/mana_en.c | 76 +++++++++++++------
>  .../ethernet/microsoft/mana/mana_ethtool.c    | 26 +++++--
>  include/net/mana/gdma.h                       |  6 +-
>  include/net/mana/mana.h                       |  9 ++-
>  5 files changed, 88 insertions(+), 34 deletions(-)
> 
> diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c 
> b/drivers/net/ethernet/microsoft/mana/gdma_main.c
> index ab942d5bfe05..10be69e97ceb 100644
> --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
> +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
> @@ -646,6 +646,11 @@ void mana_gd_ring_dim(struct gdma_queue *cq, u32 
> mod_usec, bool mod_usec_vld,
>       struct gdma_context *gc = cq->gdma_dev->gdma_context;
>       u32 dim_val;
>  
> +     mod_usec = clamp_t(u32, mod_usec, MANA_INTR_MODR_USEC_MIN,
> +                        MANA_INTR_MODR_USEC_MAX);
> +     mod_comps = clamp_t(u32, mod_comps, MANA_INTR_MODR_COMP_MIN,
> +                         MANA_INTR_MODR_COMP_MAX);

mod_comps is u32 and MANA_* are positive constants.
I believe that clamp() is sufficient here. And if so it's preferred.

That notwithstanding, this looks good to me.

Reviewed-by: Simon Horman <[email protected]>

...

Reply via email to