From: Dimitri Daskalakis <dimitri.daskalakis1@gmail.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: "Alexander Duyck" <alexanderduyck@fb.com>,
"Jakub Kicinski" <kuba@kernel.org>,
kernel-team@meta.com, "Andrew Lunn" <andrew+netdev@lunn.ch>,
"Eric Dumazet" <edumazet@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Willem de Bruijn" <willemb@google.com>,
"Simon Horman" <horms@kernel.org>,
"Björn Töpel" <bjorn@kernel.org>,
"Bobby Eshleman" <bobbyeshleman@meta.com>,
"Mina Almasry" <almasrymina@google.com>,
"Dimitri Daskalakis" <daskald@meta.com>,
netdev@vger.kernel.org,
"Dimitri Daskalakis" <dimitri.daskalakis1@gmail.com>
Subject: [PATCH net 2/4] net: add netif_disable_subqueue()
Date: Fri, 20 Nov 2026 19:32:13 -0800 [thread overview]
Message-ID: <20261121033215.1020506-3-dimitri.daskalakis1@gmail.com> (raw)
In-Reply-To: <20261121033215.1020506-1-dimitri.daskalakis1@gmail.com>
From: Dimitri Daskalakis <daskald@meta.com>
netif_tx_stop_queue() does not wait for xmit to finish, and with
queue API disabling a single queue is becoming more common.
Add a helper like netif_tx_disable() (which drivers commonly use
when stopping the interface) but for one queue.
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Dimitri Daskalakis <daskald@meta.com>
---
include/linux/netdevice.h | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 435be7880d7e..e716b98e8b4c 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -4980,23 +4980,33 @@ static inline void netif_tx_unlock_bh(struct net_device *dev)
} \
}
+/**
+ * netif_disable_subqueue() - stop subqueue and wait for xmit to finish
+ * @dev: network device
+ * @queue_index: sub queue index
+ *
+ * Stop the subqueue like netif_stop_subqueue(), but also make sure that
+ * ndo_start_xmit() is not running on it once this function returns.
+ * Does not synchronize with xmit of lltx devices.
+ */
+static inline void
+netif_disable_subqueue(struct net_device *dev, u16 queue_index)
+{
+ struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
+
+ __netif_tx_lock_bh(txq);
+ netif_tx_stop_queue(txq);
+ __netif_tx_unlock_bh(txq);
+}
+
static inline void netif_tx_disable(struct net_device *dev)
{
unsigned int i;
- int cpu;
- local_bh_disable();
- cpu = smp_processor_id();
- spin_lock(&dev->tx_global_lock);
- for (i = 0; i < dev->num_tx_queues; i++) {
- struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
-
- __netif_tx_lock(txq, cpu);
- netif_tx_stop_queue(txq);
- __netif_tx_unlock(txq);
- }
- spin_unlock(&dev->tx_global_lock);
- local_bh_enable();
+ spin_lock_bh(&dev->tx_global_lock);
+ for (i = 0; i < dev->num_tx_queues; i++)
+ netif_disable_subqueue(dev, i);
+ spin_unlock_bh(&dev->tx_global_lock);
}
#ifndef CONFIG_PREEMPT_RT
--
2.52.1
next prev parent reply other threads:[~2026-11-21 3:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 3:32 [PATCH net 0/4] eth: fbnic: queue stop fixes Dimitri Daskalakis
2026-11-21 3:32 ` [PATCH net 1/4] eth: fbnic: restart queues in place when fbnic_queue_stop() fails Dimitri Daskalakis
2026-11-21 3:32 ` Dimitri Daskalakis [this message]
2026-11-21 3:32 ` [PATCH net 3/4] eth: fbnic: wait for in-flight xmit in fbnic_queue_stop() Dimitri Daskalakis
2026-11-21 3:32 ` [PATCH net 4/4] eth: fbnic: wait for both TWQs of a Tx queue to go idle Dimitri Daskalakis
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=20261121033215.1020506-3-dimitri.daskalakis1@gmail.com \
--to=dimitri.daskalakis1@gmail.com \
--cc=alexanderduyck@fb.com \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=bjorn@kernel.org \
--cc=bobbyeshleman@meta.com \
--cc=daskald@meta.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.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