]> git.droids-corp.org - dpdk.git/commitdiff
net/ixgbe: retry misbehaving SFP read
authorStephen Douthit <stephend@silicom-usa.com>
Wed, 23 Mar 2022 20:03:46 +0000 (16:03 -0400)
committerQi Zhang <qi.z.zhang@intel.com>
Mon, 18 Apr 2022 05:47:18 +0000 (07:47 +0200)
Some XGS-PON SFPs have been observed ACKing I2C reads and returning
uninitialized garbage while their uC boots.  This can lead to the SFP ID
code marking an otherwise working SFP module as unsupported if a bogus
ID value is read while its internal PHY/microcontroller is still
booting.

Retry the ID read several times looking not just for NAK, but also for a
valid ID field.

Since the device isn't NAKing the transaction, the existing longer retry
code in ixgbe_read_i2c_byte_generic_int() doesn't apply here.

Signed-off-by: Stephen Douthit <stephend@silicom-usa.com>
Signed-off-by: Jeff Daly <jeffd@silicom-usa.com>
Reviewed-by: Haiyue Wang <haiyue.wang@intel.com>
drivers/net/ixgbe/base/ixgbe_phy.c

index 8d4d9bbfef3cbb043bcf4a95e05453bddc331054..74c5db16fa570ec6a2b3b8d2e7385abddb228a96 100644 (file)
@@ -1267,6 +1267,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
        u8 cable_tech = 0;
        u8 cable_spec = 0;
        u16 enforce_sfp = 0;
+       u8 retries;
 
        DEBUGFUNC("ixgbe_identify_sfp_module_generic");
 
@@ -1279,9 +1280,29 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
        /* LAN ID is needed for I2C access */
        hw->mac.ops.set_lan_id(hw);
 
-       status = hw->phy.ops.read_i2c_eeprom(hw,
-                                            IXGBE_SFF_IDENTIFIER,
-                                            &identifier);
+       /* Need to check this a couple of times for a sane value.
+        *
+        * SFPs that have a uC slaved to the I2C bus (vs. a dumb EEPROM) can be
+        * poorly designed such that they will ACK I2C reads and return
+        * whatever bogus data is in the SRAM (or whatever is backing the target
+        * device) before things are truly initialized.
+        *
+        * In a perfect world devices would NAK I2C requests until they were
+        * sane, but here we are.
+        *
+        * Give such devices a couple tries to get their act together before
+        * marking the device as unsupported.
+        */
+       for (retries = 0; retries < 5; retries++) {
+               status = hw->phy.ops.read_i2c_eeprom(hw,
+                                                    IXGBE_SFF_IDENTIFIER,
+                                                    &identifier);
+
+               DEBUGOUT("status %d, SFF identifier 0x%x\n", status, identifier);
+               if (status == IXGBE_SUCCESS &&
+               identifier == IXGBE_SFF_IDENTIFIER_SFP)
+                       break;
+       }
 
        if (status != IXGBE_SUCCESS)
                goto err_read_i2c_eeprom;