net: use ethtool_cmd_speed_set helper to set ethtool speed value

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jiri Pirko 2014-06-06 14:17:01 +02:00 committed by David S. Miller
parent 537fae0101
commit d4f3cd49d2
3 changed files with 18 additions and 14 deletions

View File

@ -141,6 +141,7 @@ static int igb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575; struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
struct e1000_sfp_flags *eth_flags = &dev_spec->eth_flags; struct e1000_sfp_flags *eth_flags = &dev_spec->eth_flags;
u32 status; u32 status;
u32 speed;
status = rd32(E1000_STATUS); status = rd32(E1000_STATUS);
if (hw->phy.media_type == e1000_media_type_copper) { if (hw->phy.media_type == e1000_media_type_copper) {
@ -215,13 +216,13 @@ static int igb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
if (status & E1000_STATUS_LU) { if (status & E1000_STATUS_LU) {
if ((status & E1000_STATUS_2P5_SKU) && if ((status & E1000_STATUS_2P5_SKU) &&
!(status & E1000_STATUS_2P5_SKU_OVER)) { !(status & E1000_STATUS_2P5_SKU_OVER)) {
ecmd->speed = SPEED_2500; speed = SPEED_2500;
} else if (status & E1000_STATUS_SPEED_1000) { } else if (status & E1000_STATUS_SPEED_1000) {
ecmd->speed = SPEED_1000; speed = SPEED_1000;
} else if (status & E1000_STATUS_SPEED_100) { } else if (status & E1000_STATUS_SPEED_100) {
ecmd->speed = SPEED_100; speed = SPEED_100;
} else { } else {
ecmd->speed = SPEED_10; speed = SPEED_10;
} }
if ((status & E1000_STATUS_FD) || if ((status & E1000_STATUS_FD) ||
hw->phy.media_type != e1000_media_type_copper) hw->phy.media_type != e1000_media_type_copper)
@ -229,9 +230,10 @@ static int igb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
else else
ecmd->duplex = DUPLEX_HALF; ecmd->duplex = DUPLEX_HALF;
} else { } else {
ecmd->speed = SPEED_UNKNOWN; speed = SPEED_UNKNOWN;
ecmd->duplex = DUPLEX_UNKNOWN; ecmd->duplex = DUPLEX_UNKNOWN;
} }
ethtool_cmd_speed_set(ecmd, speed);
if ((hw->phy.media_type == e1000_media_type_fiber) || if ((hw->phy.media_type == e1000_media_type_fiber) ||
hw->mac.autoneg) hw->mac.autoneg)
ecmd->autoneg = AUTONEG_ENABLE; ecmd->autoneg = AUTONEG_ENABLE;

View File

@ -298,7 +298,6 @@ static int ntb_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{ {
cmd->supported = SUPPORTED_Backplane; cmd->supported = SUPPORTED_Backplane;
cmd->advertising = ADVERTISED_Backplane; cmd->advertising = ADVERTISED_Backplane;
cmd->speed = SPEED_UNKNOWN;
ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN); ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN);
cmd->duplex = DUPLEX_FULL; cmd->duplex = DUPLEX_FULL;
cmd->port = PORT_OTHER; cmd->port = PORT_OTHER;

View File

@ -5726,6 +5726,7 @@ int qeth_core_ethtool_get_settings(struct net_device *netdev,
struct qeth_card *card = netdev->ml_priv; struct qeth_card *card = netdev->ml_priv;
enum qeth_link_types link_type; enum qeth_link_types link_type;
struct carrier_info carrier_info; struct carrier_info carrier_info;
u32 speed;
if ((card->info.type == QETH_CARD_TYPE_IQD) || (card->info.guestlan)) if ((card->info.type == QETH_CARD_TYPE_IQD) || (card->info.guestlan))
link_type = QETH_LINK_TYPE_10GBIT_ETH; link_type = QETH_LINK_TYPE_10GBIT_ETH;
@ -5740,28 +5741,29 @@ int qeth_core_ethtool_get_settings(struct net_device *netdev,
case QETH_LINK_TYPE_FAST_ETH: case QETH_LINK_TYPE_FAST_ETH:
case QETH_LINK_TYPE_LANE_ETH100: case QETH_LINK_TYPE_LANE_ETH100:
qeth_set_ecmd_adv_sup(ecmd, SPEED_100, PORT_TP); qeth_set_ecmd_adv_sup(ecmd, SPEED_100, PORT_TP);
ecmd->speed = SPEED_100; speed = SPEED_100;
ecmd->port = PORT_TP; ecmd->port = PORT_TP;
break; break;
case QETH_LINK_TYPE_GBIT_ETH: case QETH_LINK_TYPE_GBIT_ETH:
case QETH_LINK_TYPE_LANE_ETH1000: case QETH_LINK_TYPE_LANE_ETH1000:
qeth_set_ecmd_adv_sup(ecmd, SPEED_1000, PORT_FIBRE); qeth_set_ecmd_adv_sup(ecmd, SPEED_1000, PORT_FIBRE);
ecmd->speed = SPEED_1000; speed = SPEED_1000;
ecmd->port = PORT_FIBRE; ecmd->port = PORT_FIBRE;
break; break;
case QETH_LINK_TYPE_10GBIT_ETH: case QETH_LINK_TYPE_10GBIT_ETH:
qeth_set_ecmd_adv_sup(ecmd, SPEED_10000, PORT_FIBRE); qeth_set_ecmd_adv_sup(ecmd, SPEED_10000, PORT_FIBRE);
ecmd->speed = SPEED_10000; speed = SPEED_10000;
ecmd->port = PORT_FIBRE; ecmd->port = PORT_FIBRE;
break; break;
default: default:
qeth_set_ecmd_adv_sup(ecmd, SPEED_10, PORT_TP); qeth_set_ecmd_adv_sup(ecmd, SPEED_10, PORT_TP);
ecmd->speed = SPEED_10; speed = SPEED_10;
ecmd->port = PORT_TP; ecmd->port = PORT_TP;
} }
ethtool_cmd_speed_set(ecmd, speed);
/* Check if we can obtain more accurate information. */ /* Check if we can obtain more accurate information. */
/* If QUERY_CARD_INFO command is not supported or fails, */ /* If QUERY_CARD_INFO command is not supported or fails, */
@ -5806,18 +5808,19 @@ int qeth_core_ethtool_get_settings(struct net_device *netdev,
switch (carrier_info.port_speed) { switch (carrier_info.port_speed) {
case CARD_INFO_PORTS_10M: case CARD_INFO_PORTS_10M:
ecmd->speed = SPEED_10; speed = SPEED_10;
break; break;
case CARD_INFO_PORTS_100M: case CARD_INFO_PORTS_100M:
ecmd->speed = SPEED_100; speed = SPEED_100;
break; break;
case CARD_INFO_PORTS_1G: case CARD_INFO_PORTS_1G:
ecmd->speed = SPEED_1000; speed = SPEED_1000;
break; break;
case CARD_INFO_PORTS_10G: case CARD_INFO_PORTS_10G:
ecmd->speed = SPEED_10000; speed = SPEED_10000;
break; break;
} }
ethtool_cmd_speed_set(ecmd, speed);
return 0; return 0;
} }