]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
bnxt_en: Enhance autoneg support.
authorMichael Chan <michael.chan@broadcom.com>
Thu, 17 Nov 2016 02:13:08 +0000 (21:13 -0500)
committerDavid S. Miller <davem@davemloft.net>
Thu, 17 Nov 2016 04:11:07 +0000 (23:11 -0500)
On some dual port NICs, the speed setting on one port can affect the
available speed on the other port.  Add logic to detect these changes
and adjust the advertised speed settings when necessary.

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

index 13325775e160bf79d5793e7069953c90de6c02e8..4db50e831524447ab47fd73227f2614fe6b96f2b 100644 (file)
@@ -1499,6 +1499,7 @@ static int bnxt_async_event_process(struct bnxt *bp,
                        netdev_warn(bp->dev, "Link speed %d no longer supported\n",
                                    speed);
                }
+               set_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT, &bp->sp_event);
                /* fall thru */
        }
        case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE:
@@ -5095,6 +5096,7 @@ static int bnxt_update_link(struct bnxt *bp, bool chng_link_state)
        struct hwrm_port_phy_qcfg_input req = {0};
        struct hwrm_port_phy_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
        u8 link_up = link_info->link_up;
+       u16 diff;
 
        bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_QCFG, -1, -1);
 
@@ -5182,6 +5184,23 @@ static int bnxt_update_link(struct bnxt *bp, bool chng_link_state)
                link_info->link_up = 0;
        }
        mutex_unlock(&bp->hwrm_cmd_lock);
+
+       diff = link_info->support_auto_speeds ^ link_info->advertising;
+       if ((link_info->support_auto_speeds | diff) !=
+           link_info->support_auto_speeds) {
+               /* An advertised speed is no longer supported, so we need to
+                * update the advertisement settings.  See bnxt_reset() for
+                * comments about the rtnl_lock() sequence below.
+                */
+               clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
+               rtnl_lock();
+               link_info->advertising = link_info->support_auto_speeds;
+               if (test_bit(BNXT_STATE_OPEN, &bp->state) &&
+                   (link_info->autoneg & BNXT_AUTONEG_SPEED))
+                       bnxt_hwrm_set_link_setting(bp, true, false);
+               set_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
+               rtnl_unlock();
+       }
        return 0;
 }
 
@@ -6108,6 +6127,10 @@ static void bnxt_sp_task(struct work_struct *work)
        if (test_and_clear_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event))
                bnxt_cfg_ntp_filters(bp);
        if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) {
+               if (test_and_clear_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT,
+                                      &bp->sp_event))
+                       bnxt_hwrm_phy_qcaps(bp);
+
                rc = bnxt_update_link(bp, true);
                if (rc)
                        netdev_err(bp->dev, "SP task can't update link (rc: %x)\n",
index 51b164a0e8442200c55bd4dd9a54034c27bbb9fc..666bc0608ed7d2f3539e503fabb8dbc825796afd 100644 (file)
@@ -1089,6 +1089,7 @@ struct bnxt {
 #define BNXT_RESET_TASK_SILENT_SP_EVENT        11
 #define BNXT_GENEVE_ADD_PORT_SP_EVENT  12
 #define BNXT_GENEVE_DEL_PORT_SP_EVENT  13
+#define BNXT_LINK_SPEED_CHNG_SP_EVENT  14
 
        struct bnxt_pf_info     pf;
 #ifdef CONFIG_BNXT_SRIOV