Skip to contentSkip to conversation

net: stmmac: check CBS input values before configuration

PATCH In review Gan Yi Fang 2 participants 3 messages Nov 1, 2023 – Nov 9, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: stmmac: check CBS input values before configuration

From: Michael Sit Wei Hong <[email protected]>

Add check for below conditions before proceeding to configuration. A message will be prompted if the input value is invalid.

Idleslope minus sendslope should equal speed_div. Idleslope is always a positive value including zero. Sendslope is always a negative value including zero. Hicredit is always a positive value including zero. Locredit is always a negative value including zero.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +5 -0
index ac41ef4cbd2f..e8a079946f84 100644
@@ -381,6 +381,11 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
 		return -EOPNOTSUPP;
 	}
 
+	if ((qopt->idleslope - qopt->sendslope != speed_div) ||
+	    qopt->idleslope < 0 || qopt->sendslope > 0 ||
+	    qopt->hicredit < 0 || qopt->locredit > 0)
+		return -EINVAL;
+
 	mode_to_use = priv->plat->tx_queues_cfg[queue].mode_to_use;
 	if (mode_to_use == MTL_QUEUE_DCB && qopt->enable) {
 		ret = stmmac_dma_qmode(priv, priv->ioaddr, queue, MTL_QUEUE_AVB);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 10 lines · Gan Yi Fang

From: Michael Sit Wei Hong <[email protected]>

Add check for below conditions before proceeding to configuration. A message will be prompted if the input value is invalid.

Idleslope minus sendslope should equal speed_div. Idleslope is always a positive value including zero. Sendslope is always a negative value including zero. Hicredit is always a positive value including zero. Locredit is always a negative value including zero.

Which of these conditional are specific to stmmac, and which are generic to CBS? Anything which is generic to CBS i would expect to be checked at a higher level, rather than in every driver implementing CBS.

Andrew

#2 lore raw

Hi Andrew,

The values are not specific to stmmac driver.
It is more making sense to implement the checking at higher level. Let's close the review for this patch.

Best Regards,
Fang

Quoted 34 lines

-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: Wednesday, November 1, 2023 8:36 PM
To: Gan, Yi Fang <[email protected]>
Cc: Alexandre Torgue <[email protected]>; Jose Abreu <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Maxime Coquelin <[email protected]>; [email protected]; linux-stm32@st-md- mailman.stormreply.com; [email protected]; linux- [email protected]; Looi, Hong Aun <[email protected]>; Voon, Weifeng <[email protected]>; Song, Yoong Siang <[email protected]>; Sit, Michael Wei Hong <[email protected]>
Subject: Re: [PATCH net-next v2 1/1] net: stmmac: check CBS input values before configuration

Quoted 10 lines · Gan Yi Fang

From: Michael Sit Wei Hong <[email protected]>

Add check for below conditions before proceeding to configuration. A message will be prompted if the input value is invalid.

Idleslope minus sendslope should equal speed_div. Idleslope is always a positive value including zero. Sendslope is always a negative value including zero. Hicredit is always a positive value including zero. Locredit is always a negative value including zero.

Which of these conditional are specific to stmmac, and which are generic to CBS? Anything which is generic to CBS i would expect to be checked at a higher level, rather than in every driver implementing CBS.

Andrew