Skip to content

Commit 44465c4

Browse files
committed
Merge branch 'phylink-API-changes'
Florian Fainelli says: ==================== phylink: API changes This patch series contains two API changes to PHYLINK which will later be used by DSA to migrate to PHYLINK. Because these are API changes that impact other outstanding work (e.g: MVPP2) I would rather get them included sooner to minimize conflicts. Thank you! Changes in v2: - added missing documentation to mac_link_{up,down} that the interface must be configured in mac_config() - added Russell's, Andrew's and my tags ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 2166dc9 + e679c9c commit 44465c4

File tree

6 files changed

+29
-58
lines changed

6 files changed

+29
-58
lines changed

drivers/net/ethernet/marvell/mvneta.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3396,7 +3396,8 @@ static void mvneta_set_eee(struct mvneta_port *pp, bool enable)
33963396
mvreg_write(pp, MVNETA_LPI_CTRL_1, lpi_ctl1);
33973397
}
33983398

3399-
static void mvneta_mac_link_down(struct net_device *ndev, unsigned int mode)
3399+
static void mvneta_mac_link_down(struct net_device *ndev, unsigned int mode,
3400+
phy_interface_t interface)
34003401
{
34013402
struct mvneta_port *pp = netdev_priv(ndev);
34023403
u32 val;
@@ -3415,6 +3416,7 @@ static void mvneta_mac_link_down(struct net_device *ndev, unsigned int mode)
34153416
}
34163417

34173418
static void mvneta_mac_link_up(struct net_device *ndev, unsigned int mode,
3419+
phy_interface_t interface,
34183420
struct phy_device *phy)
34193421
{
34203422
struct mvneta_port *pp = netdev_priv(ndev);
@@ -4073,22 +4075,6 @@ static int mvneta_ethtool_set_wol(struct net_device *dev,
40734075
return ret;
40744076
}
40754077

4076-
static int mvneta_ethtool_get_module_info(struct net_device *dev,
4077-
struct ethtool_modinfo *modinfo)
4078-
{
4079-
struct mvneta_port *pp = netdev_priv(dev);
4080-
4081-
return phylink_ethtool_get_module_info(pp->phylink, modinfo);
4082-
}
4083-
4084-
static int mvneta_ethtool_get_module_eeprom(struct net_device *dev,
4085-
struct ethtool_eeprom *ee, u8 *buf)
4086-
{
4087-
struct mvneta_port *pp = netdev_priv(dev);
4088-
4089-
return phylink_ethtool_get_module_eeprom(pp->phylink, ee, buf);
4090-
}
4091-
40924078
static int mvneta_ethtool_get_eee(struct net_device *dev,
40934079
struct ethtool_eee *eee)
40944080
{
@@ -4163,8 +4149,6 @@ static const struct ethtool_ops mvneta_eth_tool_ops = {
41634149
.set_link_ksettings = mvneta_ethtool_set_link_ksettings,
41644150
.get_wol = mvneta_ethtool_get_wol,
41654151
.set_wol = mvneta_ethtool_set_wol,
4166-
.get_module_info = mvneta_ethtool_get_module_info,
4167-
.get_module_eeprom = mvneta_ethtool_get_module_eeprom,
41684152
.get_eee = mvneta_ethtool_get_eee,
41694153
.set_eee = mvneta_ethtool_set_eee,
41704154
};

drivers/net/phy/phylink.c

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,12 @@ static void phylink_resolve(struct work_struct *w)
470470
if (link_state.link != netif_carrier_ok(ndev)) {
471471
if (!link_state.link) {
472472
netif_carrier_off(ndev);
473-
pl->ops->mac_link_down(ndev, pl->link_an_mode);
473+
pl->ops->mac_link_down(ndev, pl->link_an_mode,
474+
pl->phy_state.interface);
474475
netdev_info(ndev, "Link is Down\n");
475476
} else {
476477
pl->ops->mac_link_up(ndev, pl->link_an_mode,
478+
pl->phy_state.interface,
477479
pl->phydev);
478480

479481
netif_carrier_on(ndev);
@@ -1248,34 +1250,6 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
12481250
}
12491251
EXPORT_SYMBOL_GPL(phylink_ethtool_set_pauseparam);
12501252

1251-
int phylink_ethtool_get_module_info(struct phylink *pl,
1252-
struct ethtool_modinfo *modinfo)
1253-
{
1254-
int ret = -EOPNOTSUPP;
1255-
1256-
WARN_ON(!lockdep_rtnl_is_held());
1257-
1258-
if (pl->sfp_bus)
1259-
ret = sfp_get_module_info(pl->sfp_bus, modinfo);
1260-
1261-
return ret;
1262-
}
1263-
EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_info);
1264-
1265-
int phylink_ethtool_get_module_eeprom(struct phylink *pl,
1266-
struct ethtool_eeprom *ee, u8 *buf)
1267-
{
1268-
int ret = -EOPNOTSUPP;
1269-
1270-
WARN_ON(!lockdep_rtnl_is_held());
1271-
1272-
if (pl->sfp_bus)
1273-
ret = sfp_get_module_eeprom(pl->sfp_bus, ee, buf);
1274-
1275-
return ret;
1276-
}
1277-
EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_eeprom);
1278-
12791253
/**
12801254
* phylink_ethtool_get_eee_err() - read the energy efficient ethernet error
12811255
* counter

drivers/net/phy/sfp-bus.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ static int sfp_register_bus(struct sfp_bus *bus)
342342
}
343343
if (bus->started)
344344
bus->socket_ops->start(bus->sfp);
345+
bus->netdev->sfp_bus = bus;
345346
bus->registered = true;
346347
return 0;
347348
}
@@ -356,6 +357,7 @@ static void sfp_unregister_bus(struct sfp_bus *bus)
356357
if (bus->phydev && ops && ops->disconnect_phy)
357358
ops->disconnect_phy(bus->upstream);
358359
}
360+
bus->netdev->sfp_bus = NULL;
359361
bus->registered = false;
360362
}
361363

@@ -371,8 +373,6 @@ static void sfp_unregister_bus(struct sfp_bus *bus)
371373
*/
372374
int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo)
373375
{
374-
if (!bus->registered)
375-
return -ENOIOCTLCMD;
376376
return bus->socket_ops->module_info(bus->sfp, modinfo);
377377
}
378378
EXPORT_SYMBOL_GPL(sfp_get_module_info);
@@ -391,8 +391,6 @@ EXPORT_SYMBOL_GPL(sfp_get_module_info);
391391
int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee,
392392
u8 *data)
393393
{
394-
if (!bus->registered)
395-
return -ENOIOCTLCMD;
396394
return bus->socket_ops->module_eeprom(bus->sfp, ee, data);
397395
}
398396
EXPORT_SYMBOL_GPL(sfp_get_module_eeprom);

include/linux/netdevice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct device;
5858
struct phy_device;
5959
struct dsa_port;
6060

61+
struct sfp_bus;
6162
/* 802.11 specific */
6263
struct wireless_dev;
6364
/* 802.15.4 specific */
@@ -1662,6 +1663,7 @@ enum netdev_priv_flags {
16621663
* @priomap: XXX: need comments on this one
16631664
* @phydev: Physical device may attach itself
16641665
* for hardware timestamping
1666+
* @sfp_bus: attached &struct sfp_bus structure.
16651667
*
16661668
* @qdisc_tx_busylock: lockdep class annotating Qdisc->busylock spinlock
16671669
* @qdisc_running_key: lockdep class annotating Qdisc->running seqcount
@@ -1945,6 +1947,7 @@ struct net_device {
19451947
struct netprio_map __rcu *priomap;
19461948
#endif
19471949
struct phy_device *phydev;
1950+
struct sfp_bus *sfp_bus;
19481951
struct lock_class_key *qdisc_tx_busylock;
19491952
struct lock_class_key *qdisc_running_key;
19501953
bool proto_down;

include/linux/phylink.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ struct phylink_mac_ops {
7373
void (*mac_config)(struct net_device *ndev, unsigned int mode,
7474
const struct phylink_link_state *state);
7575
void (*mac_an_restart)(struct net_device *ndev);
76-
void (*mac_link_down)(struct net_device *ndev, unsigned int mode);
76+
void (*mac_link_down)(struct net_device *ndev, unsigned int mode,
77+
phy_interface_t interface);
7778
void (*mac_link_up)(struct net_device *ndev, unsigned int mode,
79+
phy_interface_t interface,
7880
struct phy_device *phy);
7981
};
8082

@@ -161,25 +163,31 @@ void mac_an_restart(struct net_device *ndev);
161163
* mac_link_down() - take the link down
162164
* @ndev: a pointer to a &struct net_device for the MAC.
163165
* @mode: link autonegotiation mode
166+
* @interface: link &typedef phy_interface_t mode
164167
*
165168
* If @mode is not an in-band negotiation mode (as defined by
166169
* phylink_autoneg_inband()), force the link down and disable any
167-
* Energy Efficient Ethernet MAC configuration.
170+
* Energy Efficient Ethernet MAC configuration. Interface type
171+
* selection must be done in mac_config().
168172
*/
169-
void mac_link_down(struct net_device *ndev, unsigned int mode);
173+
void mac_link_down(struct net_device *ndev, unsigned int mode,
174+
phy_interface_t interface);
170175

171176
/**
172177
* mac_link_up() - allow the link to come up
173178
* @ndev: a pointer to a &struct net_device for the MAC.
174179
* @mode: link autonegotiation mode
180+
* @interface: link &typedef phy_interface_t mode
175181
* @phy: any attached phy
176182
*
177183
* If @mode is not an in-band negotiation mode (as defined by
178184
* phylink_autoneg_inband()), allow the link to come up. If @phy
179185
* is non-%NULL, configure Energy Efficient Ethernet by calling
180186
* phy_init_eee() and perform appropriate MAC configuration for EEE.
187+
* Interface type selection must be done in mac_config().
181188
*/
182189
void mac_link_up(struct net_device *ndev, unsigned int mode,
190+
phy_interface_t interface,
183191
struct phy_device *phy);
184192
#endif
185193

@@ -211,9 +219,6 @@ void phylink_ethtool_get_pauseparam(struct phylink *,
211219
struct ethtool_pauseparam *);
212220
int phylink_ethtool_set_pauseparam(struct phylink *,
213221
struct ethtool_pauseparam *);
214-
int phylink_ethtool_get_module_info(struct phylink *, struct ethtool_modinfo *);
215-
int phylink_ethtool_get_module_eeprom(struct phylink *,
216-
struct ethtool_eeprom *, u8 *);
217222
int phylink_get_eee_err(struct phylink *);
218223
int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *);
219224
int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *);

net/core/ethtool.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/bitops.h>
2323
#include <linux/uaccess.h>
2424
#include <linux/vmalloc.h>
25+
#include <linux/sfp.h>
2526
#include <linux/slab.h>
2627
#include <linux/rtnetlink.h>
2728
#include <linux/sched/signal.h>
@@ -2245,6 +2246,9 @@ static int __ethtool_get_module_info(struct net_device *dev,
22452246
const struct ethtool_ops *ops = dev->ethtool_ops;
22462247
struct phy_device *phydev = dev->phydev;
22472248

2249+
if (dev->sfp_bus)
2250+
return sfp_get_module_info(dev->sfp_bus, modinfo);
2251+
22482252
if (phydev && phydev->drv && phydev->drv->module_info)
22492253
return phydev->drv->module_info(phydev, modinfo);
22502254

@@ -2279,6 +2283,9 @@ static int __ethtool_get_module_eeprom(struct net_device *dev,
22792283
const struct ethtool_ops *ops = dev->ethtool_ops;
22802284
struct phy_device *phydev = dev->phydev;
22812285

2286+
if (dev->sfp_bus)
2287+
return sfp_get_module_eeprom(dev->sfp_bus, ee, data);
2288+
22822289
if (phydev && phydev->drv && phydev->drv->module_eeprom)
22832290
return phydev->drv->module_eeprom(phydev, ee, data);
22842291

0 commit comments

Comments
 (0)