diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2018-03-28 18:44:16 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-03-30 10:11:06 -0400 |
commit | e679c9c1dbfdba07b2a979a076cca74b773be8ce (patch) | |
tree | 25a3a118ff28a51f1cedd552c4090b48f2fe5560 | |
parent | c6ab3008b6a6ecda22e92f96a1b9cc6b0d0b0a4e (diff) |
sfp/phylink: move module EEPROM ethtool access into netdev core ethtool
Provide a pointer to the SFP bus in struct net_device, so that the
ethtool module EEPROM methods can access the SFP directly, rather
than needing every user to provide a hook for it.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/marvell/mvneta.c | 18 | ||||
-rw-r--r-- | drivers/net/phy/phylink.c | 28 | ||||
-rw-r--r-- | drivers/net/phy/sfp-bus.c | 6 | ||||
-rw-r--r-- | include/linux/netdevice.h | 3 | ||||
-rw-r--r-- | include/linux/phylink.h | 3 | ||||
-rw-r--r-- | net/core/ethtool.c | 7 |
6 files changed, 12 insertions, 53 deletions
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index cd09bde55596..25ced96750bf 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c | |||
@@ -4075,22 +4075,6 @@ static int mvneta_ethtool_set_wol(struct net_device *dev, | |||
4075 | return ret; | 4075 | return ret; |
4076 | } | 4076 | } |
4077 | 4077 | ||
4078 | static int mvneta_ethtool_get_module_info(struct net_device *dev, | ||
4079 | struct ethtool_modinfo *modinfo) | ||
4080 | { | ||
4081 | struct mvneta_port *pp = netdev_priv(dev); | ||
4082 | |||
4083 | return phylink_ethtool_get_module_info(pp->phylink, modinfo); | ||
4084 | } | ||
4085 | |||
4086 | static int mvneta_ethtool_get_module_eeprom(struct net_device *dev, | ||
4087 | struct ethtool_eeprom *ee, u8 *buf) | ||
4088 | { | ||
4089 | struct mvneta_port *pp = netdev_priv(dev); | ||
4090 | |||
4091 | return phylink_ethtool_get_module_eeprom(pp->phylink, ee, buf); | ||
4092 | } | ||
4093 | |||
4094 | static int mvneta_ethtool_get_eee(struct net_device *dev, | 4078 | static int mvneta_ethtool_get_eee(struct net_device *dev, |
4095 | struct ethtool_eee *eee) | 4079 | struct ethtool_eee *eee) |
4096 | { | 4080 | { |
@@ -4165,8 +4149,6 @@ static const struct ethtool_ops mvneta_eth_tool_ops = { | |||
4165 | .set_link_ksettings = mvneta_ethtool_set_link_ksettings, | 4149 | .set_link_ksettings = mvneta_ethtool_set_link_ksettings, |
4166 | .get_wol = mvneta_ethtool_get_wol, | 4150 | .get_wol = mvneta_ethtool_get_wol, |
4167 | .set_wol = mvneta_ethtool_set_wol, | 4151 | .set_wol = mvneta_ethtool_set_wol, |
4168 | .get_module_info = mvneta_ethtool_get_module_info, | ||
4169 | .get_module_eeprom = mvneta_ethtool_get_module_eeprom, | ||
4170 | .get_eee = mvneta_ethtool_get_eee, | 4152 | .get_eee = mvneta_ethtool_get_eee, |
4171 | .set_eee = mvneta_ethtool_set_eee, | 4153 | .set_eee = mvneta_ethtool_set_eee, |
4172 | }; | 4154 | }; |
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 9b1e4721ea3a..c582b2d7546c 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c | |||
@@ -1250,34 +1250,6 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl, | |||
1250 | } | 1250 | } |
1251 | EXPORT_SYMBOL_GPL(phylink_ethtool_set_pauseparam); | 1251 | EXPORT_SYMBOL_GPL(phylink_ethtool_set_pauseparam); |
1252 | 1252 | ||
1253 | int phylink_ethtool_get_module_info(struct phylink *pl, | ||
1254 | struct ethtool_modinfo *modinfo) | ||
1255 | { | ||
1256 | int ret = -EOPNOTSUPP; | ||
1257 | |||
1258 | WARN_ON(!lockdep_rtnl_is_held()); | ||
1259 | |||
1260 | if (pl->sfp_bus) | ||
1261 | ret = sfp_get_module_info(pl->sfp_bus, modinfo); | ||
1262 | |||
1263 | return ret; | ||
1264 | } | ||
1265 | EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_info); | ||
1266 | |||
1267 | int phylink_ethtool_get_module_eeprom(struct phylink *pl, | ||
1268 | struct ethtool_eeprom *ee, u8 *buf) | ||
1269 | { | ||
1270 | int ret = -EOPNOTSUPP; | ||
1271 | |||
1272 | WARN_ON(!lockdep_rtnl_is_held()); | ||
1273 | |||
1274 | if (pl->sfp_bus) | ||
1275 | ret = sfp_get_module_eeprom(pl->sfp_bus, ee, buf); | ||
1276 | |||
1277 | return ret; | ||
1278 | } | ||
1279 | EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_eeprom); | ||
1280 | |||
1281 | /** | 1253 | /** |
1282 | * phylink_ethtool_get_eee_err() - read the energy efficient ethernet error | 1254 | * phylink_ethtool_get_eee_err() - read the energy efficient ethernet error |
1283 | * counter | 1255 | * counter |
diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c index 3d4ff5d0d2a6..0381da78d228 100644 --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c | |||
@@ -342,6 +342,7 @@ static int sfp_register_bus(struct sfp_bus *bus) | |||
342 | } | 342 | } |
343 | if (bus->started) | 343 | if (bus->started) |
344 | bus->socket_ops->start(bus->sfp); | 344 | bus->socket_ops->start(bus->sfp); |
345 | bus->netdev->sfp_bus = bus; | ||
345 | bus->registered = true; | 346 | bus->registered = true; |
346 | return 0; | 347 | return 0; |
347 | } | 348 | } |
@@ -356,6 +357,7 @@ static void sfp_unregister_bus(struct sfp_bus *bus) | |||
356 | if (bus->phydev && ops && ops->disconnect_phy) | 357 | if (bus->phydev && ops && ops->disconnect_phy) |
357 | ops->disconnect_phy(bus->upstream); | 358 | ops->disconnect_phy(bus->upstream); |
358 | } | 359 | } |
360 | bus->netdev->sfp_bus = NULL; | ||
359 | bus->registered = false; | 361 | bus->registered = false; |
360 | } | 362 | } |
361 | 363 | ||
@@ -371,8 +373,6 @@ static void sfp_unregister_bus(struct sfp_bus *bus) | |||
371 | */ | 373 | */ |
372 | int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo) | 374 | int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo) |
373 | { | 375 | { |
374 | if (!bus->registered) | ||
375 | return -ENOIOCTLCMD; | ||
376 | return bus->socket_ops->module_info(bus->sfp, modinfo); | 376 | return bus->socket_ops->module_info(bus->sfp, modinfo); |
377 | } | 377 | } |
378 | EXPORT_SYMBOL_GPL(sfp_get_module_info); | 378 | EXPORT_SYMBOL_GPL(sfp_get_module_info); |
@@ -391,8 +391,6 @@ EXPORT_SYMBOL_GPL(sfp_get_module_info); | |||
391 | int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee, | 391 | int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee, |
392 | u8 *data) | 392 | u8 *data) |
393 | { | 393 | { |
394 | if (!bus->registered) | ||
395 | return -ENOIOCTLCMD; | ||
396 | return bus->socket_ops->module_eeprom(bus->sfp, ee, data); | 394 | return bus->socket_ops->module_eeprom(bus->sfp, ee, data); |
397 | } | 395 | } |
398 | EXPORT_SYMBOL_GPL(sfp_get_module_eeprom); | 396 | EXPORT_SYMBOL_GPL(sfp_get_module_eeprom); |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index da44dab492e3..cf44503ea81a 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -58,6 +58,7 @@ struct device; | |||
58 | struct phy_device; | 58 | struct phy_device; |
59 | struct dsa_port; | 59 | struct dsa_port; |
60 | 60 | ||
61 | struct sfp_bus; | ||
61 | /* 802.11 specific */ | 62 | /* 802.11 specific */ |
62 | struct wireless_dev; | 63 | struct wireless_dev; |
63 | /* 802.15.4 specific */ | 64 | /* 802.15.4 specific */ |
@@ -1662,6 +1663,7 @@ enum netdev_priv_flags { | |||
1662 | * @priomap: XXX: need comments on this one | 1663 | * @priomap: XXX: need comments on this one |
1663 | * @phydev: Physical device may attach itself | 1664 | * @phydev: Physical device may attach itself |
1664 | * for hardware timestamping | 1665 | * for hardware timestamping |
1666 | * @sfp_bus: attached &struct sfp_bus structure. | ||
1665 | * | 1667 | * |
1666 | * @qdisc_tx_busylock: lockdep class annotating Qdisc->busylock spinlock | 1668 | * @qdisc_tx_busylock: lockdep class annotating Qdisc->busylock spinlock |
1667 | * @qdisc_running_key: lockdep class annotating Qdisc->running seqcount | 1669 | * @qdisc_running_key: lockdep class annotating Qdisc->running seqcount |
@@ -1945,6 +1947,7 @@ struct net_device { | |||
1945 | struct netprio_map __rcu *priomap; | 1947 | struct netprio_map __rcu *priomap; |
1946 | #endif | 1948 | #endif |
1947 | struct phy_device *phydev; | 1949 | struct phy_device *phydev; |
1950 | struct sfp_bus *sfp_bus; | ||
1948 | struct lock_class_key *qdisc_tx_busylock; | 1951 | struct lock_class_key *qdisc_tx_busylock; |
1949 | struct lock_class_key *qdisc_running_key; | 1952 | struct lock_class_key *qdisc_running_key; |
1950 | bool proto_down; | 1953 | bool proto_down; |
diff --git a/include/linux/phylink.h b/include/linux/phylink.h index e95cc12030fa..50eeae025f1e 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h | |||
@@ -219,9 +219,6 @@ void phylink_ethtool_get_pauseparam(struct phylink *, | |||
219 | struct ethtool_pauseparam *); | 219 | struct ethtool_pauseparam *); |
220 | int phylink_ethtool_set_pauseparam(struct phylink *, | 220 | int phylink_ethtool_set_pauseparam(struct phylink *, |
221 | struct ethtool_pauseparam *); | 221 | struct ethtool_pauseparam *); |
222 | int phylink_ethtool_get_module_info(struct phylink *, struct ethtool_modinfo *); | ||
223 | int phylink_ethtool_get_module_eeprom(struct phylink *, | ||
224 | struct ethtool_eeprom *, u8 *); | ||
225 | int phylink_get_eee_err(struct phylink *); | 222 | int phylink_get_eee_err(struct phylink *); |
226 | int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *); | 223 | int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *); |
227 | int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *); | 224 | int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *); |
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index bb6e498c6e3d..eb55252ca1fb 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/bitops.h> | 22 | #include <linux/bitops.h> |
23 | #include <linux/uaccess.h> | 23 | #include <linux/uaccess.h> |
24 | #include <linux/vmalloc.h> | 24 | #include <linux/vmalloc.h> |
25 | #include <linux/sfp.h> | ||
25 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
26 | #include <linux/rtnetlink.h> | 27 | #include <linux/rtnetlink.h> |
27 | #include <linux/sched/signal.h> | 28 | #include <linux/sched/signal.h> |
@@ -2245,6 +2246,9 @@ static int __ethtool_get_module_info(struct net_device *dev, | |||
2245 | const struct ethtool_ops *ops = dev->ethtool_ops; | 2246 | const struct ethtool_ops *ops = dev->ethtool_ops; |
2246 | struct phy_device *phydev = dev->phydev; | 2247 | struct phy_device *phydev = dev->phydev; |
2247 | 2248 | ||
2249 | if (dev->sfp_bus) | ||
2250 | return sfp_get_module_info(dev->sfp_bus, modinfo); | ||
2251 | |||
2248 | if (phydev && phydev->drv && phydev->drv->module_info) | 2252 | if (phydev && phydev->drv && phydev->drv->module_info) |
2249 | return phydev->drv->module_info(phydev, modinfo); | 2253 | return phydev->drv->module_info(phydev, modinfo); |
2250 | 2254 | ||
@@ -2279,6 +2283,9 @@ static int __ethtool_get_module_eeprom(struct net_device *dev, | |||
2279 | const struct ethtool_ops *ops = dev->ethtool_ops; | 2283 | const struct ethtool_ops *ops = dev->ethtool_ops; |
2280 | struct phy_device *phydev = dev->phydev; | 2284 | struct phy_device *phydev = dev->phydev; |
2281 | 2285 | ||
2286 | if (dev->sfp_bus) | ||
2287 | return sfp_get_module_eeprom(dev->sfp_bus, ee, data); | ||
2288 | |||
2282 | if (phydev && phydev->drv && phydev->drv->module_eeprom) | 2289 | if (phydev && phydev->drv && phydev->drv->module_eeprom) |
2283 | return phydev->drv->module_eeprom(phydev, ee, data); | 2290 | return phydev->drv->module_eeprom(phydev, ee, data); |
2284 | 2291 | ||