1177867Sjfv/****************************************************************************** 2169240Sjfv 3286833Ssbruno Copyright (c) 2001-2015, Intel Corporation 4169240Sjfv All rights reserved. 5169240Sjfv 6169240Sjfv Redistribution and use in source and binary forms, with or without 7169240Sjfv modification, are permitted provided that the following conditions are met: 8169240Sjfv 9169240Sjfv 1. Redistributions of source code must retain the above copyright notice, 10169240Sjfv this list of conditions and the following disclaimer. 11169240Sjfv 12169240Sjfv 2. Redistributions in binary form must reproduce the above copyright 13169240Sjfv notice, this list of conditions and the following disclaimer in the 14169240Sjfv documentation and/or other materials provided with the distribution. 15169240Sjfv 16169240Sjfv 3. Neither the name of the Intel Corporation nor the names of its 17169240Sjfv contributors may be used to endorse or promote products derived from 18169240Sjfv this software without specific prior written permission. 19169240Sjfv 20169240Sjfv THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21169240Sjfv AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22169240Sjfv IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23169240Sjfv ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24169240Sjfv LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25169240Sjfv CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26169240Sjfv SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27169240Sjfv INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28169240Sjfv CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29169240Sjfv ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30169240Sjfv POSSIBILITY OF SUCH DAMAGE. 31169240Sjfv 32177867Sjfv******************************************************************************/ 33177867Sjfv/*$FreeBSD: stable/11/sys/dev/e1000/e1000_api.c 333213 2018-05-03 15:40:56Z marius $*/ 34169240Sjfv 35169589Sjfv#include "e1000_api.h" 36169240Sjfv 37169240Sjfv/** 38169240Sjfv * e1000_init_mac_params - Initialize MAC function pointers 39169589Sjfv * @hw: pointer to the HW structure 40169240Sjfv * 41169240Sjfv * This function initializes the function pointers for the MAC 42169240Sjfv * set of functions. Called by drivers or by e1000_setup_init_funcs. 43169240Sjfv **/ 44173788Sjfvs32 e1000_init_mac_params(struct e1000_hw *hw) 45169240Sjfv{ 46169240Sjfv s32 ret_val = E1000_SUCCESS; 47169240Sjfv 48177867Sjfv if (hw->mac.ops.init_params) { 49177867Sjfv ret_val = hw->mac.ops.init_params(hw); 50169240Sjfv if (ret_val) { 51169240Sjfv DEBUGOUT("MAC Initialization Error\n"); 52169240Sjfv goto out; 53169240Sjfv } 54169240Sjfv } else { 55169240Sjfv DEBUGOUT("mac.init_mac_params was NULL\n"); 56169240Sjfv ret_val = -E1000_ERR_CONFIG; 57169240Sjfv } 58169240Sjfv 59169240Sjfvout: 60169240Sjfv return ret_val; 61169240Sjfv} 62169240Sjfv 63169240Sjfv/** 64169240Sjfv * e1000_init_nvm_params - Initialize NVM function pointers 65169589Sjfv * @hw: pointer to the HW structure 66169240Sjfv * 67169240Sjfv * This function initializes the function pointers for the NVM 68169240Sjfv * set of functions. Called by drivers or by e1000_setup_init_funcs. 69169240Sjfv **/ 70173788Sjfvs32 e1000_init_nvm_params(struct e1000_hw *hw) 71169240Sjfv{ 72169240Sjfv s32 ret_val = E1000_SUCCESS; 73169240Sjfv 74177867Sjfv if (hw->nvm.ops.init_params) { 75177867Sjfv ret_val = hw->nvm.ops.init_params(hw); 76169240Sjfv if (ret_val) { 77169240Sjfv DEBUGOUT("NVM Initialization Error\n"); 78169240Sjfv goto out; 79169240Sjfv } 80169240Sjfv } else { 81169240Sjfv DEBUGOUT("nvm.init_nvm_params was NULL\n"); 82169240Sjfv ret_val = -E1000_ERR_CONFIG; 83169240Sjfv } 84169240Sjfv 85169240Sjfvout: 86169240Sjfv return ret_val; 87169240Sjfv} 88169240Sjfv 89169240Sjfv/** 90169240Sjfv * e1000_init_phy_params - Initialize PHY function pointers 91169589Sjfv * @hw: pointer to the HW structure 92169240Sjfv * 93169240Sjfv * This function initializes the function pointers for the PHY 94169240Sjfv * set of functions. Called by drivers or by e1000_setup_init_funcs. 95169240Sjfv **/ 96173788Sjfvs32 e1000_init_phy_params(struct e1000_hw *hw) 97169240Sjfv{ 98169240Sjfv s32 ret_val = E1000_SUCCESS; 99169240Sjfv 100177867Sjfv if (hw->phy.ops.init_params) { 101177867Sjfv ret_val = hw->phy.ops.init_params(hw); 102169240Sjfv if (ret_val) { 103169240Sjfv DEBUGOUT("PHY Initialization Error\n"); 104169240Sjfv goto out; 105169240Sjfv } 106169240Sjfv } else { 107169240Sjfv DEBUGOUT("phy.init_phy_params was NULL\n"); 108169240Sjfv ret_val = -E1000_ERR_CONFIG; 109169240Sjfv } 110169240Sjfv 111169240Sjfvout: 112169240Sjfv return ret_val; 113169240Sjfv} 114169240Sjfv 115209616Sjfv/** 116209616Sjfv * e1000_init_mbx_params - Initialize mailbox function pointers 117209616Sjfv * @hw: pointer to the HW structure 118209616Sjfv * 119209616Sjfv * This function initializes the function pointers for the PHY 120209616Sjfv * set of functions. Called by drivers or by e1000_setup_init_funcs. 121209616Sjfv **/ 122209616Sjfvs32 e1000_init_mbx_params(struct e1000_hw *hw) 123209616Sjfv{ 124209616Sjfv s32 ret_val = E1000_SUCCESS; 125190872Sjfv 126209616Sjfv if (hw->mbx.ops.init_params) { 127209616Sjfv ret_val = hw->mbx.ops.init_params(hw); 128209616Sjfv if (ret_val) { 129209616Sjfv DEBUGOUT("Mailbox Initialization Error\n"); 130209616Sjfv goto out; 131209616Sjfv } 132209616Sjfv } else { 133209616Sjfv DEBUGOUT("mbx.init_mbx_params was NULL\n"); 134209616Sjfv ret_val = -E1000_ERR_CONFIG; 135209616Sjfv } 136209616Sjfv 137209616Sjfvout: 138209616Sjfv return ret_val; 139209616Sjfv} 140209616Sjfv 141169240Sjfv/** 142169240Sjfv * e1000_set_mac_type - Sets MAC type 143169589Sjfv * @hw: pointer to the HW structure 144169240Sjfv * 145169240Sjfv * This function sets the mac type of the adapter based on the 146169240Sjfv * device ID stored in the hw structure. 147169240Sjfv * MUST BE FIRST FUNCTION CALLED (explicitly or through 148169240Sjfv * e1000_setup_init_funcs()). 149169240Sjfv **/ 150173788Sjfvs32 e1000_set_mac_type(struct e1000_hw *hw) 151169240Sjfv{ 152169240Sjfv struct e1000_mac_info *mac = &hw->mac; 153169240Sjfv s32 ret_val = E1000_SUCCESS; 154169240Sjfv 155169240Sjfv DEBUGFUNC("e1000_set_mac_type"); 156169240Sjfv 157169240Sjfv switch (hw->device_id) { 158169240Sjfv case E1000_DEV_ID_82542: 159169240Sjfv mac->type = e1000_82542; 160169240Sjfv break; 161169240Sjfv case E1000_DEV_ID_82543GC_FIBER: 162169240Sjfv case E1000_DEV_ID_82543GC_COPPER: 163169240Sjfv mac->type = e1000_82543; 164169240Sjfv break; 165169240Sjfv case E1000_DEV_ID_82544EI_COPPER: 166169240Sjfv case E1000_DEV_ID_82544EI_FIBER: 167169240Sjfv case E1000_DEV_ID_82544GC_COPPER: 168169240Sjfv case E1000_DEV_ID_82544GC_LOM: 169169240Sjfv mac->type = e1000_82544; 170169240Sjfv break; 171169240Sjfv case E1000_DEV_ID_82540EM: 172169240Sjfv case E1000_DEV_ID_82540EM_LOM: 173169240Sjfv case E1000_DEV_ID_82540EP: 174169240Sjfv case E1000_DEV_ID_82540EP_LOM: 175169240Sjfv case E1000_DEV_ID_82540EP_LP: 176169240Sjfv mac->type = e1000_82540; 177169240Sjfv break; 178169240Sjfv case E1000_DEV_ID_82545EM_COPPER: 179169240Sjfv case E1000_DEV_ID_82545EM_FIBER: 180169240Sjfv mac->type = e1000_82545; 181169240Sjfv break; 182169240Sjfv case E1000_DEV_ID_82545GM_COPPER: 183169240Sjfv case E1000_DEV_ID_82545GM_FIBER: 184169240Sjfv case E1000_DEV_ID_82545GM_SERDES: 185169240Sjfv mac->type = e1000_82545_rev_3; 186169240Sjfv break; 187169240Sjfv case E1000_DEV_ID_82546EB_COPPER: 188169240Sjfv case E1000_DEV_ID_82546EB_FIBER: 189169240Sjfv case E1000_DEV_ID_82546EB_QUAD_COPPER: 190169240Sjfv mac->type = e1000_82546; 191169240Sjfv break; 192169240Sjfv case E1000_DEV_ID_82546GB_COPPER: 193169240Sjfv case E1000_DEV_ID_82546GB_FIBER: 194169240Sjfv case E1000_DEV_ID_82546GB_SERDES: 195169240Sjfv case E1000_DEV_ID_82546GB_PCIE: 196169240Sjfv case E1000_DEV_ID_82546GB_QUAD_COPPER: 197169240Sjfv case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: 198169240Sjfv mac->type = e1000_82546_rev_3; 199169240Sjfv break; 200169240Sjfv case E1000_DEV_ID_82541EI: 201169240Sjfv case E1000_DEV_ID_82541EI_MOBILE: 202169240Sjfv case E1000_DEV_ID_82541ER_LOM: 203169240Sjfv mac->type = e1000_82541; 204169240Sjfv break; 205169240Sjfv case E1000_DEV_ID_82541ER: 206169240Sjfv case E1000_DEV_ID_82541GI: 207169240Sjfv case E1000_DEV_ID_82541GI_LF: 208169240Sjfv case E1000_DEV_ID_82541GI_MOBILE: 209169240Sjfv mac->type = e1000_82541_rev_2; 210169240Sjfv break; 211169240Sjfv case E1000_DEV_ID_82547EI: 212169240Sjfv case E1000_DEV_ID_82547EI_MOBILE: 213169240Sjfv mac->type = e1000_82547; 214169240Sjfv break; 215169240Sjfv case E1000_DEV_ID_82547GI: 216169240Sjfv mac->type = e1000_82547_rev_2; 217169240Sjfv break; 218169240Sjfv case E1000_DEV_ID_82571EB_COPPER: 219169240Sjfv case E1000_DEV_ID_82571EB_FIBER: 220169240Sjfv case E1000_DEV_ID_82571EB_SERDES: 221169589Sjfv case E1000_DEV_ID_82571EB_SERDES_DUAL: 222169589Sjfv case E1000_DEV_ID_82571EB_SERDES_QUAD: 223169240Sjfv case E1000_DEV_ID_82571EB_QUAD_COPPER: 224173788Sjfv case E1000_DEV_ID_82571PT_QUAD_COPPER: 225169240Sjfv case E1000_DEV_ID_82571EB_QUAD_FIBER: 226169240Sjfv case E1000_DEV_ID_82571EB_QUAD_COPPER_LP: 227169240Sjfv mac->type = e1000_82571; 228169240Sjfv break; 229169240Sjfv case E1000_DEV_ID_82572EI: 230169240Sjfv case E1000_DEV_ID_82572EI_COPPER: 231169240Sjfv case E1000_DEV_ID_82572EI_FIBER: 232169240Sjfv case E1000_DEV_ID_82572EI_SERDES: 233169240Sjfv mac->type = e1000_82572; 234169240Sjfv break; 235169240Sjfv case E1000_DEV_ID_82573E: 236169240Sjfv case E1000_DEV_ID_82573E_IAMT: 237169240Sjfv case E1000_DEV_ID_82573L: 238169240Sjfv mac->type = e1000_82573; 239169240Sjfv break; 240178523Sjfv case E1000_DEV_ID_82574L: 241194865Sjfv case E1000_DEV_ID_82574LA: 242178523Sjfv mac->type = e1000_82574; 243178523Sjfv break; 244194865Sjfv case E1000_DEV_ID_82583V: 245194865Sjfv mac->type = e1000_82583; 246194865Sjfv break; 247169240Sjfv case E1000_DEV_ID_80003ES2LAN_COPPER_DPT: 248169240Sjfv case E1000_DEV_ID_80003ES2LAN_SERDES_DPT: 249169240Sjfv case E1000_DEV_ID_80003ES2LAN_COPPER_SPT: 250169240Sjfv case E1000_DEV_ID_80003ES2LAN_SERDES_SPT: 251169240Sjfv mac->type = e1000_80003es2lan; 252169240Sjfv break; 253169240Sjfv case E1000_DEV_ID_ICH8_IFE: 254169240Sjfv case E1000_DEV_ID_ICH8_IFE_GT: 255169240Sjfv case E1000_DEV_ID_ICH8_IFE_G: 256169240Sjfv case E1000_DEV_ID_ICH8_IGP_M: 257169240Sjfv case E1000_DEV_ID_ICH8_IGP_M_AMT: 258169240Sjfv case E1000_DEV_ID_ICH8_IGP_AMT: 259169240Sjfv case E1000_DEV_ID_ICH8_IGP_C: 260200243Sjfv case E1000_DEV_ID_ICH8_82567V_3: 261169240Sjfv mac->type = e1000_ich8lan; 262169240Sjfv break; 263169240Sjfv case E1000_DEV_ID_ICH9_IFE: 264169240Sjfv case E1000_DEV_ID_ICH9_IFE_GT: 265169240Sjfv case E1000_DEV_ID_ICH9_IFE_G: 266176667Sjfv case E1000_DEV_ID_ICH9_IGP_M: 267176667Sjfv case E1000_DEV_ID_ICH9_IGP_M_AMT: 268177867Sjfv case E1000_DEV_ID_ICH9_IGP_M_V: 269169240Sjfv case E1000_DEV_ID_ICH9_IGP_AMT: 270178523Sjfv case E1000_DEV_ID_ICH9_BM: 271169240Sjfv case E1000_DEV_ID_ICH9_IGP_C: 272178523Sjfv case E1000_DEV_ID_ICH10_R_BM_LM: 273178523Sjfv case E1000_DEV_ID_ICH10_R_BM_LF: 274178523Sjfv case E1000_DEV_ID_ICH10_R_BM_V: 275169240Sjfv mac->type = e1000_ich9lan; 276169240Sjfv break; 277178523Sjfv case E1000_DEV_ID_ICH10_D_BM_LM: 278178523Sjfv case E1000_DEV_ID_ICH10_D_BM_LF: 279213234Sjfv case E1000_DEV_ID_ICH10_D_BM_V: 280178523Sjfv mac->type = e1000_ich10lan; 281178523Sjfv break; 282194865Sjfv case E1000_DEV_ID_PCH_D_HV_DM: 283194865Sjfv case E1000_DEV_ID_PCH_D_HV_DC: 284194865Sjfv case E1000_DEV_ID_PCH_M_HV_LM: 285194865Sjfv case E1000_DEV_ID_PCH_M_HV_LC: 286194865Sjfv mac->type = e1000_pchlan; 287194865Sjfv break; 288213234Sjfv case E1000_DEV_ID_PCH2_LV_LM: 289213234Sjfv case E1000_DEV_ID_PCH2_LV_V: 290213234Sjfv mac->type = e1000_pch2lan; 291213234Sjfv break; 292247064Sjfv case E1000_DEV_ID_PCH_LPT_I217_LM: 293247064Sjfv case E1000_DEV_ID_PCH_LPT_I217_V: 294247064Sjfv case E1000_DEV_ID_PCH_LPTLP_I218_LM: 295247064Sjfv case E1000_DEV_ID_PCH_LPTLP_I218_V: 296267935Sjfv case E1000_DEV_ID_PCH_I218_LM2: 297267935Sjfv case E1000_DEV_ID_PCH_I218_V2: 298267935Sjfv case E1000_DEV_ID_PCH_I218_LM3: 299267935Sjfv case E1000_DEV_ID_PCH_I218_V3: 300247064Sjfv mac->type = e1000_pch_lpt; 301247064Sjfv break; 302295323Serj case E1000_DEV_ID_PCH_SPT_I219_LM: 303295323Serj case E1000_DEV_ID_PCH_SPT_I219_V: 304295323Serj case E1000_DEV_ID_PCH_SPT_I219_LM2: 305295323Serj case E1000_DEV_ID_PCH_SPT_I219_V2: 306295323Serj case E1000_DEV_ID_PCH_LBG_I219_LM3: 307304337Ssbruno case E1000_DEV_ID_PCH_SPT_I219_LM4: 308304337Ssbruno case E1000_DEV_ID_PCH_SPT_I219_V4: 309304337Ssbruno case E1000_DEV_ID_PCH_SPT_I219_LM5: 310304337Ssbruno case E1000_DEV_ID_PCH_SPT_I219_V5: 311295323Serj mac->type = e1000_pch_spt; 312295323Serj break; 313333213Smarius case E1000_DEV_ID_PCH_CNP_I219_LM6: 314333213Smarius case E1000_DEV_ID_PCH_CNP_I219_V6: 315333213Smarius case E1000_DEV_ID_PCH_CNP_I219_LM7: 316333213Smarius case E1000_DEV_ID_PCH_CNP_I219_V7: 317333213Smarius case E1000_DEV_ID_PCH_ICP_I219_LM8: 318333213Smarius case E1000_DEV_ID_PCH_ICP_I219_V8: 319333213Smarius case E1000_DEV_ID_PCH_ICP_I219_LM9: 320333213Smarius case E1000_DEV_ID_PCH_ICP_I219_V9: 321333213Smarius mac->type = e1000_pch_cnp; 322333213Smarius break; 323177867Sjfv case E1000_DEV_ID_82575EB_COPPER: 324177867Sjfv case E1000_DEV_ID_82575EB_FIBER_SERDES: 325177867Sjfv case E1000_DEV_ID_82575GB_QUAD_COPPER: 326177867Sjfv mac->type = e1000_82575; 327169240Sjfv break; 328181027Sjfv case E1000_DEV_ID_82576: 329181027Sjfv case E1000_DEV_ID_82576_FIBER: 330181027Sjfv case E1000_DEV_ID_82576_SERDES: 331181027Sjfv case E1000_DEV_ID_82576_QUAD_COPPER: 332213234Sjfv case E1000_DEV_ID_82576_QUAD_COPPER_ET2: 333190872Sjfv case E1000_DEV_ID_82576_NS: 334200243Sjfv case E1000_DEV_ID_82576_NS_SERDES: 335194865Sjfv case E1000_DEV_ID_82576_SERDES_QUAD: 336181027Sjfv mac->type = e1000_82576; 337181027Sjfv break; 338200243Sjfv case E1000_DEV_ID_82580_COPPER: 339200243Sjfv case E1000_DEV_ID_82580_FIBER: 340200243Sjfv case E1000_DEV_ID_82580_SERDES: 341200243Sjfv case E1000_DEV_ID_82580_SGMII: 342200243Sjfv case E1000_DEV_ID_82580_COPPER_DUAL: 343213234Sjfv case E1000_DEV_ID_82580_QUAD_FIBER: 344215789Sjfv case E1000_DEV_ID_DH89XXCC_SGMII: 345215789Sjfv case E1000_DEV_ID_DH89XXCC_SERDES: 346218530Sjfv case E1000_DEV_ID_DH89XXCC_BACKPLANE: 347218530Sjfv case E1000_DEV_ID_DH89XXCC_SFP: 348200243Sjfv mac->type = e1000_82580; 349200243Sjfv break; 350218530Sjfv case E1000_DEV_ID_I350_COPPER: 351218530Sjfv case E1000_DEV_ID_I350_FIBER: 352218530Sjfv case E1000_DEV_ID_I350_SERDES: 353218530Sjfv case E1000_DEV_ID_I350_SGMII: 354228386Sjfv case E1000_DEV_ID_I350_DA4: 355218530Sjfv mac->type = e1000_i350; 356218530Sjfv break; 357256200Sjfv case E1000_DEV_ID_I210_COPPER_FLASHLESS: 358256200Sjfv case E1000_DEV_ID_I210_SERDES_FLASHLESS: 359238148Sjfv case E1000_DEV_ID_I210_COPPER: 360238148Sjfv case E1000_DEV_ID_I210_COPPER_OEM1: 361238148Sjfv case E1000_DEV_ID_I210_COPPER_IT: 362238148Sjfv case E1000_DEV_ID_I210_FIBER: 363238148Sjfv case E1000_DEV_ID_I210_SERDES: 364238148Sjfv case E1000_DEV_ID_I210_SGMII: 365238148Sjfv mac->type = e1000_i210; 366238148Sjfv break; 367238148Sjfv case E1000_DEV_ID_I211_COPPER: 368247064Sjfv mac->type = e1000_i211; 369247064Sjfv break; 370209616Sjfv case E1000_DEV_ID_82576_VF: 371247064Sjfv case E1000_DEV_ID_82576_VF_HV: 372209616Sjfv mac->type = e1000_vfadapt; 373209616Sjfv break; 374218530Sjfv case E1000_DEV_ID_I350_VF: 375247064Sjfv case E1000_DEV_ID_I350_VF_HV: 376218530Sjfv mac->type = e1000_vfadapt_i350; 377218530Sjfv break; 378247064Sjfv 379256200Sjfv case E1000_DEV_ID_I354_BACKPLANE_1GBPS: 380256200Sjfv case E1000_DEV_ID_I354_SGMII: 381256200Sjfv case E1000_DEV_ID_I354_BACKPLANE_2_5GBPS: 382256200Sjfv mac->type = e1000_i354; 383256200Sjfv break; 384169240Sjfv default: 385169240Sjfv /* Should never have loaded on this device */ 386169240Sjfv ret_val = -E1000_ERR_MAC_INIT; 387169240Sjfv break; 388169240Sjfv } 389169240Sjfv 390169240Sjfv return ret_val; 391169240Sjfv} 392169240Sjfv 393169240Sjfv/** 394169240Sjfv * e1000_setup_init_funcs - Initializes function pointers 395169589Sjfv * @hw: pointer to the HW structure 396169589Sjfv * @init_device: TRUE will initialize the rest of the function pointers 397228386Sjfv * getting the device ready for use. FALSE will only set 398228386Sjfv * MAC type and the function pointers for the other init 399228386Sjfv * functions. Passing FALSE will not generate any hardware 400228386Sjfv * reads or writes. 401169240Sjfv * 402169240Sjfv * This function must be called by a driver in order to use the rest 403169240Sjfv * of the 'shared' code files. Called by drivers only. 404169240Sjfv **/ 405173788Sjfvs32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device) 406169240Sjfv{ 407169240Sjfv s32 ret_val; 408169240Sjfv 409173788Sjfv /* Can't do much good without knowing the MAC type. */ 410169240Sjfv ret_val = e1000_set_mac_type(hw); 411169240Sjfv if (ret_val) { 412169240Sjfv DEBUGOUT("ERROR: MAC type could not be set properly.\n"); 413169240Sjfv goto out; 414169240Sjfv } 415169240Sjfv 416169240Sjfv if (!hw->hw_addr) { 417169240Sjfv DEBUGOUT("ERROR: Registers not mapped\n"); 418169240Sjfv ret_val = -E1000_ERR_CONFIG; 419169240Sjfv goto out; 420169240Sjfv } 421169240Sjfv 422173788Sjfv /* 423177867Sjfv * Init function pointers to generic implementations. We do this first 424177867Sjfv * allowing a driver module to override it afterward. 425169240Sjfv */ 426177867Sjfv e1000_init_mac_ops_generic(hw); 427177867Sjfv e1000_init_phy_ops_generic(hw); 428177867Sjfv e1000_init_nvm_ops_generic(hw); 429209616Sjfv e1000_init_mbx_ops_generic(hw); 430169240Sjfv 431173788Sjfv /* 432173788Sjfv * Set up the init function pointers. These are functions within the 433169240Sjfv * adapter family file that sets up function pointers for the rest of 434169240Sjfv * the functions in that family. 435169240Sjfv */ 436169240Sjfv switch (hw->mac.type) { 437169240Sjfv case e1000_82542: 438169240Sjfv e1000_init_function_pointers_82542(hw); 439169240Sjfv break; 440169240Sjfv case e1000_82543: 441169240Sjfv case e1000_82544: 442169240Sjfv e1000_init_function_pointers_82543(hw); 443169240Sjfv break; 444169240Sjfv case e1000_82540: 445169240Sjfv case e1000_82545: 446169240Sjfv case e1000_82545_rev_3: 447169240Sjfv case e1000_82546: 448169240Sjfv case e1000_82546_rev_3: 449169240Sjfv e1000_init_function_pointers_82540(hw); 450169240Sjfv break; 451169240Sjfv case e1000_82541: 452169240Sjfv case e1000_82541_rev_2: 453169240Sjfv case e1000_82547: 454169240Sjfv case e1000_82547_rev_2: 455169240Sjfv e1000_init_function_pointers_82541(hw); 456169240Sjfv break; 457169240Sjfv case e1000_82571: 458169240Sjfv case e1000_82572: 459169240Sjfv case e1000_82573: 460178523Sjfv case e1000_82574: 461194865Sjfv case e1000_82583: 462169240Sjfv e1000_init_function_pointers_82571(hw); 463169240Sjfv break; 464169240Sjfv case e1000_80003es2lan: 465169240Sjfv e1000_init_function_pointers_80003es2lan(hw); 466169240Sjfv break; 467169240Sjfv case e1000_ich8lan: 468169240Sjfv case e1000_ich9lan: 469178523Sjfv case e1000_ich10lan: 470194865Sjfv case e1000_pchlan: 471213234Sjfv case e1000_pch2lan: 472247064Sjfv case e1000_pch_lpt: 473295323Serj case e1000_pch_spt: 474333213Smarius case e1000_pch_cnp: 475169240Sjfv e1000_init_function_pointers_ich8lan(hw); 476169240Sjfv break; 477177867Sjfv case e1000_82575: 478181027Sjfv case e1000_82576: 479200243Sjfv case e1000_82580: 480218530Sjfv case e1000_i350: 481256200Sjfv case e1000_i354: 482177867Sjfv e1000_init_function_pointers_82575(hw); 483177867Sjfv break; 484238148Sjfv case e1000_i210: 485238148Sjfv case e1000_i211: 486238148Sjfv e1000_init_function_pointers_i210(hw); 487238148Sjfv break; 488209616Sjfv case e1000_vfadapt: 489209616Sjfv e1000_init_function_pointers_vf(hw); 490209616Sjfv break; 491218530Sjfv case e1000_vfadapt_i350: 492218530Sjfv e1000_init_function_pointers_vf(hw); 493218530Sjfv break; 494169240Sjfv default: 495169240Sjfv DEBUGOUT("Hardware not supported\n"); 496169240Sjfv ret_val = -E1000_ERR_CONFIG; 497169240Sjfv break; 498169240Sjfv } 499169240Sjfv 500173788Sjfv /* 501173788Sjfv * Initialize the rest of the function pointers. These require some 502169240Sjfv * register reads/writes in some cases. 503169240Sjfv */ 504173788Sjfv if (!(ret_val) && init_device) { 505169240Sjfv ret_val = e1000_init_mac_params(hw); 506169240Sjfv if (ret_val) 507169240Sjfv goto out; 508169240Sjfv 509169240Sjfv ret_val = e1000_init_nvm_params(hw); 510169240Sjfv if (ret_val) 511169240Sjfv goto out; 512169240Sjfv 513169240Sjfv ret_val = e1000_init_phy_params(hw); 514169240Sjfv if (ret_val) 515169240Sjfv goto out; 516209616Sjfv 517209616Sjfv ret_val = e1000_init_mbx_params(hw); 518209616Sjfv if (ret_val) 519209616Sjfv goto out; 520169240Sjfv } 521169240Sjfv 522169240Sjfvout: 523169240Sjfv return ret_val; 524169240Sjfv} 525169240Sjfv 526169240Sjfv/** 527169240Sjfv * e1000_get_bus_info - Obtain bus information for adapter 528169589Sjfv * @hw: pointer to the HW structure 529169240Sjfv * 530169240Sjfv * This will obtain information about the HW bus for which the 531176667Sjfv * adapter is attached and stores it in the hw structure. This is a 532169240Sjfv * function pointer entry point called by drivers. 533169240Sjfv **/ 534173788Sjfvs32 e1000_get_bus_info(struct e1000_hw *hw) 535169240Sjfv{ 536177867Sjfv if (hw->mac.ops.get_bus_info) 537177867Sjfv return hw->mac.ops.get_bus_info(hw); 538173788Sjfv 539173788Sjfv return E1000_SUCCESS; 540169240Sjfv} 541169240Sjfv 542169240Sjfv/** 543169240Sjfv * e1000_clear_vfta - Clear VLAN filter table 544169589Sjfv * @hw: pointer to the HW structure 545169240Sjfv * 546169240Sjfv * This clears the VLAN filter table on the adapter. This is a function 547169240Sjfv * pointer entry point called by drivers. 548169240Sjfv **/ 549173788Sjfvvoid e1000_clear_vfta(struct e1000_hw *hw) 550169240Sjfv{ 551177867Sjfv if (hw->mac.ops.clear_vfta) 552178523Sjfv hw->mac.ops.clear_vfta(hw); 553169240Sjfv} 554169240Sjfv 555169240Sjfv/** 556169240Sjfv * e1000_write_vfta - Write value to VLAN filter table 557169589Sjfv * @hw: pointer to the HW structure 558169589Sjfv * @offset: the 32-bit offset in which to write the value to. 559169589Sjfv * @value: the 32-bit value to write at location offset. 560169240Sjfv * 561169240Sjfv * This writes a 32-bit value to a 32-bit offset in the VLAN filter 562169240Sjfv * table. This is a function pointer entry point called by drivers. 563169240Sjfv **/ 564173788Sjfvvoid e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value) 565169240Sjfv{ 566177867Sjfv if (hw->mac.ops.write_vfta) 567177867Sjfv hw->mac.ops.write_vfta(hw, offset, value); 568169240Sjfv} 569169240Sjfv 570169240Sjfv/** 571173788Sjfv * e1000_update_mc_addr_list - Update Multicast addresses 572169589Sjfv * @hw: pointer to the HW structure 573169589Sjfv * @mc_addr_list: array of multicast addresses to program 574169589Sjfv * @mc_addr_count: number of multicast addresses to program 575169240Sjfv * 576190872Sjfv * Updates the Multicast Table Array. 577169240Sjfv * The caller must have a packed mc_addr_list of multicast addresses. 578169240Sjfv **/ 579173788Sjfvvoid e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list, 580228386Sjfv u32 mc_addr_count) 581169240Sjfv{ 582177867Sjfv if (hw->mac.ops.update_mc_addr_list) 583190872Sjfv hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, 584228386Sjfv mc_addr_count); 585169240Sjfv} 586169240Sjfv 587169240Sjfv/** 588169240Sjfv * e1000_force_mac_fc - Force MAC flow control 589169589Sjfv * @hw: pointer to the HW structure 590169240Sjfv * 591169240Sjfv * Force the MAC's flow control settings. Currently no func pointer exists 592169240Sjfv * and all implementations are handled in the generic version of this 593169240Sjfv * function. 594169240Sjfv **/ 595173788Sjfvs32 e1000_force_mac_fc(struct e1000_hw *hw) 596169240Sjfv{ 597169240Sjfv return e1000_force_mac_fc_generic(hw); 598169240Sjfv} 599169240Sjfv 600169240Sjfv/** 601169240Sjfv * e1000_check_for_link - Check/Store link connection 602169589Sjfv * @hw: pointer to the HW structure 603169240Sjfv * 604169240Sjfv * This checks the link condition of the adapter and stores the 605169240Sjfv * results in the hw->mac structure. This is a function pointer entry 606169240Sjfv * point called by drivers. 607169240Sjfv **/ 608173788Sjfvs32 e1000_check_for_link(struct e1000_hw *hw) 609169240Sjfv{ 610177867Sjfv if (hw->mac.ops.check_for_link) 611177867Sjfv return hw->mac.ops.check_for_link(hw); 612173788Sjfv 613173788Sjfv return -E1000_ERR_CONFIG; 614169240Sjfv} 615169240Sjfv 616169240Sjfv/** 617169240Sjfv * e1000_check_mng_mode - Check management mode 618169589Sjfv * @hw: pointer to the HW structure 619169240Sjfv * 620169240Sjfv * This checks if the adapter has manageability enabled. 621169240Sjfv * This is a function pointer entry point called by drivers. 622169240Sjfv **/ 623173788Sjfvbool e1000_check_mng_mode(struct e1000_hw *hw) 624169240Sjfv{ 625177867Sjfv if (hw->mac.ops.check_mng_mode) 626177867Sjfv return hw->mac.ops.check_mng_mode(hw); 627173788Sjfv 628173788Sjfv return FALSE; 629169240Sjfv} 630169240Sjfv 631169240Sjfv/** 632169240Sjfv * e1000_mng_write_dhcp_info - Writes DHCP info to host interface 633169589Sjfv * @hw: pointer to the HW structure 634169589Sjfv * @buffer: pointer to the host interface 635169589Sjfv * @length: size of the buffer 636169240Sjfv * 637169240Sjfv * Writes the DHCP information to the host interface. 638169240Sjfv **/ 639173788Sjfvs32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length) 640169240Sjfv{ 641169240Sjfv return e1000_mng_write_dhcp_info_generic(hw, buffer, length); 642169240Sjfv} 643169240Sjfv 644169240Sjfv/** 645169240Sjfv * e1000_reset_hw - Reset hardware 646169589Sjfv * @hw: pointer to the HW structure 647169240Sjfv * 648169240Sjfv * This resets the hardware into a known state. This is a function pointer 649169240Sjfv * entry point called by drivers. 650169240Sjfv **/ 651173788Sjfvs32 e1000_reset_hw(struct e1000_hw *hw) 652169240Sjfv{ 653177867Sjfv if (hw->mac.ops.reset_hw) 654177867Sjfv return hw->mac.ops.reset_hw(hw); 655173788Sjfv 656173788Sjfv return -E1000_ERR_CONFIG; 657169240Sjfv} 658169240Sjfv 659169240Sjfv/** 660169240Sjfv * e1000_init_hw - Initialize hardware 661169589Sjfv * @hw: pointer to the HW structure 662169240Sjfv * 663169240Sjfv * This inits the hardware readying it for operation. This is a function 664169240Sjfv * pointer entry point called by drivers. 665169240Sjfv **/ 666173788Sjfvs32 e1000_init_hw(struct e1000_hw *hw) 667169240Sjfv{ 668177867Sjfv if (hw->mac.ops.init_hw) 669177867Sjfv return hw->mac.ops.init_hw(hw); 670173788Sjfv 671173788Sjfv return -E1000_ERR_CONFIG; 672169240Sjfv} 673169240Sjfv 674169240Sjfv/** 675169240Sjfv * e1000_setup_link - Configures link and flow control 676169589Sjfv * @hw: pointer to the HW structure 677169240Sjfv * 678169240Sjfv * This configures link and flow control settings for the adapter. This 679169240Sjfv * is a function pointer entry point called by drivers. While modules can 680169240Sjfv * also call this, they probably call their own version of this function. 681169240Sjfv **/ 682173788Sjfvs32 e1000_setup_link(struct e1000_hw *hw) 683169240Sjfv{ 684177867Sjfv if (hw->mac.ops.setup_link) 685177867Sjfv return hw->mac.ops.setup_link(hw); 686173788Sjfv 687173788Sjfv return -E1000_ERR_CONFIG; 688169240Sjfv} 689169240Sjfv 690169240Sjfv/** 691169240Sjfv * e1000_get_speed_and_duplex - Returns current speed and duplex 692169589Sjfv * @hw: pointer to the HW structure 693169589Sjfv * @speed: pointer to a 16-bit value to store the speed 694169589Sjfv * @duplex: pointer to a 16-bit value to store the duplex. 695169240Sjfv * 696169240Sjfv * This returns the speed and duplex of the adapter in the two 'out' 697169240Sjfv * variables passed in. This is a function pointer entry point called 698169240Sjfv * by drivers. 699169240Sjfv **/ 700173788Sjfvs32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex) 701169240Sjfv{ 702177867Sjfv if (hw->mac.ops.get_link_up_info) 703177867Sjfv return hw->mac.ops.get_link_up_info(hw, speed, duplex); 704173788Sjfv 705173788Sjfv return -E1000_ERR_CONFIG; 706169240Sjfv} 707169240Sjfv 708169240Sjfv/** 709169240Sjfv * e1000_setup_led - Configures SW controllable LED 710169589Sjfv * @hw: pointer to the HW structure 711169240Sjfv * 712169240Sjfv * This prepares the SW controllable LED for use and saves the current state 713169240Sjfv * of the LED so it can be later restored. This is a function pointer entry 714169240Sjfv * point called by drivers. 715169240Sjfv **/ 716173788Sjfvs32 e1000_setup_led(struct e1000_hw *hw) 717169240Sjfv{ 718177867Sjfv if (hw->mac.ops.setup_led) 719177867Sjfv return hw->mac.ops.setup_led(hw); 720173788Sjfv 721173788Sjfv return E1000_SUCCESS; 722169240Sjfv} 723169240Sjfv 724169240Sjfv/** 725169240Sjfv * e1000_cleanup_led - Restores SW controllable LED 726169589Sjfv * @hw: pointer to the HW structure 727169240Sjfv * 728169240Sjfv * This restores the SW controllable LED to the value saved off by 729169240Sjfv * e1000_setup_led. This is a function pointer entry point called by drivers. 730169240Sjfv **/ 731173788Sjfvs32 e1000_cleanup_led(struct e1000_hw *hw) 732169240Sjfv{ 733177867Sjfv if (hw->mac.ops.cleanup_led) 734177867Sjfv return hw->mac.ops.cleanup_led(hw); 735173788Sjfv 736173788Sjfv return E1000_SUCCESS; 737169240Sjfv} 738169240Sjfv 739169240Sjfv/** 740169240Sjfv * e1000_blink_led - Blink SW controllable LED 741169589Sjfv * @hw: pointer to the HW structure 742169240Sjfv * 743169240Sjfv * This starts the adapter LED blinking. Request the LED to be setup first 744169240Sjfv * and cleaned up after. This is a function pointer entry point called by 745169240Sjfv * drivers. 746169240Sjfv **/ 747173788Sjfvs32 e1000_blink_led(struct e1000_hw *hw) 748169240Sjfv{ 749177867Sjfv if (hw->mac.ops.blink_led) 750177867Sjfv return hw->mac.ops.blink_led(hw); 751173788Sjfv 752173788Sjfv return E1000_SUCCESS; 753169240Sjfv} 754169240Sjfv 755169240Sjfv/** 756190872Sjfv * e1000_id_led_init - store LED configurations in SW 757190872Sjfv * @hw: pointer to the HW structure 758190872Sjfv * 759190872Sjfv * Initializes the LED config in SW. This is a function pointer entry point 760190872Sjfv * called by drivers. 761190872Sjfv **/ 762190872Sjfvs32 e1000_id_led_init(struct e1000_hw *hw) 763190872Sjfv{ 764190872Sjfv if (hw->mac.ops.id_led_init) 765190872Sjfv return hw->mac.ops.id_led_init(hw); 766190872Sjfv 767190872Sjfv return E1000_SUCCESS; 768190872Sjfv} 769190872Sjfv 770190872Sjfv/** 771169240Sjfv * e1000_led_on - Turn on SW controllable LED 772169589Sjfv * @hw: pointer to the HW structure 773169240Sjfv * 774169240Sjfv * Turns the SW defined LED on. This is a function pointer entry point 775169240Sjfv * called by drivers. 776169240Sjfv **/ 777173788Sjfvs32 e1000_led_on(struct e1000_hw *hw) 778169240Sjfv{ 779177867Sjfv if (hw->mac.ops.led_on) 780177867Sjfv return hw->mac.ops.led_on(hw); 781173788Sjfv 782173788Sjfv return E1000_SUCCESS; 783169240Sjfv} 784169240Sjfv 785169240Sjfv/** 786169240Sjfv * e1000_led_off - Turn off SW controllable LED 787169589Sjfv * @hw: pointer to the HW structure 788169240Sjfv * 789169240Sjfv * Turns the SW defined LED off. This is a function pointer entry point 790169240Sjfv * called by drivers. 791169240Sjfv **/ 792173788Sjfvs32 e1000_led_off(struct e1000_hw *hw) 793169240Sjfv{ 794177867Sjfv if (hw->mac.ops.led_off) 795177867Sjfv return hw->mac.ops.led_off(hw); 796173788Sjfv 797173788Sjfv return E1000_SUCCESS; 798169240Sjfv} 799169240Sjfv 800169240Sjfv/** 801169240Sjfv * e1000_reset_adaptive - Reset adaptive IFS 802169589Sjfv * @hw: pointer to the HW structure 803169240Sjfv * 804169240Sjfv * Resets the adaptive IFS. Currently no func pointer exists and all 805169240Sjfv * implementations are handled in the generic version of this function. 806169240Sjfv **/ 807173788Sjfvvoid e1000_reset_adaptive(struct e1000_hw *hw) 808169240Sjfv{ 809169240Sjfv e1000_reset_adaptive_generic(hw); 810169240Sjfv} 811169240Sjfv 812169240Sjfv/** 813169240Sjfv * e1000_update_adaptive - Update adaptive IFS 814169589Sjfv * @hw: pointer to the HW structure 815169240Sjfv * 816169240Sjfv * Updates adapter IFS. Currently no func pointer exists and all 817169240Sjfv * implementations are handled in the generic version of this function. 818169240Sjfv **/ 819173788Sjfvvoid e1000_update_adaptive(struct e1000_hw *hw) 820169240Sjfv{ 821169240Sjfv e1000_update_adaptive_generic(hw); 822169240Sjfv} 823169240Sjfv 824169240Sjfv/** 825169240Sjfv * e1000_disable_pcie_master - Disable PCI-Express master access 826169589Sjfv * @hw: pointer to the HW structure 827169240Sjfv * 828169240Sjfv * Disables PCI-Express master access and verifies there are no pending 829169240Sjfv * requests. Currently no func pointer exists and all implementations are 830169240Sjfv * handled in the generic version of this function. 831169240Sjfv **/ 832173788Sjfvs32 e1000_disable_pcie_master(struct e1000_hw *hw) 833169240Sjfv{ 834169240Sjfv return e1000_disable_pcie_master_generic(hw); 835169240Sjfv} 836169240Sjfv 837169240Sjfv/** 838169240Sjfv * e1000_config_collision_dist - Configure collision distance 839169589Sjfv * @hw: pointer to the HW structure 840169240Sjfv * 841169240Sjfv * Configures the collision distance to the default value and is used 842169240Sjfv * during link setup. 843169240Sjfv **/ 844173788Sjfvvoid e1000_config_collision_dist(struct e1000_hw *hw) 845169240Sjfv{ 846177867Sjfv if (hw->mac.ops.config_collision_dist) 847177867Sjfv hw->mac.ops.config_collision_dist(hw); 848169240Sjfv} 849169240Sjfv 850169240Sjfv/** 851169240Sjfv * e1000_rar_set - Sets a receive address register 852169589Sjfv * @hw: pointer to the HW structure 853169589Sjfv * @addr: address to set the RAR to 854169589Sjfv * @index: the RAR to set 855169240Sjfv * 856169240Sjfv * Sets a Receive Address Register (RAR) to the specified address. 857169240Sjfv **/ 858267935Sjfvint e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index) 859169240Sjfv{ 860177867Sjfv if (hw->mac.ops.rar_set) 861267935Sjfv return hw->mac.ops.rar_set(hw, addr, index); 862267935Sjfv 863267935Sjfv return E1000_SUCCESS; 864169240Sjfv} 865169240Sjfv 866169240Sjfv/** 867169240Sjfv * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state 868169589Sjfv * @hw: pointer to the HW structure 869169240Sjfv * 870169240Sjfv * Ensures that the MDI/MDIX SW state is valid. 871169240Sjfv **/ 872173788Sjfvs32 e1000_validate_mdi_setting(struct e1000_hw *hw) 873169240Sjfv{ 874177867Sjfv if (hw->mac.ops.validate_mdi_setting) 875177867Sjfv return hw->mac.ops.validate_mdi_setting(hw); 876173788Sjfv 877173788Sjfv return E1000_SUCCESS; 878169240Sjfv} 879169240Sjfv 880169240Sjfv/** 881169240Sjfv * e1000_hash_mc_addr - Determines address location in multicast table 882169589Sjfv * @hw: pointer to the HW structure 883169589Sjfv * @mc_addr: Multicast address to hash. 884169240Sjfv * 885169240Sjfv * This hashes an address to determine its location in the multicast 886169240Sjfv * table. Currently no func pointer exists and all implementations 887169240Sjfv * are handled in the generic version of this function. 888169240Sjfv **/ 889173788Sjfvu32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) 890169240Sjfv{ 891169240Sjfv return e1000_hash_mc_addr_generic(hw, mc_addr); 892169240Sjfv} 893169240Sjfv 894169240Sjfv/** 895169240Sjfv * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX 896169589Sjfv * @hw: pointer to the HW structure 897169240Sjfv * 898169240Sjfv * Enables packet filtering on transmit packets if manageability is enabled 899169240Sjfv * and host interface is enabled. 900169240Sjfv * Currently no func pointer exists and all implementations are handled in the 901169240Sjfv * generic version of this function. 902169240Sjfv **/ 903173788Sjfvbool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw) 904169240Sjfv{ 905169240Sjfv return e1000_enable_tx_pkt_filtering_generic(hw); 906169240Sjfv} 907169240Sjfv 908169240Sjfv/** 909169240Sjfv * e1000_mng_host_if_write - Writes to the manageability host interface 910169589Sjfv * @hw: pointer to the HW structure 911169589Sjfv * @buffer: pointer to the host interface buffer 912169589Sjfv * @length: size of the buffer 913169589Sjfv * @offset: location in the buffer to write to 914169589Sjfv * @sum: sum of the data (not checksum) 915169240Sjfv * 916169240Sjfv * This function writes the buffer content at the offset given on the host if. 917169240Sjfv * It also does alignment considerations to do the writes in most efficient 918169240Sjfv * way. Also fills up the sum of the buffer in *buffer parameter. 919169240Sjfv **/ 920228386Sjfvs32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length, 921228386Sjfv u16 offset, u8 *sum) 922169240Sjfv{ 923247064Sjfv return e1000_mng_host_if_write_generic(hw, buffer, length, offset, sum); 924169240Sjfv} 925169240Sjfv 926169240Sjfv/** 927169240Sjfv * e1000_mng_write_cmd_header - Writes manageability command header 928169589Sjfv * @hw: pointer to the HW structure 929169589Sjfv * @hdr: pointer to the host interface command header 930169240Sjfv * 931169240Sjfv * Writes the command header after does the checksum calculation. 932169240Sjfv **/ 933173788Sjfvs32 e1000_mng_write_cmd_header(struct e1000_hw *hw, 934228386Sjfv struct e1000_host_mng_command_header *hdr) 935169240Sjfv{ 936247064Sjfv return e1000_mng_write_cmd_header_generic(hw, hdr); 937169240Sjfv} 938169240Sjfv 939169240Sjfv/** 940169240Sjfv * e1000_mng_enable_host_if - Checks host interface is enabled 941169589Sjfv * @hw: pointer to the HW structure 942169240Sjfv * 943169240Sjfv * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND 944169240Sjfv * 945176667Sjfv * This function checks whether the HOST IF is enabled for command operation 946169240Sjfv * and also checks whether the previous command is completed. It busy waits 947169240Sjfv * in case of previous command is not completed. 948169240Sjfv **/ 949228386Sjfvs32 e1000_mng_enable_host_if(struct e1000_hw *hw) 950169240Sjfv{ 951247064Sjfv return e1000_mng_enable_host_if_generic(hw); 952169240Sjfv} 953169240Sjfv 954169240Sjfv/** 955287990Ssbruno * e1000_set_obff_timer - Set Optimized Buffer Flush/Fill timer 956287990Ssbruno * @hw: pointer to the HW structure 957287990Ssbruno * @itr: u32 indicating itr value 958287990Ssbruno * 959287990Ssbruno * Set the OBFF timer based on the given interrupt rate. 960287990Ssbruno **/ 961287990Ssbrunos32 e1000_set_obff_timer(struct e1000_hw *hw, u32 itr) 962287990Ssbruno{ 963287990Ssbruno if (hw->mac.ops.set_obff_timer) 964287990Ssbruno return hw->mac.ops.set_obff_timer(hw, itr); 965287990Ssbruno 966287990Ssbruno return E1000_SUCCESS; 967287990Ssbruno} 968287990Ssbruno 969287990Ssbruno/** 970169240Sjfv * e1000_check_reset_block - Verifies PHY can be reset 971169589Sjfv * @hw: pointer to the HW structure 972169240Sjfv * 973169240Sjfv * Checks if the PHY is in a state that can be reset or if manageability 974169240Sjfv * has it tied up. This is a function pointer entry point called by drivers. 975169240Sjfv **/ 976173788Sjfvs32 e1000_check_reset_block(struct e1000_hw *hw) 977169240Sjfv{ 978177867Sjfv if (hw->phy.ops.check_reset_block) 979177867Sjfv return hw->phy.ops.check_reset_block(hw); 980173788Sjfv 981173788Sjfv return E1000_SUCCESS; 982169240Sjfv} 983169240Sjfv 984169240Sjfv/** 985169240Sjfv * e1000_read_phy_reg - Reads PHY register 986169589Sjfv * @hw: pointer to the HW structure 987169589Sjfv * @offset: the register to read 988169589Sjfv * @data: the buffer to store the 16-bit read. 989169240Sjfv * 990169240Sjfv * Reads the PHY register and returns the value in data. 991169240Sjfv * This is a function pointer entry point called by drivers. 992169240Sjfv **/ 993173788Sjfvs32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data) 994169240Sjfv{ 995177867Sjfv if (hw->phy.ops.read_reg) 996177867Sjfv return hw->phy.ops.read_reg(hw, offset, data); 997173788Sjfv 998173788Sjfv return E1000_SUCCESS; 999169240Sjfv} 1000169240Sjfv 1001169240Sjfv/** 1002169240Sjfv * e1000_write_phy_reg - Writes PHY register 1003169589Sjfv * @hw: pointer to the HW structure 1004169589Sjfv * @offset: the register to write 1005169589Sjfv * @data: the value to write. 1006169240Sjfv * 1007169240Sjfv * Writes the PHY register at offset with the value in data. 1008169240Sjfv * This is a function pointer entry point called by drivers. 1009169240Sjfv **/ 1010173788Sjfvs32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data) 1011169240Sjfv{ 1012177867Sjfv if (hw->phy.ops.write_reg) 1013177867Sjfv return hw->phy.ops.write_reg(hw, offset, data); 1014173788Sjfv 1015173788Sjfv return E1000_SUCCESS; 1016169240Sjfv} 1017169240Sjfv 1018169240Sjfv/** 1019177867Sjfv * e1000_release_phy - Generic release PHY 1020177867Sjfv * @hw: pointer to the HW structure 1021177867Sjfv * 1022177867Sjfv * Return if silicon family does not require a semaphore when accessing the 1023177867Sjfv * PHY. 1024177867Sjfv **/ 1025177867Sjfvvoid e1000_release_phy(struct e1000_hw *hw) 1026177867Sjfv{ 1027177867Sjfv if (hw->phy.ops.release) 1028177867Sjfv hw->phy.ops.release(hw); 1029177867Sjfv} 1030177867Sjfv 1031177867Sjfv/** 1032177867Sjfv * e1000_acquire_phy - Generic acquire PHY 1033177867Sjfv * @hw: pointer to the HW structure 1034177867Sjfv * 1035177867Sjfv * Return success if silicon family does not require a semaphore when 1036177867Sjfv * accessing the PHY. 1037177867Sjfv **/ 1038177867Sjfvs32 e1000_acquire_phy(struct e1000_hw *hw) 1039177867Sjfv{ 1040177867Sjfv if (hw->phy.ops.acquire) 1041177867Sjfv return hw->phy.ops.acquire(hw); 1042177867Sjfv 1043177867Sjfv return E1000_SUCCESS; 1044177867Sjfv} 1045177867Sjfv 1046177867Sjfv/** 1047185353Sjfv * e1000_cfg_on_link_up - Configure PHY upon link up 1048185353Sjfv * @hw: pointer to the HW structure 1049185353Sjfv **/ 1050185353Sjfvs32 e1000_cfg_on_link_up(struct e1000_hw *hw) 1051185353Sjfv{ 1052185353Sjfv if (hw->phy.ops.cfg_on_link_up) 1053185353Sjfv return hw->phy.ops.cfg_on_link_up(hw); 1054185353Sjfv 1055185353Sjfv return E1000_SUCCESS; 1056185353Sjfv} 1057185353Sjfv 1058185353Sjfv/** 1059169240Sjfv * e1000_read_kmrn_reg - Reads register using Kumeran interface 1060169589Sjfv * @hw: pointer to the HW structure 1061169589Sjfv * @offset: the register to read 1062169589Sjfv * @data: the location to store the 16-bit value read. 1063169240Sjfv * 1064169240Sjfv * Reads a register out of the Kumeran interface. Currently no func pointer 1065169240Sjfv * exists and all implementations are handled in the generic version of 1066169240Sjfv * this function. 1067169240Sjfv **/ 1068173788Sjfvs32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data) 1069169240Sjfv{ 1070169240Sjfv return e1000_read_kmrn_reg_generic(hw, offset, data); 1071169240Sjfv} 1072169240Sjfv 1073169240Sjfv/** 1074169240Sjfv * e1000_write_kmrn_reg - Writes register using Kumeran interface 1075169589Sjfv * @hw: pointer to the HW structure 1076169589Sjfv * @offset: the register to write 1077169589Sjfv * @data: the value to write. 1078169240Sjfv * 1079169240Sjfv * Writes a register to the Kumeran interface. Currently no func pointer 1080169240Sjfv * exists and all implementations are handled in the generic version of 1081169240Sjfv * this function. 1082169240Sjfv **/ 1083173788Sjfvs32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data) 1084169240Sjfv{ 1085169240Sjfv return e1000_write_kmrn_reg_generic(hw, offset, data); 1086169240Sjfv} 1087169240Sjfv 1088169240Sjfv/** 1089169240Sjfv * e1000_get_cable_length - Retrieves cable length estimation 1090169589Sjfv * @hw: pointer to the HW structure 1091169240Sjfv * 1092169240Sjfv * This function estimates the cable length and stores them in 1093169240Sjfv * hw->phy.min_length and hw->phy.max_length. This is a function pointer 1094169240Sjfv * entry point called by drivers. 1095169240Sjfv **/ 1096173788Sjfvs32 e1000_get_cable_length(struct e1000_hw *hw) 1097169240Sjfv{ 1098177867Sjfv if (hw->phy.ops.get_cable_length) 1099177867Sjfv return hw->phy.ops.get_cable_length(hw); 1100173788Sjfv 1101173788Sjfv return E1000_SUCCESS; 1102169240Sjfv} 1103169240Sjfv 1104169240Sjfv/** 1105169240Sjfv * e1000_get_phy_info - Retrieves PHY information from registers 1106169589Sjfv * @hw: pointer to the HW structure 1107169240Sjfv * 1108169240Sjfv * This function gets some information from various PHY registers and 1109169240Sjfv * populates hw->phy values with it. This is a function pointer entry 1110169240Sjfv * point called by drivers. 1111169240Sjfv **/ 1112173788Sjfvs32 e1000_get_phy_info(struct e1000_hw *hw) 1113169240Sjfv{ 1114177867Sjfv if (hw->phy.ops.get_info) 1115177867Sjfv return hw->phy.ops.get_info(hw); 1116173788Sjfv 1117173788Sjfv return E1000_SUCCESS; 1118169240Sjfv} 1119169240Sjfv 1120169240Sjfv/** 1121169240Sjfv * e1000_phy_hw_reset - Hard PHY reset 1122169589Sjfv * @hw: pointer to the HW structure 1123169240Sjfv * 1124169240Sjfv * Performs a hard PHY reset. This is a function pointer entry point called 1125169240Sjfv * by drivers. 1126169240Sjfv **/ 1127173788Sjfvs32 e1000_phy_hw_reset(struct e1000_hw *hw) 1128169240Sjfv{ 1129177867Sjfv if (hw->phy.ops.reset) 1130177867Sjfv return hw->phy.ops.reset(hw); 1131173788Sjfv 1132173788Sjfv return E1000_SUCCESS; 1133169240Sjfv} 1134169240Sjfv 1135169240Sjfv/** 1136169240Sjfv * e1000_phy_commit - Soft PHY reset 1137169589Sjfv * @hw: pointer to the HW structure 1138169240Sjfv * 1139169240Sjfv * Performs a soft PHY reset on those that apply. This is a function pointer 1140169240Sjfv * entry point called by drivers. 1141169240Sjfv **/ 1142173788Sjfvs32 e1000_phy_commit(struct e1000_hw *hw) 1143169240Sjfv{ 1144177867Sjfv if (hw->phy.ops.commit) 1145177867Sjfv return hw->phy.ops.commit(hw); 1146173788Sjfv 1147173788Sjfv return E1000_SUCCESS; 1148169240Sjfv} 1149169240Sjfv 1150169240Sjfv/** 1151177867Sjfv * e1000_set_d0_lplu_state - Sets low power link up state for D0 1152169589Sjfv * @hw: pointer to the HW structure 1153169589Sjfv * @active: boolean used to enable/disable lplu 1154169240Sjfv * 1155169240Sjfv * Success returns 0, Failure returns 1 1156169240Sjfv * 1157169240Sjfv * The low power link up (lplu) state is set to the power management level D0 1158177867Sjfv * and SmartSpeed is disabled when active is TRUE, else clear lplu for D0 1159169240Sjfv * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU 1160169240Sjfv * is used during Dx states where the power conservation is most important. 1161169240Sjfv * During driver activity, SmartSpeed should be enabled so performance is 1162169240Sjfv * maintained. This is a function pointer entry point called by drivers. 1163169240Sjfv **/ 1164173788Sjfvs32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active) 1165169240Sjfv{ 1166177867Sjfv if (hw->phy.ops.set_d0_lplu_state) 1167177867Sjfv return hw->phy.ops.set_d0_lplu_state(hw, active); 1168173788Sjfv 1169173788Sjfv return E1000_SUCCESS; 1170169240Sjfv} 1171169240Sjfv 1172169240Sjfv/** 1173169240Sjfv * e1000_set_d3_lplu_state - Sets low power link up state for D3 1174169589Sjfv * @hw: pointer to the HW structure 1175169589Sjfv * @active: boolean used to enable/disable lplu 1176169240Sjfv * 1177169240Sjfv * Success returns 0, Failure returns 1 1178169240Sjfv * 1179169240Sjfv * The low power link up (lplu) state is set to the power management level D3 1180177867Sjfv * and SmartSpeed is disabled when active is TRUE, else clear lplu for D3 1181169240Sjfv * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU 1182169240Sjfv * is used during Dx states where the power conservation is most important. 1183169240Sjfv * During driver activity, SmartSpeed should be enabled so performance is 1184169240Sjfv * maintained. This is a function pointer entry point called by drivers. 1185169240Sjfv **/ 1186173788Sjfvs32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active) 1187169240Sjfv{ 1188177867Sjfv if (hw->phy.ops.set_d3_lplu_state) 1189177867Sjfv return hw->phy.ops.set_d3_lplu_state(hw, active); 1190173788Sjfv 1191173788Sjfv return E1000_SUCCESS; 1192169240Sjfv} 1193169240Sjfv 1194169240Sjfv/** 1195169240Sjfv * e1000_read_mac_addr - Reads MAC address 1196169589Sjfv * @hw: pointer to the HW structure 1197169240Sjfv * 1198169240Sjfv * Reads the MAC address out of the adapter and stores it in the HW structure. 1199169240Sjfv * Currently no func pointer exists and all implementations are handled in the 1200169240Sjfv * generic version of this function. 1201169240Sjfv **/ 1202173788Sjfvs32 e1000_read_mac_addr(struct e1000_hw *hw) 1203169240Sjfv{ 1204177867Sjfv if (hw->mac.ops.read_mac_addr) 1205177867Sjfv return hw->mac.ops.read_mac_addr(hw); 1206173788Sjfv 1207169240Sjfv return e1000_read_mac_addr_generic(hw); 1208169240Sjfv} 1209169240Sjfv 1210169240Sjfv/** 1211213234Sjfv * e1000_read_pba_string - Read device part number string 1212213234Sjfv * @hw: pointer to the HW structure 1213213234Sjfv * @pba_num: pointer to device part number 1214213234Sjfv * @pba_num_size: size of part number buffer 1215213234Sjfv * 1216213234Sjfv * Reads the product board assembly (PBA) number from the EEPROM and stores 1217213234Sjfv * the value in pba_num. 1218213234Sjfv * Currently no func pointer exists and all implementations are handled in the 1219213234Sjfv * generic version of this function. 1220213234Sjfv **/ 1221213234Sjfvs32 e1000_read_pba_string(struct e1000_hw *hw, u8 *pba_num, u32 pba_num_size) 1222213234Sjfv{ 1223213234Sjfv return e1000_read_pba_string_generic(hw, pba_num, pba_num_size); 1224213234Sjfv} 1225213234Sjfv 1226213234Sjfv/** 1227213234Sjfv * e1000_read_pba_length - Read device part number string length 1228213234Sjfv * @hw: pointer to the HW structure 1229213234Sjfv * @pba_num_size: size of part number buffer 1230213234Sjfv * 1231213234Sjfv * Reads the product board assembly (PBA) number length from the EEPROM and 1232213234Sjfv * stores the value in pba_num. 1233213234Sjfv * Currently no func pointer exists and all implementations are handled in the 1234213234Sjfv * generic version of this function. 1235213234Sjfv **/ 1236213234Sjfvs32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size) 1237213234Sjfv{ 1238213234Sjfv return e1000_read_pba_length_generic(hw, pba_num_size); 1239213234Sjfv} 1240213234Sjfv 1241213234Sjfv/** 1242169240Sjfv * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum 1243169589Sjfv * @hw: pointer to the HW structure 1244169240Sjfv * 1245169240Sjfv * Validates the NVM checksum is correct. This is a function pointer entry 1246169240Sjfv * point called by drivers. 1247169240Sjfv **/ 1248173788Sjfvs32 e1000_validate_nvm_checksum(struct e1000_hw *hw) 1249169240Sjfv{ 1250177867Sjfv if (hw->nvm.ops.validate) 1251177867Sjfv return hw->nvm.ops.validate(hw); 1252173788Sjfv 1253173788Sjfv return -E1000_ERR_CONFIG; 1254169240Sjfv} 1255169240Sjfv 1256169240Sjfv/** 1257169240Sjfv * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum 1258169589Sjfv * @hw: pointer to the HW structure 1259169240Sjfv * 1260169240Sjfv * Updates the NVM checksum. Currently no func pointer exists and all 1261169240Sjfv * implementations are handled in the generic version of this function. 1262169240Sjfv **/ 1263173788Sjfvs32 e1000_update_nvm_checksum(struct e1000_hw *hw) 1264169240Sjfv{ 1265177867Sjfv if (hw->nvm.ops.update) 1266177867Sjfv return hw->nvm.ops.update(hw); 1267173788Sjfv 1268173788Sjfv return -E1000_ERR_CONFIG; 1269169240Sjfv} 1270169240Sjfv 1271169240Sjfv/** 1272169240Sjfv * e1000_reload_nvm - Reloads EEPROM 1273169589Sjfv * @hw: pointer to the HW structure 1274169240Sjfv * 1275169240Sjfv * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the 1276169240Sjfv * extended control register. 1277169240Sjfv **/ 1278173788Sjfvvoid e1000_reload_nvm(struct e1000_hw *hw) 1279169240Sjfv{ 1280177867Sjfv if (hw->nvm.ops.reload) 1281177867Sjfv hw->nvm.ops.reload(hw); 1282169240Sjfv} 1283169240Sjfv 1284169240Sjfv/** 1285169240Sjfv * e1000_read_nvm - Reads NVM (EEPROM) 1286169589Sjfv * @hw: pointer to the HW structure 1287169589Sjfv * @offset: the word offset to read 1288169589Sjfv * @words: number of 16-bit words to read 1289169589Sjfv * @data: pointer to the properly sized buffer for the data. 1290169240Sjfv * 1291169240Sjfv * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function 1292169240Sjfv * pointer entry point called by drivers. 1293169240Sjfv **/ 1294173788Sjfvs32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) 1295169240Sjfv{ 1296177867Sjfv if (hw->nvm.ops.read) 1297177867Sjfv return hw->nvm.ops.read(hw, offset, words, data); 1298173788Sjfv 1299173788Sjfv return -E1000_ERR_CONFIG; 1300169240Sjfv} 1301169240Sjfv 1302169240Sjfv/** 1303169240Sjfv * e1000_write_nvm - Writes to NVM (EEPROM) 1304169589Sjfv * @hw: pointer to the HW structure 1305169589Sjfv * @offset: the word offset to read 1306169589Sjfv * @words: number of 16-bit words to write 1307169589Sjfv * @data: pointer to the properly sized buffer for the data. 1308169240Sjfv * 1309169240Sjfv * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function 1310169240Sjfv * pointer entry point called by drivers. 1311169240Sjfv **/ 1312173788Sjfvs32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) 1313169240Sjfv{ 1314177867Sjfv if (hw->nvm.ops.write) 1315177867Sjfv return hw->nvm.ops.write(hw, offset, words, data); 1316173788Sjfv 1317173788Sjfv return E1000_SUCCESS; 1318169240Sjfv} 1319169240Sjfv 1320169240Sjfv/** 1321169240Sjfv * e1000_write_8bit_ctrl_reg - Writes 8bit Control register 1322169589Sjfv * @hw: pointer to the HW structure 1323169589Sjfv * @reg: 32bit register offset 1324169589Sjfv * @offset: the register to write 1325169589Sjfv * @data: the value to write. 1326169240Sjfv * 1327169240Sjfv * Writes the PHY register at offset with the value in data. 1328169240Sjfv * This is a function pointer entry point called by drivers. 1329169240Sjfv **/ 1330176667Sjfvs32 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset, 1331228386Sjfv u8 data) 1332169240Sjfv{ 1333169240Sjfv return e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data); 1334169240Sjfv} 1335173788Sjfv 1336173788Sjfv/** 1337173788Sjfv * e1000_power_up_phy - Restores link in case of PHY power down 1338173788Sjfv * @hw: pointer to the HW structure 1339173788Sjfv * 1340173788Sjfv * The phy may be powered down to save power, to turn off link when the 1341173788Sjfv * driver is unloaded, or wake on lan is not enabled (among others). 1342173788Sjfv **/ 1343173788Sjfvvoid e1000_power_up_phy(struct e1000_hw *hw) 1344173788Sjfv{ 1345177867Sjfv if (hw->phy.ops.power_up) 1346177867Sjfv hw->phy.ops.power_up(hw); 1347173788Sjfv 1348173788Sjfv e1000_setup_link(hw); 1349173788Sjfv} 1350173788Sjfv 1351173788Sjfv/** 1352176667Sjfv * e1000_power_down_phy - Power down PHY 1353173788Sjfv * @hw: pointer to the HW structure 1354173788Sjfv * 1355173788Sjfv * The phy may be powered down to save power, to turn off link when the 1356173788Sjfv * driver is unloaded, or wake on lan is not enabled (among others). 1357173788Sjfv **/ 1358173788Sjfvvoid e1000_power_down_phy(struct e1000_hw *hw) 1359173788Sjfv{ 1360177867Sjfv if (hw->phy.ops.power_down) 1361177867Sjfv hw->phy.ops.power_down(hw); 1362173788Sjfv} 1363173788Sjfv 1364181027Sjfv/** 1365203049Sjfv * e1000_power_up_fiber_serdes_link - Power up serdes link 1366203049Sjfv * @hw: pointer to the HW structure 1367203049Sjfv * 1368203049Sjfv * Power on the optics and PCS. 1369203049Sjfv **/ 1370203049Sjfvvoid e1000_power_up_fiber_serdes_link(struct e1000_hw *hw) 1371203049Sjfv{ 1372203049Sjfv if (hw->mac.ops.power_up_serdes) 1373203049Sjfv hw->mac.ops.power_up_serdes(hw); 1374203049Sjfv} 1375203049Sjfv 1376203049Sjfv/** 1377181027Sjfv * e1000_shutdown_fiber_serdes_link - Remove link during power down 1378181027Sjfv * @hw: pointer to the HW structure 1379181027Sjfv * 1380181027Sjfv * Shutdown the optics and PCS on driver unload. 1381181027Sjfv **/ 1382181027Sjfvvoid e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw) 1383181027Sjfv{ 1384181027Sjfv if (hw->mac.ops.shutdown_serdes) 1385181027Sjfv hw->mac.ops.shutdown_serdes(hw); 1386181027Sjfv} 1387181027Sjfv 1388