2023-10-18 02:35:31

by Gan, Yi Fang

[permalink] [raw]
Subject: [PATCH net 1/1] net: stmmac: update MAC capabilities when tx queues are updated

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

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: <[email protected]> # 5.17+
Signed-off-by: Michael Sit Wei Hong <[email protected]>
Signed-off-by: Gan, Yi Fang <[email protected]>
---
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


2023-10-18 07:26:59

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH net 1/1] net: stmmac: update MAC capabilities when tx queues are updated

On Wed, Oct 18, 2023 at 10:31:36AM +0800, Gan, Yi Fang wrote:
> From: Michael Sit Wei Hong <[email protected]>
>
> 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!

2023-10-19 10:26:01

by Paolo Abeni

[permalink] [raw]
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 <[email protected]>
> >
> > 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

2023-10-20 03:33:42

by Gan, Yi Fang

[permalink] [raw]
Subject: RE: [PATCH net 1/1] net: stmmac: update MAC capabilities when tx queues are updated

Hi Russell King and Paolo,

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

BR,
Fang

> -----Original Message-----
> From: Paolo Abeni <[email protected]>
> Sent: Thursday, October 19, 2023 6:25 PM
> To: Russell King (Oracle) <[email protected]>; 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]>;
> Maxime Coquelin <[email protected]>; Ong, Boon Leong
> <[email protected]>; [email protected]; linux-stm32@st-md-
> mailman.stormreply.com; [email protected]; linux-
> [email protected]; Sit, Michael Wei Hong
> <[email protected]>; Looi, Hong Aun <[email protected]>;
> Voon, Weifeng <[email protected]>; Song, Yoong Siang
> <[email protected]>
> 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 <[email protected]>
> > >
> > > 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