* [PATCH net-next v2 1/1] net: stmmac: check CBS input values before configuration
@ 2023-11-01 6:19 Gan Yi Fang
2023-11-01 12:36 ` Andrew Lunn
0 siblings, 1 reply; 3+ messages in thread
From: Gan Yi Fang @ 2023-11-01 6:19 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, netdev, linux-stm32,
linux-arm-kernel, linux-kernel
Cc: Looi Hong Aun, Voon Weifeng, Song Yoong Siang,
Michael Sit Wei Hong, Gan Yi Fang
From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.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 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.
Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>
Signed-off-by: Gan, Yi Fang <yi.fang.gan@intel.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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next v2 1/1] net: stmmac: check CBS input values before configuration
2023-11-01 6:19 [PATCH net-next v2 1/1] net: stmmac: check CBS input values before configuration Gan Yi Fang
@ 2023-11-01 12:36 ` Andrew Lunn
2023-11-09 5:08 ` Gan, Yi Fang
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2023-11-01 12:36 UTC (permalink / raw)
To: Gan Yi Fang
Cc: Alexandre Torgue, Jose Abreu, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, netdev, linux-stm32,
linux-arm-kernel, linux-kernel, Looi Hong Aun, Voon Weifeng,
Song Yoong Siang, Michael Sit Wei Hong
On Wed, Nov 01, 2023 at 02:19:20PM +0800, Gan Yi Fang wrote:
> From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.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 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH net-next v2 1/1] net: stmmac: check CBS input values before configuration
2023-11-01 12:36 ` Andrew Lunn
@ 2023-11-09 5:08 ` Gan, Yi Fang
0 siblings, 0 replies; 3+ messages in thread
From: Gan, Yi Fang @ 2023-11-09 5:08 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Jose Abreu, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Looi, Hong Aun, Voon, Weifeng,
Song, Yoong Siang, Sit, Michael Wei Hong
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
> -----Original Message-----
> From: Andrew Lunn <andrew@lunn.ch>
> Sent: Wednesday, November 1, 2023 8:36 PM
> To: Gan, Yi Fang <yi.fang.gan@intel.com>
> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>; Jose Abreu
> <joabreu@synopsys.com>; David S . Miller <davem@davemloft.net>; Eric
> Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo
> Abeni <pabeni@redhat.com>; Maxime Coquelin
> <mcoquelin.stm32@gmail.com>; netdev@vger.kernel.org; linux-stm32@st-md-
> mailman.stormreply.com; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org; Looi, Hong Aun <hong.aun.looi@intel.com>; Voon,
> Weifeng <weifeng.voon@intel.com>; Song, Yoong Siang
> <yoong.siang.song@intel.com>; Sit, Michael Wei Hong
> <michael.wei.hong.sit@intel.com>
> Subject: Re: [PATCH net-next v2 1/1] net: stmmac: check CBS input values
> before configuration
>
> On Wed, Nov 01, 2023 at 02:19:20PM +0800, Gan Yi Fang wrote:
> > From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.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 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-09 5:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-01 6:19 [PATCH net-next v2 1/1] net: stmmac: check CBS input values before configuration Gan Yi Fang
2023-11-01 12:36 ` Andrew Lunn
2023-11-09 5:08 ` Gan, Yi Fang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox