]> git.itanic.dy.fi Git - linux-stable/commit
net: dsa: sja1105: fix -ENOSPC when replacing the same tc-cbs too many times
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 5 Sep 2023 21:53:37 +0000 (00:53 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Sep 2023 05:23:05 +0000 (06:23 +0100)
commit894cafc5c62ccced758077bd4e970dc714c42637
treee901d929befeb38f5d860859b6a3fc7096578fc4
parent954ad9bf13c4f95a4958b5f8433301f2ab99e1f5
net: dsa: sja1105: fix -ENOSPC when replacing the same tc-cbs too many times

After running command [2] too many times in a row:

[1] $ tc qdisc add dev sw2p0 root handle 1: mqprio num_tc 8 \
map 0 1 2 3 4 5 6 7 queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 hw 0
[2] $ tc qdisc replace dev sw2p0 parent 1:1 cbs offload 1 \
idleslope 120000 sendslope -880000 locredit -1320 hicredit 180

(aka more than priv->info->num_cbs_shapers times)

we start seeing the following error message:

Error: Specified device failed to setup cbs hardware offload.

This comes from the fact that ndo_setup_tc(TC_SETUP_QDISC_CBS) presents
the same API for the qdisc create and replace cases, and the sja1105
driver fails to distinguish between the 2. Thus, it always thinks that
it must allocate the same shaper for a {port, queue} pair, when it may
instead have to replace an existing one.

Fixes: 4d7525085a9b ("net: dsa: sja1105: offload the Credit-Based Shaper qdisc")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105_main.c