From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Serge Semin <fancer.lancer@gmail.com>
Cc: Yanteng Si <siyanteng@loongson.cn>,
andrew@lunn.ch, hkallweit1@gmail.com, peppe.cavallaro@st.com,
alexandre.torgue@foss.st.com, joabreu@synopsys.com,
Jose.Abreu@synopsys.com, chenhuacai@loongson.cn,
guyinggang@loongson.cn, netdev@vger.kernel.org,
chris.chenfeiyang@gmail.com
Subject: Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex
Date: Wed, 20 Mar 2024 10:37:00 +0000 [thread overview]
Message-ID: <Zfq8TNrt0KxW/IWh@shell.armlinux.org.uk> (raw)
In-Reply-To: <em3r6w7ydvjxualqifjurtrrfpztpil564t5k5b4kxv4f6ddrd@4weteqhekyae>
Serge,
Again, please learn to trim your replies.
On Wed, Mar 20, 2024 at 01:10:04PM +0300, Serge Semin wrote:
> > > As to this approach, I don't think it's a good model to override the
> > > stmmac MAC operations. Instead, I would suggest that a better approach
> > > would be for the platform to provide its capabilities to the stmmac
> > > core code (maybe a new member in stmmac_priv) which, when set, is used
> > > to reduce the capabilities provided to phylink via
> > > priv->phylink_config.mac_capabilities.
> > >
> > > Why? The driver has several components that are involved in the
> > > overall capabilities, and the capabilities of the system is the
> > > logical subset of all these capabilities. One component should not
> > > be setting capabilities that a different component doesn't support.
>
> In general you are right for sure - it's better to avoid one part
> setting capabilities and another part unsetting them at least from the
> readability and maintainability point of view. But in this case we've
> already got implemented a ready-to-use internal interface
> stmmac_ops::phylink_get_caps() which can be used to extend/reduce the
> capabilities field based on the particular MAC abilities. Moreover
> it's called right from the component setting the capabilities. Are you
> saying that the callback is supposed to be utilized for extending the
> capabilities only?
What concerns me is that the proposed code _overwrites_ the
capabilities from the MAC layer, so from a maintanability point of
view it's a nightmare, because you will now have the situation where
MACs provide their capabilities, and then platform code may overwrite
it - which means it's like a spiders web trying to work out what
capabilities are provided.
The reality is surely that the MAC dictates what it can do, but there
may be further restrictions by other components in the platform, so
the capabilities provided to phylink should be:
mac_capabilities & platform_capabilities
And what I'm proposing is that _that_ should be done in a way that
makes it _easy_ for the platform code to get right. Overriding
stmmac_ops::phylink_get_caps() doesn't do that - as can be seen in
the proposed patch.
Help your users write correct code by adopting a structure that makes
it easy for them to do the right thing.
> If you insist on not overriding the stmmac_ops::phylink_get_caps()
> anyway then please explain what is the principal difference
> between the next two code snippets:
> /* Get the MAC specific capabilities */
> stmmac_mac_phylink_get_caps(priv);
> and
> priv->phylink_config.mac_capabilities &= ~priv->plat->mac_caps_mask;
I was thinking:
stmmac_mac_phylink_get_caps(priv);
if (priv->plat->mac_capabilities)
priv->phylink_config.mac_capabilities &=
priv->plat->mac_capabilities;
In other words, if a platform sets plat->mac_capabilities, then it is
providing the capabilities that it supports, and those need to reduce
the capabilities provided by the MAC.
This will _also_ allow stmmac_set_half_duplex() to do the right thing.
Consider something in the platform side that doesn't allow half-duplex,
but allows tx_queues_to_use == 1. That'll set the half-duplex modes
when stmmac_set_half_duplex() is called, overriding what the platform
supports.
Now that I look at the stmmac implementation, there's even more that
is wrong. Consider plat->max_speed = 100, like
arch/arc/boot/dts/axs10x_mb.dtsi sets. If stmmac_set_half_duplex()
is called as it can be from stmmac_reinit_queues(), it'll enable
1000 half-duplex, despite the plat->max_speed = 100.
> in the MAC-capabilities update implementation? Do you think the later
> approach would be more descriptive? If so then would the
> callback-based approach almost equally descriptive if the callback
> name was, suppose, stmmac_mac_phylink_set_caps() or similar?
From what I can see of the existing stmmac MAC phylink_get_caps
implementations, there seem to be two - xgmac_phylink_get_caps()
and dwmac4_phylink_get_caps(). Both of these merely set additional
modes in priv->phylink_config.mac_capabilities. Is there a reason
to have this as an instruction stream, rather than providing data
to the core stmmac code from the MAC about its capabilities? Is
there a reason why it would be necessary for the code in a MAC backend
to make a decision about what capabilities to enable based on some
condition?
> In anyway I am sure the approach suggested in the initial patch of
> this thread isn't good since it motivates the developers to implement
> more-and-more DW MAC-specific platform capabilities flags fixing
> another flags, which makes the generic code even more complicated
> than it already is with endless if-else-plat-flags statements.
Yes, I do agree with that.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2024-03-20 10:37 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-30 8:43 [PATCH net-next v8 00/11] stmmac: Add Loongson platform support Yanteng Si
2024-01-30 8:43 ` [PATCH net-next v8 01/11] net: stmmac: Add multi-channel support Yanteng Si
2024-02-02 12:30 ` Simon Horman
2024-02-04 8:43 ` Yanteng Si
2024-02-04 23:28 ` Serge Semin
2024-02-06 9:02 ` Yanteng Si
2024-02-06 9:48 ` Serge Semin
2024-02-19 11:02 ` Yanteng Si
2024-02-21 13:48 ` Serge Semin
[not found] ` <ee2ffb6a-fe34-47a1-9734-b0e6697a5f09@loongson.cn>
2024-03-13 9:10 ` Yanteng Si
2024-03-19 14:18 ` Serge Semin
2024-03-20 9:47 ` Yanteng Si
2024-03-20 9:55 ` Russell King (Oracle)
2024-03-20 10:51 ` Yanteng Si
2024-02-05 1:11 ` Serge Semin
2024-01-30 8:43 ` [PATCH net-next v8 02/11] net: stmmac: dwmac-loongson: Refactor code for loongson_dwmac_probe() Yanteng Si
2024-02-02 12:33 ` Simon Horman
2024-02-04 8:47 ` Yanteng Si
2024-02-05 14:43 ` Serge Semin
2024-04-05 11:13 ` Yanteng Si
2024-01-30 8:43 ` [PATCH net-next v8 03/11] net: stmmac: dwmac-loongson: Add full PCI support Yanteng Si
2024-02-05 16:49 ` Serge Semin
2024-02-21 10:08 ` Yanteng Si
2024-01-30 8:43 ` [PATCH net-next v8 04/11] net: stmmac: dwmac-loongson: Move irq config to loongson_gmac_config Yanteng Si
2024-02-05 17:01 ` Serge Semin
2024-03-13 8:14 ` Yanteng Si
2024-03-19 13:43 ` Serge Semin
2024-03-20 10:12 ` Yanteng Si
2024-01-30 8:48 ` [PATCH net-next v8 05/11] net: stmmac: dwmac-loongson: Add Loongson-specific register definitions Yanteng Si
2024-02-05 18:17 ` Serge Semin
2024-02-22 13:39 ` Yanteng Si
2024-02-22 13:59 ` Serge Semin
2024-02-23 8:16 ` Yanteng Si
2024-02-23 18:50 ` Serge Semin
2024-03-07 13:15 ` Yanteng Si
2024-03-07 13:44 ` Serge Semin
2024-03-08 4:05 ` Yanteng Si
2024-01-30 8:48 ` [PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support Yanteng Si
2024-02-05 20:58 ` Serge Semin
[not found] ` <d0e56c9b-9549-4061-8e44-2504b6b96897@loongson.cn>
2024-03-14 13:12 ` Yanteng Si
2024-03-19 15:03 ` Serge Semin
2024-03-20 10:23 ` Yanteng Si
2024-03-20 12:18 ` Serge Semin
2024-03-21 9:13 ` Yanteng Si
2024-03-21 14:55 ` Andrew Lunn
2024-03-28 11:41 ` Yanteng Si
2024-03-22 19:09 ` Serge Semin
2024-01-30 8:48 ` [PATCH net-next v8 07/11] net: stmmac: dwmac-loongson: Add multi-channel supports for loongson Yanteng Si
2024-02-05 21:28 ` Serge Semin
[not found] ` <e1c7b5fa-f3f8-4aa3-af4d-ca72b54d9c8c@loongson.cn>
2024-03-14 13:13 ` Yanteng Si
2024-03-19 15:53 ` Serge Semin
2024-03-22 10:36 ` Yanteng Si
2024-03-22 18:47 ` Serge Semin
2024-04-03 8:09 ` Yanteng Si
2024-04-03 12:03 ` Serge Semin
2024-04-05 10:17 ` Yanteng Si
2024-04-03 8:23 ` Yanteng Si
2024-01-30 8:48 ` [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET Yanteng Si
2024-02-05 21:55 ` Serge Semin
[not found] ` <4873ea5a-1b23-4512-b039-0a9198b53adf@loongson.cn>
2024-03-14 13:18 ` Yanteng Si
2024-03-19 17:02 ` Serge Semin
2024-03-20 10:42 ` Yanteng Si
2024-03-21 9:29 ` Yanteng Si
2024-03-21 15:02 ` Andrew Lunn
2024-03-21 15:19 ` Russell King (Oracle)
2024-03-21 15:38 ` Andrew Lunn
2024-03-26 12:32 ` Yanteng Si
2024-03-26 12:02 ` Yanteng Si
2024-03-26 12:21 ` Andrew Lunn
2024-03-27 2:41 ` Yanteng Si
2024-03-27 12:47 ` Andrew Lunn
2024-03-28 10:08 ` Yanteng Si
2024-01-30 8:49 ` [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex Yanteng Si
2024-02-05 21:58 ` Serge Semin
2024-02-05 22:06 ` Serge Semin
2024-03-13 9:24 ` Yanteng Si
2024-03-13 10:21 ` Russell King (Oracle)
2024-03-14 13:08 ` Yanteng Si
2024-03-20 10:10 ` Serge Semin
2024-03-20 10:37 ` Russell King (Oracle) [this message]
2024-03-20 12:50 ` Russell King (Oracle)
2024-03-20 14:22 ` Russell King (Oracle)
2024-03-22 18:07 ` Serge Semin
2024-03-22 19:56 ` Russell King (Oracle)
2024-04-03 12:37 ` Serge Semin
2024-04-05 10:48 ` Yanteng Si
2024-01-30 8:49 ` [PATCH net-next v8 10/11] net: stmmac: dwmac-loongson: Disable flow control for GMAC Yanteng Si
2024-02-05 22:13 ` Serge Semin
2024-03-13 9:25 ` Yanteng Si
2024-01-30 8:49 ` [PATCH net-next v8 11/11] net: stmmac: dwmac-loongson: Disable coe for some Loongson GNET Yanteng Si
2024-02-05 22:18 ` Serge Semin
2024-03-13 9:52 ` Yanteng Si
2024-03-13 10:19 ` Yanteng Si
2024-03-20 11:24 ` Serge Semin
2024-01-30 9:57 ` [PATCH net-next v8 00/11] stmmac: Add Loongson platform support Serge Semin
2024-01-31 2:10 ` Jakub Kicinski
2024-01-31 9:20 ` Yanteng Si
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zfq8TNrt0KxW/IWh@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=Jose.Abreu@synopsys.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew@lunn.ch \
--cc=chenhuacai@loongson.cn \
--cc=chris.chenfeiyang@gmail.com \
--cc=fancer.lancer@gmail.com \
--cc=guyinggang@loongson.cn \
--cc=hkallweit1@gmail.com \
--cc=joabreu@synopsys.com \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.com \
--cc=siyanteng@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).