Skip to content

Commit

Permalink
net: ibm: ehea: use new api ethtool_{get|set}_link_ksettings
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Philippe Reynes authored and David S. Miller committed Jan 9, 2017
1 parent 1e91163 commit cecf62d
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions drivers/net/ethernet/ibm/ehea/ehea_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
#include "ehea.h"
#include "ehea_phyp.h"

static int ehea_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
static int ehea_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{
struct ehea_port *port = netdev_priv(dev);
u32 supported, advertising;
u32 speed;
int ret;

Expand All @@ -60,68 +62,75 @@ static int ehea_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
speed = -1;
break; /* BUG */
}
cmd->duplex = port->full_duplex == 1 ?
cmd->base.duplex = port->full_duplex == 1 ?
DUPLEX_FULL : DUPLEX_HALF;
} else {
speed = SPEED_UNKNOWN;
cmd->duplex = DUPLEX_UNKNOWN;
cmd->base.duplex = DUPLEX_UNKNOWN;
}
ethtool_cmd_speed_set(cmd, speed);
cmd->base.speed = speed;

if (cmd->speed == SPEED_10000) {
cmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
cmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE);
cmd->port = PORT_FIBRE;
if (cmd->base.speed == SPEED_10000) {
supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE);
cmd->base.port = PORT_FIBRE;
} else {
cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_100baseT_Full
supported = (SUPPORTED_1000baseT_Full | SUPPORTED_100baseT_Full
| SUPPORTED_100baseT_Half | SUPPORTED_10baseT_Full
| SUPPORTED_10baseT_Half | SUPPORTED_Autoneg
| SUPPORTED_TP);
cmd->advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg
advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg
| ADVERTISED_TP);
cmd->port = PORT_TP;
cmd->base.port = PORT_TP;
}

cmd->autoneg = port->autoneg == 1 ? AUTONEG_ENABLE : AUTONEG_DISABLE;
cmd->base.autoneg = port->autoneg == 1 ?
AUTONEG_ENABLE : 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;
}

static int ehea_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
static int ehea_set_link_ksettings(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{
struct ehea_port *port = netdev_priv(dev);
int ret = 0;
u32 sp;

if (cmd->autoneg == AUTONEG_ENABLE) {
if (cmd->base.autoneg == AUTONEG_ENABLE) {
sp = EHEA_SPEED_AUTONEG;
goto doit;
}

switch (cmd->speed) {
switch (cmd->base.speed) {
case SPEED_10:
if (cmd->duplex == DUPLEX_FULL)
if (cmd->base.duplex == DUPLEX_FULL)
sp = H_SPEED_10M_F;
else
sp = H_SPEED_10M_H;
break;

case SPEED_100:
if (cmd->duplex == DUPLEX_FULL)
if (cmd->base.duplex == DUPLEX_FULL)
sp = H_SPEED_100M_F;
else
sp = H_SPEED_100M_H;
break;

case SPEED_1000:
if (cmd->duplex == DUPLEX_FULL)
if (cmd->base.duplex == DUPLEX_FULL)
sp = H_SPEED_1G_F;
else
ret = -EINVAL;
break;

case SPEED_10000:
if (cmd->duplex == DUPLEX_FULL)
if (cmd->base.duplex == DUPLEX_FULL)
sp = H_SPEED_10G_F;
else
ret = -EINVAL;
Expand Down Expand Up @@ -264,16 +273,16 @@ static void ehea_get_ethtool_stats(struct net_device *dev,
}

static const struct ethtool_ops ehea_ethtool_ops = {
.get_settings = ehea_get_settings,
.get_drvinfo = ehea_get_drvinfo,
.get_msglevel = ehea_get_msglevel,
.set_msglevel = ehea_set_msglevel,
.get_link = ethtool_op_get_link,
.get_strings = ehea_get_strings,
.get_sset_count = ehea_get_sset_count,
.get_ethtool_stats = ehea_get_ethtool_stats,
.set_settings = ehea_set_settings,
.nway_reset = ehea_nway_reset, /* Restart autonegotiation */
.get_link_ksettings = ehea_get_link_ksettings,
.set_link_ksettings = ehea_set_link_ksettings,
};

void ehea_set_ethtool_ops(struct net_device *netdev)
Expand Down

0 comments on commit cecf62d

Please sign in to comment.