From d10c7b638c0f0957106caa2703f4150fbcf65642 Mon Sep 17 00:00:00 2001 From: Xiao Wang Date: Sun, 25 Sep 2016 17:00:01 +0800 Subject: [PATCH] net/ixgbe/base: use default check link for X550em_a This patch removes the X550em_a specific check link function and uses ixgbe_check_mac_link_generic instead. It is not necessary to check both the MAC link register and external PHY registers when checking the link. Signed-off-by: Xiao Wang Acked-by: Wenzhuo Lu --- drivers/net/ixgbe/base/ixgbe_common.c | 7 +++ drivers/net/ixgbe/base/ixgbe_type.h | 1 + drivers/net/ixgbe/base/ixgbe_x550.c | 78 +++------------------------ 3 files changed, 16 insertions(+), 70 deletions(-) diff --git a/drivers/net/ixgbe/base/ixgbe_common.c b/drivers/net/ixgbe/base/ixgbe_common.c index c01f9196ce..985fecea0a 100644 --- a/drivers/net/ixgbe/base/ixgbe_common.c +++ b/drivers/net/ixgbe/base/ixgbe_common.c @@ -4173,6 +4173,13 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed, *speed = IXGBE_LINK_SPEED_5GB_FULL; } break; + case IXGBE_LINKS_SPEED_10_X550EM_A: + *speed = IXGBE_LINK_SPEED_UNKNOWN; + if (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T || + hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L) { + *speed = IXGBE_LINK_SPEED_10_FULL; + } + break; default: *speed = IXGBE_LINK_SPEED_UNKNOWN; } diff --git a/drivers/net/ixgbe/base/ixgbe_type.h b/drivers/net/ixgbe/base/ixgbe_type.h index 70f684cb60..f1e4274d4e 100644 --- a/drivers/net/ixgbe/base/ixgbe_type.h +++ b/drivers/net/ixgbe/base/ixgbe_type.h @@ -2213,6 +2213,7 @@ enum { #define IXGBE_LINKS_SPEED_10G_82599 0x30000000 #define IXGBE_LINKS_SPEED_1G_82599 0x20000000 #define IXGBE_LINKS_SPEED_100_82599 0x10000000 +#define IXGBE_LINKS_SPEED_10_X550EM_A 0x00000000 #define IXGBE_LINK_UP_TIME 90 /* 9.0 Seconds */ #define IXGBE_AUTO_NEG_TIME 45 /* 4.5 Seconds */ diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c b/drivers/net/ixgbe/base/ixgbe_x550.c index a9f4d2a090..3c1932617b 100644 --- a/drivers/net/ixgbe/base/ixgbe_x550.c +++ b/drivers/net/ixgbe/base/ixgbe_x550.c @@ -1715,72 +1715,6 @@ STATIC s32 ixgbe_setup_sgmii_m88(struct ixgbe_hw *hw, ixgbe_link_speed speed, return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait); } -/** - * ixgbe_check_link_m88 - Poll PHY for link - * @hw: pointer to hardware structure - * @speed: pointer to link speed - * @link_up: true when link is up - * @link_up_wait: bool indicating whether to wait for link - * - * Check that both the MAC and PHY have link. - */ -static s32 -ixgbe_check_link_m88(struct ixgbe_hw *hw, ixgbe_link_speed *speed, - bool *link_up, bool link_up_wait) -{ - u16 reg; - s32 rc; - u32 i; - - rc = ixgbe_check_mac_link_generic(hw, speed, link_up, link_up_wait); - if (rc || !*link_up) - return rc; - - rc = hw->phy.ops.read_reg(hw, IXGBE_M88E1500_PHY_SPEC_STATUS, 0, ®); - - /* MAC link is up, so check external PHY link */ - *link_up = !!(reg & IXGBE_M88E1500_PHY_SPEC_STATUS_LINK); - - if (link_up_wait) { - for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) { - if (!rc && - (reg & IXGBE_M88E1500_PHY_SPEC_STATUS_LINK)) { - *link_up = true; - break; - } - *link_up = false; - msec_delay(100); - rc = hw->phy.ops.read_reg(hw, - IXGBE_M88E1500_PHY_SPEC_STATUS, - 0, ®); - } - } - -#define M88_SPEED(x) (IXGBE_M88E1500_PHY_SPEC_STATUS_RESOLVED | \ - IXGBE_M88E1500_PHY_SPEC_STATUS_DUPLEX | \ - ((IXGBE_M88E1500_PHY_SPEC_STATUS_SPEED_##x) <<\ - IXGBE_M88E1500_PHY_SPEC_STATUS_SPEED_SHIFT)) - - reg &= M88_SPEED(MASK); - switch (reg) { - case M88_SPEED(10): - *speed = IXGBE_LINK_SPEED_10_FULL; - break; - case M88_SPEED(100): - *speed = IXGBE_LINK_SPEED_100_FULL; - break; - case M88_SPEED(1000): - *speed = IXGBE_LINK_SPEED_1GB_FULL; - break; - default: - *speed = IXGBE_LINK_SPEED_UNKNOWN; - break; - } -#undef M88_SPEED - - return rc; -} - /** * ixgbe_init_mac_link_ops_X550em - init mac link function pointers * @hw: pointer to hardware structure @@ -1811,10 +1745,14 @@ void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw) ixgbe_setup_mac_link_sfp_x550em; break; case ixgbe_media_type_copper: - if (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L) { - mac->ops.setup_link = ixgbe_setup_sgmii_m88; - mac->ops.check_link = ixgbe_check_link_m88; + if (hw->mac.type == ixgbe_mac_X550EM_a) { + if (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T || + hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L) { + mac->ops.setup_link = ixgbe_setup_sgmii_m88; + } else { + mac->ops.setup_link = + ixgbe_setup_mac_link_t_X550em; + } } else { mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em; mac->ops.check_link = ixgbe_check_link_t_X550em; -- 2.20.1