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

net: stmmac: replace priv->speed with the portTransmitRate from the tc-cbs parameters

The current cbs parameter depends on speed after uplinking,
which is not needed and will report a configuration error
if the port is not initially connected. The UAPI exposed by
tc-cbs requires userspace to recalculate the send slope anyway,
because the formula depends on port_transmit_rate (see man tc-cbs),
which is not an invariant from tc's perspective. Therefore, we
use offload->sendslope and offload->idleslope to derive the
original port_transmit_rate from the CBS formula.

Fixes: 1f705bc6 ("net: stmmac: Add support for CBS QDISC")
Signed-off-by: default avatarXiaolei Wang <xiaolei.wang@windriver.com>
Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
Link: https://lore.kernel.org/r/20240608143524.2065736-1-xiaolei.wang@windriver.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 1b9f7563
...@@ -343,10 +343,11 @@ static int tc_setup_cbs(struct stmmac_priv *priv, ...@@ -343,10 +343,11 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
struct tc_cbs_qopt_offload *qopt) struct tc_cbs_qopt_offload *qopt)
{ {
u32 tx_queues_count = priv->plat->tx_queues_to_use; u32 tx_queues_count = priv->plat->tx_queues_to_use;
s64 port_transmit_rate_kbps;
u32 queue = qopt->queue; u32 queue = qopt->queue;
u32 ptr, speed_div;
u32 mode_to_use; u32 mode_to_use;
u64 value; u64 value;
u32 ptr;
int ret; int ret;
/* Queue 0 is not AVB capable */ /* Queue 0 is not AVB capable */
...@@ -355,30 +356,26 @@ static int tc_setup_cbs(struct stmmac_priv *priv, ...@@ -355,30 +356,26 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
if (!priv->dma_cap.av) if (!priv->dma_cap.av)
return -EOPNOTSUPP; return -EOPNOTSUPP;
port_transmit_rate_kbps = qopt->idleslope - qopt->sendslope;
/* Port Transmit Rate and Speed Divider */ /* Port Transmit Rate and Speed Divider */
switch (priv->speed) { switch (div_s64(port_transmit_rate_kbps, 1000)) {
case SPEED_10000: case SPEED_10000:
ptr = 32;
speed_div = 10000000;
break;
case SPEED_5000: case SPEED_5000:
ptr = 32; ptr = 32;
speed_div = 5000000;
break; break;
case SPEED_2500: case SPEED_2500:
ptr = 8;
speed_div = 2500000;
break;
case SPEED_1000: case SPEED_1000:
ptr = 8; ptr = 8;
speed_div = 1000000;
break; break;
case SPEED_100: case SPEED_100:
ptr = 4; ptr = 4;
speed_div = 100000;
break; break;
default: default:
return -EOPNOTSUPP; netdev_err(priv->dev,
"Invalid portTransmitRate %lld (idleSlope - sendSlope)\n",
port_transmit_rate_kbps);
return -EINVAL;
} }
mode_to_use = priv->plat->tx_queues_cfg[queue].mode_to_use; mode_to_use = priv->plat->tx_queues_cfg[queue].mode_to_use;
...@@ -398,10 +395,10 @@ static int tc_setup_cbs(struct stmmac_priv *priv, ...@@ -398,10 +395,10 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
} }
/* Final adjustments for HW */ /* Final adjustments for HW */
value = div_s64(qopt->idleslope * 1024ll * ptr, speed_div); value = div_s64(qopt->idleslope * 1024ll * ptr, port_transmit_rate_kbps);
priv->plat->tx_queues_cfg[queue].idle_slope = value & GENMASK(31, 0); priv->plat->tx_queues_cfg[queue].idle_slope = value & GENMASK(31, 0);
value = div_s64(-qopt->sendslope * 1024ll * ptr, speed_div); value = div_s64(-qopt->sendslope * 1024ll * ptr, port_transmit_rate_kbps);
priv->plat->tx_queues_cfg[queue].send_slope = value & GENMASK(31, 0); priv->plat->tx_queues_cfg[queue].send_slope = value & GENMASK(31, 0);
value = qopt->hicredit * 1024ll * 8; value = qopt->hicredit * 1024ll * 8;
......
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