Commit 76d97dd4 authored by Emil Tantilov's avatar Emil Tantilov Committed by Jeff Kirsher

ixgbe: cleanup code in ixgbe_identify_sfp_module_generic

This change cleans up several issues in ixgbe_identify_sfp_module_generic
including whitespace, redundant code, I2C EEPROM reads without exception
handling, and an if/elseif/else without braces.
Signed-off-by: default avatarEmil Tantilov <emil.s.tantilov@intel.com>
Tested-by: default avatarStephen Ko <stephen.s.ko@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent a4297dc2
...@@ -556,11 +556,10 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw) ...@@ -556,11 +556,10 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
} }
/** /**
* ixgbe_identify_sfp_module_generic - Identifies SFP module and assigns * ixgbe_identify_sfp_module_generic - Identifies SFP modules
* the PHY type.
* @hw: pointer to hardware structure * @hw: pointer to hardware structure
* *
* Searches for and indentifies the SFP module. Assings appropriate PHY type. * Searches for and identifies the SFP module and assigns appropriate PHY type.
**/ **/
s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
{ {
...@@ -581,27 +580,48 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) ...@@ -581,27 +580,48 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
goto out; goto out;
} }
status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_IDENTIFIER, status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_IDENTIFIER,
&identifier); &identifier);
if (status == IXGBE_ERR_SFP_NOT_PRESENT || status == IXGBE_ERR_I2C) { if (status == IXGBE_ERR_SWFW_SYNC ||
status = IXGBE_ERR_SFP_NOT_PRESENT; status == IXGBE_ERR_I2C ||
hw->phy.sfp_type = ixgbe_sfp_type_not_present; status == IXGBE_ERR_SFP_NOT_PRESENT)
if (hw->phy.type != ixgbe_phy_nl) { goto err_read_i2c_eeprom;
hw->phy.id = 0;
hw->phy.type = ixgbe_phy_unknown;
}
goto out;
}
if (identifier == IXGBE_SFF_IDENTIFIER_SFP) { /* LAN ID is needed for sfp_type determination */
hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_1GBE_COMP_CODES, hw->mac.ops.set_lan_id(hw);
if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
hw->phy.type = ixgbe_phy_sfp_unsupported;
status = IXGBE_ERR_SFP_NOT_SUPPORTED;
} else {
status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_1GBE_COMP_CODES,
&comp_codes_1g); &comp_codes_1g);
hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_10GBE_COMP_CODES,
if (status == IXGBE_ERR_SWFW_SYNC ||
status == IXGBE_ERR_I2C ||
status == IXGBE_ERR_SFP_NOT_PRESENT)
goto err_read_i2c_eeprom;
status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_10GBE_COMP_CODES,
&comp_codes_10g); &comp_codes_10g);
hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_CABLE_TECHNOLOGY,
if (status == IXGBE_ERR_SWFW_SYNC ||
status == IXGBE_ERR_I2C ||
status == IXGBE_ERR_SFP_NOT_PRESENT)
goto err_read_i2c_eeprom;
status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_CABLE_TECHNOLOGY,
&cable_tech); &cable_tech);
if (status == IXGBE_ERR_SWFW_SYNC ||
status == IXGBE_ERR_I2C ||
status == IXGBE_ERR_SFP_NOT_PRESENT)
goto err_read_i2c_eeprom;
/* ID Module /* ID Module
* ========= * =========
* 0 SFP_DA_CU * 0 SFP_DA_CU
...@@ -649,30 +669,26 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) ...@@ -649,30 +669,26 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
hw->phy.sfp_type = hw->phy.sfp_type =
ixgbe_sfp_type_unknown; ixgbe_sfp_type_unknown;
} }
} else if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE) } else if (comp_codes_10g &
if (hw->bus.lan_id == 0) (IXGBE_SFF_10GBASESR_CAPABLE |
hw->phy.sfp_type = IXGBE_SFF_10GBASELR_CAPABLE)) {
ixgbe_sfp_type_srlr_core0;
else
hw->phy.sfp_type =
ixgbe_sfp_type_srlr_core1;
else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
if (hw->bus.lan_id == 0) if (hw->bus.lan_id == 0)
hw->phy.sfp_type = hw->phy.sfp_type =
ixgbe_sfp_type_srlr_core0; ixgbe_sfp_type_srlr_core0;
else else
hw->phy.sfp_type = hw->phy.sfp_type =
ixgbe_sfp_type_srlr_core1; ixgbe_sfp_type_srlr_core1;
else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) } else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) {
if (hw->bus.lan_id == 0) if (hw->bus.lan_id == 0)
hw->phy.sfp_type = hw->phy.sfp_type =
ixgbe_sfp_type_1g_cu_core0; ixgbe_sfp_type_1g_cu_core0;
else else
hw->phy.sfp_type = hw->phy.sfp_type =
ixgbe_sfp_type_1g_cu_core1; ixgbe_sfp_type_1g_cu_core1;
else } else {
hw->phy.sfp_type = ixgbe_sfp_type_unknown; hw->phy.sfp_type = ixgbe_sfp_type_unknown;
} }
}
if (hw->phy.sfp_type != stored_sfp_type) if (hw->phy.sfp_type != stored_sfp_type)
hw->phy.sfp_setup_needed = true; hw->phy.sfp_setup_needed = true;
...@@ -688,16 +704,33 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) ...@@ -688,16 +704,33 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
/* Determine PHY vendor */ /* Determine PHY vendor */
if (hw->phy.type != ixgbe_phy_nl) { if (hw->phy.type != ixgbe_phy_nl) {
hw->phy.id = identifier; hw->phy.id = identifier;
hw->phy.ops.read_i2c_eeprom(hw, status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_VENDOR_OUI_BYTE0, IXGBE_SFF_VENDOR_OUI_BYTE0,
&oui_bytes[0]); &oui_bytes[0]);
hw->phy.ops.read_i2c_eeprom(hw,
if (status == IXGBE_ERR_SWFW_SYNC ||
status == IXGBE_ERR_I2C ||
status == IXGBE_ERR_SFP_NOT_PRESENT)
goto err_read_i2c_eeprom;
status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_VENDOR_OUI_BYTE1, IXGBE_SFF_VENDOR_OUI_BYTE1,
&oui_bytes[1]); &oui_bytes[1]);
hw->phy.ops.read_i2c_eeprom(hw,
if (status == IXGBE_ERR_SWFW_SYNC ||
status == IXGBE_ERR_I2C ||
status == IXGBE_ERR_SFP_NOT_PRESENT)
goto err_read_i2c_eeprom;
status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_VENDOR_OUI_BYTE2, IXGBE_SFF_VENDOR_OUI_BYTE2,
&oui_bytes[2]); &oui_bytes[2]);
if (status == IXGBE_ERR_SWFW_SYNC ||
status == IXGBE_ERR_I2C ||
status == IXGBE_ERR_SFP_NOT_PRESENT)
goto err_read_i2c_eeprom;
vendor_oui = vendor_oui =
((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) | ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
(oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) | (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
...@@ -734,7 +767,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) ...@@ -734,7 +767,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
} }
} }
/* All passive DA cables are supported */ /* Allow any DA cable vendor */
if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE | if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE |
IXGBE_SFF_DA_ACTIVE_CABLE)) { IXGBE_SFF_DA_ACTIVE_CABLE)) {
status = 0; status = 0;
...@@ -776,12 +809,18 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) ...@@ -776,12 +809,18 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
out: out:
return status; return status;
err_read_i2c_eeprom:
hw->phy.sfp_type = ixgbe_sfp_type_not_present;
if (hw->phy.type != ixgbe_phy_nl) {
hw->phy.id = 0;
hw->phy.type = ixgbe_phy_unknown;
}
return IXGBE_ERR_SFP_NOT_PRESENT;
} }
/** /**
* ixgbe_get_sfp_init_sequence_offsets - Checks the MAC's EEPROM to see * ixgbe_get_sfp_init_sequence_offsets - Provides offset of PHY init sequence
* if it supports a given SFP+ module type, if so it returns the offsets to the
* phy init sequence block.
* @hw: pointer to hardware structure * @hw: pointer to hardware structure
* @list_offset: offset to the SFP ID list * @list_offset: offset to the SFP ID list
* @data_offset: offset to the SFP data block * @data_offset: offset to the SFP data block
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment