[PATCH net-next] net: stmmac: improve TSO/GSO queue selection
Lorenzo Bianconi
lorenzo.bianconi at oss.qualcomm.com
Fri Aug 7 05:43:01 PDT 2026
GSO (TSO/USO) frames are currently always sent through queue 0 since
the driver assumed there was no way to determine which queues are TSO
capable. This unconditionally pins all GSO traffic to queue 0, bypassing
the per-flow queue distribution and any XPS setup.
Instead, pick the queue through netdev_pick_tx() and only fall back to
queue 0 when the selected queue cannot run TSO, i.e. when TBS is enabled
on it, since TSO and TBS cannot coexist on the same channel (see
stmmac_tso_channel_permitted()).
While at it, base the check on priv->gso_enabled_types rather than a
hardcoded GSO type mask, so it matches the TSO/USO capability actually
used by the transmit path (e.g. UDP segmentation is only offloaded on
GMAC4).
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi at oss.qualcomm.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b2b7d0242dd3..99fc7313f247 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -6445,19 +6445,18 @@ static int stmmac_setup_tc(struct net_device *ndev, enum tc_setup_type type,
static u16 stmmac_select_queue(struct net_device *dev, struct sk_buff *skb,
struct net_device *sb_dev)
{
- int gso = skb_shinfo(skb)->gso_type;
+ u32 queue = netdev_pick_tx(dev, skb, NULL) % dev->real_num_tx_queues;
+ struct stmmac_priv *priv = netdev_priv(dev);
- if (gso & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6 | SKB_GSO_UDP_L4)) {
- /*
- * There is no way to determine the number of TSO/USO
- * capable Queues. Let's use always the Queue 0
- * because if TSO/USO is supported then at least this
- * one will be capable.
+ if ((skb_shinfo(skb)->gso_type & priv->gso_enabled_types) &&
+ !stmmac_tso_channel_permitted(priv, queue)) {
+ /* GSO frames need HW TSO/USO, which cannot run on TBS queues.
+ * Fall back to the queue reserved for TSO (queue 0).
*/
return 0;
}
- return netdev_pick_tx(dev, skb, NULL) % dev->real_num_tx_queues;
+ return queue;
}
static int stmmac_set_mac_address(struct net_device *ndev, void *addr)
---
base-commit: 4fa4977a0d900f936bcae5cd2c510be5554e8dd6
change-id: 20260807-stmmac_select_queue-tso-fix-06cc586d4022
Best regards,
--
Lorenzo Bianconi <lorenzo.bianconi at oss.qualcomm.com>
More information about the linux-arm-kernel
mailing list