[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230204011133.5mgam2ik7znsrqxu@skbuf>
Date: Sat, 4 Feb 2023 03:11:33 +0200
From: Vladimir Oltean <olteanv@...il.com>
To: Oleksij Rempel <o.rempel@...gutronix.de>
Cc: Woojung Huh <woojung.huh@...rochip.com>,
UNGLinuxDriver@...rochip.com, Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Wei Fang <wei.fang@....com>,
Heiner Kallweit <hkallweit1@...il.com>, kernel@...gutronix.de,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
Arun.Ramadoss@...rochip.com, intel-wired-lan@...ts.osuosl.org
Subject: Re: [PATCH net-next v4 05/23] net: phy: add
genphy_c45_ethtool_get/set_eee() support
On Wed, Feb 01, 2023 at 03:58:27PM +0100, Oleksij Rempel wrote:
> Add replacement for phy_ethtool_get/set_eee() functions.
>
> - it is able to support only limited amount of link modes. We have more
> EEE link modes...
>
> By refactoring this code I address most of this point except of the last
> one. Adding additional EEE link modes will need more work.
> +/**
> + * genphy_c45_ethtool_get_eee - get EEE supported and status
> + * @phydev: target phy_device struct
> + * @data: ethtool_eee data
> + *
> + * Description: it reports the Supported/Advertisement/LP Advertisement
> + * capabilities.
> + */
> +int genphy_c45_ethtool_get_eee(struct phy_device *phydev,
> + struct ethtool_eee *data)
> +{
> + __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) = {};
> + __ETHTOOL_DECLARE_LINK_MODE_MASK(lp) = {};
> + bool overflow = false, is_enabled;
> + int ret;
> +
> + ret = genphy_c45_eee_is_active(phydev, adv, lp, &is_enabled);
> + if (ret < 0)
> + return ret;
> +
> + data->eee_enabled = is_enabled;
> + data->eee_active = ret;
> +
> + if (!ethtool_convert_link_mode_to_legacy_u32(&data->supported,
> + phydev->supported_eee))
> + overflow = true;
> + if (!ethtool_convert_link_mode_to_legacy_u32(&data->advertised, adv))
> + overflow = true;
> + if (!ethtool_convert_link_mode_to_legacy_u32(&data->lp_advertised, lp))
> + overflow = true;
ah, ok, so since struct ethtool_eee stores the link modes in the old u32
format, link modes equal to ETHTOOL_LINK_MODE_25000baseKR_Full_BIT or
higher would truncate. Makes sense.
> +
> + if (overflow)
> + phydev_warn(phydev, "Not all supported or advertised EEE link modes was passed to the user space\n");
were passed
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(genphy_c45_ethtool_get_eee);
Powered by blists - more mailing lists