]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bnxt_en: Don't allow autoneg on cards that don't support it.
authorMichael Chan <michael.chan@broadcom.com>
Mon, 13 Jun 2016 06:25:37 +0000 (02:25 -0400)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 7 Jul 2016 00:37:32 +0000 (17:37 -0700)
Orabug: 23221795

Some cards do not support autoneg.  The current code does not prevent the
user from enabling autoneg with ethtool on such cards, causing confusion.
Firmware provides the autoneg capability information and we just need to
store it in the support_auto_speeds field in bnxt_link_info struct.
The ethtool set_settings() call will check this field before proceeding
with autoneg.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 93ed8117336485af2cedb069d28f3d4270fb90a1)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

index 63bf51583c0f90241760dd595026c00b4b50511a..bb94d6c92c00c43317f87e9bd40d19667abcabba 100644 (file)
@@ -4842,6 +4842,7 @@ static int bnxt_hwrm_phy_qcaps(struct bnxt *bp)
        int rc = 0;
        struct hwrm_port_phy_qcaps_input req = {0};
        struct hwrm_port_phy_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
+       struct bnxt_link_info *link_info = &bp->link_info;
 
        if (bp->hwrm_spec_code < 0x10201)
                return 0;
@@ -4864,6 +4865,8 @@ static int bnxt_hwrm_phy_qcaps(struct bnxt *bp)
                bp->lpi_tmr_hi = le32_to_cpu(resp->valid_tx_lpi_timer_high) &
                                 PORT_PHY_QCAPS_RESP_TX_LPI_TIMER_HIGH_MASK;
        }
+       link_info->support_auto_speeds =
+               le16_to_cpu(resp->supported_speeds_auto_mode);
 
 hwrm_phy_qcaps_exit:
        mutex_unlock(&bp->hwrm_cmd_lock);
@@ -6426,6 +6429,12 @@ static int bnxt_probe_phy(struct bnxt *bp)
                return rc;
        }
 
+       /* Older firmware does not have supported_auto_speeds, so assume
+        * that all supported speeds can be autonegotiated.
+        */
+       if (link_info->auto_link_speeds && !link_info->support_auto_speeds)
+               link_info->support_auto_speeds = link_info->support_speeds;
+
        /*initialize the ethool setting copy with NVM settings */
        if (BNXT_AUTO_MODE(link_info->auto_mode)) {
                link_info->autoneg = BNXT_AUTONEG_SPEED;
index c1b41fb216dc9ee8530759e29ba18cf1b2d3c8ed..04cc69bb9e6a5d65e0726aa0187a259787bcb237 100644 (file)
@@ -849,6 +849,7 @@ struct bnxt_link_info {
 #define BNXT_LINK_SPEED_MSK_25GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_25GB
 #define BNXT_LINK_SPEED_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_40GB
 #define BNXT_LINK_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_50GB
+       u16                     support_auto_speeds;
        u16                     lp_auto_link_speeds;
        u16                     force_link_speed;
        u32                     preemphasis;
index 0fe8a47df755f6f8ff47de73cbc271e6fa209b01..872890277e43371bd49f0c9d498a8f545d75a3b7 100644 (file)
@@ -686,6 +686,17 @@ static u32 bnxt_fw_to_ethtool_support_spds(struct bnxt_link_info *link_info)
        return supported | SUPPORTED_Pause | SUPPORTED_Asym_Pause;
 }
 
+static u32 bnxt_fw_to_ethtool_support_adv_spds(struct bnxt_link_info *link_info)
+{
+       u16 fw_speeds = link_info->support_auto_speeds;
+       u32 supported;
+
+       supported = _bnxt_fw_to_ethtool_adv_spds(fw_speeds, 0);
+       if (supported)
+               supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
+       return supported;
+}
+
 u32 bnxt_fw_to_ethtool_speed(u16 fw_link_speed)
 {
        switch (fw_link_speed) {
@@ -718,7 +729,7 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 
        cmd->supported = bnxt_fw_to_ethtool_support_spds(link_info);
 
-       if (link_info->auto_link_speeds)
+       if (link_info->support_auto_speeds)
                cmd->supported |= SUPPORTED_Autoneg;
 
        if (link_info->autoneg) {
@@ -854,8 +865,14 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                return rc;
 
        if (cmd->autoneg == AUTONEG_ENABLE) {
-               u32 supported_spds = bnxt_fw_to_ethtool_support_spds(link_info);
+               u32 supported_spds =
+                       bnxt_fw_to_ethtool_support_adv_spds(link_info);
 
+               if (!supported_spds) {
+                       netdev_err(dev, "Autoneg not supported\n");
+                       rc = -EINVAL;
+                       goto set_setting_exit;
+               }
                if (cmd->advertising & ~(supported_spds | ADVERTISED_Autoneg |
                                         ADVERTISED_TP | ADVERTISED_FIBRE)) {
                        netdev_err(dev, "Unsupported advertising mask (adv: 0x%x)\n",
@@ -864,15 +881,9 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                        goto set_setting_exit;
                }
                fw_advertising = bnxt_get_fw_auto_link_speeds(cmd->advertising);
-               if (fw_advertising & ~link_info->support_speeds) {
-                       netdev_err(dev, "Advertising parameters are not supported! (adv: 0x%x)\n",
-                                  cmd->advertising);
-                       rc = -EINVAL;
-                       goto set_setting_exit;
-               }
                link_info->autoneg |= BNXT_AUTONEG_SPEED;
                if (!fw_advertising)
-                       link_info->advertising = link_info->support_speeds;
+                       link_info->advertising = link_info->support_auto_speeds;
                else
                        link_info->advertising = fw_advertising;
                /* any change to autoneg will cause link change, therefore the