Netdev List
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Koichiro Den <den@valinux.co.jp>, Jon Mason <jdmason@kudzu.us>,
	Allen Hubbe <allenbh@gmail.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: ntb@lists.linux.dev, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 2/4] net: ntb_netdev: Fix TX busy and drop handling
Date: Wed, 19 Aug 2026 16:39:17 -0700	[thread overview]
Message-ID: <cb4c7775-0307-4b0d-8963-cd5889261658@intel.com> (raw)
In-Reply-To: <20260817053519.4135287-3-den@valinux.co.jp>



On 8/16/26 10:35 PM, Koichiro Den wrote:
> Currently, ntb_netdev returns NETDEV_TX_BUSY for every enqueue error. It
> also increments the drop and error counters while leaving the skb owned
> by the qdisc, and may return BUSY with the subqueue still awake.
> Retrying a permanent error cannot succeed either.
> 
> The unconditional BUSY return and premature accounting date back to the
> initial driver. The error-path queue stop was later removed without
> changing that return value. The current flow-control code includes a
> resource check, but ntb_netdev does not honor its result before enqueue.
> 
> Honor the resource check before enqueue. For -EAGAIN and -EBUSY, stop
> the subqueue, arm the existing reaper timer, and return BUSY without
> touching the skb. For other errors, free the skb, increment tx_dropped,
> and return NETDEV_TX_OK.
> 
> Fixes: 548c237c0a99 ("net: Add support for NTB virtual ethernet device")
> Fixes: d723485cb4ca ("ntb_netdev: remove tx timeout")

This is probably the only Fixes tag we need.

> Fixes: e74bfeedad08 ("NTB: Add flow control to the ntb_netdev")
> Cc: stable@vger.kernel.org> Signed-off-by: Koichiro Den <den@valinux.co.jp>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
>  drivers/net/ntb_netdev.c | 27 +++++++++++++++++++--------
>  1 file changed, 19 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c
> index 029a4a532a10..02b35cf53a62 100644
> --- a/drivers/net/ntb_netdev.c
> +++ b/drivers/net/ntb_netdev.c
> @@ -199,8 +199,10 @@ static int __ntb_netdev_maybe_stop_tx(struct net_device *netdev,
>  static int ntb_netdev_maybe_stop_tx(struct net_device *ndev,
>  				    struct ntb_netdev_queue *q, int size)
>  {
> -	if (__netif_subqueue_stopped(ndev, q->qid) ||
> -	    (ntb_transport_tx_free_entry(q->qp) >= size))
> +	if (__netif_subqueue_stopped(ndev, q->qid))
> +		return -EBUSY;
> +
> +	if (ntb_transport_tx_free_entry(q->qp) >= size)
>  		return 0;
>  
>  	return __ntb_netdev_maybe_stop_tx(ndev, q, size);
> @@ -256,21 +258,30 @@ static netdev_tx_t ntb_netdev_start_xmit(struct sk_buff *skb,
>  
>  	q = &dev->queues[qid];
>  
> -	ntb_netdev_maybe_stop_tx(ndev, q, tx_stop);
> +	if (unlikely(ntb_netdev_maybe_stop_tx(ndev, q, tx_stop)))
> +		return NETDEV_TX_BUSY;
>  
>  	rc = ntb_transport_tx_enqueue(q->qp, skb, skb->data, skb->len);
> -	if (rc)
> -		goto err;
> +	if (rc) {
> +		if (rc == -EAGAIN || rc == -EBUSY) {
> +			netif_stop_subqueue(ndev, q->qid);
> +			mod_timer(&q->tx_timer,
> +				  jiffies + usecs_to_jiffies(tx_time));
> +			return NETDEV_TX_BUSY;
> +		}
> +
> +		goto drop;
> +	}
>  
>  	/* check for next submit */
>  	ntb_netdev_maybe_stop_tx(ndev, q, tx_stop);
>  
>  	return NETDEV_TX_OK;
>  
> -err:
> +drop:
> +	dev_kfree_skb_any(skb);
>  	ndev->stats.tx_dropped++;
> -	ndev->stats.tx_errors++;
> -	return NETDEV_TX_BUSY;
> +	return NETDEV_TX_OK;
>  }
>  
>  static void ntb_netdev_tx_timer(struct timer_list *t)


  reply	other threads:[~2026-08-19 23:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17  5:35 [PATCH net 0/4] net: ntb_netdev: Fix TX completion and error handling Koichiro Den
2026-08-17  5:35 ` [PATCH net 1/4] NTB: ntb_transport: Recycle TX entries before client callbacks Koichiro Den
2026-08-19 21:16   ` Dave Jiang
2026-08-17  5:35 ` [PATCH net 2/4] net: ntb_netdev: Fix TX busy and drop handling Koichiro Den
2026-08-19 23:39   ` Dave Jiang [this message]
2026-08-17  5:35 ` [PATCH net 3/4] NTB: ntb_transport: Fail TX enqueue when the QP link is down Koichiro Den
2026-08-19 23:46   ` Dave Jiang
2026-08-17  5:35 ` [PATCH net 4/4] NTB: ntb_transport: Reject oversized TX buffers Koichiro Den
2026-08-19 23:47   ` Dave Jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cb4c7775-0307-4b0d-8963-cd5889261658@intel.com \
    --to=dave.jiang@intel.com \
    --cc=allenbh@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=den@valinux.co.jp \
    --cc=edumazet@google.com \
    --cc=jdmason@kudzu.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ntb@lists.linux.dev \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox