git: c66d2795bdb5 - stable/14 - e1000: Improve igb(4) SFP support

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Thu, 21 Nov 2024 05:52:08 UTC
The branch stable/14 has been updated by kbowling:

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

commit c66d2795bdb5368045fd2f946038d5196b0f8817
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2024-11-07 06:02:10 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2024-11-21 05:51:50 +0000

    e1000: Improve igb(4) SFP support
    
    * Adds support for SFPs that are not correctly coded as an SFP
      transceiver. i.e. Coherent-Finisar FCLF8522P2BTL.
    * Configures multi-rate SFPs i.e. Coherent-Finisar FCLF8522P2BTL as
      SGMII so they can do 10/100/1000 auto-negotiation.
    * Adds support for 100BaseLX SGMII transceivers.
    * Some code cleanup and additional debugging.
    
    Reviewed by:    emaste, markj, Franco Fichtner <franco@opnsense.org>
    Tested by:      Natalino Picone <natalino.picone@nozominetworks.com>
    Sponsored by:   Nozomi Networks
    Sponsored by:   BBOX.io
    Differential Revision:  https://reviews.freebsd.org/D47337
    
    (cherry picked from commit 15853a5fc9548d9805a2ef22f24e2eb580198341)
---
 sys/dev/e1000/e1000_82575.c | 40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/sys/dev/e1000/e1000_82575.c b/sys/dev/e1000/e1000_82575.c
index a33aa9eb2903..47b8006314f8 100644
--- a/sys/dev/e1000/e1000_82575.c
+++ b/sys/dev/e1000/e1000_82575.c
@@ -1686,20 +1686,19 @@ static s32 e1000_get_media_type_82575(struct e1000_hw *hw)
 			break;
 		}
 
-		/* do not change link mode for 100BaseFX */
-		if (dev_spec->eth_flags.e100_base_fx)
-			break;
-
 		/* change current link mode setting */
 		ctrl_ext &= ~E1000_CTRL_EXT_LINK_MODE_MASK;
 
-		if (hw->phy.media_type == e1000_media_type_copper)
+		if (dev_spec->sgmii_active)
 			ctrl_ext |= E1000_CTRL_EXT_LINK_MODE_SGMII;
 		else
 			ctrl_ext |= E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES;
 
 		E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
 
+		break;
+	default:
+		DEBUGOUT("e1000_get_media_type_82575 unknown link type\n");
 		break;
 	}
 
@@ -1750,24 +1749,27 @@ static s32 e1000_set_sfp_media_type_82575(struct e1000_hw *hw)
 
 	/* Check if there is some SFP module plugged and powered */
 	if ((tranceiver_type == E1000_SFF_IDENTIFIER_SFP) ||
-	    (tranceiver_type == E1000_SFF_IDENTIFIER_SFF)) {
+	    (tranceiver_type == E1000_SFF_IDENTIFIER_SFF))
 		dev_spec->module_plugged = true;
-		if (eth_flags->e1000_base_lx || eth_flags->e1000_base_sx) {
-			hw->phy.media_type = e1000_media_type_internal_serdes;
-		} else if (eth_flags->e100_base_fx) {
-			dev_spec->sgmii_active = true;
-			hw->phy.media_type = e1000_media_type_internal_serdes;
-		} else if (eth_flags->e1000_base_t) {
-			dev_spec->sgmii_active = true;
-			hw->phy.media_type = e1000_media_type_copper;
-		} else {
-			hw->phy.media_type = e1000_media_type_unknown;
-			DEBUGOUT("PHY module has not been recognized\n");
-			goto out;
-		}
+	else
+		DEBUGOUT("PHY module is not SFP/SFF %x\n", tranceiver_type);
+
+	if (eth_flags->e1000_base_lx || eth_flags->e1000_base_sx) {
+		hw->phy.media_type = e1000_media_type_internal_serdes;
+		DEBUGOUT("PHY module is 1000_base_lxsx\n");
+	} else if (eth_flags->e100_base_fx || eth_flags->e100_base_lx) {
+		dev_spec->sgmii_active = true;
+		hw->phy.media_type = e1000_media_type_internal_serdes;
+		DEBUGOUT("PHY module is 100_base_fxlx\n");
+	} else if (eth_flags->e1000_base_t) {
+		dev_spec->sgmii_active = true;
+		hw->phy.media_type = e1000_media_type_copper;
+		DEBUGOUT("PHY module is 1000_base_t\n");
 	} else {
 		hw->phy.media_type = e1000_media_type_unknown;
+		DEBUGOUT("PHY module has not been recognized\n");
 	}
+
 	ret_val = E1000_SUCCESS;
 out:
 	/* Restore I2C interface setting */