Update the driver documentation TX queue example to match current APIs: - use the ring-local tx_ring_mask field in drv_tx_avail() - stop the selected netdev_queue with netif_tx_stop_queue() instead of stopping queue 0 with netif_stop_queue() Signed-off-by: Jakub Kicinski --- Documentation/networking/driver.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/networking/driver.rst b/Documentation/networking/driver.rst index 4f5dfa9c022e..195a916dc0de 100644 --- a/Documentation/networking/driver.rst +++ b/Documentation/networking/driver.rst @@ -51,7 +51,7 @@ Instead it must maintain the queue properly. For example, { u32 used = READ_ONCE(dr->prod) - READ_ONCE(dr->cons); - return dr->tx_ring_size - (used & bp->tx_ring_mask); + return dr->tx_ring_size - (used & dr->tx_ring_mask); } static netdev_tx_t drv_hard_start_xmit(struct sk_buff *skb, @@ -69,7 +69,7 @@ Instead it must maintain the queue properly. For example, //... /* This should be a very rare race - log it. */ if (drv_tx_avail(dr) <= skb_shinfo(skb)->nr_frags + 1) { - netif_stop_queue(dev); + netif_tx_stop_queue(txq); netdev_warn(dev, "Tx Ring full when queue awake!\n"); return NETDEV_TX_BUSY; } @@ -103,6 +103,9 @@ Lockless queue stop / wake helper macros .. kernel-doc:: include/net/netdev_queues.h :doc: Lockless queue stopping / waking helpers. +The standard macros like netif_txq_maybe_stop(), netif_txq_try_stop() etc. +are well tested, prefer them over local synchronization schemes. + No exclusive ownership ---------------------- -- 2.54.0