net/ixgbe/base: use default check link for X550em_a
authorXiao Wang <xiao.w.wang@intel.com>
Sun, 25 Sep 2016 09:00:01 +0000 (17:00 +0800)
committerBruce Richardson <bruce.richardson@intel.com>
Fri, 30 Sep 2016 10:27:18 +0000 (12:27 +0200)
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 <xiao.w.wang@intel.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
drivers/net/ixgbe/base/ixgbe_common.c
drivers/net/ixgbe/base/ixgbe_type.h
drivers/net/ixgbe/base/ixgbe_x550.c

index c01f919..985fece 100644 (file)
@@ -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;
        }
index 70f684c..f1e4274 100644 (file)
@@ -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 */
 
index a9f4d2a..3c19326 100644 (file)
@@ -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, &reg);
-
-       /* 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, &reg);
-               }
-       }
-
-#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;