From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: davem@davemloft.net
Cc: "Maxime Chevallier" <maxime.chevallier@bootlin.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
thomas.petazzoni@bootlin.com, "Andrew Lunn" <andrew@lunn.ch>,
"Jakub Kicinski" <kuba@kernel.org>,
"Eric Dumazet" <edumazet@google.com>,
"Paolo Abeni" <pabeni@redhat.com>,
"Russell King" <linux@armlinux.org.uk>,
linux-arm-kernel@lists.infradead.org,
"Christophe Leroy" <christophe.leroy@csgroup.eu>,
"Herve Codina" <herve.codina@bootlin.com>,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Vladimir Oltean" <vladimir.oltean@nxp.com>,
"Marek Behún" <kabel@kernel.org>,
"Köry Maincent" <kory.maincent@bootlin.com>,
"Oleksij Rempel" <o.rempel@pengutronix.de>
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 [thread overview]
Message-ID: <20241004161601.2932901-8-maxime.chevallier@bootlin.com> (raw)
In-Reply-To: <20241004161601.2932901-1-maxime.chevallier@bootlin.com>
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 <maxime.chevallier@bootlin.com>
---
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 = 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 = (phy_cfg->isolate != phydev->isolated);
+ mutex_unlock(&phydev->lock);
+
+ if (!isolate_change)
+ return 0;
+
+ ret = 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_ops = {
.get_plca_status = phy_ethtool_get_plca_status,
.start_cable_test = phy_start_cable_test,
.start_cable_test_tdr = phy_start_cable_test_tdr,
+ .get_config = phy_get_config,
+ .set_config = phy_set_config,
};
static const struct phylib_stubs __phylib_stubs = {
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;
/**
* 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 %NULL)
* and callers must take this into account. Callers must hold the RTNL lock.
@@ -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);
};
/**
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,
};
+/**
+ * struct phy_device_config - General PHY device configuration parameters for
+ * status reporting and bulk configuration
+ *
+ * A structure containing generic PHY device information, allowing to expose
+ * internal status to userspace, and perform PHY configuration in a controlled
+ * 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 *phydev,
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);
int __phy_hwtstamp_get(struct phy_device *phydev,
struct kernel_hwtstamp_config *config);
--
2.46.1
next prev parent reply other threads:[~2024-10-04 16:16 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 16:15 [PATCH net-next v2 0/9] Allow isolating PHY devices Maxime Chevallier
2024-10-04 16:15 ` [PATCH net-next v2 1/9] net: phy: allow " Maxime Chevallier
2024-10-04 16:15 ` [PATCH net-next v2 2/9] net: phy: Introduce phy_shutdown for device quiescence Maxime Chevallier
2024-10-04 16:15 ` [PATCH net-next v2 3/9] net: phy: Allow PHY drivers to report isolation support Maxime Chevallier
2024-10-04 16:46 ` Oleksij Rempel
2024-10-07 9:52 ` Maxime Chevallier
2024-10-04 18:20 ` Andrew Lunn
2024-10-07 10:27 ` Maxime Chevallier
2024-10-04 16:15 ` [PATCH net-next v2 4/9] net: phy: lxt: Mark LXT973 PHYs as having a broken isolate mode Maxime Chevallier
2024-10-04 16:15 ` [PATCH net-next v2 5/9] net: phy: marvell10g: 88x3310 and 88x3340 don't support " Maxime Chevallier
2024-10-04 16:15 ` [PATCH net-next v2 6/9] net: phy: marvell: mv88e1111 doesn't support isolate in SGMII mode Maxime Chevallier
2024-10-04 16:15 ` Maxime Chevallier [this message]
2024-10-04 18:42 ` [PATCH net-next v2 7/9] net: phy: introduce ethtool_phy_ops to get and set phy configuration Andrew Lunn
2024-10-04 19:02 ` Russell King (Oracle)
2024-10-07 10:37 ` Maxime Chevallier
2024-10-07 13:01 ` Andrew Lunn
2024-10-07 13:48 ` Maxime Chevallier
2024-10-07 16:10 ` Russell King (Oracle)
2024-10-08 7:07 ` Maxime Chevallier
2024-10-07 16:37 ` Andrew Lunn
2024-10-08 7:25 ` Maxime Chevallier
2024-10-08 13:00 ` Andrew Lunn
2024-10-08 13:22 ` Russell King (Oracle)
2024-10-08 14:57 ` Maxime Chevallier
2024-10-08 15:27 ` Russell King (Oracle)
2024-10-08 16:41 ` Maxime Chevallier
2024-10-08 17:05 ` Russell King (Oracle)
2024-10-08 17:19 ` Maxime Chevallier
2024-10-04 16:15 ` [PATCH net-next v2 8/9] net: ethtool: phy: allow reporting and setting the phy isolate status Maxime Chevallier
2024-10-04 16:15 ` [PATCH net-next v2 9/9] netlink: specs: introduce phy-set command along with configurable attributes Maxime Chevallier
2024-10-04 17:02 ` [PATCH net-next v2 0/9] Allow isolating PHY devices Russell King (Oracle)
2024-10-07 10:25 ` Maxime Chevallier
2024-10-07 15:53 ` Russell King (Oracle)
2024-10-07 16:43 ` Andrew Lunn
2024-10-08 6:28 ` Maxime Chevallier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241004161601.2932901-8-maxime.chevallier@bootlin.com \
--to=maxime.chevallier@bootlin.com \
--cc=andrew@lunn.ch \
--cc=christophe.leroy@csgroup.eu \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=herve.codina@bootlin.com \
--cc=hkallweit1@gmail.com \
--cc=kabel@kernel.org \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=vladimir.oltean@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®