net: xgbe: use new api ethtool_{get|set}_link_ksettings
authorPhilippe Reynes <tremyfr@gmail.com>
Sun, 6 Nov 2016 13:57:04 +0000 (14:57 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 9 Nov 2016 18:25:13 +0000 (13:25 -0500)
The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c

index 46c959b994a79fe31e6df62fcf69564237026c2c..920566a3a5996c3032e325e42ccd4736844a11de 100644 (file)
@@ -272,80 +272,86 @@ static int xgbe_set_pauseparam(struct net_device *netdev,
        return ret;
 }
 
-static int xgbe_get_settings(struct net_device *netdev,
-                            struct ethtool_cmd *cmd)
+static int xgbe_get_link_ksettings(struct net_device *netdev,
+                                  struct ethtool_link_ksettings *cmd)
 {
        struct xgbe_prv_data *pdata = netdev_priv(netdev);
 
-       cmd->phy_address = pdata->phy.address;
+       cmd->base.phy_address = pdata->phy.address;
 
-       cmd->supported = pdata->phy.supported;
-       cmd->advertising = pdata->phy.advertising;
-       cmd->lp_advertising = pdata->phy.lp_advertising;
+       ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
+                                               pdata->phy.supported);
+       ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
+                                               pdata->phy.advertising);
+       ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.lp_advertising,
+                                               pdata->phy.lp_advertising);
 
-       cmd->autoneg = pdata->phy.autoneg;
-       ethtool_cmd_speed_set(cmd, pdata->phy.speed);
-       cmd->duplex = pdata->phy.duplex;
+       cmd->base.autoneg = pdata->phy.autoneg;
+       cmd->base.speed = pdata->phy.speed;
+       cmd->base.duplex = pdata->phy.duplex;
 
-       cmd->port = PORT_NONE;
-       cmd->transceiver = XCVR_INTERNAL;
+       cmd->base.port = PORT_NONE;
 
        return 0;
 }
 
-static int xgbe_set_settings(struct net_device *netdev,
-                            struct ethtool_cmd *cmd)
+static int xgbe_set_link_ksettings(struct net_device *netdev,
+                                  const struct ethtool_link_ksettings *cmd)
 {
        struct xgbe_prv_data *pdata = netdev_priv(netdev);
+       u32 advertising;
        u32 speed;
        int ret;
 
-       speed = ethtool_cmd_speed(cmd);
+       speed = cmd->base.speed;
 
-       if (cmd->phy_address != pdata->phy.address) {
+       if (cmd->base.phy_address != pdata->phy.address) {
                netdev_err(netdev, "invalid phy address %hhu\n",
-                          cmd->phy_address);
+                          cmd->base.phy_address);
                return -EINVAL;
        }
 
-       if ((cmd->autoneg != AUTONEG_ENABLE) &&
-           (cmd->autoneg != AUTONEG_DISABLE)) {
+       if ((cmd->base.autoneg != AUTONEG_ENABLE) &&
+           (cmd->base.autoneg != AUTONEG_DISABLE)) {
                netdev_err(netdev, "unsupported autoneg %hhu\n",
-                          cmd->autoneg);
+                          cmd->base.autoneg);
                return -EINVAL;
        }
 
-       if (cmd->autoneg == AUTONEG_DISABLE) {
+       if (cmd->base.autoneg == AUTONEG_DISABLE) {
                if (!pdata->phy_if.phy_valid_speed(pdata, speed)) {
                        netdev_err(netdev, "unsupported speed %u\n", speed);
                        return -EINVAL;
                }
 
-               if (cmd->duplex != DUPLEX_FULL) {
+               if (cmd->base.duplex != DUPLEX_FULL) {
                        netdev_err(netdev, "unsupported duplex %hhu\n",
-                                  cmd->duplex);
+                                  cmd->base.duplex);
                        return -EINVAL;
                }
        }
 
+       ethtool_convert_link_mode_to_legacy_u32(&advertising,
+                                               cmd->link_modes.advertising);
+
        netif_dbg(pdata, link, netdev,
                  "requested advertisement %#x, phy supported %#x\n",
-                 cmd->advertising, pdata->phy.supported);
+                 advertising, pdata->phy.supported);
 
-       cmd->advertising &= pdata->phy.supported;
-       if ((cmd->autoneg == AUTONEG_ENABLE) && !cmd->advertising) {
+       advertising &= pdata->phy.supported;
+       if ((cmd->base.autoneg == AUTONEG_ENABLE) && !advertising) {
                netdev_err(netdev,
                           "unsupported requested advertisement\n");
                return -EINVAL;
        }
 
        ret = 0;
-       pdata->phy.autoneg = cmd->autoneg;
+       pdata->phy.autoneg = cmd->base.autoneg;
        pdata->phy.speed = speed;
-       pdata->phy.duplex = cmd->duplex;
-       pdata->phy.advertising = cmd->advertising;
+       pdata->phy.duplex = cmd->base.duplex;
+       pdata->phy.advertising = advertising;
 
-       if (cmd->autoneg == AUTONEG_ENABLE)
+       if (cmd->base.autoneg == AUTONEG_ENABLE)
                pdata->phy.advertising |= ADVERTISED_Autoneg;
        else
                pdata->phy.advertising &= ~ADVERTISED_Autoneg;
@@ -585,8 +591,6 @@ static int xgbe_get_ts_info(struct net_device *netdev,
 }
 
 static const struct ethtool_ops xgbe_ethtool_ops = {
-       .get_settings = xgbe_get_settings,
-       .set_settings = xgbe_set_settings,
        .get_drvinfo = xgbe_get_drvinfo,
        .get_msglevel = xgbe_get_msglevel,
        .set_msglevel = xgbe_set_msglevel,
@@ -604,6 +608,8 @@ static const struct ethtool_ops xgbe_ethtool_ops = {
        .get_rxfh = xgbe_get_rxfh,
        .set_rxfh = xgbe_set_rxfh,
        .get_ts_info = xgbe_get_ts_info,
+       .get_link_ksettings = xgbe_get_link_ksettings,
+       .set_link_ksettings = xgbe_set_link_ksettings,
 };
 
 const struct ethtool_ops *xgbe_get_ethtool_ops(void)