Subject: Re: [PATCH net-next v15 07/14] net: ethtool: Introduce a command to list PHYs on an interface

From: "Russell King (Oracle)" <[email-masked]>
Date: Wed, 3 Jul 2024 15:52:12 +0100

On Wed, Jul 03, 2024 at 04:07:57PM +0200, Maxime Chevallier wrote:
> +static int
> +ethnl_phy_fill_reply(const struct ethnl_req_info *req_base, struct sk_buff *skb)
> +{
> +	struct phy_req_info *req_info = PHY_REQINFO(req_base);
> +	struct phy_device_node *pdn = req_info->pdn;
> +	struct phy_device *phydev = pdn->phy;
> +	enum phy_upstream ptype;
> +
> +	ptype = pdn->upstream_type;
> +
> +	if (nla_put_u32(skb, ETHTOOL_A_PHY_INDEX, phydev->phyindex) ||
> +	    nla_put_string(skb, ETHTOOL_A_PHY_NAME, dev_name(&phydev->mdio.dev)) ||
> +	    nla_put_u32(skb, ETHTOOL_A_PHY_UPSTREAM_TYPE, ptype) ||
> +	    nla_put_u32(skb, ETHTOOL_A_PHY_ID, phydev->phy_id))
> +		return -EMSGSIZE;

I'm really not sure that it is a good idea to export phydev->phy_id
through this API.

Clause 45-only PHYs don't have a phy_id, they have a whole bunch of
IDs (actually, two per MMD - a device ID and a package ID. I think
the package ID is supposed to be the same for all MMDs, but in
practice it isn't.

For example, 88x3310 uses:

MMD	devid		pkgid
1	002b09aa	002b09aa
3	002b09aa	002b09aa
4	01410daa	01410daa
7	002b09aa	002b09aa

So, if we want to report the ID of the PHY, then really we need to
report the clause 22 ID, and at least all the devids of each MMD in
a clause 45 PHY. Alternatively, we may decide it isn't worth the
effort of reporting any of these IDs.

However, reporting just the clause 22 ID would be a design error
IMHO.

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