e1000_api.c revision 333213
199461Sobrien/****************************************************************************** 2218822Sdim 3218822Sdim Copyright (c) 2001-2015, Intel Corporation 499461Sobrien All rights reserved. 599461Sobrien 699461Sobrien Redistribution and use in source and binary forms, with or without 799461Sobrien modification, are permitted provided that the following conditions are met: 899461Sobrien 999461Sobrien 1. Redistributions of source code must retain the above copyright notice, 1099461Sobrien this list of conditions and the following disclaimer. 1199461Sobrien 1299461Sobrien 2. Redistributions in binary form must reproduce the above copyright 1399461Sobrien notice, this list of conditions and the following disclaimer in the 1499461Sobrien documentation and/or other materials provided with the distribution. 1599461Sobrien 1699461Sobrien 3. Neither the name of the Intel Corporation nor the names of its 1799461Sobrien contributors may be used to endorse or promote products derived from 1899461Sobrien this software without specific prior written permission. 1999461Sobrien 20218822Sdim THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21218822Sdim AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2299461Sobrien IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23218822Sdim ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2499461Sobrien LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2599461Sobrien CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2699461Sobrien SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2799461Sobrien INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2899461Sobrien CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2999461Sobrien ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3099461Sobrien POSSIBILITY OF SUCH DAMAGE. 3199461Sobrien 3299461Sobrien******************************************************************************/ 33130561Sobrien/*$FreeBSD: stable/11/sys/dev/e1000/e1000_api.c 333213 2018-05-03 15:40:56Z marius $*/ 3499461Sobrien 3599461Sobrien#include "e1000_api.h" 3699461Sobrien 3799461Sobrien/** 3899461Sobrien * e1000_init_mac_params - Initialize MAC function pointers 39130561Sobrien * @hw: pointer to the HW structure 4099461Sobrien * 41130561Sobrien * This function initializes the function pointers for the MAC 4299461Sobrien * set of functions. Called by drivers or by e1000_setup_init_funcs. 4399461Sobrien **/ 44218822Sdims32 e1000_init_mac_params(struct e1000_hw *hw) 45107492Sobrien{ 46130561Sobrien s32 ret_val = E1000_SUCCESS; 4799461Sobrien 4899461Sobrien if (hw->mac.ops.init_params) { 49130561Sobrien ret_val = hw->mac.ops.init_params(hw); 50130561Sobrien if (ret_val) { 51130561Sobrien DEBUGOUT("MAC Initialization Error\n"); 52130561Sobrien goto out; 5399461Sobrien } 54130561Sobrien } else { 5599461Sobrien DEBUGOUT("mac.init_mac_params was NULL\n"); 56130561Sobrien ret_val = -E1000_ERR_CONFIG; 5799461Sobrien } 58130561Sobrien 5999461Sobrienout: 60130561Sobrien return ret_val; 6199461Sobrien} 6299461Sobrien 63130561Sobrien/** 6499461Sobrien * e1000_init_nvm_params - Initialize NVM function pointers 6599461Sobrien * @hw: pointer to the HW structure 6699461Sobrien * 6799461Sobrien * This function initializes the function pointers for the NVM 68130561Sobrien * set of functions. Called by drivers or by e1000_setup_init_funcs. 6999461Sobrien **/ 70130561Sobriens32 e1000_init_nvm_params(struct e1000_hw *hw) 71130561Sobrien{ 72130561Sobrien s32 ret_val = E1000_SUCCESS; 73130561Sobrien 74130561Sobrien if (hw->nvm.ops.init_params) { 75130561Sobrien ret_val = hw->nvm.ops.init_params(hw); 76130561Sobrien if (ret_val) { 77130561Sobrien DEBUGOUT("NVM Initialization Error\n"); 78130561Sobrien goto out; 79130561Sobrien } 80130561Sobrien } else { 81130561Sobrien DEBUGOUT("nvm.init_nvm_params was NULL\n"); 82130561Sobrien ret_val = -E1000_ERR_CONFIG; 83130561Sobrien } 84130561Sobrien 85130561Sobrienout: 8699461Sobrien return ret_val; 8799461Sobrien} 8899461Sobrien 8999461Sobrien/** 9099461Sobrien * e1000_init_phy_params - Initialize PHY function pointers 9199461Sobrien * @hw: pointer to the HW structure 9299461Sobrien * 9399461Sobrien * This function initializes the function pointers for the PHY 9499461Sobrien * set of functions. Called by drivers or by e1000_setup_init_funcs. 9599461Sobrien **/ 9699461Sobriens32 e1000_init_phy_params(struct e1000_hw *hw) 97130561Sobrien{ 9899461Sobrien s32 ret_val = E1000_SUCCESS; 9999461Sobrien 10099461Sobrien if (hw->phy.ops.init_params) { 10199461Sobrien ret_val = hw->phy.ops.init_params(hw); 102130561Sobrien if (ret_val) { 10399461Sobrien DEBUGOUT("PHY Initialization Error\n"); 10499461Sobrien goto out; 105130561Sobrien } 10699461Sobrien } else { 107130561Sobrien DEBUGOUT("phy.init_phy_params was NULL\n"); 108130561Sobrien ret_val = -E1000_ERR_CONFIG; 109130561Sobrien } 110130561Sobrien 111130561Sobrienout: 112130561Sobrien return ret_val; 113130561Sobrien} 114130561Sobrien 115130561Sobrien/** 116130561Sobrien * e1000_init_mbx_params - Initialize mailbox function pointers 117130561Sobrien * @hw: pointer to the HW structure 118130561Sobrien * 119130561Sobrien * This function initializes the function pointers for the PHY 120130561Sobrien * set of functions. Called by drivers or by e1000_setup_init_funcs. 121130561Sobrien **/ 122130561Sobriens32 e1000_init_mbx_params(struct e1000_hw *hw) 123130561Sobrien{ 124130561Sobrien s32 ret_val = E1000_SUCCESS; 125130561Sobrien 126130561Sobrien if (hw->mbx.ops.init_params) { 127130561Sobrien ret_val = hw->mbx.ops.init_params(hw); 128130561Sobrien if (ret_val) { 129130561Sobrien DEBUGOUT("Mailbox Initialization Error\n"); 130130561Sobrien goto out; 131130561Sobrien } 132130561Sobrien } else { 133130561Sobrien DEBUGOUT("mbx.init_mbx_params was NULL\n"); 134130561Sobrien ret_val = -E1000_ERR_CONFIG; 135130561Sobrien } 136130561Sobrien 137130561Sobrienout: 138130561Sobrien return ret_val; 139130561Sobrien} 140130561Sobrien 141130561Sobrien/** 142130561Sobrien * e1000_set_mac_type - Sets MAC type 143130561Sobrien * @hw: pointer to the HW structure 144130561Sobrien * 145130561Sobrien * This function sets the mac type of the adapter based on the 146130561Sobrien * device ID stored in the hw structure. 147130561Sobrien * MUST BE FIRST FUNCTION CALLED (explicitly or through 148130561Sobrien * e1000_setup_init_funcs()). 149130561Sobrien **/ 150130561Sobriens32 e1000_set_mac_type(struct e1000_hw *hw) 151130561Sobrien{ 152130561Sobrien struct e1000_mac_info *mac = &hw->mac; 153130561Sobrien s32 ret_val = E1000_SUCCESS; 154130561Sobrien 155130561Sobrien DEBUGFUNC("e1000_set_mac_type"); 156130561Sobrien 157130561Sobrien switch (hw->device_id) { 158130561Sobrien case E1000_DEV_ID_82542: 159130561Sobrien mac->type = e1000_82542; 160130561Sobrien break; 161130561Sobrien case E1000_DEV_ID_82543GC_FIBER: 162130561Sobrien case E1000_DEV_ID_82543GC_COPPER: 163130561Sobrien mac->type = e1000_82543; 164130561Sobrien break; 165130561Sobrien case E1000_DEV_ID_82544EI_COPPER: 166130561Sobrien case E1000_DEV_ID_82544EI_FIBER: 167130561Sobrien case E1000_DEV_ID_82544GC_COPPER: 168130561Sobrien case E1000_DEV_ID_82544GC_LOM: 169130561Sobrien mac->type = e1000_82544; 170130561Sobrien break; 171130561Sobrien case E1000_DEV_ID_82540EM: 172130561Sobrien case E1000_DEV_ID_82540EM_LOM: 173130561Sobrien case E1000_DEV_ID_82540EP: 174130561Sobrien case E1000_DEV_ID_82540EP_LOM: 175130561Sobrien case E1000_DEV_ID_82540EP_LP: 176130561Sobrien mac->type = e1000_82540; 177130561Sobrien break; 178130561Sobrien case E1000_DEV_ID_82545EM_COPPER: 179130561Sobrien case E1000_DEV_ID_82545EM_FIBER: 180130561Sobrien mac->type = e1000_82545; 181130561Sobrien break; 182130561Sobrien case E1000_DEV_ID_82545GM_COPPER: 183130561Sobrien case E1000_DEV_ID_82545GM_FIBER: 184130561Sobrien case E1000_DEV_ID_82545GM_SERDES: 185130561Sobrien mac->type = e1000_82545_rev_3; 186130561Sobrien break; 187130561Sobrien case E1000_DEV_ID_82546EB_COPPER: 188130561Sobrien case E1000_DEV_ID_82546EB_FIBER: 189130561Sobrien case E1000_DEV_ID_82546EB_QUAD_COPPER: 190130561Sobrien mac->type = e1000_82546; 191130561Sobrien break; 192130561Sobrien case E1000_DEV_ID_82546GB_COPPER: 193130561Sobrien case E1000_DEV_ID_82546GB_FIBER: 194130561Sobrien case E1000_DEV_ID_82546GB_SERDES: 195130561Sobrien case E1000_DEV_ID_82546GB_PCIE: 196130561Sobrien case E1000_DEV_ID_82546GB_QUAD_COPPER: 197130561Sobrien case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: 198130561Sobrien mac->type = e1000_82546_rev_3; 199130561Sobrien break; 200130561Sobrien case E1000_DEV_ID_82541EI: 201130561Sobrien case E1000_DEV_ID_82541EI_MOBILE: 202130561Sobrien case E1000_DEV_ID_82541ER_LOM: 203130561Sobrien mac->type = e1000_82541; 204130561Sobrien break; 205130561Sobrien case E1000_DEV_ID_82541ER: 206130561Sobrien case E1000_DEV_ID_82541GI: 207130561Sobrien case E1000_DEV_ID_82541GI_LF: 208130561Sobrien case E1000_DEV_ID_82541GI_MOBILE: 209130561Sobrien mac->type = e1000_82541_rev_2; 210130561Sobrien break; 211130561Sobrien case E1000_DEV_ID_82547EI: 212130561Sobrien case E1000_DEV_ID_82547EI_MOBILE: 213130561Sobrien mac->type = e1000_82547; 21499461Sobrien break; 21599461Sobrien case E1000_DEV_ID_82547GI: 21699461Sobrien mac->type = e1000_82547_rev_2; 21799461Sobrien break; 218130561Sobrien case E1000_DEV_ID_82571EB_COPPER: 21999461Sobrien case E1000_DEV_ID_82571EB_FIBER: 220130561Sobrien case E1000_DEV_ID_82571EB_SERDES: 22199461Sobrien case E1000_DEV_ID_82571EB_SERDES_DUAL: 22299461Sobrien case E1000_DEV_ID_82571EB_SERDES_QUAD: 22399461Sobrien case E1000_DEV_ID_82571EB_QUAD_COPPER: 22499461Sobrien case E1000_DEV_ID_82571PT_QUAD_COPPER: 22599461Sobrien case E1000_DEV_ID_82571EB_QUAD_FIBER: 22699461Sobrien case E1000_DEV_ID_82571EB_QUAD_COPPER_LP: 22799461Sobrien mac->type = e1000_82571; 22899461Sobrien break; 22999461Sobrien case E1000_DEV_ID_82572EI: 23099461Sobrien case E1000_DEV_ID_82572EI_COPPER: 23199461Sobrien case E1000_DEV_ID_82572EI_FIBER: 23299461Sobrien case E1000_DEV_ID_82572EI_SERDES: 23399461Sobrien mac->type = e1000_82572; 23499461Sobrien break; 23599461Sobrien case E1000_DEV_ID_82573E: 23699461Sobrien case E1000_DEV_ID_82573E_IAMT: 23799461Sobrien case E1000_DEV_ID_82573L: 23899461Sobrien mac->type = e1000_82573; 23999461Sobrien break; 24099461Sobrien case E1000_DEV_ID_82574L: 24199461Sobrien case E1000_DEV_ID_82574LA: 24299461Sobrien mac->type = e1000_82574; 24399461Sobrien break; 24499461Sobrien case E1000_DEV_ID_82583V: 24599461Sobrien mac->type = e1000_82583; 24699461Sobrien break; 24799461Sobrien case E1000_DEV_ID_80003ES2LAN_COPPER_DPT: 24899461Sobrien case E1000_DEV_ID_80003ES2LAN_SERDES_DPT: 24999461Sobrien case E1000_DEV_ID_80003ES2LAN_COPPER_SPT: 25099461Sobrien case E1000_DEV_ID_80003ES2LAN_SERDES_SPT: 25199461Sobrien mac->type = e1000_80003es2lan; 25299461Sobrien break; 25399461Sobrien case E1000_DEV_ID_ICH8_IFE: 25499461Sobrien case E1000_DEV_ID_ICH8_IFE_GT: 25599461Sobrien case E1000_DEV_ID_ICH8_IFE_G: 25699461Sobrien case E1000_DEV_ID_ICH8_IGP_M: 25799461Sobrien case E1000_DEV_ID_ICH8_IGP_M_AMT: 258130561Sobrien case E1000_DEV_ID_ICH8_IGP_AMT: 25999461Sobrien case E1000_DEV_ID_ICH8_IGP_C: 26099461Sobrien case E1000_DEV_ID_ICH8_82567V_3: 26199461Sobrien mac->type = e1000_ich8lan; 26299461Sobrien break; 26399461Sobrien case E1000_DEV_ID_ICH9_IFE: 26499461Sobrien case E1000_DEV_ID_ICH9_IFE_GT: 26599461Sobrien case E1000_DEV_ID_ICH9_IFE_G: 26699461Sobrien case E1000_DEV_ID_ICH9_IGP_M: 26799461Sobrien case E1000_DEV_ID_ICH9_IGP_M_AMT: 26899461Sobrien case E1000_DEV_ID_ICH9_IGP_M_V: 26999461Sobrien case E1000_DEV_ID_ICH9_IGP_AMT: 27099461Sobrien case E1000_DEV_ID_ICH9_BM: 27199461Sobrien case E1000_DEV_ID_ICH9_IGP_C: 27299461Sobrien case E1000_DEV_ID_ICH10_R_BM_LM: 27399461Sobrien case E1000_DEV_ID_ICH10_R_BM_LF: 27499461Sobrien case E1000_DEV_ID_ICH10_R_BM_V: 27599461Sobrien mac->type = e1000_ich9lan; 27699461Sobrien break; 277130561Sobrien case E1000_DEV_ID_ICH10_D_BM_LM: 278130561Sobrien case E1000_DEV_ID_ICH10_D_BM_LF: 279130561Sobrien case E1000_DEV_ID_ICH10_D_BM_V: 280130561Sobrien mac->type = e1000_ich10lan; 281130561Sobrien break; 282130561Sobrien case E1000_DEV_ID_PCH_D_HV_DM: 283130561Sobrien case E1000_DEV_ID_PCH_D_HV_DC: 284130561Sobrien case E1000_DEV_ID_PCH_M_HV_LM: 285130561Sobrien case E1000_DEV_ID_PCH_M_HV_LC: 286130561Sobrien mac->type = e1000_pchlan; 287130561Sobrien break; 288130561Sobrien case E1000_DEV_ID_PCH2_LV_LM: 289130561Sobrien case E1000_DEV_ID_PCH2_LV_V: 290130561Sobrien mac->type = e1000_pch2lan; 291130561Sobrien break; 292130561Sobrien case E1000_DEV_ID_PCH_LPT_I217_LM: 293130561Sobrien case E1000_DEV_ID_PCH_LPT_I217_V: 294130561Sobrien case E1000_DEV_ID_PCH_LPTLP_I218_LM: 295130561Sobrien case E1000_DEV_ID_PCH_LPTLP_I218_V: 296130561Sobrien case E1000_DEV_ID_PCH_I218_LM2: 297130561Sobrien case E1000_DEV_ID_PCH_I218_V2: 298130561Sobrien case E1000_DEV_ID_PCH_I218_LM3: 299130561Sobrien case E1000_DEV_ID_PCH_I218_V3: 300130561Sobrien mac->type = e1000_pch_lpt; 301130561Sobrien break; 302130561Sobrien case E1000_DEV_ID_PCH_SPT_I219_LM: 303130561Sobrien case E1000_DEV_ID_PCH_SPT_I219_V: 304130561Sobrien case E1000_DEV_ID_PCH_SPT_I219_LM2: 305130561Sobrien case E1000_DEV_ID_PCH_SPT_I219_V2: 306130561Sobrien case E1000_DEV_ID_PCH_LBG_I219_LM3: 307130561Sobrien case E1000_DEV_ID_PCH_SPT_I219_LM4: 308130561Sobrien case E1000_DEV_ID_PCH_SPT_I219_V4: 309130561Sobrien case E1000_DEV_ID_PCH_SPT_I219_LM5: 310130561Sobrien case E1000_DEV_ID_PCH_SPT_I219_V5: 311130561Sobrien mac->type = e1000_pch_spt; 312130561Sobrien break; 313130561Sobrien case E1000_DEV_ID_PCH_CNP_I219_LM6: 314130561Sobrien case E1000_DEV_ID_PCH_CNP_I219_V6: 315130561Sobrien case E1000_DEV_ID_PCH_CNP_I219_LM7: 316130561Sobrien case E1000_DEV_ID_PCH_CNP_I219_V7: 317130561Sobrien case E1000_DEV_ID_PCH_ICP_I219_LM8: 318130561Sobrien case E1000_DEV_ID_PCH_ICP_I219_V8: 319130561Sobrien case E1000_DEV_ID_PCH_ICP_I219_LM9: 320130561Sobrien case E1000_DEV_ID_PCH_ICP_I219_V9: 321130561Sobrien mac->type = e1000_pch_cnp; 322130561Sobrien break; 323130561Sobrien case E1000_DEV_ID_82575EB_COPPER: 324130561Sobrien case E1000_DEV_ID_82575EB_FIBER_SERDES: 325130561Sobrien case E1000_DEV_ID_82575GB_QUAD_COPPER: 326130561Sobrien mac->type = e1000_82575; 32799461Sobrien break; 32899461Sobrien case E1000_DEV_ID_82576: 32999461Sobrien case E1000_DEV_ID_82576_FIBER: 33099461Sobrien case E1000_DEV_ID_82576_SERDES: 33199461Sobrien case E1000_DEV_ID_82576_QUAD_COPPER: 33299461Sobrien case E1000_DEV_ID_82576_QUAD_COPPER_ET2: 33399461Sobrien case E1000_DEV_ID_82576_NS: 33499461Sobrien case E1000_DEV_ID_82576_NS_SERDES: 33599461Sobrien case E1000_DEV_ID_82576_SERDES_QUAD: 33699461Sobrien mac->type = e1000_82576; 337218822Sdim break; 338218822Sdim case E1000_DEV_ID_82580_COPPER: 339218822Sdim case E1000_DEV_ID_82580_FIBER: 340218822Sdim case E1000_DEV_ID_82580_SERDES: 341218822Sdim case E1000_DEV_ID_82580_SGMII: 342218822Sdim case E1000_DEV_ID_82580_COPPER_DUAL: 343218822Sdim case E1000_DEV_ID_82580_QUAD_FIBER: 344218822Sdim case E1000_DEV_ID_DH89XXCC_SGMII: 345218822Sdim case E1000_DEV_ID_DH89XXCC_SERDES: 346218822Sdim case E1000_DEV_ID_DH89XXCC_BACKPLANE: 347218822Sdim case E1000_DEV_ID_DH89XXCC_SFP: 348218822Sdim mac->type = e1000_82580; 349218822Sdim break; 350218822Sdim case E1000_DEV_ID_I350_COPPER: 351218822Sdim case E1000_DEV_ID_I350_FIBER: 352218822Sdim case E1000_DEV_ID_I350_SERDES: 353218822Sdim case E1000_DEV_ID_I350_SGMII: 354218822Sdim case E1000_DEV_ID_I350_DA4: 355218822Sdim mac->type = e1000_i350; 35699461Sobrien break; 35799461Sobrien case E1000_DEV_ID_I210_COPPER_FLASHLESS: 35899461Sobrien case E1000_DEV_ID_I210_SERDES_FLASHLESS: 35999461Sobrien case E1000_DEV_ID_I210_COPPER: 36099461Sobrien case E1000_DEV_ID_I210_COPPER_OEM1: 36199461Sobrien case E1000_DEV_ID_I210_COPPER_IT: 36299461Sobrien case E1000_DEV_ID_I210_FIBER: 36399461Sobrien case E1000_DEV_ID_I210_SERDES: 36499461Sobrien case E1000_DEV_ID_I210_SGMII: 365218822Sdim mac->type = e1000_i210; 366218822Sdim break; 36799461Sobrien case E1000_DEV_ID_I211_COPPER: 36899461Sobrien mac->type = e1000_i211; 36999461Sobrien break; 37099461Sobrien case E1000_DEV_ID_82576_VF: 37199461Sobrien case E1000_DEV_ID_82576_VF_HV: 37299461Sobrien mac->type = e1000_vfadapt; 37399461Sobrien break; 37499461Sobrien case E1000_DEV_ID_I350_VF: 37599461Sobrien case E1000_DEV_ID_I350_VF_HV: 37699461Sobrien mac->type = e1000_vfadapt_i350; 377218822Sdim break; 378218822Sdim 379218822Sdim case E1000_DEV_ID_I354_BACKPLANE_1GBPS: 380218822Sdim case E1000_DEV_ID_I354_SGMII: 381218822Sdim case E1000_DEV_ID_I354_BACKPLANE_2_5GBPS: 382218822Sdim mac->type = e1000_i354; 383218822Sdim break; 38499461Sobrien default: 38599461Sobrien /* Should never have loaded on this device */ 38699461Sobrien ret_val = -E1000_ERR_MAC_INIT; 387130561Sobrien break; 388130561Sobrien } 389130561Sobrien 390130561Sobrien return ret_val; 391130561Sobrien} 392130561Sobrien 393130561Sobrien/** 394130561Sobrien * e1000_setup_init_funcs - Initializes function pointers 395130561Sobrien * @hw: pointer to the HW structure 396130561Sobrien * @init_device: TRUE will initialize the rest of the function pointers 397130561Sobrien * getting the device ready for use. FALSE will only set 398130561Sobrien * MAC type and the function pointers for the other init 399130561Sobrien * functions. Passing FALSE will not generate any hardware 400130561Sobrien * reads or writes. 401130561Sobrien * 402130561Sobrien * This function must be called by a driver in order to use the rest 403130561Sobrien * of the 'shared' code files. Called by drivers only. 404130561Sobrien **/ 405130561Sobriens32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device) 406130561Sobrien{ 407130561Sobrien s32 ret_val; 408130561Sobrien 409130561Sobrien /* Can't do much good without knowing the MAC type. */ 410130561Sobrien ret_val = e1000_set_mac_type(hw); 411130561Sobrien if (ret_val) { 412130561Sobrien DEBUGOUT("ERROR: MAC type could not be set properly.\n"); 413130561Sobrien goto out; 414130561Sobrien } 415130561Sobrien 416130561Sobrien if (!hw->hw_addr) { 417130561Sobrien DEBUGOUT("ERROR: Registers not mapped\n"); 418130561Sobrien ret_val = -E1000_ERR_CONFIG; 419130561Sobrien goto out; 420130561Sobrien } 421130561Sobrien 422130561Sobrien /* 423130561Sobrien * Init function pointers to generic implementations. We do this first 424130561Sobrien * allowing a driver module to override it afterward. 425130561Sobrien */ 426130561Sobrien e1000_init_mac_ops_generic(hw); 427130561Sobrien e1000_init_phy_ops_generic(hw); 428130561Sobrien e1000_init_nvm_ops_generic(hw); 429130561Sobrien e1000_init_mbx_ops_generic(hw); 430130561Sobrien 431130561Sobrien /* 432218822Sdim * Set up the init function pointers. These are functions within the 433130561Sobrien * adapter family file that sets up function pointers for the rest of 434130561Sobrien * the functions in that family. 435130561Sobrien */ 436130561Sobrien switch (hw->mac.type) { 437130561Sobrien case e1000_82542: 438130561Sobrien e1000_init_function_pointers_82542(hw); 439130561Sobrien break; 440130561Sobrien case e1000_82543: 441130561Sobrien case e1000_82544: 442130561Sobrien e1000_init_function_pointers_82543(hw); 443130561Sobrien break; 444130561Sobrien case e1000_82540: 445130561Sobrien case e1000_82545: 446130561Sobrien case e1000_82545_rev_3: 447130561Sobrien case e1000_82546: 448130561Sobrien case e1000_82546_rev_3: 449130561Sobrien e1000_init_function_pointers_82540(hw); 450130561Sobrien break; 451130561Sobrien case e1000_82541: 452130561Sobrien case e1000_82541_rev_2: 453130561Sobrien case e1000_82547: 454130561Sobrien case e1000_82547_rev_2: 455130561Sobrien e1000_init_function_pointers_82541(hw); 456130561Sobrien break; 457130561Sobrien case e1000_82571: 45899461Sobrien case e1000_82572: 45999461Sobrien case e1000_82573: 46099461Sobrien case e1000_82574: 46199461Sobrien case e1000_82583: 46299461Sobrien e1000_init_function_pointers_82571(hw); 463130561Sobrien break; 46499461Sobrien case e1000_80003es2lan: 46599461Sobrien e1000_init_function_pointers_80003es2lan(hw); 46699461Sobrien break; 46799461Sobrien case e1000_ich8lan: 46899461Sobrien case e1000_ich9lan: 46999461Sobrien case e1000_ich10lan: 47099461Sobrien case e1000_pchlan: 47199461Sobrien case e1000_pch2lan: 47299461Sobrien case e1000_pch_lpt: 47399461Sobrien case e1000_pch_spt: 47499461Sobrien case e1000_pch_cnp: 475130561Sobrien e1000_init_function_pointers_ich8lan(hw); 476130561Sobrien break; 477130561Sobrien case e1000_82575: 478130561Sobrien case e1000_82576: 479130561Sobrien case e1000_82580: 480130561Sobrien case e1000_i350: 48199461Sobrien case e1000_i354: 48299461Sobrien e1000_init_function_pointers_82575(hw); 48399461Sobrien break; 48499461Sobrien case e1000_i210: 48599461Sobrien case e1000_i211: 48699461Sobrien e1000_init_function_pointers_i210(hw); 48799461Sobrien break; 48899461Sobrien case e1000_vfadapt: 48999461Sobrien e1000_init_function_pointers_vf(hw); 49099461Sobrien break; 49199461Sobrien case e1000_vfadapt_i350: 49299461Sobrien e1000_init_function_pointers_vf(hw); 49399461Sobrien break; 49499461Sobrien default: 49599461Sobrien DEBUGOUT("Hardware not supported\n"); 49699461Sobrien ret_val = -E1000_ERR_CONFIG; 49799461Sobrien break; 49899461Sobrien } 49999461Sobrien 50099461Sobrien /* 50199461Sobrien * Initialize the rest of the function pointers. These require some 50299461Sobrien * register reads/writes in some cases. 50399461Sobrien */ 50499461Sobrien if (!(ret_val) && init_device) { 505130561Sobrien ret_val = e1000_init_mac_params(hw); 50699461Sobrien if (ret_val) 50799461Sobrien goto out; 50899461Sobrien 50999461Sobrien ret_val = e1000_init_nvm_params(hw); 51099461Sobrien if (ret_val) 51199461Sobrien goto out; 51299461Sobrien 51399461Sobrien ret_val = e1000_init_phy_params(hw); 51499461Sobrien if (ret_val) 51599461Sobrien goto out; 51699461Sobrien 51799461Sobrien ret_val = e1000_init_mbx_params(hw); 51899461Sobrien if (ret_val) 51999461Sobrien goto out; 52099461Sobrien } 52199461Sobrien 52299461Sobrienout: 52399461Sobrien return ret_val; 52499461Sobrien} 52599461Sobrien 52699461Sobrien/** 52799461Sobrien * e1000_get_bus_info - Obtain bus information for adapter 52899461Sobrien * @hw: pointer to the HW structure 52999461Sobrien * 53099461Sobrien * This will obtain information about the HW bus for which the 53199461Sobrien * adapter is attached and stores it in the hw structure. This is a 53299461Sobrien * function pointer entry point called by drivers. 53399461Sobrien **/ 53499461Sobriens32 e1000_get_bus_info(struct e1000_hw *hw) 53599461Sobrien{ 53699461Sobrien if (hw->mac.ops.get_bus_info) 53799461Sobrien return hw->mac.ops.get_bus_info(hw); 53899461Sobrien 53999461Sobrien return E1000_SUCCESS; 54099461Sobrien} 54199461Sobrien 54299461Sobrien/** 54399461Sobrien * e1000_clear_vfta - Clear VLAN filter table 54499461Sobrien * @hw: pointer to the HW structure 54599461Sobrien * 54699461Sobrien * This clears the VLAN filter table on the adapter. This is a function 54799461Sobrien * pointer entry point called by drivers. 54899461Sobrien **/ 54999461Sobrienvoid e1000_clear_vfta(struct e1000_hw *hw) 55099461Sobrien{ 55199461Sobrien if (hw->mac.ops.clear_vfta) 55299461Sobrien hw->mac.ops.clear_vfta(hw); 55399461Sobrien} 55499461Sobrien 55599461Sobrien/** 55699461Sobrien * e1000_write_vfta - Write value to VLAN filter table 55799461Sobrien * @hw: pointer to the HW structure 55899461Sobrien * @offset: the 32-bit offset in which to write the value to. 55999461Sobrien * @value: the 32-bit value to write at location offset. 56099461Sobrien * 56199461Sobrien * This writes a 32-bit value to a 32-bit offset in the VLAN filter 56299461Sobrien * table. This is a function pointer entry point called by drivers. 56399461Sobrien **/ 56499461Sobrienvoid e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value) 56599461Sobrien{ 56699461Sobrien if (hw->mac.ops.write_vfta) 56799461Sobrien hw->mac.ops.write_vfta(hw, offset, value); 56899461Sobrien} 56999461Sobrien 57099461Sobrien/** 57199461Sobrien * e1000_update_mc_addr_list - Update Multicast addresses 57299461Sobrien * @hw: pointer to the HW structure 57399461Sobrien * @mc_addr_list: array of multicast addresses to program 57499461Sobrien * @mc_addr_count: number of multicast addresses to program 57599461Sobrien * 57699461Sobrien * Updates the Multicast Table Array. 57799461Sobrien * The caller must have a packed mc_addr_list of multicast addresses. 57899461Sobrien **/ 57999461Sobrienvoid e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list, 58099461Sobrien u32 mc_addr_count) 58199461Sobrien{ 58299461Sobrien if (hw->mac.ops.update_mc_addr_list) 58399461Sobrien hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, 58499461Sobrien mc_addr_count); 58599461Sobrien} 58699461Sobrien 58799461Sobrien/** 58899461Sobrien * e1000_force_mac_fc - Force MAC flow control 58999461Sobrien * @hw: pointer to the HW structure 59099461Sobrien * 59199461Sobrien * Force the MAC's flow control settings. Currently no func pointer exists 59299461Sobrien * and all implementations are handled in the generic version of this 59399461Sobrien * function. 59499461Sobrien **/ 59599461Sobriens32 e1000_force_mac_fc(struct e1000_hw *hw) 59699461Sobrien{ 59799461Sobrien return e1000_force_mac_fc_generic(hw); 59899461Sobrien} 59999461Sobrien 60099461Sobrien/** 60199461Sobrien * e1000_check_for_link - Check/Store link connection 60299461Sobrien * @hw: pointer to the HW structure 60399461Sobrien * 60499461Sobrien * This checks the link condition of the adapter and stores the 60599461Sobrien * results in the hw->mac structure. This is a function pointer entry 60699461Sobrien * point called by drivers. 60799461Sobrien **/ 60899461Sobriens32 e1000_check_for_link(struct e1000_hw *hw) 60999461Sobrien{ 61099461Sobrien if (hw->mac.ops.check_for_link) 61199461Sobrien return hw->mac.ops.check_for_link(hw); 61299461Sobrien 61399461Sobrien return -E1000_ERR_CONFIG; 61499461Sobrien} 61599461Sobrien 61699461Sobrien/** 61799461Sobrien * e1000_check_mng_mode - Check management mode 61899461Sobrien * @hw: pointer to the HW structure 61999461Sobrien * 62099461Sobrien * This checks if the adapter has manageability enabled. 62199461Sobrien * This is a function pointer entry point called by drivers. 62299461Sobrien **/ 62399461Sobrienbool e1000_check_mng_mode(struct e1000_hw *hw) 62499461Sobrien{ 62599461Sobrien if (hw->mac.ops.check_mng_mode) 62699461Sobrien return hw->mac.ops.check_mng_mode(hw); 62799461Sobrien 62899461Sobrien return FALSE; 62999461Sobrien} 63099461Sobrien 63199461Sobrien/** 63299461Sobrien * e1000_mng_write_dhcp_info - Writes DHCP info to host interface 63399461Sobrien * @hw: pointer to the HW structure 63499461Sobrien * @buffer: pointer to the host interface 63599461Sobrien * @length: size of the buffer 63699461Sobrien * 63799461Sobrien * Writes the DHCP information to the host interface. 63899461Sobrien **/ 63999461Sobriens32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length) 64099461Sobrien{ 64199461Sobrien return e1000_mng_write_dhcp_info_generic(hw, buffer, length); 64299461Sobrien} 64399461Sobrien 64499461Sobrien/** 64599461Sobrien * e1000_reset_hw - Reset hardware 64699461Sobrien * @hw: pointer to the HW structure 64799461Sobrien * 64899461Sobrien * This resets the hardware into a known state. This is a function pointer 64999461Sobrien * entry point called by drivers. 65099461Sobrien **/ 65199461Sobriens32 e1000_reset_hw(struct e1000_hw *hw) 65299461Sobrien{ 65399461Sobrien if (hw->mac.ops.reset_hw) 65499461Sobrien return hw->mac.ops.reset_hw(hw); 65599461Sobrien 65699461Sobrien return -E1000_ERR_CONFIG; 65799461Sobrien} 65899461Sobrien 65999461Sobrien/** 66099461Sobrien * e1000_init_hw - Initialize hardware 66199461Sobrien * @hw: pointer to the HW structure 662130561Sobrien * 663130561Sobrien * This inits the hardware readying it for operation. This is a function 664130561Sobrien * pointer entry point called by drivers. 665130561Sobrien **/ 666130561Sobriens32 e1000_init_hw(struct e1000_hw *hw) 667130561Sobrien{ 668130561Sobrien if (hw->mac.ops.init_hw) 669130561Sobrien return hw->mac.ops.init_hw(hw); 670130561Sobrien 671130561Sobrien return -E1000_ERR_CONFIG; 67299461Sobrien} 67399461Sobrien 674130561Sobrien/** 675130561Sobrien * e1000_setup_link - Configures link and flow control 676130561Sobrien * @hw: pointer to the HW structure 677130561Sobrien * 678130561Sobrien * This configures link and flow control settings for the adapter. This 679130561Sobrien * is a function pointer entry point called by drivers. While modules can 680130561Sobrien * also call this, they probably call their own version of this function. 681130561Sobrien **/ 682130561Sobriens32 e1000_setup_link(struct e1000_hw *hw) 683130561Sobrien{ 684130561Sobrien if (hw->mac.ops.setup_link) 685130561Sobrien return hw->mac.ops.setup_link(hw); 686130561Sobrien 687130561Sobrien return -E1000_ERR_CONFIG; 688130561Sobrien} 689130561Sobrien 690130561Sobrien/** 691130561Sobrien * e1000_get_speed_and_duplex - Returns current speed and duplex 692218822Sdim * @hw: pointer to the HW structure 693130561Sobrien * @speed: pointer to a 16-bit value to store the speed 694130561Sobrien * @duplex: pointer to a 16-bit value to store the duplex. 695218822Sdim * 696218822Sdim * This returns the speed and duplex of the adapter in the two 'out' 697218822Sdim * variables passed in. This is a function pointer entry point called 698218822Sdim * by drivers. 699218822Sdim **/ 700218822Sdims32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex) 701218822Sdim{ 702130561Sobrien if (hw->mac.ops.get_link_up_info) 703130561Sobrien return hw->mac.ops.get_link_up_info(hw, speed, duplex); 704130561Sobrien 705130561Sobrien return -E1000_ERR_CONFIG; 706130561Sobrien} 707130561Sobrien 708130561Sobrien/** 709130561Sobrien * e1000_setup_led - Configures SW controllable LED 710130561Sobrien * @hw: pointer to the HW structure 711130561Sobrien * 71299461Sobrien * This prepares the SW controllable LED for use and saves the current state 71399461Sobrien * of the LED so it can be later restored. This is a function pointer entry 71499461Sobrien * point called by drivers. 71599461Sobrien **/ 71699461Sobriens32 e1000_setup_led(struct e1000_hw *hw) 71799461Sobrien{ 71899461Sobrien if (hw->mac.ops.setup_led) 71999461Sobrien return hw->mac.ops.setup_led(hw); 72099461Sobrien 72199461Sobrien return E1000_SUCCESS; 72299461Sobrien} 72399461Sobrien 72499461Sobrien/** 72599461Sobrien * e1000_cleanup_led - Restores SW controllable LED 72699461Sobrien * @hw: pointer to the HW structure 727130561Sobrien * 728130561Sobrien * This restores the SW controllable LED to the value saved off by 729130561Sobrien * e1000_setup_led. This is a function pointer entry point called by drivers. 730130561Sobrien **/ 731130561Sobriens32 e1000_cleanup_led(struct e1000_hw *hw) 73299461Sobrien{ 73399461Sobrien if (hw->mac.ops.cleanup_led) 73499461Sobrien return hw->mac.ops.cleanup_led(hw); 73599461Sobrien 73699461Sobrien return E1000_SUCCESS; 73799461Sobrien} 73899461Sobrien 73999461Sobrien/** 74099461Sobrien * e1000_blink_led - Blink SW controllable LED 74199461Sobrien * @hw: pointer to the HW structure 74299461Sobrien * 74399461Sobrien * This starts the adapter LED blinking. Request the LED to be setup first 74499461Sobrien * and cleaned up after. This is a function pointer entry point called by 74599461Sobrien * drivers. 74699461Sobrien **/ 74799461Sobriens32 e1000_blink_led(struct e1000_hw *hw) 74899461Sobrien{ 74999461Sobrien if (hw->mac.ops.blink_led) 75099461Sobrien return hw->mac.ops.blink_led(hw); 75199461Sobrien 75299461Sobrien return E1000_SUCCESS; 75399461Sobrien} 75499461Sobrien 75599461Sobrien/** 75699461Sobrien * e1000_id_led_init - store LED configurations in SW 75799461Sobrien * @hw: pointer to the HW structure 75899461Sobrien * 75999461Sobrien * Initializes the LED config in SW. This is a function pointer entry point 76099461Sobrien * called by drivers. 76199461Sobrien **/ 76299461Sobriens32 e1000_id_led_init(struct e1000_hw *hw) 76399461Sobrien{ 76499461Sobrien if (hw->mac.ops.id_led_init) 76599461Sobrien return hw->mac.ops.id_led_init(hw); 76699461Sobrien 767130561Sobrien return E1000_SUCCESS; 768130561Sobrien} 76999461Sobrien 77099461Sobrien/** 77199461Sobrien * e1000_led_on - Turn on SW controllable LED 77299461Sobrien * @hw: pointer to the HW structure 77399461Sobrien * 77499461Sobrien * Turns the SW defined LED on. This is a function pointer entry point 77599461Sobrien * called by drivers. 77699461Sobrien **/ 77799461Sobriens32 e1000_led_on(struct e1000_hw *hw) 77899461Sobrien{ 77999461Sobrien if (hw->mac.ops.led_on) 78099461Sobrien return hw->mac.ops.led_on(hw); 78199461Sobrien 78299461Sobrien return E1000_SUCCESS; 783107492Sobrien} 78499461Sobrien 78599461Sobrien/** 78699461Sobrien * e1000_led_off - Turn off SW controllable LED 787218822Sdim * @hw: pointer to the HW structure 788218822Sdim * 78999461Sobrien * Turns the SW defined LED off. This is a function pointer entry point 790107492Sobrien * called by drivers. 79199461Sobrien **/ 79299461Sobriens32 e1000_led_off(struct e1000_hw *hw) 79399461Sobrien{ 79499461Sobrien if (hw->mac.ops.led_off) 79599461Sobrien return hw->mac.ops.led_off(hw); 79699461Sobrien 79799461Sobrien return E1000_SUCCESS; 79899461Sobrien} 79999461Sobrien 80099461Sobrien/** 801130561Sobrien * e1000_reset_adaptive - Reset adaptive IFS 80299461Sobrien * @hw: pointer to the HW structure 80399461Sobrien * 80499461Sobrien * Resets the adaptive IFS. Currently no func pointer exists and all 80599461Sobrien * implementations are handled in the generic version of this function. 80699461Sobrien **/ 80799461Sobrienvoid e1000_reset_adaptive(struct e1000_hw *hw) 80899461Sobrien{ 80999461Sobrien e1000_reset_adaptive_generic(hw); 810130561Sobrien} 81199461Sobrien 81299461Sobrien/** 81399461Sobrien * e1000_update_adaptive - Update adaptive IFS 81499461Sobrien * @hw: pointer to the HW structure 81599461Sobrien * 81699461Sobrien * Updates adapter IFS. Currently no func pointer exists and all 81799461Sobrien * implementations are handled in the generic version of this function. 818130561Sobrien **/ 81999461Sobrienvoid e1000_update_adaptive(struct e1000_hw *hw) 82099461Sobrien{ 82199461Sobrien e1000_update_adaptive_generic(hw); 82299461Sobrien} 82399461Sobrien 82499461Sobrien/** 82599461Sobrien * e1000_disable_pcie_master - Disable PCI-Express master access 826218822Sdim * @hw: pointer to the HW structure 827218822Sdim * 828218822Sdim * Disables PCI-Express master access and verifies there are no pending 829218822Sdim * requests. Currently no func pointer exists and all implementations are 830218822Sdim * handled in the generic version of this function. 831218822Sdim **/ 83299461Sobriens32 e1000_disable_pcie_master(struct e1000_hw *hw) 83399461Sobrien{ 834130561Sobrien return e1000_disable_pcie_master_generic(hw); 835130561Sobrien} 83699461Sobrien 83799461Sobrien/** 83899461Sobrien * e1000_config_collision_dist - Configure collision distance 83999461Sobrien * @hw: pointer to the HW structure 84099461Sobrien * 84199461Sobrien * Configures the collision distance to the default value and is used 842130561Sobrien * during link setup. 84399461Sobrien **/ 84499461Sobrienvoid e1000_config_collision_dist(struct e1000_hw *hw) 84599461Sobrien{ 84699461Sobrien if (hw->mac.ops.config_collision_dist) 84799461Sobrien hw->mac.ops.config_collision_dist(hw); 84899461Sobrien} 84999461Sobrien 85099461Sobrien/** 851130561Sobrien * e1000_rar_set - Sets a receive address register 85299461Sobrien * @hw: pointer to the HW structure 85399461Sobrien * @addr: address to set the RAR to 854130561Sobrien * @index: the RAR to set 85599461Sobrien * 85699461Sobrien * Sets a Receive Address Register (RAR) to the specified address. 85799461Sobrien **/ 85899461Sobrienint e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index) 85999461Sobrien{ 86099461Sobrien if (hw->mac.ops.rar_set) 86199461Sobrien return hw->mac.ops.rar_set(hw, addr, index); 86299461Sobrien 86399461Sobrien return E1000_SUCCESS; 86499461Sobrien} 86599461Sobrien 866130561Sobrien/** 86799461Sobrien * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state 86899461Sobrien * @hw: pointer to the HW structure 86999461Sobrien * 87099461Sobrien * Ensures that the MDI/MDIX SW state is valid. 87199461Sobrien **/ 872218822Sdims32 e1000_validate_mdi_setting(struct e1000_hw *hw) 873218822Sdim{ 87499461Sobrien if (hw->mac.ops.validate_mdi_setting) 87599461Sobrien return hw->mac.ops.validate_mdi_setting(hw); 87699461Sobrien 87799461Sobrien return E1000_SUCCESS; 87899461Sobrien} 87999461Sobrien 88099461Sobrien/** 88199461Sobrien * e1000_hash_mc_addr - Determines address location in multicast table 88299461Sobrien * @hw: pointer to the HW structure 88399461Sobrien * @mc_addr: Multicast address to hash. 88499461Sobrien * 88599461Sobrien * This hashes an address to determine its location in the multicast 88699461Sobrien * table. Currently no func pointer exists and all implementations 88799461Sobrien * are handled in the generic version of this function. 888218822Sdim **/ 88999461Sobrienu32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) 89099461Sobrien{ 89199461Sobrien return e1000_hash_mc_addr_generic(hw, mc_addr); 89299461Sobrien} 89399461Sobrien 89499461Sobrien/** 89599461Sobrien * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX 89699461Sobrien * @hw: pointer to the HW structure 89799461Sobrien * 89899461Sobrien * Enables packet filtering on transmit packets if manageability is enabled 89999461Sobrien * and host interface is enabled. 90099461Sobrien * Currently no func pointer exists and all implementations are handled in the 90199461Sobrien * generic version of this function. 90299461Sobrien **/ 90399461Sobrienbool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw) 90499461Sobrien{ 90599461Sobrien return e1000_enable_tx_pkt_filtering_generic(hw); 90699461Sobrien} 90799461Sobrien 90899461Sobrien/** 90999461Sobrien * e1000_mng_host_if_write - Writes to the manageability host interface 91099461Sobrien * @hw: pointer to the HW structure 91199461Sobrien * @buffer: pointer to the host interface buffer 912130561Sobrien * @length: size of the buffer 913130561Sobrien * @offset: location in the buffer to write to 914130561Sobrien * @sum: sum of the data (not checksum) 915130561Sobrien * 916130561Sobrien * This function writes the buffer content at the offset given on the host if. 917130561Sobrien * It also does alignment considerations to do the writes in most efficient 918130561Sobrien * way. Also fills up the sum of the buffer in *buffer parameter. 919130561Sobrien **/ 920130561Sobriens32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length, 921218822Sdim u16 offset, u8 *sum) 922218822Sdim{ 923218822Sdim return e1000_mng_host_if_write_generic(hw, buffer, length, offset, sum); 924218822Sdim} 925218822Sdim 926218822Sdim/** 927218822Sdim * e1000_mng_write_cmd_header - Writes manageability command header 928218822Sdim * @hw: pointer to the HW structure 929218822Sdim * @hdr: pointer to the host interface command header 930218822Sdim * 931130561Sobrien * Writes the command header after does the checksum calculation. 932218822Sdim **/ 93399461Sobriens32 e1000_mng_write_cmd_header(struct e1000_hw *hw, 93499461Sobrien struct e1000_host_mng_command_header *hdr) 935130561Sobrien{ 936130561Sobrien return e1000_mng_write_cmd_header_generic(hw, hdr); 937130561Sobrien} 938130561Sobrien 939130561Sobrien/** 940130561Sobrien * e1000_mng_enable_host_if - Checks host interface is enabled 941130561Sobrien * @hw: pointer to the HW structure 942130561Sobrien * 943130561Sobrien * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND 944130561Sobrien * 945130561Sobrien * This function checks whether the HOST IF is enabled for command operation 946130561Sobrien * and also checks whether the previous command is completed. It busy waits 947130561Sobrien * in case of previous command is not completed. 948130561Sobrien **/ 949130561Sobriens32 e1000_mng_enable_host_if(struct e1000_hw *hw) 950130561Sobrien{ 951130561Sobrien return e1000_mng_enable_host_if_generic(hw); 952130561Sobrien} 953130561Sobrien 954130561Sobrien/** 955130561Sobrien * e1000_set_obff_timer - Set Optimized Buffer Flush/Fill timer 956130561Sobrien * @hw: pointer to the HW structure 957130561Sobrien * @itr: u32 indicating itr value 958130561Sobrien * 959130561Sobrien * Set the OBFF timer based on the given interrupt rate. 960130561Sobrien **/ 961130561Sobriens32 e1000_set_obff_timer(struct e1000_hw *hw, u32 itr) 96299461Sobrien{ 96399461Sobrien if (hw->mac.ops.set_obff_timer) 96499461Sobrien return hw->mac.ops.set_obff_timer(hw, itr); 96599461Sobrien 966130561Sobrien return E1000_SUCCESS; 96799461Sobrien} 96899461Sobrien 96999461Sobrien/** 97099461Sobrien * e1000_check_reset_block - Verifies PHY can be reset 97199461Sobrien * @hw: pointer to the HW structure 97299461Sobrien * 97399461Sobrien * Checks if the PHY is in a state that can be reset or if manageability 97499461Sobrien * has it tied up. This is a function pointer entry point called by drivers. 97599461Sobrien **/ 97699461Sobriens32 e1000_check_reset_block(struct e1000_hw *hw) 97799461Sobrien{ 97899461Sobrien if (hw->phy.ops.check_reset_block) 979130561Sobrien return hw->phy.ops.check_reset_block(hw); 980130561Sobrien 98199461Sobrien return E1000_SUCCESS; 982130561Sobrien} 983130561Sobrien 98499461Sobrien/** 98599461Sobrien * e1000_read_phy_reg - Reads PHY register 98699461Sobrien * @hw: pointer to the HW structure 98799461Sobrien * @offset: the register to read 988130561Sobrien * @data: the buffer to store the 16-bit read. 98999461Sobrien * 99099461Sobrien * Reads the PHY register and returns the value in data. 99199461Sobrien * This is a function pointer entry point called by drivers. 99299461Sobrien **/ 99399461Sobriens32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data) 99499461Sobrien{ 995130561Sobrien if (hw->phy.ops.read_reg) 99699461Sobrien return hw->phy.ops.read_reg(hw, offset, data); 99799461Sobrien 99899461Sobrien return E1000_SUCCESS; 99999461Sobrien} 100099461Sobrien 100199461Sobrien/** 100299461Sobrien * e1000_write_phy_reg - Writes PHY register 1003218822Sdim * @hw: pointer to the HW structure 1004218822Sdim * @offset: the register to write 1005130561Sobrien * @data: the value to write. 100699461Sobrien * 100799461Sobrien * Writes the PHY register at offset with the value in data. 100899461Sobrien * This is a function pointer entry point called by drivers. 100999461Sobrien **/ 101099461Sobriens32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data) 1011218822Sdim{ 1012218822Sdim if (hw->phy.ops.write_reg) 1013218822Sdim return hw->phy.ops.write_reg(hw, offset, data); 1014218822Sdim 1015218822Sdim return E1000_SUCCESS; 1016218822Sdim} 101799461Sobrien 1018130561Sobrien/** 1019130561Sobrien * e1000_release_phy - Generic release PHY 1020130561Sobrien * @hw: pointer to the HW structure 1021130561Sobrien * 1022130561Sobrien * Return if silicon family does not require a semaphore when accessing the 1023130561Sobrien * PHY. 102499461Sobrien **/ 102599461Sobrienvoid e1000_release_phy(struct e1000_hw *hw) 1026130561Sobrien{ 1027130561Sobrien if (hw->phy.ops.release) 102899461Sobrien hw->phy.ops.release(hw); 102999461Sobrien} 1030130561Sobrien 1031130561Sobrien/** 1032130561Sobrien * e1000_acquire_phy - Generic acquire PHY 1033130561Sobrien * @hw: pointer to the HW structure 1034130561Sobrien * 1035130561Sobrien * Return success if silicon family does not require a semaphore when 1036130561Sobrien * accessing the PHY. 1037130561Sobrien **/ 1038130561Sobriens32 e1000_acquire_phy(struct e1000_hw *hw) 1039130561Sobrien{ 1040130561Sobrien if (hw->phy.ops.acquire) 1041130561Sobrien return hw->phy.ops.acquire(hw); 1042130561Sobrien 1043130561Sobrien return E1000_SUCCESS; 104499461Sobrien} 1045130561Sobrien 104699461Sobrien/** 1047130561Sobrien * e1000_cfg_on_link_up - Configure PHY upon link up 1048130561Sobrien * @hw: pointer to the HW structure 1049130561Sobrien **/ 1050130561Sobriens32 e1000_cfg_on_link_up(struct e1000_hw *hw) 105199461Sobrien{ 1052130561Sobrien if (hw->phy.ops.cfg_on_link_up) 1053130561Sobrien return hw->phy.ops.cfg_on_link_up(hw); 1054130561Sobrien 1055130561Sobrien return E1000_SUCCESS; 105699461Sobrien} 1057130561Sobrien 1058130561Sobrien/** 1059130561Sobrien * e1000_read_kmrn_reg - Reads register using Kumeran interface 106099461Sobrien * @hw: pointer to the HW structure 106199461Sobrien * @offset: the register to read 106299461Sobrien * @data: the location to store the 16-bit value read. 106399461Sobrien * 106499461Sobrien * Reads a register out of the Kumeran interface. Currently no func pointer 106599461Sobrien * exists and all implementations are handled in the generic version of 106699461Sobrien * this function. 1067130561Sobrien **/ 106899461Sobriens32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data) 1069130561Sobrien{ 1070130561Sobrien return e1000_read_kmrn_reg_generic(hw, offset, data); 1071130561Sobrien} 1072130561Sobrien 1073130561Sobrien/** 1074130561Sobrien * e1000_write_kmrn_reg - Writes register using Kumeran interface 1075130561Sobrien * @hw: pointer to the HW structure 1076130561Sobrien * @offset: the register to write 1077130561Sobrien * @data: the value to write. 107899461Sobrien * 107999461Sobrien * Writes a register to the Kumeran interface. Currently no func pointer 1080130561Sobrien * exists and all implementations are handled in the generic version of 1081130561Sobrien * this function. 108299461Sobrien **/ 1083130561Sobriens32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data) 1084130561Sobrien{ 108599461Sobrien return e1000_write_kmrn_reg_generic(hw, offset, data); 1086130561Sobrien} 1087130561Sobrien 1088130561Sobrien/** 1089130561Sobrien * e1000_get_cable_length - Retrieves cable length estimation 1090130561Sobrien * @hw: pointer to the HW structure 109199461Sobrien * 109299461Sobrien * This function estimates the cable length and stores them in 1093130561Sobrien * hw->phy.min_length and hw->phy.max_length. This is a function pointer 1094130561Sobrien * entry point called by drivers. 1095130561Sobrien **/ 1096218822Sdims32 e1000_get_cable_length(struct e1000_hw *hw) 1097130561Sobrien{ 1098130561Sobrien if (hw->phy.ops.get_cable_length) 1099130561Sobrien return hw->phy.ops.get_cable_length(hw); 110099461Sobrien 1101130561Sobrien return E1000_SUCCESS; 1102130561Sobrien} 1103130561Sobrien 1104130561Sobrien/** 1105130561Sobrien * e1000_get_phy_info - Retrieves PHY information from registers 1106130561Sobrien * @hw: pointer to the HW structure 1107130561Sobrien * 1108130561Sobrien * This function gets some information from various PHY registers and 1109130561Sobrien * populates hw->phy values with it. This is a function pointer entry 1110130561Sobrien * point called by drivers. 1111130561Sobrien **/ 1112130561Sobriens32 e1000_get_phy_info(struct e1000_hw *hw) 1113130561Sobrien{ 1114130561Sobrien if (hw->phy.ops.get_info) 1115130561Sobrien return hw->phy.ops.get_info(hw); 1116130561Sobrien 1117218822Sdim return E1000_SUCCESS; 1118130561Sobrien} 1119130561Sobrien 1120130561Sobrien/** 1121130561Sobrien * e1000_phy_hw_reset - Hard PHY reset 112299461Sobrien * @hw: pointer to the HW structure 112399461Sobrien * 1124130561Sobrien * Performs a hard PHY reset. This is a function pointer entry point called 1125130561Sobrien * by drivers. 1126130561Sobrien **/ 1127130561Sobriens32 e1000_phy_hw_reset(struct e1000_hw *hw) 1128130561Sobrien{ 1129130561Sobrien if (hw->phy.ops.reset) 1130130561Sobrien return hw->phy.ops.reset(hw); 1131130561Sobrien 1132130561Sobrien return E1000_SUCCESS; 1133130561Sobrien} 1134130561Sobrien 1135130561Sobrien/** 1136130561Sobrien * e1000_phy_commit - Soft PHY reset 1137130561Sobrien * @hw: pointer to the HW structure 1138130561Sobrien * 1139130561Sobrien * Performs a soft PHY reset on those that apply. This is a function pointer 1140130561Sobrien * entry point called by drivers. 1141130561Sobrien **/ 1142130561Sobriens32 e1000_phy_commit(struct e1000_hw *hw) 1143130561Sobrien{ 1144130561Sobrien if (hw->phy.ops.commit) 1145130561Sobrien return hw->phy.ops.commit(hw); 1146130561Sobrien 1147130561Sobrien return E1000_SUCCESS; 1148130561Sobrien} 1149130561Sobrien 1150130561Sobrien/** 1151130561Sobrien * e1000_set_d0_lplu_state - Sets low power link up state for D0 1152130561Sobrien * @hw: pointer to the HW structure 1153130561Sobrien * @active: boolean used to enable/disable lplu 1154130561Sobrien * 1155130561Sobrien * Success returns 0, Failure returns 1 1156130561Sobrien * 1157130561Sobrien * The low power link up (lplu) state is set to the power management level D0 1158130561Sobrien * and SmartSpeed is disabled when active is TRUE, else clear lplu for D0 1159130561Sobrien * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU 1160130561Sobrien * is used during Dx states where the power conservation is most important. 1161130561Sobrien * During driver activity, SmartSpeed should be enabled so performance is 1162130561Sobrien * maintained. This is a function pointer entry point called by drivers. 1163130561Sobrien **/ 1164130561Sobriens32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active) 1165130561Sobrien{ 1166130561Sobrien if (hw->phy.ops.set_d0_lplu_state) 1167130561Sobrien return hw->phy.ops.set_d0_lplu_state(hw, active); 1168130561Sobrien 1169130561Sobrien return E1000_SUCCESS; 1170130561Sobrien} 1171130561Sobrien 1172130561Sobrien/** 1173130561Sobrien * e1000_set_d3_lplu_state - Sets low power link up state for D3 1174130561Sobrien * @hw: pointer to the HW structure 1175130561Sobrien * @active: boolean used to enable/disable lplu 1176130561Sobrien * 1177130561Sobrien * Success returns 0, Failure returns 1 1178130561Sobrien * 1179130561Sobrien * The low power link up (lplu) state is set to the power management level D3 1180130561Sobrien * and SmartSpeed is disabled when active is TRUE, else clear lplu for D3 1181130561Sobrien * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU 1182130561Sobrien * is used during Dx states where the power conservation is most important. 1183130561Sobrien * During driver activity, SmartSpeed should be enabled so performance is 1184130561Sobrien * maintained. This is a function pointer entry point called by drivers. 1185218822Sdim **/ 1186218822Sdims32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active) 1187130561Sobrien{ 1188130561Sobrien if (hw->phy.ops.set_d3_lplu_state) 1189130561Sobrien return hw->phy.ops.set_d3_lplu_state(hw, active); 1190130561Sobrien 1191130561Sobrien return E1000_SUCCESS; 1192130561Sobrien} 1193130561Sobrien 1194130561Sobrien/** 1195130561Sobrien * e1000_read_mac_addr - Reads MAC address 1196130561Sobrien * @hw: pointer to the HW structure 1197130561Sobrien * 1198130561Sobrien * Reads the MAC address out of the adapter and stores it in the HW structure. 1199130561Sobrien * Currently no func pointer exists and all implementations are handled in the 1200130561Sobrien * generic version of this function. 1201130561Sobrien **/ 1202130561Sobriens32 e1000_read_mac_addr(struct e1000_hw *hw) 1203130561Sobrien{ 1204130561Sobrien if (hw->mac.ops.read_mac_addr) 1205130561Sobrien return hw->mac.ops.read_mac_addr(hw); 1206130561Sobrien 1207130561Sobrien return e1000_read_mac_addr_generic(hw); 1208130561Sobrien} 1209130561Sobrien 1210130561Sobrien/** 1211130561Sobrien * e1000_read_pba_string - Read device part number string 1212130561Sobrien * @hw: pointer to the HW structure 121399461Sobrien * @pba_num: pointer to device part number 1214130561Sobrien * @pba_num_size: size of part number buffer 1215130561Sobrien * 121699461Sobrien * Reads the product board assembly (PBA) number from the EEPROM and stores 121799461Sobrien * the value in pba_num. 121899461Sobrien * Currently no func pointer exists and all implementations are handled in the 121999461Sobrien * generic version of this function. 122099461Sobrien **/ 122199461Sobriens32 e1000_read_pba_string(struct e1000_hw *hw, u8 *pba_num, u32 pba_num_size) 122299461Sobrien{ 122399461Sobrien return e1000_read_pba_string_generic(hw, pba_num, pba_num_size); 122499461Sobrien} 122599461Sobrien 1226218822Sdim/** 122799461Sobrien * e1000_read_pba_length - Read device part number string length 122899461Sobrien * @hw: pointer to the HW structure 122999461Sobrien * @pba_num_size: size of part number buffer 123099461Sobrien * 123199461Sobrien * Reads the product board assembly (PBA) number length from the EEPROM and 123299461Sobrien * stores the value in pba_num. 123399461Sobrien * Currently no func pointer exists and all implementations are handled in the 123499461Sobrien * generic version of this function. 123599461Sobrien **/ 123699461Sobriens32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size) 123799461Sobrien{ 123899461Sobrien return e1000_read_pba_length_generic(hw, pba_num_size); 123999461Sobrien} 124099461Sobrien 124199461Sobrien/** 124299461Sobrien * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum 124399461Sobrien * @hw: pointer to the HW structure 124499461Sobrien * 124599461Sobrien * Validates the NVM checksum is correct. This is a function pointer entry 124699461Sobrien * point called by drivers. 124799461Sobrien **/ 124899461Sobriens32 e1000_validate_nvm_checksum(struct e1000_hw *hw) 124999461Sobrien{ 125099461Sobrien if (hw->nvm.ops.validate) 125199461Sobrien return hw->nvm.ops.validate(hw); 125299461Sobrien 125399461Sobrien return -E1000_ERR_CONFIG; 125499461Sobrien} 125599461Sobrien 125699461Sobrien/** 125799461Sobrien * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum 125899461Sobrien * @hw: pointer to the HW structure 125999461Sobrien * 126099461Sobrien * Updates the NVM checksum. Currently no func pointer exists and all 126199461Sobrien * implementations are handled in the generic version of this function. 126299461Sobrien **/ 1263218822Sdims32 e1000_update_nvm_checksum(struct e1000_hw *hw) 1264130561Sobrien{ 1265130561Sobrien if (hw->nvm.ops.update) 126699461Sobrien return hw->nvm.ops.update(hw); 126799461Sobrien 126899461Sobrien return -E1000_ERR_CONFIG; 1269218822Sdim} 127099461Sobrien 127199461Sobrien/** 127299461Sobrien * e1000_reload_nvm - Reloads EEPROM 127399461Sobrien * @hw: pointer to the HW structure 127499461Sobrien * 127599461Sobrien * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the 127699461Sobrien * extended control register. 127799461Sobrien **/ 127899461Sobrienvoid e1000_reload_nvm(struct e1000_hw *hw) 127999461Sobrien{ 128099461Sobrien if (hw->nvm.ops.reload) 128199461Sobrien hw->nvm.ops.reload(hw); 128299461Sobrien} 128399461Sobrien 128499461Sobrien/** 128599461Sobrien * e1000_read_nvm - Reads NVM (EEPROM) 128699461Sobrien * @hw: pointer to the HW structure 1287130561Sobrien * @offset: the word offset to read 128899461Sobrien * @words: number of 16-bit words to read 1289218822Sdim * @data: pointer to the properly sized buffer for the data. 129099461Sobrien * 129199461Sobrien * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function 129299461Sobrien * pointer entry point called by drivers. 129399461Sobrien **/ 1294218822Sdims32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) 1295218822Sdim{ 129699461Sobrien if (hw->nvm.ops.read) 129799461Sobrien return hw->nvm.ops.read(hw, offset, words, data); 129899461Sobrien 129999461Sobrien return -E1000_ERR_CONFIG; 130099461Sobrien} 130199461Sobrien 130299461Sobrien/** 130399461Sobrien * e1000_write_nvm - Writes to NVM (EEPROM) 130499461Sobrien * @hw: pointer to the HW structure 130599461Sobrien * @offset: the word offset to read 130699461Sobrien * @words: number of 16-bit words to write 130799461Sobrien * @data: pointer to the properly sized buffer for the data. 130899461Sobrien * 130999461Sobrien * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function 131099461Sobrien * pointer entry point called by drivers. 1311218822Sdim **/ 1312218822Sdims32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) 1313218822Sdim{ 131499461Sobrien if (hw->nvm.ops.write) 131599461Sobrien return hw->nvm.ops.write(hw, offset, words, data); 1316130561Sobrien 131799461Sobrien return E1000_SUCCESS; 131899461Sobrien} 131999461Sobrien 132099461Sobrien/** 132199461Sobrien * e1000_write_8bit_ctrl_reg - Writes 8bit Control register 132299461Sobrien * @hw: pointer to the HW structure 132399461Sobrien * @reg: 32bit register offset 132499461Sobrien * @offset: the register to write 132599461Sobrien * @data: the value to write. 132699461Sobrien * 132799461Sobrien * Writes the PHY register at offset with the value in data. 132899461Sobrien * This is a function pointer entry point called by drivers. 132999461Sobrien **/ 133099461Sobriens32 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset, 133199461Sobrien u8 data) 1332130561Sobrien{ 1333218822Sdim return e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data); 133499461Sobrien} 133599461Sobrien 133699461Sobrien/** 133799461Sobrien * e1000_power_up_phy - Restores link in case of PHY power down 1338130561Sobrien * @hw: pointer to the HW structure 133999461Sobrien * 1340218822Sdim * The phy may be powered down to save power, to turn off link when the 1341218822Sdim * driver is unloaded, or wake on lan is not enabled (among others). 134299461Sobrien **/ 134399461Sobrienvoid e1000_power_up_phy(struct e1000_hw *hw) 134499461Sobrien{ 134599461Sobrien if (hw->phy.ops.power_up) 134699461Sobrien hw->phy.ops.power_up(hw); 134799461Sobrien 1348130561Sobrien e1000_setup_link(hw); 134999461Sobrien} 135099461Sobrien 135199461Sobrien/** 1352130561Sobrien * e1000_power_down_phy - Power down PHY 135399461Sobrien * @hw: pointer to the HW structure 135499461Sobrien * 135599461Sobrien * The phy may be powered down to save power, to turn off link when the 135699461Sobrien * driver is unloaded, or wake on lan is not enabled (among others). 135799461Sobrien **/ 135899461Sobrienvoid e1000_power_down_phy(struct e1000_hw *hw) 135999461Sobrien{ 136099461Sobrien if (hw->phy.ops.power_down) 136199461Sobrien hw->phy.ops.power_down(hw); 136299461Sobrien} 136399461Sobrien 136499461Sobrien/** 136599461Sobrien * e1000_power_up_fiber_serdes_link - Power up serdes link 136699461Sobrien * @hw: pointer to the HW structure 136799461Sobrien * 136899461Sobrien * Power on the optics and PCS. 136999461Sobrien **/ 137099461Sobrienvoid e1000_power_up_fiber_serdes_link(struct e1000_hw *hw) 1371130561Sobrien{ 1372130561Sobrien if (hw->mac.ops.power_up_serdes) 1373130561Sobrien hw->mac.ops.power_up_serdes(hw); 1374130561Sobrien} 137599461Sobrien 137699461Sobrien/** 137799461Sobrien * e1000_shutdown_fiber_serdes_link - Remove link during power down 1378130561Sobrien * @hw: pointer to the HW structure 1379130561Sobrien * 1380130561Sobrien * Shutdown the optics and PCS on driver unload. 1381130561Sobrien **/ 138299461Sobrienvoid e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw) 138399461Sobrien{ 138499461Sobrien if (hw->mac.ops.shutdown_serdes) 138599461Sobrien hw->mac.ops.shutdown_serdes(hw); 138699461Sobrien} 138799461Sobrien 1388130561Sobrien