bnxt_en: Improve ethtool .get_settings().
authorMichael Chan <michael.chan@broadcom.com>
Tue, 5 Apr 2016 18:09:03 +0000 (14:09 -0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 5 Apr 2016 20:20:48 +0000 (16:20 -0400)
If autoneg is off, we should always report the speed and duplex settings
even if it is link down so the user knows the current settings.  The
unknown speed and duplex should only be used for autoneg when link is
down.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

index 952b5ba1c4da7846a405818155934629f0fa5337..a2e93241b06bde7be3b87100bba4ff7866dbab8d 100644 (file)
@@ -698,10 +698,23 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                if (link_info->phy_link_status == BNXT_LINK_LINK)
                        cmd->lp_advertising =
                                bnxt_fw_to_ethtool_lp_adv(link_info);
+               ethtool_speed = bnxt_fw_to_ethtool_speed(link_info->link_speed);
+               if (!netif_carrier_ok(dev))
+                       cmd->duplex = DUPLEX_UNKNOWN;
+               else if (link_info->duplex & BNXT_LINK_DUPLEX_FULL)
+                       cmd->duplex = DUPLEX_FULL;
+               else
+                       cmd->duplex = DUPLEX_HALF;
        } else {
                cmd->autoneg = AUTONEG_DISABLE;
                cmd->advertising = 0;
+               ethtool_speed =
+                       bnxt_fw_to_ethtool_speed(link_info->req_link_speed);
+               cmd->duplex = DUPLEX_HALF;
+               if (link_info->req_duplex == BNXT_LINK_DUPLEX_FULL)
+                       cmd->duplex = DUPLEX_FULL;
        }
+       ethtool_cmd_speed_set(cmd, ethtool_speed);
 
        cmd->port = PORT_NONE;
        if (link_info->media_type == PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP) {
@@ -719,14 +732,6 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                        cmd->port = PORT_FIBRE;
        }
 
-       if (link_info->phy_link_status == BNXT_LINK_LINK) {
-               if (link_info->duplex & BNXT_LINK_DUPLEX_FULL)
-                       cmd->duplex = DUPLEX_FULL;
-       } else {
-               cmd->duplex = DUPLEX_UNKNOWN;
-       }
-       ethtool_speed = bnxt_fw_to_ethtool_speed(link_info->link_speed);
-       ethtool_cmd_speed_set(cmd, ethtool_speed);
        if (link_info->transceiver ==
            PORT_PHY_QCFG_RESP_XCVR_PKG_TYPE_XCVR_INTERNAL)
                cmd->transceiver = XCVR_INTERNAL;