]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
netdevsim: implement peer queue flow control
authorBreno Leitao <leitao@debian.org>
Fri, 11 Jul 2025 17:06:59 +0000 (10:06 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 15 Jul 2025 00:36:50 +0000 (17:36 -0700)
commitff2ac4df58adb6d7721bb0ce6069e1bd0e613126
tree7b16726c806611ab3afa1213638e39ed885831af
parent5777d1871bf69d435e57e639fcf132d2d0c00883
netdevsim: implement peer queue flow control

Add flow control mechanism between paired netdevsim devices to stop the
TX queue during high traffic scenarios. When a receive queue becomes
congested (approaching NSIM_RING_SIZE limit), the corresponding transmit
queue on the peer device is stopped using netif_subqueue_try_stop().

Once the receive queue has sufficient capacity again, the peer's
transmit queue is resumed with netif_tx_wake_queue().

Key changes:
  * Add nsim_stop_peer_tx_queue() to pause peer TX when RX queue is full
  * Add nsim_start_peer_tx_queue() to resume peer TX when RX queue drains
  * Implement queue mapping validation to ensure TX/RX queue count match
  * Wake all queues during device unlinking to prevent stuck queues
  * Use RCU protection when accessing peer device references
  * wake the queues when changing the queue numbers
  * Remove IFF_NO_QUEUE given it will enqueue packets now

The flow control only activates when devices have matching TX/RX queue
counts to ensure proper queue mapping.

Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20250711-netdev_flow_control-v3-1-aa1d5a155762@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/netdevsim/bus.c
drivers/net/netdevsim/ethtool.c
drivers/net/netdevsim/netdev.c