aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilippe Reynes <tremyfr@gmail.com>2017-03-04 18:04:18 -0500
committerDavid S. Miller <davem@davemloft.net>2017-03-09 01:18:05 -0500
commit92552fdda557d1a9d7a819a79d0e356d439e8cfc (patch)
tree69b59d4e7b3ea86ce4dca00a2ba0d70499d4993a
parentd972253146867b65ecff0bcc0e551a970b3efa1b (diff)
net: sun: sungem: use new api ethtool_{get|set}_link_ksettings
The ethtool api {get|set}_settings is deprecated. We move this driver to new api {get|set}_link_ksettings. As I don't have the hardware, I'd be very pleased if someone may test this patch. Signed-off-by: Philippe Reynes <tremyfr@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/sun/sungem.c98
1 files changed, 57 insertions, 41 deletions
diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c
index 5c5952e782cd..dbfca0466760 100644
--- a/drivers/net/ethernet/sun/sungem.c
+++ b/drivers/net/ethernet/sun/sungem.c
@@ -1250,12 +1250,17 @@ static void gem_stop_dma(struct gem *gp)
1250 1250
1251 1251
1252// XXX dbl check what that function should do when called on PCS PHY 1252// XXX dbl check what that function should do when called on PCS PHY
1253static void gem_begin_auto_negotiation(struct gem *gp, struct ethtool_cmd *ep) 1253static void gem_begin_auto_negotiation(struct gem *gp,
1254 const struct ethtool_link_ksettings *ep)
1254{ 1255{
1255 u32 advertise, features; 1256 u32 advertise, features;
1256 int autoneg; 1257 int autoneg;
1257 int speed; 1258 int speed;
1258 int duplex; 1259 int duplex;
1260 u32 advertising;
1261
1262 ethtool_convert_link_mode_to_legacy_u32(&advertising,
1263 ep->link_modes.advertising);
1259 1264
1260 if (gp->phy_type != phy_mii_mdio0 && 1265 if (gp->phy_type != phy_mii_mdio0 &&
1261 gp->phy_type != phy_mii_mdio1) 1266 gp->phy_type != phy_mii_mdio1)
@@ -1278,13 +1283,13 @@ static void gem_begin_auto_negotiation(struct gem *gp, struct ethtool_cmd *ep)
1278 /* Setup link parameters */ 1283 /* Setup link parameters */
1279 if (!ep) 1284 if (!ep)
1280 goto start_aneg; 1285 goto start_aneg;
1281 if (ep->autoneg == AUTONEG_ENABLE) { 1286 if (ep->base.autoneg == AUTONEG_ENABLE) {
1282 advertise = ep->advertising; 1287 advertise = advertising;
1283 autoneg = 1; 1288 autoneg = 1;
1284 } else { 1289 } else {
1285 autoneg = 0; 1290 autoneg = 0;
1286 speed = ethtool_cmd_speed(ep); 1291 speed = ep->base.speed;
1287 duplex = ep->duplex; 1292 duplex = ep->base.duplex;
1288 } 1293 }
1289 1294
1290start_aneg: 1295start_aneg:
@@ -2515,85 +2520,96 @@ static void gem_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
2515 strlcpy(info->bus_info, pci_name(gp->pdev), sizeof(info->bus_info)); 2520 strlcpy(info->bus_info, pci_name(gp->pdev), sizeof(info->bus_info));
2516} 2521}
2517 2522
2518static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2523static int gem_get_link_ksettings(struct net_device *dev,
2524 struct ethtool_link_ksettings *cmd)
2519{ 2525{
2520 struct gem *gp = netdev_priv(dev); 2526 struct gem *gp = netdev_priv(dev);
2527 u32 supported, advertising;
2521 2528
2522 if (gp->phy_type == phy_mii_mdio0 || 2529 if (gp->phy_type == phy_mii_mdio0 ||
2523 gp->phy_type == phy_mii_mdio1) { 2530 gp->phy_type == phy_mii_mdio1) {
2524 if (gp->phy_mii.def) 2531 if (gp->phy_mii.def)
2525 cmd->supported = gp->phy_mii.def->features; 2532 supported = gp->phy_mii.def->features;
2526 else 2533 else
2527 cmd->supported = (SUPPORTED_10baseT_Half | 2534 supported = (SUPPORTED_10baseT_Half |
2528 SUPPORTED_10baseT_Full); 2535 SUPPORTED_10baseT_Full);
2529 2536
2530 /* XXX hardcoded stuff for now */ 2537 /* XXX hardcoded stuff for now */
2531 cmd->port = PORT_MII; 2538 cmd->base.port = PORT_MII;
2532 cmd->transceiver = XCVR_EXTERNAL; 2539 cmd->base.phy_address = 0; /* XXX fixed PHYAD */
2533 cmd->phy_address = 0; /* XXX fixed PHYAD */
2534 2540
2535 /* Return current PHY settings */ 2541 /* Return current PHY settings */
2536 cmd->autoneg = gp->want_autoneg; 2542 cmd->base.autoneg = gp->want_autoneg;
2537 ethtool_cmd_speed_set(cmd, gp->phy_mii.speed); 2543 cmd->base.speed = gp->phy_mii.speed;
2538 cmd->duplex = gp->phy_mii.duplex; 2544 cmd->base.duplex = gp->phy_mii.duplex;
2539 cmd->advertising = gp->phy_mii.advertising; 2545 advertising = gp->phy_mii.advertising;
2540 2546
2541 /* If we started with a forced mode, we don't have a default 2547 /* If we started with a forced mode, we don't have a default
2542 * advertise set, we need to return something sensible so 2548 * advertise set, we need to return something sensible so
2543 * userland can re-enable autoneg properly. 2549 * userland can re-enable autoneg properly.
2544 */ 2550 */
2545 if (cmd->advertising == 0) 2551 if (advertising == 0)
2546 cmd->advertising = cmd->supported; 2552 advertising = supported;
2547 } else { // XXX PCS ? 2553 } else { // XXX PCS ?
2548 cmd->supported = 2554 supported =
2549 (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | 2555 (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
2550 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | 2556 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
2551 SUPPORTED_Autoneg); 2557 SUPPORTED_Autoneg);
2552 cmd->advertising = cmd->supported; 2558 advertising = supported;
2553 ethtool_cmd_speed_set(cmd, 0); 2559 cmd->base.speed = 0;
2554 cmd->duplex = cmd->port = cmd->phy_address = 2560 cmd->base.duplex = 0;
2555 cmd->transceiver = cmd->autoneg = 0; 2561 cmd->base.port = 0;
2562 cmd->base.phy_address = 0;
2563 cmd->base.autoneg = 0;
2556 2564
2557 /* serdes means usually a Fibre connector, with most fixed */ 2565 /* serdes means usually a Fibre connector, with most fixed */
2558 if (gp->phy_type == phy_serdes) { 2566 if (gp->phy_type == phy_serdes) {
2559 cmd->port = PORT_FIBRE; 2567 cmd->base.port = PORT_FIBRE;
2560 cmd->supported = (SUPPORTED_1000baseT_Half | 2568 supported = (SUPPORTED_1000baseT_Half |
2561 SUPPORTED_1000baseT_Full | 2569 SUPPORTED_1000baseT_Full |
2562 SUPPORTED_FIBRE | SUPPORTED_Autoneg | 2570 SUPPORTED_FIBRE | SUPPORTED_Autoneg |
2563 SUPPORTED_Pause | SUPPORTED_Asym_Pause); 2571 SUPPORTED_Pause | SUPPORTED_Asym_Pause);
2564 cmd->advertising = cmd->supported; 2572 advertising = supported;
2565 cmd->transceiver = XCVR_INTERNAL;
2566 if (gp->lstate == link_up) 2573 if (gp->lstate == link_up)
2567 ethtool_cmd_speed_set(cmd, SPEED_1000); 2574 cmd->base.speed = SPEED_1000;
2568 cmd->duplex = DUPLEX_FULL; 2575 cmd->base.duplex = DUPLEX_FULL;
2569 cmd->autoneg = 1; 2576 cmd->base.autoneg = 1;
2570 } 2577 }
2571 } 2578 }
2572 cmd->maxtxpkt = cmd->maxrxpkt = 0; 2579
2580 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
2581 supported);
2582 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
2583 advertising);
2573 2584
2574 return 0; 2585 return 0;
2575} 2586}
2576 2587
2577static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2588static int gem_set_link_ksettings(struct net_device *dev,
2589 const struct ethtool_link_ksettings *cmd)
2578{ 2590{
2579 struct gem *gp = netdev_priv(dev); 2591 struct gem *gp = netdev_priv(dev);
2580 u32 speed = ethtool_cmd_speed(cmd); 2592 u32 speed = cmd->base.speed;
2593 u32 advertising;
2594
2595 ethtool_convert_link_mode_to_legacy_u32(&advertising,
2596 cmd->link_modes.advertising);
2581 2597
2582 /* Verify the settings we care about. */ 2598 /* Verify the settings we care about. */
2583 if (cmd->autoneg != AUTONEG_ENABLE && 2599 if (cmd->base.autoneg != AUTONEG_ENABLE &&
2584 cmd->autoneg != AUTONEG_DISABLE) 2600 cmd->base.autoneg != AUTONEG_DISABLE)
2585 return -EINVAL; 2601 return -EINVAL;
2586 2602
2587 if (cmd->autoneg == AUTONEG_ENABLE && 2603 if (cmd->base.autoneg == AUTONEG_ENABLE &&
2588 cmd->advertising == 0) 2604 advertising == 0)
2589 return -EINVAL; 2605 return -EINVAL;
2590 2606
2591 if (cmd->autoneg == AUTONEG_DISABLE && 2607 if (cmd->base.autoneg == AUTONEG_DISABLE &&
2592 ((speed != SPEED_1000 && 2608 ((speed != SPEED_1000 &&
2593 speed != SPEED_100 && 2609 speed != SPEED_100 &&
2594 speed != SPEED_10) || 2610 speed != SPEED_10) ||
2595 (cmd->duplex != DUPLEX_HALF && 2611 (cmd->base.duplex != DUPLEX_HALF &&
2596 cmd->duplex != DUPLEX_FULL))) 2612 cmd->base.duplex != DUPLEX_FULL)))
2597 return -EINVAL; 2613 return -EINVAL;
2598 2614
2599 /* Apply settings and restart link process. */ 2615 /* Apply settings and restart link process. */
@@ -2666,13 +2682,13 @@ static int gem_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2666static const struct ethtool_ops gem_ethtool_ops = { 2682static const struct ethtool_ops gem_ethtool_ops = {
2667 .get_drvinfo = gem_get_drvinfo, 2683 .get_drvinfo = gem_get_drvinfo,
2668 .get_link = ethtool_op_get_link, 2684 .get_link = ethtool_op_get_link,
2669 .get_settings = gem_get_settings,
2670 .set_settings = gem_set_settings,
2671 .nway_reset = gem_nway_reset, 2685 .nway_reset = gem_nway_reset,
2672 .get_msglevel = gem_get_msglevel, 2686 .get_msglevel = gem_get_msglevel,
2673 .set_msglevel = gem_set_msglevel, 2687 .set_msglevel = gem_set_msglevel,
2674 .get_wol = gem_get_wol, 2688 .get_wol = gem_get_wol,
2675 .set_wol = gem_set_wol, 2689 .set_wol = gem_set_wol,
2690 .get_link_ksettings = gem_get_link_ksettings,
2691 .set_link_ksettings = gem_set_link_ksettings,
2676}; 2692};
2677 2693
2678static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 2694static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)