[PATCH RFC net-next 5/5] net: dsa: always use phylink for CPU and DSA ports

Russell King (Oracle) linux at armlinux.org.uk
Fri Jul 8 08:25:03 PDT 2022


Hi,

On Thu, Jul 07, 2022 at 10:37:53PM +0300, Vladimir Oltean wrote:
> +static int dsa_port_fixup_broken_dt(struct dsa_port *dp)

As I mentioned, I doubt that Andrew considers this "broken DT" as he's
been promoting this as a standard DSA feature.

> +{
> +	struct property_entry fixed_link_props[] = {
> +		PROPERTY_ENTRY_BOOL("full-duplex"),
> +		PROPERTY_ENTRY_U32("speed", 1000), /* TODO determine actual speed */
> +		{},
> +	};
> +	struct property_entry port_props[3] = {};
> +	struct fwnode_handle *fixed_link_fwnode;
> +	struct fwnode_handle *new_port_fwnode;
> +	struct device_node *dn = dp->dn;
> +	phy_interface_t mode;
> +	int err;
> +
> +	if (of_parse_phandle(dn, "phy-handle", 0) ||
> +	    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 0;

I think this is sufficient. Yes, phylink accepts "phy" and "phy-device"
because it has to for compatibility with other drivers, but the binding
document for DSA quite clearly states that "phy-handle" is what DSA
accepts, so DT in the kernel will be validated against the yaml file
and enforce correctness here.

We do need to check for "sfp" being present as well.

> +
> +	err = of_get_phy_mode(dn, &mode);
> +	if (err)
> +		/* TODO this may be missing too, ask the driver for the
> +		 * max-speed interface mode for this port
> +		 */
> +		mode = PHY_INTERFACE_MODE_NA;

I think it would be easier to omit the phy-mode property in the swnode
if it isn't present in DT, because then we can handle that in
dsa_port_phylink_create() as I've done in my patch series via the
ds->ops->phylink_get_caps() method.

> +
> +	port_props[0] = PROPERTY_ENTRY_U32("reg", dp->index);

You said in one of your other replies that this node we're constructing
is only for phylink, do we need the "reg" property? phylink doesn't care
about it.

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



More information about the linux-arm-kernel mailing list