[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231027061114.3792619-1-yi.fang.gan@intel.com>
Date: Fri, 27 Oct 2023 14:11:14 +0800
From: Gan Yi Fang <yi.fang.gan@...el.com>
To: Alexandre Torgue <alexandre.torgue@...s.st.com>,
Jose Abreu <joabreu@...opsys.com>,
"David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
netdev@...r.kernel.org,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Cc: Looi Hong Aun <hong.aun.looi@...el.com>,
Voon Weifeng <weifeng.voon@...el.com>,
Song Yoong Siang <yoong.siang.song@...el.com>,
Michael Sit Wei Hong <michael.wei.hong.sit@...el.com>,
Gan Yi Fang <yi.fang.gan@...el.com>
Subject: [PATCH net-next 1/1] net: stmmac: check CBS input values before configuration
From: Michael Sit Wei Hong <michael.wei.hong.sit@...el.com>
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.
Sendslope is always a negative value.
Hicredit is always a positive value.
Locredit is always a negative value.
Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@...el.com>
Signed-off-by: Gan, Yi Fang <yi.fang.gan@...el.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
index ac41ef4cbd2f..e8a079946f84 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
@@ -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);
--
2.34.1
Powered by blists - more mailing lists