ixgbe: Filter out spurious link up indication
authorSebastian Czapla <sebastianx.czapla@intel.com>
Mon, 12 Dec 2022 09:59:38 +0000 (10:59 +0100)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Fri, 13 Jan 2023 17:42:15 +0000 (09:42 -0800)
Add delayed link state recheck to filter false link up indication
caused by transceiver with no fiber cable attached.

Signed-off-by: Sebastian Czapla <sebastianx.czapla@intel.com>
Tested-by: Sunitha Mekala <sunithax.d.mekala@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ixgbe/ixgbe_common.c

index 38c4609..878dd8d 100644 (file)
@@ -3292,13 +3292,14 @@ static bool ixgbe_need_crosstalk_fix(struct ixgbe_hw *hw)
 s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
                                 bool *link_up, bool link_up_wait_to_complete)
 {
+       bool crosstalk_fix_active = ixgbe_need_crosstalk_fix(hw);
        u32 links_reg, links_orig;
        u32 i;
 
        /* If Crosstalk fix enabled do the sanity check of making sure
         * the SFP+ cage is full.
         */
-       if (ixgbe_need_crosstalk_fix(hw)) {
+       if (crosstalk_fix_active) {
                u32 sfp_cage_full;
 
                switch (hw->mac.type) {
@@ -3346,10 +3347,24 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
                        links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
                }
        } else {
-               if (links_reg & IXGBE_LINKS_UP)
+               if (links_reg & IXGBE_LINKS_UP) {
+                       if (crosstalk_fix_active) {
+                               /* Check the link state again after a delay
+                                * to filter out spurious link up
+                                * notifications.
+                                */
+                               mdelay(5);
+                               links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
+                               if (!(links_reg & IXGBE_LINKS_UP)) {
+                                       *link_up = false;
+                                       *speed = IXGBE_LINK_SPEED_UNKNOWN;
+                                       return 0;
+                               }
+                       }
                        *link_up = true;
-               else
+               } else {
                        *link_up = false;
+               }
        }
 
        switch (links_reg & IXGBE_LINKS_SPEED_82599) {