From: Joshua Hay <[email protected]>
Date: Wed, 25 Jun 2025 09:11:55 -0700

> The Tx refillq logic will cause packets to be silently dropped if there
> are not enough buffer resources available to send a packet in flow
> scheduling mode. Instead, determine how many buffers are needed along
> with number of descriptors. Make sure there are enough of both resources
> to send the packet, and stop the queue if not.
> 
> Fixes: 7292af042bcf ("idpf: fix a race in txq wakeup")
> Signed-off-by: Joshua Hay <[email protected]>
> Reviewed-by: Madhu Chittim <[email protected]>
> ---
>  .../ethernet/intel/idpf/idpf_singleq_txrx.c   |  4 +-
>  drivers/net/ethernet/intel/idpf/idpf_txrx.c   | 51 +++++++++++++------
>  drivers/net/ethernet/intel/idpf/idpf_txrx.h   |  9 +++-
>  3 files changed, 44 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c 
> b/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
> index 4c1d7235a073..d8216bb13019 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
> @@ -361,12 +361,12 @@ netdev_tx_t idpf_tx_singleq_frame(struct sk_buff *skb,
>                                 struct idpf_tx_queue *tx_q)
>  {
>       struct idpf_tx_offload_params offload = { };
> +     unsigned int count, buf_count;

u32

>       struct idpf_tx_buf *first;
>       int csum, tso, needed;
> -     unsigned int count;
>       __be16 protocol;
>  
> -     count = idpf_tx_desc_count_required(tx_q, skb);
> +     count = idpf_tx_res_count_required(tx_q, skb, &buf_count);
>       if (unlikely(!count))
>               return idpf_tx_drop_skb(tx_q, skb);

[...]

>  static int idpf_tx_maybe_stop_splitq(struct idpf_tx_queue *tx_q,
> -                                  unsigned int descs_needed)
> +                                  unsigned int descs_needed,
> +                                  unsigned int bufs_needed)

Same (and everywhere else).

>  {
> +     /* Since we have multiple resources to check for splitq, our
> +      * start,stop_thrs becomes a boolean check instead of a count
> +      * threshold.
> +      */
>       if (netif_subqueue_maybe_stop(tx_q->netdev, tx_q->idx,
> -                                   idpf_txq_has_room(tx_q, descs_needed),
> +                                   idpf_txq_has_room(tx_q, descs_needed,
> +                                                     bufs_needed),
>                                     1, 1))
>               return 0;

[...]

> diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.h 
> b/drivers/net/ethernet/intel/idpf/idpf_txrx.h
> index a79a6a89c5e3..2d4846793f5a 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_txrx.h
> +++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.h
> @@ -116,6 +116,10 @@ do {                                                     
>         \
>  #define IDPF_DESC_UNUSED(txq)     \
>       ((((txq)->next_to_clean > (txq)->next_to_use) ? 0 : (txq)->desc_count) 
> + \
>       (txq)->next_to_clean - (txq)->next_to_use - 1)
> +#define IDPF_BUFS_UNUSED(refillq)      \
> +     ((((refillq)->next_to_use > (refillq)->next_to_clean) ? \
> +       0 : (refillq)->desc_count) + \
> +      (refillq)->next_to_use - (refillq)->next_to_clean)

Just make a static inline.

>  
>  #define IDPF_TX_BUF_RSV_UNUSED(txq)  ((txq)->stash->buf_stack.top)
>  #define IDPF_TX_BUF_RSV_LOW(txq)     (IDPF_TX_BUF_RSV_UNUSED(txq) < \

Thanks,
Olek

Reply via email to