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

net: dlink: dl2k: 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 speed and duplex, 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 453e5f3d
...@@ -1256,52 +1256,63 @@ static void rio_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info ...@@ -1256,52 +1256,63 @@ static void rio_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
strlcpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info)); strlcpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info));
} }
static int rio_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) static int rio_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{ {
struct netdev_private *np = netdev_priv(dev); struct netdev_private *np = netdev_priv(dev);
u32 supported, advertising;
if (np->phy_media) { if (np->phy_media) {
/* fiber device */ /* fiber device */
cmd->supported = SUPPORTED_Autoneg | SUPPORTED_FIBRE; supported = SUPPORTED_Autoneg | SUPPORTED_FIBRE;
cmd->advertising= ADVERTISED_Autoneg | ADVERTISED_FIBRE; advertising = ADVERTISED_Autoneg | ADVERTISED_FIBRE;
cmd->port = PORT_FIBRE; cmd->base.port = PORT_FIBRE;
cmd->transceiver = XCVR_INTERNAL;
} else { } else {
/* copper device */ /* copper device */
cmd->supported = SUPPORTED_10baseT_Half | supported = SUPPORTED_10baseT_Half |
SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half
| SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Full | | SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Full |
SUPPORTED_Autoneg | SUPPORTED_MII; SUPPORTED_Autoneg | SUPPORTED_MII;
cmd->advertising = ADVERTISED_10baseT_Half | advertising = ADVERTISED_10baseT_Half |
ADVERTISED_10baseT_Full | ADVERTISED_100baseT_Half | ADVERTISED_10baseT_Full | ADVERTISED_100baseT_Half |
ADVERTISED_100baseT_Full | ADVERTISED_1000baseT_Full| ADVERTISED_100baseT_Full | ADVERTISED_1000baseT_Full |
ADVERTISED_Autoneg | ADVERTISED_MII; ADVERTISED_Autoneg | ADVERTISED_MII;
cmd->port = PORT_MII; cmd->base.port = PORT_MII;
cmd->transceiver = XCVR_INTERNAL;
} }
if ( np->link_status ) { if (np->link_status) {
ethtool_cmd_speed_set(cmd, np->speed); cmd->base.speed = np->speed;
cmd->duplex = np->full_duplex ? DUPLEX_FULL : DUPLEX_HALF; cmd->base.duplex = np->full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
} else { } else {
ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN); cmd->base.speed = SPEED_UNKNOWN;
cmd->duplex = DUPLEX_UNKNOWN; cmd->base.duplex = DUPLEX_UNKNOWN;
} }
if ( np->an_enable) if (np->an_enable)
cmd->autoneg = AUTONEG_ENABLE; cmd->base.autoneg = AUTONEG_ENABLE;
else else
cmd->autoneg = AUTONEG_DISABLE; cmd->base.autoneg = AUTONEG_DISABLE;
cmd->base.phy_address = np->phy_addr;
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
supported);
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
advertising);
cmd->phy_address = np->phy_addr;
return 0; return 0;
} }
static int rio_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) static int rio_set_link_ksettings(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{ {
struct netdev_private *np = netdev_priv(dev); struct netdev_private *np = netdev_priv(dev);
u32 speed = cmd->base.speed;
u8 duplex = cmd->base.duplex;
netif_carrier_off(dev); netif_carrier_off(dev);
if (cmd->autoneg == AUTONEG_ENABLE) { if (cmd->base.autoneg == AUTONEG_ENABLE) {
if (np->an_enable) if (np->an_enable) {
return 0; return 0;
else { } else {
np->an_enable = 1; np->an_enable = 1;
mii_set_media(dev); mii_set_media(dev);
return 0; return 0;
...@@ -1309,18 +1320,18 @@ static int rio_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) ...@@ -1309,18 +1320,18 @@ static int rio_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
} else { } else {
np->an_enable = 0; np->an_enable = 0;
if (np->speed == 1000) { if (np->speed == 1000) {
ethtool_cmd_speed_set(cmd, SPEED_100); speed = SPEED_100;
cmd->duplex = DUPLEX_FULL; duplex = DUPLEX_FULL;
printk("Warning!! Can't disable Auto negotiation in 1000Mbps, change to Manual 100Mbps, Full duplex.\n"); printk("Warning!! Can't disable Auto negotiation in 1000Mbps, change to Manual 100Mbps, Full duplex.\n");
} }
switch (ethtool_cmd_speed(cmd)) { switch (speed) {
case SPEED_10: case SPEED_10:
np->speed = 10; np->speed = 10;
np->full_duplex = (cmd->duplex == DUPLEX_FULL); np->full_duplex = (duplex == DUPLEX_FULL);
break; break;
case SPEED_100: case SPEED_100:
np->speed = 100; np->speed = 100;
np->full_duplex = (cmd->duplex == DUPLEX_FULL); np->full_duplex = (duplex == DUPLEX_FULL);
break; break;
case SPEED_1000: /* not supported */ case SPEED_1000: /* not supported */
default: default:
...@@ -1339,9 +1350,9 @@ static u32 rio_get_link(struct net_device *dev) ...@@ -1339,9 +1350,9 @@ static u32 rio_get_link(struct net_device *dev)
static const struct ethtool_ops ethtool_ops = { static const struct ethtool_ops ethtool_ops = {
.get_drvinfo = rio_get_drvinfo, .get_drvinfo = rio_get_drvinfo,
.get_settings = rio_get_settings,
.set_settings = rio_set_settings,
.get_link = rio_get_link, .get_link = rio_get_link,
.get_link_ksettings = rio_get_link_ksettings,
.set_link_ksettings = rio_set_link_ksettings,
}; };
static int static int
......
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