ethdev: better typing of RSS constants
[dpdk.git] / lib / librte_pmd_e1000 / e1000 / e1000_api.c
index fc41f73..a064565 100644 (file)
@@ -1,36 +1,35 @@
-/******************************************************************************
-
-  Copyright (c) 2001-2011, Intel Corporation 
-  All rights reserved.
-  
-  Redistribution and use in source and binary forms, with or without 
-  modification, are permitted provided that the following conditions are met:
-  
-   1. Redistributions of source code must retain the above copyright notice, 
-      this list of conditions and the following disclaimer.
-  
-   2. Redistributions in binary form must reproduce the above copyright 
-      notice, this list of conditions and the following disclaimer in the 
-      documentation and/or other materials provided with the distribution.
-  
-   3. Neither the name of the Intel Corporation nor the names of its 
-      contributors may be used to endorse or promote products derived from 
-      this software without specific prior written permission.
-  
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
-  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
-  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
-  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
-  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
-  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
-  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
-  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
-  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-  POSSIBILITY OF SUCH DAMAGE.
-
-******************************************************************************/
-/*$FreeBSD$*/
+/*******************************************************************************
+
+Copyright (c) 2001-2014, Intel Corporation
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Intel Corporation nor the names of its
+    contributors may be used to endorse or promote products derived from
+    this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+***************************************************************************/
 
 #include "e1000_api.h"
 
@@ -155,6 +154,146 @@ s32 e1000_set_mac_type(struct e1000_hw *hw)
        DEBUGFUNC("e1000_set_mac_type");
 
        switch (hw->device_id) {
+       case E1000_DEV_ID_82542:
+               mac->type = e1000_82542;
+               break;
+       case E1000_DEV_ID_82543GC_FIBER:
+       case E1000_DEV_ID_82543GC_COPPER:
+               mac->type = e1000_82543;
+               break;
+       case E1000_DEV_ID_82544EI_COPPER:
+       case E1000_DEV_ID_82544EI_FIBER:
+       case E1000_DEV_ID_82544GC_COPPER:
+       case E1000_DEV_ID_82544GC_LOM:
+               mac->type = e1000_82544;
+               break;
+       case E1000_DEV_ID_82540EM:
+       case E1000_DEV_ID_82540EM_LOM:
+       case E1000_DEV_ID_82540EP:
+       case E1000_DEV_ID_82540EP_LOM:
+       case E1000_DEV_ID_82540EP_LP:
+               mac->type = e1000_82540;
+               break;
+       case E1000_DEV_ID_82545EM_COPPER:
+       case E1000_DEV_ID_82545EM_FIBER:
+               mac->type = e1000_82545;
+               break;
+       case E1000_DEV_ID_82545GM_COPPER:
+       case E1000_DEV_ID_82545GM_FIBER:
+       case E1000_DEV_ID_82545GM_SERDES:
+               mac->type = e1000_82545_rev_3;
+               break;
+       case E1000_DEV_ID_82546EB_COPPER:
+       case E1000_DEV_ID_82546EB_FIBER:
+       case E1000_DEV_ID_82546EB_QUAD_COPPER:
+               mac->type = e1000_82546;
+               break;
+       case E1000_DEV_ID_82546GB_COPPER:
+       case E1000_DEV_ID_82546GB_FIBER:
+       case E1000_DEV_ID_82546GB_SERDES:
+       case E1000_DEV_ID_82546GB_PCIE:
+       case E1000_DEV_ID_82546GB_QUAD_COPPER:
+       case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
+               mac->type = e1000_82546_rev_3;
+               break;
+       case E1000_DEV_ID_82541EI:
+       case E1000_DEV_ID_82541EI_MOBILE:
+       case E1000_DEV_ID_82541ER_LOM:
+               mac->type = e1000_82541;
+               break;
+       case E1000_DEV_ID_82541ER:
+       case E1000_DEV_ID_82541GI:
+       case E1000_DEV_ID_82541GI_LF:
+       case E1000_DEV_ID_82541GI_MOBILE:
+               mac->type = e1000_82541_rev_2;
+               break;
+       case E1000_DEV_ID_82547EI:
+       case E1000_DEV_ID_82547EI_MOBILE:
+               mac->type = e1000_82547;
+               break;
+       case E1000_DEV_ID_82547GI:
+               mac->type = e1000_82547_rev_2;
+               break;
+       case E1000_DEV_ID_82571EB_COPPER:
+       case E1000_DEV_ID_82571EB_FIBER:
+       case E1000_DEV_ID_82571EB_SERDES:
+       case E1000_DEV_ID_82571EB_SERDES_DUAL:
+       case E1000_DEV_ID_82571EB_SERDES_QUAD:
+       case E1000_DEV_ID_82571EB_QUAD_COPPER:
+       case E1000_DEV_ID_82571PT_QUAD_COPPER:
+       case E1000_DEV_ID_82571EB_QUAD_FIBER:
+       case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
+               mac->type = e1000_82571;
+               break;
+       case E1000_DEV_ID_82572EI:
+       case E1000_DEV_ID_82572EI_COPPER:
+       case E1000_DEV_ID_82572EI_FIBER:
+       case E1000_DEV_ID_82572EI_SERDES:
+               mac->type = e1000_82572;
+               break;
+       case E1000_DEV_ID_82573E:
+       case E1000_DEV_ID_82573E_IAMT:
+       case E1000_DEV_ID_82573L:
+               mac->type = e1000_82573;
+               break;
+       case E1000_DEV_ID_82574L:
+       case E1000_DEV_ID_82574LA:
+               mac->type = e1000_82574;
+               break;
+       case E1000_DEV_ID_82583V:
+               mac->type = e1000_82583;
+               break;
+       case E1000_DEV_ID_80003ES2LAN_COPPER_DPT:
+       case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
+       case E1000_DEV_ID_80003ES2LAN_COPPER_SPT:
+       case E1000_DEV_ID_80003ES2LAN_SERDES_SPT:
+               mac->type = e1000_80003es2lan;
+               break;
+       case E1000_DEV_ID_ICH8_IFE:
+       case E1000_DEV_ID_ICH8_IFE_GT:
+       case E1000_DEV_ID_ICH8_IFE_G:
+       case E1000_DEV_ID_ICH8_IGP_M:
+       case E1000_DEV_ID_ICH8_IGP_M_AMT:
+       case E1000_DEV_ID_ICH8_IGP_AMT:
+       case E1000_DEV_ID_ICH8_IGP_C:
+       case E1000_DEV_ID_ICH8_82567V_3:
+               mac->type = e1000_ich8lan;
+               break;
+       case E1000_DEV_ID_ICH9_IFE:
+       case E1000_DEV_ID_ICH9_IFE_GT:
+       case E1000_DEV_ID_ICH9_IFE_G:
+       case E1000_DEV_ID_ICH9_IGP_M:
+       case E1000_DEV_ID_ICH9_IGP_M_AMT:
+       case E1000_DEV_ID_ICH9_IGP_M_V:
+       case E1000_DEV_ID_ICH9_IGP_AMT:
+       case E1000_DEV_ID_ICH9_BM:
+       case E1000_DEV_ID_ICH9_IGP_C:
+       case E1000_DEV_ID_ICH10_R_BM_LM:
+       case E1000_DEV_ID_ICH10_R_BM_LF:
+       case E1000_DEV_ID_ICH10_R_BM_V:
+               mac->type = e1000_ich9lan;
+               break;
+       case E1000_DEV_ID_ICH10_D_BM_LM:
+       case E1000_DEV_ID_ICH10_D_BM_LF:
+       case E1000_DEV_ID_ICH10_D_BM_V:
+               mac->type = e1000_ich10lan;
+               break;
+       case E1000_DEV_ID_PCH_D_HV_DM:
+       case E1000_DEV_ID_PCH_D_HV_DC:
+       case E1000_DEV_ID_PCH_M_HV_LM:
+       case E1000_DEV_ID_PCH_M_HV_LC:
+               mac->type = e1000_pchlan;
+               break;
+       case E1000_DEV_ID_PCH2_LV_LM:
+       case E1000_DEV_ID_PCH2_LV_V:
+               mac->type = e1000_pch2lan;
+               break;
+       case E1000_DEV_ID_PCH_LPT_I217_LM:
+       case E1000_DEV_ID_PCH_LPT_I217_V:
+       case E1000_DEV_ID_PCH_LPTLP_I218_LM:
+       case E1000_DEV_ID_PCH_LPTLP_I218_V:
+               mac->type = e1000_pch_lpt;
+               break;
        case E1000_DEV_ID_82575EB_COPPER:
        case E1000_DEV_ID_82575EB_FIBER_SERDES:
        case E1000_DEV_ID_82575GB_QUAD_COPPER:
@@ -189,12 +328,33 @@ s32 e1000_set_mac_type(struct e1000_hw *hw)
        case E1000_DEV_ID_I350_DA4:
                mac->type = e1000_i350;
                break;
+       case E1000_DEV_ID_I210_COPPER_FLASHLESS:
+       case E1000_DEV_ID_I210_SERDES_FLASHLESS:
+       case E1000_DEV_ID_I210_COPPER:
+       case E1000_DEV_ID_I210_COPPER_OEM1:
+       case E1000_DEV_ID_I210_COPPER_IT:
+       case E1000_DEV_ID_I210_FIBER:
+       case E1000_DEV_ID_I210_SERDES:
+       case E1000_DEV_ID_I210_SGMII:
+               mac->type = e1000_i210;
+               break;
+       case E1000_DEV_ID_I211_COPPER:
+               mac->type = e1000_i211;
+               break;
        case E1000_DEV_ID_82576_VF:
+       case E1000_DEV_ID_82576_VF_HV:
                mac->type = e1000_vfadapt;
                break;
        case E1000_DEV_ID_I350_VF:
+       case E1000_DEV_ID_I350_VF_HV:
                mac->type = e1000_vfadapt_i350;
                break;
+
+       case E1000_DEV_ID_I354_BACKPLANE_1GBPS:
+       case E1000_DEV_ID_I354_SGMII:
+       case E1000_DEV_ID_I354_BACKPLANE_2_5GBPS:
+               mac->type = e1000_i354;
+               break;
        default:
                /* Should never have loaded on this device */
                ret_val = -E1000_ERR_MAC_INIT;
@@ -207,11 +367,11 @@ s32 e1000_set_mac_type(struct e1000_hw *hw)
 /**
  *  e1000_setup_init_funcs - Initializes function pointers
  *  @hw: pointer to the HW structure
- *  @init_device: TRUE will initialize the rest of the function pointers
- *                 getting the device ready for use.  FALSE will only set
- *                 MAC type and the function pointers for the other init
- *                 functions.  Passing FALSE will not generate any hardware
- *                 reads or writes.
+ *  @init_device: true will initialize the rest of the function pointers
+ *               getting the device ready for use.  false will only set
+ *               MAC type and the function pointers for the other init
+ *               functions.  Passing false will not generate any hardware
+ *               reads or writes.
  *
  *  This function must be called by a driver in order to use the rest
  *  of the 'shared' code files. Called by drivers only.
@@ -248,12 +408,55 @@ s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
         * the functions in that family.
         */
        switch (hw->mac.type) {
+       case e1000_82542:
+               e1000_init_function_pointers_82542(hw);
+               break;
+       case e1000_82543:
+       case e1000_82544:
+               e1000_init_function_pointers_82543(hw);
+               break;
+       case e1000_82540:
+       case e1000_82545:
+       case e1000_82545_rev_3:
+       case e1000_82546:
+       case e1000_82546_rev_3:
+               e1000_init_function_pointers_82540(hw);
+               break;
+       case e1000_82541:
+       case e1000_82541_rev_2:
+       case e1000_82547:
+       case e1000_82547_rev_2:
+               e1000_init_function_pointers_82541(hw);
+               break;
+       case e1000_82571:
+       case e1000_82572:
+       case e1000_82573:
+       case e1000_82574:
+       case e1000_82583:
+               e1000_init_function_pointers_82571(hw);
+               break;
+       case e1000_80003es2lan:
+               e1000_init_function_pointers_80003es2lan(hw);
+               break;
+       case e1000_ich8lan:
+       case e1000_ich9lan:
+       case e1000_ich10lan:
+       case e1000_pchlan:
+       case e1000_pch2lan:
+       case e1000_pch_lpt:
+               e1000_init_function_pointers_ich8lan(hw);
+               break;
        case e1000_82575:
        case e1000_82576:
        case e1000_82580:
        case e1000_i350:
+       case e1000_i354:
                e1000_init_function_pointers_82575(hw);
                break;
+       case e1000_i210:
+       case e1000_i211:
+               e1000_init_function_pointers_i210(hw);
+               break;
        case e1000_vfadapt:
                e1000_init_function_pointers_vf(hw);
                break;
@@ -346,11 +549,11 @@ void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
  *  The caller must have a packed mc_addr_list of multicast addresses.
  **/
 void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
-                               u32 mc_addr_count)
+                              u32 mc_addr_count)
 {
        if (hw->mac.ops.update_mc_addr_list)
                hw->mac.ops.update_mc_addr_list(hw, mc_addr_list,
-                                               mc_addr_count);
+                                               mc_addr_count);
 }
 
 /**
@@ -394,7 +597,7 @@ bool e1000_check_mng_mode(struct e1000_hw *hw)
        if (hw->mac.ops.check_mng_mode)
                return hw->mac.ops.check_mng_mode(hw);
 
-       return FALSE;
+       return false;
 }
 
 /**
@@ -684,14 +887,10 @@ bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
  *  It also does alignment considerations to do the writes in most efficient
  *  way.  Also fills up the sum of the buffer in *buffer parameter.
  **/
-s32 e1000_mng_host_if_write(struct e1000_hw * hw, u8 *buffer, u16 length,
-                            u16 offset, u8 *sum)
+s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
+                           u16 offset, u8 *sum)
 {
-       if (hw->mac.ops.mng_host_if_write)
-               return hw->mac.ops.mng_host_if_write(hw, buffer, length,
-                                                    offset, sum);
-
-       return E1000_NOT_IMPLEMENTED;
+       return e1000_mng_host_if_write_generic(hw, buffer, length, offset, sum);
 }
 
 /**
@@ -702,12 +901,9 @@ s32 e1000_mng_host_if_write(struct e1000_hw * hw, u8 *buffer, u16 length,
  *  Writes the command header after does the checksum calculation.
  **/
 s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
-                               struct e1000_host_mng_command_header *hdr)
+                              struct e1000_host_mng_command_header *hdr)
 {
-       if (hw->mac.ops.mng_write_cmd_header)
-               return hw->mac.ops.mng_write_cmd_header(hw, hdr);
-
-       return E1000_NOT_IMPLEMENTED;
+       return e1000_mng_write_cmd_header_generic(hw, hdr);
 }
 
 /**
@@ -720,27 +916,9 @@ s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
  *  and also checks whether the previous command is completed.  It busy waits
  *  in case of previous command is not completed.
  **/
-s32 e1000_mng_enable_host_if(struct e1000_hw * hw)
+s32 e1000_mng_enable_host_if(struct e1000_hw *hw)
 {
-       if (hw->mac.ops.mng_enable_host_if)
-               return hw->mac.ops.mng_enable_host_if(hw);
-
-       return E1000_NOT_IMPLEMENTED;
-}
-
-/**
- *  e1000_wait_autoneg - Waits for autonegotiation completion
- *  @hw: pointer to the HW structure
- *
- *  Waits for autoneg to complete. Currently no func pointer exists and all
- *  implementations are handled in the generic version of this function.
- **/
-s32 e1000_wait_autoneg(struct e1000_hw *hw)
-{
-       if (hw->mac.ops.wait_autoneg)
-               return hw->mac.ops.wait_autoneg(hw);
-
-       return E1000_SUCCESS;
+       return e1000_mng_enable_host_if_generic(hw);
 }
 
 /**
@@ -820,6 +998,18 @@ s32 e1000_acquire_phy(struct e1000_hw *hw)
        return E1000_SUCCESS;
 }
 
+/**
+ *  e1000_cfg_on_link_up - Configure PHY upon link up
+ *  @hw: pointer to the HW structure
+ **/
+s32 e1000_cfg_on_link_up(struct e1000_hw *hw)
+{
+       if (hw->phy.ops.cfg_on_link_up)
+               return hw->phy.ops.cfg_on_link_up(hw);
+
+       return E1000_SUCCESS;
+}
+
 /**
  *  e1000_read_kmrn_reg - Reads register using Kumeran interface
  *  @hw: pointer to the HW structure
@@ -920,7 +1110,7 @@ s32 e1000_phy_commit(struct e1000_hw *hw)
  *  Success returns 0, Failure returns 1
  *
  *  The low power link up (lplu) state is set to the power management level D0
- *  and SmartSpeed is disabled when active is TRUE, else clear lplu for D0
+ *  and SmartSpeed is disabled when active is true, else clear lplu for D0
  *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
  *  is used during Dx states where the power conservation is most important.
  *  During driver activity, SmartSpeed should be enabled so performance is
@@ -942,7 +1132,7 @@ s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
  *  Success returns 0, Failure returns 1
  *
  *  The low power link up (lplu) state is set to the power management level D3
- *  and SmartSpeed is disabled when active is TRUE, else clear lplu for D3
+ *  and SmartSpeed is disabled when active is true, else clear lplu for D3
  *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
  *  is used during Dx states where the power conservation is most important.
  *  During driver activity, SmartSpeed should be enabled so performance is
@@ -1003,6 +1193,21 @@ s32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size)
        return e1000_read_pba_length_generic(hw, pba_num_size);
 }
 
+/**
+ *  e1000_read_pba_num - Read device part number
+ *  @hw: pointer to the HW structure
+ *  @pba_num: pointer to device part number
+ *
+ *  Reads the product board assembly (PBA) number from the EEPROM and stores
+ *  the value in pba_num.
+ *  Currently no func pointer exists and all implementations are handled in the
+ *  generic version of this function.
+ **/
+s32 e1000_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
+{
+       return e1000_read_pba_num_generic(hw, pba_num);
+}
+
 /**
  *  e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
  *  @hw: pointer to the HW structure
@@ -1093,7 +1298,7 @@ s32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
  *  This is a function pointer entry point called by drivers.
  **/
 s32 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset,
-                              u8 data)
+                             u8 data)
 {
        return e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data);
 }