Skip to content

Commit 2487768

Browse files
yoongsiang2kuba-moo
authored andcommitted
net: stmmac: fix CBS idleslope and sendslope calculation
When link speed is not 100 Mbps, port transmit rate and speed divider are set to 8 and 1000000 respectively. These values are incorrect for CBS idleslope and sendslope HW values calculation if the link speed is not 1 Gbps. This patch adds switch statement to set the values of port transmit rate and speed divider for 10 Gbps, 5 Gbps, 2.5 Gbps, 1 Gbps, and 100 Mbps. Note that CBS is not supported at 10 Mbps. Fixes: bc41a66 ("net: stmmac: tc: Remove the speed dependency") Fixes: 1f705bc ("net: stmmac: Add support for CBS QDISC") Signed-off-by: Song, Yoong Siang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e5bcf0e commit 2487768

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,32 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
316316
if (!priv->dma_cap.av)
317317
return -EOPNOTSUPP;
318318

319+
/* Port Transmit Rate and Speed Divider */
320+
switch (priv->speed) {
321+
case SPEED_10000:
322+
ptr = 32;
323+
speed_div = 10000000;
324+
break;
325+
case SPEED_5000:
326+
ptr = 32;
327+
speed_div = 5000000;
328+
break;
329+
case SPEED_2500:
330+
ptr = 8;
331+
speed_div = 2500000;
332+
break;
333+
case SPEED_1000:
334+
ptr = 8;
335+
speed_div = 1000000;
336+
break;
337+
case SPEED_100:
338+
ptr = 4;
339+
speed_div = 100000;
340+
break;
341+
default:
342+
return -EOPNOTSUPP;
343+
}
344+
319345
mode_to_use = priv->plat->tx_queues_cfg[queue].mode_to_use;
320346
if (mode_to_use == MTL_QUEUE_DCB && qopt->enable) {
321347
ret = stmmac_dma_qmode(priv, priv->ioaddr, queue, MTL_QUEUE_AVB);
@@ -332,10 +358,6 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
332358
priv->plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB;
333359
}
334360

335-
/* Port Transmit Rate and Speed Divider */
336-
ptr = (priv->speed == SPEED_100) ? 4 : 8;
337-
speed_div = (priv->speed == SPEED_100) ? 100000 : 1000000;
338-
339361
/* Final adjustments for HW */
340362
value = div_s64(qopt->idleslope * 1024ll * ptr, speed_div);
341363
priv->plat->tx_queues_cfg[queue].idle_slope = value & GENMASK(31, 0);

0 commit comments

Comments
 (0)