linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 1/1] net: stmmac: update MAC capabilities when tx queues are updated
@ 2023-10-18  2:31 Gan, Yi Fang
  2023-10-18  7:25 ` Russell King (Oracle)
  0 siblings, 1 reply; 4+ messages in thread
From: Gan, Yi Fang @ 2023-10-18  2:31 UTC (permalink / raw)
  To: Alexandre Torgue, Jose Abreu, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Russell King,
	Ong Boon Leong, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel
  Cc: Michael Sit Wei Hong, Looi Hong Aun, Voon Weifeng,
	Song Yoong Siang, Gan Yi Fang

From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>

Upon boot up, the driver will configure the MAC capabilities based on
the maximum number of tx and rx queues. When the user changes the
tx queues to single queue, the MAC should be capable of supporting Half
Duplex, but the driver does not update the MAC capabilities when it is
configured so.

Using the stmmac_reinit_queues() to check the number of tx queues
and set the MAC capabilities accordingly.

Fixes: 0366f7e06a6b ("net: stmmac: add ethtool support for get/set channels")
Cc: <stable@vger.kernel.org> # 5.17+
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_main.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index ed1a5a31a491..7ddc33fa0cb5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -7172,6 +7172,14 @@ int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt)
 			priv->rss.table[i] = ethtool_rxfh_indir_default(i,
 									rx_cnt);
 
+	/* Half-Duplex can only work with single tx queue */
+	if (priv->plat->tx_queues_to_use > 1)
+		priv->phylink_config.mac_capabilities &=
+			~(MAC_10HD | MAC_100HD | MAC_1000HD);
+	else
+		priv->phylink_config.mac_capabilities |=
+			(MAC_10HD | MAC_100HD | MAC_1000HD);
+
 	stmmac_napi_add(dev);
 
 	if (netif_running(dev))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 1/1] net: stmmac: update MAC capabilities when tx queues are updated
  2023-10-18  2:31 [PATCH net 1/1] net: stmmac: update MAC capabilities when tx queues are updated Gan, Yi Fang
@ 2023-10-18  7:25 ` Russell King (Oracle)
  2023-10-19 10:24   ` Paolo Abeni
  0 siblings, 1 reply; 4+ messages in thread
From: Russell King (Oracle) @ 2023-10-18  7:25 UTC (permalink / raw)
  To: Gan, Yi Fang
  Cc: Alexandre Torgue, Jose Abreu, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Ong Boon Leong,
	netdev, linux-stm32, linux-arm-kernel, linux-kernel,
	Michael Sit Wei Hong, Looi Hong Aun, Voon Weifeng,
	Song Yoong Siang

On Wed, Oct 18, 2023 at 10:31:36AM +0800, Gan, Yi Fang wrote:
> From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>
> 
> Upon boot up, the driver will configure the MAC capabilities based on
> the maximum number of tx and rx queues. When the user changes the
> tx queues to single queue, the MAC should be capable of supporting Half
> Duplex, but the driver does not update the MAC capabilities when it is
> configured so.
> 
> Using the stmmac_reinit_queues() to check the number of tx queues
> and set the MAC capabilities accordingly.

There is other setup elsewhere in the driver that fiddles with this in
stmmac_phy_setup(). Maybe provide a helper function so that this
decision making can be made in one function called from both these
locations, so if the decision making for HD support changes, only one
place needs changing?

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net 1/1] net: stmmac: update MAC capabilities when tx queues are updated
  2023-10-18  7:25 ` Russell King (Oracle)
@ 2023-10-19 10:24   ` Paolo Abeni
  2023-10-20  3:33     ` Gan, Yi Fang
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Abeni @ 2023-10-19 10:24 UTC (permalink / raw)
  To: Russell King (Oracle), Gan, Yi Fang
  Cc: Alexandre Torgue, Jose Abreu, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Maxime Coquelin, Ong Boon Leong, netdev,
	linux-stm32, linux-arm-kernel, linux-kernel,
	Michael Sit Wei Hong, Looi Hong Aun, Voon Weifeng,
	Song Yoong Siang

On Wed, 2023-10-18 at 08:25 +0100, Russell King (Oracle) wrote:
> On Wed, Oct 18, 2023 at 10:31:36AM +0800, Gan, Yi Fang wrote:
> > From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>
> > 
> > Upon boot up, the driver will configure the MAC capabilities based on
> > the maximum number of tx and rx queues. When the user changes the
> > tx queues to single queue, the MAC should be capable of supporting Half
> > Duplex, but the driver does not update the MAC capabilities when it is
> > configured so.
> > 
> > Using the stmmac_reinit_queues() to check the number of tx queues
> > and set the MAC capabilities accordingly.
> 
> There is other setup elsewhere in the driver that fiddles with this in
> stmmac_phy_setup(). Maybe provide a helper function so that this
> decision making can be made in one function called from both these
> locations, so if the decision making for HD support changes, only one
> place needs changing?

Indeed that looks both straight-forward and more robust.

@Gan, Yi Fang: please send a v2 introducing and using such helper,
thanks!

Paolo


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH net 1/1] net: stmmac: update MAC capabilities when tx queues are updated
  2023-10-19 10:24   ` Paolo Abeni
@ 2023-10-20  3:33     ` Gan, Yi Fang
  0 siblings, 0 replies; 4+ messages in thread
From: Gan, Yi Fang @ 2023-10-20  3:33 UTC (permalink / raw)
  To: Paolo Abeni, Russell King (Oracle)
  Cc: Alexandre Torgue, Jose Abreu, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Maxime Coquelin, Ong, Boon Leong, netdev,
	linux-stm32, linux-arm-kernel, linux-kernel, Sit,
	Michael Wei Hong, Looi, Hong Aun, Voon, Weifeng, Song,
	Yoong Siang

Hi Russell King and Paolo,

Thank you for the feedbacks. I already submit V2 with the helper.

BR,
Fang

> -----Original Message-----
> From: Paolo Abeni <pabeni@redhat.com>
> Sent: Thursday, October 19, 2023 6:25 PM
> To: Russell King (Oracle) <linux@armlinux.org.uk>; 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>;
> Maxime Coquelin <mcoquelin.stm32@gmail.com>; Ong, Boon Leong
> <boon.leong.ong@intel.com>; netdev@vger.kernel.org; linux-stm32@st-md-
> mailman.stormreply.com; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org; Sit, Michael Wei Hong
> <michael.wei.hong.sit@intel.com>; Looi, Hong Aun <hong.aun.looi@intel.com>;
> Voon, Weifeng <weifeng.voon@intel.com>; Song, Yoong Siang
> <yoong.siang.song@intel.com>
> Subject: Re: [PATCH net 1/1] net: stmmac: update MAC capabilities when tx
> queues are updated
> 
> On Wed, 2023-10-18 at 08:25 +0100, Russell King (Oracle) wrote:
> > On Wed, Oct 18, 2023 at 10:31:36AM +0800, Gan, Yi Fang wrote:
> > > From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>
> > >
> > > Upon boot up, the driver will configure the MAC capabilities based
> > > on the maximum number of tx and rx queues. When the user changes the
> > > tx queues to single queue, the MAC should be capable of supporting
> > > Half Duplex, but the driver does not update the MAC capabilities
> > > when it is configured so.
> > >
> > > Using the stmmac_reinit_queues() to check the number of tx queues
> > > and set the MAC capabilities accordingly.
> >
> > There is other setup elsewhere in the driver that fiddles with this in
> > stmmac_phy_setup(). Maybe provide a helper function so that this
> > decision making can be made in one function called from both these
> > locations, so if the decision making for HD support changes, only one
> > place needs changing?
> 
> Indeed that looks both straight-forward and more robust.
> 
> @Gan, Yi Fang: please send a v2 introducing and using such helper, thanks!
> 
> Paolo


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-20  3:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-18  2:31 [PATCH net 1/1] net: stmmac: update MAC capabilities when tx queues are updated Gan, Yi Fang
2023-10-18  7:25 ` Russell King (Oracle)
2023-10-19 10:24   ` Paolo Abeni
2023-10-20  3:33     ` 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;
as well as URLs for NNTP newsgroup(s).