From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Cc: "Andrew Lunn" <andrew@lunn.ch>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Alvin __ipraga" <alsi@bang-olufsen.dk>,
"Claudiu Manoil" <claudiu.manoil@nxp.com>,
"Daniel Scally" <djrscally@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"DENG Qingfang" <dqfext@gmail.com>,
"Eric Dumazet" <edumazet@google.com>,
"Florian Fainelli" <f.fainelli@gmail.com>,
"George McCollister" <george.mccollister@gmail.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Hauke Mehrtens" <hauke@hauke-m.de>,
"Heikki Krogerus" <heikki.krogerus@linux.intel.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Kurt Kanzenbach" <kurt@linutronix.de>,
"Landen Chao" <Landen.Chao@mediatek.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
"Matthias Brugger" <matthias.bgg@gmail.com>,
netdev@vger.kernel.org, "Paolo Abeni" <pabeni@redhat.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Sakari Ailus" <sakari.ailus@linux.intel.com>,
"Sean Wang" <sean.wang@mediatek.com>,
UNGLinuxDriver@microchip.com,
"Vivien Didelot" <vivien.didelot@gmail.com>,
"Vladimir Oltean" <olteanv@gmail.com>,
"Woojung Huh" <woojung.huh@microchip.com>,
"Marek Behún" <kabel@kernel.org>
Subject: Re: [PATCH net-next 5/6] net: dsa: use swnode fixed-link if using default params
Date: Fri, 15 Jul 2022 23:11:18 +0300 [thread overview]
Message-ID: <YtHJ5rfxZ+icXrkC@smile.fi.intel.com> (raw)
In-Reply-To: <E1oCNlE-006e3z-3T@rmk-PC.armlinux.org.uk>
On Fri, Jul 15, 2022 at 05:01:48PM +0100, Russell King (Oracle) wrote:
> Create and use a swnode fixed-link specification for phylink if no
> parameters are given in DT for a fixed-link. This allows phylink to
> be used for "default" cases for DSA and CPU ports. Enable the use
> of phylink in all cases for DSA and CPU ports.
> Co-developed by Vladimir Oltean and myself.
Why not to use
Co-developed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
?
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Reviewed-by: Marek Behún <kabel@kernel.org>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
...
> +static struct {
> + unsigned long mask;
> + int speed;
> + int duplex;
> +} phylink_caps_params[] = {
> + { MAC_400000FD, SPEED_400000, DUPLEX_FULL },
> + { MAC_200000FD, SPEED_200000, DUPLEX_FULL },
> + { MAC_100000FD, SPEED_100000, DUPLEX_FULL },
> + { MAC_56000FD, SPEED_56000, DUPLEX_FULL },
> + { MAC_50000FD, SPEED_50000, DUPLEX_FULL },
> + { MAC_40000FD, SPEED_40000, DUPLEX_FULL },
> + { MAC_25000FD, SPEED_25000, DUPLEX_FULL },
> + { MAC_20000FD, SPEED_20000, DUPLEX_FULL },
> + { MAC_10000FD, SPEED_10000, DUPLEX_FULL },
> + { MAC_5000FD, SPEED_5000, DUPLEX_FULL },
> + { MAC_2500FD, SPEED_2500, DUPLEX_FULL },
> + { MAC_1000FD, SPEED_1000, DUPLEX_FULL },
> + { MAC_100FD, SPEED_100, DUPLEX_FULL },
> + { MAC_10FD, SPEED_10, DUPLEX_FULL },
> + { MAC_1000HD, SPEED_1000, DUPLEX_HALF },
> + { MAC_100HD, SPEED_100, DUPLEX_HALF },
> + { MAC_10HD, SPEED_10, DUPLEX_HALF },
> +};
> +
> +static int dsa_port_find_max_speed(unsigned long caps, int *speed, int *duplex)
> +{
> + int i;
> +
> + *speed = SPEED_UNKNOWN;
> + *duplex = DUPLEX_UNKNOWN;
> +
> + for (i = 0; i < ARRAY_SIZE(phylink_caps_params); i++) {
> + if (caps & phylink_caps_params[i].mask) {
> + *speed = phylink_caps_params[i].speed;
> + *duplex = phylink_caps_params[i].duplex;
> + break;
With the below check it's way too protective programming.
return 0;
> + }
> + }
> +
> + return *speed == SPEED_UNKNOWN ? -EINVAL : 0;
return -EINVAL;
> +}
...
> +static struct fwnode_handle *dsa_port_get_fwnode(struct dsa_port *dp,
> + phy_interface_t mode)
> +{
> + struct property_entry fixed_link_props[3] = { };
> + struct property_entry port_props[3] = {};
A bit of consistency in the assignments?
Also it seems you are using up to 2 for the first one and only 1 in the second
one. IIUC it requires a terminator entry, so it means 3 and 2. Do we really
need 3 in the second case?
> + struct fwnode_handle *fixed_link_fwnode;
> + struct fwnode_handle *new_port_fwnode;
> + struct device_node *dn = dp->dn;
> + struct device_node *phy_node;
> + int err, speed, duplex;
> + unsigned long caps;
> +
> + phy_node = of_parse_phandle(dn, "phy-handle", 0);
fwnode in the name, why not to use fwnode APIs?
fwnode_find_reference();
> + of_node_put(phy_node);
> + if (phy_node || of_phy_is_fixed_link(dn))
> + /* Nothing broken, nothing to fix.
> + * TODO: As discussed with Russell, maybe phylink could provide
> + * a more comprehensive helper to determine what constitutes a
> + * valid fwnode binding than this guerilla kludge.
> + */
> + return of_fwnode_handle(dn);
> +
> + if (mode == PHY_INTERFACE_MODE_NA)
> + dsa_port_find_max_caps(dp, &mode, &caps);
> + else
> + caps = dp->pl_config.mac_capabilities &
> + phylink_interface_to_caps(mode);
> +
> + err = dsa_port_find_max_speed(caps, &speed, &duplex);
> + if (err)
> + return ERR_PTR(err);
> +
> + fixed_link_props[0] = PROPERTY_ENTRY_U32("speed", speed);
> + if (duplex == DUPLEX_FULL)
> + fixed_link_props[1] = PROPERTY_ENTRY_BOOL("full-duplex");
> +
> + port_props[0] = PROPERTY_ENTRY_STRING("phy-mode", phy_modes(mode));
> +
> + new_port_fwnode = fwnode_create_software_node(port_props, NULL);
> + if (IS_ERR(new_port_fwnode))
> + return new_port_fwnode;
> +
> + /* Node needs to be named so that phylink's call to
> + * fwnode_get_named_child_node() finds it.
> + */
> + fixed_link_fwnode = fwnode_create_named_software_node(fixed_link_props,
> + new_port_fwnode,
> + "fixed-link");
> + if (IS_ERR(fixed_link_fwnode)) {
> + fwnode_remove_software_node(new_port_fwnode);
> + return fixed_link_fwnode;
> + }
> +
> + return new_port_fwnode;
> +}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2022-07-15 20:11 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-15 16:00 [PATCH net-next 0/6] net: dsa: always use phylink Russell King (Oracle)
2022-07-15 16:01 ` [PATCH net-next 1/6] net: phylink: split out and export interface to caps translation Russell King (Oracle)
2022-07-15 16:01 ` [PATCH net-next 2/6] software node: allow named software node to be created Russell King
2022-07-15 19:57 ` Andy Shevchenko
2022-07-15 20:17 ` Vladimir Oltean
2022-07-15 20:33 ` Andy Shevchenko
2022-07-15 20:48 ` Vladimir Oltean
2022-07-18 12:29 ` Andy Shevchenko
2022-07-18 13:27 ` Russell King (Oracle)
2022-07-18 18:43 ` Andy Shevchenko
2022-07-18 18:53 ` Andy Shevchenko
2022-07-18 19:14 ` Russell King (Oracle)
2022-07-18 19:24 ` Andy Shevchenko
2022-07-18 20:39 ` Marek Behún
2022-07-18 20:48 ` Andy Shevchenko
2022-07-19 7:18 ` Marek Behún
2022-07-29 12:08 ` Andy Shevchenko
2022-07-18 19:11 ` Russell King (Oracle)
2022-07-18 20:07 ` Andy Shevchenko
2022-07-18 20:38 ` Russell King (Oracle)
2022-07-19 8:50 ` Sakari Ailus
2022-07-20 22:56 ` Vladimir Oltean
2022-07-22 6:21 ` Sakari Ailus
2022-07-18 20:42 ` Andrew Lunn
2022-07-15 16:01 ` [PATCH net-next 3/6] net: dsa: add support for retrieving the interface mode Russell King (Oracle)
2022-07-15 17:24 ` Vladimir Oltean
2022-07-15 21:31 ` Russell King (Oracle)
2022-07-15 22:23 ` Vladimir Oltean
2022-07-15 22:57 ` Russell King (Oracle)
2022-07-16 10:57 ` Vladimir Oltean
2022-07-16 11:13 ` Russell King (Oracle)
2022-07-16 12:36 ` Vladimir Oltean
2022-07-18 8:48 ` Russell King (Oracle)
2022-07-20 22:44 ` Vladimir Oltean
2022-07-21 13:46 ` Vladimir Oltean
2022-07-21 14:46 ` Andrew Lunn
2022-07-21 14:54 ` Russell King (Oracle)
2022-07-21 15:15 ` Vladimir Oltean
2022-07-21 17:21 ` Marek Behún
2022-07-21 18:15 ` Russell King (Oracle)
2022-07-21 18:22 ` Vladimir Oltean
2022-07-21 21:14 ` Russell King (Oracle)
2022-07-21 21:36 ` Vladimir Oltean
2022-07-22 8:28 ` Russell King (Oracle)
2022-07-22 10:52 ` Vladimir Oltean
2022-07-22 11:44 ` Russell King (Oracle)
2022-07-22 12:14 ` Russell King (Oracle)
2022-07-22 12:46 ` Vladimir Oltean
2022-07-22 13:16 ` Russell King (Oracle)
2022-07-22 16:56 ` Vladimir Oltean
2022-07-22 21:20 ` Russell King (Oracle)
2022-07-22 21:53 ` Andrew Lunn
2022-07-22 22:35 ` Andrew Lunn
2022-07-22 22:39 ` Vladimir Oltean
2022-07-23 7:12 ` Russell King (Oracle)
2022-07-23 13:44 ` Vladimir Oltean
2022-07-25 10:11 ` Russell King (Oracle)
2022-07-23 17:26 ` Marek Behún
2022-07-24 17:39 ` Vladimir Oltean
2022-07-22 13:20 ` Andrew Lunn
2022-07-22 12:59 ` Marek Behún
2022-07-22 13:23 ` Russell King (Oracle)
2022-07-22 14:19 ` Marek Behún
2022-07-15 16:01 ` [PATCH net-next 4/6] net: dsa: mv88e6xxx: report the default interface mode for the port Russell King (Oracle)
2022-07-15 16:01 ` [PATCH net-next 5/6] net: dsa: use swnode fixed-link if using default params Russell King (Oracle)
2022-07-15 20:11 ` Andy Shevchenko [this message]
2022-07-15 21:36 ` Russell King (Oracle)
2022-07-18 18:59 ` Andy Shevchenko
2022-07-18 19:13 ` Russell King (Oracle)
2022-07-18 20:08 ` Andy Shevchenko
2022-07-15 16:01 ` [PATCH net-next 6/6] net: dsa: mv88e6xxx: remove handling for DSA and CPU ports Russell King (Oracle)
2022-07-15 17:17 ` [PATCH net-next 0/6] net: dsa: always use phylink Vladimir Oltean
2022-07-15 20:59 ` Russell King (Oracle)
2022-07-15 23:03 ` Jakub Kicinski
2022-07-16 11:15 ` Vladimir Oltean
2022-07-16 11:43 ` Russell King (Oracle)
2022-07-16 13:13 ` Vladimir Oltean
2022-07-18 8:53 ` Russell King (Oracle)
2022-07-18 12:45 ` Vladimir Oltean
2022-07-18 13:02 ` Russell King (Oracle)
2022-07-18 14:25 ` Vladimir Oltean
2022-07-16 23:44 ` Jakub Kicinski
2022-07-27 9:00 ` Marek Behún
2022-07-27 13:38 ` Vladimir Oltean
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=YtHJ5rfxZ+icXrkC@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=Landen.Chao@mediatek.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=alsi@bang-olufsen.dk \
--cc=andrew@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=djrscally@gmail.com \
--cc=dqfext@gmail.com \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=george.mccollister@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hauke@hauke-m.de \
--cc=heikki.krogerus@linux.intel.com \
--cc=hkallweit1@gmail.com \
--cc=kabel@kernel.org \
--cc=kuba@kernel.org \
--cc=kurt@linutronix.de \
--cc=linus.walleij@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=rafael@kernel.org \
--cc=rmk+kernel@armlinux.org.uk \
--cc=sakari.ailus@linux.intel.com \
--cc=sean.wang@mediatek.com \
--cc=vivien.didelot@gmail.com \
--cc=woojung.huh@microchip.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).