alx_write_mem32(hw, ALX_TXQ0, txq | ALX_TXQ0_EN);
 
        mac = hw->rx_ctrl;
-       if (hw->link_speed % 10 == DUPLEX_FULL)
+       if (hw->duplex == DUPLEX_FULL)
                mac |= ALX_MAC_CTRL_FULLD;
        else
                mac &= ~ALX_MAC_CTRL_FULLD;
        ALX_SET_FIELD(mac, ALX_MAC_CTRL_SPEED,
-                     hw->link_speed >= SPEED_1000 ? ALX_MAC_CTRL_SPEED_1000 :
+                     hw->link_speed == SPEED_1000 ? ALX_MAC_CTRL_SPEED_1000 :
                                                     ALX_MAC_CTRL_SPEED_10_100);
        mac |= ALX_MAC_CTRL_TX_EN | ALX_MAC_CTRL_RX_EN;
        hw->rx_ctrl = mac;
        u16 phy_val, len, agc;
        u8 revid = alx_hw_revision(hw);
        bool adj_th = revid == ALX_REV_B0;
-       int speed;
-
-       if (hw->link_speed == SPEED_UNKNOWN)
-               speed = SPEED_UNKNOWN;
-       else
-               speed = hw->link_speed - hw->link_speed % 10;
 
        if (revid != ALX_REV_B0 && !alx_is_rev_a(revid))
                return;
 
        /* 1000BT/AZ, wrong cable length */
-       if (speed != SPEED_UNKNOWN) {
+       if (hw->link_speed != SPEED_UNKNOWN) {
                alx_read_phy_ext(hw, ALX_MIIEXT_PCS, ALX_MIIEXT_CLDCTRL6,
                                 &phy_val);
                len = ALX_GET_FIELD(phy_val, ALX_CLDCTRL6_CAB_LEN);
                alx_read_phy_dbg(hw, ALX_MIIDBG_AGC, &phy_val);
                agc = ALX_GET_FIELD(phy_val, ALX_AGC_2_VGA);
 
-               if ((speed == SPEED_1000 &&
+               if ((hw->link_speed == SPEED_1000 &&
                     (len > ALX_CLDCTRL6_CAB_LEN_SHORT1G ||
                      (len == 0 && agc > ALX_AGC_LONG1G_LIMT))) ||
-                   (speed == SPEED_100 &&
+                   (hw->link_speed == SPEED_100 &&
                     (len > ALX_CLDCTRL6_CAB_LEN_SHORT100M ||
                      (len == 0 && agc > ALX_AGC_LONG100M_LIMT)))) {
                        alx_write_phy_dbg(hw, ALX_MIIDBG_AZ_ANADECT,
 
                /* threshold adjust */
                if (adj_th && hw->lnk_patch) {
-                       if (speed == SPEED_100) {
+                       if (hw->link_speed == SPEED_100) {
                                alx_write_phy_dbg(hw, ALX_MIIDBG_MSE16DB,
                                                  ALX_MSE16DB_UP);
-                       } else if (speed == SPEED_1000) {
+                       } else if (hw->link_speed == SPEED_1000) {
                                /*
                                 * Giga link threshold, raise the tolerance of
                                 * noise 50%
  *    1. phy link must be established before calling this function
  *    2. wol option (pattern,magic,link,etc.) is configed before call it.
  */
-int alx_pre_suspend(struct alx_hw *hw, int speed)
+int alx_pre_suspend(struct alx_hw *hw, int speed, u8 duplex)
 {
        u32 master, mac, phy, val;
        int err = 0;
                        mac |= ALX_MAC_CTRL_RX_EN | ALX_MAC_CTRL_BRD_EN;
                if (hw->sleep_ctrl & ALX_SLEEP_CIFS)
                        mac |= ALX_MAC_CTRL_TX_EN;
-               if (speed % 10 == DUPLEX_FULL)
+               if (duplex == DUPLEX_FULL)
                        mac |= ALX_MAC_CTRL_FULLD;
-               if (speed >= SPEED_1000)
+               if (speed == SPEED_1000)
                        ALX_SET_FIELD(mac, ALX_MAC_CTRL_SPEED,
                                      ALX_MAC_CTRL_SPEED_1000);
                phy |= ALX_PHY_CTRL_DSPRST_OUT;
        return cfg == hw_cfg;
 }
 
-int alx_get_phy_link(struct alx_hw *hw, int *speed)
+int alx_read_phy_link(struct alx_hw *hw)
 {
        struct pci_dev *pdev = hw->pdev;
        u16 bmsr, giga;
                return err;
 
        if (!(bmsr & BMSR_LSTATUS)) {
-               *speed = SPEED_UNKNOWN;
+               hw->link_speed = SPEED_UNKNOWN;
+               hw->duplex = DUPLEX_UNKNOWN;
                return 0;
        }
 
 
        switch (giga & ALX_GIGA_PSSR_SPEED) {
        case ALX_GIGA_PSSR_1000MBS:
-               *speed = SPEED_1000;
+               hw->link_speed = SPEED_1000;
                break;
        case ALX_GIGA_PSSR_100MBS:
-               *speed = SPEED_100;
+               hw->link_speed = SPEED_100;
                break;
        case ALX_GIGA_PSSR_10MBS:
-               *speed = SPEED_10;
+               hw->link_speed = SPEED_10;
                break;
        default:
                goto wrong_speed;
        }
 
-       *speed += (giga & ALX_GIGA_PSSR_DPLX) ? DUPLEX_FULL : DUPLEX_HALF;
-       return 1;
+       hw->duplex = (giga & ALX_GIGA_PSSR_DPLX) ? DUPLEX_FULL : DUPLEX_HALF;
+       return 0;
 
 wrong_speed:
        dev_err(&pdev->dev, "invalid PHY speed/duplex: 0x%x\n", giga);
        alx_write_mem32(hw, ALX_WRR, val);
 }
 
-static inline u32 alx_speed_to_ethadv(int speed)
-{
-       switch (speed) {
-       case SPEED_1000 + DUPLEX_FULL:
-               return ADVERTISED_1000baseT_Full;
-       case SPEED_100 + DUPLEX_FULL:
-               return ADVERTISED_100baseT_Full;
-       case SPEED_100 + DUPLEX_HALF:
-               return ADVERTISED_100baseT_Half;
-       case SPEED_10 + DUPLEX_FULL:
-               return ADVERTISED_10baseT_Full;
-       case SPEED_10 + DUPLEX_HALF:
-               return ADVERTISED_10baseT_Half;
-       default:
-               return 0;
-       }
-}
-
-int alx_select_powersaving_speed(struct alx_hw *hw, int *speed)
+int alx_select_powersaving_speed(struct alx_hw *hw, int *speed, u8 *duplex)
 {
-       int i, err, spd;
+       int i, err;
        u16 lpa;
 
-       err = alx_get_phy_link(hw, &spd);
-       if (err < 0)
+       err = alx_read_phy_link(hw);
+       if (err)
                return err;
 
-       if (spd == SPEED_UNKNOWN)
+       if (hw->link_speed == SPEED_UNKNOWN) {
+               *speed = SPEED_UNKNOWN;
+               *duplex = DUPLEX_UNKNOWN;
                return 0;
+       }
 
        err = alx_read_phy_reg(hw, MII_LPA, &lpa);
        if (err)
                return err;
 
        if (!(lpa & LPA_LPACK)) {
-               *speed = spd;
+               *speed = hw->link_speed;
                return 0;
        }
 
-       if (lpa & LPA_10FULL)
-               *speed = SPEED_10 + DUPLEX_FULL;
-       else if (lpa & LPA_10HALF)
-               *speed = SPEED_10 + DUPLEX_HALF;
-       else if (lpa & LPA_100FULL)
-               *speed = SPEED_100 + DUPLEX_FULL;
-       else
-               *speed = SPEED_100 + DUPLEX_HALF;
-
-       if (*speed != spd) {
-               err = alx_write_phy_reg(hw, ALX_MII_IER, 0);
-               if (err)
-                       return err;
-               err = alx_setup_speed_duplex(hw,
-                                            alx_speed_to_ethadv(*speed) |
-                                            ADVERTISED_Autoneg,
-                                            ALX_FC_ANEG | ALX_FC_RX |
-                                            ALX_FC_TX);
-               if (err)
-                       return err;
+       if (lpa & LPA_10FULL) {
+               *speed = SPEED_10;
+               *duplex = DUPLEX_FULL;
+       } else if (lpa & LPA_10HALF) {
+               *speed = SPEED_10;
+               *duplex = DUPLEX_HALF;
+       } else if (lpa & LPA_100FULL) {
+               *speed = SPEED_100;
+               *duplex = DUPLEX_FULL;
+       } else {
+               *speed = SPEED_100;
+               *duplex = DUPLEX_HALF;
+       }
 
-               /* wait for linkup */
-               for (i = 0; i < ALX_MAX_SETUP_LNK_CYCLE; i++) {
-                       int speed2;
+       if (*speed == hw->link_speed && *duplex == hw->duplex)
+               return 0;
+       err = alx_write_phy_reg(hw, ALX_MII_IER, 0);
+       if (err)
+               return err;
+       err = alx_setup_speed_duplex(hw, alx_speed_to_ethadv(*speed, *duplex) |
+                                        ADVERTISED_Autoneg, ALX_FC_ANEG |
+                                        ALX_FC_RX | ALX_FC_TX);
+       if (err)
+               return err;
 
-                       msleep(100);
+       /* wait for linkup */
+       for (i = 0; i < ALX_MAX_SETUP_LNK_CYCLE; i++) {
+               msleep(100);
 
-                       err = alx_get_phy_link(hw, &speed2);
-                       if (err < 0)
-                               return err;
-                       if (speed2 != SPEED_UNKNOWN)
-                               break;
-               }
-               if (i == ALX_MAX_SETUP_LNK_CYCLE)
-                       return -ETIMEDOUT;
+               err = alx_read_phy_link(hw);
+               if (err < 0)
+                       return err;
+               if (hw->link_speed != SPEED_UNKNOWN)
+                       break;
        }
+       if (i == ALX_MAX_SETUP_LNK_CYCLE)
+               return -ETIMEDOUT;
 
        return 0;
 }
 
        u32 smb_timer;
        /* SPEED_* + DUPLEX_*, SPEED_UNKNOWN if link is down */
        int link_speed;
+       u8 duplex;
 
        /* auto-neg advertisement or force mode config */
-       u32 adv_cfg;
        u8 flowctrl;
+       u32 adv_cfg;
 
        u32 sleep_ctrl;
 
 void alx_enable_aspm(struct alx_hw *hw, bool l0s_en, bool l1_en);
 int alx_setup_speed_duplex(struct alx_hw *hw, u32 ethadv, u8 flowctrl);
 void alx_post_phy_link(struct alx_hw *hw);
-int alx_pre_suspend(struct alx_hw *hw, int speed);
+int alx_pre_suspend(struct alx_hw *hw, int speed, u8 duplex);
 int alx_read_phy_reg(struct alx_hw *hw, u16 reg, u16 *phy_data);
 int alx_write_phy_reg(struct alx_hw *hw, u16 reg, u16 phy_data);
 int alx_read_phy_ext(struct alx_hw *hw, u8 dev, u16 reg, u16 *pdata);
 int alx_write_phy_ext(struct alx_hw *hw, u8 dev, u16 reg, u16 data);
-int alx_get_phy_link(struct alx_hw *hw, int *speed);
+int alx_read_phy_link(struct alx_hw *hw);
 int alx_clear_phy_intr(struct alx_hw *hw);
 int alx_config_wol(struct alx_hw *hw);
 void alx_cfg_mac_flowcontrol(struct alx_hw *hw, u8 fc);
 bool alx_phy_configured(struct alx_hw *hw);
 void alx_configure_basic(struct alx_hw *hw);
 void alx_disable_rss(struct alx_hw *hw);
-int alx_select_powersaving_speed(struct alx_hw *hw, int *speed);
+int alx_select_powersaving_speed(struct alx_hw *hw, int *speed, u8 *duplex);
 bool alx_get_phy_info(struct alx_hw *hw);
 
+static inline u32 alx_speed_to_ethadv(int speed, u8 duplex)
+{
+       if (speed == SPEED_1000 && duplex == DUPLEX_FULL)
+               return ADVERTISED_1000baseT_Full;
+       if (speed == SPEED_100 && duplex == DUPLEX_FULL)
+               return ADVERTISED_100baseT_Full;
+       if (speed == SPEED_100 && duplex== DUPLEX_HALF)
+               return ADVERTISED_100baseT_Half;
+       if (speed == SPEED_10 && duplex == DUPLEX_FULL)
+               return ADVERTISED_10baseT_Full;
+       if (speed == SPEED_10 && duplex == DUPLEX_HALF)
+               return ADVERTISED_10baseT_Half;
+       return 0;
+}
+
 #endif
 
        hw->dma_chnl = hw->max_dma_chnl;
        hw->ith_tpd = alx->tx_ringsz / 3;
        hw->link_speed = SPEED_UNKNOWN;
+       hw->duplex = DUPLEX_UNKNOWN;
        hw->adv_cfg = ADVERTISED_Autoneg |
                      ADVERTISED_10baseT_Half |
                      ADVERTISED_10baseT_Full |
 
        alx_netif_stop(alx);
        hw->link_speed = SPEED_UNKNOWN;
+       hw->duplex = DUPLEX_UNKNOWN;
 
        alx_reset_mac(hw);
 
        alx_free_rings(alx);
 }
 
-static const char *alx_speed_desc(u16 speed)
+static const char *alx_speed_desc(struct alx_hw *hw)
 {
-       switch (speed) {
-       case SPEED_1000 + DUPLEX_FULL:
+       switch (alx_speed_to_ethadv(hw->link_speed, hw->duplex)) {
+       case ADVERTISED_1000baseT_Full:
                return "1 Gbps Full";
-       case SPEED_100 + DUPLEX_FULL:
+       case ADVERTISED_100baseT_Full:
                return "100 Mbps Full";
-       case SPEED_100 + DUPLEX_HALF:
+       case ADVERTISED_100baseT_Half:
                return "100 Mbps Half";
-       case SPEED_10 + DUPLEX_FULL:
+       case ADVERTISED_10baseT_Full:
                return "10 Mbps Full";
-       case SPEED_10 + DUPLEX_HALF:
+       case ADVERTISED_10baseT_Half:
                return "10 Mbps Half";
        default:
                return "Unknown speed";
 {
        struct alx_hw *hw = &alx->hw;
        unsigned long flags;
-       int speed, old_speed;
+       int old_speed;
+       u8 old_duplex;
        int err;
 
        /* clear PHY internal interrupt status, otherwise the main
         */
        alx_clear_phy_intr(hw);
 
-       err = alx_get_phy_link(hw, &speed);
+       old_speed = hw->link_speed;
+       old_duplex = hw->duplex;
+       err = alx_read_phy_link(hw);
        if (err < 0)
                goto reset;
 
        alx_write_mem32(hw, ALX_IMR, alx->int_mask);
        spin_unlock_irqrestore(&alx->irq_lock, flags);
 
-       old_speed = hw->link_speed;
-
-       if (old_speed == speed)
+       if (old_speed == hw->link_speed)
                return;
-       hw->link_speed = speed;
 
-       if (speed != SPEED_UNKNOWN) {
+       if (hw->link_speed != SPEED_UNKNOWN) {
                netif_info(alx, link, alx->dev,
-                          "NIC Up: %s\n", alx_speed_desc(speed));
+                          "NIC Up: %s\n", alx_speed_desc(hw));
                alx_post_phy_link(hw);
                alx_enable_aspm(hw, true, true);
                alx_start_mac(hw);
        struct net_device *netdev = alx->dev;
        struct alx_hw *hw = &alx->hw;
        int err, speed;
+       u8 duplex;
 
        netif_device_detach(netdev);
 
                return err;
 #endif
 
-       err = alx_select_powersaving_speed(hw, &speed);
+       err = alx_select_powersaving_speed(hw, &speed, &duplex);
        if (err)
                return err;
        err = alx_clear_phy_intr(hw);
        if (err)
                return err;
-       err = alx_pre_suspend(hw, speed);
+       err = alx_pre_suspend(hw, speed, duplex);
        if (err)
                return err;
        err = alx_config_wol(hw);