enic: add device ids
[dpdk.git] / lib / librte_pmd_e1000 / e1000 / e1000_80003es2lan.c
index 7fee262..72692d9 100644 (file)
@@ -1,6 +1,6 @@
 /*******************************************************************************
 
-Copyright (c) 2001-2012, Intel Corporation
+Copyright (c) 2001-2014, Intel Corporation
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -37,9 +37,6 @@ POSSIBILITY OF SUCH DAMAGE.
 
 #include "e1000_api.h"
 
-STATIC s32  e1000_init_phy_params_80003es2lan(struct e1000_hw *hw);
-STATIC s32  e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw);
-STATIC s32  e1000_init_mac_params_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_acquire_phy_80003es2lan(struct e1000_hw *hw);
 STATIC void e1000_release_phy_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw);
@@ -61,17 +58,16 @@ STATIC s32  e1000_reset_hw_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_init_hw_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw);
 STATIC void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw);
-static s32  e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
-static s32  e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex);
-static s32  e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);
-static s32  e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw);
-static s32  e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
+STATIC s32  e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
+STATIC s32  e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex);
+STATIC s32  e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);
+STATIC s32  e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw);
+STATIC s32  e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
                                            u16 *data);
-static s32  e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
+STATIC s32  e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
                                             u16 data);
-static s32  e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw);
-static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);
-static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
+STATIC void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);
+STATIC void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
 STATIC s32  e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw);
 STATIC void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw);
 
@@ -79,7 +75,7 @@ STATIC void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw);
  * with a lower bound at "index" and the upper bound at
  * "index + 5".
  */
-static const u16 e1000_gg82563_cable_length_table[] = {
+STATIC const u16 e1000_gg82563_cable_length_table[] = {
        0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF };
 #define GG82563_CABLE_LENGTH_TABLE_SIZE \
                (sizeof(e1000_gg82563_cable_length_table) / \
@@ -402,7 +398,7 @@ STATIC void e1000_release_nvm_80003es2lan(struct e1000_hw *hw)
  *  Acquire the SW/FW semaphore to access the PHY or NVM.  The mask
  *  will also specify which port we're acquiring the lock for.
  **/
-static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
+STATIC s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
 {
        u32 swfw_sync;
        u32 swmask = mask;
@@ -449,7 +445,7 @@ static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
  *  Release the SW/FW semaphore used to access the PHY or NVM.  The mask
  *  will also specify which port we're releasing the lock for.
  **/
-static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
+STATIC void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
 {
        u32 swfw_sync;
 
@@ -760,7 +756,7 @@ STATIC s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)
 STATIC s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
-       s32 ret_val = E1000_SUCCESS;
+       s32 ret_val;
        u16 phy_data, index;
 
        DEBUGFUNC("e1000_get_cable_length_80003es2lan");
@@ -846,13 +842,18 @@ STATIC s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
        ctrl = E1000_READ_REG(hw, E1000_CTRL);
 
        ret_val = e1000_acquire_phy_80003es2lan(hw);
+       if (ret_val)
+               return ret_val;
+
        DEBUGOUT("Issuing a global reset to MAC\n");
        E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
        e1000_release_phy_80003es2lan(hw);
 
        /* Disable IBIST slave mode (far-end loopback) */
-       e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
-                                       &kum_reg_data);
+       ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
+                               E1000_KMRNCTRLSTA_INBAND_PARAM, &kum_reg_data);
+       if (ret_val)
+               return ret_val;
        kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
        e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
                                        kum_reg_data);
@@ -889,9 +890,9 @@ STATIC s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
 
        /* Initialize identification LED */
        ret_val = mac->ops.id_led_init(hw);
+       /* An error is not fatal and we should not stop init due to this */
        if (ret_val)
                DEBUGOUT("Error initializing identification LED\n");
-               /* This is not fatal and we should not stop init due to this */
 
        /* Disabling VLAN filtering */
        DEBUGOUT("Initializing the IEEE VLAN\n");
@@ -907,6 +908,8 @@ STATIC s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
 
        /* Setup link and flow control */
        ret_val = mac->ops.setup_link(hw);
+       if (ret_val)
+               return ret_val;
 
        /* Disable IBIST slave mode (far-end loopback) */
        e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
@@ -917,14 +920,14 @@ STATIC s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
 
        /* Set the transmit descriptor write-back policy */
        reg_data = E1000_READ_REG(hw, E1000_TXDCTL(0));
-       reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
-                  E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC;
+       reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) |
+                   E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC);
        E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg_data);
 
        /* ...for both queues. */
        reg_data = E1000_READ_REG(hw, E1000_TXDCTL(1));
-       reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
-                  E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC;
+       reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) |
+                   E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC);
        E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg_data);
 
        /* Enable retransmit on late collisions */
@@ -951,10 +954,9 @@ STATIC s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
        /* default to true to enable the MDIC W/A */
        hw->dev_spec._80003es2lan.mdic_wa_enable = true;
 
-       ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
-                                                E1000_KMRNCTRLSTA_OFFSET >>
-                                                E1000_KMRNCTRLSTA_OFFSET_SHIFT,
-                                                &i);
+       ret_val =
+           e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET >>
+                                           E1000_KMRNCTRLSTA_OFFSET_SHIFT, &i);
        if (!ret_val) {
                if ((i & E1000_KMRNCTRLSTA_OPMODE_MASK) ==
                     E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO)
@@ -977,7 +979,7 @@ STATIC s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
  *
  *  Initializes required hardware-dependent bits needed for normal operation.
  **/
-static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw)
+STATIC void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw)
 {
        u32 reg;
 
@@ -1024,11 +1026,11 @@ static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw)
  *
  *  Setup some GG82563 PHY registers for obtaining link
  **/
-static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
+STATIC s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
        s32 ret_val;
-       u32 ctrl_ext;
+       u32 reg;
        u16 data;
 
        DEBUGFUNC("e1000_copper_link_setup_gg82563_80003es2lan");
@@ -1093,20 +1095,19 @@ static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
        }
 
        /* Bypass Rx and Tx FIFO's */
-       ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
-                                       E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL,
-                                       E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS |
-                                       E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS);
+       reg = E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL;
+       data = (E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS |
+               E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS);
+       ret_val = e1000_write_kmrn_reg_80003es2lan(hw, reg, data);
        if (ret_val)
                return ret_val;
 
-       ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
-                               E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE, &data);
+       reg = E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE;
+       ret_val = e1000_read_kmrn_reg_80003es2lan(hw, reg, &data);
        if (ret_val)
                return ret_val;
        data |= E1000_KMRNCTRLSTA_OPMODE_E_IDLE;
-       ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
-                               E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE, data);
+       ret_val = e1000_write_kmrn_reg_80003es2lan(hw, reg, data);
        if (ret_val)
                return ret_val;
 
@@ -1119,9 +1120,9 @@ static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
        if (ret_val)
                return ret_val;
 
-       ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
-       ctrl_ext &= ~(E1000_CTRL_EXT_LINK_MODE_MASK);
-       E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
+       reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
+       reg &= ~E1000_CTRL_EXT_LINK_MODE_MASK;
+       E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
 
        ret_val = hw->phy.ops.read_reg(hw, GG82563_PHY_PWR_MGMT_CTRL, &data);
        if (ret_val)
@@ -1203,13 +1204,17 @@ STATIC s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
                                                   reg_data);
        if (ret_val)
                return ret_val;
-       ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
-                               E1000_KMRNCTRLSTA_OFFSET_INB_CTRL, &reg_data);
+       ret_val =
+           e1000_read_kmrn_reg_80003es2lan(hw,
+                                           E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
+                                           &reg_data);
        if (ret_val)
                return ret_val;
        reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING;
-       ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
-                               E1000_KMRNCTRLSTA_OFFSET_INB_CTRL, reg_data);
+       ret_val =
+           e1000_write_kmrn_reg_80003es2lan(hw,
+                                            E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
+                                            reg_data);
        if (ret_val)
                return ret_val;
 
@@ -1228,7 +1233,7 @@ STATIC s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
  *  Configure the KMRN interface by applying last minute quirks for
  *  10/100 operation.
  **/
-static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
+STATIC s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
 {
        s32 ret_val = E1000_SUCCESS;
        u16 speed;
@@ -1259,7 +1264,7 @@ static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
  *  Configure the KMRN interface by applying last minute quirks for
  *  10/100 operation.
  **/
-static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
+STATIC s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
 {
        s32 ret_val;
        u32 tipg;
@@ -1269,9 +1274,10 @@ static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
        DEBUGFUNC("e1000_configure_kmrn_for_10_100");
 
        reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT;
-       ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
-                                      E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
-                                      reg_data);
+       ret_val =
+           e1000_write_kmrn_reg_80003es2lan(hw,
+                                            E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
+                                            reg_data);
        if (ret_val)
                return ret_val;
 
@@ -1309,7 +1315,7 @@ static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
  *  Configure the KMRN interface by applying last minute quirks for
  *  gigabit operation.
  **/
-static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
+STATIC s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
 {
        s32 ret_val;
        u16 reg_data, reg_data2;
@@ -1319,8 +1325,10 @@ static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
        DEBUGFUNC("e1000_configure_kmrn_for_1000");
 
        reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT;
-       ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
-                               E1000_KMRNCTRLSTA_OFFSET_HD_CTRL, reg_data);
+       ret_val =
+           e1000_write_kmrn_reg_80003es2lan(hw,
+                                            E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
+                                            reg_data);
        if (ret_val)
                return ret_val;
 
@@ -1358,11 +1366,11 @@ static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
  *  using the kumeran interface.  The information retrieved is stored in data.
  *  Release the semaphore before exiting.
  **/
-static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
+STATIC s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
                                           u16 *data)
 {
        u32 kmrnctrlsta;
-       s32 ret_val = E1000_SUCCESS;
+       s32 ret_val;
 
        DEBUGFUNC("e1000_read_kmrn_reg_80003es2lan");
 
@@ -1395,11 +1403,11 @@ static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
  *  at the offset using the kumeran interface.  Release semaphore
  *  before exiting.
  **/
-static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
+STATIC s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
                                            u16 data)
 {
        u32 kmrnctrlsta;
-       s32 ret_val = E1000_SUCCESS;
+       s32 ret_val;
 
        DEBUGFUNC("e1000_write_kmrn_reg_80003es2lan");
 
@@ -1425,7 +1433,7 @@ static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
  **/
 STATIC s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw)
 {
-       s32 ret_val = E1000_SUCCESS;
+       s32 ret_val;
 
        DEBUGFUNC("e1000_read_mac_addr_80003es2lan");