Commit 90fdd04e authored by Philippe Reynes's avatar Philippe Reynes Committed by David S. Miller

net: xgbe: 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.
Signed-off-by: default avatarPhilippe Reynes <tremyfr@gmail.com>
Acked-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ea74df81
...@@ -272,80 +272,86 @@ static int xgbe_set_pauseparam(struct net_device *netdev, ...@@ -272,80 +272,86 @@ static int xgbe_set_pauseparam(struct net_device *netdev,
return ret; return ret;
} }
static int xgbe_get_settings(struct net_device *netdev, static int xgbe_get_link_ksettings(struct net_device *netdev,
struct ethtool_cmd *cmd) struct ethtool_link_ksettings *cmd)
{ {
struct xgbe_prv_data *pdata = netdev_priv(netdev); 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; ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
cmd->advertising = pdata->phy.advertising; pdata->phy.supported);
cmd->lp_advertising = pdata->phy.lp_advertising; 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; cmd->base.autoneg = pdata->phy.autoneg;
ethtool_cmd_speed_set(cmd, pdata->phy.speed); cmd->base.speed = pdata->phy.speed;
cmd->duplex = pdata->phy.duplex; cmd->base.duplex = pdata->phy.duplex;
cmd->port = PORT_NONE; cmd->base.port = PORT_NONE;
cmd->transceiver = XCVR_INTERNAL;
return 0; return 0;
} }
static int xgbe_set_settings(struct net_device *netdev, static int xgbe_set_link_ksettings(struct net_device *netdev,
struct ethtool_cmd *cmd) const struct ethtool_link_ksettings *cmd)
{ {
struct xgbe_prv_data *pdata = netdev_priv(netdev); struct xgbe_prv_data *pdata = netdev_priv(netdev);
u32 advertising;
u32 speed; u32 speed;
int ret; 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", netdev_err(netdev, "invalid phy address %hhu\n",
cmd->phy_address); cmd->base.phy_address);
return -EINVAL; return -EINVAL;
} }
if ((cmd->autoneg != AUTONEG_ENABLE) && if ((cmd->base.autoneg != AUTONEG_ENABLE) &&
(cmd->autoneg != AUTONEG_DISABLE)) { (cmd->base.autoneg != AUTONEG_DISABLE)) {
netdev_err(netdev, "unsupported autoneg %hhu\n", netdev_err(netdev, "unsupported autoneg %hhu\n",
cmd->autoneg); cmd->base.autoneg);
return -EINVAL; return -EINVAL;
} }
if (cmd->autoneg == AUTONEG_DISABLE) { if (cmd->base.autoneg == AUTONEG_DISABLE) {
if (!pdata->phy_if.phy_valid_speed(pdata, speed)) { if (!pdata->phy_if.phy_valid_speed(pdata, speed)) {
netdev_err(netdev, "unsupported speed %u\n", speed); netdev_err(netdev, "unsupported speed %u\n", speed);
return -EINVAL; return -EINVAL;
} }
if (cmd->duplex != DUPLEX_FULL) { if (cmd->base.duplex != DUPLEX_FULL) {
netdev_err(netdev, "unsupported duplex %hhu\n", netdev_err(netdev, "unsupported duplex %hhu\n",
cmd->duplex); cmd->base.duplex);
return -EINVAL; return -EINVAL;
} }
} }
ethtool_convert_link_mode_to_legacy_u32(&advertising,
cmd->link_modes.advertising);
netif_dbg(pdata, link, netdev, netif_dbg(pdata, link, netdev,
"requested advertisement %#x, phy supported %#x\n", "requested advertisement %#x, phy supported %#x\n",
cmd->advertising, pdata->phy.supported); advertising, pdata->phy.supported);
cmd->advertising &= pdata->phy.supported; advertising &= pdata->phy.supported;
if ((cmd->autoneg == AUTONEG_ENABLE) && !cmd->advertising) { if ((cmd->base.autoneg == AUTONEG_ENABLE) && !advertising) {
netdev_err(netdev, netdev_err(netdev,
"unsupported requested advertisement\n"); "unsupported requested advertisement\n");
return -EINVAL; return -EINVAL;
} }
ret = 0; ret = 0;
pdata->phy.autoneg = cmd->autoneg; pdata->phy.autoneg = cmd->base.autoneg;
pdata->phy.speed = speed; pdata->phy.speed = speed;
pdata->phy.duplex = cmd->duplex; pdata->phy.duplex = cmd->base.duplex;
pdata->phy.advertising = cmd->advertising; pdata->phy.advertising = advertising;
if (cmd->autoneg == AUTONEG_ENABLE) if (cmd->base.autoneg == AUTONEG_ENABLE)
pdata->phy.advertising |= ADVERTISED_Autoneg; pdata->phy.advertising |= ADVERTISED_Autoneg;
else else
pdata->phy.advertising &= ~ADVERTISED_Autoneg; pdata->phy.advertising &= ~ADVERTISED_Autoneg;
...@@ -585,8 +591,6 @@ static int xgbe_get_ts_info(struct net_device *netdev, ...@@ -585,8 +591,6 @@ static int xgbe_get_ts_info(struct net_device *netdev,
} }
static const struct ethtool_ops xgbe_ethtool_ops = { static const struct ethtool_ops xgbe_ethtool_ops = {
.get_settings = xgbe_get_settings,
.set_settings = xgbe_set_settings,
.get_drvinfo = xgbe_get_drvinfo, .get_drvinfo = xgbe_get_drvinfo,
.get_msglevel = xgbe_get_msglevel, .get_msglevel = xgbe_get_msglevel,
.set_msglevel = xgbe_set_msglevel, .set_msglevel = xgbe_set_msglevel,
...@@ -604,6 +608,8 @@ static const struct ethtool_ops xgbe_ethtool_ops = { ...@@ -604,6 +608,8 @@ static const struct ethtool_ops xgbe_ethtool_ops = {
.get_rxfh = xgbe_get_rxfh, .get_rxfh = xgbe_get_rxfh,
.set_rxfh = xgbe_set_rxfh, .set_rxfh = xgbe_set_rxfh,
.get_ts_info = xgbe_get_ts_info, .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) const struct ethtool_ops *xgbe_get_ethtool_ops(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment