net/hns3: fix typos on comments
[dpdk.git] / drivers / net / txgbe / base / txgbe_hw.c
index 1b40bfa..3e7f2f9 100644 (file)
@@ -3,7 +3,10 @@
  */
 
 #include "txgbe_type.h"
+#include "txgbe_mbx.h"
 #include "txgbe_phy.h"
+#include "txgbe_dcb.h"
+#include "txgbe_vf.h"
 #include "txgbe_eeprom.h"
 #include "txgbe_mng.h"
 #include "txgbe_hw.h"
@@ -12,6 +15,8 @@
 #define TXGBE_RAPTOR_MAX_RX_QUEUES 128
 #define TXGBE_RAPTOR_RAR_ENTRIES   128
 #define TXGBE_RAPTOR_MC_TBL_SIZE   128
+#define TXGBE_RAPTOR_VFT_TBL_SIZE  128
+#define TXGBE_RAPTOR_RX_PB_SIZE          512 /*KB*/
 
 static s32 txgbe_setup_copper_link_raptor(struct txgbe_hw *hw,
                                         u32 speed,
@@ -21,6 +26,164 @@ static s32 txgbe_mta_vector(struct txgbe_hw *hw, u8 *mc_addr);
 static s32 txgbe_get_san_mac_addr_offset(struct txgbe_hw *hw,
                                         u16 *san_mac_offset);
 
+/**
+ * txgbe_device_supports_autoneg_fc - Check if device supports autonegotiation
+ * of flow control
+ * @hw: pointer to hardware structure
+ *
+ * This function returns true if the device supports flow control
+ * autonegotiation, and false if it does not.
+ *
+ **/
+bool txgbe_device_supports_autoneg_fc(struct txgbe_hw *hw)
+{
+       bool supported = false;
+       u32 speed;
+       bool link_up;
+
+       DEBUGFUNC("txgbe_device_supports_autoneg_fc");
+
+       switch (hw->phy.media_type) {
+       case txgbe_media_type_fiber_qsfp:
+       case txgbe_media_type_fiber:
+               hw->mac.check_link(hw, &speed, &link_up, false);
+               /* if link is down, assume supported */
+               if (link_up)
+                       supported = speed == TXGBE_LINK_SPEED_1GB_FULL ?
+                       true : false;
+               else
+                       supported = true;
+
+               break;
+       case txgbe_media_type_backplane:
+               supported = true;
+               break;
+       case txgbe_media_type_copper:
+               /* only some copper devices support flow control autoneg */
+               switch (hw->subsystem_device_id & 0xFF) {
+               case TXGBE_DEV_ID_XAUI:
+               case TXGBE_DEV_ID_SGMII:
+                       supported = true;
+                       break;
+               default:
+                       supported = false;
+               }
+       default:
+               break;
+       }
+
+       if (!supported)
+               DEBUGOUT("Device %x does not support flow control autoneg",
+                             hw->device_id);
+       return supported;
+}
+
+/**
+ *  txgbe_setup_fc - Set up flow control
+ *  @hw: pointer to hardware structure
+ *
+ *  Called at init time to set up flow control.
+ **/
+s32 txgbe_setup_fc(struct txgbe_hw *hw)
+{
+       s32 err = 0;
+       u32 reg = 0;
+       u16 reg_cu = 0;
+       u32 value = 0;
+       u64 reg_bp = 0;
+
+       DEBUGFUNC("txgbe_setup_fc");
+
+       /* Validate the requested mode */
+       if (hw->fc.strict_ieee && hw->fc.requested_mode == txgbe_fc_rx_pause) {
+               DEBUGOUT("txgbe_fc_rx_pause not valid in strict IEEE mode\n");
+               err = TXGBE_ERR_INVALID_LINK_SETTINGS;
+               goto out;
+       }
+
+       /*
+        * 10gig parts do not have a word in the EEPROM to determine the
+        * default flow control setting, so we explicitly set it to full.
+        */
+       if (hw->fc.requested_mode == txgbe_fc_default)
+               hw->fc.requested_mode = txgbe_fc_full;
+
+       /*
+        * The possible values of fc.requested_mode are:
+        * 0: Flow control is completely disabled
+        * 1: Rx flow control is enabled (we can receive pause frames,
+        *    but not send pause frames).
+        * 2: Tx flow control is enabled (we can send pause frames but
+        *    we do not support receiving pause frames).
+        * 3: Both Rx and Tx flow control (symmetric) are enabled.
+        * other: Invalid.
+        */
+       switch (hw->fc.requested_mode) {
+       case txgbe_fc_none:
+               /* Flow control completely disabled by software override. */
+               break;
+       case txgbe_fc_tx_pause:
+               /*
+                * Tx Flow control is enabled, and Rx Flow control is
+                * disabled by software override.
+                */
+               reg |= SR_MII_MMD_AN_ADV_PAUSE_ASM;
+               reg_bp |= SR_AN_MMD_ADV_REG1_PAUSE_ASM;
+               break;
+       case txgbe_fc_rx_pause:
+               /*
+                * Rx Flow control is enabled and Tx Flow control is
+                * disabled by software override. Since there really
+                * isn't a way to advertise that we are capable of RX
+                * Pause ONLY, we will advertise that we support both
+                * symmetric and asymmetric Rx PAUSE, as such we fall
+                * through to the fc_full statement.  Later, we will
+                * disable the adapter's ability to send PAUSE frames.
+                */
+       case txgbe_fc_full:
+               /* Flow control (both Rx and Tx) is enabled by SW override. */
+               reg |= SR_MII_MMD_AN_ADV_PAUSE_SYM |
+                       SR_MII_MMD_AN_ADV_PAUSE_ASM;
+               reg_bp |= SR_AN_MMD_ADV_REG1_PAUSE_SYM |
+                       SR_AN_MMD_ADV_REG1_PAUSE_ASM;
+               break;
+       default:
+               DEBUGOUT("Flow control param set incorrectly\n");
+               err = TXGBE_ERR_CONFIG;
+               goto out;
+       }
+
+       /*
+        * Enable auto-negotiation between the MAC & PHY;
+        * the MAC will advertise clause 37 flow control.
+        */
+       value = rd32_epcs(hw, SR_MII_MMD_AN_ADV);
+       value = (value & ~(SR_MII_MMD_AN_ADV_PAUSE_ASM |
+               SR_MII_MMD_AN_ADV_PAUSE_SYM)) | reg;
+       wr32_epcs(hw, SR_MII_MMD_AN_ADV, value);
+
+       /*
+        * AUTOC restart handles negotiation of 1G and 10G on backplane
+        * and copper. There is no need to set the PCS1GCTL register.
+        *
+        */
+       if (hw->phy.media_type == txgbe_media_type_backplane) {
+               value = rd32_epcs(hw, SR_AN_MMD_ADV_REG1);
+               value = (value & ~(SR_AN_MMD_ADV_REG1_PAUSE_ASM |
+                       SR_AN_MMD_ADV_REG1_PAUSE_SYM)) |
+                       reg_bp;
+               wr32_epcs(hw, SR_AN_MMD_ADV_REG1, value);
+       } else if ((hw->phy.media_type == txgbe_media_type_copper) &&
+                   (txgbe_device_supports_autoneg_fc(hw))) {
+               hw->phy.write_reg(hw, TXGBE_MD_AUTO_NEG_ADVT,
+                                     TXGBE_MD_DEV_AUTO_NEG, reg_cu);
+       }
+
+       DEBUGOUT("Set up FC; reg = 0x%08X\n", reg);
+out:
+       return err;
+}
+
 /**
  *  txgbe_start_hw - Prepare hardware for Tx/Rx
  *  @hw: pointer to hardware structure
@@ -32,6 +195,7 @@ static s32 txgbe_get_san_mac_addr_offset(struct txgbe_hw *hw,
  **/
 s32 txgbe_start_hw(struct txgbe_hw *hw)
 {
+       s32 err;
        u16 device_caps;
 
        DEBUGFUNC("txgbe_start_hw");
@@ -39,9 +203,19 @@ s32 txgbe_start_hw(struct txgbe_hw *hw)
        /* Set the media type */
        hw->phy.media_type = hw->phy.get_media_type(hw);
 
+       /* Clear the VLAN filter table */
+       hw->mac.clear_vfta(hw);
+
        /* Clear statistics registers */
        hw->mac.clear_hw_cntrs(hw);
 
+       /* Setup flow control */
+       err = txgbe_setup_fc(hw);
+       if (err != 0 && err != TXGBE_NOT_IMPLEMENTED) {
+               DEBUGOUT("Flow control setup failed, returning %d\n", err);
+               return err;
+       }
+
        /* Cache bit indicating need for crosstalk fix */
        switch (hw->mac.type) {
        case txgbe_mac_raptor:
@@ -102,6 +276,9 @@ s32 txgbe_init_hw(struct txgbe_hw *hw)
 
        DEBUGFUNC("txgbe_init_hw");
 
+       /* Get firmware version */
+       hw->phy.get_fw_version(hw, &hw->fw_version);
+
        /* Reset the hardware */
        status = hw->mac.reset_hw(hw);
        if (status == 0 || status == TXGBE_ERR_SFP_NOT_PRESENT) {
@@ -115,6 +292,123 @@ s32 txgbe_init_hw(struct txgbe_hw *hw)
        return status;
 }
 
+/**
+ *  txgbe_clear_hw_cntrs - Generic clear hardware counters
+ *  @hw: pointer to hardware structure
+ *
+ *  Clears all hardware statistics counters by reading them from the hardware
+ *  Statistics counters are clear on read.
+ **/
+s32 txgbe_clear_hw_cntrs(struct txgbe_hw *hw)
+{
+       u16 i = 0;
+
+       DEBUGFUNC("txgbe_clear_hw_cntrs");
+
+       /* QP Stats */
+       /* don't write clear queue stats */
+       for (i = 0; i < TXGBE_MAX_QP; i++) {
+               hw->qp_last[i].rx_qp_packets = 0;
+               hw->qp_last[i].tx_qp_packets = 0;
+               hw->qp_last[i].rx_qp_bytes = 0;
+               hw->qp_last[i].tx_qp_bytes = 0;
+               hw->qp_last[i].rx_qp_mc_packets = 0;
+       }
+
+       /* PB Stats */
+       for (i = 0; i < TXGBE_MAX_UP; i++) {
+               rd32(hw, TXGBE_PBRXUPXON(i));
+               rd32(hw, TXGBE_PBRXUPXOFF(i));
+               rd32(hw, TXGBE_PBTXUPXON(i));
+               rd32(hw, TXGBE_PBTXUPXOFF(i));
+               rd32(hw, TXGBE_PBTXUPOFF(i));
+
+               rd32(hw, TXGBE_PBRXMISS(i));
+       }
+       rd32(hw, TXGBE_PBRXLNKXON);
+       rd32(hw, TXGBE_PBRXLNKXOFF);
+       rd32(hw, TXGBE_PBTXLNKXON);
+       rd32(hw, TXGBE_PBTXLNKXOFF);
+
+       /* DMA Stats */
+       rd32(hw, TXGBE_DMARXPKT);
+       rd32(hw, TXGBE_DMATXPKT);
+
+       rd64(hw, TXGBE_DMARXOCTL);
+       rd64(hw, TXGBE_DMATXOCTL);
+
+       /* MAC Stats */
+       rd64(hw, TXGBE_MACRXERRCRCL);
+       rd64(hw, TXGBE_MACRXMPKTL);
+       rd64(hw, TXGBE_MACTXMPKTL);
+
+       rd64(hw, TXGBE_MACRXPKTL);
+       rd64(hw, TXGBE_MACTXPKTL);
+       rd64(hw, TXGBE_MACRXGBOCTL);
+
+       rd64(hw, TXGBE_MACRXOCTL);
+       rd32(hw, TXGBE_MACTXOCTL);
+
+       rd64(hw, TXGBE_MACRX1TO64L);
+       rd64(hw, TXGBE_MACRX65TO127L);
+       rd64(hw, TXGBE_MACRX128TO255L);
+       rd64(hw, TXGBE_MACRX256TO511L);
+       rd64(hw, TXGBE_MACRX512TO1023L);
+       rd64(hw, TXGBE_MACRX1024TOMAXL);
+       rd64(hw, TXGBE_MACTX1TO64L);
+       rd64(hw, TXGBE_MACTX65TO127L);
+       rd64(hw, TXGBE_MACTX128TO255L);
+       rd64(hw, TXGBE_MACTX256TO511L);
+       rd64(hw, TXGBE_MACTX512TO1023L);
+       rd64(hw, TXGBE_MACTX1024TOMAXL);
+
+       rd64(hw, TXGBE_MACRXERRLENL);
+       rd32(hw, TXGBE_MACRXOVERSIZE);
+       rd32(hw, TXGBE_MACRXJABBER);
+
+       /* FCoE Stats */
+       rd32(hw, TXGBE_FCOECRC);
+       rd32(hw, TXGBE_FCOELAST);
+       rd32(hw, TXGBE_FCOERPDC);
+       rd32(hw, TXGBE_FCOEPRC);
+       rd32(hw, TXGBE_FCOEPTC);
+       rd32(hw, TXGBE_FCOEDWRC);
+       rd32(hw, TXGBE_FCOEDWTC);
+
+       /* Flow Director Stats */
+       rd32(hw, TXGBE_FDIRMATCH);
+       rd32(hw, TXGBE_FDIRMISS);
+       rd32(hw, TXGBE_FDIRUSED);
+       rd32(hw, TXGBE_FDIRUSED);
+       rd32(hw, TXGBE_FDIRFAIL);
+       rd32(hw, TXGBE_FDIRFAIL);
+
+       /* MACsec Stats */
+       rd32(hw, TXGBE_LSECTX_UTPKT);
+       rd32(hw, TXGBE_LSECTX_ENCPKT);
+       rd32(hw, TXGBE_LSECTX_PROTPKT);
+       rd32(hw, TXGBE_LSECTX_ENCOCT);
+       rd32(hw, TXGBE_LSECTX_PROTOCT);
+       rd32(hw, TXGBE_LSECRX_UTPKT);
+       rd32(hw, TXGBE_LSECRX_BTPKT);
+       rd32(hw, TXGBE_LSECRX_NOSCIPKT);
+       rd32(hw, TXGBE_LSECRX_UNSCIPKT);
+       rd32(hw, TXGBE_LSECRX_DECOCT);
+       rd32(hw, TXGBE_LSECRX_VLDOCT);
+       rd32(hw, TXGBE_LSECRX_UNCHKPKT);
+       rd32(hw, TXGBE_LSECRX_DLYPKT);
+       rd32(hw, TXGBE_LSECRX_LATEPKT);
+       for (i = 0; i < 2; i++) {
+               rd32(hw, TXGBE_LSECRX_OKPKT(i));
+               rd32(hw, TXGBE_LSECRX_INVPKT(i));
+               rd32(hw, TXGBE_LSECRX_BADPKT(i));
+       }
+       rd32(hw, TXGBE_LSECRX_INVSAPKT);
+       rd32(hw, TXGBE_LSECRX_BADSAPKT);
+
+       return 0;
+}
+
 /**
  *  txgbe_get_mac_addr - Generic get MAC address
  *  @hw: pointer to hardware structure
@@ -223,6 +517,52 @@ s32 txgbe_stop_hw(struct txgbe_hw *hw)
        return 0;
 }
 
+/**
+ *  txgbe_led_on - Turns on the software controllable LEDs.
+ *  @hw: pointer to hardware structure
+ *  @index: led number to turn on
+ **/
+s32 txgbe_led_on(struct txgbe_hw *hw, u32 index)
+{
+       u32 led_reg = rd32(hw, TXGBE_LEDCTL);
+
+       DEBUGFUNC("txgbe_led_on");
+
+       if (index > 4)
+               return TXGBE_ERR_PARAM;
+
+       /* To turn on the LED, set mode to ON. */
+       led_reg |= TXGBE_LEDCTL_SEL(index);
+       led_reg |= TXGBE_LEDCTL_ORD(index);
+       wr32(hw, TXGBE_LEDCTL, led_reg);
+       txgbe_flush(hw);
+
+       return 0;
+}
+
+/**
+ *  txgbe_led_off - Turns off the software controllable LEDs.
+ *  @hw: pointer to hardware structure
+ *  @index: led number to turn off
+ **/
+s32 txgbe_led_off(struct txgbe_hw *hw, u32 index)
+{
+       u32 led_reg = rd32(hw, TXGBE_LEDCTL);
+
+       DEBUGFUNC("txgbe_led_off");
+
+       if (index > 4)
+               return TXGBE_ERR_PARAM;
+
+       /* To turn off the LED, set mode to OFF. */
+       led_reg &= ~(TXGBE_LEDCTL_SEL(index));
+       led_reg &= ~(TXGBE_LEDCTL_ORD(index));
+       wr32(hw, TXGBE_LEDCTL, led_reg);
+       txgbe_flush(hw);
+
+       return 0;
+}
+
 /**
  *  txgbe_validate_mac_addr - Validate MAC address
  *  @mac_addr: pointer to MAC address.
@@ -549,6 +889,513 @@ s32 txgbe_update_mc_addr_list(struct txgbe_hw *hw, u8 *mc_addr_list,
        return 0;
 }
 
+/**
+ *  txgbe_fc_enable - Enable flow control
+ *  @hw: pointer to hardware structure
+ *
+ *  Enable flow control according to the current settings.
+ **/
+s32 txgbe_fc_enable(struct txgbe_hw *hw)
+{
+       s32 err = 0;
+       u32 mflcn_reg, fccfg_reg;
+       u32 pause_time;
+       u32 fcrtl, fcrth;
+       int i;
+
+       DEBUGFUNC("txgbe_fc_enable");
+
+       /* Validate the water mark configuration */
+       if (!hw->fc.pause_time) {
+               err = TXGBE_ERR_INVALID_LINK_SETTINGS;
+               goto out;
+       }
+
+       /* Low water mark of zero causes XOFF floods */
+       for (i = 0; i < TXGBE_DCB_TC_MAX; i++) {
+               if ((hw->fc.current_mode & txgbe_fc_tx_pause) &&
+                   hw->fc.high_water[i]) {
+                       if (!hw->fc.low_water[i] ||
+                           hw->fc.low_water[i] >= hw->fc.high_water[i]) {
+                               DEBUGOUT("Invalid water mark configuration\n");
+                               err = TXGBE_ERR_INVALID_LINK_SETTINGS;
+                               goto out;
+                       }
+               }
+       }
+
+       /* Negotiate the fc mode to use */
+       hw->mac.fc_autoneg(hw);
+
+       /* Disable any previous flow control settings */
+       mflcn_reg = rd32(hw, TXGBE_RXFCCFG);
+       mflcn_reg &= ~(TXGBE_RXFCCFG_FC | TXGBE_RXFCCFG_PFC);
+
+       fccfg_reg = rd32(hw, TXGBE_TXFCCFG);
+       fccfg_reg &= ~(TXGBE_TXFCCFG_FC | TXGBE_TXFCCFG_PFC);
+
+       /*
+        * The possible values of fc.current_mode are:
+        * 0: Flow control is completely disabled
+        * 1: Rx flow control is enabled (we can receive pause frames,
+        *    but not send pause frames).
+        * 2: Tx flow control is enabled (we can send pause frames but
+        *    we do not support receiving pause frames).
+        * 3: Both Rx and Tx flow control (symmetric) are enabled.
+        * other: Invalid.
+        */
+       switch (hw->fc.current_mode) {
+       case txgbe_fc_none:
+               /*
+                * Flow control is disabled by software override or autoneg.
+                * The code below will actually disable it in the HW.
+                */
+               break;
+       case txgbe_fc_rx_pause:
+               /*
+                * Rx Flow control is enabled and Tx Flow control is
+                * disabled by software override. Since there really
+                * isn't a way to advertise that we are capable of RX
+                * Pause ONLY, we will advertise that we support both
+                * symmetric and asymmetric Rx PAUSE.  Later, we will
+                * disable the adapter's ability to send PAUSE frames.
+                */
+               mflcn_reg |= TXGBE_RXFCCFG_FC;
+               break;
+       case txgbe_fc_tx_pause:
+               /*
+                * Tx Flow control is enabled, and Rx Flow control is
+                * disabled by software override.
+                */
+               fccfg_reg |= TXGBE_TXFCCFG_FC;
+               break;
+       case txgbe_fc_full:
+               /* Flow control (both Rx and Tx) is enabled by SW override. */
+               mflcn_reg |= TXGBE_RXFCCFG_FC;
+               fccfg_reg |= TXGBE_TXFCCFG_FC;
+               break;
+       default:
+               DEBUGOUT("Flow control param set incorrectly\n");
+               err = TXGBE_ERR_CONFIG;
+               goto out;
+       }
+
+       /* Set 802.3x based flow control settings. */
+       wr32(hw, TXGBE_RXFCCFG, mflcn_reg);
+       wr32(hw, TXGBE_TXFCCFG, fccfg_reg);
+
+       /* Set up and enable Rx high/low water mark thresholds, enable XON. */
+       for (i = 0; i < TXGBE_DCB_TC_MAX; i++) {
+               if ((hw->fc.current_mode & txgbe_fc_tx_pause) &&
+                   hw->fc.high_water[i]) {
+                       fcrtl = TXGBE_FCWTRLO_TH(hw->fc.low_water[i]) |
+                               TXGBE_FCWTRLO_XON;
+                       fcrth = TXGBE_FCWTRHI_TH(hw->fc.high_water[i]) |
+                               TXGBE_FCWTRHI_XOFF;
+               } else {
+                       /*
+                        * In order to prevent Tx hangs when the internal Tx
+                        * switch is enabled we must set the high water mark
+                        * to the Rx packet buffer size - 24KB.  This allows
+                        * the Tx switch to function even under heavy Rx
+                        * workloads.
+                        */
+                       fcrtl = 0;
+                       fcrth = rd32(hw, TXGBE_PBRXSIZE(i)) - 24576;
+               }
+               wr32(hw, TXGBE_FCWTRLO(i), fcrtl);
+               wr32(hw, TXGBE_FCWTRHI(i), fcrth);
+       }
+
+       /* Configure pause time (2 TCs per register) */
+       pause_time = TXGBE_RXFCFSH_TIME(hw->fc.pause_time);
+       for (i = 0; i < (TXGBE_DCB_TC_MAX / 2); i++)
+               wr32(hw, TXGBE_FCXOFFTM(i), pause_time * 0x00010001);
+
+       /* Configure flow control refresh threshold value */
+       wr32(hw, TXGBE_RXFCRFSH, hw->fc.pause_time / 2);
+
+out:
+       return err;
+}
+
+/**
+ *  txgbe_negotiate_fc - Negotiate flow control
+ *  @hw: pointer to hardware structure
+ *  @adv_reg: flow control advertised settings
+ *  @lp_reg: link partner's flow control settings
+ *  @adv_sym: symmetric pause bit in advertisement
+ *  @adv_asm: asymmetric pause bit in advertisement
+ *  @lp_sym: symmetric pause bit in link partner advertisement
+ *  @lp_asm: asymmetric pause bit in link partner advertisement
+ *
+ *  Find the intersection between advertised settings and link partner's
+ *  advertised settings
+ **/
+s32 txgbe_negotiate_fc(struct txgbe_hw *hw, u32 adv_reg, u32 lp_reg,
+                      u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm)
+{
+       if ((!(adv_reg)) ||  (!(lp_reg))) {
+               DEBUGOUT("Local or link partner's advertised flow control "
+                             "settings are NULL. Local: %x, link partner: %x\n",
+                             adv_reg, lp_reg);
+               return TXGBE_ERR_FC_NOT_NEGOTIATED;
+       }
+
+       if ((adv_reg & adv_sym) && (lp_reg & lp_sym)) {
+               /*
+                * Now we need to check if the user selected Rx ONLY
+                * of pause frames.  In this case, we had to advertise
+                * FULL flow control because we could not advertise RX
+                * ONLY. Hence, we must now check to see if we need to
+                * turn OFF the TRANSMISSION of PAUSE frames.
+                */
+               if (hw->fc.requested_mode == txgbe_fc_full) {
+                       hw->fc.current_mode = txgbe_fc_full;
+                       DEBUGOUT("Flow Control = FULL.\n");
+               } else {
+                       hw->fc.current_mode = txgbe_fc_rx_pause;
+                       DEBUGOUT("Flow Control=RX PAUSE frames only\n");
+               }
+       } else if (!(adv_reg & adv_sym) && (adv_reg & adv_asm) &&
+                  (lp_reg & lp_sym) && (lp_reg & lp_asm)) {
+               hw->fc.current_mode = txgbe_fc_tx_pause;
+               DEBUGOUT("Flow Control = TX PAUSE frames only.\n");
+       } else if ((adv_reg & adv_sym) && (adv_reg & adv_asm) &&
+                  !(lp_reg & lp_sym) && (lp_reg & lp_asm)) {
+               hw->fc.current_mode = txgbe_fc_rx_pause;
+               DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
+       } else {
+               hw->fc.current_mode = txgbe_fc_none;
+               DEBUGOUT("Flow Control = NONE.\n");
+       }
+       return 0;
+}
+
+/**
+ *  txgbe_fc_autoneg_fiber - Enable flow control on 1 gig fiber
+ *  @hw: pointer to hardware structure
+ *
+ *  Enable flow control according on 1 gig fiber.
+ **/
+STATIC s32 txgbe_fc_autoneg_fiber(struct txgbe_hw *hw)
+{
+       u32 pcs_anadv_reg, pcs_lpab_reg;
+       s32 err = TXGBE_ERR_FC_NOT_NEGOTIATED;
+
+       /*
+        * On multispeed fiber at 1g, bail out if
+        * - link is up but AN did not complete, or if
+        * - link is up and AN completed but timed out
+        */
+
+       pcs_anadv_reg = rd32_epcs(hw, SR_MII_MMD_AN_ADV);
+       pcs_lpab_reg = rd32_epcs(hw, SR_MII_MMD_LP_BABL);
+
+       err =  txgbe_negotiate_fc(hw, pcs_anadv_reg,
+                                     pcs_lpab_reg,
+                                     SR_MII_MMD_AN_ADV_PAUSE_SYM,
+                                     SR_MII_MMD_AN_ADV_PAUSE_ASM,
+                                     SR_MII_MMD_AN_ADV_PAUSE_SYM,
+                                     SR_MII_MMD_AN_ADV_PAUSE_ASM);
+
+       return err;
+}
+
+/**
+ *  txgbe_fc_autoneg_backplane - Enable flow control IEEE clause 37
+ *  @hw: pointer to hardware structure
+ *
+ *  Enable flow control according to IEEE clause 37.
+ **/
+STATIC s32 txgbe_fc_autoneg_backplane(struct txgbe_hw *hw)
+{
+       u32 anlp1_reg, autoc_reg;
+       s32 err = TXGBE_ERR_FC_NOT_NEGOTIATED;
+
+       /*
+        * Read the 10g AN autoc and LP ability registers and resolve
+        * local flow control settings accordingly
+        */
+       autoc_reg = rd32_epcs(hw, SR_AN_MMD_ADV_REG1);
+       anlp1_reg = rd32_epcs(hw, SR_AN_MMD_LP_ABL1);
+
+       err = txgbe_negotiate_fc(hw, autoc_reg,
+               anlp1_reg,
+               SR_AN_MMD_ADV_REG1_PAUSE_SYM,
+               SR_AN_MMD_ADV_REG1_PAUSE_ASM,
+               SR_AN_MMD_ADV_REG1_PAUSE_SYM,
+               SR_AN_MMD_ADV_REG1_PAUSE_ASM);
+
+       return err;
+}
+
+/**
+ *  txgbe_fc_autoneg_copper - Enable flow control IEEE clause 37
+ *  @hw: pointer to hardware structure
+ *
+ *  Enable flow control according to IEEE clause 37.
+ **/
+STATIC s32 txgbe_fc_autoneg_copper(struct txgbe_hw *hw)
+{
+       u16 technology_ability_reg = 0;
+       u16 lp_technology_ability_reg = 0;
+
+       hw->phy.read_reg(hw, TXGBE_MD_AUTO_NEG_ADVT,
+                            TXGBE_MD_DEV_AUTO_NEG,
+                            &technology_ability_reg);
+       hw->phy.read_reg(hw, TXGBE_MD_AUTO_NEG_LP,
+                            TXGBE_MD_DEV_AUTO_NEG,
+                            &lp_technology_ability_reg);
+
+       return txgbe_negotiate_fc(hw, (u32)technology_ability_reg,
+                                 (u32)lp_technology_ability_reg,
+                                 TXGBE_TAF_SYM_PAUSE, TXGBE_TAF_ASM_PAUSE,
+                                 TXGBE_TAF_SYM_PAUSE, TXGBE_TAF_ASM_PAUSE);
+}
+
+/**
+ *  txgbe_fc_autoneg - Configure flow control
+ *  @hw: pointer to hardware structure
+ *
+ *  Compares our advertised flow control capabilities to those advertised by
+ *  our link partner, and determines the proper flow control mode to use.
+ **/
+void txgbe_fc_autoneg(struct txgbe_hw *hw)
+{
+       s32 err = TXGBE_ERR_FC_NOT_NEGOTIATED;
+       u32 speed;
+       bool link_up;
+
+       DEBUGFUNC("txgbe_fc_autoneg");
+
+       /*
+        * AN should have completed when the cable was plugged in.
+        * Look for reasons to bail out.  Bail out if:
+        * - FC autoneg is disabled, or if
+        * - link is not up.
+        */
+       if (hw->fc.disable_fc_autoneg) {
+               DEBUGOUT("Flow control autoneg is disabled");
+               goto out;
+       }
+
+       hw->mac.check_link(hw, &speed, &link_up, false);
+       if (!link_up) {
+               DEBUGOUT("The link is down");
+               goto out;
+       }
+
+       switch (hw->phy.media_type) {
+       /* Autoneg flow control on fiber adapters */
+       case txgbe_media_type_fiber_qsfp:
+       case txgbe_media_type_fiber:
+               if (speed == TXGBE_LINK_SPEED_1GB_FULL)
+                       err = txgbe_fc_autoneg_fiber(hw);
+               break;
+
+       /* Autoneg flow control on backplane adapters */
+       case txgbe_media_type_backplane:
+               err = txgbe_fc_autoneg_backplane(hw);
+               break;
+
+       /* Autoneg flow control on copper adapters */
+       case txgbe_media_type_copper:
+               if (txgbe_device_supports_autoneg_fc(hw))
+                       err = txgbe_fc_autoneg_copper(hw);
+               break;
+
+       default:
+               break;
+       }
+
+out:
+       if (err == 0) {
+               hw->fc.fc_was_autonegged = true;
+       } else {
+               hw->fc.fc_was_autonegged = false;
+               hw->fc.current_mode = hw->fc.requested_mode;
+       }
+}
+
+/**
+ *  txgbe_acquire_swfw_sync - Acquire SWFW semaphore
+ *  @hw: pointer to hardware structure
+ *  @mask: Mask to specify which semaphore to acquire
+ *
+ *  Acquires the SWFW semaphore through the MNGSEM register for the specified
+ *  function (CSR, PHY0, PHY1, EEPROM, Flash)
+ **/
+s32 txgbe_acquire_swfw_sync(struct txgbe_hw *hw, u32 mask)
+{
+       u32 mngsem = 0;
+       u32 swmask = TXGBE_MNGSEM_SW(mask);
+       u32 fwmask = TXGBE_MNGSEM_FW(mask);
+       u32 timeout = 200;
+       u32 i;
+
+       DEBUGFUNC("txgbe_acquire_swfw_sync");
+
+       for (i = 0; i < timeout; i++) {
+               /*
+                * SW NVM semaphore bit is used for access to all
+                * SW_FW_SYNC bits (not just NVM)
+                */
+               if (txgbe_get_eeprom_semaphore(hw))
+                       return TXGBE_ERR_SWFW_SYNC;
+
+               mngsem = rd32(hw, TXGBE_MNGSEM);
+               if (mngsem & (fwmask | swmask)) {
+                       /* Resource is currently in use by FW or SW */
+                       txgbe_release_eeprom_semaphore(hw);
+                       msec_delay(5);
+               } else {
+                       mngsem |= swmask;
+                       wr32(hw, TXGBE_MNGSEM, mngsem);
+                       txgbe_release_eeprom_semaphore(hw);
+                       return 0;
+               }
+       }
+
+       /* If time expired clear the bits holding the lock and retry */
+       if (mngsem & (fwmask | swmask))
+               txgbe_release_swfw_sync(hw, mngsem & (fwmask | swmask));
+
+       msec_delay(5);
+       return TXGBE_ERR_SWFW_SYNC;
+}
+
+/**
+ *  txgbe_release_swfw_sync - Release SWFW semaphore
+ *  @hw: pointer to hardware structure
+ *  @mask: Mask to specify which semaphore to release
+ *
+ *  Releases the SWFW semaphore through the MNGSEM register for the specified
+ *  function (CSR, PHY0, PHY1, EEPROM, Flash)
+ **/
+void txgbe_release_swfw_sync(struct txgbe_hw *hw, u32 mask)
+{
+       u32 mngsem;
+       u32 swmask = mask;
+
+       DEBUGFUNC("txgbe_release_swfw_sync");
+
+       txgbe_get_eeprom_semaphore(hw);
+
+       mngsem = rd32(hw, TXGBE_MNGSEM);
+       mngsem &= ~swmask;
+       wr32(hw, TXGBE_MNGSEM, mngsem);
+
+       txgbe_release_eeprom_semaphore(hw);
+}
+
+/**
+ *  txgbe_disable_sec_rx_path - Stops the receive data path
+ *  @hw: pointer to hardware structure
+ *
+ *  Stops the receive data path and waits for the HW to internally empty
+ *  the Rx security block
+ **/
+s32 txgbe_disable_sec_rx_path(struct txgbe_hw *hw)
+{
+#define TXGBE_MAX_SECRX_POLL 4000
+
+       int i;
+       u32 secrxreg;
+
+       DEBUGFUNC("txgbe_disable_sec_rx_path");
+
+       secrxreg = rd32(hw, TXGBE_SECRXCTL);
+       secrxreg |= TXGBE_SECRXCTL_XDSA;
+       wr32(hw, TXGBE_SECRXCTL, secrxreg);
+       for (i = 0; i < TXGBE_MAX_SECRX_POLL; i++) {
+               secrxreg = rd32(hw, TXGBE_SECRXSTAT);
+               if (!(secrxreg & TXGBE_SECRXSTAT_RDY))
+                       /* Use interrupt-safe sleep just in case */
+                       usec_delay(10);
+               else
+                       break;
+       }
+
+       /* For informational purposes only */
+       if (i >= TXGBE_MAX_SECRX_POLL)
+               DEBUGOUT("Rx unit being enabled before security "
+                        "path fully disabled.  Continuing with init.\n");
+
+       return 0;
+}
+
+/**
+ *  txgbe_enable_sec_rx_path - Enables the receive data path
+ *  @hw: pointer to hardware structure
+ *
+ *  Enables the receive data path.
+ **/
+s32 txgbe_enable_sec_rx_path(struct txgbe_hw *hw)
+{
+       u32 secrxreg;
+
+       DEBUGFUNC("txgbe_enable_sec_rx_path");
+
+       secrxreg = rd32(hw, TXGBE_SECRXCTL);
+       secrxreg &= ~TXGBE_SECRXCTL_XDSA;
+       wr32(hw, TXGBE_SECRXCTL, secrxreg);
+       txgbe_flush(hw);
+
+       return 0;
+}
+
+/**
+ *  txgbe_disable_sec_tx_path - Stops the transmit data path
+ *  @hw: pointer to hardware structure
+ *
+ *  Stops the transmit data path and waits for the HW to internally empty
+ *  the Tx security block
+ **/
+int txgbe_disable_sec_tx_path(struct txgbe_hw *hw)
+{
+#define TXGBE_MAX_SECTX_POLL 40
+
+       int i;
+       u32 sectxreg;
+
+       sectxreg = rd32(hw, TXGBE_SECTXCTL);
+       sectxreg |= TXGBE_SECTXCTL_XDSA;
+       wr32(hw, TXGBE_SECTXCTL, sectxreg);
+       for (i = 0; i < TXGBE_MAX_SECTX_POLL; i++) {
+               sectxreg = rd32(hw, TXGBE_SECTXSTAT);
+               if (sectxreg & TXGBE_SECTXSTAT_RDY)
+                       break;
+               /* Use interrupt-safe sleep just in case */
+               usec_delay(1000);
+       }
+
+       /* For informational purposes only */
+       if (i >= TXGBE_MAX_SECTX_POLL)
+               PMD_DRV_LOG(DEBUG, "Tx unit being enabled before security "
+                        "path fully disabled.  Continuing with init.");
+
+       return 0;
+}
+
+/**
+ *  txgbe_enable_sec_tx_path - Enables the transmit data path
+ *  @hw: pointer to hardware structure
+ *
+ *  Enables the transmit data path.
+ **/
+int txgbe_enable_sec_tx_path(struct txgbe_hw *hw)
+{
+       uint32_t sectxreg;
+
+       sectxreg = rd32(hw, TXGBE_SECTXCTL);
+       sectxreg &= ~TXGBE_SECTXCTL_XDSA;
+       wr32(hw, TXGBE_SECTXCTL, sectxreg);
+       txgbe_flush(hw);
+
+       return 0;
+}
+
 /**
  *  txgbe_get_san_mac_addr_offset - Get SAN MAC address offset from the EEPROM
  *  @hw: pointer to hardware structure
@@ -627,58 +1474,377 @@ san_mac_addr_out:
         * No addresses available in this EEPROM.  It's not an
         * error though, so just wipe the local address and return.
         */
-       for (i = 0; i < 6; i++)
-               san_mac_addr[i] = 0xFF;
+       for (i = 0; i < 6; i++)
+               san_mac_addr[i] = 0xFF;
+       return 0;
+}
+
+/**
+ *  txgbe_set_san_mac_addr - Write the SAN MAC address to the EEPROM
+ *  @hw: pointer to hardware structure
+ *  @san_mac_addr: SAN MAC address
+ *
+ *  Write a SAN MAC address to the EEPROM.
+ **/
+s32 txgbe_set_san_mac_addr(struct txgbe_hw *hw, u8 *san_mac_addr)
+{
+       s32 err;
+       u16 san_mac_data, san_mac_offset;
+       u8 i;
+
+       DEBUGFUNC("txgbe_set_san_mac_addr");
+
+       /* Look for SAN mac address pointer.  If not defined, return */
+       err = txgbe_get_san_mac_addr_offset(hw, &san_mac_offset);
+       if (err || san_mac_offset == 0 || san_mac_offset == 0xFFFF)
+               return TXGBE_ERR_NO_SAN_ADDR_PTR;
+
+       /* Apply the port offset to the address offset */
+       (hw->bus.func) ? (san_mac_offset += TXGBE_SAN_MAC_ADDR_PORT1_OFFSET) :
+                        (san_mac_offset += TXGBE_SAN_MAC_ADDR_PORT0_OFFSET);
+
+       for (i = 0; i < 3; i++) {
+               san_mac_data = (u16)((u16)(san_mac_addr[i * 2 + 1]) << 8);
+               san_mac_data |= (u16)(san_mac_addr[i * 2]);
+               hw->rom.write16(hw, san_mac_offset, san_mac_data);
+               san_mac_offset++;
+       }
+
+       return 0;
+}
+
+/**
+ *  txgbe_clear_vmdq - Disassociate a VMDq pool index from a rx address
+ *  @hw: pointer to hardware struct
+ *  @rar: receive address register index to disassociate
+ *  @vmdq: VMDq pool index to remove from the rar
+ **/
+s32 txgbe_clear_vmdq(struct txgbe_hw *hw, u32 rar, u32 vmdq)
+{
+       u32 mpsar_lo, mpsar_hi;
+       u32 rar_entries = hw->mac.num_rar_entries;
+
+       DEBUGFUNC("txgbe_clear_vmdq");
+
+       /* Make sure we are using a valid rar index range */
+       if (rar >= rar_entries) {
+               DEBUGOUT("RAR index %d is out of range.\n", rar);
+               return TXGBE_ERR_INVALID_ARGUMENT;
+       }
+
+       wr32(hw, TXGBE_ETHADDRIDX, rar);
+       mpsar_lo = rd32(hw, TXGBE_ETHADDRASSL);
+       mpsar_hi = rd32(hw, TXGBE_ETHADDRASSH);
+
+       if (TXGBE_REMOVED(hw->hw_addr))
+               goto done;
+
+       if (!mpsar_lo && !mpsar_hi)
+               goto done;
+
+       if (vmdq == BIT_MASK32) {
+               if (mpsar_lo) {
+                       wr32(hw, TXGBE_ETHADDRASSL, 0);
+                       mpsar_lo = 0;
+               }
+               if (mpsar_hi) {
+                       wr32(hw, TXGBE_ETHADDRASSH, 0);
+                       mpsar_hi = 0;
+               }
+       } else if (vmdq < 32) {
+               mpsar_lo &= ~(1 << vmdq);
+               wr32(hw, TXGBE_ETHADDRASSL, mpsar_lo);
+       } else {
+               mpsar_hi &= ~(1 << (vmdq - 32));
+               wr32(hw, TXGBE_ETHADDRASSH, mpsar_hi);
+       }
+
+       /* was that the last pool using this rar? */
+       if (mpsar_lo == 0 && mpsar_hi == 0 &&
+           rar != 0 && rar != hw->mac.san_mac_rar_index)
+               hw->mac.clear_rar(hw, rar);
+done:
+       return 0;
+}
+
+/**
+ *  txgbe_set_vmdq - Associate a VMDq pool index with a rx address
+ *  @hw: pointer to hardware struct
+ *  @rar: receive address register index to associate with a VMDq index
+ *  @vmdq: VMDq pool index
+ **/
+s32 txgbe_set_vmdq(struct txgbe_hw *hw, u32 rar, u32 vmdq)
+{
+       u32 mpsar;
+       u32 rar_entries = hw->mac.num_rar_entries;
+
+       DEBUGFUNC("txgbe_set_vmdq");
+
+       /* Make sure we are using a valid rar index range */
+       if (rar >= rar_entries) {
+               DEBUGOUT("RAR index %d is out of range.\n", rar);
+               return TXGBE_ERR_INVALID_ARGUMENT;
+       }
+
+       wr32(hw, TXGBE_ETHADDRIDX, rar);
+       if (vmdq < 32) {
+               mpsar = rd32(hw, TXGBE_ETHADDRASSL);
+               mpsar |= 1 << vmdq;
+               wr32(hw, TXGBE_ETHADDRASSL, mpsar);
+       } else {
+               mpsar = rd32(hw, TXGBE_ETHADDRASSH);
+               mpsar |= 1 << (vmdq - 32);
+               wr32(hw, TXGBE_ETHADDRASSH, mpsar);
+       }
+       return 0;
+}
+
+/**
+ *  txgbe_init_uta_tables - Initialize the Unicast Table Array
+ *  @hw: pointer to hardware structure
+ **/
+s32 txgbe_init_uta_tables(struct txgbe_hw *hw)
+{
+       int i;
+
+       DEBUGFUNC("txgbe_init_uta_tables");
+       DEBUGOUT(" Clearing UTA\n");
+
+       for (i = 0; i < 128; i++)
+               wr32(hw, TXGBE_UCADDRTBL(i), 0);
+
+       return 0;
+}
+
+/**
+ *  txgbe_find_vlvf_slot - find the vlanid or the first empty slot
+ *  @hw: pointer to hardware structure
+ *  @vlan: VLAN id to write to VLAN filter
+ *  @vlvf_bypass: true to find vlanid only, false returns first empty slot if
+ *               vlanid not found
+ *
+ *
+ *  return the VLVF index where this VLAN id should be placed
+ *
+ **/
+s32 txgbe_find_vlvf_slot(struct txgbe_hw *hw, u32 vlan, bool vlvf_bypass)
+{
+       s32 regindex, first_empty_slot;
+       u32 bits;
+
+       /* short cut the special case */
+       if (vlan == 0)
+               return 0;
+
+       /* if vlvf_bypass is set we don't want to use an empty slot, we
+        * will simply bypass the VLVF if there are no entries present in the
+        * VLVF that contain our VLAN
+        */
+       first_empty_slot = vlvf_bypass ? TXGBE_ERR_NO_SPACE : 0;
+
+       /* add VLAN enable bit for comparison */
+       vlan |= TXGBE_PSRVLAN_EA;
+
+       /* Search for the vlan id in the VLVF entries. Save off the first empty
+        * slot found along the way.
+        *
+        * pre-decrement loop covering (TXGBE_NUM_POOL - 1) .. 1
+        */
+       for (regindex = TXGBE_NUM_POOL; --regindex;) {
+               wr32(hw, TXGBE_PSRVLANIDX, regindex);
+               bits = rd32(hw, TXGBE_PSRVLAN);
+               if (bits == vlan)
+                       return regindex;
+               if (!first_empty_slot && !bits)
+                       first_empty_slot = regindex;
+       }
+
+       /* If we are here then we didn't find the VLAN.  Return first empty
+        * slot we found during our search, else error.
+        */
+       if (!first_empty_slot)
+               DEBUGOUT("No space in VLVF.\n");
+
+       return first_empty_slot ? first_empty_slot : TXGBE_ERR_NO_SPACE;
+}
+
+/**
+ *  txgbe_set_vfta - Set VLAN filter table
+ *  @hw: pointer to hardware structure
+ *  @vlan: VLAN id to write to VLAN filter
+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
+ *  @vlan_on: boolean flag to turn on/off VLAN
+ *  @vlvf_bypass: boolean flag indicating updating default pool is okay
+ *
+ *  Turn on/off specified VLAN in the VLAN filter table.
+ **/
+s32 txgbe_set_vfta(struct txgbe_hw *hw, u32 vlan, u32 vind,
+                          bool vlan_on, bool vlvf_bypass)
+{
+       u32 regidx, vfta_delta, vfta;
+       s32 err;
+
+       DEBUGFUNC("txgbe_set_vfta");
+
+       if (vlan > 4095 || vind > 63)
+               return TXGBE_ERR_PARAM;
+
+       /*
+        * this is a 2 part operation - first the VFTA, then the
+        * VLVF and VLVFB if VT Mode is set
+        * We don't write the VFTA until we know the VLVF part succeeded.
+        */
+
+       /* Part 1
+        * The VFTA is a bitstring made up of 128 32-bit registers
+        * that enable the particular VLAN id, much like the MTA:
+        *    bits[11-5]: which register
+        *    bits[4-0]:  which bit in the register
+        */
+       regidx = vlan / 32;
+       vfta_delta = 1 << (vlan % 32);
+       vfta = rd32(hw, TXGBE_VLANTBL(regidx));
+
+       /*
+        * vfta_delta represents the difference between the current value
+        * of vfta and the value we want in the register.  Since the diff
+        * is an XOR mask we can just update the vfta using an XOR
+        */
+       vfta_delta &= vlan_on ? ~vfta : vfta;
+       vfta ^= vfta_delta;
+
+       /* Part 2
+        * Call txgbe_set_vlvf to set VLVFB and VLVF
+        */
+       err = txgbe_set_vlvf(hw, vlan, vind, vlan_on, &vfta_delta,
+                                        vfta, vlvf_bypass);
+       if (err != 0) {
+               if (vlvf_bypass)
+                       goto vfta_update;
+               return err;
+       }
+
+vfta_update:
+       /* Update VFTA now that we are ready for traffic */
+       if (vfta_delta)
+               wr32(hw, TXGBE_VLANTBL(regidx), vfta);
+
        return 0;
 }
 
 /**
- *  txgbe_set_san_mac_addr - Write the SAN MAC address to the EEPROM
+ *  txgbe_set_vlvf - Set VLAN Pool Filter
  *  @hw: pointer to hardware structure
- *  @san_mac_addr: SAN MAC address
+ *  @vlan: VLAN id to write to VLAN filter
+ *  @vind: VMDq output index that maps queue to VLAN id in PSRVLANPLM
+ *  @vlan_on: boolean flag to turn on/off VLAN in PSRVLAN
+ *  @vfta_delta: pointer to the difference between the current value
+ *              of PSRVLANPLM and the desired value
+ *  @vfta: the desired value of the VFTA
+ *  @vlvf_bypass: boolean flag indicating updating default pool is okay
  *
- *  Write a SAN MAC address to the EEPROM.
+ *  Turn on/off specified bit in VLVF table.
  **/
-s32 txgbe_set_san_mac_addr(struct txgbe_hw *hw, u8 *san_mac_addr)
+s32 txgbe_set_vlvf(struct txgbe_hw *hw, u32 vlan, u32 vind,
+                          bool vlan_on, u32 *vfta_delta, u32 vfta,
+                          bool vlvf_bypass)
 {
-       s32 err;
-       u16 san_mac_data, san_mac_offset;
-       u8 i;
+       u32 bits;
+       u32 portctl;
+       s32 vlvf_index;
 
-       DEBUGFUNC("txgbe_set_san_mac_addr");
+       DEBUGFUNC("txgbe_set_vlvf");
 
-       /* Look for SAN mac address pointer.  If not defined, return */
-       err = txgbe_get_san_mac_addr_offset(hw, &san_mac_offset);
-       if (err || san_mac_offset == 0 || san_mac_offset == 0xFFFF)
-               return TXGBE_ERR_NO_SAN_ADDR_PTR;
+       if (vlan > 4095 || vind > 63)
+               return TXGBE_ERR_PARAM;
 
-       /* Apply the port offset to the address offset */
-       (hw->bus.func) ? (san_mac_offset += TXGBE_SAN_MAC_ADDR_PORT1_OFFSET) :
-                        (san_mac_offset += TXGBE_SAN_MAC_ADDR_PORT0_OFFSET);
+       /* If VT Mode is set
+        *   Either vlan_on
+        *     make sure the vlan is in PSRVLAN
+        *     set the vind bit in the matching PSRVLANPLM
+        *   Or !vlan_on
+        *     clear the pool bit and possibly the vind
+        */
+       portctl = rd32(hw, TXGBE_PORTCTL);
+       if (!(portctl & TXGBE_PORTCTL_NUMVT_MASK))
+               return 0;
 
-       for (i = 0; i < 3; i++) {
-               san_mac_data = (u16)((u16)(san_mac_addr[i * 2 + 1]) << 8);
-               san_mac_data |= (u16)(san_mac_addr[i * 2]);
-               hw->rom.write16(hw, san_mac_offset, san_mac_data);
-               san_mac_offset++;
+       vlvf_index = txgbe_find_vlvf_slot(hw, vlan, vlvf_bypass);
+       if (vlvf_index < 0)
+               return vlvf_index;
+
+       wr32(hw, TXGBE_PSRVLANIDX, vlvf_index);
+       bits = rd32(hw, TXGBE_PSRVLANPLM(vind / 32));
+
+       /* set the pool bit */
+       bits |= 1 << (vind % 32);
+       if (vlan_on)
+               goto vlvf_update;
+
+       /* clear the pool bit */
+       bits ^= 1 << (vind % 32);
+
+       if (!bits &&
+           !rd32(hw, TXGBE_PSRVLANPLM(vind / 32))) {
+               /* Clear PSRVLANPLM first, then disable PSRVLAN. Otherwise
+                * we run the risk of stray packets leaking into
+                * the PF via the default pool
+                */
+               if (*vfta_delta)
+                       wr32(hw, TXGBE_PSRVLANPLM(vlan / 32), vfta);
+
+               /* disable VLVF and clear remaining bit from pool */
+               wr32(hw, TXGBE_PSRVLAN, 0);
+               wr32(hw, TXGBE_PSRVLANPLM(vind / 32), 0);
+
+               return 0;
        }
 
+       /* If there are still bits set in the PSRVLANPLM registers
+        * for the VLAN ID indicated we need to see if the
+        * caller is requesting that we clear the PSRVLANPLM entry bit.
+        * If the caller has requested that we clear the PSRVLANPLM
+        * entry bit but there are still pools/VFs using this VLAN
+        * ID entry then ignore the request.  We're not worried
+        * about the case where we're turning the PSRVLANPLM VLAN ID
+        * entry bit on, only when requested to turn it off as
+        * there may be multiple pools and/or VFs using the
+        * VLAN ID entry.  In that case we cannot clear the
+        * PSRVLANPLM bit until all pools/VFs using that VLAN ID have also
+        * been cleared.  This will be indicated by "bits" being
+        * zero.
+        */
+       *vfta_delta = 0;
+
+vlvf_update:
+       /* record pool change and enable VLAN ID if not already enabled */
+       wr32(hw, TXGBE_PSRVLANPLM(vind / 32), bits);
+       wr32(hw, TXGBE_PSRVLAN, TXGBE_PSRVLAN_EA | vlan);
+
        return 0;
 }
 
 /**
- *  txgbe_init_uta_tables - Initialize the Unicast Table Array
+ *  txgbe_clear_vfta - Clear VLAN filter table
  *  @hw: pointer to hardware structure
+ *
+ *  Clears the VLAN filer table, and the VMDq index associated with the filter
  **/
-s32 txgbe_init_uta_tables(struct txgbe_hw *hw)
+s32 txgbe_clear_vfta(struct txgbe_hw *hw)
 {
-       int i;
+       u32 offset;
 
-       DEBUGFUNC("txgbe_init_uta_tables");
-       DEBUGOUT(" Clearing UTA\n");
+       DEBUGFUNC("txgbe_clear_vfta");
 
-       for (i = 0; i < 128; i++)
-               wr32(hw, TXGBE_UCADDRTBL(i), 0);
+       for (offset = 0; offset < hw->mac.vft_size; offset++)
+               wr32(hw, TXGBE_VLANTBL(offset), 0);
+
+       for (offset = 0; offset < TXGBE_NUM_POOL; offset++) {
+               wr32(hw, TXGBE_PSRVLANIDX, offset);
+               wr32(hw, TXGBE_PSRVLAN, 0);
+               wr32(hw, TXGBE_PSRVLANPLM(0), 0);
+               wr32(hw, TXGBE_PSRVLANPLM(1), 0);
+       }
 
        return 0;
 }
@@ -794,6 +1960,103 @@ s32 txgbe_check_mac_link(struct txgbe_hw *hw, u32 *speed,
        return 0;
 }
 
+/**
+ *  txgbe_get_wwn_prefix - Get alternative WWNN/WWPN prefix from
+ *  the EEPROM
+ *  @hw: pointer to hardware structure
+ *  @wwnn_prefix: the alternative WWNN prefix
+ *  @wwpn_prefix: the alternative WWPN prefix
+ *
+ *  This function will read the EEPROM from the alternative SAN MAC address
+ *  block to check the support for the alternative WWNN/WWPN prefix support.
+ **/
+s32 txgbe_get_wwn_prefix(struct txgbe_hw *hw, u16 *wwnn_prefix,
+                                u16 *wwpn_prefix)
+{
+       u16 offset, caps;
+       u16 alt_san_mac_blk_offset;
+
+       DEBUGFUNC("txgbe_get_wwn_prefix");
+
+       /* clear output first */
+       *wwnn_prefix = 0xFFFF;
+       *wwpn_prefix = 0xFFFF;
+
+       /* check if alternative SAN MAC is supported */
+       offset = TXGBE_ALT_SAN_MAC_ADDR_BLK_PTR;
+       if (hw->rom.readw_sw(hw, offset, &alt_san_mac_blk_offset))
+               goto wwn_prefix_err;
+
+       if (alt_san_mac_blk_offset == 0 || alt_san_mac_blk_offset == 0xFFFF)
+               goto wwn_prefix_out;
+
+       /* check capability in alternative san mac address block */
+       offset = alt_san_mac_blk_offset + TXGBE_ALT_SAN_MAC_ADDR_CAPS_OFFSET;
+       if (hw->rom.read16(hw, offset, &caps))
+               goto wwn_prefix_err;
+       if (!(caps & TXGBE_ALT_SAN_MAC_ADDR_CAPS_ALTWWN))
+               goto wwn_prefix_out;
+
+       /* get the corresponding prefix for WWNN/WWPN */
+       offset = alt_san_mac_blk_offset + TXGBE_ALT_SAN_MAC_ADDR_WWNN_OFFSET;
+       if (hw->rom.read16(hw, offset, wwnn_prefix))
+               DEBUGOUT("eeprom read at offset %d failed", offset);
+
+       offset = alt_san_mac_blk_offset + TXGBE_ALT_SAN_MAC_ADDR_WWPN_OFFSET;
+       if (hw->rom.read16(hw, offset, wwpn_prefix))
+               goto wwn_prefix_err;
+
+wwn_prefix_out:
+       return 0;
+
+wwn_prefix_err:
+       DEBUGOUT("eeprom read at offset %d failed", offset);
+       return 0;
+}
+
+/**
+ *  txgbe_set_mac_anti_spoofing - Enable/Disable MAC anti-spoofing
+ *  @hw: pointer to hardware structure
+ *  @enable: enable or disable switch for MAC anti-spoofing
+ *  @vf: Virtual Function pool - VF Pool to set for MAC anti-spoofing
+ *
+ **/
+void txgbe_set_mac_anti_spoofing(struct txgbe_hw *hw, bool enable, int vf)
+{
+       int vf_target_reg = vf >> 3;
+       int vf_target_shift = vf % 8;
+       u32 pfvfspoof;
+
+       pfvfspoof = rd32(hw, TXGBE_POOLTXASMAC(vf_target_reg));
+       if (enable)
+               pfvfspoof |= (1 << vf_target_shift);
+       else
+               pfvfspoof &= ~(1 << vf_target_shift);
+       wr32(hw, TXGBE_POOLTXASMAC(vf_target_reg), pfvfspoof);
+}
+
+/**
+ * txgbe_set_ethertype_anti_spoofing - Configure Ethertype anti-spoofing
+ * @hw: pointer to hardware structure
+ * @enable: enable or disable switch for Ethertype anti-spoofing
+ * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
+ *
+ **/
+void txgbe_set_ethertype_anti_spoofing(struct txgbe_hw *hw,
+               bool enable, int vf)
+{
+       int vf_target_reg = vf >> 3;
+       int vf_target_shift = vf % 8;
+       u32 pfvfspoof;
+
+       pfvfspoof = rd32(hw, TXGBE_POOLTXASET(vf_target_reg));
+       if (enable)
+               pfvfspoof |= (1 << vf_target_shift);
+       else
+               pfvfspoof &= ~(1 << vf_target_shift);
+       wr32(hw, TXGBE_POOLTXASET(vf_target_reg), pfvfspoof);
+}
+
 /**
  *  txgbe_get_device_caps - Get additional device capabilities
  *  @hw: pointer to hardware structure
@@ -811,6 +2074,68 @@ s32 txgbe_get_device_caps(struct txgbe_hw *hw, u16 *device_caps)
        return 0;
 }
 
+/**
+ * txgbe_set_pba - Initialize Rx packet buffer
+ * @hw: pointer to hardware structure
+ * @num_pb: number of packet buffers to allocate
+ * @headroom: reserve n KB of headroom
+ * @strategy: packet buffer allocation strategy
+ **/
+void txgbe_set_pba(struct txgbe_hw *hw, int num_pb, u32 headroom,
+                            int strategy)
+{
+       u32 pbsize = hw->mac.rx_pb_size;
+       int i = 0;
+       u32 rxpktsize, txpktsize, txpbthresh;
+
+       UNREFERENCED_PARAMETER(hw);
+
+       /* Reserve headroom */
+       pbsize -= headroom;
+
+       if (!num_pb)
+               num_pb = 1;
+
+       /* Divide remaining packet buffer space amongst the number of packet
+        * buffers requested using supplied strategy.
+        */
+       switch (strategy) {
+       case PBA_STRATEGY_WEIGHTED:
+               /* txgbe_dcb_pba_80_48 strategy weight first half of packet
+                * buffer with 5/8 of the packet buffer space.
+                */
+               rxpktsize = (pbsize * 5) / (num_pb * 4);
+               pbsize -= rxpktsize * (num_pb / 2);
+               rxpktsize <<= 10;
+               for (; i < (num_pb / 2); i++)
+                       wr32(hw, TXGBE_PBRXSIZE(i), rxpktsize);
+               /* fall through - configure remaining packet buffers */
+       case PBA_STRATEGY_EQUAL:
+               rxpktsize = (pbsize / (num_pb - i));
+               rxpktsize <<= 10;
+               for (; i < num_pb; i++)
+                       wr32(hw, TXGBE_PBRXSIZE(i), rxpktsize);
+               break;
+       default:
+               break;
+       }
+
+       /* Only support an equally distributed Tx packet buffer strategy. */
+       txpktsize = TXGBE_PBTXSIZE_MAX / num_pb;
+       txpbthresh = (txpktsize / 1024) - TXGBE_TXPKT_SIZE_MAX;
+       for (i = 0; i < num_pb; i++) {
+               wr32(hw, TXGBE_PBTXSIZE(i), txpktsize);
+               wr32(hw, TXGBE_PBTXDMATH(i), txpbthresh);
+       }
+
+       /* Clear unused TCs, if any, to zero buffer size*/
+       for (; i < TXGBE_MAX_UP; i++) {
+               wr32(hw, TXGBE_PBRXSIZE(i), 0);
+               wr32(hw, TXGBE_PBTXSIZE(i), 0);
+               wr32(hw, TXGBE_PBTXDMATH(i), 0);
+       }
+}
+
 /**
  * txgbe_clear_tx_pending - Clear pending TX work from the PCIe fifo
  * @hw: pointer to the hardware structure
@@ -853,6 +2178,71 @@ void txgbe_clear_tx_pending(struct txgbe_hw *hw)
        wr32(hw, TXGBE_PSRCTL, hlreg0);
 }
 
+/**
+ *  txgbe_get_thermal_sensor_data - Gathers thermal sensor data
+ *  @hw: pointer to hardware structure
+ *
+ *  Returns the thermal sensor data structure
+ **/
+s32 txgbe_get_thermal_sensor_data(struct txgbe_hw *hw)
+{
+       struct txgbe_thermal_sensor_data *data = &hw->mac.thermal_sensor_data;
+       s64 tsv;
+       u32 ts_stat;
+
+       DEBUGFUNC("txgbe_get_thermal_sensor_data");
+
+       /* Only support thermal sensors attached to physical port 0 */
+       if (hw->bus.lan_id != 0)
+               return TXGBE_NOT_IMPLEMENTED;
+
+       ts_stat = rd32(hw, TXGBE_TSSTAT);
+       tsv = (s64)TXGBE_TSSTAT_DATA(ts_stat);
+       tsv = tsv > 1200 ? tsv : 1200;
+       tsv = -(48380 << 8) / 1000
+               + tsv * (31020 << 8) / 100000
+               - tsv * tsv * (18201 << 8) / 100000000
+               + tsv * tsv * tsv * (81542 << 8) / 1000000000000
+               - tsv * tsv * tsv * tsv * (16743 << 8) / 1000000000000000;
+       tsv >>= 8;
+
+       data->sensor[0].temp = (s16)tsv;
+
+       return 0;
+}
+
+/**
+ *  txgbe_init_thermal_sensor_thresh - Inits thermal sensor thresholds
+ *  @hw: pointer to hardware structure
+ *
+ *  Inits the thermal sensor thresholds according to the NVM map
+ *  and save off the threshold and location values into mac.thermal_sensor_data
+ **/
+s32 txgbe_init_thermal_sensor_thresh(struct txgbe_hw *hw)
+{
+       struct txgbe_thermal_sensor_data *data = &hw->mac.thermal_sensor_data;
+
+       DEBUGFUNC("txgbe_init_thermal_sensor_thresh");
+
+       memset(data, 0, sizeof(struct txgbe_thermal_sensor_data));
+
+       if (hw->bus.lan_id != 0)
+               return TXGBE_NOT_IMPLEMENTED;
+
+       wr32(hw, TXGBE_TSCTRL, TXGBE_TSCTRL_EVALMD);
+       wr32(hw, TXGBE_TSINTR,
+               TXGBE_TSINTR_AEN | TXGBE_TSINTR_DEN);
+       wr32(hw, TXGBE_TSEN, TXGBE_TSEN_ENA);
+
+
+       data->sensor[0].alarm_thresh = 100;
+       wr32(hw, TXGBE_TSATHRE, 677);
+       data->sensor[0].dalarm_thresh = 90;
+       wr32(hw, TXGBE_TSDTHRE, 614);
+
+       return 0;
+}
+
 void txgbe_disable_rx(struct txgbe_hw *hw)
 {
        u32 pfdtxgswc;
@@ -1058,6 +2448,9 @@ s32 txgbe_init_shared_code(struct txgbe_hw *hw)
        case txgbe_mac_raptor:
                status = txgbe_init_ops_pf(hw);
                break;
+       case txgbe_mac_raptor_vf:
+               status = txgbe_init_ops_vf(hw);
+               break;
        default:
                status = TXGBE_ERR_DEVICE_NOT_SUPPORTED;
                break;
@@ -1088,26 +2481,12 @@ s32 txgbe_set_mac_type(struct txgbe_hw *hw)
        }
 
        switch (hw->device_id) {
-       case TXGBE_DEV_ID_RAPTOR_KR_KX_KX4:
-               hw->phy.media_type = txgbe_media_type_backplane;
-               hw->mac.type = txgbe_mac_raptor;
-               break;
-       case TXGBE_DEV_ID_RAPTOR_XAUI:
-       case TXGBE_DEV_ID_RAPTOR_SGMII:
-               hw->phy.media_type = txgbe_media_type_copper;
-               hw->mac.type = txgbe_mac_raptor;
-               break;
-       case TXGBE_DEV_ID_RAPTOR_SFP:
-       case TXGBE_DEV_ID_WX1820_SFP:
-               hw->phy.media_type = txgbe_media_type_fiber;
-               hw->mac.type = txgbe_mac_raptor;
-               break;
-       case TXGBE_DEV_ID_RAPTOR_QSFP:
-               hw->phy.media_type = txgbe_media_type_fiber_qsfp;
+       case TXGBE_DEV_ID_SP1000:
+       case TXGBE_DEV_ID_WX1820:
                hw->mac.type = txgbe_mac_raptor;
                break;
-       case TXGBE_DEV_ID_RAPTOR_VF:
-       case TXGBE_DEV_ID_RAPTOR_VF_HV:
+       case TXGBE_DEV_ID_SP1000_VF:
+       case TXGBE_DEV_ID_WX1820_VF:
                hw->phy.media_type = txgbe_media_type_virtual;
                hw->mac.type = txgbe_mac_raptor_vf;
                break;
@@ -1117,8 +2496,8 @@ s32 txgbe_set_mac_type(struct txgbe_hw *hw)
                break;
        }
 
-       DEBUGOUT("found mac: %d media: %d, returns: %d\n",
-                 hw->mac.type, hw->phy.media_type, err);
+       DEBUGOUT("found mac: %d, returns: %d\n",
+                 hw->mac.type, err);
        return err;
 }
 
@@ -1149,13 +2528,9 @@ void txgbe_init_mac_link_ops(struct txgbe_hw *hw)
                mac->setup_link = txgbe_setup_mac_link_multispeed_fiber;
                mac->setup_mac_link = txgbe_setup_mac_link;
                mac->set_rate_select_speed = txgbe_set_hard_rate_select_speed;
-       } else if ((hw->phy.media_type == txgbe_media_type_backplane) &&
-                   (hw->phy.smart_speed == txgbe_smart_speed_auto ||
-                    hw->phy.smart_speed == txgbe_smart_speed_on) &&
-                    !txgbe_verify_lesm_fw_enabled_raptor(hw)) {
-               mac->setup_link = txgbe_setup_mac_link_smartspeed;
        } else {
                mac->setup_link = txgbe_setup_mac_link;
+               mac->set_rate_select_speed = txgbe_set_hard_rate_select_speed;
        }
 }
 
@@ -1176,7 +2551,7 @@ s32 txgbe_init_phy_raptor(struct txgbe_hw *hw)
 
        DEBUGFUNC("txgbe_init_phy_raptor");
 
-       if (hw->device_id == TXGBE_DEV_ID_RAPTOR_QSFP) {
+       if ((hw->device_id & 0xFF) == TXGBE_DEV_ID_QSFP) {
                /* Store flag indicating I2C bus access control unit. */
                hw->phy.qsfp_shared_i2c_bus = TRUE;
 
@@ -1199,6 +2574,11 @@ s32 txgbe_init_phy_raptor(struct txgbe_hw *hw)
                                  txgbe_get_copper_link_capabilities;
        }
 
+       if (phy->media_type == txgbe_media_type_backplane) {
+               mac->kr_handle = txgbe_kr_handle;
+               mac->bp_down_event = txgbe_bp_down_event;
+       }
+
        /* Set necessary function pointers based on PHY type */
        switch (hw->phy.type) {
        case txgbe_phy_tn:
@@ -1245,6 +2625,82 @@ s32 txgbe_setup_sfp_modules(struct txgbe_hw *hw)
        return err;
 }
 
+/**
+ *  txgbe_prot_autoc_read_raptor - Hides MAC differences needed for AUTOC read
+ *  @hw: pointer to hardware structure
+ *  @locked: Return the if we locked for this read.
+ *  @value: Value we read from AUTOC
+ *
+ *  For this part we need to wrap read-modify-writes with a possible
+ *  FW/SW lock.  It is assumed this lock will be freed with the next
+ *  prot_autoc_write_raptor().
+ */
+s32 txgbe_prot_autoc_read_raptor(struct txgbe_hw *hw, bool *locked, u64 *value)
+{
+       s32 err;
+       bool lock_state = false;
+
+        /* If LESM is on then we need to hold the SW/FW semaphore. */
+       if (txgbe_verify_lesm_fw_enabled_raptor(hw)) {
+               err = hw->mac.acquire_swfw_sync(hw,
+                                       TXGBE_MNGSEM_SWPHY);
+               if (err != 0)
+                       return TXGBE_ERR_SWFW_SYNC;
+
+               lock_state = true;
+       }
+
+       if (locked)
+               *locked = lock_state;
+
+       *value = txgbe_autoc_read(hw);
+       return 0;
+}
+
+/**
+ * txgbe_prot_autoc_write_raptor - Hides MAC differences needed for AUTOC write
+ * @hw: pointer to hardware structure
+ * @autoc: value to write to AUTOC
+ * @locked: bool to indicate whether the SW/FW lock was already taken by
+ *           previous prot_autoc_read_raptor.
+ *
+ * This part may need to hold the SW/FW lock around all writes to
+ * AUTOC. Likewise after a write we need to do a pipeline reset.
+ */
+s32 txgbe_prot_autoc_write_raptor(struct txgbe_hw *hw, bool locked, u64 autoc)
+{
+       int err = 0;
+
+       /* Blocked by MNG FW so bail */
+       if (txgbe_check_reset_blocked(hw))
+               goto out;
+
+       /* We only need to get the lock if:
+        *  - We didn't do it already (in the read part of a read-modify-write)
+        *  - LESM is enabled.
+        */
+       if (!locked && txgbe_verify_lesm_fw_enabled_raptor(hw)) {
+               err = hw->mac.acquire_swfw_sync(hw,
+                                       TXGBE_MNGSEM_SWPHY);
+               if (err != 0)
+                       return TXGBE_ERR_SWFW_SYNC;
+
+               locked = true;
+       }
+
+       txgbe_autoc_write(hw, autoc);
+       err = txgbe_reset_pipeline_raptor(hw);
+
+out:
+       /* Free the SW/FW semaphore as we either grabbed it here or
+        * already had it when this function was called.
+        */
+       if (locked)
+               hw->mac.release_swfw_sync(hw, TXGBE_MNGSEM_SWPHY);
+
+       return err;
+}
+
 /**
  *  txgbe_init_ops_pf - Inits func ptrs and MAC type
  *  @hw: pointer to hardware structure
@@ -1258,6 +2714,7 @@ s32 txgbe_init_ops_pf(struct txgbe_hw *hw)
        struct txgbe_mac_info *mac = &hw->mac;
        struct txgbe_phy_info *phy = &hw->phy;
        struct txgbe_rom_info *rom = &hw->rom;
+       struct txgbe_mbx_info *mbx = &hw->mbx;
 
        DEBUGFUNC("txgbe_init_ops_pf");
 
@@ -1274,34 +2731,79 @@ s32 txgbe_init_ops_pf(struct txgbe_hw *hw)
        phy->write_reg_mdi = txgbe_write_phy_reg_mdi;
        phy->setup_link = txgbe_setup_phy_link;
        phy->setup_link_speed = txgbe_setup_phy_link_speed;
+       phy->get_fw_version = txgbe_get_phy_fw_version;
        phy->read_i2c_byte = txgbe_read_i2c_byte;
        phy->write_i2c_byte = txgbe_write_i2c_byte;
+       phy->read_i2c_sff8472 = txgbe_read_i2c_sff8472;
        phy->read_i2c_eeprom = txgbe_read_i2c_eeprom;
        phy->write_i2c_eeprom = txgbe_write_i2c_eeprom;
+       phy->identify_sfp = txgbe_identify_module;
+       phy->read_i2c_byte_unlocked = txgbe_read_i2c_byte_unlocked;
+       phy->write_i2c_byte_unlocked = txgbe_write_i2c_byte_unlocked;
        phy->reset = txgbe_reset_phy;
 
        /* MAC */
        mac->init_hw = txgbe_init_hw;
        mac->start_hw = txgbe_start_hw_raptor;
+       mac->clear_hw_cntrs = txgbe_clear_hw_cntrs;
+       mac->enable_rx_dma = txgbe_enable_rx_dma_raptor;
        mac->get_mac_addr = txgbe_get_mac_addr;
        mac->stop_hw = txgbe_stop_hw;
+       mac->acquire_swfw_sync = txgbe_acquire_swfw_sync;
+       mac->release_swfw_sync = txgbe_release_swfw_sync;
        mac->reset_hw = txgbe_reset_hw;
+       mac->update_mc_addr_list = txgbe_update_mc_addr_list;
+
+       mac->disable_sec_rx_path = txgbe_disable_sec_rx_path;
+       mac->enable_sec_rx_path = txgbe_enable_sec_rx_path;
+       mac->disable_sec_tx_path = txgbe_disable_sec_tx_path;
+       mac->enable_sec_tx_path = txgbe_enable_sec_tx_path;
        mac->get_san_mac_addr = txgbe_get_san_mac_addr;
        mac->set_san_mac_addr = txgbe_set_san_mac_addr;
        mac->get_device_caps = txgbe_get_device_caps;
+       mac->get_wwn_prefix = txgbe_get_wwn_prefix;
        mac->autoc_read = txgbe_autoc_read;
        mac->autoc_write = txgbe_autoc_write;
+       mac->prot_autoc_read = txgbe_prot_autoc_read_raptor;
+       mac->prot_autoc_write = txgbe_prot_autoc_write_raptor;
 
+       /* RAR, Multicast, VLAN */
        mac->set_rar = txgbe_set_rar;
        mac->clear_rar = txgbe_clear_rar;
        mac->init_rx_addrs = txgbe_init_rx_addrs;
        mac->enable_rx = txgbe_enable_rx;
        mac->disable_rx = txgbe_disable_rx;
+       mac->set_vmdq = txgbe_set_vmdq;
+       mac->clear_vmdq = txgbe_clear_vmdq;
+       mac->set_vfta = txgbe_set_vfta;
+       mac->set_vlvf = txgbe_set_vlvf;
+       mac->clear_vfta = txgbe_clear_vfta;
        mac->init_uta_tables = txgbe_init_uta_tables;
        mac->setup_sfp = txgbe_setup_sfp_modules;
+       mac->set_mac_anti_spoofing = txgbe_set_mac_anti_spoofing;
+       mac->set_ethertype_anti_spoofing = txgbe_set_ethertype_anti_spoofing;
+
+       /* Flow Control */
+       mac->fc_enable = txgbe_fc_enable;
+       mac->setup_fc = txgbe_setup_fc;
+       mac->fc_autoneg = txgbe_fc_autoneg;
+
        /* Link */
        mac->get_link_capabilities = txgbe_get_link_capabilities_raptor;
        mac->check_link = txgbe_check_mac_link;
+       mac->setup_pba = txgbe_set_pba;
+
+       /* Manageability interface */
+       mac->set_fw_drv_ver = txgbe_hic_set_drv_ver;
+       mac->get_thermal_sensor_data = txgbe_get_thermal_sensor_data;
+       mac->init_thermal_sensor_thresh = txgbe_init_thermal_sensor_thresh;
+
+       mbx->init_params = txgbe_init_mbx_params_pf;
+       mbx->read = txgbe_read_mbx_pf;
+       mbx->write = txgbe_write_mbx_pf;
+       mbx->check_for_msg = txgbe_check_for_msg_pf;
+       mbx->check_for_ack = txgbe_check_for_ack_pf;
+       mbx->check_for_rst = txgbe_check_for_rst_pf;
 
        /* EEPROM */
        rom->init_params = txgbe_init_eeprom_params;
@@ -1318,7 +2820,9 @@ s32 txgbe_init_ops_pf(struct txgbe_hw *hw)
        rom->calc_checksum = txgbe_calc_eeprom_checksum;
 
        mac->mcft_size          = TXGBE_RAPTOR_MC_TBL_SIZE;
+       mac->vft_size           = TXGBE_RAPTOR_VFT_TBL_SIZE;
        mac->num_rar_entries    = TXGBE_RAPTOR_RAR_ENTRIES;
+       mac->rx_pb_size         = TXGBE_RAPTOR_RX_PB_SIZE;
        mac->max_rx_queues      = TXGBE_RAPTOR_MAX_RX_QUEUES;
        mac->max_tx_queues      = TXGBE_RAPTOR_MAX_TX_QUEUES;
 
@@ -1447,6 +2951,9 @@ u32 txgbe_get_media_type_raptor(struct txgbe_hw *hw)
 
        DEBUGFUNC("txgbe_get_media_type_raptor");
 
+       if (hw->phy.ffe_set)
+               txgbe_bp_mode_set(hw);
+
        /* Detect if there is a copper PHY attached. */
        switch (hw->phy.type) {
        case txgbe_phy_cu_unknown:
@@ -1457,22 +2964,29 @@ u32 txgbe_get_media_type_raptor(struct txgbe_hw *hw)
                break;
        }
 
-       switch (hw->device_id) {
-       case TXGBE_DEV_ID_RAPTOR_KR_KX_KX4:
+       switch (hw->subsystem_device_id & 0xFF) {
+       case TXGBE_DEV_ID_KR_KX_KX4:
+       case TXGBE_DEV_ID_MAC_SGMII:
+       case TXGBE_DEV_ID_MAC_XAUI:
                /* Default device ID is mezzanine card KX/KX4 */
                media_type = txgbe_media_type_backplane;
                break;
-       case TXGBE_DEV_ID_RAPTOR_SFP:
-       case TXGBE_DEV_ID_WX1820_SFP:
+       case TXGBE_DEV_ID_SFP:
                media_type = txgbe_media_type_fiber;
                break;
-       case TXGBE_DEV_ID_RAPTOR_QSFP:
+       case TXGBE_DEV_ID_QSFP:
                media_type = txgbe_media_type_fiber_qsfp;
                break;
-       case TXGBE_DEV_ID_RAPTOR_XAUI:
-       case TXGBE_DEV_ID_RAPTOR_SGMII:
+       case TXGBE_DEV_ID_XAUI:
+       case TXGBE_DEV_ID_SGMII:
                media_type = txgbe_media_type_copper;
                break;
+       case TXGBE_DEV_ID_SFI_XAUI:
+               if (hw->bus.lan_id == 0)
+                       media_type = txgbe_media_type_fiber;
+               else
+                       media_type = txgbe_media_type_copper;
+               break;
        default:
                media_type = txgbe_media_type_unknown;
                break;
@@ -1752,13 +3266,11 @@ s32 txgbe_setup_mac_link(struct txgbe_hw *hw,
        u64 pma_pmd_10gs = autoc & TXGBE_AUTOC_10GS_PMA_PMD_MASK;
        u64 pma_pmd_1g = autoc & TXGBE_AUTOC_1G_PMA_PMD_MASK;
        u64 link_mode = autoc & TXGBE_AUTOC_LMS_MASK;
-       u64 current_autoc = autoc;
        u64 orig_autoc = 0;
-       u32 links_reg;
-       u32 i;
        u32 link_capabilities = TXGBE_LINK_SPEED_UNKNOWN;
 
        DEBUGFUNC("txgbe_setup_mac_link");
+       UNREFERENCED_PARAMETER(autoneg_wait_to_complete);
 
        /* Check to see if speed passed in is supported. */
        status = hw->mac.get_link_capabilities(hw,
@@ -1789,8 +3301,7 @@ s32 txgbe_setup_mac_link(struct txgbe_hw *hw,
                if (speed & TXGBE_LINK_SPEED_10GB_FULL) {
                        if (orig_autoc & TXGBE_AUTOC_KX4_SUPP)
                                autoc |= TXGBE_AUTOC_KX4_SUPP;
-                       if ((orig_autoc & TXGBE_AUTOC_KR_SUPP) &&
-                           !hw->phy.smart_speed_active)
+                       if (orig_autoc & TXGBE_AUTOC_KR_SUPP)
                                autoc |= TXGBE_AUTOC_KR_SUPP;
                }
                if (speed & TXGBE_LINK_SPEED_1GB_FULL)
@@ -1817,35 +3328,14 @@ s32 txgbe_setup_mac_link(struct txgbe_hw *hw,
                }
        }
 
-       if (autoc == current_autoc)
-               return status;
-
        autoc &= ~TXGBE_AUTOC_SPEED_MASK;
        autoc |= TXGBE_AUTOC_SPEED(speed);
+       autoc &= ~TXGBE_AUTOC_AUTONEG;
        autoc |= (autoneg ? TXGBE_AUTOC_AUTONEG : 0);
 
        /* Restart link */
        hw->mac.autoc_write(hw, autoc);
 
-       /* Only poll for autoneg to complete if specified to do so */
-       if (autoneg_wait_to_complete) {
-               if (link_mode == TXGBE_AUTOC_LMS_KX4_KX_KR ||
-                   link_mode == TXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
-                   link_mode == TXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
-                       links_reg = 0; /*Just in case Autoneg time=0*/
-                       for (i = 0; i < TXGBE_AUTO_NEG_TIME; i++) {
-                               links_reg = rd32(hw, TXGBE_PORTSTAT);
-                               if (links_reg & TXGBE_PORTSTAT_UP)
-                                       break;
-                               msec_delay(100);
-                       }
-                       if (!(links_reg & TXGBE_PORTSTAT_UP)) {
-                               status = TXGBE_ERR_AUTONEG_NOT_COMPLETE;
-                               DEBUGOUT("Autoneg did not complete.\n");
-                       }
-               }
-       }
-
        /* Add delay to filter out noises during initial link setup */
        msec_delay(50);
 
@@ -1958,6 +3448,7 @@ txgbe_reset_misc(struct txgbe_hw *hw)
        /* enable mac transmitter */
        wr32m(hw, TXGBE_MACTXCFG, TXGBE_MACTXCFG_TXE, TXGBE_MACTXCFG_TXE);
 
+       hw->mac.autoc = hw->mac.orig_autoc;
        for (i = 0; i < 4; i++)
                wr32m(hw, TXGBE_IVAR(i), 0x80808080, 0);
 }
@@ -2051,12 +3542,19 @@ mac_reset_top:
         */
        if (!hw->mac.orig_link_settings_stored) {
                hw->mac.orig_autoc = hw->mac.autoc_read(hw);
-               hw->mac.autoc_write(hw, hw->mac.orig_autoc);
                hw->mac.orig_link_settings_stored = true;
        } else {
                hw->mac.orig_autoc = autoc;
        }
 
+       if (hw->phy.ffe_set) {
+               /* Make sure phy power is up */
+               msec_delay(50);
+
+               /* A temporary solution to set phy */
+               txgbe_set_phy_temp(hw);
+       }
+
        /* Store the permanent mac address */
        hw->mac.get_mac_addr(hw, hw->mac.perm_addr);
 
@@ -2094,6 +3592,93 @@ mac_reset_top:
        return status;
 }
 
+/**
+ * txgbe_fdir_check_cmd_complete - poll to check whether FDIRPICMD is complete
+ * @hw: pointer to hardware structure
+ * @fdircmd: current value of FDIRCMD register
+ */
+static s32 txgbe_fdir_check_cmd_complete(struct txgbe_hw *hw, u32 *fdircmd)
+{
+       int i;
+
+       for (i = 0; i < TXGBE_FDIRCMD_CMD_POLL; i++) {
+               *fdircmd = rd32(hw, TXGBE_FDIRPICMD);
+               if (!(*fdircmd & TXGBE_FDIRPICMD_OP_MASK))
+                       return 0;
+               usec_delay(10);
+       }
+
+       return TXGBE_ERR_FDIR_CMD_INCOMPLETE;
+}
+
+/**
+ *  txgbe_reinit_fdir_tables - Reinitialize Flow Director tables.
+ *  @hw: pointer to hardware structure
+ **/
+s32 txgbe_reinit_fdir_tables(struct txgbe_hw *hw)
+{
+       s32 err;
+       int i;
+       u32 fdirctrl = rd32(hw, TXGBE_FDIRCTL);
+       u32 fdircmd;
+       fdirctrl &= ~TXGBE_FDIRCTL_INITDONE;
+
+       DEBUGFUNC("txgbe_reinit_fdir_tables");
+
+       /*
+        * Before starting reinitialization process,
+        * FDIRPICMD.OP must be zero.
+        */
+       err = txgbe_fdir_check_cmd_complete(hw, &fdircmd);
+       if (err) {
+               DEBUGOUT("Flow Director previous command did not complete, aborting table re-initialization.\n");
+               return err;
+       }
+
+       wr32(hw, TXGBE_FDIRFREE, 0);
+       txgbe_flush(hw);
+       /*
+        * adapters flow director init flow cannot be restarted,
+        * Workaround silicon errata by performing the following steps
+        * before re-writing the FDIRCTL control register with the same value.
+        * - write 1 to bit 8 of FDIRPICMD register &
+        * - write 0 to bit 8 of FDIRPICMD register
+        */
+       wr32m(hw, TXGBE_FDIRPICMD, TXGBE_FDIRPICMD_CLR, TXGBE_FDIRPICMD_CLR);
+       txgbe_flush(hw);
+       wr32m(hw, TXGBE_FDIRPICMD, TXGBE_FDIRPICMD_CLR, 0);
+       txgbe_flush(hw);
+       /*
+        * Clear FDIR Hash register to clear any leftover hashes
+        * waiting to be programmed.
+        */
+       wr32(hw, TXGBE_FDIRPIHASH, 0x00);
+       txgbe_flush(hw);
+
+       wr32(hw, TXGBE_FDIRCTL, fdirctrl);
+       txgbe_flush(hw);
+
+       /* Poll init-done after we write FDIRCTL register */
+       for (i = 0; i < TXGBE_FDIR_INIT_DONE_POLL; i++) {
+               if (rd32m(hw, TXGBE_FDIRCTL, TXGBE_FDIRCTL_INITDONE))
+                       break;
+               msec_delay(1);
+       }
+       if (i >= TXGBE_FDIR_INIT_DONE_POLL) {
+               DEBUGOUT("Flow Director Signature poll time exceeded!\n");
+               return TXGBE_ERR_FDIR_REINIT_FAILED;
+       }
+
+       /* Clear FDIR statistics registers (read to clear) */
+       rd32(hw, TXGBE_FDIRUSED);
+       rd32(hw, TXGBE_FDIRFAIL);
+       rd32(hw, TXGBE_FDIRMATCH);
+       rd32(hw, TXGBE_FDIRMISS);
+       rd32(hw, TXGBE_FDIRLEN);
+
+       return 0;
+}
+
 /**
  *  txgbe_start_hw_raptor - Prepare hardware for Tx/Rx
  *  @hw: pointer to hardware structure
@@ -2123,6 +3708,35 @@ out:
        return err;
 }
 
+/**
+ *  txgbe_enable_rx_dma_raptor - Enable the Rx DMA unit
+ *  @hw: pointer to hardware structure
+ *  @regval: register value to write to RXCTRL
+ *
+ *  Enables the Rx DMA unit
+ **/
+s32 txgbe_enable_rx_dma_raptor(struct txgbe_hw *hw, u32 regval)
+{
+       DEBUGFUNC("txgbe_enable_rx_dma_raptor");
+
+       /*
+        * Workaround silicon errata when enabling the Rx datapath.
+        * If traffic is incoming before we enable the Rx unit, it could hang
+        * the Rx DMA unit.  Therefore, make sure the security engine is
+        * completely disabled prior to enabling the Rx unit.
+        */
+
+       hw->mac.disable_sec_rx_path(hw);
+
+       if (regval & TXGBE_PBRXCTL_ENA)
+               txgbe_enable_rx(hw);
+       else
+               txgbe_disable_rx(hw);
+
+       hw->mac.enable_sec_rx_path(hw);
+
+       return 0;
+}
 
 /**
  *  txgbe_verify_lesm_fw_enabled_raptor - Checks LESM FW module state.