From: Russell King <rmk+kernel@arm.linux.org.uk>
To: Florian Fainelli <f.fainelli@gmail.com>,
Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH RFC 24/26] phylink: add module EEPROM support
Date: Mon, 07 Dec 2015 17:39:14 +0000 [thread overview]
Message-ID: <E1a5zko-000772-Iq@rmk-PC.arm.linux.org.uk> (raw)
In-Reply-To: <20151207173553.GU8644@n2100.arm.linux.org.uk>
Add support for reading module EEPROMs through phylink.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
drivers/net/phy/phylink.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++
include/linux/phylink.h | 12 +++++++++
2 files changed, 78 insertions(+)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 82492db0fd04..cd56d454c587 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -60,6 +60,9 @@ struct phylink {
struct work_struct resolve;
bool mac_link_up;
+
+ const struct phylink_module_ops *module_ops;
+ void *module_data;
};
static const char *phylink_an_mode_str(unsigned int mode)
@@ -800,6 +803,36 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
}
EXPORT_SYMBOL_GPL(phylink_ethtool_set_pauseparam);
+int phylink_ethtool_get_module_info(struct phylink *pl,
+ struct ethtool_modinfo *modinfo)
+{
+ int ret = -EOPNOTSUPP;
+
+ mutex_lock(&pl->config_mutex);
+ if (pl->module_ops)
+ ret = pl->module_ops->get_module_info(pl->module_data,
+ modinfo);
+ mutex_unlock(&pl->config_mutex);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_info);
+
+int phylink_ethtool_get_module_eeprom(struct phylink *pl,
+ struct ethtool_eeprom *ee, u8 *buf)
+{
+ int ret = -EOPNOTSUPP;
+
+ mutex_lock(&pl->config_mutex);
+ if (pl->module_ops)
+ ret = pl->module_ops->get_module_eeprom(pl->module_data, ee,
+ buf);
+ mutex_unlock(&pl->config_mutex);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_eeprom);
+
int phylink_init_eee(struct phylink *pl, bool clk_stop_enable)
{
int ret = -EPROTONOSUPPORT;
@@ -996,6 +1029,39 @@ EXPORT_SYMBOL_GPL(phylink_mii_ioctl);
+int phylink_register_module(struct phylink *pl, void *data,
+ const struct phylink_module_ops *ops)
+{
+ int ret = -EBUSY;
+
+ mutex_lock(&pl->config_mutex);
+ if (!pl->module_ops) {
+ pl->module_ops = ops;
+ pl->module_data = data;
+ ret = 0;
+ }
+ mutex_unlock(&pl->config_mutex);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(phylink_register_module);
+
+int phylink_unregister_module(struct phylink *pl, void *data)
+{
+ int ret = -EINVAL;
+
+ mutex_lock(&pl->config_mutex);
+ if (pl->module_data == data) {
+ pl->module_ops = NULL;
+ pl->module_data = NULL;
+ ret = 0;
+ }
+ mutex_unlock(&pl->config_mutex);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(phylink_unregister_module);
+
void phylink_disable(struct phylink *pl)
{
set_bit(PHYLINK_DISABLE_LINK, &pl->phylink_disable_state);
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index 361fbe9222b2..01d442b08e62 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -55,6 +55,11 @@ struct phylink_mac_ops {
struct phy_device *);
};
+struct phylink_module_ops {
+ int (*get_module_info)(void *, struct ethtool_modinfo *);
+ int (*get_module_eeprom)(void *, struct ethtool_eeprom *, u8 *);
+};
+
struct phylink *phylink_create(struct net_device *, struct device_node *,
phy_interface_t iface, const struct phylink_mac_ops *ops);
void phylink_destroy(struct phylink *);
@@ -75,12 +80,19 @@ void phylink_ethtool_get_pauseparam(struct phylink *,
struct ethtool_pauseparam *);
int phylink_ethtool_set_pauseparam(struct phylink *,
struct ethtool_pauseparam *);
+int phylink_ethtool_get_module_info(struct phylink *, struct ethtool_modinfo *);
+int phylink_ethtool_get_module_eeprom(struct phylink *,
+ struct ethtool_eeprom *, u8 *);
int phylink_init_eee(struct phylink *, bool);
int phylink_get_eee_err(struct phylink *);
int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *);
int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *);
int phylink_mii_ioctl(struct phylink *, struct ifreq *, int);
+int phylink_register_module(struct phylink *, void *,
+ const struct phylink_module_ops *);
+int phylink_unregister_module(struct phylink *, void *);
+
void phylink_set_link_port(struct phylink *pl, u32 support, u8 port);
int phylink_set_link_an_mode(struct phylink *pl, unsigned int mode);
void phylink_disable(struct phylink *pl);
--
2.1.0
next prev parent reply other threads:[~2015-12-07 17:39 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-07 17:35 [PATCH RFC 00/26] Phylink & SFP support Russell King - ARM Linux
2015-12-07 17:37 ` [PATCH RFC 01/26] phy: move fixed_phy MII register generation to a library Russell King
2016-01-07 19:47 ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 02/26] phy: convert swphy register generation to tabular form Russell King
2016-01-07 19:47 ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 03/26] phy: separate swphy state validation from register generation Russell King
2016-01-07 19:48 ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 04/26] phy: generate swphy registers on the fly Russell King
2016-01-07 19:49 ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 05/26] phy: improve safety of fixed-phy MII register reading Russell King
2016-01-07 19:50 ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 06/26] phy: provide a hook for link up/link down events Russell King
2016-01-07 19:53 ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 07/26] phy: marvell: 88E1512: add flow control support Russell King
2016-01-07 19:53 ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 08/26] phy: export phy_start_machine() for phylink Russell King
2016-01-07 19:53 ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 09/26] phy: export phy_speed_to_str() " Russell King
2016-01-07 19:54 ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 10/26] phy: add I2C mdio bus Russell King
2015-12-08 18:15 ` Florian Fainelli
2015-12-11 10:25 ` Russell King - ARM Linux
2015-12-07 17:38 ` [PATCH RFC 11/26] phylink: add phylink infrastructure Russell King
2016-01-07 20:09 ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 12/26] phylink: add hooks for SFP support Russell King
2016-01-07 20:05 ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 13/26] sfp: add phylink based SFP module support Russell King
2016-01-07 20:23 ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 14/26] sfp: display SFP module information Russell King
2016-01-07 20:23 ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 15/26] net: mvneta: convert to phylink Russell King
2016-01-07 20:22 ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 16/26] phy: fixed-phy: remove fixed_phy_update_state() Russell King
2016-01-07 20:15 ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 17/26] phylink: add ethtool nway_reset support Russell King
2016-01-07 20:24 ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 18/26] net: mvneta: add " Russell King
2016-01-07 20:19 ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 19/26] phylink: add flow control support Russell King
2016-01-07 20:25 ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 20/26] net: mvneta: add flow control support via phylink Russell King
2016-01-07 20:26 ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 21/26] net: mvneta: enable flow control for PHY connections Russell King
2016-01-07 20:31 ` Florian Fainelli
2015-12-07 17:39 ` [PATCH RFC 22/26] phylink: add EEE support Russell King
2016-01-07 20:34 ` Florian Fainelli
2015-12-07 17:39 ` [PATCH RFC 23/26] net: mvneta: " Russell King
2016-01-07 20:35 ` Florian Fainelli
2015-12-07 17:39 ` Russell King [this message]
2016-01-07 20:36 ` [PATCH RFC 24/26] phylink: add module EEPROM support Florian Fainelli
2015-12-07 17:39 ` [PATCH RFC 25/26] net: mvneta: add module EEPROM reading support Russell King
2016-01-07 20:36 ` Florian Fainelli
2015-12-07 17:39 ` [PATCH RFC 26/26] sfp/phylink: hook up eeprom functions Russell King
2015-12-15 7:26 ` [PATCH RFC 00/26] Phylink & SFP support Dustin Byford
2015-12-28 2:08 ` Florian Fainelli
2015-12-28 23:39 ` Dustin Byford
2016-01-07 20:42 ` Florian Fainelli
2015-12-28 1:56 ` Florian Fainelli
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=E1a5zko-000772-Iq@rmk-PC.arm.linux.org.uk \
--to=rmk+kernel@arm.linux.org.uk \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=thomas.petazzoni@free-electrons.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;
as well as URLs for NNTP newsgroup(s).