From nobody Thu Nov 28 02:46:30 2024 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 320411C302A; Fri, 4 Oct 2024 16:16:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058575; cv=none; b=lDtJliUhM7HJFMB3UqsZZOx736xylIBtMuQiUdSdo+eqUB21GJ8ouW4uiJtvPhHm5SaUZywkXpp2AoBvT+kvahzI4qwJQLTdsdRCoeU7Stcw1Jn16vh36YZEVVzt/vvMUiVJ+OG/LTUOBqogIG9Cbwm2tbpjIPnTehSJwdyqNWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058575; c=relaxed/simple; bh=cWiP3Kjqz/izcUhaTbZyZSDrw3J4YdbAhVr9h4xaE1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d/jCyJ9anttXT7MqLEhS3xYIeF8dq4VUOXiINiFQ2XidCUt2szLx+6jEbRJ3ug0LiUfEX5qS/ItT+astjOVLFd9oy08saHBlToHdXNew+Jo/OvbLpOmYW1W7gYw4ral4w3uQpQGHptRU3jUTvk9uyGbKEbCwpZtYf8cVCw3yG14= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Aj03KI7d; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Aj03KI7d" Received: by mail.gandi.net (Postfix) with ESMTPSA id 8FB7320007; Fri, 4 Oct 2024 16:16:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728058566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S1PpGNdeGt7JU4mNt5Ls+bwThFLcxi58wb3XDdywdCU=; b=Aj03KI7dOrnnOhsIil95hZvWSRtFywE/A+1VNYi+kSo+khvYzUGUre4UCC5X6lmTSIH75w n7G5wEb+VmwVnmGYBWnuvkmvaMYGUlM/lvdiYiMJXj0J3fC+M70tPAZ9rTRNSjt77XFDEu JfAq2nOZNMcRJvghouT97Qss2WGkdHPBE7PAyWI4zGEiAw7KinuLn/cFb5wGcb6vtk6aQ0 kp0zV2cIBiRhTn9COyGVkcjXlMShYEn33x1Isb2oipWeZi69W9sYD4T/CZEu2aXHwpnqcI oKL2lTWESARGKEnOmezOlI2VzAQISevE6ZI3/ojarFVsVRwJUozZaYr6oG+cSg== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?K=C3=B6ry=20Maincent?= , Oleksij Rempel Subject: [PATCH net-next v2 1/9] net: phy: allow isolating PHY devices Date: Fri, 4 Oct 2024 18:15:51 +0200 Message-ID: <20241004161601.2932901-2-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> References: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" The 802.3 specifications describes the isolation mode as setting the PHY's MII interface in high-impedance mode, thus isolating the PHY from that bus. This effectively breaks the link between the MAC and the PHY, but without necessarily disrupting the link between the PHY and the LP. This mode can be useful for testing purposes, but also when there are multiple PHYs on the same MII bus (a case that the 802.3 specification refers to). In Isolation mode, the PHY will still continue to respond to MDIO commands. Introduce a helper to set the phy in an isolated mode. Signed-off-by: Maxime Chevallier --- V2 : No change drivers/net/phy/phy_device.c | 76 +++++++++++++++++++++++++++++++++--- include/linux/phy.h | 4 ++ 2 files changed, 74 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 560e338b307a..c468e72bef4b 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2127,6 +2127,38 @@ int phy_loopback(struct phy_device *phydev, bool ena= ble) } EXPORT_SYMBOL(phy_loopback); =20 +int phy_isolate(struct phy_device *phydev, bool enable) +{ + int ret =3D 0; + + if (!phydev->drv) + return -EIO; + + mutex_lock(&phydev->lock); + + if (enable && phydev->isolated) { + ret =3D -EBUSY; + goto out; + } + + if (!enable && !phydev->isolated) { + ret =3D -EINVAL; + goto out; + } + + ret =3D genphy_isolate(phydev, enable); + + if (ret) + goto out; + + phydev->isolated =3D enable; + +out: + mutex_unlock(&phydev->lock); + return ret; +} +EXPORT_SYMBOL(phy_isolate); + /** * phy_reset_after_clk_enable - perform a PHY reset if needed * @phydev: target phy_device struct @@ -2280,7 +2312,7 @@ int genphy_setup_forced(struct phy_device *phydev) ctl =3D mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); =20 return phy_modify(phydev, MII_BMCR, - ~(BMCR_LOOPBACK | BMCR_ISOLATE | BMCR_PDOWN), ctl); + ~(BMCR_LOOPBACK | BMCR_PDOWN), ctl); } EXPORT_SYMBOL(genphy_setup_forced); =20 @@ -2369,8 +2401,11 @@ EXPORT_SYMBOL(genphy_read_master_slave); */ int genphy_restart_aneg(struct phy_device *phydev) { - /* Don't isolate the PHY if we're negotiating */ - return phy_modify(phydev, MII_BMCR, BMCR_ISOLATE, + u16 mask =3D phydev->isolated ? 0 : BMCR_ISOLATE; + /* Don't isolate the PHY if we're negotiating, unless the PHY is + * explicitly isolated + */ + return phy_modify(phydev, MII_BMCR, mask, BMCR_ANENABLE | BMCR_ANRESTART); } EXPORT_SYMBOL(genphy_restart_aneg); @@ -2394,7 +2429,8 @@ int genphy_check_and_restart_aneg(struct phy_device *= phydev, bool restart) if (ret < 0) return ret; =20 - if (!(ret & BMCR_ANENABLE) || (ret & BMCR_ISOLATE)) + if (!(ret & BMCR_ANENABLE) || + ((ret & BMCR_ISOLATE) && !phydev->isolated)) restart =3D true; } =20 @@ -2495,7 +2531,8 @@ int genphy_c37_config_aneg(struct phy_device *phydev) if (ctl < 0) return ctl; =20 - if (!(ctl & BMCR_ANENABLE) || (ctl & BMCR_ISOLATE)) + if (!(ctl & BMCR_ANENABLE) || + ((ctl & BMCR_ISOLATE) && !phydev->isolated)) changed =3D 1; /* do restart aneg */ } =20 @@ -2782,12 +2819,18 @@ EXPORT_SYMBOL(genphy_c37_read_status); int genphy_soft_reset(struct phy_device *phydev) { u16 res =3D BMCR_RESET; + u16 mask =3D 0; int ret; =20 if (phydev->autoneg =3D=3D AUTONEG_ENABLE) res |=3D BMCR_ANRESTART; =20 - ret =3D phy_modify(phydev, MII_BMCR, BMCR_ISOLATE, res); + if (phydev->isolated) + res |=3D BMCR_ISOLATE; + else + mask |=3D BMCR_ISOLATE; + + ret =3D phy_modify(phydev, MII_BMCR, mask, res); if (ret < 0) return ret; =20 @@ -2912,6 +2955,12 @@ int genphy_loopback(struct phy_device *phydev, bool = enable) u16 ctl =3D BMCR_LOOPBACK; int ret, val; =20 + /* Isolating and looping-back the MII interface doesn't really + * make sense + */ + if (phydev->isolated) + return -EINVAL; + ctl |=3D mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); =20 phy_modify(phydev, MII_BMCR, ~0, ctl); @@ -2924,6 +2973,8 @@ int genphy_loopback(struct phy_device *phydev, bool e= nable) } else { phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, 0); =20 + genphy_isolate(phydev, phydev->isolated); + phy_config_aneg(phydev); } =20 @@ -2931,6 +2982,19 @@ int genphy_loopback(struct phy_device *phydev, bool = enable) } EXPORT_SYMBOL(genphy_loopback); =20 +int genphy_isolate(struct phy_device *phydev, bool enable) +{ + u16 val =3D 0; + + if (enable) + val =3D BMCR_ISOLATE; + + phy_modify(phydev, MII_BMCR, BMCR_ISOLATE, val); + + return 0; +} +EXPORT_SYMBOL(genphy_isolate); + /** * phy_remove_link_mode - Remove a supported link mode * @phydev: phy_device structure to remove link mode from diff --git a/include/linux/phy.h b/include/linux/phy.h index a98bc91a0cde..ae33919aa0f5 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -573,6 +573,7 @@ struct macsec_ops; * @mac_managed_pm: Set true if MAC driver takes of suspending/resuming PHY * @wol_enabled: Set to true if the PHY or the attached MAC have Wake-on-L= AN * enabled. + * @isolated: Set to true if the PHY's MII has been isolated. * @state: State of the PHY for management purposes * @dev_flags: Device-specific flags used by the PHY driver. * @@ -676,6 +677,7 @@ struct phy_device { unsigned is_on_sfp_module:1; unsigned mac_managed_pm:1; unsigned wol_enabled:1; + unsigned isolated:1; =20 unsigned autoneg:1; /* The most recently read link state */ @@ -1781,6 +1783,7 @@ int phy_suspend(struct phy_device *phydev); int phy_resume(struct phy_device *phydev); int __phy_resume(struct phy_device *phydev); int phy_loopback(struct phy_device *phydev, bool enable); +int phy_isolate(struct phy_device *phydev, bool enable); int phy_sfp_connect_phy(void *upstream, struct phy_device *phy); void phy_sfp_disconnect_phy(void *upstream, struct phy_device *phy); void phy_sfp_attach(void *upstream, struct sfp_bus *bus); @@ -1894,6 +1897,7 @@ int genphy_read_master_slave(struct phy_device *phyde= v); int genphy_suspend(struct phy_device *phydev); int genphy_resume(struct phy_device *phydev); int genphy_loopback(struct phy_device *phydev, bool enable); +int genphy_isolate(struct phy_device *phydev, bool enable); int genphy_soft_reset(struct phy_device *phydev); irqreturn_t genphy_handle_interrupt_no_ack(struct phy_device *phydev); =20 --=20 2.46.1 From nobody Thu Nov 28 02:46:30 2024 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D04BB1C305B; Fri, 4 Oct 2024 16:16:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058577; cv=none; b=e1pspe7+jTSkZdXpAoB+vmvuhK0BKHJJDXZ3n1Q+qOjHfrYNLFKEMTfKcEb+U0SeDizOBQByePV193IHTVH4M1jfb0PaJC8GbyJJ2aiztVjSRsUaFg6GlkTFkwxEHl42Cn2lomBeQeGNCq0okrvEUdIxdAY5FCR3lklIyl/B3O0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058577; c=relaxed/simple; bh=FLiOKMSX1qX5t7E4RC3TaYm7ih/eICsTBamSnxEWTgw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tA8c/esoxFhX63g6kUExjef5htS0I0HCdhobg3RfBp4C3xP2elLFZdA7LYgO98R+UOz3RY+UOm40JdmH5qrFPbExtDNTryMthP8aSWxbdEWeQ3iamQKOD3Ws3mkxMLeXbbo1XQSrOn3j7EaFCoP+ma1yDRI92aKhfo8x7Lcth2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=f5qpaduI; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="f5qpaduI" Received: by mail.gandi.net (Postfix) with ESMTPSA id 9E3C820005; Fri, 4 Oct 2024 16:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728058567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9/f6q5Qizdcop8Nrj7jLWs03QirLpkKjlSjLKs9Yhpc=; b=f5qpaduI01vlyF6v0hnvsY7WPF8ShonKgNmMqew+TfsDwF9f+n7+hbTSBKMUZqYAgLi/aQ UvqG/TyT7i7LWmG/E5W+gqpKCnRRy8cx7CIdlig2dVyUIwqtti2w8n5R76/5ce9l4HYJGP EPpJKV9VKXsYQHP4WRxKC62HCojjcPhMRm5u8gohDq+6evu0E8mvvzzuFefY2gmZqKs9TG w/0SGODav1K4neVE+bNqkk9dhlwozsqje/MKatUSngcjAi1StT9q/P7qTL2OTgL0aiHHJJ gAgi02P3xXtlIaDDRDJxa7viWopiG5/AhzYDNLLYLyblLjuMTj+0a/rwyTiaiQ== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?K=C3=B6ry=20Maincent?= , Oleksij Rempel , Florian Fainelli Subject: [PATCH net-next v2 2/9] net: phy: Introduce phy_shutdown for device quiescence. Date: Fri, 4 Oct 2024 18:15:52 +0200 Message-ID: <20241004161601.2932901-3-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> References: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" When the hardware platform goes down for reboot, there's always the chance that the PHY device doesn't get reset, or fully reconfigured by the bootloader, which could rely on strap settings. Therefore, when special modes from the PHY are being used, which could make it non-functional at reboot, introduce a phy_shutdown helper to pull the PHY out of the non-functional mode it is currently in. Currently, this applies to the isolation mode. Suggested-by: Florian Fainelli Signed-off-by: Maxime Chevallier --- V2 : New patch drivers/net/phy/phy_device.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index c468e72bef4b..a0d8ff995024 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3733,6 +3733,17 @@ static int phy_remove(struct device *dev) return 0; } =20 +static void phy_shutdown(struct device *dev) +{ + struct phy_device *phydev =3D to_phy_device(dev); + + /* If the PHY isn't reset and reconfigured by the bootloader, the PHY + * will stay isolated. Make sure to un-isolate PHYs during shutdown. + */ + if (phydev->isolated) + phy_isolate(phydev, false); +} + /** * phy_driver_register - register a phy_driver with the PHY layer * @new_driver: new phy_driver to register @@ -3766,6 +3777,7 @@ int phy_driver_register(struct phy_driver *new_driver= , struct module *owner) new_driver->mdiodrv.driver.bus =3D &mdio_bus_type; new_driver->mdiodrv.driver.probe =3D phy_probe; new_driver->mdiodrv.driver.remove =3D phy_remove; + new_driver->mdiodrv.driver.shutdown =3D phy_shutdown; new_driver->mdiodrv.driver.owner =3D owner; new_driver->mdiodrv.driver.probe_type =3D PROBE_FORCE_SYNCHRONOUS; =20 --=20 2.46.1 From nobody Thu Nov 28 02:46:30 2024 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94BE81C7291; Fri, 4 Oct 2024 16:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058578; cv=none; b=GBWVkMzF80TZEWmuR53RPsfA11RaTREHk7ZiCxFegqxV0XxvNtynzbbl+EDiqLZj2K/ZHRqzInm2WVepAdtejpiP8257tynakx2lpxJLW8JONPVlsFtWqhipqscJWyeT1u8O0sud0NNAawr3orbxFaGDwvjHdWNLA3SXktKP2M0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058578; c=relaxed/simple; bh=Bg/ls7hlfga8JfozWCtqDImaSPRRA7SiUVoQmJ277kM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EDJ5cGldNf/l02snJgu6PqBDkR+5r8sSHhmE68M5C5vjsLLyaS/tftq20jr8Oj0qYEP2HJ0l6OR4oGLaZo9HOVk5GpFo/JcSYB9/VAPihnyV66nhrhluEmXtbrQ8r9jffAbQvcczikgj+lZ2q/t3jYeTwmbBdLm0g+te63FBU9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=jQ3ra73D; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="jQ3ra73D" Received: by mail.gandi.net (Postfix) with ESMTPSA id C14C120009; Fri, 4 Oct 2024 16:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728058568; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=la8SYFLXiQbvELSBNxA6DPB/JK9HrzHWiWkj/zCFpDg=; b=jQ3ra73DjV+eY3z7qTSpp6U8ixANJh4PvBVhFTSwwoVxspGtNZbfbR+U11E13a5Nryasan UACUOKrq5dom/rPejVvYr1YM+VJBUk9iEb9Tid7JNfs3SB2WQ4IFYVBSYafK3CF7JLRkcg KG1jckkj0hwFY+fSlYyn1arKslIVUZx/bw/QWEaH4d7T7FZ+AQ1m/VfFFdqNEWYaRz/3+U 70RuwdHgbSlS+hAoOcJ+sOvrGQCQ38eynEeRjcsVuwolqNhYOfvK1PX+T++Y9AuG5aYr3h dQhRSPCQsY5U/dXU2122WBx6mBFTtyxRpBfO/oZStCeffLZlhYyUpWyjUKlzNQ== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?K=C3=B6ry=20Maincent?= , Oleksij Rempel Subject: [PATCH net-next v2 3/9] net: phy: Allow PHY drivers to report isolation support Date: Fri, 4 Oct 2024 18:15:53 +0200 Message-ID: <20241004161601.2932901-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> References: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" Some PHYs have malfunctionning isolation modes, where the MII lines aren't correctly set in high-impedance, potentially interfering with the MII bus in unexpected ways. Some other PHYs simply don't support it. The isolation support may depend on the interface mode being used, so introduce a new driver callback to report the isolation support in the current PHY configuration. As some PHYs just never support isolation, introduce a genphy helper that can be used for strictly non-isolating PHYs. Signed-off-by: Maxime Chevallier --- V2 : Moved from flag to callback, introduced genphy helper drivers/net/phy/phy_device.c | 11 +++++++++++ include/linux/phy.h | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index a0d8ff995024..9294b73c391a 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2127,6 +2127,14 @@ int phy_loopback(struct phy_device *phydev, bool ena= ble) } EXPORT_SYMBOL(phy_loopback); =20 +static bool phy_can_isolate(struct phy_device *phydev) +{ + if (phydev->drv && phydev->drv->can_isolate) + return phydev->drv->can_isolate(phydev); + + return true; +} + int phy_isolate(struct phy_device *phydev, bool enable) { int ret =3D 0; @@ -2134,6 +2142,9 @@ int phy_isolate(struct phy_device *phydev, bool enabl= e) if (!phydev->drv) return -EIO; =20 + if (!phy_can_isolate(phydev)) + return -EOPNOTSUPP; + mutex_lock(&phydev->lock); =20 if (enable && phydev->isolated) { diff --git a/include/linux/phy.h b/include/linux/phy.h index ae33919aa0f5..e43f7169c57d 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1192,6 +1192,19 @@ struct phy_driver { */ int (*led_polarity_set)(struct phy_device *dev, int index, unsigned long modes); + + /** + * @can_isolate: Query the PHY isolation capability + * @dev: PHY device to query + * + * Although PHY isolation is part of 802.3, not all PHYs support that + * feature. Some PHYs can only support isolation when using a specific + * phy_interface_mode, and some don't support it at all. + * + * Returns true if the PHY can isolate in its current configuration, + * false otherwise. + */ + bool (*can_isolate)(struct phy_device *dev); }; #define to_phy_driver(d) container_of_const(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv) @@ -1910,6 +1923,12 @@ static inline int genphy_no_config_intr(struct phy_d= evice *phydev) { return 0; } + +static inline bool genphy_no_isolate(struct phy_device *phydev) +{ + return false; +} + int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad, u16 regnum); int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum, --=20 2.46.1 From nobody Thu Nov 28 02:46:30 2024 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F8321C75EF; Fri, 4 Oct 2024 16:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058579; cv=none; b=D3M2GWV4Il47QtdXXE6tfu6VquvOu1Dhwrtqll2245JZm4ucPb8HNaediliETSLsQQ37+G5sZY2hKt8k6u3/SY8rThw0hD3YWA3ElUJE+VAqH5uBCn2FJej+esflmk1JZA4iNSYEhEEhORvc9b4egkLfjVTt9i7ii1MdvRlX6vo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058579; c=relaxed/simple; bh=/t/i/v7Y4wFFXBA5yU25ZUKM1qTMIM422hMgQyatXM8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qWrlSmsEq3PPuB1L3YnPiCxZXs1A06lfmLEo19QvMaPTZjSO/WfwgXYlhHLD0PhSnTJSIvpcrcJkt7uPEcWuBVLCGOCc2V3HINdpsL0L5ezsH5qqEkGRClB06m1tU5bMF0qWTP68sB3HmIw+Www30Ndzk3IQtXDexpbNnFRWCzI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=QNpaTKOz; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="QNpaTKOz" Received: by mail.gandi.net (Postfix) with ESMTPSA id BE61520008; Fri, 4 Oct 2024 16:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728058569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l94MYM9aLPoFsocgRBRMqaai5hzItvu6ewJPpEKL7nk=; b=QNpaTKOzl/37uWbR/6MeQsbwPIWLvqndTwQ++ICUhcct7Pw1conr08/X46fycgOrW/c1EZ hBlr1Xa3n6BrNPtFJmHfYxRiJAd+DikF4FdXXTcqPuegnspwpahzwtXXSXlf4P4p2Xpfn4 zVZmet0cMxUZUdTNi7Ui6nO5s96JM5q7WJczt8PMOvDgn7DrLbrbQvcm/MrzRh582Y1qz1 Be2czEbCDSI6fVAOBM9/AfmTtJl8K/9ApxRts9+uTctBFg62jtF5B3GMiE5+7W0SmVTWx7 B9Ws1iFtsoWLoStLhjPIfvlJzGKJ91qnSTkwYgx3XWDN0RYijr4FrdhWIkn9DA== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?K=C3=B6ry=20Maincent?= , Oleksij Rempel Subject: [PATCH net-next v2 4/9] net: phy: lxt: Mark LXT973 PHYs as having a broken isolate mode Date: Fri, 4 Oct 2024 18:15:54 +0200 Message-ID: <20241004161601.2932901-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> References: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" Testing showed that PHYs from the LXT973 family have a non-working isolate mode, where the MII lines aren't set in high-impedance as would be expected. Prevent isolating these PHYs. Signed-off-by: Maxime Chevallier --- V2 : Use callback instead of flag drivers/net/phy/lxt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c index e3bf827b7959..45f92451bee8 100644 --- a/drivers/net/phy/lxt.c +++ b/drivers/net/phy/lxt.c @@ -334,6 +334,7 @@ static struct phy_driver lxt97x_driver[] =3D { .read_status =3D lxt973a2_read_status, .suspend =3D genphy_suspend, .resume =3D genphy_resume, + .can_isolate =3D genphy_no_isolate, }, { .phy_id =3D 0x00137a10, .name =3D "LXT973", @@ -344,6 +345,7 @@ static struct phy_driver lxt97x_driver[] =3D { .config_aneg =3D lxt973_config_aneg, .suspend =3D genphy_suspend, .resume =3D genphy_resume, + .can_isolate =3D genphy_no_isolate, } }; =20 module_phy_driver(lxt97x_driver); --=20 2.46.1 From nobody Thu Nov 28 02:46:30 2024 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AF971C82FC; Fri, 4 Oct 2024 16:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058580; cv=none; b=l09/Oqqu7XCZpYldGKoED5wHMkLfTh05iB+kccQipFR4htmCunnSrX/OQUoR8UnQnjYGjNlVx+sF+xo+CeF1DM7H4RTp6Hy5AgnmlTz3qjI24jy2UkY9ppor3TfQM10uKwnsyk0k7UYMtpW3C9X1M0lfLuUx5aRr7hCIyRQ1QmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058580; c=relaxed/simple; bh=P5TebehUaWq4vjDvoTeNxwj6jDSsnkYNxZtOrSq1kao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=El8JB6wfN07T+lGJe68Y0bGu/hGkc6pKG6g64XlapQ1NMcIrDDldDE4wLfUi2YEwQIb42gsdWuYkal5HNBNDXM4LliUHmPRwXgtbDSmRgd8ejxFgOl9Ygz3Mp4dW7/qNcaS/49zTILeYXolIAMG1bV2AD7S1Hc+3CiOFkBLiHlA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=errC3PZ2; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="errC3PZ2" Received: by mail.gandi.net (Postfix) with ESMTPSA id B969C2000C; Fri, 4 Oct 2024 16:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728058570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dp0DBhFARDfArCSdgYYrzM2jCoA7FW/8kA7NOUCl2/c=; b=errC3PZ2jBRAdl7toejcmwvgAChfwyA5o3tRl8Q6lgQT5wNZf9YvCiIg3IWTthRtutbJxv gYTwTb0oG60PIMYz00uHYDPjkXEK08mRuLtjugUhc9YWBcr/kHO8BXGY9q4LT8KypSUpFC nu5BYhd3TSqqPN02LSPZfWPP8qqLsyg42oSf9fPzTAZqx3XoMyvMcqkHdq8RE1bAf1kRTv qWFB8UJS9m4f/QVKtD3C48c/kah5AcJ3ZJuhfZ7DlF/TFMF4CMDIrngvyUovzJVKUIbcsi OJzPB2k0jk53GRaP7S/JK7PUt9FCiwjUoe9+tJbVYXBMWsAUypVOvV/YsMokwA== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?K=C3=B6ry=20Maincent?= , Oleksij Rempel Subject: [PATCH net-next v2 5/9] net: phy: marvell10g: 88x3310 and 88x3340 don't support isolate mode Date: Fri, 4 Oct 2024 18:15:55 +0200 Message-ID: <20241004161601.2932901-6-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> References: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" The 88x3310 and 88x3340 PHYs don't support the isolation mode, regardless of the MII mode being used (SGMII/1000BaseX/2500BaseX/5GBaseR/10GBaseR). Report this through the .can_isolate() callback. This was confirmed on the 88x3310 on a MacchiatoBin. Signed-off-by: Maxime Chevallier --- V2 : Use callback instead of flag drivers/net/phy/marvell10g.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c index 6642eb642d4b..c1a471f55cd4 100644 --- a/drivers/net/phy/marvell10g.c +++ b/drivers/net/phy/marvell10g.c @@ -1422,6 +1422,7 @@ static struct phy_driver mv3310_drivers[] =3D { .set_loopback =3D genphy_c45_loopback, .get_wol =3D mv3110_get_wol, .set_wol =3D mv3110_set_wol, + .can_isolate =3D genphy_no_isolate, }, { .phy_id =3D MARVELL_PHY_ID_88X3310, @@ -1441,6 +1442,7 @@ static struct phy_driver mv3310_drivers[] =3D { .set_tunable =3D mv3310_set_tunable, .remove =3D mv3310_remove, .set_loopback =3D genphy_c45_loopback, + .can_isolate =3D genphy_no_isolate, }, { .phy_id =3D MARVELL_PHY_ID_88E2110, --=20 2.46.1 From nobody Thu Nov 28 02:46:30 2024 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31FE81AA79D; Fri, 4 Oct 2024 16:16:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058575; cv=none; b=XAP97wtAsDqK+FDVYlZwkDb7W02Hu8/J5l7SqKK7Vgm90giI76sa1SN/qe+xEiTgIRHUxzynyftVNofM8fSjJr/SQvam+SbpYDODJ2AUDv7jXOnEAqQIXWm/5KQq8gRnd7+Ec84tRtrgqifp7a2IfH08jnZ1RqftmhmqiJOLi+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058575; c=relaxed/simple; bh=MXRnTnSJrBb1vnWAX8AVE5zZEfy5t/0VU3LPcntsBkU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HAw6PZEFp/WnbE20i6u4/0t3mfsAaSDGIz5dv8A5SUtS0wtirDfITxiQ/X17DKQ3xbe10VkvRfi8rVX0ME4pc8o/QNko90LrPCmKAxAxvA2ohITpPQAblap60HH1hvS6JiEeYx6/B4Gs4/Fn7ZDfcRWL5YZKtq1Nk17jkAnyOdE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=nQ2zjjAQ; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="nQ2zjjAQ" Received: by mail.gandi.net (Postfix) with ESMTPSA id ACE122000A; Fri, 4 Oct 2024 16:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728058571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WFvkoN0tzzAFwJQTN+9OZPcm7C12bxp5VehHzezOGxs=; b=nQ2zjjAQlt78dYOu0azZAA8LApDVs8sqGRzduRI0Q77ScZDM8EovGkfJup3Kt8KRk0SRDK FI35D4EVOm5eLhbjlxt7SrN9xB6Y/ldF72ZCCuDWhzjASUla+iNxbcAaODYABOELlZu0N4 HJUwdmPhjQm+iQHwZbs6oriIhb82MNfYTuRCowgg0frvQAOMxw+jhYajfL85RK7Z2Oe37l 3Cdxa9zyUQ5Lc4wU01d/Jd9lcDGMNu7AvZpP8/jEucICgW+oZ+obA2LWE2usGt8kX4lAXO PqSIvJeBoGo22TxqPFMJSke+eOfoTR876OO1S2hEDkNkMDNAXkS9jkgYSWIpsw== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?K=C3=B6ry=20Maincent?= , Oleksij Rempel Subject: [PATCH net-next v2 6/9] net: phy: marvell: mv88e1111 doesn't support isolate in SGMII mode Date: Fri, 4 Oct 2024 18:15:56 +0200 Message-ID: <20241004161601.2932901-7-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> References: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" The 88e1111 datasheet indicates that it supports the isolate mode in GMII, RGMII and TBI modes, but doesn't mention what it does in the other modes. Testing showed that setting the isolate bit while the PHY is in SGMII mode has no effect. Reflect that behaviour in the .can_isolate() driver ops. Signed-off-by: Maxime Chevallier --- V2 : New patch drivers/net/phy/marvell.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 9964bf3dea2f..912b08d9c124 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -1092,6 +1092,14 @@ static int m88e1111_set_tunable(struct phy_device *p= hydev, } } =20 +static bool m88e1111_can_isolate(struct phy_device *phydev) +{ + if (phydev->interface =3D=3D PHY_INTERFACE_MODE_SGMII) + return false; + + return true; +} + static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data) { int val, cnt, enable; @@ -3704,6 +3712,7 @@ static struct phy_driver marvell_drivers[] =3D { .set_tunable =3D m88e1111_set_tunable, .cable_test_start =3D m88e1111_vct_cable_test_start, .cable_test_get_status =3D m88e1111_vct_cable_test_get_status, + .can_isolate =3D m88e1111_can_isolate, }, { .phy_id =3D MARVELL_PHY_ID_88E1111_FINISAR, --=20 2.46.1 From nobody Thu Nov 28 02:46:30 2024 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 277351C3031; Fri, 4 Oct 2024 16:16:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058576; cv=none; b=OQIjVztkt8bPLXwrSULg++nEZ1nhgwX2iENA62FtyvvSJdAGso70Mfv5rZeiy2n+ksmKrlcGrTeQdjsrxelcP5h7Ys84XLfV+0UWXoiCxIJ0rrDLH96lHguZjbUpJvM02sgKmBmys3LqNqsXQMjQibLIxbQFYtD/TxdoiM3Urvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058576; c=relaxed/simple; bh=/PV7aAVXGK9JhfUmjlaINovWWOnjLNE8jKwB1u9YCko=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TMOvPe6Yg2hIudcEtIhA5ykct8Dz6HrbEv42cAfnFHWaPJc6Oho+YIdwk4/sECOP7JIQSib1OpCMMYViyPdm7wvkipOT/APmDNELd3WqkADVV1GzSoznmsLYMrf87l2xWrOpQu2Qu2pkIvC8kYpcy6AudTCS/IfCO0OJhDYnODk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=GBj/oSpJ; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="GBj/oSpJ" Received: by mail.gandi.net (Postfix) with ESMTPSA id A89D82000E; Fri, 4 Oct 2024 16:16:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728058572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M7SVNiIf/mt0akg6bQEG9T1CrSVV/qDQCzlAu9x3Ggw=; b=GBj/oSpJNOTe+yUfhxA9M5BlO+VDZZqEEXXSIIRKVwhU31rxtM2eKCvJ2xQ+oD6fbntUGA USsaNGHZqwWhjBBqf5DZI9CAnocxQw4yHMsHmDR+BVo7LMBDFcPK4xwQ8n2d0VY1MNEG0n uED/8PXtc2MlZwQVJ9GGcmfpzOrPICbVMWMCB0KIkSDrTR+HnzruZPEOaYW382S62+Kqkk tp2CEwLtweqpEcoO81A8QiBiaharNb+YdqCxPNE7h95IGAiwl6tdo9qupP2Ca1hgyXuSlW vXcCF5G5SXOzeLJQnB//o5+P1YYg81h1/IGiSWGJCIufYIPyWGiefQDPB4uIPw== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?K=C3=B6ry=20Maincent?= , Oleksij Rempel Subject: [PATCH net-next v2 7/9] net: phy: introduce ethtool_phy_ops to get and set phy configuration Date: Fri, 4 Oct 2024 18:15:57 +0200 Message-ID: <20241004161601.2932901-8-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> References: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" Expose phy-specific configuration hooks to get and set the state of an ethernet PHY's internal configuration. So far, these parameters only include the isolation state of the PHY. The .get_config() ethtool_phy_ops gets these status information from the phy_device's internal flags, while the .set_config() operation allows changing these configuration parameters. Signed-off-by: Maxime Chevallier --- V2 : Dropped loopback mode drivers/net/phy/phy.c | 44 ++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy_device.c | 2 ++ include/linux/ethtool.h | 8 +++++++ include/linux/phy.h | 19 ++++++++++++++++ 4 files changed, 73 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 4f3e742907cb..5a689da060d1 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1811,3 +1811,47 @@ int phy_ethtool_nway_reset(struct net_device *ndev) return ret; } EXPORT_SYMBOL(phy_ethtool_nway_reset); + +/** + * phy_get_config - Get PHY configuration parameters + * @phydev: the PHY device to act upon + * @phy_cfg: The configuration to apply + */ + +int phy_get_config(struct phy_device *phydev, + struct phy_device_config *phy_cfg) +{ + mutex_lock(&phydev->lock); + phy_cfg->isolate =3D phydev->isolated; + mutex_unlock(&phydev->lock); + + return 0; +} + +/** + * phy_set_config - Set PHY configuration parameters + * @phydev: the PHY device to act upon + * @phy_cfg: the configuration to apply + * @extack: a netlink extack for useful error reporting + */ + +int phy_set_config(struct phy_device *phydev, + const struct phy_device_config *phy_cfg, + struct netlink_ext_ack *extack) +{ + bool isolate_change; + int ret; + + mutex_lock(&phydev->lock); + isolate_change =3D (phy_cfg->isolate !=3D phydev->isolated); + mutex_unlock(&phydev->lock); + + if (!isolate_change) + return 0; + + ret =3D phy_isolate(phydev, phy_cfg->isolate); + if (ret) + NL_SET_ERR_MSG(extack, "Error while configuring PHY isolation"); + + return ret; +} diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 9294b73c391a..1111a3cbcb02 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3857,6 +3857,8 @@ static const struct ethtool_phy_ops phy_ethtool_phy_o= ps =3D { .get_plca_status =3D phy_ethtool_get_plca_status, .start_cable_test =3D phy_start_cable_test, .start_cable_test_tdr =3D phy_start_cable_test_tdr, + .get_config =3D phy_get_config, + .set_config =3D phy_set_config, }; =20 static const struct phylib_stubs __phylib_stubs =3D { diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 12f6dc567598..480ee99a69a5 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -1140,6 +1140,7 @@ struct phy_device; struct phy_tdr_config; struct phy_plca_cfg; struct phy_plca_status; +struct phy_device_config; =20 /** * struct ethtool_phy_ops - Optional PHY device options @@ -1151,6 +1152,8 @@ struct phy_plca_status; * @get_plca_status: Get PLCA configuration. * @start_cable_test: Start a cable test * @start_cable_test_tdr: Start a Time Domain Reflectometry cable test + * @get_config: Retrieve phy device configuration parameters + * @set_config: Set phy device configuration parameters * * All operations are optional (i.e. the function pointer may be set to %N= ULL) * and callers must take this into account. Callers must hold the RTNL loc= k. @@ -1172,6 +1175,11 @@ struct ethtool_phy_ops { int (*start_cable_test_tdr)(struct phy_device *phydev, struct netlink_ext_ack *extack, const struct phy_tdr_config *config); + int (*get_config)(struct phy_device *phydev, + struct phy_device_config *phy_cfg); + int (*set_config)(struct phy_device *phydev, + const struct phy_device_config *phy_cfg, + struct netlink_ext_ack *extack); }; =20 /** diff --git a/include/linux/phy.h b/include/linux/phy.h index e43f7169c57d..662ba57cd0de 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -886,6 +886,20 @@ enum phy_led_modes { __PHY_LED_MODES_NUM, }; =20 +/** + * struct phy_device_config - General PHY device configuration parameters = for + * status reporting and bulk configuration + * + * A structure containing generic PHY device information, allowing to expo= se + * internal status to userspace, and perform PHY configuration in a contro= lled + * manner. + * + * @isolate: The MII-side isolation status of the PHY + */ +struct phy_device_config { + bool isolate; +}; + /** * struct phy_led: An LED driven by the PHY * @@ -2085,6 +2099,11 @@ int phy_ethtool_set_plca_cfg(struct phy_device *phyd= ev, struct netlink_ext_ack *extack); int phy_ethtool_get_plca_status(struct phy_device *phydev, struct phy_plca_status *plca_st); +int phy_get_config(struct phy_device *phydev, + struct phy_device_config *phy_cfg); +int phy_set_config(struct phy_device *phydev, + const struct phy_device_config *phy_cfg, + struct netlink_ext_ack *extack); =20 int __phy_hwtstamp_get(struct phy_device *phydev, struct kernel_hwtstamp_config *config); --=20 2.46.1 From nobody Thu Nov 28 02:46:30 2024 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B20F1E3760; Fri, 4 Oct 2024 16:16:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058577; cv=none; b=lpSLMB+5ATWC68z/3PiqINREgwU/rpPiYGZx2UsMdK0q8dd+7pne+DyshcAiFRNbFeUbEDTgOxy18SUVCkSU52lQXRQTjx+PACqF3iTmMIKlv3GzsW1AD55EIZdax2zf5x7jEl6Q5DuMxExK+ywAg4J1VDLvXOWT090EkGQgY8k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058577; c=relaxed/simple; bh=Nl9ovOr0JrFISdFoJ16CYHXfCUoM759fcxXvz+/XEps=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ipIe8ju3uBfJvfKVAGaRpNHS16isLhMdP9tOReAyzrxfeC/rvCCzxc76rb7wTyULI8j6ePMZub8QNHZLqv2XkjEkHBd1d2sOInJzaJEROBC8F03R3pDLcSRHmRqbN+oiBvoMFc0RHzz+V1WoE4H7YrmQ5soh4a8PefZkXFmgdmc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=XXZOTKXl; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="XXZOTKXl" Received: by mail.gandi.net (Postfix) with ESMTPSA id 9A8072000D; Fri, 4 Oct 2024 16:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728058573; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8bbMTQ2Ujk5xefPwIIDflX8atbICLJzjWfHmkwLkMEk=; b=XXZOTKXlGW729F30JPg2425kU3jttNDmC5BAlvX0aBEmXaEkk4p1pK0eJ2Jtx6pBErIQ7T BIdePdzb1wqtPTnrUb3EfJ5vzSSFrzDc2fsYCyfe22/9CEtl0btrrptyW4CcdQ+GMs2F8g mULDRQc+3aTBR514Kl4GqKAIb51duuZz/gqJahGmupYG66xWgpt+oEpzSwLPGcCrxGMjNH rEdu2wNB4J7BVwgN9JyP/stpLwbdl5WRLOQ+YIpfreO/hezkOCsnLVmkhv6JOt3BeI5K9T mVPFakwcS2Uu1IUK1wKoJ3bghEiiFKnciSOAXU/oETNlmloI3QnLvBX96JE1hw== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?K=C3=B6ry=20Maincent?= , Oleksij Rempel Subject: [PATCH net-next v2 8/9] net: ethtool: phy: allow reporting and setting the phy isolate status Date: Fri, 4 Oct 2024 18:15:58 +0200 Message-ID: <20241004161601.2932901-9-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> References: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" Add the isolate status information to the ETHTOOL_PHY_GET netlink command attributes, and allow changing this parameter from a newly-introduced ETHTOOL_PHY_SET command. Signed-off-by: Maxime Chevallier --- V2 : Dropped loopback mode Documentation/networking/ethtool-netlink.rst | 1 + include/uapi/linux/ethtool_netlink.h | 2 + net/ethtool/netlink.c | 8 +++ net/ethtool/netlink.h | 1 + net/ethtool/phy.c | 68 ++++++++++++++++++++ 5 files changed, 80 insertions(+) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/n= etworking/ethtool-netlink.rst index 295563e91082..800a8812a760 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -2235,6 +2235,7 @@ Kernel response contents: bus, the name of this sfp = bus ``ETHTOOL_A_PHY_DOWNSTREAM_SFP_NAME`` string if the phy controls an sfp= bus, the name of the sfp bus + ``ETHTOOL_A_PHY_ISOLATE`` u8 The PHY Isolate status =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D =20 When ``ETHTOOL_A_PHY_UPSTREAM_TYPE`` is PHY_UPSTREAM_PHY, the PHY's parent= is diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/etht= ool_netlink.h index 283305f6b063..bee5bf7ef90d 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -59,6 +59,7 @@ enum { ETHTOOL_MSG_MM_SET, ETHTOOL_MSG_MODULE_FW_FLASH_ACT, ETHTOOL_MSG_PHY_GET, + ETHTOOL_MSG_PHY_SET, =20 /* add new constants above here */ __ETHTOOL_MSG_USER_CNT, @@ -1079,6 +1080,7 @@ enum { ETHTOOL_A_PHY_UPSTREAM_INDEX, /* u32 */ ETHTOOL_A_PHY_UPSTREAM_SFP_NAME, /* string */ ETHTOOL_A_PHY_DOWNSTREAM_SFP_NAME, /* string */ + ETHTOOL_A_PHY_ISOLATE, /* u8 */ =20 /* add new constants above here */ __ETHTOOL_A_PHY_CNT, diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index e3f0ef6b851b..26982f47a934 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -394,6 +394,7 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] =3D { [ETHTOOL_MSG_PLCA_GET_STATUS] =3D ðnl_plca_status_request_ops, [ETHTOOL_MSG_MM_GET] =3D ðnl_mm_request_ops, [ETHTOOL_MSG_MM_SET] =3D ðnl_mm_request_ops, + [ETHTOOL_MSG_PHY_SET] =3D ðnl_phy_request_ops, }; =20 static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *= cb) @@ -1243,6 +1244,13 @@ static const struct genl_ops ethtool_genl_ops[] =3D { .policy =3D ethnl_phy_get_policy, .maxattr =3D ARRAY_SIZE(ethnl_phy_get_policy) - 1, }, + { + .cmd =3D ETHTOOL_MSG_PHY_SET, + .flags =3D GENL_UNS_ADMIN_PERM, + .doit =3D ethnl_default_set_doit, + .policy =3D ethnl_phy_set_policy, + .maxattr =3D ARRAY_SIZE(ethnl_phy_set_policy) - 1, + }, }; =20 static const struct genl_multicast_group ethtool_nl_mcgrps[] =3D { diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 203b08eb6c6f..7ae73e2eab32 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -485,6 +485,7 @@ extern const struct nla_policy ethnl_mm_get_policy[ETHT= OOL_A_MM_HEADER + 1]; extern const struct nla_policy ethnl_mm_set_policy[ETHTOOL_A_MM_MAX + 1]; extern const struct nla_policy ethnl_module_fw_flash_act_policy[ETHTOOL_A_= MODULE_FW_FLASH_PASSWORD + 1]; extern const struct nla_policy ethnl_phy_get_policy[ETHTOOL_A_PHY_HEADER += 1]; +extern const struct nla_policy ethnl_phy_set_policy[ETHTOOL_A_PHY_MAX + 1]; =20 int ethnl_set_features(struct sk_buff *skb, struct genl_info *info); int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info); diff --git a/net/ethtool/phy.c b/net/ethtool/phy.c index ed8f690f6bac..b211bd83a3a0 100644 --- a/net/ethtool/phy.c +++ b/net/ethtool/phy.c @@ -30,10 +30,13 @@ ethnl_phy_reply_size(const struct ethnl_req_info *req_b= ase, struct phy_req_info *req_info =3D PHY_REQINFO(req_base); struct phy_device_node *pdn =3D req_info->pdn; struct phy_device *phydev =3D pdn->phy; + const struct ethtool_phy_ops *ops; size_t size =3D 0; =20 ASSERT_RTNL(); =20 + ops =3D ethtool_phy_ops; + /* ETHTOOL_A_PHY_INDEX */ size +=3D nla_total_size(sizeof(u32)); =20 @@ -66,6 +69,10 @@ ethnl_phy_reply_size(const struct ethnl_req_info *req_ba= se, size +=3D nla_total_size(strlen(sfp_name) + 1); } =20 + /* ETHTOOL_A_PHY_ISOLATE */ + if (ops && ops->get_config) + size +=3D nla_total_size(sizeof(u8)); + return size; } =20 @@ -75,10 +82,20 @@ ethnl_phy_fill_reply(const struct ethnl_req_info *req_b= ase, struct sk_buff *skb) struct phy_req_info *req_info =3D PHY_REQINFO(req_base); struct phy_device_node *pdn =3D req_info->pdn; struct phy_device *phydev =3D pdn->phy; + const struct ethtool_phy_ops *ops; + struct phy_device_config cfg; enum phy_upstream ptype; + int ret; =20 ptype =3D pdn->upstream_type; =20 + ops =3D ethtool_phy_ops; + if (ops && ops->get_config) { + ret =3D ops->get_config(phydev, &cfg); + if (ret) + return ret; + } + if (nla_put_u32(skb, ETHTOOL_A_PHY_INDEX, phydev->phyindex) || nla_put_string(skb, ETHTOOL_A_PHY_NAME, dev_name(&phydev->mdio.dev)) = || nla_put_u32(skb, ETHTOOL_A_PHY_UPSTREAM_TYPE, ptype)) @@ -114,6 +131,13 @@ ethnl_phy_fill_reply(const struct ethnl_req_info *req_= base, struct sk_buff *skb) return -EMSGSIZE; } =20 + /* Append PHY configuration, if possible */ + if (!ops || !ops->get_config) + return 0; + + if (nla_put_u8(skb, ETHTOOL_A_PHY_ISOLATE, cfg.isolate)) + return -EMSGSIZE; + return 0; } =20 @@ -304,3 +328,47 @@ int ethnl_phy_dumpit(struct sk_buff *skb, struct netli= nk_callback *cb) =20 return ret; } + +const struct nla_policy ethnl_phy_set_policy[] =3D { + [ETHTOOL_A_PHY_HEADER] =3D + NLA_POLICY_NESTED(ethnl_header_policy_phy), + [ETHTOOL_A_PHY_ISOLATE] =3D NLA_POLICY_MAX(NLA_U8, 1), +}; + +static int ethnl_set_phy(struct ethnl_req_info *req_info, struct genl_info= *info) +{ + struct netlink_ext_ack *extack =3D info->extack; + const struct ethtool_phy_ops *ops; + struct nlattr **tb =3D info->attrs; + struct phy_device_config cfg; + struct phy_device *phydev; + bool mod =3D false; + int ret; + + ops =3D ethtool_phy_ops; + if (!ops || !ops->set_config || !ops->get_config) + return -EOPNOTSUPP; + + /* We're running under rtnl */ + phydev =3D ethnl_req_get_phydev(req_info, tb[ETHTOOL_A_PHY_HEADER], + extack); + if (IS_ERR_OR_NULL(phydev)) + return -ENODEV; + + ret =3D ops->get_config(phydev, &cfg); + if (ret) + return ret; + + ethnl_update_bool(&cfg.isolate, tb[ETHTOOL_A_PHY_ISOLATE], &mod); + + if (!mod) + return 0; + + /* Returning 0 is fine as we don't have a notification */ + return ops->set_config(phydev, &cfg, extack); +} + +const struct ethnl_request_ops ethnl_phy_request_ops =3D { + .hdr_attr =3D ETHTOOL_A_PHY_HEADER, + .set =3D ethnl_set_phy, +}; --=20 2.46.1 From nobody Thu Nov 28 02:46:30 2024 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21EE61C7274; Fri, 4 Oct 2024 16:16:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058578; cv=none; b=FYccUhKQl/9grOdkD2suDMfz//r2HDmx0brcXAnYmFWr0p67fET63GL/Cc2oOM/DNoz4+2TuXyBZtMuNHwKCF1BBgTvwFkX6BKRKadY7o67k5vjoJW5PNLFUu7zmkC08aW88wJYKoC67y3IZCrthFXYQ7C0crHTyvknMBY+HjEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728058578; c=relaxed/simple; bh=rAWpMtyvcBRdtxRlnUDXb/bpryEr0mMERltzyczUZ6A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UBS4+3eRQmyQG/VjQIp02tAN1DWq8Jps1PoSnRRfnfVnQoA7hWoWTKuI8YCwppsWDlDTGqZaLrXyc/qxCybHueNBdoam5G5++R9UX5fG7Id5HW+f0tos04Rhr35Z3x2B7wM95Ltt26viggwBjUKltPm0r/XsZQoaDOjCjN9CmMI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=KI9IOlr3; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="KI9IOlr3" Received: by mail.gandi.net (Postfix) with ESMTPSA id 8D2DD20012; Fri, 4 Oct 2024 16:16:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728058574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DWhLd3vDKecLf43Ct4Q5pvEcdnHZ2BjA0Ud7Z6NbNnY=; b=KI9IOlr3ZroGDVJwZBUxGDphPPHWXrZwULxfsezS+povC9iBvwUoZjmZ0Obgo0odGHbo/u IhddPguuILaFebua7zyi0/sAs0Cj6R36MpBNFJOVXIwYZAPNgQiZSXr0BMyRiKuUhOpKRX PBqX9r3vSdWeFMocvIZli5mQy4qgrMwt6I3DTlv+HOGUNd312KOIvh4iYXpq5uR7y4oWw/ /I5CykLaBMdhOorpUQYhcdrfNrZQkwkMqDEX5QO8n2w8Qu/UzJ8BOgho+vjQfEN2cdg1LC CoohEvXumtsoqRrYn6mRXg22E/iGlT/vdq64DyZqBPdeLUD6jD5p4hD2A5PYIg== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?K=C3=B6ry=20Maincent?= , Oleksij Rempel Subject: [PATCH net-next v2 9/9] netlink: specs: introduce phy-set command along with configurable attributes Date: Fri, 4 Oct 2024 18:15:59 +0200 Message-ID: <20241004161601.2932901-10-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> References: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" Update the ethnl specification to include the newly introduced isolated attribute, and describe the newly introduced ETHTOOL_PHY_SET command. Signed-off-by: Maxime Chevallier --- V2 : Dropped loopback mode Documentation/netlink/specs/ethtool.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netli= nk/specs/ethtool.yaml index 6a050d755b9c..6f5cdb3af64d 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -1132,6 +1132,9 @@ attribute-sets: - name: downstream-sfp-name type: string + - + name: isolate + type: u8 =20 operations: enum-model: directional @@ -1950,4 +1953,16 @@ operations: - upstream-index - upstream-sfp-name - downstream-sfp-name + - isolate dump: *phy-get-op + - + name: phy-set + doc: Set configuration attributes for attached PHY devices + + attribute-set: phy + + do: + request: + attributes: + - header + - isolate --=20 2.46.1