git: 04a5e6d7cadd - main - ixgbe(4): Filter out spurious link up indication

From: Eric Joyner <erj_at_FreeBSD.org>
Date: Wed, 15 Feb 2023 22:41:21 UTC
The branch main has been updated by erj:

URL: https://cgit.FreeBSD.org/src/commit/?id=04a5e6d7cadd06b10169c3c3a560649e7dc7444c

commit 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Author:     Krzysztof Galazka <krzysztof.galazka@intel.com>
AuthorDate: 2023-02-15 22:35:40 +0000
Commit:     Eric Joyner <erj@FreeBSD.org>
CommitDate: 2023-02-15 22:38:05 +0000

    ixgbe(4): Filter out spurious link up indication
    
    Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
    to filter out spurious link up indication by transceiver with no fiber
    cable connected.
    
    Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
    Signed-off-by: Eric Joyner <erj@FreeBSD.org>
    
    Reviewed by:    erj@
    Tested by:      Gowtham Kumar Ks <gowtham.kumar.ks@intel.com>
    MFC after:      3 days
    Sponsored by:   Intel Corporation
    Differential Revision:  https://reviews.freebsd.org/D38395
---
 sys/dev/ixgbe/ixgbe_common.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/sys/dev/ixgbe/ixgbe_common.c b/sys/dev/ixgbe/ixgbe_common.c
index 3f38f5e27123..86301dab80ed 100644
--- a/sys/dev/ixgbe/ixgbe_common.c
+++ b/sys/dev/ixgbe/ixgbe_common.c
@@ -4232,10 +4232,25 @@ 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 (ixgbe_need_crosstalk_fix(hw)) {
+				/* Check the link state again after a delay
+				 * to filter out spurious link up
+				 * notifications.
+				 */
+				msec_delay(5);
+				links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
+				if (!(links_reg & IXGBE_LINKS_UP)) {
+					*link_up = false;
+					*speed = IXGBE_LINK_SPEED_UNKNOWN;
+					return IXGBE_SUCCESS;
+				}
+
+			}
 			*link_up = true;
-		else
+		} else {
 			*link_up = false;
+		}
 	}
 
 	switch (links_reg & IXGBE_LINKS_SPEED_82599) {