From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Ioana Ciornei <ioana.ciornei@nxp.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"davem@davemloft.net" <davem@davemloft.net>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Alexandru Marginean <alexandru.marginean@nxp.com>,
"michael@walle.cc" <michael@walle.cc>,
"andrew@lunn.ch" <andrew@lunn.ch>,
"f.fainelli@gmail.com" <f.fainelli@gmail.com>
Subject: Re: [PATCH net-next 4/5] net: phy: add Lynx PCS MDIO module
Date: Thu, 18 Jun 2020 17:55:10 +0100 [thread overview]
Message-ID: <20200618165510.GG1551@shell.armlinux.org.uk> (raw)
In-Reply-To: <VI1PR0402MB387191C53CE915E5AC060669E09B0@VI1PR0402MB3871.eurprd04.prod.outlook.com>
On Thu, Jun 18, 2020 at 04:17:56PM +0000, Ioana Ciornei wrote:
> > > +struct mdio_lynx_pcs *mdio_lynx_pcs_create(struct mdio_device
> > > +*mdio_dev) {
> > > + struct mdio_lynx_pcs *pcs;
> > > +
> > > + if (WARN_ON(!mdio_dev))
> > > + return NULL;
> > > +
> > > + pcs = kzalloc(sizeof(*pcs), GFP_KERNEL);
> > > + if (!pcs)
> > > + return NULL;
> > > +
> > > + pcs->dev = mdio_dev;
> > > + pcs->an_restart = lynx_pcs_an_restart;
> > > + pcs->get_state = lynx_pcs_get_state;
> > > + pcs->link_up = lynx_pcs_link_up;
> > > + pcs->config = lynx_pcs_config;
> >
> > We really should not have these private structure interfaces. Private structure-
> > based driver specific interfaces really don't constitute a sane approach to
> > interface design.
> >
> > Would it work if there was a "struct mdio_device" add to the phylink_config
> > structure, and then you could have the phylink_pcs_ops embedded into this
> > driver?
>
> I think that would restrict too much the usage.
> I am afraid there will be instances where the PCS is not recognizable by PHY_ID,
> thus no way of knowing which driver to probe which mdio_device.
> Also, I would leave to the driver the choice of using (or not) the functions
> exported by Lynx.
I think you've taken my point way too far. What I'm complaining about
is the indirection of lynx_pcs_an_restart() et.al. through a driver-
private structure.
In order to access lynx_pcs_an_restart(), we need to dereference
struct mdio_lynx_pcs, which is a structure specific to this lynx PCS
driver. What this leads to is users doing this:
if (pcs_is_lynx) {
struct mdio_lynx_pcs *pcs = foo->bar;
pcs->an_restart(...);
} else if (pcs_is_something_else) {
struct mdio_somethingelse_pcs *pcs = foo->bar;
pcs->an_restart(...);
}
which really does not scale. A step forward would be:
if (pcs_is_lynx) {
lynx_pcs_an_restart(...);
} else if (pcs_is_something_else) {
something_else_pcs_an_restart(...);
}
but that also scales horribly.
Even better would be to have a generic set of operations for PCS
devices that can be declared in the lynx PCS driver and used
externally... like, maybe struct phylink_pcs_ops, which is made
globally visible for MAC drivers to use with phylink_add_pcs().
Or maybe a function in this lynx PCS driver that calls phylink_add_pcs()
itself with its own PCS operations, and maybe also sets a field in
struct phylink_config for the PCS mdio device?
Or something like that - just some a way that doesn't force us down
a path that we end up forcing people into code that has to decide
what sort of PCS we have at runtime in all these method paths.
> What if we directly export the helper functions directly as symbols which can
> be used by the driver without any mdio_lynx_pcs in the middle
> (just the mdio_device passed to the function).
> This would be exactly as phylink_mii_c22_pcs_[an_restart/config] are currently
> used.
The difference is that phylink_mii_c22_pcs_* are designed as library
functions - functions that are very likely to be re-used for multiple
different PCS (because the format, location, and access method of
these registers is defined by IEEE 802.3). It's a bit like phylib's
configuration of autoneg - we don't have all the individual drivers
doing that, we have core code that does that for us in the form of
helpers.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2020-06-18 16:55 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-18 12:08 [PATCH net-next 0/5] net: phy: add Lynx PCS MDIO module Ioana Ciornei
2020-06-18 12:08 ` [PATCH net-next 1/5] net: phylink: add interface to configure clause 22 PCS PHY Ioana Ciornei
2020-06-18 12:08 ` [PATCH net-next 2/5] net: phylink: consider QSGMII interface mode in phylink_mii_c22_pcs_get_state Ioana Ciornei
2020-06-18 12:08 ` [PATCH net-next 3/5] net: mdiobus: add clause 45 mdiobus write accessor Ioana Ciornei
2020-06-18 12:08 ` [PATCH net-next 4/5] net: phy: add Lynx PCS MDIO module Ioana Ciornei
2020-06-18 14:06 ` Russell King - ARM Linux admin
2020-06-18 16:17 ` Ioana Ciornei
2020-06-18 16:55 ` Russell King - ARM Linux admin [this message]
2020-06-18 17:34 ` Ioana Ciornei
2020-06-18 22:01 ` Russell King - ARM Linux admin
2020-06-18 22:03 ` Andrew Lunn
2020-06-18 22:21 ` Russell King - ARM Linux admin
2020-06-18 22:56 ` Ioana Ciornei
2020-06-18 15:47 ` Jakub Kicinski
2020-06-18 22:13 ` Andrew Lunn
2020-06-18 22:25 ` Vladimir Oltean
2020-06-18 22:27 ` Russell King - ARM Linux admin
2020-06-18 22:37 ` Andrew Lunn
2020-06-18 22:49 ` Russell King - ARM Linux admin
2020-06-18 12:08 ` [PATCH net-next 5/5] net: dsa: felix: use the Lynx PCS helpers Ioana Ciornei
2020-06-18 15:48 ` Jakub Kicinski
2020-06-19 7:43 ` Ioana Ciornei
2020-06-20 15:46 ` kernel test robot
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=20200618165510.GG1551@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=alexandru.marginean@nxp.com \
--cc=andrew@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=ioana.ciornei@nxp.com \
--cc=michael@walle.cc \
--cc=netdev@vger.kernel.org \
--cc=vladimir.oltean@nxp.com \
/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).