Commit b8c43360 authored by Xiaolei Wang's avatar Xiaolei Wang Committed by Jakub Kicinski

net: stmmac: No need to calculate speed divider when offload is disabled

commit be27b896 ("net: stmmac: replace priv->speed with
the portTransmitRate from the tc-cbs parameters") introduced
a problem. When deleting, it prompts "Invalid portTransmitRate
0 (idleSlope - sendSlope)" and exits. Add judgment on cbs.enable.
Only when offload is enabled, speed divider needs to be calculated.

Fixes: be27b896 ("net: stmmac: replace priv->speed with the portTransmitRate from the tc-cbs parameters")
Signed-off-by: default avatarXiaolei Wang <xiaolei.wang@windriver.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240617013922.1035854-1-xiaolei.wang@windriver.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 40a64cc9
......@@ -358,24 +358,28 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
port_transmit_rate_kbps = qopt->idleslope - qopt->sendslope;
/* Port Transmit Rate and Speed Divider */
switch (div_s64(port_transmit_rate_kbps, 1000)) {
case SPEED_10000:
case SPEED_5000:
ptr = 32;
break;
case SPEED_2500:
case SPEED_1000:
ptr = 8;
break;
case SPEED_100:
ptr = 4;
break;
default:
netdev_err(priv->dev,
"Invalid portTransmitRate %lld (idleSlope - sendSlope)\n",
port_transmit_rate_kbps);
return -EINVAL;
if (qopt->enable) {
/* Port Transmit Rate and Speed Divider */
switch (div_s64(port_transmit_rate_kbps, 1000)) {
case SPEED_10000:
case SPEED_5000:
ptr = 32;
break;
case SPEED_2500:
case SPEED_1000:
ptr = 8;
break;
case SPEED_100:
ptr = 4;
break;
default:
netdev_err(priv->dev,
"Invalid portTransmitRate %lld (idleSlope - sendSlope)\n",
port_transmit_rate_kbps);
return -EINVAL;
}
} else {
ptr = 0;
}
mode_to_use = priv->plat->tx_queues_cfg[queue].mode_to_use;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment