Commit 1dae02b3 authored by Philippe Reynes's avatar Philippe Reynes Committed by David S. Miller

net: atheros: atl1: 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.

The previous implementation of set_settings was modifying
the value of advertising, but with the new API, it's not
possible. The structure ethtool_link_ksettings is defined
as const.
Signed-off-by: default avatarPhilippe Reynes <tremyfr@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 58046c70
...@@ -3214,66 +3214,72 @@ static int atl1_get_sset_count(struct net_device *netdev, int sset) ...@@ -3214,66 +3214,72 @@ static int atl1_get_sset_count(struct net_device *netdev, int sset)
} }
} }
static int atl1_get_settings(struct net_device *netdev, static int atl1_get_link_ksettings(struct net_device *netdev,
struct ethtool_cmd *ecmd) struct ethtool_link_ksettings *cmd)
{ {
struct atl1_adapter *adapter = netdev_priv(netdev); struct atl1_adapter *adapter = netdev_priv(netdev);
struct atl1_hw *hw = &adapter->hw; struct atl1_hw *hw = &adapter->hw;
u32 supported, advertising;
ecmd->supported = (SUPPORTED_10baseT_Half | supported = (SUPPORTED_10baseT_Half |
SUPPORTED_10baseT_Full | SUPPORTED_10baseT_Full |
SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Half |
SUPPORTED_100baseT_Full | SUPPORTED_100baseT_Full |
SUPPORTED_1000baseT_Full | SUPPORTED_1000baseT_Full |
SUPPORTED_Autoneg | SUPPORTED_TP); SUPPORTED_Autoneg | SUPPORTED_TP);
ecmd->advertising = ADVERTISED_TP; advertising = ADVERTISED_TP;
if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR || if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
hw->media_type == MEDIA_TYPE_1000M_FULL) { hw->media_type == MEDIA_TYPE_1000M_FULL) {
ecmd->advertising |= ADVERTISED_Autoneg; advertising |= ADVERTISED_Autoneg;
if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR) { if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR) {
ecmd->advertising |= ADVERTISED_Autoneg; advertising |= ADVERTISED_Autoneg;
ecmd->advertising |= advertising |=
(ADVERTISED_10baseT_Half | (ADVERTISED_10baseT_Half |
ADVERTISED_10baseT_Full | ADVERTISED_10baseT_Full |
ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Half |
ADVERTISED_100baseT_Full | ADVERTISED_100baseT_Full |
ADVERTISED_1000baseT_Full); ADVERTISED_1000baseT_Full);
} else } else
ecmd->advertising |= (ADVERTISED_1000baseT_Full); advertising |= (ADVERTISED_1000baseT_Full);
} }
ecmd->port = PORT_TP; cmd->base.port = PORT_TP;
ecmd->phy_address = 0; cmd->base.phy_address = 0;
ecmd->transceiver = XCVR_INTERNAL;
if (netif_carrier_ok(adapter->netdev)) { if (netif_carrier_ok(adapter->netdev)) {
u16 link_speed, link_duplex; u16 link_speed, link_duplex;
atl1_get_speed_and_duplex(hw, &link_speed, &link_duplex); atl1_get_speed_and_duplex(hw, &link_speed, &link_duplex);
ethtool_cmd_speed_set(ecmd, link_speed); cmd->base.speed = link_speed;
if (link_duplex == FULL_DUPLEX) if (link_duplex == FULL_DUPLEX)
ecmd->duplex = DUPLEX_FULL; cmd->base.duplex = DUPLEX_FULL;
else else
ecmd->duplex = DUPLEX_HALF; cmd->base.duplex = DUPLEX_HALF;
} else { } else {
ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN); cmd->base.speed = SPEED_UNKNOWN;
ecmd->duplex = DUPLEX_UNKNOWN; cmd->base.duplex = DUPLEX_UNKNOWN;
} }
if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR || if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
hw->media_type == MEDIA_TYPE_1000M_FULL) hw->media_type == MEDIA_TYPE_1000M_FULL)
ecmd->autoneg = AUTONEG_ENABLE; cmd->base.autoneg = AUTONEG_ENABLE;
else else
ecmd->autoneg = AUTONEG_DISABLE; cmd->base.autoneg = AUTONEG_DISABLE;
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
supported);
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
advertising);
return 0; return 0;
} }
static int atl1_set_settings(struct net_device *netdev, static int atl1_set_link_ksettings(struct net_device *netdev,
struct ethtool_cmd *ecmd) const struct ethtool_link_ksettings *cmd)
{ {
struct atl1_adapter *adapter = netdev_priv(netdev); struct atl1_adapter *adapter = netdev_priv(netdev);
struct atl1_hw *hw = &adapter->hw; struct atl1_hw *hw = &adapter->hw;
u16 phy_data; u16 phy_data;
int ret_val = 0; int ret_val = 0;
u16 old_media_type = hw->media_type; u16 old_media_type = hw->media_type;
u32 advertising;
if (netif_running(adapter->netdev)) { if (netif_running(adapter->netdev)) {
if (netif_msg_link(adapter)) if (netif_msg_link(adapter))
...@@ -3282,12 +3288,12 @@ static int atl1_set_settings(struct net_device *netdev, ...@@ -3282,12 +3288,12 @@ static int atl1_set_settings(struct net_device *netdev,
atl1_down(adapter); atl1_down(adapter);
} }
if (ecmd->autoneg == AUTONEG_ENABLE) if (cmd->base.autoneg == AUTONEG_ENABLE)
hw->media_type = MEDIA_TYPE_AUTO_SENSOR; hw->media_type = MEDIA_TYPE_AUTO_SENSOR;
else { else {
u32 speed = ethtool_cmd_speed(ecmd); u32 speed = cmd->base.speed;
if (speed == SPEED_1000) { if (speed == SPEED_1000) {
if (ecmd->duplex != DUPLEX_FULL) { if (cmd->base.duplex != DUPLEX_FULL) {
if (netif_msg_link(adapter)) if (netif_msg_link(adapter))
dev_warn(&adapter->pdev->dev, dev_warn(&adapter->pdev->dev,
"1000M half is invalid\n"); "1000M half is invalid\n");
...@@ -3296,12 +3302,12 @@ static int atl1_set_settings(struct net_device *netdev, ...@@ -3296,12 +3302,12 @@ static int atl1_set_settings(struct net_device *netdev,
} }
hw->media_type = MEDIA_TYPE_1000M_FULL; hw->media_type = MEDIA_TYPE_1000M_FULL;
} else if (speed == SPEED_100) { } else if (speed == SPEED_100) {
if (ecmd->duplex == DUPLEX_FULL) if (cmd->base.duplex == DUPLEX_FULL)
hw->media_type = MEDIA_TYPE_100M_FULL; hw->media_type = MEDIA_TYPE_100M_FULL;
else else
hw->media_type = MEDIA_TYPE_100M_HALF; hw->media_type = MEDIA_TYPE_100M_HALF;
} else { } else {
if (ecmd->duplex == DUPLEX_FULL) if (cmd->base.duplex == DUPLEX_FULL)
hw->media_type = MEDIA_TYPE_10M_FULL; hw->media_type = MEDIA_TYPE_10M_FULL;
else else
hw->media_type = MEDIA_TYPE_10M_HALF; hw->media_type = MEDIA_TYPE_10M_HALF;
...@@ -3309,7 +3315,7 @@ static int atl1_set_settings(struct net_device *netdev, ...@@ -3309,7 +3315,7 @@ static int atl1_set_settings(struct net_device *netdev,
} }
switch (hw->media_type) { switch (hw->media_type) {
case MEDIA_TYPE_AUTO_SENSOR: case MEDIA_TYPE_AUTO_SENSOR:
ecmd->advertising = advertising =
ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Half |
ADVERTISED_10baseT_Full | ADVERTISED_10baseT_Full |
ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Half |
...@@ -3318,12 +3324,12 @@ static int atl1_set_settings(struct net_device *netdev, ...@@ -3318,12 +3324,12 @@ static int atl1_set_settings(struct net_device *netdev,
ADVERTISED_Autoneg | ADVERTISED_TP; ADVERTISED_Autoneg | ADVERTISED_TP;
break; break;
case MEDIA_TYPE_1000M_FULL: case MEDIA_TYPE_1000M_FULL:
ecmd->advertising = advertising =
ADVERTISED_1000baseT_Full | ADVERTISED_1000baseT_Full |
ADVERTISED_Autoneg | ADVERTISED_TP; ADVERTISED_Autoneg | ADVERTISED_TP;
break; break;
default: default:
ecmd->advertising = 0; advertising = 0;
break; break;
} }
if (atl1_phy_setup_autoneg_adv(hw)) { if (atl1_phy_setup_autoneg_adv(hw)) {
...@@ -3663,8 +3669,6 @@ static int atl1_nway_reset(struct net_device *netdev) ...@@ -3663,8 +3669,6 @@ static int atl1_nway_reset(struct net_device *netdev)
} }
static const struct ethtool_ops atl1_ethtool_ops = { static const struct ethtool_ops atl1_ethtool_ops = {
.get_settings = atl1_get_settings,
.set_settings = atl1_set_settings,
.get_drvinfo = atl1_get_drvinfo, .get_drvinfo = atl1_get_drvinfo,
.get_wol = atl1_get_wol, .get_wol = atl1_get_wol,
.set_wol = atl1_set_wol, .set_wol = atl1_set_wol,
...@@ -3681,6 +3685,8 @@ static const struct ethtool_ops atl1_ethtool_ops = { ...@@ -3681,6 +3685,8 @@ static const struct ethtool_ops atl1_ethtool_ops = {
.nway_reset = atl1_nway_reset, .nway_reset = atl1_nway_reset,
.get_ethtool_stats = atl1_get_ethtool_stats, .get_ethtool_stats = atl1_get_ethtool_stats,
.get_sset_count = atl1_get_sset_count, .get_sset_count = atl1_get_sset_count,
.get_link_ksettings = atl1_get_link_ksettings,
.set_link_ksettings = atl1_set_link_ksettings,
}; };
module_pci_driver(atl1_driver); module_pci_driver(atl1_driver);
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