If an SFP+ module is not inserted, don't try to access SFP+ EEPROM.

This change eliminate long timeout.

 Reduce code duplication using with ixgbe_sfp_cage_full(hw).
This commit is contained in:
msaitoh 2020-08-31 11:19:54 +00:00
parent 90a952c9c5
commit 167aba13e5
6 changed files with 57 additions and 84 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ixgbe.c,v 1.250 2020/08/31 06:23:19 msaitoh Exp $ */
/* $NetBSD: ixgbe.c,v 1.251 2020/08/31 11:19:54 msaitoh Exp $ */
/******************************************************************************
@ -70,6 +70,7 @@
#endif
#include "ixgbe.h"
#include "ixgbe_phy.h"
#include "ixgbe_sriov.h"
#include "vlan.h"
@ -257,9 +258,6 @@ static int ixgbe_sysctl_debug(SYSCTLFN_PROTO);
static int ixgbe_sysctl_wol_enable(SYSCTLFN_PROTO);
static int ixgbe_sysctl_wufc(SYSCTLFN_PROTO);
/* Support for pluggable optic modules */
static bool ixgbe_sfp_cage_full(struct adapter *);
/* Legacy (single vector) interrupt handler */
static int ixgbe_legacy_irq(void *);
@ -786,7 +784,7 @@ ixgbe_quirks(struct adapter *adapter)
(strcmp(product, "MA10-ST0") == 0)) {
aprint_verbose_dev(dev,
"Enable SFP+ MOD_ABS inverse quirk\n");
adapter->quirks |= IXGBE_QUIRK_MOD_ABS_INVERT;
adapter->hw.quirks |= IXGBE_QUIRK_MOD_ABS_INVERT;
}
}
}
@ -4519,7 +4517,7 @@ ixgbe_handle_timer(struct work *wk, void *context)
was_full =
hw->phy.sfp_type != ixgbe_sfp_type_not_present;
is_full = ixgbe_sfp_cage_full(adapter);
is_full = ixgbe_sfp_cage_full(hw);
/* Do probe if cage state changed */
if (was_full ^ is_full)
@ -4660,35 +4658,6 @@ ixgbe_handle_recovery_mode_timer(struct work *wk, void *context)
IXGBE_CORE_UNLOCK(adapter);
} /* ixgbe_handle_recovery_mode_timer */
/************************************************************************
* ixgbe_sfp_cage_full
*
* Determine if a port had optics inserted.
************************************************************************/
static bool
ixgbe_sfp_cage_full(struct adapter *adapter)
{
struct ixgbe_hw *hw = &adapter->hw;
uint32_t mask;
int rv;
if (hw->mac.type >= ixgbe_mac_X540)
mask = IXGBE_ESDP_SDP0;
else
mask = IXGBE_ESDP_SDP2;
rv = IXGBE_READ_REG(hw, IXGBE_ESDP) & mask;
if ((adapter->quirks & IXGBE_QUIRK_MOD_ABS_INVERT) != 0)
rv = !rv;
if (hw->mac.type == ixgbe_mac_X550EM_a) {
/* X550EM_a's SDP0 is inverted than others. */
return !rv;
}
return rv;
} /* ixgbe_sfp_cage_full */
/************************************************************************
* ixgbe_handle_mod - Tasklet for SFP module interrupts
************************************************************************/
@ -4699,32 +4668,15 @@ ixgbe_handle_mod(void *context)
struct ixgbe_hw *hw = &adapter->hw;
device_t dev = adapter->dev;
enum ixgbe_sfp_type last_sfp_type;
u32 err, cage_full = 0;
u32 err;
bool last_unsupported_sfp_recovery;
last_sfp_type = hw->phy.sfp_type;
last_unsupported_sfp_recovery = hw->need_unsupported_sfp_recovery;
++adapter->mod_workev.ev_count;
if (adapter->hw.need_crosstalk_fix) {
switch (hw->mac.type) {
case ixgbe_mac_82599EB:
cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) &
IXGBE_ESDP_SDP2;
break;
case ixgbe_mac_X550EM_x:
case ixgbe_mac_X550EM_a:
/*
* XXX See ixgbe_sfp_cage_full(). It seems the bit is
* inverted on X550EM_a, so I think this is incorrect.
*/
cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) &
IXGBE_ESDP_SDP0;
break;
default:
break;
}
if (!cage_full)
if ((hw->mac.type != ixgbe_mac_82598EB) &&
!ixgbe_sfp_cage_full(hw))
goto out;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ixgbe.h,v 1.70 2020/08/27 00:07:56 msaitoh Exp $ */
/* $NetBSD: ixgbe.h,v 1.71 2020/08/31 11:19:54 msaitoh Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@ -623,9 +623,6 @@ struct adapter {
u32 feat_cap;
u32 feat_en;
/* Quirks */
u32 quirks;
/* Traffic classes */
struct ixgbe_tc tcs[IXGBE_DCB_MAX_TRAFFIC_CLASS];
@ -773,8 +770,6 @@ bool ixgbe_rxeof(struct ix_queue *);
#define IXGBE_REQUEST_TASK_LSC 0x20
#define IXGBE_REQUEST_TASK_NEED_ACKINTR 0x80
#define IXGBE_QUIRK_MOD_ABS_INVERT __BIT(0)
/* For NetBSD */
const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *);
void ixgbe_jcl_reinit(struct adapter *, bus_dma_tag_t, struct rx_ring *,

View File

@ -1,4 +1,4 @@
/* $NetBSD: ixgbe_common.c,v 1.28 2020/08/27 03:57:52 msaitoh Exp $ */
/* $NetBSD: ixgbe_common.c,v 1.29 2020/08/31 11:19:54 msaitoh Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@ -4267,25 +4267,8 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
* the SFP+ cage is full.
*/
if (ixgbe_need_crosstalk_fix(hw)) {
u32 sfp_cage_full;
switch (hw->mac.type) {
case ixgbe_mac_82599EB:
sfp_cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) &
IXGBE_ESDP_SDP2;
break;
case ixgbe_mac_X550EM_x:
case ixgbe_mac_X550EM_a:
sfp_cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) &
IXGBE_ESDP_SDP0;
break;
default:
/* sanity check - No SFP+ devices here */
sfp_cage_full = FALSE;
break;
}
if (!sfp_cage_full) {
if ((hw->mac.type != ixgbe_mac_82598EB) &&
!ixgbe_sfp_cage_full(hw)) {
*link_up = FALSE;
*speed = IXGBE_LINK_SPEED_UNKNOWN;
return IXGBE_SUCCESS;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ixgbe_phy.c,v 1.22 2020/08/31 06:20:06 msaitoh Exp $ */
/* $NetBSD: ixgbe_phy.c,v 1.23 2020/08/31 11:19:54 msaitoh Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@ -1288,6 +1288,36 @@ err_eeprom:
return IXGBE_ERR_PHY;
}
/************************************************************************
* ixgbe_sfp_cage_full
*
* Determine if an SFP+ module is inserted to the cage.
************************************************************************/
bool
ixgbe_sfp_cage_full(struct ixgbe_hw *hw)
{
uint32_t mask;
int rv;
KASSERT(hw->mac.type != ixgbe_mac_82598EB);
if (hw->mac.type >= ixgbe_mac_X540)
mask = IXGBE_ESDP_SDP0;
else
mask = IXGBE_ESDP_SDP2;
rv = IXGBE_READ_REG(hw, IXGBE_ESDP) & mask;
if ((hw->quirks & IXGBE_QUIRK_MOD_ABS_INVERT) != 0)
rv = !rv;
if (hw->mac.type == ixgbe_mac_X550EM_a) {
/* X550EM_a's SDP0 is inverted than others. */
return !rv;
}
return rv;
} /* ixgbe_sfp_cage_full */
/**
* ixgbe_identify_module_generic - Identifies module type
* @hw: pointer to hardware structure
@ -1300,6 +1330,14 @@ s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw)
DEBUGFUNC("ixgbe_identify_module_generic");
/* Lightweight way to check if the cage is not full. */
if (hw->mac.type != ixgbe_mac_82598EB) {
if (!ixgbe_sfp_cage_full(hw)) {
hw->phy.sfp_type = ixgbe_sfp_type_not_present;
return IXGBE_ERR_SFP_NOT_PRESENT;
}
}
switch (hw->mac.ops.get_media_type(hw)) {
case ixgbe_media_type_fiber:
status = ixgbe_identify_sfp_module_generic(hw);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ixgbe_phy.h,v 1.11 2018/04/04 08:13:07 msaitoh Exp $ */
/* $NetBSD: ixgbe_phy.h,v 1.12 2020/08/31 11:19:54 msaitoh Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@ -194,6 +194,7 @@ s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw,
s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw);
s32 ixgbe_set_copper_phy_power(struct ixgbe_hw *hw, bool on);
bool ixgbe_sfp_cage_full(struct ixgbe_hw *hw);
s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw);
s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw);
u64 ixgbe_get_supported_phy_sfp_layer_generic(struct ixgbe_hw *hw);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ixgbe_type.h,v 1.44 2019/12/23 09:36:18 msaitoh Exp $ */
/* $NetBSD: ixgbe_type.h,v 1.45 2020/08/31 11:19:54 msaitoh Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@ -4264,6 +4264,7 @@ struct ixgbe_hw {
bool wol_enabled;
bool need_crosstalk_fix;
bool need_unsupported_sfp_recovery;
u32 quirks;
};
#define ixgbe_call_func(hw, func, params, error) \
@ -4537,4 +4538,7 @@ struct ixgbe_bypass_eeprom {
#define IXGBE_HOST_INTERFACE_APPLY_UPDATE_CMD 0x38
#define IXGBE_HOST_INTERFACE_MASK_CMD 0x000000FF
/* Flags for hw.quirks */
#define IXGBE_QUIRK_MOD_ABS_INVERT __BIT(0)
#endif /* _IXGBE_TYPE_H_ */