Skip to content

Commit

Permalink
net: stmmac: No need to calculate speed divider when offload is disabled
Browse files Browse the repository at this point in the history
commit be27b89 ("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: be27b89 ("net: stmmac: replace priv->speed with the portTransmitRate from the tc-cbs parameters")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240617013922.1035854-1-xiaolei.wang@windriver.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Xiaolei Wang authored and Jakub Kicinski committed Jun 19, 2024
1 parent 40a64cc commit b8c4336
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b8c4336

Please sign in to comment.