Commit e90dd264 authored by Mark Rustad's avatar Mark Rustad Committed by Jeff Kirsher

ixgbe: Make return values more direct

Make return values more direct, eliminating some gotos and
otherwise unneeded conditionals. This also eliminates some
local variables. Also a few minor cleanups in affected code
so checkpatch won't complain.
Signed-off-by: default avatarMark Rustad <mark.d.rustad@intel.com>
Tested-by: default avatarPhil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 9f1fb8ac
...@@ -122,7 +122,7 @@ static s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw) ...@@ -122,7 +122,7 @@ static s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw)
{ {
struct ixgbe_mac_info *mac = &hw->mac; struct ixgbe_mac_info *mac = &hw->mac;
struct ixgbe_phy_info *phy = &hw->phy; struct ixgbe_phy_info *phy = &hw->phy;
s32 ret_val = 0; s32 ret_val;
u16 list_offset, data_offset; u16 list_offset, data_offset;
/* Identify the PHY */ /* Identify the PHY */
...@@ -147,28 +147,23 @@ static s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw) ...@@ -147,28 +147,23 @@ static s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw)
/* Call SFP+ identify routine to get the SFP+ module type */ /* Call SFP+ identify routine to get the SFP+ module type */
ret_val = phy->ops.identify_sfp(hw); ret_val = phy->ops.identify_sfp(hw);
if (ret_val != 0) if (ret_val)
goto out; return ret_val;
else if (hw->phy.sfp_type == ixgbe_sfp_type_unknown) { if (hw->phy.sfp_type == ixgbe_sfp_type_unknown)
ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED; return IXGBE_ERR_SFP_NOT_SUPPORTED;
goto out;
}
/* Check to see if SFP+ module is supported */ /* Check to see if SFP+ module is supported */
ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, ret_val = ixgbe_get_sfp_init_sequence_offsets(hw,
&list_offset, &list_offset,
&data_offset); &data_offset);
if (ret_val != 0) { if (ret_val)
ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED; return IXGBE_ERR_SFP_NOT_SUPPORTED;
goto out;
}
break; break;
default: default:
break; break;
} }
out: return 0;
return ret_val;
} }
/** /**
...@@ -183,7 +178,7 @@ static s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw) ...@@ -183,7 +178,7 @@ static s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)
{ {
u32 regval; u32 regval;
u32 i; u32 i;
s32 ret_val = 0; s32 ret_val;
ret_val = ixgbe_start_hw_generic(hw); ret_val = ixgbe_start_hw_generic(hw);
...@@ -203,11 +198,13 @@ static s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw) ...@@ -203,11 +198,13 @@ static s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)
IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval); IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval);
} }
if (ret_val)
return ret_val;
/* set the completion timeout for interface */ /* set the completion timeout for interface */
if (ret_val == 0) ixgbe_set_pcie_completion_timeout(hw);
ixgbe_set_pcie_completion_timeout(hw);
return ret_val; return 0;
} }
/** /**
...@@ -222,7 +219,6 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw, ...@@ -222,7 +219,6 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
ixgbe_link_speed *speed, ixgbe_link_speed *speed,
bool *autoneg) bool *autoneg)
{ {
s32 status = 0;
u32 autoc = 0; u32 autoc = 0;
/* /*
...@@ -262,11 +258,10 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw, ...@@ -262,11 +258,10 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
break; break;
default: default:
status = IXGBE_ERR_LINK_SETUP; return IXGBE_ERR_LINK_SETUP;
break;
} }
return status; return 0;
} }
/** /**
...@@ -277,14 +272,12 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw, ...@@ -277,14 +272,12 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
**/ **/
static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw) static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
{ {
enum ixgbe_media_type media_type;
/* Detect if there is a copper PHY attached. */ /* Detect if there is a copper PHY attached. */
switch (hw->phy.type) { switch (hw->phy.type) {
case ixgbe_phy_cu_unknown: case ixgbe_phy_cu_unknown:
case ixgbe_phy_tn: case ixgbe_phy_tn:
media_type = ixgbe_media_type_copper; return ixgbe_media_type_copper;
goto out;
default: default:
break; break;
} }
...@@ -294,30 +287,27 @@ static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw) ...@@ -294,30 +287,27 @@ static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_82598: case IXGBE_DEV_ID_82598:
case IXGBE_DEV_ID_82598_BX: case IXGBE_DEV_ID_82598_BX:
/* Default device ID is mezzanine card KX/KX4 */ /* Default device ID is mezzanine card KX/KX4 */
media_type = ixgbe_media_type_backplane; return ixgbe_media_type_backplane;
break;
case IXGBE_DEV_ID_82598AF_DUAL_PORT: case IXGBE_DEV_ID_82598AF_DUAL_PORT:
case IXGBE_DEV_ID_82598AF_SINGLE_PORT: case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
case IXGBE_DEV_ID_82598_DA_DUAL_PORT: case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM: case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
case IXGBE_DEV_ID_82598EB_XF_LR: case IXGBE_DEV_ID_82598EB_XF_LR:
case IXGBE_DEV_ID_82598EB_SFP_LOM: case IXGBE_DEV_ID_82598EB_SFP_LOM:
media_type = ixgbe_media_type_fiber; return ixgbe_media_type_fiber;
break;
case IXGBE_DEV_ID_82598EB_CX4: case IXGBE_DEV_ID_82598EB_CX4:
case IXGBE_DEV_ID_82598_CX4_DUAL_PORT: case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
media_type = ixgbe_media_type_cx4; return ixgbe_media_type_cx4;
break;
case IXGBE_DEV_ID_82598AT: case IXGBE_DEV_ID_82598AT:
case IXGBE_DEV_ID_82598AT2: case IXGBE_DEV_ID_82598AT2:
media_type = ixgbe_media_type_copper; return ixgbe_media_type_copper;
break;
default: default:
media_type = ixgbe_media_type_unknown; return ixgbe_media_type_unknown;
break;
} }
out:
return media_type;
} }
/** /**
...@@ -328,7 +318,6 @@ static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw) ...@@ -328,7 +318,6 @@ static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
**/ **/
static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw) static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
{ {
s32 ret_val = 0;
u32 fctrl_reg; u32 fctrl_reg;
u32 rmcs_reg; u32 rmcs_reg;
u32 reg; u32 reg;
...@@ -338,10 +327,8 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw) ...@@ -338,10 +327,8 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
bool link_up; bool link_up;
/* Validate the water mark configuration */ /* Validate the water mark configuration */
if (!hw->fc.pause_time) { if (!hw->fc.pause_time)
ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; return IXGBE_ERR_INVALID_LINK_SETTINGS;
goto out;
}
/* Low water mark of zero causes XOFF floods */ /* Low water mark of zero causes XOFF floods */
for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
...@@ -350,8 +337,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw) ...@@ -350,8 +337,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
if (!hw->fc.low_water[i] || if (!hw->fc.low_water[i] ||
hw->fc.low_water[i] >= hw->fc.high_water[i]) { hw->fc.low_water[i] >= hw->fc.high_water[i]) {
hw_dbg(hw, "Invalid water mark configuration\n"); hw_dbg(hw, "Invalid water mark configuration\n");
ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; return IXGBE_ERR_INVALID_LINK_SETTINGS;
goto out;
} }
} }
} }
...@@ -428,8 +414,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw) ...@@ -428,8 +414,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
break; break;
default: default:
hw_dbg(hw, "Flow control param set incorrectly\n"); hw_dbg(hw, "Flow control param set incorrectly\n");
ret_val = IXGBE_ERR_CONFIG; return IXGBE_ERR_CONFIG;
goto out;
} }
/* Set 802.3x based flow control settings. */ /* Set 802.3x based flow control settings. */
...@@ -460,8 +445,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw) ...@@ -460,8 +445,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
/* Configure flow control refresh threshold value */ /* Configure flow control refresh threshold value */
IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2); IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
out: return 0;
return ret_val;
} }
/** /**
...@@ -597,7 +581,7 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, ...@@ -597,7 +581,7 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
} }
if (!*link_up) if (!*link_up)
goto out; return 0;
} }
links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS); links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
...@@ -628,7 +612,6 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, ...@@ -628,7 +612,6 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
(ixgbe_validate_link_ready(hw) != 0)) (ixgbe_validate_link_ready(hw) != 0))
*link_up = false; *link_up = false;
out:
return 0; return 0;
} }
...@@ -645,7 +628,6 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw, ...@@ -645,7 +628,6 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,
bool autoneg_wait_to_complete) bool autoneg_wait_to_complete)
{ {
bool autoneg = false; bool autoneg = false;
s32 status = 0;
ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN; ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
u32 curr_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); u32 curr_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
u32 autoc = curr_autoc; u32 autoc = curr_autoc;
...@@ -656,7 +638,7 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw, ...@@ -656,7 +638,7 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,
speed &= link_capabilities; speed &= link_capabilities;
if (speed == IXGBE_LINK_SPEED_UNKNOWN) if (speed == IXGBE_LINK_SPEED_UNKNOWN)
status = IXGBE_ERR_LINK_SETUP; return IXGBE_ERR_LINK_SETUP;
/* Set KX4/KX support according to speed requested */ /* Set KX4/KX support according to speed requested */
else if (link_mode == IXGBE_AUTOC_LMS_KX4_AN || else if (link_mode == IXGBE_AUTOC_LMS_KX4_AN ||
...@@ -670,17 +652,11 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw, ...@@ -670,17 +652,11 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,
IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc); IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
} }
if (status == 0) { /* Setup and restart the link based on the new values in
/* * ixgbe_hw This will write the AUTOC register based on the new
* Setup and restart the link based on the new values in * stored values
* ixgbe_hw This will write the AUTOC register based on the new */
* stored values return ixgbe_start_mac_link_82598(hw, autoneg_wait_to_complete);
*/
status = ixgbe_start_mac_link_82598(hw,
autoneg_wait_to_complete);
}
return status;
} }
...@@ -717,7 +693,7 @@ static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw, ...@@ -717,7 +693,7 @@ static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw,
**/ **/
static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw) static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
{ {
s32 status = 0; s32 status;
s32 phy_status = 0; s32 phy_status = 0;
u32 ctrl; u32 ctrl;
u32 gheccr; u32 gheccr;
...@@ -727,8 +703,8 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw) ...@@ -727,8 +703,8 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
/* Call adapter stop to disable tx/rx and clear interrupts */ /* Call adapter stop to disable tx/rx and clear interrupts */
status = hw->mac.ops.stop_adapter(hw); status = hw->mac.ops.stop_adapter(hw);
if (status != 0) if (status)
goto reset_hw_out; return status;
/* /*
* Power up the Atlas Tx lanes if they are currently powered down. * Power up the Atlas Tx lanes if they are currently powered down.
...@@ -770,7 +746,7 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw) ...@@ -770,7 +746,7 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
/* Init PHY and function pointers, perform SFP setup */ /* Init PHY and function pointers, perform SFP setup */
phy_status = hw->phy.ops.init(hw); phy_status = hw->phy.ops.init(hw);
if (phy_status == IXGBE_ERR_SFP_NOT_SUPPORTED) if (phy_status == IXGBE_ERR_SFP_NOT_SUPPORTED)
goto reset_hw_out; return phy_status;
if (phy_status == IXGBE_ERR_SFP_NOT_PRESENT) if (phy_status == IXGBE_ERR_SFP_NOT_PRESENT)
goto mac_reset_top; goto mac_reset_top;
...@@ -836,7 +812,6 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw) ...@@ -836,7 +812,6 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
*/ */
hw->mac.ops.init_rx_addrs(hw); hw->mac.ops.init_rx_addrs(hw);
reset_hw_out:
if (phy_status) if (phy_status)
status = phy_status; status = phy_status;
......
...@@ -123,7 +123,7 @@ static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw) ...@@ -123,7 +123,7 @@ static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw) static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
{ {
s32 ret_val = 0; s32 ret_val;
u16 list_offset, data_offset, data_value; u16 list_offset, data_offset, data_value;
if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) { if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {
...@@ -133,16 +133,14 @@ static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw) ...@@ -133,16 +133,14 @@ static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset, ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
&data_offset); &data_offset);
if (ret_val != 0) if (ret_val)
goto setup_sfp_out; return ret_val;
/* PHY config will finish before releasing the semaphore */ /* PHY config will finish before releasing the semaphore */
ret_val = hw->mac.ops.acquire_swfw_sync(hw, ret_val = hw->mac.ops.acquire_swfw_sync(hw,
IXGBE_GSSR_MAC_CSR_SM); IXGBE_GSSR_MAC_CSR_SM);
if (ret_val != 0) { if (ret_val)
ret_val = IXGBE_ERR_SWFW_SYNC; return IXGBE_ERR_SWFW_SYNC;
goto setup_sfp_out;
}
if (hw->eeprom.ops.read(hw, ++data_offset, &data_value)) if (hw->eeprom.ops.read(hw, ++data_offset, &data_value))
goto setup_sfp_err; goto setup_sfp_err;
...@@ -169,13 +167,11 @@ static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw) ...@@ -169,13 +167,11 @@ static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
if (ret_val) { if (ret_val) {
hw_dbg(hw, " sfp module setup not complete\n"); hw_dbg(hw, " sfp module setup not complete\n");
ret_val = IXGBE_ERR_SFP_SETUP_NOT_COMPLETE; return IXGBE_ERR_SFP_SETUP_NOT_COMPLETE;
goto setup_sfp_out;
} }
} }
setup_sfp_out: return 0;
return ret_val;
setup_sfp_err: setup_sfp_err:
/* Release the semaphore */ /* Release the semaphore */
...@@ -294,7 +290,7 @@ static s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw) ...@@ -294,7 +290,7 @@ static s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw)
{ {
struct ixgbe_mac_info *mac = &hw->mac; struct ixgbe_mac_info *mac = &hw->mac;
struct ixgbe_phy_info *phy = &hw->phy; struct ixgbe_phy_info *phy = &hw->phy;
s32 ret_val = 0; s32 ret_val;
u32 esdp; u32 esdp;
if (hw->device_id == IXGBE_DEV_ID_82599_QSFP_SF_QP) { if (hw->device_id == IXGBE_DEV_ID_82599_QSFP_SF_QP) {
...@@ -355,7 +351,6 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw, ...@@ -355,7 +351,6 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
ixgbe_link_speed *speed, ixgbe_link_speed *speed,
bool *autoneg) bool *autoneg)
{ {
s32 status = 0;
u32 autoc = 0; u32 autoc = 0;
/* Determine 1G link capabilities off of SFP+ type */ /* Determine 1G link capabilities off of SFP+ type */
...@@ -367,7 +362,7 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw, ...@@ -367,7 +362,7 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) { hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
*speed = IXGBE_LINK_SPEED_1GB_FULL; *speed = IXGBE_LINK_SPEED_1GB_FULL;
*autoneg = true; *autoneg = true;
goto out; return 0;
} }
/* /*
...@@ -430,8 +425,7 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw, ...@@ -430,8 +425,7 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
break; break;
default: default:
status = IXGBE_ERR_LINK_SETUP; return IXGBE_ERR_LINK_SETUP;
goto out;
} }
if (hw->phy.multispeed_fiber) { if (hw->phy.multispeed_fiber) {
...@@ -445,8 +439,7 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw, ...@@ -445,8 +439,7 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
*autoneg = true; *autoneg = true;
} }
out: return 0;
return status;
} }
/** /**
...@@ -457,14 +450,12 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw, ...@@ -457,14 +450,12 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
**/ **/
static enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw) static enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw)
{ {
enum ixgbe_media_type media_type;
/* Detect if there is a copper PHY attached. */ /* Detect if there is a copper PHY attached. */
switch (hw->phy.type) { switch (hw->phy.type) {
case ixgbe_phy_cu_unknown: case ixgbe_phy_cu_unknown:
case ixgbe_phy_tn: case ixgbe_phy_tn:
media_type = ixgbe_media_type_copper; return ixgbe_media_type_copper;
goto out;
default: default:
break; break;
} }
...@@ -477,34 +468,31 @@ static enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw) ...@@ -477,34 +468,31 @@ static enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_82599_BACKPLANE_FCOE: case IXGBE_DEV_ID_82599_BACKPLANE_FCOE:
case IXGBE_DEV_ID_82599_XAUI_LOM: case IXGBE_DEV_ID_82599_XAUI_LOM:
/* Default device ID is mezzanine card KX/KX4 */ /* Default device ID is mezzanine card KX/KX4 */
media_type = ixgbe_media_type_backplane; return ixgbe_media_type_backplane;
break;
case IXGBE_DEV_ID_82599_SFP: case IXGBE_DEV_ID_82599_SFP:
case IXGBE_DEV_ID_82599_SFP_FCOE: case IXGBE_DEV_ID_82599_SFP_FCOE:
case IXGBE_DEV_ID_82599_SFP_EM: case IXGBE_DEV_ID_82599_SFP_EM:
case IXGBE_DEV_ID_82599_SFP_SF2: case IXGBE_DEV_ID_82599_SFP_SF2:
case IXGBE_DEV_ID_82599_SFP_SF_QP: case IXGBE_DEV_ID_82599_SFP_SF_QP:
case IXGBE_DEV_ID_82599EN_SFP: case IXGBE_DEV_ID_82599EN_SFP:
media_type = ixgbe_media_type_fiber; return ixgbe_media_type_fiber;
break;
case IXGBE_DEV_ID_82599_CX4: case IXGBE_DEV_ID_82599_CX4:
media_type = ixgbe_media_type_cx4; return ixgbe_media_type_cx4;
break;
case IXGBE_DEV_ID_82599_T3_LOM: case IXGBE_DEV_ID_82599_T3_LOM:
media_type = ixgbe_media_type_copper; return ixgbe_media_type_copper;
break;
case IXGBE_DEV_ID_82599_LS: case IXGBE_DEV_ID_82599_LS:
media_type = ixgbe_media_type_fiber_lco; return ixgbe_media_type_fiber_lco;
break;
case IXGBE_DEV_ID_82599_QSFP_SF_QP: case IXGBE_DEV_ID_82599_QSFP_SF_QP:
media_type = ixgbe_media_type_fiber_qsfp; return ixgbe_media_type_fiber_qsfp;
break;
default: default:
media_type = ixgbe_media_type_unknown; return ixgbe_media_type_unknown;
break;
} }
out:
return media_type;
} }
/** /**
...@@ -554,7 +542,7 @@ static s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw, ...@@ -554,7 +542,7 @@ static s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
status = hw->mac.ops.acquire_swfw_sync(hw, status = hw->mac.ops.acquire_swfw_sync(hw,
IXGBE_GSSR_MAC_CSR_SM); IXGBE_GSSR_MAC_CSR_SM);
if (status) if (status)
goto out; return status;
got_lock = true; got_lock = true;
} }
...@@ -591,7 +579,6 @@ static s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw, ...@@ -591,7 +579,6 @@ static s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
/* Add delay to filter out noises during initial link setup */ /* Add delay to filter out noises during initial link setup */
msleep(50); msleep(50);
out:
return status; return status;
} }
...@@ -958,7 +945,7 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw, ...@@ -958,7 +945,7 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
bool autoneg_wait_to_complete) bool autoneg_wait_to_complete)
{ {
bool autoneg = false; bool autoneg = false;
s32 status = 0; s32 status;
u32 pma_pmd_1g, link_mode, links_reg, i; u32 pma_pmd_1g, link_mode, links_reg, i;
u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2); u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK; u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
...@@ -974,15 +961,13 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw, ...@@ -974,15 +961,13 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
/* Check to see if speed passed in is supported. */ /* Check to see if speed passed in is supported. */
status = hw->mac.ops.get_link_capabilities(hw, &link_capabilities, status = hw->mac.ops.get_link_capabilities(hw, &link_capabilities,
&autoneg); &autoneg);
if (status != 0) if (status)
goto out; return status;
speed &= link_capabilities; speed &= link_capabilities;
if (speed == IXGBE_LINK_SPEED_UNKNOWN) { if (speed == IXGBE_LINK_SPEED_UNKNOWN)
status = IXGBE_ERR_LINK_SETUP; return IXGBE_ERR_LINK_SETUP;
goto out;
}
/* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/ /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
if (hw->mac.orig_link_settings_stored) if (hw->mac.orig_link_settings_stored)
...@@ -1033,7 +1018,7 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw, ...@@ -1033,7 +1018,7 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
/* Restart link */ /* Restart link */
status = hw->mac.ops.prot_autoc_write(hw, autoc, false); status = hw->mac.ops.prot_autoc_write(hw, autoc, false);
if (status) if (status)
goto out; return status;
/* Only poll for autoneg to complete if specified to do so */ /* Only poll for autoneg to complete if specified to do so */
if (autoneg_wait_to_complete) { if (autoneg_wait_to_complete) {
...@@ -1060,7 +1045,6 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw, ...@@ -1060,7 +1045,6 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
msleep(50); msleep(50);
} }
out:
return status; return status;
} }
...@@ -1105,8 +1089,8 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw) ...@@ -1105,8 +1089,8 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
/* Call adapter stop to disable tx/rx and clear interrupts */ /* Call adapter stop to disable tx/rx and clear interrupts */
status = hw->mac.ops.stop_adapter(hw); status = hw->mac.ops.stop_adapter(hw);
if (status != 0) if (status)
goto reset_hw_out; return status;
/* flush pending Tx transactions */ /* flush pending Tx transactions */
ixgbe_clear_tx_pending(hw); ixgbe_clear_tx_pending(hw);
...@@ -1117,7 +1101,7 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw) ...@@ -1117,7 +1101,7 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
status = hw->phy.ops.init(hw); status = hw->phy.ops.init(hw);
if (status == IXGBE_ERR_SFP_NOT_SUPPORTED) if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
goto reset_hw_out; return status;
/* Setup SFP module if there is one present. */ /* Setup SFP module if there is one present. */
if (hw->phy.sfp_setup_needed) { if (hw->phy.sfp_setup_needed) {
...@@ -1126,7 +1110,7 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw) ...@@ -1126,7 +1110,7 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
} }
if (status == IXGBE_ERR_SFP_NOT_SUPPORTED) if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
goto reset_hw_out; return status;
/* Reset PHY */ /* Reset PHY */
if (hw->phy.reset_disable == false && hw->phy.ops.reset != NULL) if (hw->phy.reset_disable == false && hw->phy.ops.reset != NULL)
...@@ -1216,7 +1200,7 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw) ...@@ -1216,7 +1200,7 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
hw->mac.orig_autoc, hw->mac.orig_autoc,
false); false);
if (status) if (status)
goto reset_hw_out; return status;
} }
if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) != if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=
...@@ -1258,7 +1242,6 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw) ...@@ -1258,7 +1242,6 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
hw->mac.ops.get_wwn_prefix(hw, &hw->mac.wwnn_prefix, hw->mac.ops.get_wwn_prefix(hw, &hw->mac.wwnn_prefix,
&hw->mac.wwpn_prefix); &hw->mac.wwpn_prefix);
reset_hw_out:
return status; return status;
} }
...@@ -1927,20 +1910,20 @@ static s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw) ...@@ -1927,20 +1910,20 @@ static s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw)
s32 ret_val = 0; s32 ret_val = 0;
ret_val = ixgbe_start_hw_generic(hw); ret_val = ixgbe_start_hw_generic(hw);
if (ret_val != 0) if (ret_val)
goto out; return ret_val;
ret_val = ixgbe_start_hw_gen2(hw); ret_val = ixgbe_start_hw_gen2(hw);
if (ret_val != 0) if (ret_val)
goto out; return ret_val;
/* We need to run link autotry after the driver loads */ /* We need to run link autotry after the driver loads */
hw->mac.autotry_restart = true; hw->mac.autotry_restart = true;
if (ret_val == 0) if (ret_val)
ret_val = ixgbe_verify_fw_version_82599(hw); return ret_val;
out:
return ret_val; return ixgbe_verify_fw_version_82599(hw);
} }
/** /**
...@@ -1953,16 +1936,15 @@ static s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw) ...@@ -1953,16 +1936,15 @@ static s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw)
**/ **/
static s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw) static s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw)
{ {
s32 status = IXGBE_ERR_PHY_ADDR_INVALID; s32 status;
/* Detect PHY if not unknown - returns success if already detected. */ /* Detect PHY if not unknown - returns success if already detected. */
status = ixgbe_identify_phy_generic(hw); status = ixgbe_identify_phy_generic(hw);
if (status != 0) { if (status) {
/* 82599 10GBASE-T requires an external PHY */ /* 82599 10GBASE-T requires an external PHY */
if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)
goto out; return status;
else status = ixgbe_identify_module_generic(hw);
status = ixgbe_identify_module_generic(hw);
} }
/* Set PHY type none if no PHY detected */ /* Set PHY type none if no PHY detected */
...@@ -1973,9 +1955,8 @@ static s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw) ...@@ -1973,9 +1955,8 @@ static s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw)
/* Return error if SFP module has been detected but is not supported */ /* Return error if SFP module has been detected but is not supported */
if (hw->phy.type == ixgbe_phy_sfp_unsupported) if (hw->phy.type == ixgbe_phy_sfp_unsupported)
status = IXGBE_ERR_SFP_NOT_SUPPORTED; return IXGBE_ERR_SFP_NOT_SUPPORTED;
out:
return status; return status;
} }
...@@ -2021,26 +2002,24 @@ static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw) ...@@ -2021,26 +2002,24 @@ static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw)
u16 fw_version = 0; u16 fw_version = 0;
/* firmware check is only necessary for SFI devices */ /* firmware check is only necessary for SFI devices */
if (hw->phy.media_type != ixgbe_media_type_fiber) { if (hw->phy.media_type != ixgbe_media_type_fiber)
status = 0; return 0;
goto fw_version_out;
}
/* get the offset to the Firmware Module block */ /* get the offset to the Firmware Module block */
offset = IXGBE_FW_PTR; offset = IXGBE_FW_PTR;
if (hw->eeprom.ops.read(hw, offset, &fw_offset)) if (hw->eeprom.ops.read(hw, offset, &fw_offset))
goto fw_version_err; goto fw_version_err;
if ((fw_offset == 0) || (fw_offset == 0xFFFF)) if (fw_offset == 0 || fw_offset == 0xFFFF)
goto fw_version_out; return IXGBE_ERR_EEPROM_VERSION;
/* get the offset to the Pass Through Patch Configuration block */ /* get the offset to the Pass Through Patch Configuration block */
offset = fw_offset + IXGBE_FW_PASSTHROUGH_PATCH_CONFIG_PTR; offset = fw_offset + IXGBE_FW_PASSTHROUGH_PATCH_CONFIG_PTR;
if (hw->eeprom.ops.read(hw, offset, &fw_ptp_cfg_offset)) if (hw->eeprom.ops.read(hw, offset, &fw_ptp_cfg_offset))
goto fw_version_err; goto fw_version_err;
if ((fw_ptp_cfg_offset == 0) || (fw_ptp_cfg_offset == 0xFFFF)) if (fw_ptp_cfg_offset == 0 || fw_ptp_cfg_offset == 0xFFFF)
goto fw_version_out; return IXGBE_ERR_EEPROM_VERSION;
/* get the firmware version */ /* get the firmware version */
offset = fw_ptp_cfg_offset + IXGBE_FW_PATCH_VERSION_4; offset = fw_ptp_cfg_offset + IXGBE_FW_PATCH_VERSION_4;
...@@ -2050,7 +2029,6 @@ static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw) ...@@ -2050,7 +2029,6 @@ static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw)
if (fw_version > 0x5) if (fw_version > 0x5)
status = 0; status = 0;
fw_version_out:
return status; return status;
fw_version_err: fw_version_err:
...@@ -2067,37 +2045,33 @@ static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw) ...@@ -2067,37 +2045,33 @@ static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw)
**/ **/
static bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw) static bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw)
{ {
bool lesm_enabled = false;
u16 fw_offset, fw_lesm_param_offset, fw_lesm_state; u16 fw_offset, fw_lesm_param_offset, fw_lesm_state;
s32 status; s32 status;
/* get the offset to the Firmware Module block */ /* get the offset to the Firmware Module block */
status = hw->eeprom.ops.read(hw, IXGBE_FW_PTR, &fw_offset); status = hw->eeprom.ops.read(hw, IXGBE_FW_PTR, &fw_offset);
if ((status != 0) || if (status || fw_offset == 0 || fw_offset == 0xFFFF)
(fw_offset == 0) || (fw_offset == 0xFFFF)) return false;
goto out;
/* get the offset to the LESM Parameters block */ /* get the offset to the LESM Parameters block */
status = hw->eeprom.ops.read(hw, (fw_offset + status = hw->eeprom.ops.read(hw, (fw_offset +
IXGBE_FW_LESM_PARAMETERS_PTR), IXGBE_FW_LESM_PARAMETERS_PTR),
&fw_lesm_param_offset); &fw_lesm_param_offset);
if ((status != 0) || if (status ||
(fw_lesm_param_offset == 0) || (fw_lesm_param_offset == 0xFFFF)) fw_lesm_param_offset == 0 || fw_lesm_param_offset == 0xFFFF)
goto out; return false;
/* get the lesm state word */ /* get the lesm state word */
status = hw->eeprom.ops.read(hw, (fw_lesm_param_offset + status = hw->eeprom.ops.read(hw, (fw_lesm_param_offset +
IXGBE_FW_LESM_STATE_1), IXGBE_FW_LESM_STATE_1),
&fw_lesm_state); &fw_lesm_state);
if ((status == 0) && if (!status && (fw_lesm_state & IXGBE_FW_LESM_STATE_ENABLED))
(fw_lesm_state & IXGBE_FW_LESM_STATE_ENABLED)) return true;
lesm_enabled = true;
out: return false;
return lesm_enabled;
} }
/** /**
...@@ -2115,22 +2089,16 @@ static s32 ixgbe_read_eeprom_buffer_82599(struct ixgbe_hw *hw, u16 offset, ...@@ -2115,22 +2089,16 @@ static s32 ixgbe_read_eeprom_buffer_82599(struct ixgbe_hw *hw, u16 offset,
u16 words, u16 *data) u16 words, u16 *data)
{ {
struct ixgbe_eeprom_info *eeprom = &hw->eeprom; struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
s32 ret_val = IXGBE_ERR_CONFIG;
/* /* If EEPROM is detected and can be addressed using 14 bits,
* If EEPROM is detected and can be addressed using 14 bits,
* use EERD otherwise use bit bang * use EERD otherwise use bit bang
*/ */
if ((eeprom->type == ixgbe_eeprom_spi) && if (eeprom->type == ixgbe_eeprom_spi &&
(offset + (words - 1) <= IXGBE_EERD_MAX_ADDR)) offset + (words - 1) <= IXGBE_EERD_MAX_ADDR)
ret_val = ixgbe_read_eerd_buffer_generic(hw, offset, words, return ixgbe_read_eerd_buffer_generic(hw, offset, words, data);
data);
else
ret_val = ixgbe_read_eeprom_buffer_bit_bang_generic(hw, offset,
words,
data);
return ret_val; return ixgbe_read_eeprom_buffer_bit_bang_generic(hw, offset, words,
data);
} }
/** /**
...@@ -2147,19 +2115,15 @@ static s32 ixgbe_read_eeprom_82599(struct ixgbe_hw *hw, ...@@ -2147,19 +2115,15 @@ static s32 ixgbe_read_eeprom_82599(struct ixgbe_hw *hw,
u16 offset, u16 *data) u16 offset, u16 *data)
{ {
struct ixgbe_eeprom_info *eeprom = &hw->eeprom; struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
s32 ret_val = IXGBE_ERR_CONFIG;
/* /*
* If EEPROM is detected and can be addressed using 14 bits, * If EEPROM is detected and can be addressed using 14 bits,
* use EERD otherwise use bit bang * use EERD otherwise use bit bang
*/ */
if ((eeprom->type == ixgbe_eeprom_spi) && if (eeprom->type == ixgbe_eeprom_spi && offset <= IXGBE_EERD_MAX_ADDR)
(offset <= IXGBE_EERD_MAX_ADDR)) return ixgbe_read_eerd_generic(hw, offset, data);
ret_val = ixgbe_read_eerd_generic(hw, offset, data);
else
ret_val = ixgbe_read_eeprom_bit_bang_generic(hw, offset, data);
return ret_val; return ixgbe_read_eeprom_bit_bang_generic(hw, offset, data);
} }
/** /**
......
...@@ -122,8 +122,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw) ...@@ -122,8 +122,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
*/ */
if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) { if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
hw_dbg(hw, "ixgbe_fc_rx_pause not valid in strict IEEE mode\n"); hw_dbg(hw, "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; return IXGBE_ERR_INVALID_LINK_SETTINGS;
goto out;
} }
/* /*
...@@ -143,7 +142,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw) ...@@ -143,7 +142,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
/* some MAC's need RMW protection on AUTOC */ /* some MAC's need RMW protection on AUTOC */
ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &reg_bp); ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &reg_bp);
if (ret_val) if (ret_val)
goto out; return ret_val;
/* only backplane uses autoc so fall though */ /* only backplane uses autoc so fall though */
case ixgbe_media_type_fiber: case ixgbe_media_type_fiber:
...@@ -214,8 +213,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw) ...@@ -214,8 +213,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
break; break;
default: default:
hw_dbg(hw, "Flow control param set incorrectly\n"); hw_dbg(hw, "Flow control param set incorrectly\n");
ret_val = IXGBE_ERR_CONFIG; return IXGBE_ERR_CONFIG;
goto out;
} }
if (hw->mac.type != ixgbe_mac_X540) { if (hw->mac.type != ixgbe_mac_X540) {
...@@ -246,7 +244,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw) ...@@ -246,7 +244,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
*/ */
ret_val = hw->mac.ops.prot_autoc_write(hw, reg_bp, locked); ret_val = hw->mac.ops.prot_autoc_write(hw, reg_bp, locked);
if (ret_val) if (ret_val)
goto out; return ret_val;
} else if ((hw->phy.media_type == ixgbe_media_type_copper) && } else if ((hw->phy.media_type == ixgbe_media_type_copper) &&
ixgbe_device_supports_autoneg_fc(hw)) { ixgbe_device_supports_autoneg_fc(hw)) {
...@@ -255,7 +253,6 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw) ...@@ -255,7 +253,6 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
} }
hw_dbg(hw, "Set up FC; IXGBE_AUTOC = 0x%08X\n", reg); hw_dbg(hw, "Set up FC; IXGBE_AUTOC = 0x%08X\n", reg);
out:
return ret_val; return ret_val;
} }
...@@ -294,12 +291,11 @@ s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw) ...@@ -294,12 +291,11 @@ s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)
/* Setup flow control */ /* Setup flow control */
ret_val = ixgbe_setup_fc(hw); ret_val = ixgbe_setup_fc(hw);
if (!ret_val) if (!ret_val)
goto out; return 0;
/* Clear adapter stopped flag */ /* Clear adapter stopped flag */
hw->adapter_stopped = false; hw->adapter_stopped = false;
out:
return ret_val; return ret_val;
} }
...@@ -836,20 +832,16 @@ s32 ixgbe_init_eeprom_params_generic(struct ixgbe_hw *hw) ...@@ -836,20 +832,16 @@ s32 ixgbe_init_eeprom_params_generic(struct ixgbe_hw *hw)
s32 ixgbe_write_eeprom_buffer_bit_bang_generic(struct ixgbe_hw *hw, u16 offset, s32 ixgbe_write_eeprom_buffer_bit_bang_generic(struct ixgbe_hw *hw, u16 offset,
u16 words, u16 *data) u16 words, u16 *data)
{ {
s32 status = 0; s32 status;
u16 i, count; u16 i, count;
hw->eeprom.ops.init_params(hw); hw->eeprom.ops.init_params(hw);
if (words == 0) { if (words == 0)
status = IXGBE_ERR_INVALID_ARGUMENT; return IXGBE_ERR_INVALID_ARGUMENT;
goto out;
}
if (offset + words > hw->eeprom.word_size) { if (offset + words > hw->eeprom.word_size)
status = IXGBE_ERR_EEPROM; return IXGBE_ERR_EEPROM;
goto out;
}
/* /*
* The EEPROM page size cannot be queried from the chip. We do lazy * The EEPROM page size cannot be queried from the chip. We do lazy
...@@ -874,7 +866,6 @@ s32 ixgbe_write_eeprom_buffer_bit_bang_generic(struct ixgbe_hw *hw, u16 offset, ...@@ -874,7 +866,6 @@ s32 ixgbe_write_eeprom_buffer_bit_bang_generic(struct ixgbe_hw *hw, u16 offset,
break; break;
} }
out:
return status; return status;
} }
...@@ -899,64 +890,61 @@ static s32 ixgbe_write_eeprom_buffer_bit_bang(struct ixgbe_hw *hw, u16 offset, ...@@ -899,64 +890,61 @@ static s32 ixgbe_write_eeprom_buffer_bit_bang(struct ixgbe_hw *hw, u16 offset,
/* Prepare the EEPROM for writing */ /* Prepare the EEPROM for writing */
status = ixgbe_acquire_eeprom(hw); status = ixgbe_acquire_eeprom(hw);
if (status)
return status;
if (status == 0) { if (ixgbe_ready_eeprom(hw) != 0) {
if (ixgbe_ready_eeprom(hw) != 0) { ixgbe_release_eeprom(hw);
ixgbe_release_eeprom(hw); return IXGBE_ERR_EEPROM;
status = IXGBE_ERR_EEPROM;
}
} }
if (status == 0) { for (i = 0; i < words; i++) {
for (i = 0; i < words; i++) { ixgbe_standby_eeprom(hw);
ixgbe_standby_eeprom(hw);
/* Send the WRITE ENABLE command (8 bit opcode) */
ixgbe_shift_out_eeprom_bits(hw,
IXGBE_EEPROM_WREN_OPCODE_SPI,
IXGBE_EEPROM_OPCODE_BITS);
/* Send the WRITE ENABLE command (8 bit opcode ) */ ixgbe_standby_eeprom(hw);
ixgbe_shift_out_eeprom_bits(hw,
IXGBE_EEPROM_WREN_OPCODE_SPI,
IXGBE_EEPROM_OPCODE_BITS);
ixgbe_standby_eeprom(hw); /* Some SPI eeproms use the 8th address bit embedded
* in the opcode
*/
if ((hw->eeprom.address_bits == 8) &&
((offset + i) >= 128))
write_opcode |= IXGBE_EEPROM_A8_OPCODE_SPI;
/* /* Send the Write command (8-bit opcode + addr) */
* Some SPI eeproms use the 8th address bit embedded ixgbe_shift_out_eeprom_bits(hw, write_opcode,
* in the opcode IXGBE_EEPROM_OPCODE_BITS);
*/ ixgbe_shift_out_eeprom_bits(hw, (u16)((offset + i) * 2),
if ((hw->eeprom.address_bits == 8) && hw->eeprom.address_bits);
((offset + i) >= 128))
write_opcode |= IXGBE_EEPROM_A8_OPCODE_SPI; page_size = hw->eeprom.word_page_size;
/* Send the Write command (8-bit opcode + addr) */ /* Send the data in burst via SPI */
ixgbe_shift_out_eeprom_bits(hw, write_opcode, do {
IXGBE_EEPROM_OPCODE_BITS); word = data[i];
ixgbe_shift_out_eeprom_bits(hw, (u16)((offset + i) * 2), word = (word >> 8) | (word << 8);
hw->eeprom.address_bits); ixgbe_shift_out_eeprom_bits(hw, word, 16);
page_size = hw->eeprom.word_page_size; if (page_size == 0)
break;
/* Send the data in burst via SPI*/
do { /* do not wrap around page */
word = data[i]; if (((offset + i) & (page_size - 1)) ==
word = (word >> 8) | (word << 8); (page_size - 1))
ixgbe_shift_out_eeprom_bits(hw, word, 16); break;
} while (++i < words);
if (page_size == 0)
break; ixgbe_standby_eeprom(hw);
usleep_range(10000, 20000);
/* do not wrap around page */
if (((offset + i) & (page_size - 1)) ==
(page_size - 1))
break;
} while (++i < words);
ixgbe_standby_eeprom(hw);
usleep_range(10000, 20000);
}
/* Done with writing - release the EEPROM */
ixgbe_release_eeprom(hw);
} }
/* Done with writing - release the EEPROM */
ixgbe_release_eeprom(hw);
return status; return 0;
} }
/** /**
...@@ -970,19 +958,12 @@ static s32 ixgbe_write_eeprom_buffer_bit_bang(struct ixgbe_hw *hw, u16 offset, ...@@ -970,19 +958,12 @@ static s32 ixgbe_write_eeprom_buffer_bit_bang(struct ixgbe_hw *hw, u16 offset,
**/ **/
s32 ixgbe_write_eeprom_generic(struct ixgbe_hw *hw, u16 offset, u16 data) s32 ixgbe_write_eeprom_generic(struct ixgbe_hw *hw, u16 offset, u16 data)
{ {
s32 status;
hw->eeprom.ops.init_params(hw); hw->eeprom.ops.init_params(hw);
if (offset >= hw->eeprom.word_size) { if (offset >= hw->eeprom.word_size)
status = IXGBE_ERR_EEPROM; return IXGBE_ERR_EEPROM;
goto out;
}
status = ixgbe_write_eeprom_buffer_bit_bang(hw, offset, 1, &data); return ixgbe_write_eeprom_buffer_bit_bang(hw, offset, 1, &data);
out:
return status;
} }
/** /**
...@@ -997,20 +978,16 @@ s32 ixgbe_write_eeprom_generic(struct ixgbe_hw *hw, u16 offset, u16 data) ...@@ -997,20 +978,16 @@ s32 ixgbe_write_eeprom_generic(struct ixgbe_hw *hw, u16 offset, u16 data)
s32 ixgbe_read_eeprom_buffer_bit_bang_generic(struct ixgbe_hw *hw, u16 offset, s32 ixgbe_read_eeprom_buffer_bit_bang_generic(struct ixgbe_hw *hw, u16 offset,
u16 words, u16 *data) u16 words, u16 *data)
{ {
s32 status = 0; s32 status;
u16 i, count; u16 i, count;
hw->eeprom.ops.init_params(hw); hw->eeprom.ops.init_params(hw);
if (words == 0) { if (words == 0)
status = IXGBE_ERR_INVALID_ARGUMENT; return IXGBE_ERR_INVALID_ARGUMENT;
goto out;
}
if (offset + words > hw->eeprom.word_size) { if (offset + words > hw->eeprom.word_size)
status = IXGBE_ERR_EEPROM; return IXGBE_ERR_EEPROM;
goto out;
}
/* /*
* We cannot hold synchronization semaphores for too long * We cannot hold synchronization semaphores for too long
...@@ -1024,12 +1001,11 @@ s32 ixgbe_read_eeprom_buffer_bit_bang_generic(struct ixgbe_hw *hw, u16 offset, ...@@ -1024,12 +1001,11 @@ s32 ixgbe_read_eeprom_buffer_bit_bang_generic(struct ixgbe_hw *hw, u16 offset,
status = ixgbe_read_eeprom_buffer_bit_bang(hw, offset + i, status = ixgbe_read_eeprom_buffer_bit_bang(hw, offset + i,
count, &data[i]); count, &data[i]);
if (status != 0) if (status)
break; return status;
} }
out: return 0;
return status;
} }
/** /**
...@@ -1051,41 +1027,38 @@ static s32 ixgbe_read_eeprom_buffer_bit_bang(struct ixgbe_hw *hw, u16 offset, ...@@ -1051,41 +1027,38 @@ static s32 ixgbe_read_eeprom_buffer_bit_bang(struct ixgbe_hw *hw, u16 offset,
/* Prepare the EEPROM for reading */ /* Prepare the EEPROM for reading */
status = ixgbe_acquire_eeprom(hw); status = ixgbe_acquire_eeprom(hw);
if (status)
return status;
if (status == 0) { if (ixgbe_ready_eeprom(hw) != 0) {
if (ixgbe_ready_eeprom(hw) != 0) { ixgbe_release_eeprom(hw);
ixgbe_release_eeprom(hw); return IXGBE_ERR_EEPROM;
status = IXGBE_ERR_EEPROM;
}
} }
if (status == 0) { for (i = 0; i < words; i++) {
for (i = 0; i < words; i++) { ixgbe_standby_eeprom(hw);
ixgbe_standby_eeprom(hw); /* Some SPI eeproms use the 8th address bit embedded
/* * in the opcode
* Some SPI eeproms use the 8th address bit embedded */
* in the opcode if ((hw->eeprom.address_bits == 8) &&
*/ ((offset + i) >= 128))
if ((hw->eeprom.address_bits == 8) && read_opcode |= IXGBE_EEPROM_A8_OPCODE_SPI;
((offset + i) >= 128))
read_opcode |= IXGBE_EEPROM_A8_OPCODE_SPI;
/* Send the READ command (opcode + addr) */
ixgbe_shift_out_eeprom_bits(hw, read_opcode,
IXGBE_EEPROM_OPCODE_BITS);
ixgbe_shift_out_eeprom_bits(hw, (u16)((offset + i) * 2),
hw->eeprom.address_bits);
/* Read the data. */
word_in = ixgbe_shift_in_eeprom_bits(hw, 16);
data[i] = (word_in >> 8) | (word_in << 8);
}
/* End this read operation */ /* Send the READ command (opcode + addr) */
ixgbe_release_eeprom(hw); ixgbe_shift_out_eeprom_bits(hw, read_opcode,
IXGBE_EEPROM_OPCODE_BITS);
ixgbe_shift_out_eeprom_bits(hw, (u16)((offset + i) * 2),
hw->eeprom.address_bits);
/* Read the data. */
word_in = ixgbe_shift_in_eeprom_bits(hw, 16);
data[i] = (word_in >> 8) | (word_in << 8);
} }
return status; /* End this read operation */
ixgbe_release_eeprom(hw);
return 0;
} }
/** /**
...@@ -1099,19 +1072,12 @@ static s32 ixgbe_read_eeprom_buffer_bit_bang(struct ixgbe_hw *hw, u16 offset, ...@@ -1099,19 +1072,12 @@ static s32 ixgbe_read_eeprom_buffer_bit_bang(struct ixgbe_hw *hw, u16 offset,
s32 ixgbe_read_eeprom_bit_bang_generic(struct ixgbe_hw *hw, u16 offset, s32 ixgbe_read_eeprom_bit_bang_generic(struct ixgbe_hw *hw, u16 offset,
u16 *data) u16 *data)
{ {
s32 status;
hw->eeprom.ops.init_params(hw); hw->eeprom.ops.init_params(hw);
if (offset >= hw->eeprom.word_size) { if (offset >= hw->eeprom.word_size)
status = IXGBE_ERR_EEPROM; return IXGBE_ERR_EEPROM;
goto out;
}
status = ixgbe_read_eeprom_buffer_bit_bang(hw, offset, 1, data);
out: return ixgbe_read_eeprom_buffer_bit_bang(hw, offset, 1, data);
return status;
} }
/** /**
...@@ -1127,20 +1093,16 @@ s32 ixgbe_read_eerd_buffer_generic(struct ixgbe_hw *hw, u16 offset, ...@@ -1127,20 +1093,16 @@ s32 ixgbe_read_eerd_buffer_generic(struct ixgbe_hw *hw, u16 offset,
u16 words, u16 *data) u16 words, u16 *data)
{ {
u32 eerd; u32 eerd;
s32 status = 0; s32 status;
u32 i; u32 i;
hw->eeprom.ops.init_params(hw); hw->eeprom.ops.init_params(hw);
if (words == 0) { if (words == 0)
status = IXGBE_ERR_INVALID_ARGUMENT; return IXGBE_ERR_INVALID_ARGUMENT;
goto out;
}
if (offset >= hw->eeprom.word_size) { if (offset >= hw->eeprom.word_size)
status = IXGBE_ERR_EEPROM; return IXGBE_ERR_EEPROM;
goto out;
}
for (i = 0; i < words; i++) { for (i = 0; i < words; i++) {
eerd = ((offset + i) << IXGBE_EEPROM_RW_ADDR_SHIFT) | eerd = ((offset + i) << IXGBE_EEPROM_RW_ADDR_SHIFT) |
...@@ -1154,11 +1116,11 @@ s32 ixgbe_read_eerd_buffer_generic(struct ixgbe_hw *hw, u16 offset, ...@@ -1154,11 +1116,11 @@ s32 ixgbe_read_eerd_buffer_generic(struct ixgbe_hw *hw, u16 offset,
IXGBE_EEPROM_RW_REG_DATA); IXGBE_EEPROM_RW_REG_DATA);
} else { } else {
hw_dbg(hw, "Eeprom read timed out\n"); hw_dbg(hw, "Eeprom read timed out\n");
goto out; return status;
} }
} }
out:
return status; return 0;
} }
/** /**
...@@ -1174,7 +1136,7 @@ static s32 ixgbe_detect_eeprom_page_size_generic(struct ixgbe_hw *hw, ...@@ -1174,7 +1136,7 @@ static s32 ixgbe_detect_eeprom_page_size_generic(struct ixgbe_hw *hw,
u16 offset) u16 offset)
{ {
u16 data[IXGBE_EEPROM_PAGE_SIZE_MAX]; u16 data[IXGBE_EEPROM_PAGE_SIZE_MAX];
s32 status = 0; s32 status;
u16 i; u16 i;
for (i = 0; i < IXGBE_EEPROM_PAGE_SIZE_MAX; i++) for (i = 0; i < IXGBE_EEPROM_PAGE_SIZE_MAX; i++)
...@@ -1184,12 +1146,12 @@ static s32 ixgbe_detect_eeprom_page_size_generic(struct ixgbe_hw *hw, ...@@ -1184,12 +1146,12 @@ static s32 ixgbe_detect_eeprom_page_size_generic(struct ixgbe_hw *hw,
status = ixgbe_write_eeprom_buffer_bit_bang(hw, offset, status = ixgbe_write_eeprom_buffer_bit_bang(hw, offset,
IXGBE_EEPROM_PAGE_SIZE_MAX, data); IXGBE_EEPROM_PAGE_SIZE_MAX, data);
hw->eeprom.word_page_size = 0; hw->eeprom.word_page_size = 0;
if (status != 0) if (status)
goto out; return status;
status = ixgbe_read_eeprom_buffer_bit_bang(hw, offset, 1, data); status = ixgbe_read_eeprom_buffer_bit_bang(hw, offset, 1, data);
if (status != 0) if (status)
goto out; return status;
/* /*
* When writing in burst more than the actual page size * When writing in burst more than the actual page size
...@@ -1199,8 +1161,7 @@ static s32 ixgbe_detect_eeprom_page_size_generic(struct ixgbe_hw *hw, ...@@ -1199,8 +1161,7 @@ static s32 ixgbe_detect_eeprom_page_size_generic(struct ixgbe_hw *hw,
hw_dbg(hw, "Detected EEPROM page size = %d words.\n", hw_dbg(hw, "Detected EEPROM page size = %d words.\n",
hw->eeprom.word_page_size); hw->eeprom.word_page_size);
out: return 0;
return status;
} }
/** /**
...@@ -1229,20 +1190,16 @@ s32 ixgbe_write_eewr_buffer_generic(struct ixgbe_hw *hw, u16 offset, ...@@ -1229,20 +1190,16 @@ s32 ixgbe_write_eewr_buffer_generic(struct ixgbe_hw *hw, u16 offset,
u16 words, u16 *data) u16 words, u16 *data)
{ {
u32 eewr; u32 eewr;
s32 status = 0; s32 status;
u16 i; u16 i;
hw->eeprom.ops.init_params(hw); hw->eeprom.ops.init_params(hw);
if (words == 0) { if (words == 0)
status = IXGBE_ERR_INVALID_ARGUMENT; return IXGBE_ERR_INVALID_ARGUMENT;
goto out;
}
if (offset >= hw->eeprom.word_size) { if (offset >= hw->eeprom.word_size)
status = IXGBE_ERR_EEPROM; return IXGBE_ERR_EEPROM;
goto out;
}
for (i = 0; i < words; i++) { for (i = 0; i < words; i++) {
eewr = ((offset + i) << IXGBE_EEPROM_RW_ADDR_SHIFT) | eewr = ((offset + i) << IXGBE_EEPROM_RW_ADDR_SHIFT) |
...@@ -1250,22 +1207,21 @@ s32 ixgbe_write_eewr_buffer_generic(struct ixgbe_hw *hw, u16 offset, ...@@ -1250,22 +1207,21 @@ s32 ixgbe_write_eewr_buffer_generic(struct ixgbe_hw *hw, u16 offset,
IXGBE_EEPROM_RW_REG_START; IXGBE_EEPROM_RW_REG_START;
status = ixgbe_poll_eerd_eewr_done(hw, IXGBE_NVM_POLL_WRITE); status = ixgbe_poll_eerd_eewr_done(hw, IXGBE_NVM_POLL_WRITE);
if (status != 0) { if (status) {
hw_dbg(hw, "Eeprom write EEWR timed out\n"); hw_dbg(hw, "Eeprom write EEWR timed out\n");
goto out; return status;
} }
IXGBE_WRITE_REG(hw, IXGBE_EEWR, eewr); IXGBE_WRITE_REG(hw, IXGBE_EEWR, eewr);
status = ixgbe_poll_eerd_eewr_done(hw, IXGBE_NVM_POLL_WRITE); status = ixgbe_poll_eerd_eewr_done(hw, IXGBE_NVM_POLL_WRITE);
if (status != 0) { if (status) {
hw_dbg(hw, "Eeprom write EEWR timed out\n"); hw_dbg(hw, "Eeprom write EEWR timed out\n");
goto out; return status;
} }
} }
out: return 0;
return status;
} }
/** /**
...@@ -1293,7 +1249,6 @@ static s32 ixgbe_poll_eerd_eewr_done(struct ixgbe_hw *hw, u32 ee_reg) ...@@ -1293,7 +1249,6 @@ static s32 ixgbe_poll_eerd_eewr_done(struct ixgbe_hw *hw, u32 ee_reg)
{ {
u32 i; u32 i;
u32 reg; u32 reg;
s32 status = IXGBE_ERR_EEPROM;
for (i = 0; i < IXGBE_EERD_EEWR_ATTEMPTS; i++) { for (i = 0; i < IXGBE_EERD_EEWR_ATTEMPTS; i++) {
if (ee_reg == IXGBE_NVM_POLL_READ) if (ee_reg == IXGBE_NVM_POLL_READ)
...@@ -1302,12 +1257,11 @@ static s32 ixgbe_poll_eerd_eewr_done(struct ixgbe_hw *hw, u32 ee_reg) ...@@ -1302,12 +1257,11 @@ static s32 ixgbe_poll_eerd_eewr_done(struct ixgbe_hw *hw, u32 ee_reg)
reg = IXGBE_READ_REG(hw, IXGBE_EEWR); reg = IXGBE_READ_REG(hw, IXGBE_EEWR);
if (reg & IXGBE_EEPROM_RW_REG_DONE) { if (reg & IXGBE_EEPROM_RW_REG_DONE) {
status = 0; return 0;
break;
} }
udelay(5); udelay(5);
} }
return status; return IXGBE_ERR_EEPROM;
} }
/** /**
...@@ -1319,47 +1273,42 @@ static s32 ixgbe_poll_eerd_eewr_done(struct ixgbe_hw *hw, u32 ee_reg) ...@@ -1319,47 +1273,42 @@ static s32 ixgbe_poll_eerd_eewr_done(struct ixgbe_hw *hw, u32 ee_reg)
**/ **/
static s32 ixgbe_acquire_eeprom(struct ixgbe_hw *hw) static s32 ixgbe_acquire_eeprom(struct ixgbe_hw *hw)
{ {
s32 status = 0;
u32 eec; u32 eec;
u32 i; u32 i;
if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) != 0) if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) != 0)
status = IXGBE_ERR_SWFW_SYNC; return IXGBE_ERR_SWFW_SYNC;
if (status == 0) { eec = IXGBE_READ_REG(hw, IXGBE_EEC);
eec = IXGBE_READ_REG(hw, IXGBE_EEC);
/* Request EEPROM Access */
eec |= IXGBE_EEC_REQ;
IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
for (i = 0; i < IXGBE_EEPROM_GRANT_ATTEMPTS; i++) { /* Request EEPROM Access */
eec = IXGBE_READ_REG(hw, IXGBE_EEC); eec |= IXGBE_EEC_REQ;
if (eec & IXGBE_EEC_GNT) IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
break;
udelay(5);
}
/* Release if grant not acquired */ for (i = 0; i < IXGBE_EEPROM_GRANT_ATTEMPTS; i++) {
if (!(eec & IXGBE_EEC_GNT)) { eec = IXGBE_READ_REG(hw, IXGBE_EEC);
eec &= ~IXGBE_EEC_REQ; if (eec & IXGBE_EEC_GNT)
IXGBE_WRITE_REG(hw, IXGBE_EEC, eec); break;
hw_dbg(hw, "Could not acquire EEPROM grant\n"); udelay(5);
}
hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM); /* Release if grant not acquired */
status = IXGBE_ERR_EEPROM; if (!(eec & IXGBE_EEC_GNT)) {
} eec &= ~IXGBE_EEC_REQ;
IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
hw_dbg(hw, "Could not acquire EEPROM grant\n");
/* Setup EEPROM for Read/Write */ hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
if (status == 0) { return IXGBE_ERR_EEPROM;
/* Clear CS and SK */
eec &= ~(IXGBE_EEC_CS | IXGBE_EEC_SK);
IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
IXGBE_WRITE_FLUSH(hw);
udelay(1);
}
} }
return status;
/* Setup EEPROM for Read/Write */
/* Clear CS and SK */
eec &= ~(IXGBE_EEC_CS | IXGBE_EEC_SK);
IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
IXGBE_WRITE_FLUSH(hw);
udelay(1);
return 0;
} }
/** /**
...@@ -1370,7 +1319,6 @@ static s32 ixgbe_acquire_eeprom(struct ixgbe_hw *hw) ...@@ -1370,7 +1319,6 @@ static s32 ixgbe_acquire_eeprom(struct ixgbe_hw *hw)
**/ **/
static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw) static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw)
{ {
s32 status = IXGBE_ERR_EEPROM;
u32 timeout = 2000; u32 timeout = 2000;
u32 i; u32 i;
u32 swsm; u32 swsm;
...@@ -1382,17 +1330,14 @@ static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw) ...@@ -1382,17 +1330,14 @@ static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw)
* set and we have the semaphore * set and we have the semaphore
*/ */
swsm = IXGBE_READ_REG(hw, IXGBE_SWSM); swsm = IXGBE_READ_REG(hw, IXGBE_SWSM);
if (!(swsm & IXGBE_SWSM_SMBI)) { if (!(swsm & IXGBE_SWSM_SMBI))
status = 0;
break; break;
}
usleep_range(50, 100); usleep_range(50, 100);
} }
if (i == timeout) { if (i == timeout) {
hw_dbg(hw, "Driver can't access the Eeprom - SMBI Semaphore not granted.\n"); hw_dbg(hw, "Driver can't access the Eeprom - SMBI Semaphore not granted.\n");
/* /* this release is particularly important because our attempts
* this release is particularly important because our attempts
* above to get the semaphore may have succeeded, and if there * above to get the semaphore may have succeeded, and if there
* was a timeout, we should unconditionally clear the semaphore * was a timeout, we should unconditionally clear the semaphore
* bits to free the driver to make progress * bits to free the driver to make progress
...@@ -1400,50 +1345,45 @@ static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw) ...@@ -1400,50 +1345,45 @@ static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw)
ixgbe_release_eeprom_semaphore(hw); ixgbe_release_eeprom_semaphore(hw);
usleep_range(50, 100); usleep_range(50, 100);
/* /* one last try
* one last try
* If the SMBI bit is 0 when we read it, then the bit will be * If the SMBI bit is 0 when we read it, then the bit will be
* set and we have the semaphore * set and we have the semaphore
*/ */
swsm = IXGBE_READ_REG(hw, IXGBE_SWSM); swsm = IXGBE_READ_REG(hw, IXGBE_SWSM);
if (!(swsm & IXGBE_SWSM_SMBI)) if (swsm & IXGBE_SWSM_SMBI) {
status = 0; hw_dbg(hw, "Software semaphore SMBI between device drivers not granted.\n");
return IXGBE_ERR_EEPROM;
}
} }
/* Now get the semaphore between SW/FW through the SWESMBI bit */ /* Now get the semaphore between SW/FW through the SWESMBI bit */
if (status == 0) { for (i = 0; i < timeout; i++) {
for (i = 0; i < timeout; i++) { swsm = IXGBE_READ_REG(hw, IXGBE_SWSM);
swsm = IXGBE_READ_REG(hw, IXGBE_SWSM);
/* Set the SW EEPROM semaphore bit to request access */ /* Set the SW EEPROM semaphore bit to request access */
swsm |= IXGBE_SWSM_SWESMBI; swsm |= IXGBE_SWSM_SWESMBI;
IXGBE_WRITE_REG(hw, IXGBE_SWSM, swsm); IXGBE_WRITE_REG(hw, IXGBE_SWSM, swsm);
/* /* If we set the bit successfully then we got the
* If we set the bit successfully then we got the * semaphore.
* semaphore. */
*/ swsm = IXGBE_READ_REG(hw, IXGBE_SWSM);
swsm = IXGBE_READ_REG(hw, IXGBE_SWSM); if (swsm & IXGBE_SWSM_SWESMBI)
if (swsm & IXGBE_SWSM_SWESMBI) break;
break;
usleep_range(50, 100); usleep_range(50, 100);
} }
/* /* Release semaphores and return error if SW EEPROM semaphore
* Release semaphores and return error if SW EEPROM semaphore * was not granted because we don't have access to the EEPROM
* was not granted because we don't have access to the EEPROM */
*/ if (i >= timeout) {
if (i >= timeout) { hw_dbg(hw, "SWESMBI Software EEPROM semaphore not granted.\n");
hw_dbg(hw, "SWESMBI Software EEPROM semaphore not granted.\n"); ixgbe_release_eeprom_semaphore(hw);
ixgbe_release_eeprom_semaphore(hw); return IXGBE_ERR_EEPROM;
status = IXGBE_ERR_EEPROM;
}
} else {
hw_dbg(hw, "Software semaphore SMBI between device drivers not granted.\n");
} }
return status; return 0;
} }
/** /**
...@@ -1470,7 +1410,6 @@ static void ixgbe_release_eeprom_semaphore(struct ixgbe_hw *hw) ...@@ -1470,7 +1410,6 @@ static void ixgbe_release_eeprom_semaphore(struct ixgbe_hw *hw)
**/ **/
static s32 ixgbe_ready_eeprom(struct ixgbe_hw *hw) static s32 ixgbe_ready_eeprom(struct ixgbe_hw *hw)
{ {
s32 status = 0;
u16 i; u16 i;
u8 spi_stat_reg; u8 spi_stat_reg;
...@@ -1497,10 +1436,10 @@ static s32 ixgbe_ready_eeprom(struct ixgbe_hw *hw) ...@@ -1497,10 +1436,10 @@ static s32 ixgbe_ready_eeprom(struct ixgbe_hw *hw)
*/ */
if (i >= IXGBE_EEPROM_MAX_RETRY_SPI) { if (i >= IXGBE_EEPROM_MAX_RETRY_SPI) {
hw_dbg(hw, "SPI EEPROM Status error\n"); hw_dbg(hw, "SPI EEPROM Status error\n");
status = IXGBE_ERR_EEPROM; return IXGBE_ERR_EEPROM;
} }
return status; return 0;
} }
/** /**
...@@ -2099,17 +2038,14 @@ s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw) ...@@ -2099,17 +2038,14 @@ s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw)
**/ **/
s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw) s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)
{ {
s32 ret_val = 0;
u32 mflcn_reg, fccfg_reg; u32 mflcn_reg, fccfg_reg;
u32 reg; u32 reg;
u32 fcrtl, fcrth; u32 fcrtl, fcrth;
int i; int i;
/* Validate the water mark configuration. */ /* Validate the water mark configuration. */
if (!hw->fc.pause_time) { if (!hw->fc.pause_time)
ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; return IXGBE_ERR_INVALID_LINK_SETTINGS;
goto out;
}
/* Low water mark of zero causes XOFF floods */ /* Low water mark of zero causes XOFF floods */
for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
...@@ -2118,8 +2054,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw) ...@@ -2118,8 +2054,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)
if (!hw->fc.low_water[i] || if (!hw->fc.low_water[i] ||
hw->fc.low_water[i] >= hw->fc.high_water[i]) { hw->fc.low_water[i] >= hw->fc.high_water[i]) {
hw_dbg(hw, "Invalid water mark configuration\n"); hw_dbg(hw, "Invalid water mark configuration\n");
ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; return IXGBE_ERR_INVALID_LINK_SETTINGS;
goto out;
} }
} }
} }
...@@ -2176,8 +2111,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw) ...@@ -2176,8 +2111,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)
break; break;
default: default:
hw_dbg(hw, "Flow control param set incorrectly\n"); hw_dbg(hw, "Flow control param set incorrectly\n");
ret_val = IXGBE_ERR_CONFIG; return IXGBE_ERR_CONFIG;
goto out;
} }
/* Set 802.3x based flow control settings. */ /* Set 802.3x based flow control settings. */
...@@ -2213,8 +2147,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw) ...@@ -2213,8 +2147,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)
IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2); IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
out: return 0;
return ret_val;
} }
/** /**
...@@ -2275,7 +2208,7 @@ static s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg, ...@@ -2275,7 +2208,7 @@ static s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
static s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw) static s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw)
{ {
u32 pcs_anadv_reg, pcs_lpab_reg, linkstat; u32 pcs_anadv_reg, pcs_lpab_reg, linkstat;
s32 ret_val = IXGBE_ERR_FC_NOT_NEGOTIATED; s32 ret_val;
/* /*
* On multispeed fiber at 1g, bail out if * On multispeed fiber at 1g, bail out if
...@@ -2286,7 +2219,7 @@ static s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw) ...@@ -2286,7 +2219,7 @@ static s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw)
linkstat = IXGBE_READ_REG(hw, IXGBE_PCS1GLSTA); linkstat = IXGBE_READ_REG(hw, IXGBE_PCS1GLSTA);
if ((!!(linkstat & IXGBE_PCS1GLSTA_AN_COMPLETE) == 0) || if ((!!(linkstat & IXGBE_PCS1GLSTA_AN_COMPLETE) == 0) ||
(!!(linkstat & IXGBE_PCS1GLSTA_AN_TIMED_OUT) == 1)) (!!(linkstat & IXGBE_PCS1GLSTA_AN_TIMED_OUT) == 1))
goto out; return IXGBE_ERR_FC_NOT_NEGOTIATED;
pcs_anadv_reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA); pcs_anadv_reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA);
pcs_lpab_reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANLP); pcs_lpab_reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANLP);
...@@ -2297,7 +2230,6 @@ static s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw) ...@@ -2297,7 +2230,6 @@ static s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw)
IXGBE_PCS1GANA_SYM_PAUSE, IXGBE_PCS1GANA_SYM_PAUSE,
IXGBE_PCS1GANA_ASM_PAUSE); IXGBE_PCS1GANA_ASM_PAUSE);
out:
return ret_val; return ret_val;
} }
...@@ -2310,7 +2242,7 @@ static s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw) ...@@ -2310,7 +2242,7 @@ static s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw)
static s32 ixgbe_fc_autoneg_backplane(struct ixgbe_hw *hw) static s32 ixgbe_fc_autoneg_backplane(struct ixgbe_hw *hw)
{ {
u32 links2, anlp1_reg, autoc_reg, links; u32 links2, anlp1_reg, autoc_reg, links;
s32 ret_val = IXGBE_ERR_FC_NOT_NEGOTIATED; s32 ret_val;
/* /*
* On backplane, bail out if * On backplane, bail out if
...@@ -2319,12 +2251,12 @@ static s32 ixgbe_fc_autoneg_backplane(struct ixgbe_hw *hw) ...@@ -2319,12 +2251,12 @@ static s32 ixgbe_fc_autoneg_backplane(struct ixgbe_hw *hw)
*/ */
links = IXGBE_READ_REG(hw, IXGBE_LINKS); links = IXGBE_READ_REG(hw, IXGBE_LINKS);
if ((links & IXGBE_LINKS_KX_AN_COMP) == 0) if ((links & IXGBE_LINKS_KX_AN_COMP) == 0)
goto out; return IXGBE_ERR_FC_NOT_NEGOTIATED;
if (hw->mac.type == ixgbe_mac_82599EB) { if (hw->mac.type == ixgbe_mac_82599EB) {
links2 = IXGBE_READ_REG(hw, IXGBE_LINKS2); links2 = IXGBE_READ_REG(hw, IXGBE_LINKS2);
if ((links2 & IXGBE_LINKS2_AN_SUPPORTED) == 0) if ((links2 & IXGBE_LINKS2_AN_SUPPORTED) == 0)
goto out; return IXGBE_ERR_FC_NOT_NEGOTIATED;
} }
/* /*
* Read the 10g AN autoc and LP ability registers and resolve * Read the 10g AN autoc and LP ability registers and resolve
...@@ -2337,7 +2269,6 @@ static s32 ixgbe_fc_autoneg_backplane(struct ixgbe_hw *hw) ...@@ -2337,7 +2269,6 @@ static s32 ixgbe_fc_autoneg_backplane(struct ixgbe_hw *hw)
anlp1_reg, IXGBE_AUTOC_SYM_PAUSE, IXGBE_AUTOC_ASM_PAUSE, anlp1_reg, IXGBE_AUTOC_SYM_PAUSE, IXGBE_AUTOC_ASM_PAUSE,
IXGBE_ANLP1_SYM_PAUSE, IXGBE_ANLP1_ASM_PAUSE); IXGBE_ANLP1_SYM_PAUSE, IXGBE_ANLP1_ASM_PAUSE);
out:
return ret_val; return ret_val;
} }
...@@ -2483,7 +2414,6 @@ static u32 ixgbe_pcie_timeout_poll(struct ixgbe_hw *hw) ...@@ -2483,7 +2414,6 @@ static u32 ixgbe_pcie_timeout_poll(struct ixgbe_hw *hw)
**/ **/
static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw) static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw)
{ {
s32 status = 0;
u32 i, poll; u32 i, poll;
u16 value; u16 value;
...@@ -2493,13 +2423,13 @@ static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw) ...@@ -2493,13 +2423,13 @@ static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw)
/* Exit if master requests are blocked */ /* Exit if master requests are blocked */
if (!(IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_GIO) || if (!(IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_GIO) ||
ixgbe_removed(hw->hw_addr)) ixgbe_removed(hw->hw_addr))
goto out; return 0;
/* Poll for master request bit to clear */ /* Poll for master request bit to clear */
for (i = 0; i < IXGBE_PCI_MASTER_DISABLE_TIMEOUT; i++) { for (i = 0; i < IXGBE_PCI_MASTER_DISABLE_TIMEOUT; i++) {
udelay(100); udelay(100);
if (!(IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_GIO)) if (!(IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_GIO))
goto out; return 0;
} }
/* /*
...@@ -2522,16 +2452,13 @@ static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw) ...@@ -2522,16 +2452,13 @@ static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw)
udelay(100); udelay(100);
value = ixgbe_read_pci_cfg_word(hw, IXGBE_PCI_DEVICE_STATUS); value = ixgbe_read_pci_cfg_word(hw, IXGBE_PCI_DEVICE_STATUS);
if (ixgbe_removed(hw->hw_addr)) if (ixgbe_removed(hw->hw_addr))
goto out; return 0;
if (!(value & IXGBE_PCI_DEVICE_STATUS_TRANSACTION_PENDING)) if (!(value & IXGBE_PCI_DEVICE_STATUS_TRANSACTION_PENDING))
goto out; return 0;
} }
hw_dbg(hw, "PCIe transaction pending bit also did not clear.\n"); hw_dbg(hw, "PCIe transaction pending bit also did not clear.\n");
status = IXGBE_ERR_MASTER_REQUESTS_PENDING; return IXGBE_ERR_MASTER_REQUESTS_PENDING;
out:
return status;
} }
/** /**
...@@ -2706,8 +2633,8 @@ s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index) ...@@ -2706,8 +2633,8 @@ s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index)
bool link_up = false; bool link_up = false;
u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL); u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
s32 ret_val = 0;
bool locked = false; bool locked = false;
s32 ret_val;
/* /*
* Link must be up to auto-blink the LEDs; * Link must be up to auto-blink the LEDs;
...@@ -2718,14 +2645,14 @@ s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index) ...@@ -2718,14 +2645,14 @@ s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index)
if (!link_up) { if (!link_up) {
ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &autoc_reg); ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &autoc_reg);
if (ret_val) if (ret_val)
goto out; return ret_val;
autoc_reg |= IXGBE_AUTOC_AN_RESTART; autoc_reg |= IXGBE_AUTOC_AN_RESTART;
autoc_reg |= IXGBE_AUTOC_FLU; autoc_reg |= IXGBE_AUTOC_FLU;
ret_val = hw->mac.ops.prot_autoc_write(hw, autoc_reg, locked); ret_val = hw->mac.ops.prot_autoc_write(hw, autoc_reg, locked);
if (ret_val) if (ret_val)
goto out; return ret_val;
IXGBE_WRITE_FLUSH(hw); IXGBE_WRITE_FLUSH(hw);
...@@ -2737,8 +2664,7 @@ s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index) ...@@ -2737,8 +2664,7 @@ s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index)
IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, led_reg); IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, led_reg);
IXGBE_WRITE_FLUSH(hw); IXGBE_WRITE_FLUSH(hw);
out: return 0;
return ret_val;
} }
/** /**
...@@ -2750,19 +2676,19 @@ s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index) ...@@ -2750,19 +2676,19 @@ s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index)
{ {
u32 autoc_reg = 0; u32 autoc_reg = 0;
u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL); u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
s32 ret_val = 0;
bool locked = false; bool locked = false;
s32 ret_val;
ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &autoc_reg); ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &autoc_reg);
if (ret_val) if (ret_val)
goto out; return ret_val;
autoc_reg &= ~IXGBE_AUTOC_FLU; autoc_reg &= ~IXGBE_AUTOC_FLU;
autoc_reg |= IXGBE_AUTOC_AN_RESTART; autoc_reg |= IXGBE_AUTOC_AN_RESTART;
ret_val = hw->mac.ops.prot_autoc_write(hw, autoc_reg, locked); ret_val = hw->mac.ops.prot_autoc_write(hw, autoc_reg, locked);
if (ret_val) if (ret_val)
goto out; return ret_val;
led_reg &= ~IXGBE_LED_MODE_MASK(index); led_reg &= ~IXGBE_LED_MODE_MASK(index);
led_reg &= ~IXGBE_LED_BLINK(index); led_reg &= ~IXGBE_LED_BLINK(index);
...@@ -2770,8 +2696,7 @@ s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index) ...@@ -2770,8 +2696,7 @@ s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index)
IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, led_reg); IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, led_reg);
IXGBE_WRITE_FLUSH(hw); IXGBE_WRITE_FLUSH(hw);
out: return 0;
return ret_val;
} }
/** /**
...@@ -2863,7 +2788,7 @@ s32 ixgbe_get_san_mac_addr_generic(struct ixgbe_hw *hw, u8 *san_mac_addr) ...@@ -2863,7 +2788,7 @@ s32 ixgbe_get_san_mac_addr_generic(struct ixgbe_hw *hw, u8 *san_mac_addr)
**/ **/
u16 ixgbe_get_pcie_msix_count_generic(struct ixgbe_hw *hw) u16 ixgbe_get_pcie_msix_count_generic(struct ixgbe_hw *hw)
{ {
u16 msix_count = 1; u16 msix_count;
u16 max_msix_count; u16 max_msix_count;
u16 pcie_offset; u16 pcie_offset;
...@@ -2878,7 +2803,7 @@ u16 ixgbe_get_pcie_msix_count_generic(struct ixgbe_hw *hw) ...@@ -2878,7 +2803,7 @@ u16 ixgbe_get_pcie_msix_count_generic(struct ixgbe_hw *hw)
max_msix_count = IXGBE_MAX_MSIX_VECTORS_82599; max_msix_count = IXGBE_MAX_MSIX_VECTORS_82599;
break; break;
default: default:
return msix_count; return 1;
} }
msix_count = ixgbe_read_pci_cfg_word(hw, pcie_offset); msix_count = ixgbe_read_pci_cfg_word(hw, pcie_offset);
...@@ -2916,10 +2841,10 @@ s32 ixgbe_clear_vmdq_generic(struct ixgbe_hw *hw, u32 rar, u32 vmdq) ...@@ -2916,10 +2841,10 @@ s32 ixgbe_clear_vmdq_generic(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
mpsar_hi = IXGBE_READ_REG(hw, IXGBE_MPSAR_HI(rar)); mpsar_hi = IXGBE_READ_REG(hw, IXGBE_MPSAR_HI(rar));
if (ixgbe_removed(hw->hw_addr)) if (ixgbe_removed(hw->hw_addr))
goto done; return 0;
if (!mpsar_lo && !mpsar_hi) if (!mpsar_lo && !mpsar_hi)
goto done; return 0;
if (vmdq == IXGBE_CLEAR_VMDQ_ALL) { if (vmdq == IXGBE_CLEAR_VMDQ_ALL) {
if (mpsar_lo) { if (mpsar_lo) {
...@@ -2941,7 +2866,6 @@ s32 ixgbe_clear_vmdq_generic(struct ixgbe_hw *hw, u32 rar, u32 vmdq) ...@@ -2941,7 +2866,6 @@ s32 ixgbe_clear_vmdq_generic(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
/* was that the last pool using this rar? */ /* was that the last pool using this rar? */
if (mpsar_lo == 0 && mpsar_hi == 0 && rar != 0) if (mpsar_lo == 0 && mpsar_hi == 0 && rar != 0)
hw->mac.ops.clear_rar(hw, rar); hw->mac.ops.clear_rar(hw, rar);
done:
return 0; return 0;
} }
...@@ -3310,14 +3234,14 @@ s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 *wwnn_prefix, ...@@ -3310,14 +3234,14 @@ s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 *wwnn_prefix,
if ((alt_san_mac_blk_offset == 0) || if ((alt_san_mac_blk_offset == 0) ||
(alt_san_mac_blk_offset == 0xFFFF)) (alt_san_mac_blk_offset == 0xFFFF))
goto wwn_prefix_out; return 0;
/* check capability in alternative san mac address block */ /* check capability in alternative san mac address block */
offset = alt_san_mac_blk_offset + IXGBE_ALT_SAN_MAC_ADDR_CAPS_OFFSET; offset = alt_san_mac_blk_offset + IXGBE_ALT_SAN_MAC_ADDR_CAPS_OFFSET;
if (hw->eeprom.ops.read(hw, offset, &caps)) if (hw->eeprom.ops.read(hw, offset, &caps))
goto wwn_prefix_err; goto wwn_prefix_err;
if (!(caps & IXGBE_ALT_SAN_MAC_ADDR_CAPS_ALTWWN)) if (!(caps & IXGBE_ALT_SAN_MAC_ADDR_CAPS_ALTWWN))
goto wwn_prefix_out; return 0;
/* get the corresponding prefix for WWNN/WWPN */ /* get the corresponding prefix for WWNN/WWPN */
offset = alt_san_mac_blk_offset + IXGBE_ALT_SAN_MAC_ADDR_WWNN_OFFSET; offset = alt_san_mac_blk_offset + IXGBE_ALT_SAN_MAC_ADDR_WWNN_OFFSET;
...@@ -3328,7 +3252,6 @@ s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 *wwnn_prefix, ...@@ -3328,7 +3252,6 @@ s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 *wwnn_prefix,
if (hw->eeprom.ops.read(hw, offset, wwpn_prefix)) if (hw->eeprom.ops.read(hw, offset, wwpn_prefix))
goto wwn_prefix_err; goto wwn_prefix_err;
wwn_prefix_out:
return 0; return 0;
wwn_prefix_err: wwn_prefix_err:
...@@ -3522,21 +3445,17 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, ...@@ -3522,21 +3445,17 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
u32 hdr_size = sizeof(struct ixgbe_hic_hdr); u32 hdr_size = sizeof(struct ixgbe_hic_hdr);
u8 buf_len, dword_len; u8 buf_len, dword_len;
s32 ret_val = 0;
if (length == 0 || length & 0x3 || if (length == 0 || length & 0x3 ||
length > IXGBE_HI_MAX_BLOCK_BYTE_LENGTH) { length > IXGBE_HI_MAX_BLOCK_BYTE_LENGTH) {
hw_dbg(hw, "Buffer length failure.\n"); hw_dbg(hw, "Buffer length failure.\n");
ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND; return IXGBE_ERR_HOST_INTERFACE_COMMAND;
goto out;
} }
/* Check that the host interface is enabled. */ /* Check that the host interface is enabled. */
hicr = IXGBE_READ_REG(hw, IXGBE_HICR); hicr = IXGBE_READ_REG(hw, IXGBE_HICR);
if ((hicr & IXGBE_HICR_EN) == 0) { if ((hicr & IXGBE_HICR_EN) == 0) {
hw_dbg(hw, "IXGBE_HOST_EN bit disabled.\n"); hw_dbg(hw, "IXGBE_HOST_EN bit disabled.\n");
ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND; return IXGBE_ERR_HOST_INTERFACE_COMMAND;
goto out;
} }
/* Calculate length in DWORDs */ /* Calculate length in DWORDs */
...@@ -3564,8 +3483,7 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, ...@@ -3564,8 +3483,7 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
if (i == IXGBE_HI_COMMAND_TIMEOUT || if (i == IXGBE_HI_COMMAND_TIMEOUT ||
(!(IXGBE_READ_REG(hw, IXGBE_HICR) & IXGBE_HICR_SV))) { (!(IXGBE_READ_REG(hw, IXGBE_HICR) & IXGBE_HICR_SV))) {
hw_dbg(hw, "Command has failed with no status valid.\n"); hw_dbg(hw, "Command has failed with no status valid.\n");
ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND; return IXGBE_ERR_HOST_INTERFACE_COMMAND;
goto out;
} }
/* Calculate length in DWORDs */ /* Calculate length in DWORDs */
...@@ -3580,12 +3498,11 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, ...@@ -3580,12 +3498,11 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
/* If there is any thing in data position pull it in */ /* If there is any thing in data position pull it in */
buf_len = ((struct ixgbe_hic_hdr *)buffer)->buf_len; buf_len = ((struct ixgbe_hic_hdr *)buffer)->buf_len;
if (buf_len == 0) if (buf_len == 0)
goto out; return 0;
if (length < (buf_len + hdr_size)) { if (length < (buf_len + hdr_size)) {
hw_dbg(hw, "Buffer not large enough for reply message.\n"); hw_dbg(hw, "Buffer not large enough for reply message.\n");
ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND; return IXGBE_ERR_HOST_INTERFACE_COMMAND;
goto out;
} }
/* Calculate length in DWORDs, add 3 for odd lengths */ /* Calculate length in DWORDs, add 3 for odd lengths */
...@@ -3597,8 +3514,7 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, ...@@ -3597,8 +3514,7 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
le32_to_cpus(&buffer[bi]); le32_to_cpus(&buffer[bi]);
} }
out: return 0;
return ret_val;
} }
/** /**
...@@ -3619,12 +3535,10 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min, ...@@ -3619,12 +3535,10 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min,
{ {
struct ixgbe_hic_drv_info fw_cmd; struct ixgbe_hic_drv_info fw_cmd;
int i; int i;
s32 ret_val = 0; s32 ret_val;
if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM) != 0) { if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM))
ret_val = IXGBE_ERR_SWFW_SYNC; return IXGBE_ERR_SWFW_SYNC;
goto out;
}
fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO; fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO;
fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN; fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN;
...@@ -3656,7 +3570,6 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min, ...@@ -3656,7 +3570,6 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min,
} }
hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM); hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM);
out:
return ret_val; return ret_val;
} }
...@@ -3725,28 +3638,23 @@ static const u8 ixgbe_emc_therm_limit[4] = { ...@@ -3725,28 +3638,23 @@ static const u8 ixgbe_emc_therm_limit[4] = {
static s32 ixgbe_get_ets_data(struct ixgbe_hw *hw, u16 *ets_cfg, static s32 ixgbe_get_ets_data(struct ixgbe_hw *hw, u16 *ets_cfg,
u16 *ets_offset) u16 *ets_offset)
{ {
s32 status = 0; s32 status;
status = hw->eeprom.ops.read(hw, IXGBE_ETS_CFG, ets_offset); status = hw->eeprom.ops.read(hw, IXGBE_ETS_CFG, ets_offset);
if (status) if (status)
goto out; return status;
if ((*ets_offset == 0x0000) || (*ets_offset == 0xFFFF)) { if ((*ets_offset == 0x0000) || (*ets_offset == 0xFFFF))
status = IXGBE_NOT_IMPLEMENTED; return IXGBE_NOT_IMPLEMENTED;
goto out;
}
status = hw->eeprom.ops.read(hw, *ets_offset, ets_cfg); status = hw->eeprom.ops.read(hw, *ets_offset, ets_cfg);
if (status) if (status)
goto out; return status;
if ((*ets_cfg & IXGBE_ETS_TYPE_MASK) != IXGBE_ETS_TYPE_EMC_SHIFTED) { if ((*ets_cfg & IXGBE_ETS_TYPE_MASK) != IXGBE_ETS_TYPE_EMC_SHIFTED)
status = IXGBE_NOT_IMPLEMENTED; return IXGBE_NOT_IMPLEMENTED;
goto out;
}
out: return 0;
return status;
} }
/** /**
...@@ -3757,7 +3665,7 @@ static s32 ixgbe_get_ets_data(struct ixgbe_hw *hw, u16 *ets_cfg, ...@@ -3757,7 +3665,7 @@ static s32 ixgbe_get_ets_data(struct ixgbe_hw *hw, u16 *ets_cfg,
**/ **/
s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw) s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw)
{ {
s32 status = 0; s32 status;
u16 ets_offset; u16 ets_offset;
u16 ets_cfg; u16 ets_cfg;
u16 ets_sensor; u16 ets_sensor;
...@@ -3766,14 +3674,12 @@ s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw) ...@@ -3766,14 +3674,12 @@ s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw)
struct ixgbe_thermal_sensor_data *data = &hw->mac.thermal_sensor_data; struct ixgbe_thermal_sensor_data *data = &hw->mac.thermal_sensor_data;
/* Only support thermal sensors attached to physical port 0 */ /* Only support thermal sensors attached to physical port 0 */
if ((IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)) { if ((IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1))
status = IXGBE_NOT_IMPLEMENTED; return IXGBE_NOT_IMPLEMENTED;
goto out;
}
status = ixgbe_get_ets_data(hw, &ets_cfg, &ets_offset); status = ixgbe_get_ets_data(hw, &ets_cfg, &ets_offset);
if (status) if (status)
goto out; return status;
num_sensors = (ets_cfg & IXGBE_ETS_NUM_SENSORS_MASK); num_sensors = (ets_cfg & IXGBE_ETS_NUM_SENSORS_MASK);
if (num_sensors > IXGBE_MAX_SENSORS) if (num_sensors > IXGBE_MAX_SENSORS)
...@@ -3786,7 +3692,7 @@ s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw) ...@@ -3786,7 +3692,7 @@ s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw)
status = hw->eeprom.ops.read(hw, (ets_offset + 1 + i), status = hw->eeprom.ops.read(hw, (ets_offset + 1 + i),
&ets_sensor); &ets_sensor);
if (status) if (status)
goto out; return status;
sensor_index = ((ets_sensor & IXGBE_ETS_DATA_INDEX_MASK) >> sensor_index = ((ets_sensor & IXGBE_ETS_DATA_INDEX_MASK) >>
IXGBE_ETS_DATA_INDEX_SHIFT); IXGBE_ETS_DATA_INDEX_SHIFT);
...@@ -3799,11 +3705,11 @@ s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw) ...@@ -3799,11 +3705,11 @@ s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw)
IXGBE_I2C_THERMAL_SENSOR_ADDR, IXGBE_I2C_THERMAL_SENSOR_ADDR,
&data->sensor[i].temp); &data->sensor[i].temp);
if (status) if (status)
goto out; return status;
} }
} }
out:
return status; return 0;
} }
/** /**
...@@ -3815,7 +3721,7 @@ s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw) ...@@ -3815,7 +3721,7 @@ s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw)
**/ **/
s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw) s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw)
{ {
s32 status = 0; s32 status;
u16 ets_offset; u16 ets_offset;
u16 ets_cfg; u16 ets_cfg;
u16 ets_sensor; u16 ets_sensor;
...@@ -3828,14 +3734,12 @@ s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw) ...@@ -3828,14 +3734,12 @@ s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw)
memset(data, 0, sizeof(struct ixgbe_thermal_sensor_data)); memset(data, 0, sizeof(struct ixgbe_thermal_sensor_data));
/* Only support thermal sensors attached to physical port 0 */ /* Only support thermal sensors attached to physical port 0 */
if ((IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)) { if ((IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1))
status = IXGBE_NOT_IMPLEMENTED; return IXGBE_NOT_IMPLEMENTED;
goto out;
}
status = ixgbe_get_ets_data(hw, &ets_cfg, &ets_offset); status = ixgbe_get_ets_data(hw, &ets_cfg, &ets_offset);
if (status) if (status)
goto out; return status;
low_thresh_delta = ((ets_cfg & IXGBE_ETS_LTHRES_DELTA_MASK) >> low_thresh_delta = ((ets_cfg & IXGBE_ETS_LTHRES_DELTA_MASK) >>
IXGBE_ETS_LTHRES_DELTA_SHIFT); IXGBE_ETS_LTHRES_DELTA_SHIFT);
...@@ -3869,7 +3773,7 @@ s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw) ...@@ -3869,7 +3773,7 @@ s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw)
data->sensor[i].caution_thresh = therm_limit; data->sensor[i].caution_thresh = therm_limit;
data->sensor[i].max_op_thresh = therm_limit - low_thresh_delta; data->sensor[i].max_op_thresh = therm_limit - low_thresh_delta;
} }
out:
return status; return 0;
} }
/******************************************************************************* /*******************************************************************************
Intel 10 Gigabit PCI Express Linux driver Intel 10 Gigabit PCI Express Linux driver
Copyright(c) 1999 - 2013 Intel Corporation. Copyright(c) 1999 - 2014 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
...@@ -87,7 +87,6 @@ s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *hw, ...@@ -87,7 +87,6 @@ s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *hw,
int min_credit; int min_credit;
int min_multiplier; int min_multiplier;
int min_percent = 100; int min_percent = 100;
s32 ret_val = 0;
/* Initialization values default for Tx settings */ /* Initialization values default for Tx settings */
u32 credit_refill = 0; u32 credit_refill = 0;
u32 credit_max = 0; u32 credit_max = 0;
...@@ -95,10 +94,8 @@ s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *hw, ...@@ -95,10 +94,8 @@ s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *hw,
u8 bw_percent = 0; u8 bw_percent = 0;
u8 i; u8 i;
if (dcb_config == NULL) { if (!dcb_config)
ret_val = DCB_ERR_CONFIG; return DCB_ERR_CONFIG;
goto out;
}
min_credit = ((max_frame / 2) + DCB_CREDIT_QUANTUM - 1) / min_credit = ((max_frame / 2) + DCB_CREDIT_QUANTUM - 1) /
DCB_CREDIT_QUANTUM; DCB_CREDIT_QUANTUM;
...@@ -174,8 +171,7 @@ s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *hw, ...@@ -174,8 +171,7 @@ s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *hw,
p->data_credits_max = (u16)credit_max; p->data_credits_max = (u16)credit_max;
} }
out: return 0;
return ret_val;
} }
void ixgbe_dcb_unpack_pfc(struct ixgbe_dcb_config *cfg, u8 *pfc_en) void ixgbe_dcb_unpack_pfc(struct ixgbe_dcb_config *cfg, u8 *pfc_en)
...@@ -236,7 +232,7 @@ u8 ixgbe_dcb_get_tc_from_up(struct ixgbe_dcb_config *cfg, int direction, u8 up) ...@@ -236,7 +232,7 @@ u8 ixgbe_dcb_get_tc_from_up(struct ixgbe_dcb_config *cfg, int direction, u8 up)
/* If tc is 0 then DCB is likely not enabled or supported */ /* If tc is 0 then DCB is likely not enabled or supported */
if (!tc) if (!tc)
goto out; return 0;
/* /*
* Test from maximum TC to 1 and report the first match we find. If * Test from maximum TC to 1 and report the first match we find. If
...@@ -247,7 +243,7 @@ u8 ixgbe_dcb_get_tc_from_up(struct ixgbe_dcb_config *cfg, int direction, u8 up) ...@@ -247,7 +243,7 @@ u8 ixgbe_dcb_get_tc_from_up(struct ixgbe_dcb_config *cfg, int direction, u8 up)
if (prio_mask & tc_config[tc].path[direction].up_to_tc_bitmap) if (prio_mask & tc_config[tc].path[direction].up_to_tc_bitmap)
break; break;
} }
out:
return tc; return tc;
} }
...@@ -269,7 +265,6 @@ void ixgbe_dcb_unpack_map(struct ixgbe_dcb_config *cfg, int direction, u8 *map) ...@@ -269,7 +265,6 @@ void ixgbe_dcb_unpack_map(struct ixgbe_dcb_config *cfg, int direction, u8 *map)
s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw, s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw,
struct ixgbe_dcb_config *dcb_config) struct ixgbe_dcb_config *dcb_config)
{ {
s32 ret = 0;
u8 pfc_en; u8 pfc_en;
u8 ptype[MAX_TRAFFIC_CLASS]; u8 ptype[MAX_TRAFFIC_CLASS];
u8 bwgid[MAX_TRAFFIC_CLASS]; u8 bwgid[MAX_TRAFFIC_CLASS];
...@@ -287,37 +282,31 @@ s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw, ...@@ -287,37 +282,31 @@ s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw,
switch (hw->mac.type) { switch (hw->mac.type) {
case ixgbe_mac_82598EB: case ixgbe_mac_82598EB:
ret = ixgbe_dcb_hw_config_82598(hw, pfc_en, refill, max, return ixgbe_dcb_hw_config_82598(hw, pfc_en, refill, max,
bwgid, ptype); bwgid, ptype);
break;
case ixgbe_mac_82599EB: case ixgbe_mac_82599EB:
case ixgbe_mac_X540: case ixgbe_mac_X540:
ret = ixgbe_dcb_hw_config_82599(hw, pfc_en, refill, max, return ixgbe_dcb_hw_config_82599(hw, pfc_en, refill, max,
bwgid, ptype, prio_tc); bwgid, ptype, prio_tc);
break;
default: default:
break; break;
} }
return ret; return 0;
} }
/* Helper routines to abstract HW specifics from DCB netlink ops */ /* Helper routines to abstract HW specifics from DCB netlink ops */
s32 ixgbe_dcb_hw_pfc_config(struct ixgbe_hw *hw, u8 pfc_en, u8 *prio_tc) s32 ixgbe_dcb_hw_pfc_config(struct ixgbe_hw *hw, u8 pfc_en, u8 *prio_tc)
{ {
int ret = -EINVAL;
switch (hw->mac.type) { switch (hw->mac.type) {
case ixgbe_mac_82598EB: case ixgbe_mac_82598EB:
ret = ixgbe_dcb_config_pfc_82598(hw, pfc_en); return ixgbe_dcb_config_pfc_82598(hw, pfc_en);
break;
case ixgbe_mac_82599EB: case ixgbe_mac_82599EB:
case ixgbe_mac_X540: case ixgbe_mac_X540:
ret = ixgbe_dcb_config_pfc_82599(hw, pfc_en, prio_tc); return ixgbe_dcb_config_pfc_82599(hw, pfc_en, prio_tc);
break;
default: default:
break; break;
} }
return ret; return -EINVAL;
} }
s32 ixgbe_dcb_hw_ets(struct ixgbe_hw *hw, struct ieee_ets *ets, int max_frame) s32 ixgbe_dcb_hw_ets(struct ixgbe_hw *hw, struct ieee_ets *ets, int max_frame)
......
/******************************************************************************* /*******************************************************************************
Intel 10 Gigabit PCI Express Linux driver Intel 10 Gigabit PCI Express Linux driver
Copyright(c) 1999 - 2013 Intel Corporation. Copyright(c) 1999 - 2014 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
...@@ -153,7 +153,6 @@ static u8 ixgbe_dcbnl_get_state(struct net_device *netdev) ...@@ -153,7 +153,6 @@ static u8 ixgbe_dcbnl_get_state(struct net_device *netdev)
static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state) static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
{ {
struct ixgbe_adapter *adapter = netdev_priv(netdev); struct ixgbe_adapter *adapter = netdev_priv(netdev);
int err = 0;
/* Fail command if not in CEE mode */ /* Fail command if not in CEE mode */
if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE)) if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
...@@ -161,12 +160,10 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state) ...@@ -161,12 +160,10 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
/* verify there is something to do, if not then exit */ /* verify there is something to do, if not then exit */
if (!state == !(adapter->flags & IXGBE_FLAG_DCB_ENABLED)) if (!state == !(adapter->flags & IXGBE_FLAG_DCB_ENABLED))
goto out; return 0;
err = ixgbe_setup_tc(netdev, return !!ixgbe_setup_tc(netdev,
state ? adapter->dcb_cfg.num_tcs.pg_tcs : 0); state ? adapter->dcb_cfg.num_tcs.pg_tcs : 0);
out:
return !!err;
} }
static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev, static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev,
...@@ -331,12 +328,12 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) ...@@ -331,12 +328,12 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
/* Fail command if not in CEE mode */ /* Fail command if not in CEE mode */
if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE)) if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
return ret; return DCB_NO_HW_CHG;
adapter->dcb_set_bitmap |= ixgbe_copy_dcb_cfg(adapter, adapter->dcb_set_bitmap |= ixgbe_copy_dcb_cfg(adapter,
MAX_TRAFFIC_CLASS); MAX_TRAFFIC_CLASS);
if (!adapter->dcb_set_bitmap) if (!adapter->dcb_set_bitmap)
return ret; return DCB_NO_HW_CHG;
if (adapter->dcb_set_bitmap & (BIT_PG_TX|BIT_PG_RX)) { if (adapter->dcb_set_bitmap & (BIT_PG_TX|BIT_PG_RX)) {
u16 refill[MAX_TRAFFIC_CLASS], max[MAX_TRAFFIC_CLASS]; u16 refill[MAX_TRAFFIC_CLASS], max[MAX_TRAFFIC_CLASS];
...@@ -536,7 +533,7 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev, ...@@ -536,7 +533,7 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev,
{ {
struct ixgbe_adapter *adapter = netdev_priv(dev); struct ixgbe_adapter *adapter = netdev_priv(dev);
int max_frame = dev->mtu + ETH_HLEN + ETH_FCS_LEN; int max_frame = dev->mtu + ETH_HLEN + ETH_FCS_LEN;
int i, err = 0; int i, err;
__u8 max_tc = 0; __u8 max_tc = 0;
__u8 map_chg = 0; __u8 map_chg = 0;
...@@ -573,17 +570,15 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev, ...@@ -573,17 +570,15 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev,
if (max_tc > adapter->dcb_cfg.num_tcs.pg_tcs) if (max_tc > adapter->dcb_cfg.num_tcs.pg_tcs)
return -EINVAL; return -EINVAL;
if (max_tc != netdev_get_num_tc(dev)) if (max_tc != netdev_get_num_tc(dev)) {
err = ixgbe_setup_tc(dev, max_tc); err = ixgbe_setup_tc(dev, max_tc);
else if (map_chg) if (err)
return err;
} else if (map_chg) {
ixgbe_dcbnl_devreset(dev); ixgbe_dcbnl_devreset(dev);
}
if (err) return ixgbe_dcb_hw_ets(&adapter->hw, ets, max_frame);
goto err_out;
err = ixgbe_dcb_hw_ets(&adapter->hw, ets, max_frame);
err_out:
return err;
} }
static int ixgbe_dcbnl_ieee_getpfc(struct net_device *dev, static int ixgbe_dcbnl_ieee_getpfc(struct net_device *dev,
...@@ -647,10 +642,10 @@ static int ixgbe_dcbnl_ieee_setapp(struct net_device *dev, ...@@ -647,10 +642,10 @@ static int ixgbe_dcbnl_ieee_setapp(struct net_device *dev,
struct dcb_app *app) struct dcb_app *app)
{ {
struct ixgbe_adapter *adapter = netdev_priv(dev); struct ixgbe_adapter *adapter = netdev_priv(dev);
int err = -EINVAL; int err;
if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE)) if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
return err; return -EINVAL;
err = dcb_ieee_setapp(dev, app); err = dcb_ieee_setapp(dev, app);
if (err) if (err)
...@@ -662,7 +657,7 @@ static int ixgbe_dcbnl_ieee_setapp(struct net_device *dev, ...@@ -662,7 +657,7 @@ static int ixgbe_dcbnl_ieee_setapp(struct net_device *dev,
u8 app_mask = dcb_ieee_getapp_mask(dev, app); u8 app_mask = dcb_ieee_getapp_mask(dev, app);
if (app_mask & (1 << adapter->fcoe.up)) if (app_mask & (1 << adapter->fcoe.up))
return err; return 0;
adapter->fcoe.up = app->priority; adapter->fcoe.up = app->priority;
ixgbe_dcbnl_devreset(dev); ixgbe_dcbnl_devreset(dev);
...@@ -705,7 +700,7 @@ static int ixgbe_dcbnl_ieee_delapp(struct net_device *dev, ...@@ -705,7 +700,7 @@ static int ixgbe_dcbnl_ieee_delapp(struct net_device *dev,
u8 app_mask = dcb_ieee_getapp_mask(dev, app); u8 app_mask = dcb_ieee_getapp_mask(dev, app);
if (app_mask & (1 << adapter->fcoe.up)) if (app_mask & (1 << adapter->fcoe.up))
return err; return 0;
adapter->fcoe.up = app_mask ? adapter->fcoe.up = app_mask ?
ffs(app_mask) - 1 : IXGBE_FCOE_DEFTC; ffs(app_mask) - 1 : IXGBE_FCOE_DEFTC;
......
/******************************************************************************* /*******************************************************************************
Intel 10 Gigabit PCI Express Linux driver Intel 10 Gigabit PCI Express Linux driver
Copyright(c) 1999 - 2013 Intel Corporation. Copyright(c) 1999 - 2014 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
...@@ -67,23 +67,23 @@ static inline void ixgbe_fcoe_clear_ddp(struct ixgbe_fcoe_ddp *ddp) ...@@ -67,23 +67,23 @@ static inline void ixgbe_fcoe_clear_ddp(struct ixgbe_fcoe_ddp *ddp)
*/ */
int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid) int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid)
{ {
int len = 0; int len;
struct ixgbe_fcoe *fcoe; struct ixgbe_fcoe *fcoe;
struct ixgbe_adapter *adapter; struct ixgbe_adapter *adapter;
struct ixgbe_fcoe_ddp *ddp; struct ixgbe_fcoe_ddp *ddp;
u32 fcbuff; u32 fcbuff;
if (!netdev) if (!netdev)
goto out_ddp_put; return 0;
if (xid >= IXGBE_FCOE_DDP_MAX) if (xid >= IXGBE_FCOE_DDP_MAX)
goto out_ddp_put; return 0;
adapter = netdev_priv(netdev); adapter = netdev_priv(netdev);
fcoe = &adapter->fcoe; fcoe = &adapter->fcoe;
ddp = &fcoe->ddp[xid]; ddp = &fcoe->ddp[xid];
if (!ddp->udl) if (!ddp->udl)
goto out_ddp_put; return 0;
len = ddp->len; len = ddp->len;
/* if there an error, force to invalidate ddp context */ /* if there an error, force to invalidate ddp context */
...@@ -114,7 +114,6 @@ int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid) ...@@ -114,7 +114,6 @@ int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid)
ixgbe_fcoe_clear_ddp(ddp); ixgbe_fcoe_clear_ddp(ddp);
out_ddp_put:
return len; return len;
} }
...@@ -394,17 +393,17 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, ...@@ -394,17 +393,17 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
xid = be16_to_cpu(fh->fh_rx_id); xid = be16_to_cpu(fh->fh_rx_id);
if (xid >= IXGBE_FCOE_DDP_MAX) if (xid >= IXGBE_FCOE_DDP_MAX)
goto ddp_out; return -EINVAL;
fcoe = &adapter->fcoe; fcoe = &adapter->fcoe;
ddp = &fcoe->ddp[xid]; ddp = &fcoe->ddp[xid];
if (!ddp->udl) if (!ddp->udl)
goto ddp_out; return -EINVAL;
ddp_err = ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_ERR_FCEOFE | ddp_err = ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_ERR_FCEOFE |
IXGBE_RXDADV_ERR_FCERR); IXGBE_RXDADV_ERR_FCERR);
if (ddp_err) if (ddp_err)
goto ddp_out; return -EINVAL;
switch (ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_FCSTAT)) { switch (ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_FCSTAT)) {
/* return 0 to bypass going to ULD for DDPed data */ /* return 0 to bypass going to ULD for DDPed data */
...@@ -447,7 +446,7 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, ...@@ -447,7 +446,7 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
crc = (struct fcoe_crc_eof *)skb_put(skb, sizeof(*crc)); crc = (struct fcoe_crc_eof *)skb_put(skb, sizeof(*crc));
crc->fcoe_eof = FC_EOF_T; crc->fcoe_eof = FC_EOF_T;
} }
ddp_out:
return rc; return rc;
} }
...@@ -878,7 +877,6 @@ int ixgbe_fcoe_disable(struct net_device *netdev) ...@@ -878,7 +877,6 @@ int ixgbe_fcoe_disable(struct net_device *netdev)
*/ */
int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type) int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type)
{ {
int rc = -EINVAL;
u16 prefix = 0xffff; u16 prefix = 0xffff;
struct ixgbe_adapter *adapter = netdev_priv(netdev); struct ixgbe_adapter *adapter = netdev_priv(netdev);
struct ixgbe_mac_info *mac = &adapter->hw.mac; struct ixgbe_mac_info *mac = &adapter->hw.mac;
...@@ -903,9 +901,9 @@ int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type) ...@@ -903,9 +901,9 @@ int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type)
((u64) mac->san_addr[3] << 16) | ((u64) mac->san_addr[3] << 16) |
((u64) mac->san_addr[4] << 8) | ((u64) mac->san_addr[4] << 8) |
((u64) mac->san_addr[5]); ((u64) mac->san_addr[5]);
rc = 0; return 0;
} }
return rc; return -EINVAL;
} }
/** /**
......
...@@ -570,7 +570,7 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter) ...@@ -570,7 +570,7 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter)
/* Print TX Ring Summary */ /* Print TX Ring Summary */
if (!netdev || !netif_running(netdev)) if (!netdev || !netif_running(netdev))
goto exit; return;
dev_info(&adapter->pdev->dev, "TX Rings Summary\n"); dev_info(&adapter->pdev->dev, "TX Rings Summary\n");
pr_info(" %s %s %s %s\n", pr_info(" %s %s %s %s\n",
...@@ -685,7 +685,7 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter) ...@@ -685,7 +685,7 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter)
/* Print RX Rings */ /* Print RX Rings */
if (!netif_msg_rx_status(adapter)) if (!netif_msg_rx_status(adapter))
goto exit; return;
dev_info(&adapter->pdev->dev, "RX Rings Dump\n"); dev_info(&adapter->pdev->dev, "RX Rings Dump\n");
...@@ -787,9 +787,6 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter) ...@@ -787,9 +787,6 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter)
} }
} }
exit:
return;
} }
static void ixgbe_release_hw_control(struct ixgbe_adapter *adapter) static void ixgbe_release_hw_control(struct ixgbe_adapter *adapter)
...@@ -1011,7 +1008,6 @@ static inline bool ixgbe_check_tx_hang(struct ixgbe_ring *tx_ring) ...@@ -1011,7 +1008,6 @@ static inline bool ixgbe_check_tx_hang(struct ixgbe_ring *tx_ring)
u32 tx_done = ixgbe_get_tx_completed(tx_ring); u32 tx_done = ixgbe_get_tx_completed(tx_ring);
u32 tx_done_old = tx_ring->tx_stats.tx_done_old; u32 tx_done_old = tx_ring->tx_stats.tx_done_old;
u32 tx_pending = ixgbe_get_tx_pending(tx_ring); u32 tx_pending = ixgbe_get_tx_pending(tx_ring);
bool ret = false;
clear_check_for_tx_hang(tx_ring); clear_check_for_tx_hang(tx_ring);
...@@ -1027,18 +1023,16 @@ static inline bool ixgbe_check_tx_hang(struct ixgbe_ring *tx_ring) ...@@ -1027,18 +1023,16 @@ static inline bool ixgbe_check_tx_hang(struct ixgbe_ring *tx_ring)
* run the check_tx_hang logic with a transmit completion * run the check_tx_hang logic with a transmit completion
* pending but without time to complete it yet. * pending but without time to complete it yet.
*/ */
if ((tx_done_old == tx_done) && tx_pending) { if (tx_done_old == tx_done && tx_pending)
/* make sure it is true for two checks in a row */ /* make sure it is true for two checks in a row */
ret = test_and_set_bit(__IXGBE_HANG_CHECK_ARMED, return test_and_set_bit(__IXGBE_HANG_CHECK_ARMED,
&tx_ring->state); &tx_ring->state);
} else { /* update completed stats and continue */
/* update completed stats and continue */ tx_ring->tx_stats.tx_done_old = tx_done;
tx_ring->tx_stats.tx_done_old = tx_done; /* reset the countdown */
/* reset the countdown */ clear_bit(__IXGBE_HANG_CHECK_ARMED, &tx_ring->state);
clear_bit(__IXGBE_HANG_CHECK_ARMED, &tx_ring->state);
}
return ret; return false;
} }
/** /**
...@@ -4701,18 +4695,18 @@ static int ixgbe_non_sfp_link_config(struct ixgbe_hw *hw) ...@@ -4701,18 +4695,18 @@ static int ixgbe_non_sfp_link_config(struct ixgbe_hw *hw)
ret = hw->mac.ops.check_link(hw, &speed, &link_up, false); ret = hw->mac.ops.check_link(hw, &speed, &link_up, false);
if (ret) if (ret)
goto link_cfg_out; return ret;
speed = hw->phy.autoneg_advertised; speed = hw->phy.autoneg_advertised;
if ((!speed) && (hw->mac.ops.get_link_capabilities)) if ((!speed) && (hw->mac.ops.get_link_capabilities))
ret = hw->mac.ops.get_link_capabilities(hw, &speed, ret = hw->mac.ops.get_link_capabilities(hw, &speed,
&autoneg); &autoneg);
if (ret) if (ret)
goto link_cfg_out; return ret;
if (hw->mac.ops.setup_link) if (hw->mac.ops.setup_link)
ret = hw->mac.ops.setup_link(hw, speed, link_up); ret = hw->mac.ops.setup_link(hw, speed, link_up);
link_cfg_out:
return ret; return ret;
} }
......
...@@ -43,16 +43,15 @@ ...@@ -43,16 +43,15 @@
s32 ixgbe_read_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id) s32 ixgbe_read_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
{ {
struct ixgbe_mbx_info *mbx = &hw->mbx; struct ixgbe_mbx_info *mbx = &hw->mbx;
s32 ret_val = IXGBE_ERR_MBX;
/* limit read to size of mailbox */ /* limit read to size of mailbox */
if (size > mbx->size) if (size > mbx->size)
size = mbx->size; size = mbx->size;
if (mbx->ops.read) if (!mbx->ops.read)
ret_val = mbx->ops.read(hw, msg, size, mbx_id); return IXGBE_ERR_MBX;
return ret_val; return mbx->ops.read(hw, msg, size, mbx_id);
} }
/** /**
...@@ -87,12 +86,11 @@ s32 ixgbe_write_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id) ...@@ -87,12 +86,11 @@ s32 ixgbe_write_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
s32 ixgbe_check_for_msg(struct ixgbe_hw *hw, u16 mbx_id) s32 ixgbe_check_for_msg(struct ixgbe_hw *hw, u16 mbx_id)
{ {
struct ixgbe_mbx_info *mbx = &hw->mbx; struct ixgbe_mbx_info *mbx = &hw->mbx;
s32 ret_val = IXGBE_ERR_MBX;
if (mbx->ops.check_for_msg) if (!mbx->ops.check_for_msg)
ret_val = mbx->ops.check_for_msg(hw, mbx_id); return IXGBE_ERR_MBX;
return ret_val; return mbx->ops.check_for_msg(hw, mbx_id);
} }
/** /**
...@@ -105,12 +103,11 @@ s32 ixgbe_check_for_msg(struct ixgbe_hw *hw, u16 mbx_id) ...@@ -105,12 +103,11 @@ s32 ixgbe_check_for_msg(struct ixgbe_hw *hw, u16 mbx_id)
s32 ixgbe_check_for_ack(struct ixgbe_hw *hw, u16 mbx_id) s32 ixgbe_check_for_ack(struct ixgbe_hw *hw, u16 mbx_id)
{ {
struct ixgbe_mbx_info *mbx = &hw->mbx; struct ixgbe_mbx_info *mbx = &hw->mbx;
s32 ret_val = IXGBE_ERR_MBX;
if (mbx->ops.check_for_ack) if (!mbx->ops.check_for_ack)
ret_val = mbx->ops.check_for_ack(hw, mbx_id); return IXGBE_ERR_MBX;
return ret_val; return mbx->ops.check_for_ack(hw, mbx_id);
} }
/** /**
...@@ -123,12 +120,11 @@ s32 ixgbe_check_for_ack(struct ixgbe_hw *hw, u16 mbx_id) ...@@ -123,12 +120,11 @@ s32 ixgbe_check_for_ack(struct ixgbe_hw *hw, u16 mbx_id)
s32 ixgbe_check_for_rst(struct ixgbe_hw *hw, u16 mbx_id) s32 ixgbe_check_for_rst(struct ixgbe_hw *hw, u16 mbx_id)
{ {
struct ixgbe_mbx_info *mbx = &hw->mbx; struct ixgbe_mbx_info *mbx = &hw->mbx;
s32 ret_val = IXGBE_ERR_MBX;
if (mbx->ops.check_for_rst) if (!mbx->ops.check_for_rst)
ret_val = mbx->ops.check_for_rst(hw, mbx_id); return IXGBE_ERR_MBX;
return ret_val; return mbx->ops.check_for_rst(hw, mbx_id);
} }
/** /**
...@@ -144,17 +140,16 @@ static s32 ixgbe_poll_for_msg(struct ixgbe_hw *hw, u16 mbx_id) ...@@ -144,17 +140,16 @@ static s32 ixgbe_poll_for_msg(struct ixgbe_hw *hw, u16 mbx_id)
int countdown = mbx->timeout; int countdown = mbx->timeout;
if (!countdown || !mbx->ops.check_for_msg) if (!countdown || !mbx->ops.check_for_msg)
goto out; return IXGBE_ERR_MBX;
while (countdown && mbx->ops.check_for_msg(hw, mbx_id)) { while (mbx->ops.check_for_msg(hw, mbx_id)) {
countdown--; countdown--;
if (!countdown) if (!countdown)
break; return IXGBE_ERR_MBX;
udelay(mbx->usec_delay); udelay(mbx->usec_delay);
} }
out: return 0;
return countdown ? 0 : IXGBE_ERR_MBX;
} }
/** /**
...@@ -170,17 +165,16 @@ static s32 ixgbe_poll_for_ack(struct ixgbe_hw *hw, u16 mbx_id) ...@@ -170,17 +165,16 @@ static s32 ixgbe_poll_for_ack(struct ixgbe_hw *hw, u16 mbx_id)
int countdown = mbx->timeout; int countdown = mbx->timeout;
if (!countdown || !mbx->ops.check_for_ack) if (!countdown || !mbx->ops.check_for_ack)
goto out; return IXGBE_ERR_MBX;
while (countdown && mbx->ops.check_for_ack(hw, mbx_id)) { while (mbx->ops.check_for_ack(hw, mbx_id)) {
countdown--; countdown--;
if (!countdown) if (!countdown)
break; return IXGBE_ERR_MBX;
udelay(mbx->usec_delay); udelay(mbx->usec_delay);
} }
out: return 0;
return countdown ? 0 : IXGBE_ERR_MBX;
} }
/** /**
...@@ -197,18 +191,17 @@ static s32 ixgbe_read_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, ...@@ -197,18 +191,17 @@ static s32 ixgbe_read_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size,
u16 mbx_id) u16 mbx_id)
{ {
struct ixgbe_mbx_info *mbx = &hw->mbx; struct ixgbe_mbx_info *mbx = &hw->mbx;
s32 ret_val = IXGBE_ERR_MBX; s32 ret_val;
if (!mbx->ops.read) if (!mbx->ops.read)
goto out; return IXGBE_ERR_MBX;
ret_val = ixgbe_poll_for_msg(hw, mbx_id); ret_val = ixgbe_poll_for_msg(hw, mbx_id);
if (ret_val)
return ret_val;
/* if ack received read message, otherwise we timed out */ /* if ack received read message */
if (!ret_val) return mbx->ops.read(hw, msg, size, mbx_id);
ret_val = mbx->ops.read(hw, msg, size, mbx_id);
out:
return ret_val;
} }
/** /**
...@@ -225,33 +218,31 @@ static s32 ixgbe_write_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, ...@@ -225,33 +218,31 @@ static s32 ixgbe_write_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size,
u16 mbx_id) u16 mbx_id)
{ {
struct ixgbe_mbx_info *mbx = &hw->mbx; struct ixgbe_mbx_info *mbx = &hw->mbx;
s32 ret_val = IXGBE_ERR_MBX; s32 ret_val;
/* exit if either we can't write or there isn't a defined timeout */ /* exit if either we can't write or there isn't a defined timeout */
if (!mbx->ops.write || !mbx->timeout) if (!mbx->ops.write || !mbx->timeout)
goto out; return IXGBE_ERR_MBX;
/* send msg */ /* send msg */
ret_val = mbx->ops.write(hw, msg, size, mbx_id); ret_val = mbx->ops.write(hw, msg, size, mbx_id);
if (ret_val)
return ret_val;
/* if msg sent wait until we receive an ack */ /* if msg sent wait until we receive an ack */
if (!ret_val) return ixgbe_poll_for_ack(hw, mbx_id);
ret_val = ixgbe_poll_for_ack(hw, mbx_id);
out:
return ret_val;
} }
static s32 ixgbe_check_for_bit_pf(struct ixgbe_hw *hw, u32 mask, s32 index) static s32 ixgbe_check_for_bit_pf(struct ixgbe_hw *hw, u32 mask, s32 index)
{ {
u32 mbvficr = IXGBE_READ_REG(hw, IXGBE_MBVFICR(index)); u32 mbvficr = IXGBE_READ_REG(hw, IXGBE_MBVFICR(index));
s32 ret_val = IXGBE_ERR_MBX;
if (mbvficr & mask) { if (mbvficr & mask) {
ret_val = 0;
IXGBE_WRITE_REG(hw, IXGBE_MBVFICR(index), mask); IXGBE_WRITE_REG(hw, IXGBE_MBVFICR(index), mask);
return 0;
} }
return ret_val; return IXGBE_ERR_MBX;
} }
/** /**
...@@ -263,17 +254,16 @@ static s32 ixgbe_check_for_bit_pf(struct ixgbe_hw *hw, u32 mask, s32 index) ...@@ -263,17 +254,16 @@ static s32 ixgbe_check_for_bit_pf(struct ixgbe_hw *hw, u32 mask, s32 index)
**/ **/
static s32 ixgbe_check_for_msg_pf(struct ixgbe_hw *hw, u16 vf_number) static s32 ixgbe_check_for_msg_pf(struct ixgbe_hw *hw, u16 vf_number)
{ {
s32 ret_val = IXGBE_ERR_MBX;
s32 index = IXGBE_MBVFICR_INDEX(vf_number); s32 index = IXGBE_MBVFICR_INDEX(vf_number);
u32 vf_bit = vf_number % 16; u32 vf_bit = vf_number % 16;
if (!ixgbe_check_for_bit_pf(hw, IXGBE_MBVFICR_VFREQ_VF1 << vf_bit, if (!ixgbe_check_for_bit_pf(hw, IXGBE_MBVFICR_VFREQ_VF1 << vf_bit,
index)) { index)) {
ret_val = 0;
hw->mbx.stats.reqs++; hw->mbx.stats.reqs++;
return 0;
} }
return ret_val; return IXGBE_ERR_MBX;
} }
/** /**
...@@ -285,17 +275,16 @@ static s32 ixgbe_check_for_msg_pf(struct ixgbe_hw *hw, u16 vf_number) ...@@ -285,17 +275,16 @@ static s32 ixgbe_check_for_msg_pf(struct ixgbe_hw *hw, u16 vf_number)
**/ **/
static s32 ixgbe_check_for_ack_pf(struct ixgbe_hw *hw, u16 vf_number) static s32 ixgbe_check_for_ack_pf(struct ixgbe_hw *hw, u16 vf_number)
{ {
s32 ret_val = IXGBE_ERR_MBX;
s32 index = IXGBE_MBVFICR_INDEX(vf_number); s32 index = IXGBE_MBVFICR_INDEX(vf_number);
u32 vf_bit = vf_number % 16; u32 vf_bit = vf_number % 16;
if (!ixgbe_check_for_bit_pf(hw, IXGBE_MBVFICR_VFACK_VF1 << vf_bit, if (!ixgbe_check_for_bit_pf(hw, IXGBE_MBVFICR_VFACK_VF1 << vf_bit,
index)) { index)) {
ret_val = 0;
hw->mbx.stats.acks++; hw->mbx.stats.acks++;
return 0;
} }
return ret_val; return IXGBE_ERR_MBX;
} }
/** /**
...@@ -310,7 +299,6 @@ static s32 ixgbe_check_for_rst_pf(struct ixgbe_hw *hw, u16 vf_number) ...@@ -310,7 +299,6 @@ static s32 ixgbe_check_for_rst_pf(struct ixgbe_hw *hw, u16 vf_number)
u32 reg_offset = (vf_number < 32) ? 0 : 1; u32 reg_offset = (vf_number < 32) ? 0 : 1;
u32 vf_shift = vf_number % 32; u32 vf_shift = vf_number % 32;
u32 vflre = 0; u32 vflre = 0;
s32 ret_val = IXGBE_ERR_MBX;
switch (hw->mac.type) { switch (hw->mac.type) {
case ixgbe_mac_82599EB: case ixgbe_mac_82599EB:
...@@ -324,12 +312,12 @@ static s32 ixgbe_check_for_rst_pf(struct ixgbe_hw *hw, u16 vf_number) ...@@ -324,12 +312,12 @@ static s32 ixgbe_check_for_rst_pf(struct ixgbe_hw *hw, u16 vf_number)
} }
if (vflre & (1 << vf_shift)) { if (vflre & (1 << vf_shift)) {
ret_val = 0;
IXGBE_WRITE_REG(hw, IXGBE_VFLREC(reg_offset), (1 << vf_shift)); IXGBE_WRITE_REG(hw, IXGBE_VFLREC(reg_offset), (1 << vf_shift));
hw->mbx.stats.rsts++; hw->mbx.stats.rsts++;
return 0;
} }
return ret_val; return IXGBE_ERR_MBX;
} }
/** /**
...@@ -341,7 +329,6 @@ static s32 ixgbe_check_for_rst_pf(struct ixgbe_hw *hw, u16 vf_number) ...@@ -341,7 +329,6 @@ static s32 ixgbe_check_for_rst_pf(struct ixgbe_hw *hw, u16 vf_number)
**/ **/
static s32 ixgbe_obtain_mbx_lock_pf(struct ixgbe_hw *hw, u16 vf_number) static s32 ixgbe_obtain_mbx_lock_pf(struct ixgbe_hw *hw, u16 vf_number)
{ {
s32 ret_val = IXGBE_ERR_MBX;
u32 p2v_mailbox; u32 p2v_mailbox;
/* Take ownership of the buffer */ /* Take ownership of the buffer */
...@@ -350,9 +337,9 @@ static s32 ixgbe_obtain_mbx_lock_pf(struct ixgbe_hw *hw, u16 vf_number) ...@@ -350,9 +337,9 @@ static s32 ixgbe_obtain_mbx_lock_pf(struct ixgbe_hw *hw, u16 vf_number)
/* reserve mailbox for vf use */ /* reserve mailbox for vf use */
p2v_mailbox = IXGBE_READ_REG(hw, IXGBE_PFMAILBOX(vf_number)); p2v_mailbox = IXGBE_READ_REG(hw, IXGBE_PFMAILBOX(vf_number));
if (p2v_mailbox & IXGBE_PFMAILBOX_PFU) if (p2v_mailbox & IXGBE_PFMAILBOX_PFU)
ret_val = 0; return 0;
return ret_val; return IXGBE_ERR_MBX;
} }
/** /**
...@@ -373,7 +360,7 @@ static s32 ixgbe_write_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size, ...@@ -373,7 +360,7 @@ static s32 ixgbe_write_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size,
/* lock the mailbox to prevent pf/vf race condition */ /* lock the mailbox to prevent pf/vf race condition */
ret_val = ixgbe_obtain_mbx_lock_pf(hw, vf_number); ret_val = ixgbe_obtain_mbx_lock_pf(hw, vf_number);
if (ret_val) if (ret_val)
goto out_no_write; return ret_val;
/* flush msg and acks as we are overwriting the message buffer */ /* flush msg and acks as we are overwriting the message buffer */
ixgbe_check_for_msg_pf(hw, vf_number); ixgbe_check_for_msg_pf(hw, vf_number);
...@@ -389,9 +376,7 @@ static s32 ixgbe_write_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size, ...@@ -389,9 +376,7 @@ static s32 ixgbe_write_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size,
/* update stats */ /* update stats */
hw->mbx.stats.msgs_tx++; hw->mbx.stats.msgs_tx++;
out_no_write: return 0;
return ret_val;
} }
/** /**
...@@ -414,7 +399,7 @@ static s32 ixgbe_read_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size, ...@@ -414,7 +399,7 @@ static s32 ixgbe_read_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size,
/* lock the mailbox to prevent pf/vf race condition */ /* lock the mailbox to prevent pf/vf race condition */
ret_val = ixgbe_obtain_mbx_lock_pf(hw, vf_number); ret_val = ixgbe_obtain_mbx_lock_pf(hw, vf_number);
if (ret_val) if (ret_val)
goto out_no_read; return ret_val;
/* copy the message to the mailbox memory buffer */ /* copy the message to the mailbox memory buffer */
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
...@@ -426,8 +411,7 @@ static s32 ixgbe_read_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size, ...@@ -426,8 +411,7 @@ static s32 ixgbe_read_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size,
/* update stats */ /* update stats */
hw->mbx.stats.msgs_rx++; hw->mbx.stats.msgs_rx++;
out_no_read: return 0;
return ret_val;
} }
#ifdef CONFIG_PCI_IOV #ifdef CONFIG_PCI_IOV
......
...@@ -57,7 +57,6 @@ static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw); ...@@ -57,7 +57,6 @@ static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw);
**/ **/
s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw) s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
{ {
s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
u32 phy_addr; u32 phy_addr;
u16 ext_ability = 0; u16 ext_ability = 0;
...@@ -84,18 +83,14 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw) ...@@ -84,18 +83,14 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
ixgbe_phy_generic; ixgbe_phy_generic;
} }
status = 0; return 0;
break;
} }
} }
/* clear value if nothing found */ /* clear value if nothing found */
if (status != 0) hw->phy.mdio.prtad = 0;
hw->phy.mdio.prtad = 0; return IXGBE_ERR_PHY_ADDR_INVALID;
} else {
status = 0;
} }
return 0;
return status;
} }
/** /**
...@@ -192,16 +187,16 @@ s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw) ...@@ -192,16 +187,16 @@ s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
status = ixgbe_identify_phy_generic(hw); status = ixgbe_identify_phy_generic(hw);
if (status != 0 || hw->phy.type == ixgbe_phy_none) if (status != 0 || hw->phy.type == ixgbe_phy_none)
goto out; return status;
/* Don't reset PHY if it's shut down due to overtemp. */ /* Don't reset PHY if it's shut down due to overtemp. */
if (!hw->phy.reset_if_overtemp && if (!hw->phy.reset_if_overtemp &&
(IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw))) (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw)))
goto out; return 0;
/* Blocked by MNG FW so bail */ /* Blocked by MNG FW so bail */
if (ixgbe_check_reset_blocked(hw)) if (ixgbe_check_reset_blocked(hw))
goto out; return 0;
/* /*
* Perform soft PHY reset to the PHY_XS. * Perform soft PHY reset to the PHY_XS.
...@@ -227,12 +222,11 @@ s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw) ...@@ -227,12 +222,11 @@ s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
} }
if (ctrl & MDIO_CTRL1_RESET) { if (ctrl & MDIO_CTRL1_RESET) {
status = IXGBE_ERR_RESET_FAILED;
hw_dbg(hw, "PHY reset polling failed to complete.\n"); hw_dbg(hw, "PHY reset polling failed to complete.\n");
return IXGBE_ERR_RESET_FAILED;
} }
out: return 0;
return status;
} }
/** /**
...@@ -333,7 +327,7 @@ s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr, ...@@ -333,7 +327,7 @@ s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
phy_data); phy_data);
hw->mac.ops.release_swfw_sync(hw, gssr); hw->mac.ops.release_swfw_sync(hw, gssr);
} else { } else {
status = IXGBE_ERR_SWFW_SYNC; return IXGBE_ERR_SWFW_SYNC;
} }
return status; return status;
...@@ -436,7 +430,7 @@ s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr, ...@@ -436,7 +430,7 @@ s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
phy_data); phy_data);
hw->mac.ops.release_swfw_sync(hw, gssr); hw->mac.ops.release_swfw_sync(hw, gssr);
} else { } else {
status = IXGBE_ERR_SWFW_SYNC; return IXGBE_ERR_SWFW_SYNC;
} }
return status; return status;
...@@ -509,7 +503,7 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw) ...@@ -509,7 +503,7 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
/* Blocked by MNG FW so don't reset PHY */ /* Blocked by MNG FW so don't reset PHY */
if (ixgbe_check_reset_blocked(hw)) if (ixgbe_check_reset_blocked(hw))
return status; return 0;
/* Restart PHY autonegotiation and wait for completion */ /* Restart PHY autonegotiation and wait for completion */
hw->phy.ops.read_reg(hw, MDIO_CTRL1, hw->phy.ops.read_reg(hw, MDIO_CTRL1,
...@@ -535,8 +529,8 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw) ...@@ -535,8 +529,8 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
} }
if (time_out == max_time_out) { if (time_out == max_time_out) {
status = IXGBE_ERR_LINK_SETUP;
hw_dbg(hw, "ixgbe_setup_phy_link_generic: time out\n"); hw_dbg(hw, "ixgbe_setup_phy_link_generic: time out\n");
return IXGBE_ERR_LINK_SETUP;
} }
return status; return status;
...@@ -585,7 +579,7 @@ s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw, ...@@ -585,7 +579,7 @@ s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
ixgbe_link_speed *speed, ixgbe_link_speed *speed,
bool *autoneg) bool *autoneg)
{ {
s32 status = IXGBE_ERR_LINK_SETUP; s32 status;
u16 speed_ability; u16 speed_ability;
*speed = 0; *speed = 0;
...@@ -616,7 +610,7 @@ s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw, ...@@ -616,7 +610,7 @@ s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed, s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
bool *link_up) bool *link_up)
{ {
s32 status = 0; s32 status;
u32 time_out; u32 time_out;
u32 max_time_out = 10; u32 max_time_out = 10;
u16 phy_link = 0; u16 phy_link = 0;
...@@ -662,7 +656,7 @@ s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed, ...@@ -662,7 +656,7 @@ s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
**/ **/
s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw) s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
{ {
s32 status = 0; s32 status;
u32 time_out; u32 time_out;
u32 max_time_out = 10; u32 max_time_out = 10;
u16 autoneg_reg = IXGBE_MII_AUTONEG_REG; u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
...@@ -719,7 +713,7 @@ s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw) ...@@ -719,7 +713,7 @@ s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
/* Blocked by MNG FW so don't reset PHY */ /* Blocked by MNG FW so don't reset PHY */
if (ixgbe_check_reset_blocked(hw)) if (ixgbe_check_reset_blocked(hw))
return status; return 0;
/* Restart PHY autonegotiation and wait for completion */ /* Restart PHY autonegotiation and wait for completion */
hw->phy.ops.read_reg(hw, MDIO_CTRL1, hw->phy.ops.read_reg(hw, MDIO_CTRL1,
...@@ -744,8 +738,8 @@ s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw) ...@@ -744,8 +738,8 @@ s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
} }
if (time_out == max_time_out) { if (time_out == max_time_out) {
status = IXGBE_ERR_LINK_SETUP;
hw_dbg(hw, "ixgbe_setup_phy_link_tnx: time out\n"); hw_dbg(hw, "ixgbe_setup_phy_link_tnx: time out\n");
return IXGBE_ERR_LINK_SETUP;
} }
return status; return status;
...@@ -759,7 +753,7 @@ s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw) ...@@ -759,7 +753,7 @@ s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw, s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
u16 *firmware_version) u16 *firmware_version)
{ {
s32 status = 0; s32 status;
status = hw->phy.ops.read_reg(hw, TNX_FW_REV, status = hw->phy.ops.read_reg(hw, TNX_FW_REV,
MDIO_MMD_VEND1, MDIO_MMD_VEND1,
...@@ -776,7 +770,7 @@ s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw, ...@@ -776,7 +770,7 @@ s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw, s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw,
u16 *firmware_version) u16 *firmware_version)
{ {
s32 status = 0; s32 status;
status = hw->phy.ops.read_reg(hw, AQ_FW_REV, status = hw->phy.ops.read_reg(hw, AQ_FW_REV,
MDIO_MMD_VEND1, MDIO_MMD_VEND1,
...@@ -795,12 +789,12 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw) ...@@ -795,12 +789,12 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
bool end_data = false; bool end_data = false;
u16 list_offset, data_offset; u16 list_offset, data_offset;
u16 phy_data = 0; u16 phy_data = 0;
s32 ret_val = 0; s32 ret_val;
u32 i; u32 i;
/* Blocked by MNG FW so bail */ /* Blocked by MNG FW so bail */
if (ixgbe_check_reset_blocked(hw)) if (ixgbe_check_reset_blocked(hw))
goto out; return 0;
hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS, &phy_data); hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS, &phy_data);
...@@ -818,15 +812,14 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw) ...@@ -818,15 +812,14 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
if ((phy_data & MDIO_CTRL1_RESET) != 0) { if ((phy_data & MDIO_CTRL1_RESET) != 0) {
hw_dbg(hw, "PHY reset did not complete.\n"); hw_dbg(hw, "PHY reset did not complete.\n");
ret_val = IXGBE_ERR_PHY; return IXGBE_ERR_PHY;
goto out;
} }
/* Get init offsets */ /* Get init offsets */
ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset, ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
&data_offset); &data_offset);
if (ret_val != 0) if (ret_val)
goto out; return ret_val;
ret_val = hw->eeprom.ops.read(hw, data_offset, &block_crc); ret_val = hw->eeprom.ops.read(hw, data_offset, &block_crc);
data_offset++; data_offset++;
...@@ -876,18 +869,15 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw) ...@@ -876,18 +869,15 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
hw_dbg(hw, "SOL\n"); hw_dbg(hw, "SOL\n");
} else { } else {
hw_dbg(hw, "Bad control value\n"); hw_dbg(hw, "Bad control value\n");
ret_val = IXGBE_ERR_PHY; return IXGBE_ERR_PHY;
goto out;
} }
break; break;
default: default:
hw_dbg(hw, "Bad control type\n"); hw_dbg(hw, "Bad control type\n");
ret_val = IXGBE_ERR_PHY; return IXGBE_ERR_PHY;
goto out;
} }
} }
out:
return ret_val; return ret_val;
err_eeprom: err_eeprom:
...@@ -903,34 +893,29 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw) ...@@ -903,34 +893,29 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
**/ **/
s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw) s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw)
{ {
s32 status = IXGBE_ERR_SFP_NOT_PRESENT;
switch (hw->mac.ops.get_media_type(hw)) { switch (hw->mac.ops.get_media_type(hw)) {
case ixgbe_media_type_fiber: case ixgbe_media_type_fiber:
status = ixgbe_identify_sfp_module_generic(hw); return ixgbe_identify_sfp_module_generic(hw);
break;
case ixgbe_media_type_fiber_qsfp: case ixgbe_media_type_fiber_qsfp:
status = ixgbe_identify_qsfp_module_generic(hw); return ixgbe_identify_qsfp_module_generic(hw);
break;
default: default:
hw->phy.sfp_type = ixgbe_sfp_type_not_present; hw->phy.sfp_type = ixgbe_sfp_type_not_present;
status = IXGBE_ERR_SFP_NOT_PRESENT; return IXGBE_ERR_SFP_NOT_PRESENT;
break;
} }
return status; return IXGBE_ERR_SFP_NOT_PRESENT;
} }
/** /**
* ixgbe_identify_sfp_module_generic - Identifies SFP modules * ixgbe_identify_sfp_module_generic - Identifies SFP modules
* @hw: pointer to hardware structure * @hw: pointer to hardware structure
* *
* Searches for and identifies the SFP module and assigns 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)
{ {
struct ixgbe_adapter *adapter = hw->back; struct ixgbe_adapter *adapter = hw->back;
s32 status = IXGBE_ERR_PHY_ADDR_INVALID; s32 status;
u32 vendor_oui = 0; u32 vendor_oui = 0;
enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type; enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
u8 identifier = 0; u8 identifier = 0;
...@@ -943,15 +928,14 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) ...@@ -943,15 +928,14 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber) { if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber) {
hw->phy.sfp_type = ixgbe_sfp_type_not_present; hw->phy.sfp_type = ixgbe_sfp_type_not_present;
status = IXGBE_ERR_SFP_NOT_PRESENT; return IXGBE_ERR_SFP_NOT_PRESENT;
goto out;
} }
status = hw->phy.ops.read_i2c_eeprom(hw, status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_IDENTIFIER, IXGBE_SFF_IDENTIFIER,
&identifier); &identifier);
if (status != 0) if (status)
goto err_read_i2c_eeprom; goto err_read_i2c_eeprom;
/* LAN ID is needed for sfp_type determination */ /* LAN ID is needed for sfp_type determination */
...@@ -959,239 +943,224 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) ...@@ -959,239 +943,224 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
if (identifier != IXGBE_SFF_IDENTIFIER_SFP) { if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
hw->phy.type = ixgbe_phy_sfp_unsupported; hw->phy.type = ixgbe_phy_sfp_unsupported;
status = IXGBE_ERR_SFP_NOT_SUPPORTED; return IXGBE_ERR_SFP_NOT_SUPPORTED;
} else { }
status = hw->phy.ops.read_i2c_eeprom(hw, status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_1GBE_COMP_CODES, IXGBE_SFF_1GBE_COMP_CODES,
&comp_codes_1g); &comp_codes_1g);
if (status != 0) if (status)
goto err_read_i2c_eeprom; goto err_read_i2c_eeprom;
status = hw->phy.ops.read_i2c_eeprom(hw, status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_10GBE_COMP_CODES, IXGBE_SFF_10GBE_COMP_CODES,
&comp_codes_10g); &comp_codes_10g);
if (status != 0) if (status)
goto err_read_i2c_eeprom; goto err_read_i2c_eeprom;
status = hw->phy.ops.read_i2c_eeprom(hw, status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_CABLE_TECHNOLOGY, IXGBE_SFF_CABLE_TECHNOLOGY,
&cable_tech); &cable_tech);
if (status != 0) if (status)
goto err_read_i2c_eeprom; goto err_read_i2c_eeprom;
/* ID Module /* ID Module
* ========= * =========
* 0 SFP_DA_CU * 0 SFP_DA_CU
* 1 SFP_SR * 1 SFP_SR
* 2 SFP_LR * 2 SFP_LR
* 3 SFP_DA_CORE0 - 82599-specific * 3 SFP_DA_CORE0 - 82599-specific
* 4 SFP_DA_CORE1 - 82599-specific * 4 SFP_DA_CORE1 - 82599-specific
* 5 SFP_SR/LR_CORE0 - 82599-specific * 5 SFP_SR/LR_CORE0 - 82599-specific
* 6 SFP_SR/LR_CORE1 - 82599-specific * 6 SFP_SR/LR_CORE1 - 82599-specific
* 7 SFP_act_lmt_DA_CORE0 - 82599-specific * 7 SFP_act_lmt_DA_CORE0 - 82599-specific
* 8 SFP_act_lmt_DA_CORE1 - 82599-specific * 8 SFP_act_lmt_DA_CORE1 - 82599-specific
* 9 SFP_1g_cu_CORE0 - 82599-specific * 9 SFP_1g_cu_CORE0 - 82599-specific
* 10 SFP_1g_cu_CORE1 - 82599-specific * 10 SFP_1g_cu_CORE1 - 82599-specific
* 11 SFP_1g_sx_CORE0 - 82599-specific * 11 SFP_1g_sx_CORE0 - 82599-specific
* 12 SFP_1g_sx_CORE1 - 82599-specific * 12 SFP_1g_sx_CORE1 - 82599-specific
*/ */
if (hw->mac.type == ixgbe_mac_82598EB) { if (hw->mac.type == ixgbe_mac_82598EB) {
if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
hw->phy.sfp_type = ixgbe_sfp_type_da_cu; hw->phy.sfp_type = ixgbe_sfp_type_da_cu;
else if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE) else if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
hw->phy.sfp_type = ixgbe_sfp_type_sr; hw->phy.sfp_type = ixgbe_sfp_type_sr;
else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE) else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
hw->phy.sfp_type = ixgbe_sfp_type_lr; hw->phy.sfp_type = ixgbe_sfp_type_lr;
else
hw->phy.sfp_type = ixgbe_sfp_type_unknown;
} else if (hw->mac.type == ixgbe_mac_82599EB) {
if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) {
if (hw->bus.lan_id == 0)
hw->phy.sfp_type =
ixgbe_sfp_type_da_cu_core0;
else else
hw->phy.sfp_type = ixgbe_sfp_type_unknown; hw->phy.sfp_type =
} else if (hw->mac.type == ixgbe_mac_82599EB) { ixgbe_sfp_type_da_cu_core1;
if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) { } else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE) {
if (hw->bus.lan_id == 0) hw->phy.ops.read_i2c_eeprom(
hw->phy.sfp_type = hw, IXGBE_SFF_CABLE_SPEC_COMP,
ixgbe_sfp_type_da_cu_core0; &cable_spec);
else if (cable_spec &
hw->phy.sfp_type = IXGBE_SFF_DA_SPEC_ACTIVE_LIMITING) {
ixgbe_sfp_type_da_cu_core1;
} else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE) {
hw->phy.ops.read_i2c_eeprom(
hw, IXGBE_SFF_CABLE_SPEC_COMP,
&cable_spec);
if (cable_spec &
IXGBE_SFF_DA_SPEC_ACTIVE_LIMITING) {
if (hw->bus.lan_id == 0)
hw->phy.sfp_type =
ixgbe_sfp_type_da_act_lmt_core0;
else
hw->phy.sfp_type =
ixgbe_sfp_type_da_act_lmt_core1;
} else {
hw->phy.sfp_type =
ixgbe_sfp_type_unknown;
}
} else if (comp_codes_10g &
(IXGBE_SFF_10GBASESR_CAPABLE |
IXGBE_SFF_10GBASELR_CAPABLE)) {
if (hw->bus.lan_id == 0)
hw->phy.sfp_type =
ixgbe_sfp_type_srlr_core0;
else
hw->phy.sfp_type =
ixgbe_sfp_type_srlr_core1;
} else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) {
if (hw->bus.lan_id == 0)
hw->phy.sfp_type =
ixgbe_sfp_type_1g_cu_core0;
else
hw->phy.sfp_type =
ixgbe_sfp_type_1g_cu_core1;
} else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) {
if (hw->bus.lan_id == 0)
hw->phy.sfp_type =
ixgbe_sfp_type_1g_sx_core0;
else
hw->phy.sfp_type =
ixgbe_sfp_type_1g_sx_core1;
} else if (comp_codes_1g & IXGBE_SFF_1GBASELX_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_lx_core0; ixgbe_sfp_type_da_act_lmt_core0;
else else
hw->phy.sfp_type = hw->phy.sfp_type =
ixgbe_sfp_type_1g_lx_core1; ixgbe_sfp_type_da_act_lmt_core1;
} else { } else {
hw->phy.sfp_type = ixgbe_sfp_type_unknown; hw->phy.sfp_type =
ixgbe_sfp_type_unknown;
} }
} else if (comp_codes_10g &
(IXGBE_SFF_10GBASESR_CAPABLE |
IXGBE_SFF_10GBASELR_CAPABLE)) {
if (hw->bus.lan_id == 0)
hw->phy.sfp_type =
ixgbe_sfp_type_srlr_core0;
else
hw->phy.sfp_type =
ixgbe_sfp_type_srlr_core1;
} else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) {
if (hw->bus.lan_id == 0)
hw->phy.sfp_type =
ixgbe_sfp_type_1g_cu_core0;
else
hw->phy.sfp_type =
ixgbe_sfp_type_1g_cu_core1;
} else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) {
if (hw->bus.lan_id == 0)
hw->phy.sfp_type =
ixgbe_sfp_type_1g_sx_core0;
else
hw->phy.sfp_type =
ixgbe_sfp_type_1g_sx_core1;
} else if (comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) {
if (hw->bus.lan_id == 0)
hw->phy.sfp_type =
ixgbe_sfp_type_1g_lx_core0;
else
hw->phy.sfp_type =
ixgbe_sfp_type_1g_lx_core1;
} else {
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;
/* Determine if the SFP+ PHY is dual speed or not. */
hw->phy.multispeed_fiber = false;
if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
(comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
(comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
hw->phy.multispeed_fiber = true;
/* Determine PHY vendor */
if (hw->phy.type != ixgbe_phy_nl) {
hw->phy.id = identifier;
status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_VENDOR_OUI_BYTE0,
&oui_bytes[0]);
if (status != 0)
goto err_read_i2c_eeprom;
status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_VENDOR_OUI_BYTE1,
&oui_bytes[1]);
if (status != 0)
goto err_read_i2c_eeprom;
status = hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_VENDOR_OUI_BYTE2,
&oui_bytes[2]);
if (status != 0)
goto err_read_i2c_eeprom;
vendor_oui =
((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
(oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
(oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
switch (vendor_oui) {
case IXGBE_SFF_VENDOR_OUI_TYCO:
if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
hw->phy.type =
ixgbe_phy_sfp_passive_tyco;
break;
case IXGBE_SFF_VENDOR_OUI_FTL:
if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
hw->phy.type = ixgbe_phy_sfp_ftl_active;
else
hw->phy.type = ixgbe_phy_sfp_ftl;
break;
case IXGBE_SFF_VENDOR_OUI_AVAGO:
hw->phy.type = ixgbe_phy_sfp_avago;
break;
case IXGBE_SFF_VENDOR_OUI_INTEL:
hw->phy.type = ixgbe_phy_sfp_intel;
break;
default:
if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
hw->phy.type =
ixgbe_phy_sfp_passive_unknown;
else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
hw->phy.type =
ixgbe_phy_sfp_active_unknown;
else
hw->phy.type = ixgbe_phy_sfp_unknown;
break;
}
}
/* Allow any DA cable vendor */ /* Determine if the SFP+ PHY is dual speed or not. */
if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE | hw->phy.multispeed_fiber = false;
IXGBE_SFF_DA_ACTIVE_CABLE)) { if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
status = 0; (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
goto out; ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
} (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
hw->phy.multispeed_fiber = true;
/* Verify supported 1G SFP modules */ /* Determine PHY vendor */
if (comp_codes_10g == 0 && if (hw->phy.type != ixgbe_phy_nl) {
!(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 || hw->phy.id = identifier;
hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 || status = hw->phy.ops.read_i2c_eeprom(hw,
hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 || IXGBE_SFF_VENDOR_OUI_BYTE0,
hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 || &oui_bytes[0]);
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
hw->phy.type = ixgbe_phy_sfp_unsupported;
status = IXGBE_ERR_SFP_NOT_SUPPORTED;
goto out;
}
/* Anything else 82598-based is supported */ if (status != 0)
if (hw->mac.type == ixgbe_mac_82598EB) { goto err_read_i2c_eeprom;
status = 0;
goto out;
}
hw->mac.ops.get_device_caps(hw, &enforce_sfp); status = hw->phy.ops.read_i2c_eeprom(hw,
if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP) && IXGBE_SFF_VENDOR_OUI_BYTE1,
!(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 || &oui_bytes[1]);
hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 || if (status != 0)
hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 || goto err_read_i2c_eeprom;
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) { status = hw->phy.ops.read_i2c_eeprom(hw,
/* Make sure we're a supported PHY type */ IXGBE_SFF_VENDOR_OUI_BYTE2,
if (hw->phy.type == ixgbe_phy_sfp_intel) { &oui_bytes[2]);
status = 0;
} else { if (status != 0)
if (hw->allow_unsupported_sfp) { goto err_read_i2c_eeprom;
e_warn(drv, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.\n");
status = 0; vendor_oui =
} else { ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
hw_dbg(hw, (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
"SFP+ module not supported\n"); (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
hw->phy.type =
ixgbe_phy_sfp_unsupported; switch (vendor_oui) {
status = IXGBE_ERR_SFP_NOT_SUPPORTED; case IXGBE_SFF_VENDOR_OUI_TYCO:
} if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
} hw->phy.type =
} else { ixgbe_phy_sfp_passive_tyco;
status = 0; break;
case IXGBE_SFF_VENDOR_OUI_FTL:
if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
hw->phy.type = ixgbe_phy_sfp_ftl_active;
else
hw->phy.type = ixgbe_phy_sfp_ftl;
break;
case IXGBE_SFF_VENDOR_OUI_AVAGO:
hw->phy.type = ixgbe_phy_sfp_avago;
break;
case IXGBE_SFF_VENDOR_OUI_INTEL:
hw->phy.type = ixgbe_phy_sfp_intel;
break;
default:
if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
hw->phy.type =
ixgbe_phy_sfp_passive_unknown;
else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
hw->phy.type =
ixgbe_phy_sfp_active_unknown;
else
hw->phy.type = ixgbe_phy_sfp_unknown;
break;
} }
} }
out: /* Allow any DA cable vendor */
return status; if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE |
IXGBE_SFF_DA_ACTIVE_CABLE))
return 0;
/* Verify supported 1G SFP modules */
if (comp_codes_10g == 0 &&
!(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
hw->phy.type = ixgbe_phy_sfp_unsupported;
return IXGBE_ERR_SFP_NOT_SUPPORTED;
}
/* Anything else 82598-based is supported */
if (hw->mac.type == ixgbe_mac_82598EB)
return 0;
hw->mac.ops.get_device_caps(hw, &enforce_sfp);
if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP) &&
!(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
/* Make sure we're a supported PHY type */
if (hw->phy.type == ixgbe_phy_sfp_intel)
return 0;
if (hw->allow_unsupported_sfp) {
e_warn(drv, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.\n");
return 0;
}
hw_dbg(hw, "SFP+ module not supported\n");
hw->phy.type = ixgbe_phy_sfp_unsupported;
return IXGBE_ERR_SFP_NOT_SUPPORTED;
}
return 0;
err_read_i2c_eeprom: err_read_i2c_eeprom:
hw->phy.sfp_type = ixgbe_sfp_type_not_present; hw->phy.sfp_type = ixgbe_sfp_type_not_present;
...@@ -1211,7 +1180,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) ...@@ -1211,7 +1180,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw) static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
{ {
struct ixgbe_adapter *adapter = hw->back; struct ixgbe_adapter *adapter = hw->back;
s32 status = IXGBE_ERR_PHY_ADDR_INVALID; s32 status;
u32 vendor_oui = 0; u32 vendor_oui = 0;
enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type; enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
u8 identifier = 0; u8 identifier = 0;
...@@ -1226,8 +1195,7 @@ static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw) ...@@ -1226,8 +1195,7 @@ static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber_qsfp) { if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber_qsfp) {
hw->phy.sfp_type = ixgbe_sfp_type_not_present; hw->phy.sfp_type = ixgbe_sfp_type_not_present;
status = IXGBE_ERR_SFP_NOT_PRESENT; return IXGBE_ERR_SFP_NOT_PRESENT;
goto out;
} }
status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_IDENTIFIER, status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_IDENTIFIER,
...@@ -1238,8 +1206,7 @@ static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw) ...@@ -1238,8 +1206,7 @@ static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
if (identifier != IXGBE_SFF_IDENTIFIER_QSFP_PLUS) { if (identifier != IXGBE_SFF_IDENTIFIER_QSFP_PLUS) {
hw->phy.type = ixgbe_phy_sfp_unsupported; hw->phy.type = ixgbe_phy_sfp_unsupported;
status = IXGBE_ERR_SFP_NOT_SUPPORTED; return IXGBE_ERR_SFP_NOT_SUPPORTED;
goto out;
} }
hw->phy.id = identifier; hw->phy.id = identifier;
...@@ -1310,8 +1277,7 @@ static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw) ...@@ -1310,8 +1277,7 @@ static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
} else { } else {
/* unsupported module type */ /* unsupported module type */
hw->phy.type = ixgbe_phy_sfp_unsupported; hw->phy.type = ixgbe_phy_sfp_unsupported;
status = IXGBE_ERR_SFP_NOT_SUPPORTED; return IXGBE_ERR_SFP_NOT_SUPPORTED;
goto out;
} }
} }
...@@ -1363,27 +1329,19 @@ static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw) ...@@ -1363,27 +1329,19 @@ static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
hw->mac.ops.get_device_caps(hw, &enforce_sfp); hw->mac.ops.get_device_caps(hw, &enforce_sfp);
if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP)) { if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP)) {
/* Make sure we're a supported PHY type */ /* Make sure we're a supported PHY type */
if (hw->phy.type == ixgbe_phy_qsfp_intel) { if (hw->phy.type == ixgbe_phy_qsfp_intel)
status = 0; return 0;
} else { if (hw->allow_unsupported_sfp) {
if (hw->allow_unsupported_sfp == true) { e_warn(drv, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.\n");
e_warn(drv, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.\n"); return 0;
status = 0;
} else {
hw_dbg(hw,
"QSFP module not supported\n");
hw->phy.type =
ixgbe_phy_sfp_unsupported;
status = IXGBE_ERR_SFP_NOT_SUPPORTED;
}
} }
} else { hw_dbg(hw, "QSFP module not supported\n");
status = 0; hw->phy.type = ixgbe_phy_sfp_unsupported;
return IXGBE_ERR_SFP_NOT_SUPPORTED;
} }
return 0;
} }
return 0;
out:
return status;
err_read_i2c_eeprom: err_read_i2c_eeprom:
hw->phy.sfp_type = ixgbe_sfp_type_not_present; hw->phy.sfp_type = ixgbe_sfp_type_not_present;
...@@ -1544,7 +1502,7 @@ s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset, ...@@ -1544,7 +1502,7 @@ s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset, s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
u8 dev_addr, u8 *data) u8 dev_addr, u8 *data)
{ {
s32 status = 0; s32 status;
u32 max_retry = 10; u32 max_retry = 10;
u32 retry = 0; u32 retry = 0;
u16 swfw_mask = 0; u16 swfw_mask = 0;
...@@ -1557,10 +1515,8 @@ s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset, ...@@ -1557,10 +1515,8 @@ s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
swfw_mask = IXGBE_GSSR_PHY0_SM; swfw_mask = IXGBE_GSSR_PHY0_SM;
do { do {
if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) != 0) { if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
status = IXGBE_ERR_SWFW_SYNC; return IXGBE_ERR_SWFW_SYNC;
goto read_byte_out;
}
ixgbe_i2c_start(hw); ixgbe_i2c_start(hw);
...@@ -1617,7 +1573,6 @@ s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset, ...@@ -1617,7 +1573,6 @@ s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
hw->mac.ops.release_swfw_sync(hw, swfw_mask); hw->mac.ops.release_swfw_sync(hw, swfw_mask);
read_byte_out:
return status; return status;
} }
...@@ -1633,7 +1588,7 @@ s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset, ...@@ -1633,7 +1588,7 @@ s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset, s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
u8 dev_addr, u8 data) u8 dev_addr, u8 data)
{ {
s32 status = 0; s32 status;
u32 max_retry = 1; u32 max_retry = 1;
u32 retry = 0; u32 retry = 0;
u16 swfw_mask = 0; u16 swfw_mask = 0;
...@@ -1643,10 +1598,8 @@ s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset, ...@@ -1643,10 +1598,8 @@ s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
else else
swfw_mask = IXGBE_GSSR_PHY0_SM; swfw_mask = IXGBE_GSSR_PHY0_SM;
if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) != 0) { if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
status = IXGBE_ERR_SWFW_SYNC; return IXGBE_ERR_SWFW_SYNC;
goto write_byte_out;
}
do { do {
ixgbe_i2c_start(hw); ixgbe_i2c_start(hw);
...@@ -1689,7 +1642,6 @@ s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset, ...@@ -1689,7 +1642,6 @@ s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
hw->mac.ops.release_swfw_sync(hw, swfw_mask); hw->mac.ops.release_swfw_sync(hw, swfw_mask);
write_byte_out:
return status; return status;
} }
...@@ -1774,7 +1726,7 @@ static s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data) ...@@ -1774,7 +1726,7 @@ static s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data)
**/ **/
static s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data) static s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data)
{ {
s32 status = 0; s32 status;
s32 i; s32 i;
u32 i2cctl; u32 i2cctl;
bool bit = false; bool bit = false;
...@@ -1893,11 +1845,11 @@ static s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data) ...@@ -1893,11 +1845,11 @@ static s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data)
*/ */
udelay(IXGBE_I2C_T_LOW); udelay(IXGBE_I2C_T_LOW);
} else { } else {
status = IXGBE_ERR_I2C;
hw_dbg(hw, "I2C data was not set to %X\n", data); hw_dbg(hw, "I2C data was not set to %X\n", data);
return IXGBE_ERR_I2C;
} }
return status; return 0;
} }
/** /**
* ixgbe_raise_i2c_clk - Raises the I2C SCL clock * ixgbe_raise_i2c_clk - Raises the I2C SCL clock
...@@ -1954,8 +1906,6 @@ static void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl) ...@@ -1954,8 +1906,6 @@ static void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
**/ **/
static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data) static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data)
{ {
s32 status = 0;
if (data) if (data)
*i2cctl |= IXGBE_I2C_DATA_OUT; *i2cctl |= IXGBE_I2C_DATA_OUT;
else else
...@@ -1970,11 +1920,11 @@ static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data) ...@@ -1970,11 +1920,11 @@ static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data)
/* Verify data was set correctly */ /* Verify data was set correctly */
*i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL); *i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL);
if (data != ixgbe_get_i2c_data(i2cctl)) { if (data != ixgbe_get_i2c_data(i2cctl)) {
status = IXGBE_ERR_I2C;
hw_dbg(hw, "Error - I2C data was not set to %X.\n", data); hw_dbg(hw, "Error - I2C data was not set to %X.\n", data);
return IXGBE_ERR_I2C;
} }
return status; return 0;
} }
/** /**
...@@ -1986,14 +1936,9 @@ static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data) ...@@ -1986,14 +1936,9 @@ static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data)
**/ **/
static bool ixgbe_get_i2c_data(u32 *i2cctl) static bool ixgbe_get_i2c_data(u32 *i2cctl)
{ {
bool data;
if (*i2cctl & IXGBE_I2C_DATA_IN) if (*i2cctl & IXGBE_I2C_DATA_IN)
data = true; return true;
else return false;
data = false;
return data;
} }
/** /**
...@@ -2038,20 +1983,17 @@ static void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw) ...@@ -2038,20 +1983,17 @@ static void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw)
**/ **/
s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw) s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
{ {
s32 status = 0;
u16 phy_data = 0; u16 phy_data = 0;
if (hw->device_id != IXGBE_DEV_ID_82599_T3_LOM) if (hw->device_id != IXGBE_DEV_ID_82599_T3_LOM)
goto out; return 0;
/* Check that the LASI temp alarm status was triggered */ /* Check that the LASI temp alarm status was triggered */
hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG, hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG,
MDIO_MMD_PMAPMD, &phy_data); MDIO_MMD_PMAPMD, &phy_data);
if (!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM)) if (!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM))
goto out; return 0;
status = IXGBE_ERR_OVERTEMP; return IXGBE_ERR_OVERTEMP;
out:
return status;
} }
/******************************************************************************* /*******************************************************************************
Intel 10 Gigabit PCI Express Linux driver Intel 10 Gigabit PCI Express Linux driver
Copyright(c) 1999 - 2013 Intel Corporation. Copyright(c) 1999 - 2014 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
...@@ -245,10 +245,10 @@ static int ixgbe_pci_sriov_enable(struct pci_dev *dev, int num_vfs) ...@@ -245,10 +245,10 @@ static int ixgbe_pci_sriov_enable(struct pci_dev *dev, int num_vfs)
if (pre_existing_vfs && pre_existing_vfs != num_vfs) if (pre_existing_vfs && pre_existing_vfs != num_vfs)
err = ixgbe_disable_sriov(adapter); err = ixgbe_disable_sriov(adapter);
else if (pre_existing_vfs && pre_existing_vfs == num_vfs) else if (pre_existing_vfs && pre_existing_vfs == num_vfs)
goto out; return num_vfs;
if (err) if (err)
goto err_out; return err;
/* While the SR-IOV capability structure reports total VFs to be /* While the SR-IOV capability structure reports total VFs to be
* 64 we limit the actual number that can be allocated to 63 so * 64 we limit the actual number that can be allocated to 63 so
...@@ -256,16 +256,14 @@ static int ixgbe_pci_sriov_enable(struct pci_dev *dev, int num_vfs) ...@@ -256,16 +256,14 @@ static int ixgbe_pci_sriov_enable(struct pci_dev *dev, int num_vfs)
* PF. The PCI bus driver already checks for other values out of * PF. The PCI bus driver already checks for other values out of
* range. * range.
*/ */
if (num_vfs > IXGBE_MAX_VFS_DRV_LIMIT) { if (num_vfs > IXGBE_MAX_VFS_DRV_LIMIT)
err = -EPERM; return -EPERM;
goto err_out;
}
adapter->num_vfs = num_vfs; adapter->num_vfs = num_vfs;
err = __ixgbe_enable_sriov(adapter); err = __ixgbe_enable_sriov(adapter);
if (err) if (err)
goto err_out; return err;
for (i = 0; i < adapter->num_vfs; i++) for (i = 0; i < adapter->num_vfs; i++)
ixgbe_vf_configuration(dev, (i | 0x10000000)); ixgbe_vf_configuration(dev, (i | 0x10000000));
...@@ -273,17 +271,14 @@ static int ixgbe_pci_sriov_enable(struct pci_dev *dev, int num_vfs) ...@@ -273,17 +271,14 @@ static int ixgbe_pci_sriov_enable(struct pci_dev *dev, int num_vfs)
err = pci_enable_sriov(dev, num_vfs); err = pci_enable_sriov(dev, num_vfs);
if (err) { if (err) {
e_dev_warn("Failed to enable PCI sriov: %d\n", err); e_dev_warn("Failed to enable PCI sriov: %d\n", err);
goto err_out; return err;
} }
ixgbe_sriov_reinit(adapter); ixgbe_sriov_reinit(adapter);
out:
return num_vfs; return num_vfs;
#else
err_out:
return err;
#endif
return 0; return 0;
#endif
} }
static int ixgbe_pci_sriov_disable(struct pci_dev *dev) static int ixgbe_pci_sriov_disable(struct pci_dev *dev)
...@@ -807,7 +802,7 @@ static int ixgbe_set_vf_vlan_msg(struct ixgbe_adapter *adapter, ...@@ -807,7 +802,7 @@ static int ixgbe_set_vf_vlan_msg(struct ixgbe_adapter *adapter,
if (!add && adapter->netdev->flags & IFF_PROMISC) { if (!add && adapter->netdev->flags & IFF_PROMISC) {
reg_ndx = ixgbe_find_vlvf_entry(hw, vid); reg_ndx = ixgbe_find_vlvf_entry(hw, vid);
if (reg_ndx < 0) if (reg_ndx < 0)
goto out; return err;
vlvf = IXGBE_READ_REG(hw, IXGBE_VLVF(reg_ndx)); vlvf = IXGBE_READ_REG(hw, IXGBE_VLVF(reg_ndx));
/* See if any other pools are set for this VLAN filter /* See if any other pools are set for this VLAN filter
* entry other than the PF. * entry other than the PF.
...@@ -833,8 +828,6 @@ static int ixgbe_set_vf_vlan_msg(struct ixgbe_adapter *adapter, ...@@ -833,8 +828,6 @@ static int ixgbe_set_vf_vlan_msg(struct ixgbe_adapter *adapter,
ixgbe_set_vf_vlan(adapter, add, vid, VMDQ_P(0)); ixgbe_set_vf_vlan(adapter, add, vid, VMDQ_P(0));
} }
out:
return err; return err;
} }
...@@ -951,7 +944,7 @@ static int ixgbe_rcv_msg_from_vf(struct ixgbe_adapter *adapter, u32 vf) ...@@ -951,7 +944,7 @@ static int ixgbe_rcv_msg_from_vf(struct ixgbe_adapter *adapter, u32 vf)
/* this is a message we already processed, do nothing */ /* this is a message we already processed, do nothing */
if (msgbuf[0] & (IXGBE_VT_MSGTYPE_ACK | IXGBE_VT_MSGTYPE_NACK)) if (msgbuf[0] & (IXGBE_VT_MSGTYPE_ACK | IXGBE_VT_MSGTYPE_NACK))
return retval; return 0;
/* flush the ack before we write any messages back */ /* flush the ack before we write any messages back */
IXGBE_WRITE_FLUSH(hw); IXGBE_WRITE_FLUSH(hw);
...@@ -966,7 +959,7 @@ static int ixgbe_rcv_msg_from_vf(struct ixgbe_adapter *adapter, u32 vf) ...@@ -966,7 +959,7 @@ static int ixgbe_rcv_msg_from_vf(struct ixgbe_adapter *adapter, u32 vf)
if (!adapter->vfinfo[vf].clear_to_send) { if (!adapter->vfinfo[vf].clear_to_send) {
msgbuf[0] |= IXGBE_VT_MSGTYPE_NACK; msgbuf[0] |= IXGBE_VT_MSGTYPE_NACK;
ixgbe_write_mbx(hw, msgbuf, 1, vf); ixgbe_write_mbx(hw, msgbuf, 1, vf);
return retval; return 0;
} }
switch ((msgbuf[0] & 0xFFFF)) { switch ((msgbuf[0] & 0xFFFF)) {
......
...@@ -99,8 +99,8 @@ static s32 ixgbe_reset_hw_X540(struct ixgbe_hw *hw) ...@@ -99,8 +99,8 @@ static s32 ixgbe_reset_hw_X540(struct ixgbe_hw *hw)
/* Call adapter stop to disable tx/rx and clear interrupts */ /* Call adapter stop to disable tx/rx and clear interrupts */
status = hw->mac.ops.stop_adapter(hw); status = hw->mac.ops.stop_adapter(hw);
if (status != 0) if (status)
goto reset_hw_out; return status;
/* flush pending Tx transactions */ /* flush pending Tx transactions */
ixgbe_clear_tx_pending(hw); ixgbe_clear_tx_pending(hw);
...@@ -168,7 +168,6 @@ static s32 ixgbe_reset_hw_X540(struct ixgbe_hw *hw) ...@@ -168,7 +168,6 @@ static s32 ixgbe_reset_hw_X540(struct ixgbe_hw *hw)
hw->mac.ops.get_wwn_prefix(hw, &hw->mac.wwnn_prefix, hw->mac.ops.get_wwn_prefix(hw, &hw->mac.wwnn_prefix,
&hw->mac.wwpn_prefix); &hw->mac.wwpn_prefix);
reset_hw_out:
return status; return status;
} }
...@@ -182,15 +181,13 @@ static s32 ixgbe_reset_hw_X540(struct ixgbe_hw *hw) ...@@ -182,15 +181,13 @@ static s32 ixgbe_reset_hw_X540(struct ixgbe_hw *hw)
**/ **/
static s32 ixgbe_start_hw_X540(struct ixgbe_hw *hw) static s32 ixgbe_start_hw_X540(struct ixgbe_hw *hw)
{ {
s32 ret_val = 0; s32 ret_val;
ret_val = ixgbe_start_hw_generic(hw); ret_val = ixgbe_start_hw_generic(hw);
if (ret_val != 0) if (ret_val)
goto out; return ret_val;
ret_val = ixgbe_start_hw_gen2(hw); return ixgbe_start_hw_gen2(hw);
out:
return ret_val;
} }
/** /**
...@@ -483,12 +480,12 @@ static s32 ixgbe_update_eeprom_checksum_X540(struct ixgbe_hw *hw) ...@@ -483,12 +480,12 @@ static s32 ixgbe_update_eeprom_checksum_X540(struct ixgbe_hw *hw)
static s32 ixgbe_update_flash_X540(struct ixgbe_hw *hw) static s32 ixgbe_update_flash_X540(struct ixgbe_hw *hw)
{ {
u32 flup; u32 flup;
s32 status = IXGBE_ERR_EEPROM; s32 status;
status = ixgbe_poll_flash_update_done_X540(hw); status = ixgbe_poll_flash_update_done_X540(hw);
if (status == IXGBE_ERR_EEPROM) { if (status == IXGBE_ERR_EEPROM) {
hw_dbg(hw, "Flash update time out\n"); hw_dbg(hw, "Flash update time out\n");
goto out; return status;
} }
flup = IXGBE_READ_REG(hw, IXGBE_EEC) | IXGBE_EEC_FLUP; flup = IXGBE_READ_REG(hw, IXGBE_EEC) | IXGBE_EEC_FLUP;
...@@ -514,7 +511,7 @@ static s32 ixgbe_update_flash_X540(struct ixgbe_hw *hw) ...@@ -514,7 +511,7 @@ static s32 ixgbe_update_flash_X540(struct ixgbe_hw *hw)
else else
hw_dbg(hw, "Flash update time out\n"); hw_dbg(hw, "Flash update time out\n");
} }
out:
return status; return status;
} }
...@@ -529,17 +526,14 @@ static s32 ixgbe_poll_flash_update_done_X540(struct ixgbe_hw *hw) ...@@ -529,17 +526,14 @@ static s32 ixgbe_poll_flash_update_done_X540(struct ixgbe_hw *hw)
{ {
u32 i; u32 i;
u32 reg; u32 reg;
s32 status = IXGBE_ERR_EEPROM;
for (i = 0; i < IXGBE_FLUDONE_ATTEMPTS; i++) { for (i = 0; i < IXGBE_FLUDONE_ATTEMPTS; i++) {
reg = IXGBE_READ_REG(hw, IXGBE_EEC); reg = IXGBE_READ_REG(hw, IXGBE_EEC);
if (reg & IXGBE_EEC_FLUDONE) { if (reg & IXGBE_EEC_FLUDONE)
status = 0; return 0;
break;
}
udelay(5); udelay(5);
} }
return status; return IXGBE_ERR_EEPROM;
} }
/** /**
......
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