Module Name: src Committed By: msaitoh Date: Mon Aug 31 11:19:54 UTC 2020
Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h ixgbe_common.c ixgbe_phy.c ixgbe_phy.h ixgbe_type.h Log Message: 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). To generate a diff of this commit: cvs rdiff -u -r1.250 -r1.251 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.70 -r1.71 src/sys/dev/pci/ixgbe/ixgbe.h cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/ixgbe/ixgbe_common.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/ixgbe/ixgbe_phy.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/ixgbe/ixgbe_phy.h cvs rdiff -u -r1.44 -r1.45 src/sys/dev/pci/ixgbe/ixgbe_type.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.250 src/sys/dev/pci/ixgbe/ixgbe.c:1.251 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.250 Mon Aug 31 06:23:19 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 31 11:19:54 2020 @@ -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_P 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 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) @@ -4661,35 +4659,6 @@ ixgbe_handle_recovery_mode_timer(struct } /* 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 ************************************************************************/ static void @@ -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; } Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.70 src/sys/dev/pci/ixgbe/ixgbe.h:1.71 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.70 Thu Aug 27 00:07:56 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.h Mon Aug 31 11:19:54 2020 @@ -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 *, Index: src/sys/dev/pci/ixgbe/ixgbe_common.c diff -u src/sys/dev/pci/ixgbe/ixgbe_common.c:1.28 src/sys/dev/pci/ixgbe/ixgbe_common.c:1.29 --- src/sys/dev/pci/ixgbe/ixgbe_common.c:1.28 Thu Aug 27 03:57:52 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_common.c Mon Aug 31 11:19:54 2020 @@ -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 * 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; Index: src/sys/dev/pci/ixgbe/ixgbe_phy.c diff -u src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.22 src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.23 --- src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.22 Mon Aug 31 06:20:06 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_phy.c Mon Aug 31 11:19:54 2020 @@ -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 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); Index: src/sys/dev/pci/ixgbe/ixgbe_phy.h diff -u src/sys/dev/pci/ixgbe/ixgbe_phy.h:1.11 src/sys/dev/pci/ixgbe/ixgbe_phy.h:1.12 --- src/sys/dev/pci/ixgbe/ixgbe_phy.h:1.11 Wed Apr 4 08:13:07 2018 +++ src/sys/dev/pci/ixgbe/ixgbe_phy.h Mon Aug 31 11:19:54 2020 @@ -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_gener 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); Index: src/sys/dev/pci/ixgbe/ixgbe_type.h diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.44 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.45 --- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.44 Mon Dec 23 09:36:18 2019 +++ src/sys/dev/pci/ixgbe/ixgbe_type.h Mon Aug 31 11:19:54 2020 @@ -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_ */