From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C76AAC05027 for ; Wed, 1 Feb 2023 14:59:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232836AbjBAO7s (ORCPT ); Wed, 1 Feb 2023 09:59:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232303AbjBAO7F (ORCPT ); Wed, 1 Feb 2023 09:59:05 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E60666ACA7 for ; Wed, 1 Feb 2023 06:59:03 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rd-0A; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZW-001w1O-Ty; Wed, 01 Feb 2023 15:58:50 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hUh-81; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 01/23] net: dsa: microchip: enable EEE support Date: Wed, 1 Feb 2023 15:58:23 +0100 Message-Id: <20230201145845.2312060-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Some of KSZ9477 family switches provides EEE support. To enable it, we just need to register set_mac_eee/set_mac_eee handlers and validate supported chip version and port. Signed-off-by: Oleksij Rempel --- drivers/net/dsa/microchip/ksz_common.c | 66 ++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 46becc0382d6..5ecd74248eee 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2673,6 +2673,70 @@ static int ksz_max_mtu(struct dsa_switch *ds, int po= rt) return -EOPNOTSUPP; } =20 +static int ksz_validate_eee(struct dsa_switch *ds, int port) +{ + struct ksz_device *dev =3D ds->priv; + + if (!dev->info->internal_phy[port]) + return -EOPNOTSUPP; + + switch (dev->chip_id) { + case KSZ8563_CHIP_ID: + case KSZ9477_CHIP_ID: + case KSZ9563_CHIP_ID: + case KSZ9567_CHIP_ID: + case KSZ9893_CHIP_ID: + case KSZ9896_CHIP_ID: + case KSZ9897_CHIP_ID: + return 0; + } + + return -EOPNOTSUPP; +} + +static int ksz_get_mac_eee(struct dsa_switch *ds, int port, + struct ethtool_eee *e) +{ + int ret; + + ret =3D ksz_validate_eee(ds, port); + if (ret) + return ret; + + /* There is no documented control of Tx LPI configuration. + */ + e->tx_lpi_enabled =3D true; + /* There is no documented control of Tx LPI timer. According to testes + * Tx LPI timer seems to be set by default to minimal value. + */ + e->tx_lpi_timer =3D 0; + + return 0; +} + +static int ksz_set_mac_eee(struct dsa_switch *ds, int port, + struct ethtool_eee *e) +{ + struct ksz_device *dev =3D ds->priv; + int ret; + + ret =3D ksz_validate_eee(ds, port); + if (ret) + return ret; + + if (!e->tx_lpi_enabled) { + dev_err(dev->dev, "Disabling EEE Tx LPI is not supported\n"); + return -EINVAL; + } + + if (e->tx_lpi_timer) { + dev_err(dev->dev, "Setting EEE Tx LPI timer is not supported\n"); + return -EINVAL; + } + + return 0; +} + static void ksz_set_xmii(struct ksz_device *dev, int port, phy_interface_t interface) { @@ -3130,6 +3194,8 @@ static const struct dsa_switch_ops ksz_switch_ops =3D= { .port_txtstamp =3D ksz_port_txtstamp, .port_rxtstamp =3D ksz_port_rxtstamp, .port_setup_tc =3D ksz_setup_tc, + .get_mac_eee =3D ksz_get_mac_eee, + .set_mac_eee =3D ksz_set_mac_eee, }; =20 struct ksz_device *ksz_switch_alloc(struct device *base, void *priv) --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFCF9C636CD for ; Wed, 1 Feb 2023 15:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232888AbjBAPAW (ORCPT ); Wed, 1 Feb 2023 10:00:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232532AbjBAO7G (ORCPT ); Wed, 1 Feb 2023 09:59:06 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 671866ACB3 for ; Wed, 1 Feb 2023 06:59:04 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rq-Be; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZY-001w25-HE; Wed, 01 Feb 2023 15:58:51 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hUq-95; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 02/23] net: phy: add genphy_c45_read_eee_abilities() function Date: Wed, 1 Feb 2023 15:58:24 +0100 Message-Id: <20230201145845.2312060-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add generic function for EEE abilities defined by IEEE 802.3 specification. For now following registers are supported: - IEEE 802.3-2018 45.2.3.10 EEE control and capability 1 (Register 3.20) - IEEE 802.3cg-2019 45.2.1.186b 10BASE-T1L PMA status register (Register 1.2295) Since I was not able to find any flag signaling support of this registers, we should detect link mode abilities first and then based on this abilities doing EEE link modes detection. Results of EEE ability detection will be stored in to new variable phydev->supported_eee. Signed-off-by: Oleksij Rempel --- drivers/net/phy/phy-c45.c | 49 ++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy_device.c | 16 ++++++++++++ include/linux/mdio.h | 17 +++++++++++++ include/linux/phy.h | 5 ++++ 4 files changed, 87 insertions(+) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 9f9565a4819d..ae87f5856650 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -661,6 +661,55 @@ int genphy_c45_read_mdix(struct phy_device *phydev) } EXPORT_SYMBOL_GPL(genphy_c45_read_mdix); =20 +/** + * genphy_c45_read_eee_abilities - read supported EEE link modes + * @phydev: target phy_device struct + * + * Read supported EEE link modes. + */ +int genphy_c45_read_eee_abilities(struct phy_device *phydev) +{ + __ETHTOOL_DECLARE_LINK_MODE_MASK(common); + int val; + + linkmode_and(common, phydev->supported, PHY_EEE_100_10000_FEATURES); + /* There is not indicator if optional register + * "EEE control and capability 1" (3.20) is supported. Read it only + * on devices with appropriate linkmodes. + */ + if (!linkmode_empty(common)) { + /* IEEE 802.3-2018 45.2.3.10 EEE control and capability 1 + * (Register 3.20) + */ + val =3D phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE); + if (val < 0) + return val; + + mii_eee_100_10000_adv_mod_linkmode_t(phydev->supported_eee, val); + + /* Some buggy devices claim not supported EEE link modes */ + linkmode_and(phydev->supported_eee, phydev->supported_eee, + phydev->supported); + } + + if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, + phydev->supported)) { + /* IEEE 802.3cg-2019 45.2.1.186b 10BASE-T1L PMA status register + * (Register 1.2295) + */ + val =3D phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10T1L_STAT); + if (val < 0) + return val; + + linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, + phydev->supported_eee, + val & MDIO_PMA_10T1L_STAT_EEE); + } + + return 0; +} +EXPORT_SYMBOL_GPL(genphy_c45_read_eee_abilities); + /** * genphy_c45_pma_read_abilities - read supported link modes from PMA * @phydev: target phy_device struct diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 9ba8f973f26f..3651f1fd8fc9 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -132,6 +132,18 @@ static const int phy_10gbit_full_features_array[] =3D { ETHTOOL_LINK_MODE_10000baseT_Full_BIT, }; =20 +static const int phy_eee_100_10000_features_array[6] =3D { + ETHTOOL_LINK_MODE_100baseT_Full_BIT, + ETHTOOL_LINK_MODE_1000baseT_Full_BIT, + ETHTOOL_LINK_MODE_10000baseT_Full_BIT, + ETHTOOL_LINK_MODE_1000baseKX_Full_BIT, + ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, + ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, +}; + +__ETHTOOL_DECLARE_LINK_MODE_MASK(phy_eee_100_10000_features) __ro_after_in= it; +EXPORT_SYMBOL_GPL(phy_eee_100_10000_features); + static void features_init(void) { /* 10/100 half/full*/ @@ -213,6 +225,10 @@ static void features_init(void) linkmode_set_bit_array(phy_10gbit_fec_features_array, ARRAY_SIZE(phy_10gbit_fec_features_array), phy_10gbit_fec_features); + linkmode_set_bit_array(phy_eee_100_10000_features_array, + ARRAY_SIZE(phy_eee_100_10000_features_array), + phy_eee_100_10000_features); + } =20 void phy_device_free(struct phy_device *phydev) diff --git a/include/linux/mdio.h b/include/linux/mdio.h index c0da30d63b1d..77c324f89b66 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -402,6 +402,23 @@ static inline u32 linkmode_adv_to_mii_t1_adv_m_t(unsig= ned long *advertising) return result; } =20 +static inline void mii_eee_100_10000_adv_mod_linkmode_t(unsigned long *adv, + u32 val) +{ + linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, + adv, val & MDIO_EEE_100TX); + linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, + adv, val & MDIO_EEE_1000T); + linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, + adv, val & MDIO_EEE_10GT); + linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseKX_Full_BIT, + adv, val & MDIO_EEE_1000KX); + linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, + adv, val & MDIO_EEE_10GKX4); + linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, + adv, val & MDIO_EEE_10GKR); +} + int __mdiobus_read(struct mii_bus *bus, int addr, u32 regnum); int __mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val); int __mdiobus_modify_changed(struct mii_bus *bus, int addr, u32 regnum, diff --git a/include/linux/phy.h b/include/linux/phy.h index fbeba4fee8d4..567810f71fb6 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -52,6 +52,7 @@ extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_gbit_all_port= s_features) __ro_after_ extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_10gbit_features) __ro_after_in= it; extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_10gbit_fec_features) __ro_afte= r_init; extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_10gbit_full_features) __ro_aft= er_init; +extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_eee_100_10000_features) __ro_a= fter_init; =20 #define PHY_BASIC_FEATURES ((unsigned long *)&phy_basic_features) #define PHY_BASIC_T1_FEATURES ((unsigned long *)&phy_basic_t1_features) @@ -62,6 +63,7 @@ extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_10gbit_full_f= eatures) __ro_after_ini #define PHY_10GBIT_FEATURES ((unsigned long *)&phy_10gbit_features) #define PHY_10GBIT_FEC_FEATURES ((unsigned long *)&phy_10gbit_fec_features) #define PHY_10GBIT_FULL_FEATURES ((unsigned long *)&phy_10gbit_full_featur= es) +#define PHY_EEE_100_10000_FEATURES ((unsigned long *)&phy_eee_100_10000_fe= atures) =20 extern const int phy_basic_ports_array[3]; extern const int phy_fibre_port_array[1]; @@ -676,6 +678,8 @@ struct phy_device { __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising); /* used with phy_speed_down */ __ETHTOOL_DECLARE_LINK_MODE_MASK(adv_old); + /* used for eee validation */ + __ETHTOOL_DECLARE_LINK_MODE_MASK(supported_eee); =20 /* Host supported PHY interface types. Should be ignored if empty. */ DECLARE_PHY_INTERFACE_MASK(host_interfaces); @@ -1737,6 +1741,7 @@ int genphy_c45_an_config_aneg(struct phy_device *phyd= ev); int genphy_c45_an_disable_aneg(struct phy_device *phydev); int genphy_c45_read_mdix(struct phy_device *phydev); int genphy_c45_pma_read_abilities(struct phy_device *phydev); +int genphy_c45_read_eee_abilities(struct phy_device *phydev); int genphy_c45_pma_baset1_read_master_slave(struct phy_device *phydev); int genphy_c45_read_status(struct phy_device *phydev); int genphy_c45_baset1_read_status(struct phy_device *phydev); --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D76F7C05027 for ; Wed, 1 Feb 2023 15:00:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232905AbjBAPAf (ORCPT ); Wed, 1 Feb 2023 10:00:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232760AbjBAO7Q (ORCPT ); Wed, 1 Feb 2023 09:59:16 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB44F6B9AB for ; Wed, 1 Feb 2023 06:59:07 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZc-0002rm-Vc; Wed, 01 Feb 2023 15:58:57 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZY-001w1r-5c; Wed, 01 Feb 2023 15:58:51 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hUz-9u; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 03/23] net: phy: micrel: add ksz9477_get_features() Date: Wed, 1 Feb 2023 15:58:25 +0100 Message-Id: <20230201145845.2312060-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" KSZ8563R, which has same PHYID as KSZ9477 family, will change "EEE control and capability 1" (Register 3.20) content depending on configuration of "EEE advertisement 1" (Register 7.60). Changes on the 7.60 will affect 3.20 register. So, instead of depending on register 3.20 driver should set supported_eee. Proper supported_eee configuration is needed to make use of generic PHY c45 set/get_eee functions provided by next patches. Signed-off-by: Oleksij Rempel --- drivers/net/phy/micrel.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index d5b80c31ab91..767c4111cb18 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -1370,6 +1370,26 @@ static int ksz9131_config_aneg(struct phy_device *ph= ydev) return genphy_config_aneg(phydev); } =20 +static int ksz9477_get_features(struct phy_device *phydev) +{ + int ret; + + ret =3D genphy_read_abilities(phydev); + if (ret) + return ret; + + /* The "EEE control and capability 1" (Register 3.20) seems to be + * influenced by the "EEE advertisement 1" (Register 7.60). Changes + * on the 7.60 will affect 3.20. So, we need to construct our own list + * of caps. + * KSZ8563R should have 100BaseTX/Full only. + */ + linkmode_and(phydev->supported_eee, phydev->supported, + PHY_EEE_100_10000_FEATURES); + + return 0; +} + #define KSZ8873MLL_GLOBAL_CONTROL_4 0x06 #define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX BIT(6) #define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED BIT(4) @@ -3422,6 +3442,7 @@ static struct phy_driver ksphy_driver[] =3D { .handle_interrupt =3D kszphy_handle_interrupt, .suspend =3D genphy_suspend, .resume =3D genphy_resume, + .get_features =3D ksz9477_get_features, } }; =20 module_phy_driver(ksphy_driver); --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47497C636CD for ; Wed, 1 Feb 2023 15:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231755AbjBAPAO (ORCPT ); Wed, 1 Feb 2023 10:00:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232562AbjBAO7G (ORCPT ); Wed, 1 Feb 2023 09:59:06 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D9806ACB8 for ; Wed, 1 Feb 2023 06:59:04 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rX-0A; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZW-001w18-3B; Wed, 01 Feb 2023 15:58:49 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hV8-AV; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 04/23] net: phy: export phy_check_valid() function Date: Wed, 1 Feb 2023 15:58:26 +0100 Message-Id: <20230201145845.2312060-5-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This function will be needed for genphy_c45_ethtool_get_eee() provided by next patch. Signed-off-by: Oleksij Rempel Reviewed-by: Andrew Lunn --- drivers/net/phy/phy.c | 4 ++-- include/linux/phy.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 3378ca4f49b6..41cfb24c48c1 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -242,11 +242,11 @@ unsigned int phy_supported_speeds(struct phy_device *= phy, * * Description: Returns true if there is a valid setting, false otherwise. */ -static inline bool phy_check_valid(int speed, int duplex, - unsigned long *features) +bool phy_check_valid(int speed, int duplex, unsigned long *features) { return !!phy_lookup_setting(speed, duplex, features, true); } +EXPORT_SYMBOL(phy_check_valid); =20 /** * phy_sanitize_settings - make sure the PHY is set to supported speed and= duplex diff --git a/include/linux/phy.h b/include/linux/phy.h index 567810f71fb6..fa8453c48ad1 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1618,6 +1618,7 @@ int phy_start_aneg(struct phy_device *phydev); int phy_aneg_done(struct phy_device *phydev); int phy_speed_down(struct phy_device *phydev, bool sync); int phy_speed_up(struct phy_device *phydev); +bool phy_check_valid(int speed, int duplex, unsigned long *features); =20 int phy_restart_aneg(struct phy_device *phydev); int phy_reset_after_clk_enable(struct phy_device *phydev); --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 816C5C636CD for ; Wed, 1 Feb 2023 15:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232200AbjBAPAB (ORCPT ); Wed, 1 Feb 2023 10:00:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232477AbjBAO7G (ORCPT ); Wed, 1 Feb 2023 09:59:06 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A1AB6AC8F for ; Wed, 1 Feb 2023 06:59:03 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rb-0F; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZW-001w1K-QB; Wed, 01 Feb 2023 15:58:49 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hVH-B6; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 05/23] net: phy: add genphy_c45_ethtool_get/set_eee() support Date: Wed, 1 Feb 2023 15:58:27 +0100 Message-Id: <20230201145845.2312060-6-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add replacement for phy_ethtool_get/set_eee() functions. Current phy_ethtool_get/set_eee() implementation is great and it is possible to make it even better: - this functionality is for devices implementing parts of IEEE 802.3 specification beyond Clause 22. The better place for this code is phy-c45.c - currently it is able to do read/write operations on PHYs with different abilities to not existing registers. It is better to use stored supported_eee abilities to avoid false read/write operations. - the eee_active detection will provide wrong results on not supported link modes. It is better to validate speed/duplex properties against supported EEE link modes. - 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. Signed-off-by: Oleksij Rempel --- drivers/net/phy/phy-c45.c | 238 ++++++++++++++++++++++++++++++++++++++ include/linux/mdio.h | 36 ++++++ include/linux/phy.h | 7 ++ include/uapi/linux/mdio.h | 8 ++ 4 files changed, 289 insertions(+) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index ae87f5856650..9582c8bf74ec 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -661,6 +661,132 @@ int genphy_c45_read_mdix(struct phy_device *phydev) } EXPORT_SYMBOL_GPL(genphy_c45_read_mdix); =20 +/** + * genphy_c45_write_eee_adv - write advertised EEE link modes + * @phydev: target phy_device struct + */ +int genphy_c45_write_eee_adv(struct phy_device *phydev, unsigned long *adv) +{ + __ETHTOOL_DECLARE_LINK_MODE_MASK(common); + int val, changed; + + linkmode_and(common, phydev->supported_eee, PHY_EEE_100_10000_FEATURES); + if (!linkmode_empty(common)) { + val =3D linkmode_adv_to_mii_eee_100_10000_adv_t(adv); + + /* In eee_broken_modes are stored MDIO_AN_EEE_ADV specific raw + * register values. + */ + val &=3D ~phydev->eee_broken_modes; + + /* IEEE 802.3-2018 45.2.7.13 EEE advertisement 1 + * (Register 7.60) + */ + val =3D phy_modify_mmd_changed(phydev, MDIO_MMD_AN, + MDIO_AN_EEE_ADV, + MDIO_EEE_100TX | MDIO_EEE_1000T | + MDIO_EEE_10GT | MDIO_EEE_1000KX | + MDIO_EEE_10GKX4 | MDIO_EEE_10GKR, + val); + if (val < 0) + return val; + if (val > 0) + changed =3D 1; + } + + if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, + phydev->supported_eee)) { + val =3D linkmode_adv_to_mii_10base_t1_t(adv); + /* IEEE 802.3cg-2019 45.2.7.25 10BASE-T1 AN control register + * (Register 7.526) + */ + val =3D phy_modify_mmd_changed(phydev, MDIO_MMD_AN, + MDIO_AN_10BT1_AN_CTRL, + MDIO_AN_10BT1_AN_CTRL_ADV_EEE_T1L, + val); + if (val < 0) + return val; + if (val > 0) + changed =3D 1; + } + + return changed; +} + +/** + * genphy_c45_read_eee_adv - read advertised EEE link modes + * @phydev: target phy_device struct + */ +static int genphy_c45_read_eee_adv(struct phy_device *phydev, + unsigned long *adv) +{ + __ETHTOOL_DECLARE_LINK_MODE_MASK(common); + int val; + + linkmode_and(common, phydev->supported_eee, PHY_EEE_100_10000_FEATURES); + if (!linkmode_empty(common)) { + /* IEEE 802.3-2018 45.2.7.13 EEE advertisement 1 + * (Register 7.60) + */ + val =3D phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV); + if (val < 0) + return val; + + mii_eee_100_10000_adv_mod_linkmode_t(adv, val); + } + + if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, + phydev->supported_eee)) { + /* IEEE 802.3cg-2019 45.2.7.25 10BASE-T1 AN control register + * (Register 7.526) + */ + val =3D phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10BT1_AN_CTRL); + if (val < 0) + return val; + + mii_10base_t1_adv_mod_linkmode_t(adv, val); + } + + return 0; +} + +/** + * genphy_c45_read_eee_lpa - read advertised LP EEE link modes + * @phydev: target phy_device struct + */ +static int genphy_c45_read_eee_lpa(struct phy_device *phydev, + unsigned long *lpa) +{ + __ETHTOOL_DECLARE_LINK_MODE_MASK(common); + int val; + + linkmode_and(common, phydev->supported_eee, PHY_EEE_100_10000_FEATURES); + if (!linkmode_empty(common)) { + /* IEEE 802.3-2018 45.2.7.14 EEE link partner ability 1 + * (Register 7.61) + */ + val =3D phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE); + if (val < 0) + return val; + + mii_eee_100_10000_adv_mod_linkmode_t(lpa, val); + } + + if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, + phydev->supported_eee)) { + /* IEEE 802.3cg-2019 45.2.7.26 10BASE-T1 AN status register + * (Register 7.527) + */ + val =3D phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10BT1_AN_STAT); + if (val < 0) + return val; + + mii_10base_t1_adv_mod_linkmode_t(lpa, val); + } + + return 0; +} + /** * genphy_c45_read_eee_abilities - read supported EEE link modes * @phydev: target phy_device struct @@ -1173,6 +1299,118 @@ int genphy_c45_plca_get_status(struct phy_device *p= hydev, } EXPORT_SYMBOL_GPL(genphy_c45_plca_get_status); =20 +/** + * genphy_c45_eee_is_active - get EEE supported and status + * @phydev: target phy_device struct + * @data: ethtool_eee data + * + * Description: it reports the possible state of EEE functionality. + */ +int genphy_c45_eee_is_active(struct phy_device *phydev, unsigned long *adv, + unsigned long *lp, bool *is_enabled) +{ + __ETHTOOL_DECLARE_LINK_MODE_MASK(tmp_adv) =3D {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(tmp_lp) =3D {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(common); + bool eee_enabled, eee_active; + int ret; + + ret =3D genphy_c45_read_eee_adv(phydev, tmp_adv); + if (ret) + return ret; + + ret =3D genphy_c45_read_eee_lpa(phydev, tmp_lp); + if (ret) + return ret; + + eee_enabled =3D !linkmode_empty(tmp_adv); + linkmode_and(common, tmp_adv, tmp_lp); + if (eee_enabled && !linkmode_empty(common)) + eee_active =3D phy_check_valid(phydev->speed, phydev->duplex, + common); + else + eee_active =3D false; + + if (adv) + linkmode_copy(adv, tmp_adv); + if (lp) + linkmode_copy(lp, tmp_lp); + if (is_enabled) + *is_enabled =3D eee_enabled; + + return eee_active; +} +EXPORT_SYMBOL(genphy_c45_eee_is_active); + +/** + * 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) =3D {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(lp) =3D {}; + bool overflow =3D false, is_enabled; + int ret; + + ret =3D genphy_c45_eee_is_active(phydev, adv, lp, &is_enabled); + if (ret < 0) + return ret; + + data->eee_enabled =3D is_enabled; + data->eee_active =3D ret; + + if (!ethtool_convert_link_mode_to_legacy_u32(&data->supported, + phydev->supported_eee)) + overflow =3D true; + if (!ethtool_convert_link_mode_to_legacy_u32(&data->advertised, adv)) + overflow =3D true; + if (!ethtool_convert_link_mode_to_legacy_u32(&data->lp_advertised, lp)) + overflow =3D true; + + if (overflow) + phydev_warn(phydev, "Not all supported or advertised EEE link modes was = passed to the user space\n"); + + return 0; +} +EXPORT_SYMBOL(genphy_c45_ethtool_get_eee); + +/** + * genphy_c45_ethtool_set_eee - get EEE supported and status + * @phydev: target phy_device struct + * @data: ethtool_eee data + * + * Description: it reportes the Supported/Advertisement/LP Advertisement + * capabilities. + */ +int genphy_c45_ethtool_set_eee(struct phy_device *phydev, + struct ethtool_eee *data) +{ + __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) =3D {}; + int ret; + + if (data->eee_enabled) { + if (data->advertised) + adv[0] =3D data->advertised; + else + linkmode_copy(adv, phydev->supported_eee); + } + + ret =3D genphy_c45_write_eee_adv(phydev, adv); + if (ret < 0) + return ret; + if (ret > 0) + return phy_restart_aneg(phydev); + + return 0; +} +EXPORT_SYMBOL(genphy_c45_ethtool_set_eee); + struct phy_driver genphy_c45_driver =3D { .phy_id =3D 0xffffffff, .phy_id_mask =3D 0xffffffff, diff --git a/include/linux/mdio.h b/include/linux/mdio.h index 77c324f89b66..fcd5492e4993 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -419,6 +419,42 @@ static inline void mii_eee_100_10000_adv_mod_linkmode_= t(unsigned long *adv, adv, val & MDIO_EEE_10GKR); } =20 +static inline u32 linkmode_adv_to_mii_eee_100_10000_adv_t(unsigned long *a= dv) +{ + u32 result =3D 0; + + if (linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, adv)) + result |=3D MDIO_EEE_100TX; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, adv)) + result |=3D MDIO_EEE_1000T; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, adv)) + result |=3D MDIO_EEE_10GT; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseKX_Full_BIT, adv)) + result |=3D MDIO_EEE_1000KX; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, adv)) + result |=3D MDIO_EEE_10GKX4; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, adv)) + result |=3D MDIO_EEE_10GKR; + + return result; +} + +static inline void mii_10base_t1_adv_mod_linkmode_t(unsigned long *adv, u1= 6 val) +{ + linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, + adv, val & MDIO_AN_10BT1_AN_CTRL_ADV_EEE_T1L); +} + +static inline u32 linkmode_adv_to_mii_10base_t1_t(unsigned long *adv) +{ + u32 result =3D 0; + + if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, adv)) + result |=3D MDIO_AN_10BT1_AN_CTRL_ADV_EEE_T1L; + + return result; +} + int __mdiobus_read(struct mii_bus *bus, int addr, u32 regnum); int __mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val); int __mdiobus_modify_changed(struct mii_bus *bus, int addr, u32 regnum, diff --git a/include/linux/phy.h b/include/linux/phy.h index fa8453c48ad1..f8fbbf137ece 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1757,6 +1757,13 @@ int genphy_c45_plca_set_cfg(struct phy_device *phyde= v, const struct phy_plca_cfg *plca_cfg); int genphy_c45_plca_get_status(struct phy_device *phydev, struct phy_plca_status *plca_st); +int genphy_c45_eee_is_active(struct phy_device *phydev, unsigned long *adv, + unsigned long *lp, bool *is_enabled); +int genphy_c45_ethtool_get_eee(struct phy_device *phydev, + struct ethtool_eee *data); +int genphy_c45_ethtool_set_eee(struct phy_device *phydev, + struct ethtool_eee *data); +int genphy_c45_write_eee_adv(struct phy_device *phydev, unsigned long *adv= ); =20 /* Generic C45 PHY driver */ extern struct phy_driver genphy_c45_driver; diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h index 75b7257a51e1..256b463e47a6 100644 --- a/include/uapi/linux/mdio.h +++ b/include/uapi/linux/mdio.h @@ -79,6 +79,8 @@ #define MDIO_AN_T1_LP_L 517 /* BASE-T1 AN LP Base Page ability register [= 15:0] */ #define MDIO_AN_T1_LP_M 518 /* BASE-T1 AN LP Base Page ability register [= 31:16] */ #define MDIO_AN_T1_LP_H 519 /* BASE-T1 AN LP Base Page ability register [= 47:32] */ +#define MDIO_AN_10BT1_AN_CTRL 526 /* 10BASE-T1 AN control register */ +#define MDIO_AN_10BT1_AN_STAT 527 /* 10BASE-T1 AN status register */ #define MDIO_PMA_PMD_BT1_CTRL 2100 /* BASE-T1 PMA/PMD control register */ =20 /* LASI (Link Alarm Status Interrupt) registers, defined by XENPAK MSA. */ @@ -340,6 +342,12 @@ #define MDIO_AN_T1_LP_H_10L_TX_HI_REQ 0x1000 /* 10BASE-T1L High Level LP T= ransmit Request */ #define MDIO_AN_T1_LP_H_10L_TX_HI 0x2000 /* 10BASE-T1L High Level LP Trans= mit Ability */ =20 +/* 10BASE-T1 AN control register */ +#define MDIO_AN_10BT1_AN_CTRL_ADV_EEE_T1L 0x4000 /* 10BASE-T1L EEE ability= advertisement */ + +/* 10BASE-T1 AN status register */ +#define MDIO_AN_10BT1_AN_STAT_LPA_EEE_T1L 0x4000 /* 10BASE-T1L LP EEE abil= ity advertisement */ + /* BASE-T1 PMA/PMD control register */ #define MDIO_PMA_PMD_BT1_CTRL_CFG_MST 0x4000 /* MASTER-SLAVE config value = */ =20 --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 046DAC05027 for ; Wed, 1 Feb 2023 15:00:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232918AbjBAPAn (ORCPT ); Wed, 1 Feb 2023 10:00:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232806AbjBAO7i (ORCPT ); Wed, 1 Feb 2023 09:59:38 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 289936ACAA for ; Wed, 1 Feb 2023 06:59:08 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rZ-0E; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZW-001w1E-Hn; Wed, 01 Feb 2023 15:58:49 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hVQ-Bo; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 06/23] net: phy: c22: migrate to genphy_c45_write_eee_adv() Date: Wed, 1 Feb 2023 15:58:28 +0100 Message-Id: <20230201145845.2312060-7-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Migrate from genphy_config_eee_advert() to genphy_c45_write_eee_adv(). It should work as before except write operation to the EEE adv registers will be done only if some EEE abilities was detected. If some driver will have a regression, related driver should provide own .get_features callback. See micrel.c:ksz9477_get_features() as example. Signed-off-by: Oleksij Rempel --- drivers/net/phy/phy_device.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 3651f1fd8fc9..0c47fa765b69 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2231,7 +2231,10 @@ int __genphy_config_aneg(struct phy_device *phydev, = bool changed) { int err; =20 - if (genphy_config_eee_advert(phydev)) + err =3D genphy_c45_write_eee_adv(phydev, phydev->supported_eee); + if (err < 0) + return err; + else if (err) changed =3D true; =20 err =3D genphy_setup_master_slave(phydev); @@ -2653,6 +2656,11 @@ int genphy_read_abilities(struct phy_device *phydev) phydev->supported, val & ESTATUS_1000_XFULL); } =20 + /* This is optional functionality. If not supported, we may get an error + * which should be ignored. + */ + genphy_c45_read_eee_abilities(phydev); + return 0; } EXPORT_SYMBOL(genphy_read_abilities); --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FC0AC636CD for ; Wed, 1 Feb 2023 14:59:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231841AbjBAO7h (ORCPT ); Wed, 1 Feb 2023 09:59:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231956AbjBAO7F (ORCPT ); Wed, 1 Feb 2023 09:59:05 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8208C6AC96 for ; Wed, 1 Feb 2023 06:59:03 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rV-0D; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZV-001w14-Pv; Wed, 01 Feb 2023 15:58:48 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hVZ-CN; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 07/23] net: phy: c45: migrate to genphy_c45_write_eee_adv() Date: Wed, 1 Feb 2023 15:58:29 +0100 Message-Id: <20230201145845.2312060-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Migrate from genphy_config_eee_advert() to genphy_c45_write_eee_adv(). It should work as before except write operation to the EEE adv registers will be done only if some EEE abilities was detected. If some driver will have a regression, related driver should provide own .get_features callback. See micrel.c:ksz9477_get_features() as example. Signed-off-by: Oleksij Rempel --- drivers/net/phy/phy-c45.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 9582c8bf74ec..6149e8c3243f 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -262,7 +262,11 @@ int genphy_c45_an_config_aneg(struct phy_device *phyde= v) linkmode_and(phydev->advertising, phydev->advertising, phydev->supported); =20 - changed =3D genphy_config_eee_advert(phydev); + ret =3D genphy_c45_write_eee_adv(phydev, phydev->supported_eee); + if (ret < 0) + return ret; + else if (ret) + changed =3D true; =20 if (genphy_c45_baset1_able(phydev)) return genphy_c45_baset1_an_config_aneg(phydev); @@ -950,6 +954,11 @@ int genphy_c45_pma_read_abilities(struct phy_device *p= hydev) } } =20 + /* This is optional functionality. If not supported, we may get an error + * which should be ignored. + */ + genphy_c45_read_eee_abilities(phydev); + return 0; } EXPORT_SYMBOL_GPL(genphy_c45_pma_read_abilities); --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06490C636CD for ; Wed, 1 Feb 2023 15:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232913AbjBAPAi (ORCPT ); Wed, 1 Feb 2023 10:00:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232784AbjBAO7T (ORCPT ); Wed, 1 Feb 2023 09:59:19 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E9FB6ACA1 for ; Wed, 1 Feb 2023 06:59:08 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rW-0C; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZV-001w15-Se; Wed, 01 Feb 2023 15:58:48 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hVi-Ct; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 08/23] net: phy: migrate phy_init_eee() to genphy_c45_eee_is_active() Date: Wed, 1 Feb 2023 15:58:30 +0100 Message-Id: <20230201145845.2312060-9-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Reduce code duplicated by migrating phy_init_eee() to genphy_c45_eee_is_active(). Signed-off-by: Oleksij Rempel --- drivers/net/phy/phy.c | 89 +++++++------------------------------------ 1 file changed, 14 insertions(+), 75 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 41cfb24c48c1..36533746630e 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1457,30 +1457,6 @@ void phy_mac_interrupt(struct phy_device *phydev) } EXPORT_SYMBOL(phy_mac_interrupt); =20 -static void mmd_eee_adv_to_linkmode(unsigned long *advertising, u16 eee_ad= v) -{ - linkmode_zero(advertising); - - if (eee_adv & MDIO_EEE_100TX) - linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, - advertising); - if (eee_adv & MDIO_EEE_1000T) - linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, - advertising); - if (eee_adv & MDIO_EEE_10GT) - linkmode_set_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, - advertising); - if (eee_adv & MDIO_EEE_1000KX) - linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseKX_Full_BIT, - advertising); - if (eee_adv & MDIO_EEE_10GKX4) - linkmode_set_bit(ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, - advertising); - if (eee_adv & MDIO_EEE_10GKR) - linkmode_set_bit(ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, - advertising); -} - /** * phy_init_eee - init and check the EEE feature * @phydev: target phy_device struct @@ -1493,62 +1469,25 @@ static void mmd_eee_adv_to_linkmode(unsigned long *= advertising, u16 eee_adv) */ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable) { + int ret; + if (!phydev->drv) return -EIO; =20 - /* According to 802.3az,the EEE is supported only in full duplex-mode. - */ - if (phydev->duplex =3D=3D DUPLEX_FULL) { - __ETHTOOL_DECLARE_LINK_MODE_MASK(common); - __ETHTOOL_DECLARE_LINK_MODE_MASK(lp); - __ETHTOOL_DECLARE_LINK_MODE_MASK(adv); - int eee_lp, eee_cap, eee_adv; - int status; - u32 cap; - - /* Read phy status to properly get the right settings */ - status =3D phy_read_status(phydev); - if (status) - return status; - - /* First check if the EEE ability is supported */ - eee_cap =3D phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE); - if (eee_cap <=3D 0) - goto eee_exit_err; - - cap =3D mmd_eee_cap_to_ethtool_sup_t(eee_cap); - if (!cap) - goto eee_exit_err; - - /* Check which link settings negotiated and verify it in - * the EEE advertising registers. - */ - eee_lp =3D phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE); - if (eee_lp <=3D 0) - goto eee_exit_err; - - eee_adv =3D phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV); - if (eee_adv <=3D 0) - goto eee_exit_err; - - mmd_eee_adv_to_linkmode(adv, eee_adv); - mmd_eee_adv_to_linkmode(lp, eee_lp); - linkmode_and(common, adv, lp); - - if (!phy_check_valid(phydev->speed, phydev->duplex, common)) - goto eee_exit_err; + ret =3D genphy_c45_eee_is_active(phydev, NULL, NULL, NULL); + if (ret < 0) + return ret; + if (!ret) + return -EPROTONOSUPPORT; =20 - if (clk_stop_enable) - /* Configure the PHY to stop receiving xMII - * clock while it is signaling LPI. - */ - phy_set_bits_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, - MDIO_PCS_CTRL1_CLKSTOP_EN); + if (clk_stop_enable) + /* Configure the PHY to stop receiving xMII + * clock while it is signaling LPI. + */ + ret =3D phy_set_bits_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, + MDIO_PCS_CTRL1_CLKSTOP_EN); =20 - return 0; /* EEE supported */ - } -eee_exit_err: - return -EPROTONOSUPPORT; + return ret < 0 ? ret : 0; } EXPORT_SYMBOL(phy_init_eee); =20 --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5A83C636CD for ; Wed, 1 Feb 2023 14:59:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232807AbjBAO7k (ORCPT ); Wed, 1 Feb 2023 09:59:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232090AbjBAO7F (ORCPT ); Wed, 1 Feb 2023 09:59:05 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 847C26AC97 for ; Wed, 1 Feb 2023 06:59:03 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rg-0A; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZX-001w1b-An; Wed, 01 Feb 2023 15:58:50 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hVr-DQ; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 09/23] net: phy: start using genphy_c45_ethtool_get/set_eee() Date: Wed, 1 Feb 2023 15:58:31 +0100 Message-Id: <20230201145845.2312060-10-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" All preparations are done. Now we can start using new functions and remove the old code. Signed-off-by: Oleksij Rempel --- drivers/net/phy/phy.c | 60 ++----------------------------------------- 1 file changed, 2 insertions(+), 58 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 36533746630e..2f1041a7211e 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1517,33 +1517,10 @@ EXPORT_SYMBOL(phy_get_eee_err); */ int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *dat= a) { - int val; - if (!phydev->drv) return -EIO; =20 - /* Get Supported EEE */ - val =3D phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE); - if (val < 0) - return val; - data->supported =3D mmd_eee_cap_to_ethtool_sup_t(val); - - /* Get advertisement EEE */ - val =3D phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV); - if (val < 0) - return val; - data->advertised =3D mmd_eee_adv_to_ethtool_adv_t(val); - data->eee_enabled =3D !!data->advertised; - - /* Get LP advertisement EEE */ - val =3D phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE); - if (val < 0) - return val; - data->lp_advertised =3D mmd_eee_adv_to_ethtool_adv_t(val); - - data->eee_active =3D !!(data->advertised & data->lp_advertised); - - return 0; + return genphy_c45_ethtool_get_eee(phydev, data); } EXPORT_SYMBOL(phy_ethtool_get_eee); =20 @@ -1556,43 +1533,10 @@ EXPORT_SYMBOL(phy_ethtool_get_eee); */ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *dat= a) { - int cap, old_adv, adv =3D 0, ret; - if (!phydev->drv) return -EIO; =20 - /* Get Supported EEE */ - cap =3D phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE); - if (cap < 0) - return cap; - - old_adv =3D phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV); - if (old_adv < 0) - return old_adv; - - if (data->eee_enabled) { - adv =3D !data->advertised ? cap : - ethtool_adv_to_mmd_eee_adv_t(data->advertised) & cap; - /* Mask prohibited EEE modes */ - adv &=3D ~phydev->eee_broken_modes; - } - - if (old_adv !=3D adv) { - ret =3D phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv); - if (ret < 0) - return ret; - - /* Restart autonegotiation so the new modes get sent to the - * link partner. - */ - if (phydev->autoneg =3D=3D AUTONEG_ENABLE) { - ret =3D phy_restart_aneg(phydev); - if (ret < 0) - return ret; - } - } - - return 0; + return genphy_c45_ethtool_set_eee(phydev, data); } EXPORT_SYMBOL(phy_ethtool_set_eee); =20 --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2D92C636D3 for ; Wed, 1 Feb 2023 15:00:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232874AbjBAPAU (ORCPT ); Wed, 1 Feb 2023 10:00:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232520AbjBAO7G (ORCPT ); Wed, 1 Feb 2023 09:59:06 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55C0265EE9 for ; Wed, 1 Feb 2023 06:59:04 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002ri-0K; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZX-001w1h-QP; Wed, 01 Feb 2023 15:58:50 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hW0-Dx; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 10/23] net: phy: add driver specific get/set_eee support Date: Wed, 1 Feb 2023 15:58:32 +0100 Message-Id: <20230201145845.2312060-11-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Not all PHYs can be handled by generic phy_ethtool_get/set_eee() functions. So, add driver specific get/set_eee support. Signed-off-by: Oleksij Rempel --- drivers/net/phy/phy.c | 6 ++++++ include/linux/phy.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 2f1041a7211e..c42df62df302 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1520,6 +1520,9 @@ int phy_ethtool_get_eee(struct phy_device *phydev, st= ruct ethtool_eee *data) if (!phydev->drv) return -EIO; =20 + if (phydev->drv->get_eee) + return phydev->drv->get_eee(phydev, data); + return genphy_c45_ethtool_get_eee(phydev, data); } EXPORT_SYMBOL(phy_ethtool_get_eee); @@ -1536,6 +1539,9 @@ int phy_ethtool_set_eee(struct phy_device *phydev, st= ruct ethtool_eee *data) if (!phydev->drv) return -EIO; =20 + if (phydev->drv->set_eee) + return phydev->drv->set_eee(phydev, data); + return genphy_c45_ethtool_set_eee(phydev, data); } EXPORT_SYMBOL(phy_ethtool_set_eee); diff --git a/include/linux/phy.h b/include/linux/phy.h index f8fbbf137ece..89556cb2c555 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1051,6 +1051,11 @@ struct phy_driver { /** @get_plca_status: Return the current PLCA status info */ int (*get_plca_status)(struct phy_device *dev, struct phy_plca_status *plca_st); + + /** @get_eee: Return the current EEE configuration */ + int (*get_eee)(struct phy_device *phydev, struct ethtool_eee *e); + /** @set_eee: Set the EEE configuration */ + int (*set_eee)(struct phy_device *phydev, struct ethtool_eee *e); }; #define to_phy_driver(d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv) --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88687C05027 for ; Wed, 1 Feb 2023 15:00:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232891AbjBAPA3 (ORCPT ); Wed, 1 Feb 2023 10:00:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbjBAO7I (ORCPT ); Wed, 1 Feb 2023 09:59:08 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8AF96B988 for ; Wed, 1 Feb 2023 06:59:05 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZc-0002re-1H; Wed, 01 Feb 2023 15:58:56 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZX-001w1S-1S; Wed, 01 Feb 2023 15:58:50 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hW9-EV; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 11/23] net: phy: at803x: implement ethtool access to SmartEEE functionality Date: Wed, 1 Feb 2023 15:58:33 +0100 Message-Id: <20230201145845.2312060-12-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If AR8035 PHY is used with a MAC without EEE support (iMX6, etc), then we need to process ethtool_eee::tx_lpi_timer and tx_lpi_enabled by the PHY driver. So, add get/set_eee support for this functionality. Signed-off-by: Oleksij Rempel --- drivers/net/phy/at803x.c | 109 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 22f4458274aa..9eb4439b0afc 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -166,8 +166,18 @@ =20 #define AT803X_MMD3_SMARTEEE_CTL1 0x805b #define AT803X_MMD3_SMARTEEE_CTL2 0x805c +#define AT803X_MMD3_SMARTEEE_LPI_TIME_LOW GENMASK(15, 0) +#define AT803X_MMD3_SMARTEEE_LPI_TIME_15_0 GENMASK(15, 0) #define AT803X_MMD3_SMARTEEE_CTL3 0x805d #define AT803X_MMD3_SMARTEEE_CTL3_LPI_EN BIT(8) +#define AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH GENMASK(7, 0) +#define AT803X_MMD3_SMARTEEE_LPI_TIME_23_16 GENMASK(23, 16) +/* Tx LPI timer resolution */ +#define AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS 163840 +#define AT803X_MMD3_SMARTEEE_LPI_TIME_MAX_US \ + ((GENMASK(23, 0) * AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS) / \ + NSEC_PER_USEC) +#define AT803X_MMD3_SMARTEEE_LPI_TIME_DEF_US 335544 =20 #define ATH9331_PHY_ID 0x004dd041 #define ATH8030_PHY_ID 0x004dd076 @@ -951,17 +961,26 @@ static int at803x_get_features(struct phy_device *phy= dev) return 0; } =20 -static int at803x_smarteee_config(struct phy_device *phydev) +static int at803x_smarteee_config(struct phy_device *phydev, bool enable, + u32 tx_lpi_timer_us) { struct at803x_priv *priv =3D phydev->priv; + u64 tx_lpi_timer_raw; + u64 tx_lpi_timer_ns; u16 mask =3D 0, val =3D 0; int ret; =20 - if (priv->flags & AT803X_DISABLE_SMARTEEE) + if (priv->flags & AT803X_DISABLE_SMARTEEE || !enable) return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3, AT803X_MMD3_SMARTEEE_CTL3_LPI_EN, 0); =20 + if (tx_lpi_timer_us > AT803X_MMD3_SMARTEEE_LPI_TIME_MAX_US) { + phydev_err(phydev, "Max LPI timer is %lu microsecs\n", + AT803X_MMD3_SMARTEEE_LPI_TIME_MAX_US); + return -EINVAL; + } + if (priv->smarteee_lpi_tw_1g) { mask |=3D 0xff00; val |=3D priv->smarteee_lpi_tw_1g << 8; @@ -978,9 +997,27 @@ static int at803x_smarteee_config(struct phy_device *p= hydev) if (ret) return ret; =20 + tx_lpi_timer_ns =3D tx_lpi_timer_us * NSEC_PER_USEC; + tx_lpi_timer_raw =3D + DIV_ROUND_CLOSEST_ULL(tx_lpi_timer_ns, + AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS); + val =3D FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_LOW, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_15_0, + tx_lpi_timer_raw)); + + ret =3D phy_write_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL2, + val); + if (ret) + return ret; + + val =3D AT803X_MMD3_SMARTEEE_CTL3_LPI_EN | + FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16, + tx_lpi_timer_raw)); + return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3, - AT803X_MMD3_SMARTEEE_CTL3_LPI_EN, - AT803X_MMD3_SMARTEEE_CTL3_LPI_EN); + AT803X_MMD3_SMARTEEE_CTL3_LPI_EN | + AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH, val); } =20 static int at803x_clk_out_config(struct phy_device *phydev) @@ -1067,7 +1104,8 @@ static int at803x_config_init(struct phy_device *phyd= ev) if (ret < 0) return ret; =20 - ret =3D at803x_smarteee_config(phydev); + ret =3D at803x_smarteee_config(phydev, true, + AT803X_MMD3_SMARTEEE_LPI_TIME_DEF_US); if (ret < 0) return ret; =20 @@ -1612,6 +1650,65 @@ static int at803x_cable_test_start(struct phy_device= *phydev) return 0; } =20 +static int at803x_get_eee(struct phy_device *phydev, struct ethtool_eee *d= ata) +{ + struct at803x_priv *priv =3D phydev->priv; + u32 tx_timer_raw; + u64 tx_timer_ns; + int ret; + + /* If SmartEEE is not enabled, it is expected that tx_lpi_* fields + * are processed by the MAC driver. + */ + if (priv->flags & AT803X_DISABLE_SMARTEEE) + return genphy_c45_ethtool_get_eee(phydev, data); + + ret =3D phy_read_mmd(phydev, MDIO_MMD_PCS, + AT803X_MMD3_SMARTEEE_CTL2); + tx_timer_raw =3D FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_15_0, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_LOW, + ret)); + if (ret < 0) + return ret; + + ret =3D phy_read_mmd(phydev, MDIO_MMD_PCS, + AT803X_MMD3_SMARTEEE_CTL3); + if (ret < 0) + return ret; + + tx_timer_raw |=3D FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH, + ret)); + tx_timer_ns =3D tx_timer_raw * AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS; + data->tx_lpi_timer =3D DIV_ROUND_CLOSEST_ULL(tx_timer_ns, NSEC_PER_USEC); + + data->tx_lpi_enabled =3D !!(ret & AT803X_MMD3_SMARTEEE_CTL3_LPI_EN); + + return genphy_c45_ethtool_get_eee(phydev, data); +} + +static int at803x_set_eee(struct phy_device *phydev, struct ethtool_eee *d= ata) +{ + struct at803x_priv *priv =3D phydev->priv; + int ret; + + /* If SmartEEE is not enabled, it is expected that tx_lpi_* fields + * are processed by the MAC driver. + */ + if (priv->flags & AT803X_DISABLE_SMARTEEE) + return genphy_c45_ethtool_set_eee(phydev, data); + + /* Changing Tx LPI on/off or Tx LPI timer settings + * do not require link reset. + */ + ret =3D at803x_smarteee_config(phydev, data->tx_lpi_enabled, + data->tx_lpi_timer); + if (ret) + return ret; + + return genphy_c45_ethtool_set_eee(phydev, data); +} + static int qca83xx_config_init(struct phy_device *phydev) { u8 switch_revision; @@ -2038,6 +2135,8 @@ static struct phy_driver at803x_driver[] =3D { .set_tunable =3D at803x_set_tunable, .cable_test_start =3D at803x_cable_test_start, .cable_test_get_status =3D at803x_cable_test_get_status, + .get_eee =3D at803x_get_eee, + .set_eee =3D at803x_set_eee, }, { /* Qualcomm Atheros AR8030 */ .phy_id =3D ATH8030_PHY_ID, --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4085AC05027 for ; Wed, 1 Feb 2023 14:59:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232018AbjBAO7p (ORCPT ); Wed, 1 Feb 2023 09:59:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232166AbjBAO7F (ORCPT ); Wed, 1 Feb 2023 09:59:05 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D99C56AC99 for ; Wed, 1 Feb 2023 06:59:03 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rY-0C; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZW-001w1D-CR; Wed, 01 Feb 2023 15:58:49 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hWI-F4; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 12/23] net: phy: at803x: ar8035: fix EEE support for half duplex links Date: Wed, 1 Feb 2023 15:58:34 +0100 Message-Id: <20230201145845.2312060-13-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If AR8035 is running with enabled EEE and LPI, it will not be able to establish an 100BaseTX/Half or 1000BaseT/Half link. Similar issue we will have with 100BaseTX/Full and LPI TX timer configured to less then 80msec. To avoid this issue, we need to keep LPI disabled before link is establish and enable it only we detected supported link configuration. Signed-off-by: Oleksij Rempel --- drivers/net/phy/at803x.c | 41 +++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 9eb4439b0afc..5ab43eb63581 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -313,6 +313,7 @@ struct at803x_priv { u8 smarteee_lpi_tw_100m; bool is_fiber; bool is_1000basex; + bool tx_lpi_on; struct regulator_dev *vddio_rdev; struct regulator_dev *vddh_rdev; struct regulator *vddio; @@ -970,6 +971,8 @@ static int at803x_smarteee_config(struct phy_device *ph= ydev, bool enable, u16 mask =3D 0, val =3D 0; int ret; =20 + priv->tx_lpi_on =3D enable; + if (priv->flags & AT803X_DISABLE_SMARTEEE || !enable) return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3, @@ -1010,10 +1013,15 @@ static int at803x_smarteee_config(struct phy_device= *phydev, bool enable, if (ret) return ret; =20 - val =3D AT803X_MMD3_SMARTEEE_CTL3_LPI_EN | - FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH, - FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16, - tx_lpi_timer_raw)); + val =3D FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16, + tx_lpi_timer_raw)); + + if (phydev->state =3D=3D PHY_RUNNING && + phy_check_valid(phydev->speed, phydev->duplex, + phydev->supported_eee)) { + val |=3D AT803X_MMD3_SMARTEEE_CTL3_LPI_EN; + } =20 return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3, AT803X_MMD3_SMARTEEE_CTL3_LPI_EN | @@ -1682,7 +1690,7 @@ static int at803x_get_eee(struct phy_device *phydev, = struct ethtool_eee *data) tx_timer_ns =3D tx_timer_raw * AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS; data->tx_lpi_timer =3D DIV_ROUND_CLOSEST_ULL(tx_timer_ns, NSEC_PER_USEC); =20 - data->tx_lpi_enabled =3D !!(ret & AT803X_MMD3_SMARTEEE_CTL3_LPI_EN); + data->tx_lpi_enabled =3D priv->tx_lpi_on; =20 return genphy_c45_ethtool_get_eee(phydev, data); } @@ -1709,6 +1717,28 @@ static int at803x_set_eee(struct phy_device *phydev,= struct ethtool_eee *data) return genphy_c45_ethtool_set_eee(phydev, data); } =20 +static void at8035_link_change_notify(struct phy_device *phydev) +{ + struct at803x_priv *priv =3D phydev->priv; + + if (priv->flags & AT803X_DISABLE_SMARTEEE) + return; + + if (phydev->state =3D=3D PHY_RUNNING) { + if (priv->tx_lpi_on && phy_check_valid(phydev->speed, + phydev->duplex, + phydev->supported_eee)) + phy_set_bits_mmd(phydev, MDIO_MMD_PCS, + AT803X_MMD3_SMARTEEE_CTL3, + AT803X_MMD3_SMARTEEE_CTL3_LPI_EN); + } else { + if (priv->tx_lpi_on) + phy_clear_bits_mmd(phydev, MDIO_MMD_PCS, + AT803X_MMD3_SMARTEEE_CTL3, + AT803X_MMD3_SMARTEEE_CTL3_LPI_EN); + } +} + static int qca83xx_config_init(struct phy_device *phydev) { u8 switch_revision; @@ -2137,6 +2167,7 @@ static struct phy_driver at803x_driver[] =3D { .cable_test_get_status =3D at803x_cable_test_get_status, .get_eee =3D at803x_get_eee, .set_eee =3D at803x_set_eee, + .link_change_notify =3D at8035_link_change_notify, }, { /* Qualcomm Atheros AR8030 */ .phy_id =3D ATH8030_PHY_ID, --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FAA3C05027 for ; Wed, 1 Feb 2023 15:00:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232895AbjBAPAc (ORCPT ); Wed, 1 Feb 2023 10:00:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232717AbjBAO7J (ORCPT ); Wed, 1 Feb 2023 09:59:09 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38B7A6B9A6 for ; Wed, 1 Feb 2023 06:59:07 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZd-0002rn-06; Wed, 01 Feb 2023 15:58:57 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZY-001w1w-8a; Wed, 01 Feb 2023 15:58:51 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hWR-Fc; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 13/23] net: phy: add PHY specifica flag to signal SmartEEE support Date: Wed, 1 Feb 2023 15:58:35 +0100 Message-Id: <20230201145845.2312060-14-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Typical EEE support need cooperation of MAC and PHY, so both parts should be able to do EEE. But, there also PHYs compatible with normal 802.3az standard working with legacy MAC without EEE ability, acting as a complete EEE power saving system. To identify this PHYs we need a PHY specific flag. Since the PHY specification implementing this functionality calls it SmartEEE, use the same flag name - PHY_SMART_EEE. Signed-off-by: Oleksij Rempel --- include/linux/phy.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/phy.h b/include/linux/phy.h index 89556cb2c555..6063b0c7a06e 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -85,6 +85,7 @@ extern const int phy_10gbit_features_array[1]; #define PHY_IS_INTERNAL 0x00000001 #define PHY_RST_AFTER_CLK_EN 0x00000002 #define PHY_POLL_CABLE_TEST 0x00000004 +#define PHY_SMART_EEE 0x00000008 /* EEE done by PHY without MAC */ #define MDIO_DEVICE_IS_PHY 0x80000000 =20 /** --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92F83C05027 for ; Wed, 1 Feb 2023 14:59:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232646AbjBAO7H (ORCPT ); Wed, 1 Feb 2023 09:59:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbjBAO7D (ORCPT ); Wed, 1 Feb 2023 09:59:03 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE1B965EE9 for ; Wed, 1 Feb 2023 06:59:02 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rk-0A; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZY-001w1k-10; Wed, 01 Feb 2023 15:58:51 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hWa-G8; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 14/23] net: phy: at803x: add PHY_SMART_EEE flag to AR8035 Date: Wed, 1 Feb 2023 15:58:36 +0100 Message-Id: <20230201145845.2312060-15-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" AR8035 is one of the PHYs with SmartEEE functionality. This flag will be used by one of next patches on the i.MX FEC driver. Signed-off-by: Oleksij Rempel --- drivers/net/phy/at803x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 5ab43eb63581..94dbec0a992c 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -2147,7 +2147,7 @@ static struct phy_driver at803x_driver[] =3D { /* Qualcomm Atheros AR8035 */ PHY_ID_MATCH_EXACT(ATH8035_PHY_ID), .name =3D "Qualcomm Atheros AR8035", - .flags =3D PHY_POLL_CABLE_TEST, + .flags =3D PHY_POLL_CABLE_TEST | PHY_SMART_EEE, .probe =3D at803x_probe, .remove =3D at803x_remove, .config_aneg =3D at803x_config_aneg, --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0D54C636D3 for ; Wed, 1 Feb 2023 15:00:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232883AbjBAO75 (ORCPT ); Wed, 1 Feb 2023 09:59:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232285AbjBAO7F (ORCPT ); Wed, 1 Feb 2023 09:59:05 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5E336ACA1 for ; Wed, 1 Feb 2023 06:59:03 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rl-0N; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZY-001w1q-5E; Wed, 01 Feb 2023 15:58:51 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hWj-Ge; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 15/23] net: phy: add phy_has_smarteee() helper Date: Wed, 1 Feb 2023 15:58:37 +0100 Message-Id: <20230201145845.2312060-16-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add helper to identify PHYs with SmartEEE support. Signed-off-by: Oleksij Rempel --- include/linux/phy.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/phy.h b/include/linux/phy.h index 6063b0c7a06e..c85187897115 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1407,6 +1407,15 @@ static inline bool phy_polling_mode(struct phy_devic= e *phydev) return phydev->irq =3D=3D PHY_POLL; } =20 +/** + * phy_has_rxtstamp - Tests whether a PHY supports SmartEEE. + * @phydev: the phy_device struct + */ +static inline bool phy_has_smarteee(struct phy_device *phydev) +{ + return phydev && phydev->drv && !!(phydev->drv->flags & PHY_SMART_EEE); +} + /** * phy_has_hwtstamp - Tests whether a PHY time stamp configuration. * @phydev: the phy_device struct --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FD13C636CD for ; Wed, 1 Feb 2023 15:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231781AbjBAPAG (ORCPT ); Wed, 1 Feb 2023 10:00:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232320AbjBAO7F (ORCPT ); Wed, 1 Feb 2023 09:59:05 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FA716ACAA for ; Wed, 1 Feb 2023 06:59:04 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rf-0D; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZX-001w1V-48; Wed, 01 Feb 2023 15:58:50 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hWs-H9; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 16/23] net: fec: add support for PHYs with SmartEEE support Date: Wed, 1 Feb 2023 15:58:38 +0100 Message-Id: <20230201145845.2312060-17-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Ethernet controller in i.MX6*/i.MX7* series do not provide EEE support. But this chips are used sometimes in combinations with SmartEEE capable PHYs. So, instead of aborting get/set_eee access on MACs without EEE support, ask PHY if it is able to do the EEE job by using SmartEEE. Signed-off-by: Oleksij Rempel --- drivers/net/ethernet/freescale/fec_main.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethern= et/freescale/fec_main.c index 5ff45b1a74a5..fb5c050f3fd3 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3102,8 +3102,15 @@ fec_enet_get_eee(struct net_device *ndev, struct eth= tool_eee *edata) struct fec_enet_private *fep =3D netdev_priv(ndev); struct ethtool_eee *p =3D &fep->eee; =20 - if (!(fep->quirks & FEC_QUIRK_HAS_EEE)) - return -EOPNOTSUPP; + if (!(fep->quirks & FEC_QUIRK_HAS_EEE)) { + if (!netif_running(ndev)) + return -ENETDOWN; + + if (!phy_has_smarteee(ndev->phydev)) + return -EOPNOTSUPP; + + return phy_ethtool_get_eee(ndev->phydev, edata); + } =20 if (!netif_running(ndev)) return -ENETDOWN; @@ -3123,8 +3130,15 @@ fec_enet_set_eee(struct net_device *ndev, struct eth= tool_eee *edata) struct ethtool_eee *p =3D &fep->eee; int ret =3D 0; =20 - if (!(fep->quirks & FEC_QUIRK_HAS_EEE)) - return -EOPNOTSUPP; + if (!(fep->quirks & FEC_QUIRK_HAS_EEE)) { + if (!netif_running(ndev)) + return -ENETDOWN; + + if (!phy_has_smarteee(ndev->phydev)) + return -EOPNOTSUPP; + + return phy_ethtool_set_eee(ndev->phydev, edata); + } =20 if (!netif_running(ndev)) return -ENETDOWN; --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68ABFC636CD for ; Wed, 1 Feb 2023 14:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232805AbjBAO7b (ORCPT ); Wed, 1 Feb 2023 09:59:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231903AbjBAO7F (ORCPT ); Wed, 1 Feb 2023 09:59:05 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 676CB6A71F for ; Wed, 1 Feb 2023 06:59:03 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rh-0E; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZX-001w1d-Fq; Wed, 01 Feb 2023 15:58:50 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hX1-Hg; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 17/23] e1000e: replace EEE ethtool helpers to linkmode variants Date: Wed, 1 Feb 2023 15:58:39 +0100 Message-Id: <20230201145845.2312060-18-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace EEE ethtool helpers with linkmode variants. This will reduce similar code snippets and prepare ethtool EEE interface to linkmode migration. Signed-off-by: Oleksij Rempel --- drivers/net/ethernet/intel/e1000e/ethtool.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethe= rnet/intel/e1000e/ethtool.c index 721f86fd5802..7285e93b34ce 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -2188,6 +2188,9 @@ static int e1000_get_rxnfc(struct net_device *netdev, static int e1000e_get_eee(struct net_device *netdev, struct ethtool_eee *e= data) { struct e1000_adapter *adapter =3D netdev_priv(netdev); + __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_able) =3D {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_adv) =3D {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_lp) =3D {}; struct e1000_hw *hw =3D &adapter->hw; u16 cap_addr, lpa_addr, pcs_stat_addr, phy_data; u32 ret_val; @@ -2222,16 +2225,19 @@ static int e1000e_get_eee(struct net_device *netdev= , struct ethtool_eee *edata) ret_val =3D e1000_read_emi_reg_locked(hw, cap_addr, &phy_data); if (ret_val) goto release; - edata->supported =3D mmd_eee_cap_to_ethtool_sup_t(phy_data); + mii_eee_100_10000_adv_mod_linkmode_t(lm_able, phy_data); + ethtool_convert_link_mode_to_legacy_u32(&edata->supported, lm_able); =20 /* EEE Advertised */ - edata->advertised =3D mmd_eee_adv_to_ethtool_adv_t(adapter->eee_advert); + mii_eee_100_10000_adv_mod_linkmode_t(lm_adv, adapter->eee_advert); + ethtool_convert_link_mode_to_legacy_u32(&edata->advertised, lm_adv); =20 /* EEE Link Partner Advertised */ ret_val =3D e1000_read_emi_reg_locked(hw, lpa_addr, &phy_data); if (ret_val) goto release; - edata->lp_advertised =3D mmd_eee_adv_to_ethtool_adv_t(phy_data); + mii_eee_100_10000_adv_mod_linkmode_t(lm_lp, phy_data); + ethtool_convert_link_mode_to_legacy_u32(&edata->lp_advertised, lm_lp); =20 /* EEE PCS Status */ ret_val =3D e1000_read_emi_reg_locked(hw, pcs_stat_addr, &phy_data); @@ -2264,6 +2270,7 @@ static int e1000e_get_eee(struct net_device *netdev, = struct ethtool_eee *edata) static int e1000e_set_eee(struct net_device *netdev, struct ethtool_eee *e= data) { struct e1000_adapter *adapter =3D netdev_priv(netdev); + __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) =3D {}; struct e1000_hw *hw =3D &adapter->hw; struct ethtool_eee eee_curr; s32 ret_val; @@ -2287,7 +2294,8 @@ static int e1000e_set_eee(struct net_device *netdev, = struct ethtool_eee *edata) return -EINVAL; } =20 - adapter->eee_advert =3D ethtool_adv_to_mmd_eee_adv_t(edata->advertised); + adv[0] =3D edata->advertised; + adapter->eee_advert =3D linkmode_adv_to_mii_eee_100_10000_adv_t(adv); =20 hw->dev_spec.ich8lan.eee_disable =3D !edata->eee_enabled; =20 --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D5FBC05027 for ; Wed, 1 Feb 2023 14:59:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231946AbjBAO71 (ORCPT ); Wed, 1 Feb 2023 09:59:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231893AbjBAO7E (ORCPT ); Wed, 1 Feb 2023 09:59:04 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 682B96A73F for ; Wed, 1 Feb 2023 06:59:03 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rj-0F; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZY-001w1l-12; Wed, 01 Feb 2023 15:58:51 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hXA-ID; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 18/23] igb: replace EEE ethtool helpers to linkmode variants Date: Wed, 1 Feb 2023 15:58:40 +0100 Message-Id: <20230201145845.2312060-19-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace EEE ethtool helpers with linkmode variants. This will reduce similar code snippets and prepare ethtool EEE interface to linkmode migration. Signed-off-by: Oleksij Rempel --- drivers/net/ethernet/intel/igb/igb_ethtool.c | 23 +++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/eth= ernet/intel/igb/igb_ethtool.c index 7d60da1b7bf4..f7a633f0d6a6 100644 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c @@ -3026,6 +3026,8 @@ static int igb_set_rxnfc(struct net_device *dev, stru= ct ethtool_rxnfc *cmd) static int igb_get_eee(struct net_device *netdev, struct ethtool_eee *edat= a) { struct igb_adapter *adapter =3D netdev_priv(netdev); + __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) =3D {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(lp) =3D {}; struct e1000_hw *hw =3D &adapter->hw; u32 ret_val; u16 phy_data; @@ -3036,9 +3038,12 @@ static int igb_get_eee(struct net_device *netdev, st= ruct ethtool_eee *edata) =20 edata->supported =3D (SUPPORTED_1000baseT_Full | SUPPORTED_100baseT_Full); - if (!hw->dev_spec._82575.eee_disable) - edata->advertised =3D - mmd_eee_adv_to_ethtool_adv_t(adapter->eee_advert); + + if (!hw->dev_spec._82575.eee_disable) { + mii_eee_100_10000_adv_mod_linkmode_t(adv, adapter->eee_advert); + ethtool_convert_link_mode_to_legacy_u32(&edata->advertised, + adv); + } =20 /* The IPCNFG and EEER registers are not supported on I354. */ if (hw->mac.type =3D=3D e1000_i354) { @@ -3064,7 +3069,9 @@ static int igb_get_eee(struct net_device *netdev, str= uct ethtool_eee *edata) if (ret_val) return -ENODATA; =20 - edata->lp_advertised =3D mmd_eee_adv_to_ethtool_adv_t(phy_data); + mii_eee_100_10000_adv_mod_linkmode_t(lp, phy_data); + ethtool_convert_link_mode_to_legacy_u32(&edata->lp_advertised, + lp); break; case e1000_i354: case e1000_i210: @@ -3075,7 +3082,9 @@ static int igb_get_eee(struct net_device *netdev, str= uct ethtool_eee *edata) if (ret_val) return -ENODATA; =20 - edata->lp_advertised =3D mmd_eee_adv_to_ethtool_adv_t(phy_data); + mii_eee_100_10000_adv_mod_linkmode_t(lp, phy_data); + ethtool_convert_link_mode_to_legacy_u32(&edata->lp_advertised, + lp); =20 break; default: @@ -3105,6 +3114,7 @@ static int igb_set_eee(struct net_device *netdev, struct ethtool_eee *edata) { struct igb_adapter *adapter =3D netdev_priv(netdev); + __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) =3D {}; struct e1000_hw *hw =3D &adapter->hw; struct ethtool_eee eee_curr; bool adv1g_eee =3D true, adv100m_eee =3D true; @@ -3149,7 +3159,8 @@ static int igb_set_eee(struct net_device *netdev, return -EINVAL; } =20 - adapter->eee_advert =3D ethtool_adv_to_mmd_eee_adv_t(edata->advertised); + adv[0] =3D edata->advertised; + adapter->eee_advert =3D linkmode_adv_to_mii_eee_100_10000_adv_t(adv); if (hw->dev_spec._82575.eee_disable !=3D !edata->eee_enabled) { hw->dev_spec._82575.eee_disable =3D !edata->eee_enabled; adapter->flags |=3D IGB_FLAG_EEE; --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2F9FC636CD for ; Wed, 1 Feb 2023 15:00:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229743AbjBAPAZ (ORCPT ); Wed, 1 Feb 2023 10:00:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232636AbjBAO7H (ORCPT ); Wed, 1 Feb 2023 09:59:07 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E33B6ACBB for ; Wed, 1 Feb 2023 06:59:04 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rc-0G; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZW-001w1N-SO; Wed, 01 Feb 2023 15:58:49 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hXJ-Ik; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 19/23] igc: replace EEE ethtool helpers to linkmode variants Date: Wed, 1 Feb 2023 15:58:41 +0100 Message-Id: <20230201145845.2312060-20-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace EEE ethtool helpers with linkmode variants. This will reduce similar code snippets and prepare ethtool EEE interface to linkmode migration. Signed-off-by: Oleksij Rempel --- drivers/net/ethernet/intel/igc/igc_ethtool.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/eth= ernet/intel/igc/igc_ethtool.c index 5a26a7805ef8..b23e904fc347 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -1582,12 +1582,14 @@ static int igc_ethtool_get_eee(struct net_device *n= etdev, struct ethtool_eee *edata) { struct igc_adapter *adapter =3D netdev_priv(netdev); + __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) =3D {}; struct igc_hw *hw =3D &adapter->hw; u32 eeer; =20 - if (hw->dev_spec._base.eee_enable) - edata->advertised =3D - mmd_eee_adv_to_ethtool_adv_t(adapter->eee_advert); + if (hw->dev_spec._base.eee_enable) { + mii_eee_100_10000_adv_mod_linkmode_t(adv, adapter->eee_advert); + ethtool_convert_link_mode_to_legacy_u32(&edata->advertised, adv); + } =20 *edata =3D adapter->eee; edata->supported =3D SUPPORTED_Autoneg; @@ -1623,6 +1625,7 @@ static int igc_ethtool_set_eee(struct net_device *net= dev, struct ethtool_eee *edata) { struct igc_adapter *adapter =3D netdev_priv(netdev); + __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) =3D {}; struct igc_hw *hw =3D &adapter->hw; struct ethtool_eee eee_curr; s32 ret_val; @@ -1655,7 +1658,8 @@ static int igc_ethtool_set_eee(struct net_device *net= dev, return -EINVAL; } =20 - adapter->eee_advert =3D ethtool_adv_to_mmd_eee_adv_t(edata->advertised); + adv[0] =3D edata->advertised; + adapter->eee_advert =3D linkmode_adv_to_mii_eee_100_10000_adv_t(adv); if (hw->dev_spec._base.eee_enable !=3D edata->eee_enabled) { hw->dev_spec._base.eee_enable =3D edata->eee_enabled; adapter->flags |=3D IGC_FLAG_EEE; --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D61A0C636D3 for ; Wed, 1 Feb 2023 14:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232742AbjBAO7O (ORCPT ); Wed, 1 Feb 2023 09:59:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230046AbjBAO7D (ORCPT ); Wed, 1 Feb 2023 09:59:03 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D128769B1B for ; Wed, 1 Feb 2023 06:59:02 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002ro-6K; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZY-001w1z-CZ; Wed, 01 Feb 2023 15:58:51 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hXS-JG; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 20/23] tg3: replace EEE ethtool helpers to linkmode variants Date: Wed, 1 Feb 2023 15:58:42 +0100 Message-Id: <20230201145845.2312060-21-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace EEE ethtool helpers with linkmode variants. This will reduce similar code snippets and prepare ethtool EEE interface to linkmode migration. Signed-off-by: Oleksij Rempel --- drivers/net/ethernet/broadcom/tg3.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/bro= adcom/tg3.c index 58747292521d..a3764e360d23 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -2339,6 +2339,8 @@ static void tg3_phy_apply_otp(struct tg3 *tp) =20 static void tg3_eee_pull_config(struct tg3 *tp, struct ethtool_eee *eee) { + __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) =3D {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(lp) =3D {}; u32 val; struct ethtool_eee *dest =3D &tp->eee; =20 @@ -2361,13 +2363,16 @@ static void tg3_eee_pull_config(struct tg3 *tp, str= uct ethtool_eee *eee) /* Pull lp advertised settings */ if (tg3_phy_cl45_read(tp, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE, &val)) return; - dest->lp_advertised =3D mmd_eee_adv_to_ethtool_adv_t(val); + mii_eee_100_10000_adv_mod_linkmode_t(lp, val); + ethtool_convert_link_mode_to_legacy_u32(&dest->lp_advertised, lp); + =20 /* Pull advertised and eee_enabled settings */ if (tg3_phy_cl45_read(tp, MDIO_MMD_AN, MDIO_AN_EEE_ADV, &val)) return; dest->eee_enabled =3D !!val; - dest->advertised =3D mmd_eee_adv_to_ethtool_adv_t(val); + mii_eee_100_10000_adv_mod_linkmode_t(adv, val); + ethtool_convert_link_mode_to_legacy_u32(&dest->advertised, adv); =20 /* Pull tx_lpi_enabled */ val =3D tr32(TG3_CPMU_EEE_MODE); --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5DC9C636D3 for ; Wed, 1 Feb 2023 15:00:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232727AbjBAPAL (ORCPT ); Wed, 1 Feb 2023 10:00:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232506AbjBAO7G (ORCPT ); Wed, 1 Feb 2023 09:59:06 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63E9C69B1B for ; Wed, 1 Feb 2023 06:59:04 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rr-KZ; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZY-001w28-K2; Wed, 01 Feb 2023 15:58:51 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hXb-Jm; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 21/23] r8152: replace EEE ethtool helpers to linkmode variants Date: Wed, 1 Feb 2023 15:58:43 +0100 Message-Id: <20230201145845.2312060-22-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace EEE ethtool helpers with linkmode variants. This will reduce similar code snippets and prepare ethtool EEE interface to linkmode migration. Signed-off-by: Oleksij Rempel --- drivers/net/usb/r8152.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index decb5ba56a25..dbfde0aec003 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -8745,17 +8745,23 @@ static void rtl8152_get_strings(struct net_device *= dev, u32 stringset, u8 *data) =20 static int r8152_get_eee(struct r8152 *tp, struct ethtool_eee *eee) { - u32 lp, adv, supported =3D 0; + __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_able) =3D {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_adv) =3D {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_lp) =3D {}; + u32 lp, adv, supported; u16 val; =20 val =3D r8152_mmd_read(tp, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE); - supported =3D mmd_eee_cap_to_ethtool_sup_t(val); + mii_eee_100_10000_adv_mod_linkmode_t(lm_able, val); + ethtool_convert_link_mode_to_legacy_u32(&supported, lm_able); =20 val =3D r8152_mmd_read(tp, MDIO_MMD_AN, MDIO_AN_EEE_ADV); - adv =3D mmd_eee_adv_to_ethtool_adv_t(val); + mii_eee_100_10000_adv_mod_linkmode_t(lm_adv, val); + ethtool_convert_link_mode_to_legacy_u32(&adv, lm_adv); =20 val =3D r8152_mmd_read(tp, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE); - lp =3D mmd_eee_adv_to_ethtool_adv_t(val); + mii_eee_100_10000_adv_mod_linkmode_t(lm_lp, val); + ethtool_convert_link_mode_to_legacy_u32(&lp, lm_lp); =20 eee->eee_enabled =3D tp->eee_en; eee->eee_active =3D !!(supported & adv & lp); @@ -8768,7 +8774,11 @@ static int r8152_get_eee(struct r8152 *tp, struct et= htool_eee *eee) =20 static int r8152_set_eee(struct r8152 *tp, struct ethtool_eee *eee) { - u16 val =3D ethtool_adv_to_mmd_eee_adv_t(eee->advertised); + __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) =3D {}; + u16 val; + + adv[0] =3D eee->advertised; + val =3D linkmode_adv_to_mii_eee_100_10000_adv_t(adv); =20 tp->eee_en =3D eee->eee_enabled; tp->eee_adv =3D val; @@ -8780,17 +8790,23 @@ static int r8152_set_eee(struct r8152 *tp, struct e= thtool_eee *eee) =20 static int r8153_get_eee(struct r8152 *tp, struct ethtool_eee *eee) { - u32 lp, adv, supported =3D 0; + __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_able) =3D {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_adv) =3D {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_lp) =3D {}; + u32 lp, adv, supported; u16 val; =20 val =3D ocp_reg_read(tp, OCP_EEE_ABLE); - supported =3D mmd_eee_cap_to_ethtool_sup_t(val); + mii_eee_100_10000_adv_mod_linkmode_t(lm_able, val); + ethtool_convert_link_mode_to_legacy_u32(&supported, lm_able); =20 val =3D ocp_reg_read(tp, OCP_EEE_ADV); - adv =3D mmd_eee_adv_to_ethtool_adv_t(val); + mii_eee_100_10000_adv_mod_linkmode_t(lm_adv, val); + ethtool_convert_link_mode_to_legacy_u32(&adv, lm_adv); =20 val =3D ocp_reg_read(tp, OCP_EEE_LPABLE); - lp =3D mmd_eee_adv_to_ethtool_adv_t(val); + mii_eee_100_10000_adv_mod_linkmode_t(lm_lp, val); + ethtool_convert_link_mode_to_legacy_u32(&lp, lm_lp); =20 eee->eee_enabled =3D tp->eee_en; eee->eee_active =3D !!(supported & adv & lp); --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08236C05027 for ; Wed, 1 Feb 2023 14:59:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232778AbjBAO7T (ORCPT ); Wed, 1 Feb 2023 09:59:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbjBAO7E (ORCPT ); Wed, 1 Feb 2023 09:59:04 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2846969B34 for ; Wed, 1 Feb 2023 06:59:03 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002rp-6Q; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZY-001w21-Du; Wed, 01 Feb 2023 15:58:51 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hXj-KI; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 22/23] net: usb: ax88179_178a: replace EEE ethtool helpers to linkmode variants Date: Wed, 1 Feb 2023 15:58:44 +0100 Message-Id: <20230201145845.2312060-23-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace EEE ethtool helpers with linkmode variants. This will reduce similar code snippets and prepare ethtool EEE interface to linkmode migration. Signed-off-by: Oleksij Rempel --- drivers/net/usb/ax88179_178a.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c index aff39bf3161d..7e8b5f174184 100644 --- a/drivers/net/usb/ax88179_178a.c +++ b/drivers/net/usb/ax88179_178a.c @@ -652,6 +652,9 @@ static int ax88179_set_link_ksettings(struct net_device= *net, static int ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_eee *data) { + __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_able) =3D {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_adv) =3D {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_lp) =3D {}; int val; =20 /* Get Supported EEE */ @@ -659,21 +662,24 @@ ax88179_ethtool_get_eee(struct usbnet *dev, struct et= htool_eee *data) MDIO_MMD_PCS); if (val < 0) return val; - data->supported =3D mmd_eee_cap_to_ethtool_sup_t(val); + mii_eee_100_10000_adv_mod_linkmode_t(lm_able, val); + ethtool_convert_link_mode_to_legacy_u32(&data->supported, lm_able); =20 /* Get advertisement EEE */ val =3D ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_ADV, MDIO_MMD_AN); if (val < 0) return val; - data->advertised =3D mmd_eee_adv_to_ethtool_adv_t(val); + mii_eee_100_10000_adv_mod_linkmode_t(lm_adv, val); + ethtool_convert_link_mode_to_legacy_u32(&data->advertised, lm_adv); =20 /* Get LP advertisement EEE */ val =3D ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_LPABLE, MDIO_MMD_AN); if (val < 0) return val; - data->lp_advertised =3D mmd_eee_adv_to_ethtool_adv_t(val); + mii_eee_100_10000_adv_mod_linkmode_t(lm_lp, val); + ethtool_convert_link_mode_to_legacy_u32(&data->lp_advertised, lm_lp); =20 return 0; } @@ -681,7 +687,11 @@ ax88179_ethtool_get_eee(struct usbnet *dev, struct eth= tool_eee *data) static int ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_eee *data) { - u16 tmp16 =3D ethtool_adv_to_mmd_eee_adv_t(data->advertised); + __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) =3D {}; + u16 tmp16; + + adv[0] =3D data->advertised; + tmp16 =3D linkmode_adv_to_mii_eee_100_10000_adv_t(adv); =20 return ax88179_phy_write_mmd_indirect(dev, MDIO_AN_EEE_ADV, MDIO_MMD_AN, tmp16); @@ -706,7 +716,7 @@ static int ax88179_chk_eee(struct usbnet *dev) return false; } =20 - cap =3D mmd_eee_cap_to_ethtool_sup_t(eee_cap); + cap =3D eee_cap & (MDIO_EEE_100TX | MDIO_EEE_1000T); if (!cap) { priv->eee_active =3D 0; return false; @@ -729,8 +739,8 @@ static int ax88179_chk_eee(struct usbnet *dev) return false; } =20 - adv =3D mmd_eee_adv_to_ethtool_adv_t(eee_adv); - lp =3D mmd_eee_adv_to_ethtool_adv_t(eee_lp); + adv =3D eee_adv & (MDIO_EEE_100TX | MDIO_EEE_1000T); + lp =3D eee_lp & (MDIO_EEE_100TX | MDIO_EEE_1000T); supported =3D (ecmd.speed =3D=3D SPEED_1000) ? SUPPORTED_1000baseT_Full : SUPPORTED_100baseT_Full; --=20 2.30.2 From nobody Sat Sep 13 15:04:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D636BC636D7 for ; Wed, 1 Feb 2023 14:59:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232866AbjBAO7x (ORCPT ); Wed, 1 Feb 2023 09:59:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232200AbjBAO7F (ORCPT ); Wed, 1 Feb 2023 09:59:05 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5A0E6AC9C for ; Wed, 1 Feb 2023 06:59:03 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEZY-0002s6-Sa; Wed, 01 Feb 2023 15:58:52 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pNEZY-001w2B-Ng; Wed, 01 Feb 2023 15:58:51 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pNEZT-009hXt-Ko; Wed, 01 Feb 2023 15:58:47 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v4 23/23] net: mdio: drop EEE ethtool helpers in favor to linkmode variants Date: Wed, 1 Feb 2023 15:58:45 +0100 Message-Id: <20230201145845.2312060-24-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201145845.2312060-1-o.rempel@pengutronix.de> References: <20230201145845.2312060-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" IEEE 802.3 specification provides more EEE capable link modes as this helpe= rs will be able to handle. So, remove them in favor of: mii_eee_100_10000_adv_mod_linkmode_t linkmode_adv_to_mii_eee_100_10000_adv_t Signed-off-by: Oleksij Rempel --- include/linux/mdio.h | 83 -------------------------------------------- 1 file changed, 83 deletions(-) diff --git a/include/linux/mdio.h b/include/linux/mdio.h index fcd5492e4993..492ec2de24ac 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -205,89 +205,6 @@ mdio45_ethtool_ksettings_get(const struct mdio_if_info= *mdio, extern int mdio_mii_ioctl(const struct mdio_if_info *mdio, struct mii_ioctl_data *mii_data, int cmd); =20 -/** - * mmd_eee_cap_to_ethtool_sup_t - * @eee_cap: value of the MMD EEE Capability register - * - * A small helper function that translates MMD EEE Capability (3.20) bits - * to ethtool supported settings. - */ -static inline u32 mmd_eee_cap_to_ethtool_sup_t(u16 eee_cap) -{ - u32 supported =3D 0; - - if (eee_cap & MDIO_EEE_100TX) - supported |=3D SUPPORTED_100baseT_Full; - if (eee_cap & MDIO_EEE_1000T) - supported |=3D SUPPORTED_1000baseT_Full; - if (eee_cap & MDIO_EEE_10GT) - supported |=3D SUPPORTED_10000baseT_Full; - if (eee_cap & MDIO_EEE_1000KX) - supported |=3D SUPPORTED_1000baseKX_Full; - if (eee_cap & MDIO_EEE_10GKX4) - supported |=3D SUPPORTED_10000baseKX4_Full; - if (eee_cap & MDIO_EEE_10GKR) - supported |=3D SUPPORTED_10000baseKR_Full; - - return supported; -} - -/** - * mmd_eee_adv_to_ethtool_adv_t - * @eee_adv: value of the MMD EEE Advertisement/Link Partner Ability regis= ters - * - * A small helper function that translates the MMD EEE Advertisment (7.60) - * and MMD EEE Link Partner Ability (7.61) bits to ethtool advertisement - * settings. - */ -static inline u32 mmd_eee_adv_to_ethtool_adv_t(u16 eee_adv) -{ - u32 adv =3D 0; - - if (eee_adv & MDIO_EEE_100TX) - adv |=3D ADVERTISED_100baseT_Full; - if (eee_adv & MDIO_EEE_1000T) - adv |=3D ADVERTISED_1000baseT_Full; - if (eee_adv & MDIO_EEE_10GT) - adv |=3D ADVERTISED_10000baseT_Full; - if (eee_adv & MDIO_EEE_1000KX) - adv |=3D ADVERTISED_1000baseKX_Full; - if (eee_adv & MDIO_EEE_10GKX4) - adv |=3D ADVERTISED_10000baseKX4_Full; - if (eee_adv & MDIO_EEE_10GKR) - adv |=3D ADVERTISED_10000baseKR_Full; - - return adv; -} - -/** - * ethtool_adv_to_mmd_eee_adv_t - * @adv: the ethtool advertisement settings - * - * A small helper function that translates ethtool advertisement settings - * to EEE advertisements for the MMD EEE Advertisement (7.60) and - * MMD EEE Link Partner Ability (7.61) registers. - */ -static inline u16 ethtool_adv_to_mmd_eee_adv_t(u32 adv) -{ - u16 reg =3D 0; - - if (adv & ADVERTISED_100baseT_Full) - reg |=3D MDIO_EEE_100TX; - if (adv & ADVERTISED_1000baseT_Full) - reg |=3D MDIO_EEE_1000T; - if (adv & ADVERTISED_10000baseT_Full) - reg |=3D MDIO_EEE_10GT; - if (adv & ADVERTISED_1000baseKX_Full) - reg |=3D MDIO_EEE_1000KX; - if (adv & ADVERTISED_10000baseKX4_Full) - reg |=3D MDIO_EEE_10GKX4; - if (adv & ADVERTISED_10000baseKR_Full) - reg |=3D MDIO_EEE_10GKR; - - return reg; -} - /** * linkmode_adv_to_mii_10gbt_adv_t * @advertising: the linkmode advertisement settings --=20 2.30.2