e1000_api.c revision 238148
1177867Sjfv/******************************************************************************
2169240Sjfv
3238148Sjfv  Copyright (c) 2001-2012, 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: head/sys/dev/e1000/e1000_api.c 238148 2012-07-05 20:26:57Z jfv $*/
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;
292177867Sjfv	case E1000_DEV_ID_82575EB_COPPER:
293177867Sjfv	case E1000_DEV_ID_82575EB_FIBER_SERDES:
294177867Sjfv	case E1000_DEV_ID_82575GB_QUAD_COPPER:
295177867Sjfv		mac->type = e1000_82575;
296169240Sjfv		break;
297181027Sjfv	case E1000_DEV_ID_82576:
298181027Sjfv	case E1000_DEV_ID_82576_FIBER:
299181027Sjfv	case E1000_DEV_ID_82576_SERDES:
300181027Sjfv	case E1000_DEV_ID_82576_QUAD_COPPER:
301213234Sjfv	case E1000_DEV_ID_82576_QUAD_COPPER_ET2:
302190872Sjfv	case E1000_DEV_ID_82576_NS:
303200243Sjfv	case E1000_DEV_ID_82576_NS_SERDES:
304194865Sjfv	case E1000_DEV_ID_82576_SERDES_QUAD:
305181027Sjfv		mac->type = e1000_82576;
306181027Sjfv		break;
307200243Sjfv	case E1000_DEV_ID_82580_COPPER:
308200243Sjfv	case E1000_DEV_ID_82580_FIBER:
309200243Sjfv	case E1000_DEV_ID_82580_SERDES:
310200243Sjfv	case E1000_DEV_ID_82580_SGMII:
311200243Sjfv	case E1000_DEV_ID_82580_COPPER_DUAL:
312213234Sjfv	case E1000_DEV_ID_82580_QUAD_FIBER:
313215789Sjfv	case E1000_DEV_ID_DH89XXCC_SGMII:
314215789Sjfv	case E1000_DEV_ID_DH89XXCC_SERDES:
315218530Sjfv	case E1000_DEV_ID_DH89XXCC_BACKPLANE:
316218530Sjfv	case E1000_DEV_ID_DH89XXCC_SFP:
317200243Sjfv		mac->type = e1000_82580;
318200243Sjfv		break;
319218530Sjfv	case E1000_DEV_ID_I350_COPPER:
320218530Sjfv	case E1000_DEV_ID_I350_FIBER:
321218530Sjfv	case E1000_DEV_ID_I350_SERDES:
322218530Sjfv	case E1000_DEV_ID_I350_SGMII:
323228386Sjfv	case E1000_DEV_ID_I350_DA4:
324218530Sjfv		mac->type = e1000_i350;
325218530Sjfv		break;
326238148Sjfv	case E1000_DEV_ID_I210_COPPER:
327238148Sjfv	case E1000_DEV_ID_I210_COPPER_OEM1:
328238148Sjfv	case E1000_DEV_ID_I210_COPPER_IT:
329238148Sjfv	case E1000_DEV_ID_I210_FIBER:
330238148Sjfv	case E1000_DEV_ID_I210_SERDES:
331238148Sjfv	case E1000_DEV_ID_I210_SGMII:
332238148Sjfv		mac->type = e1000_i210;
333238148Sjfv		break;
334238148Sjfv	case E1000_DEV_ID_I211_COPPER:
335238148Sjfv	mac->type = e1000_i211;
336238148Sjfv	break;
337209616Sjfv	case E1000_DEV_ID_82576_VF:
338209616Sjfv		mac->type = e1000_vfadapt;
339209616Sjfv		break;
340218530Sjfv	case E1000_DEV_ID_I350_VF:
341218530Sjfv		mac->type = e1000_vfadapt_i350;
342218530Sjfv		break;
343169240Sjfv	default:
344169240Sjfv		/* Should never have loaded on this device */
345169240Sjfv		ret_val = -E1000_ERR_MAC_INIT;
346169240Sjfv		break;
347169240Sjfv	}
348169240Sjfv
349169240Sjfv	return ret_val;
350169240Sjfv}
351169240Sjfv
352169240Sjfv/**
353169240Sjfv *  e1000_setup_init_funcs - Initializes function pointers
354169589Sjfv *  @hw: pointer to the HW structure
355169589Sjfv *  @init_device: TRUE will initialize the rest of the function pointers
356228386Sjfv *		  getting the device ready for use.  FALSE will only set
357228386Sjfv *		  MAC type and the function pointers for the other init
358228386Sjfv *		  functions.  Passing FALSE will not generate any hardware
359228386Sjfv *		  reads or writes.
360169240Sjfv *
361169240Sjfv *  This function must be called by a driver in order to use the rest
362169240Sjfv *  of the 'shared' code files. Called by drivers only.
363169240Sjfv **/
364173788Sjfvs32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
365169240Sjfv{
366169240Sjfv	s32 ret_val;
367169240Sjfv
368173788Sjfv	/* Can't do much good without knowing the MAC type. */
369169240Sjfv	ret_val = e1000_set_mac_type(hw);
370169240Sjfv	if (ret_val) {
371169240Sjfv		DEBUGOUT("ERROR: MAC type could not be set properly.\n");
372169240Sjfv		goto out;
373169240Sjfv	}
374169240Sjfv
375169240Sjfv	if (!hw->hw_addr) {
376169240Sjfv		DEBUGOUT("ERROR: Registers not mapped\n");
377169240Sjfv		ret_val = -E1000_ERR_CONFIG;
378169240Sjfv		goto out;
379169240Sjfv	}
380169240Sjfv
381173788Sjfv	/*
382177867Sjfv	 * Init function pointers to generic implementations. We do this first
383177867Sjfv	 * allowing a driver module to override it afterward.
384169240Sjfv	 */
385177867Sjfv	e1000_init_mac_ops_generic(hw);
386177867Sjfv	e1000_init_phy_ops_generic(hw);
387177867Sjfv	e1000_init_nvm_ops_generic(hw);
388209616Sjfv	e1000_init_mbx_ops_generic(hw);
389169240Sjfv
390173788Sjfv	/*
391173788Sjfv	 * Set up the init function pointers. These are functions within the
392169240Sjfv	 * adapter family file that sets up function pointers for the rest of
393169240Sjfv	 * the functions in that family.
394169240Sjfv	 */
395169240Sjfv	switch (hw->mac.type) {
396169240Sjfv	case e1000_82542:
397169240Sjfv		e1000_init_function_pointers_82542(hw);
398169240Sjfv		break;
399169240Sjfv	case e1000_82543:
400169240Sjfv	case e1000_82544:
401169240Sjfv		e1000_init_function_pointers_82543(hw);
402169240Sjfv		break;
403169240Sjfv	case e1000_82540:
404169240Sjfv	case e1000_82545:
405169240Sjfv	case e1000_82545_rev_3:
406169240Sjfv	case e1000_82546:
407169240Sjfv	case e1000_82546_rev_3:
408169240Sjfv		e1000_init_function_pointers_82540(hw);
409169240Sjfv		break;
410169240Sjfv	case e1000_82541:
411169240Sjfv	case e1000_82541_rev_2:
412169240Sjfv	case e1000_82547:
413169240Sjfv	case e1000_82547_rev_2:
414169240Sjfv		e1000_init_function_pointers_82541(hw);
415169240Sjfv		break;
416169240Sjfv	case e1000_82571:
417169240Sjfv	case e1000_82572:
418169240Sjfv	case e1000_82573:
419178523Sjfv	case e1000_82574:
420194865Sjfv	case e1000_82583:
421169240Sjfv		e1000_init_function_pointers_82571(hw);
422169240Sjfv		break;
423169240Sjfv	case e1000_80003es2lan:
424169240Sjfv		e1000_init_function_pointers_80003es2lan(hw);
425169240Sjfv		break;
426169240Sjfv	case e1000_ich8lan:
427169240Sjfv	case e1000_ich9lan:
428178523Sjfv	case e1000_ich10lan:
429194865Sjfv	case e1000_pchlan:
430213234Sjfv	case e1000_pch2lan:
431169240Sjfv		e1000_init_function_pointers_ich8lan(hw);
432169240Sjfv		break;
433177867Sjfv	case e1000_82575:
434181027Sjfv	case e1000_82576:
435200243Sjfv	case e1000_82580:
436218530Sjfv	case e1000_i350:
437177867Sjfv		e1000_init_function_pointers_82575(hw);
438177867Sjfv		break;
439238148Sjfv	case e1000_i210:
440238148Sjfv	case e1000_i211:
441238148Sjfv		e1000_init_function_pointers_i210(hw);
442238148Sjfv		break;
443209616Sjfv	case e1000_vfadapt:
444209616Sjfv		e1000_init_function_pointers_vf(hw);
445209616Sjfv		break;
446218530Sjfv	case e1000_vfadapt_i350:
447218530Sjfv		e1000_init_function_pointers_vf(hw);
448218530Sjfv		break;
449169240Sjfv	default:
450169240Sjfv		DEBUGOUT("Hardware not supported\n");
451169240Sjfv		ret_val = -E1000_ERR_CONFIG;
452169240Sjfv		break;
453169240Sjfv	}
454169240Sjfv
455173788Sjfv	/*
456173788Sjfv	 * Initialize the rest of the function pointers. These require some
457169240Sjfv	 * register reads/writes in some cases.
458169240Sjfv	 */
459173788Sjfv	if (!(ret_val) && init_device) {
460169240Sjfv		ret_val = e1000_init_mac_params(hw);
461169240Sjfv		if (ret_val)
462169240Sjfv			goto out;
463169240Sjfv
464169240Sjfv		ret_val = e1000_init_nvm_params(hw);
465169240Sjfv		if (ret_val)
466169240Sjfv			goto out;
467169240Sjfv
468169240Sjfv		ret_val = e1000_init_phy_params(hw);
469169240Sjfv		if (ret_val)
470169240Sjfv			goto out;
471209616Sjfv
472209616Sjfv		ret_val = e1000_init_mbx_params(hw);
473209616Sjfv		if (ret_val)
474209616Sjfv			goto out;
475169240Sjfv	}
476169240Sjfv
477169240Sjfvout:
478169240Sjfv	return ret_val;
479169240Sjfv}
480169240Sjfv
481169240Sjfv/**
482169240Sjfv *  e1000_get_bus_info - Obtain bus information for adapter
483169589Sjfv *  @hw: pointer to the HW structure
484169240Sjfv *
485169240Sjfv *  This will obtain information about the HW bus for which the
486176667Sjfv *  adapter is attached and stores it in the hw structure. This is a
487169240Sjfv *  function pointer entry point called by drivers.
488169240Sjfv **/
489173788Sjfvs32 e1000_get_bus_info(struct e1000_hw *hw)
490169240Sjfv{
491177867Sjfv	if (hw->mac.ops.get_bus_info)
492177867Sjfv		return hw->mac.ops.get_bus_info(hw);
493173788Sjfv
494173788Sjfv	return E1000_SUCCESS;
495169240Sjfv}
496169240Sjfv
497169240Sjfv/**
498169240Sjfv *  e1000_clear_vfta - Clear VLAN filter table
499169589Sjfv *  @hw: pointer to the HW structure
500169240Sjfv *
501169240Sjfv *  This clears the VLAN filter table on the adapter. This is a function
502169240Sjfv *  pointer entry point called by drivers.
503169240Sjfv **/
504173788Sjfvvoid e1000_clear_vfta(struct e1000_hw *hw)
505169240Sjfv{
506177867Sjfv	if (hw->mac.ops.clear_vfta)
507178523Sjfv		hw->mac.ops.clear_vfta(hw);
508169240Sjfv}
509169240Sjfv
510169240Sjfv/**
511169240Sjfv *  e1000_write_vfta - Write value to VLAN filter table
512169589Sjfv *  @hw: pointer to the HW structure
513169589Sjfv *  @offset: the 32-bit offset in which to write the value to.
514169589Sjfv *  @value: the 32-bit value to write at location offset.
515169240Sjfv *
516169240Sjfv *  This writes a 32-bit value to a 32-bit offset in the VLAN filter
517169240Sjfv *  table. This is a function pointer entry point called by drivers.
518169240Sjfv **/
519173788Sjfvvoid e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
520169240Sjfv{
521177867Sjfv	if (hw->mac.ops.write_vfta)
522177867Sjfv		hw->mac.ops.write_vfta(hw, offset, value);
523169240Sjfv}
524169240Sjfv
525169240Sjfv/**
526173788Sjfv *  e1000_update_mc_addr_list - Update Multicast addresses
527169589Sjfv *  @hw: pointer to the HW structure
528169589Sjfv *  @mc_addr_list: array of multicast addresses to program
529169589Sjfv *  @mc_addr_count: number of multicast addresses to program
530169240Sjfv *
531190872Sjfv *  Updates the Multicast Table Array.
532169240Sjfv *  The caller must have a packed mc_addr_list of multicast addresses.
533169240Sjfv **/
534173788Sjfvvoid e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
535228386Sjfv			       u32 mc_addr_count)
536169240Sjfv{
537177867Sjfv	if (hw->mac.ops.update_mc_addr_list)
538190872Sjfv		hw->mac.ops.update_mc_addr_list(hw, mc_addr_list,
539228386Sjfv						mc_addr_count);
540169240Sjfv}
541169240Sjfv
542169240Sjfv/**
543169240Sjfv *  e1000_force_mac_fc - Force MAC flow control
544169589Sjfv *  @hw: pointer to the HW structure
545169240Sjfv *
546169240Sjfv *  Force the MAC's flow control settings. Currently no func pointer exists
547169240Sjfv *  and all implementations are handled in the generic version of this
548169240Sjfv *  function.
549169240Sjfv **/
550173788Sjfvs32 e1000_force_mac_fc(struct e1000_hw *hw)
551169240Sjfv{
552169240Sjfv	return e1000_force_mac_fc_generic(hw);
553169240Sjfv}
554169240Sjfv
555169240Sjfv/**
556169240Sjfv *  e1000_check_for_link - Check/Store link connection
557169589Sjfv *  @hw: pointer to the HW structure
558169240Sjfv *
559169240Sjfv *  This checks the link condition of the adapter and stores the
560169240Sjfv *  results in the hw->mac structure. This is a function pointer entry
561169240Sjfv *  point called by drivers.
562169240Sjfv **/
563173788Sjfvs32 e1000_check_for_link(struct e1000_hw *hw)
564169240Sjfv{
565177867Sjfv	if (hw->mac.ops.check_for_link)
566177867Sjfv		return hw->mac.ops.check_for_link(hw);
567173788Sjfv
568173788Sjfv	return -E1000_ERR_CONFIG;
569169240Sjfv}
570169240Sjfv
571169240Sjfv/**
572169240Sjfv *  e1000_check_mng_mode - Check management mode
573169589Sjfv *  @hw: pointer to the HW structure
574169240Sjfv *
575169240Sjfv *  This checks if the adapter has manageability enabled.
576169240Sjfv *  This is a function pointer entry point called by drivers.
577169240Sjfv **/
578173788Sjfvbool e1000_check_mng_mode(struct e1000_hw *hw)
579169240Sjfv{
580177867Sjfv	if (hw->mac.ops.check_mng_mode)
581177867Sjfv		return hw->mac.ops.check_mng_mode(hw);
582173788Sjfv
583173788Sjfv	return FALSE;
584169240Sjfv}
585169240Sjfv
586169240Sjfv/**
587169240Sjfv *  e1000_mng_write_dhcp_info - Writes DHCP info to host interface
588169589Sjfv *  @hw: pointer to the HW structure
589169589Sjfv *  @buffer: pointer to the host interface
590169589Sjfv *  @length: size of the buffer
591169240Sjfv *
592169240Sjfv *  Writes the DHCP information to the host interface.
593169240Sjfv **/
594173788Sjfvs32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
595169240Sjfv{
596169240Sjfv	return e1000_mng_write_dhcp_info_generic(hw, buffer, length);
597169240Sjfv}
598169240Sjfv
599169240Sjfv/**
600169240Sjfv *  e1000_reset_hw - Reset hardware
601169589Sjfv *  @hw: pointer to the HW structure
602169240Sjfv *
603169240Sjfv *  This resets the hardware into a known state. This is a function pointer
604169240Sjfv *  entry point called by drivers.
605169240Sjfv **/
606173788Sjfvs32 e1000_reset_hw(struct e1000_hw *hw)
607169240Sjfv{
608177867Sjfv	if (hw->mac.ops.reset_hw)
609177867Sjfv		return hw->mac.ops.reset_hw(hw);
610173788Sjfv
611173788Sjfv	return -E1000_ERR_CONFIG;
612169240Sjfv}
613169240Sjfv
614169240Sjfv/**
615169240Sjfv *  e1000_init_hw - Initialize hardware
616169589Sjfv *  @hw: pointer to the HW structure
617169240Sjfv *
618169240Sjfv *  This inits the hardware readying it for operation. This is a function
619169240Sjfv *  pointer entry point called by drivers.
620169240Sjfv **/
621173788Sjfvs32 e1000_init_hw(struct e1000_hw *hw)
622169240Sjfv{
623177867Sjfv	if (hw->mac.ops.init_hw)
624177867Sjfv		return hw->mac.ops.init_hw(hw);
625173788Sjfv
626173788Sjfv	return -E1000_ERR_CONFIG;
627169240Sjfv}
628169240Sjfv
629169240Sjfv/**
630169240Sjfv *  e1000_setup_link - Configures link and flow control
631169589Sjfv *  @hw: pointer to the HW structure
632169240Sjfv *
633169240Sjfv *  This configures link and flow control settings for the adapter. This
634169240Sjfv *  is a function pointer entry point called by drivers. While modules can
635169240Sjfv *  also call this, they probably call their own version of this function.
636169240Sjfv **/
637173788Sjfvs32 e1000_setup_link(struct e1000_hw *hw)
638169240Sjfv{
639177867Sjfv	if (hw->mac.ops.setup_link)
640177867Sjfv		return hw->mac.ops.setup_link(hw);
641173788Sjfv
642173788Sjfv	return -E1000_ERR_CONFIG;
643169240Sjfv}
644169240Sjfv
645169240Sjfv/**
646169240Sjfv *  e1000_get_speed_and_duplex - Returns current speed and duplex
647169589Sjfv *  @hw: pointer to the HW structure
648169589Sjfv *  @speed: pointer to a 16-bit value to store the speed
649169589Sjfv *  @duplex: pointer to a 16-bit value to store the duplex.
650169240Sjfv *
651169240Sjfv *  This returns the speed and duplex of the adapter in the two 'out'
652169240Sjfv *  variables passed in. This is a function pointer entry point called
653169240Sjfv *  by drivers.
654169240Sjfv **/
655173788Sjfvs32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
656169240Sjfv{
657177867Sjfv	if (hw->mac.ops.get_link_up_info)
658177867Sjfv		return hw->mac.ops.get_link_up_info(hw, speed, duplex);
659173788Sjfv
660173788Sjfv	return -E1000_ERR_CONFIG;
661169240Sjfv}
662169240Sjfv
663169240Sjfv/**
664169240Sjfv *  e1000_setup_led - Configures SW controllable LED
665169589Sjfv *  @hw: pointer to the HW structure
666169240Sjfv *
667169240Sjfv *  This prepares the SW controllable LED for use and saves the current state
668169240Sjfv *  of the LED so it can be later restored. This is a function pointer entry
669169240Sjfv *  point called by drivers.
670169240Sjfv **/
671173788Sjfvs32 e1000_setup_led(struct e1000_hw *hw)
672169240Sjfv{
673177867Sjfv	if (hw->mac.ops.setup_led)
674177867Sjfv		return hw->mac.ops.setup_led(hw);
675173788Sjfv
676173788Sjfv	return E1000_SUCCESS;
677169240Sjfv}
678169240Sjfv
679169240Sjfv/**
680169240Sjfv *  e1000_cleanup_led - Restores SW controllable LED
681169589Sjfv *  @hw: pointer to the HW structure
682169240Sjfv *
683169240Sjfv *  This restores the SW controllable LED to the value saved off by
684169240Sjfv *  e1000_setup_led. This is a function pointer entry point called by drivers.
685169240Sjfv **/
686173788Sjfvs32 e1000_cleanup_led(struct e1000_hw *hw)
687169240Sjfv{
688177867Sjfv	if (hw->mac.ops.cleanup_led)
689177867Sjfv		return hw->mac.ops.cleanup_led(hw);
690173788Sjfv
691173788Sjfv	return E1000_SUCCESS;
692169240Sjfv}
693169240Sjfv
694169240Sjfv/**
695169240Sjfv *  e1000_blink_led - Blink SW controllable LED
696169589Sjfv *  @hw: pointer to the HW structure
697169240Sjfv *
698169240Sjfv *  This starts the adapter LED blinking. Request the LED to be setup first
699169240Sjfv *  and cleaned up after. This is a function pointer entry point called by
700169240Sjfv *  drivers.
701169240Sjfv **/
702173788Sjfvs32 e1000_blink_led(struct e1000_hw *hw)
703169240Sjfv{
704177867Sjfv	if (hw->mac.ops.blink_led)
705177867Sjfv		return hw->mac.ops.blink_led(hw);
706173788Sjfv
707173788Sjfv	return E1000_SUCCESS;
708169240Sjfv}
709169240Sjfv
710169240Sjfv/**
711190872Sjfv *  e1000_id_led_init - store LED configurations in SW
712190872Sjfv *  @hw: pointer to the HW structure
713190872Sjfv *
714190872Sjfv *  Initializes the LED config in SW. This is a function pointer entry point
715190872Sjfv *  called by drivers.
716190872Sjfv **/
717190872Sjfvs32 e1000_id_led_init(struct e1000_hw *hw)
718190872Sjfv{
719190872Sjfv	if (hw->mac.ops.id_led_init)
720190872Sjfv		return hw->mac.ops.id_led_init(hw);
721190872Sjfv
722190872Sjfv	return E1000_SUCCESS;
723190872Sjfv}
724190872Sjfv
725190872Sjfv/**
726169240Sjfv *  e1000_led_on - Turn on SW controllable LED
727169589Sjfv *  @hw: pointer to the HW structure
728169240Sjfv *
729169240Sjfv *  Turns the SW defined LED on. This is a function pointer entry point
730169240Sjfv *  called by drivers.
731169240Sjfv **/
732173788Sjfvs32 e1000_led_on(struct e1000_hw *hw)
733169240Sjfv{
734177867Sjfv	if (hw->mac.ops.led_on)
735177867Sjfv		return hw->mac.ops.led_on(hw);
736173788Sjfv
737173788Sjfv	return E1000_SUCCESS;
738169240Sjfv}
739169240Sjfv
740169240Sjfv/**
741169240Sjfv *  e1000_led_off - Turn off SW controllable LED
742169589Sjfv *  @hw: pointer to the HW structure
743169240Sjfv *
744169240Sjfv *  Turns the SW defined LED off. This is a function pointer entry point
745169240Sjfv *  called by drivers.
746169240Sjfv **/
747173788Sjfvs32 e1000_led_off(struct e1000_hw *hw)
748169240Sjfv{
749177867Sjfv	if (hw->mac.ops.led_off)
750177867Sjfv		return hw->mac.ops.led_off(hw);
751173788Sjfv
752173788Sjfv	return E1000_SUCCESS;
753169240Sjfv}
754169240Sjfv
755169240Sjfv/**
756169240Sjfv *  e1000_reset_adaptive - Reset adaptive IFS
757169589Sjfv *  @hw: pointer to the HW structure
758169240Sjfv *
759169240Sjfv *  Resets the adaptive IFS. Currently no func pointer exists and all
760169240Sjfv *  implementations are handled in the generic version of this function.
761169240Sjfv **/
762173788Sjfvvoid e1000_reset_adaptive(struct e1000_hw *hw)
763169240Sjfv{
764169240Sjfv	e1000_reset_adaptive_generic(hw);
765169240Sjfv}
766169240Sjfv
767169240Sjfv/**
768169240Sjfv *  e1000_update_adaptive - Update adaptive IFS
769169589Sjfv *  @hw: pointer to the HW structure
770169240Sjfv *
771169240Sjfv *  Updates adapter IFS. Currently no func pointer exists and all
772169240Sjfv *  implementations are handled in the generic version of this function.
773169240Sjfv **/
774173788Sjfvvoid e1000_update_adaptive(struct e1000_hw *hw)
775169240Sjfv{
776169240Sjfv	e1000_update_adaptive_generic(hw);
777169240Sjfv}
778169240Sjfv
779169240Sjfv/**
780169240Sjfv *  e1000_disable_pcie_master - Disable PCI-Express master access
781169589Sjfv *  @hw: pointer to the HW structure
782169240Sjfv *
783169240Sjfv *  Disables PCI-Express master access and verifies there are no pending
784169240Sjfv *  requests. Currently no func pointer exists and all implementations are
785169240Sjfv *  handled in the generic version of this function.
786169240Sjfv **/
787173788Sjfvs32 e1000_disable_pcie_master(struct e1000_hw *hw)
788169240Sjfv{
789169240Sjfv	return e1000_disable_pcie_master_generic(hw);
790169240Sjfv}
791169240Sjfv
792169240Sjfv/**
793169240Sjfv *  e1000_config_collision_dist - Configure collision distance
794169589Sjfv *  @hw: pointer to the HW structure
795169240Sjfv *
796169240Sjfv *  Configures the collision distance to the default value and is used
797169240Sjfv *  during link setup.
798169240Sjfv **/
799173788Sjfvvoid e1000_config_collision_dist(struct e1000_hw *hw)
800169240Sjfv{
801177867Sjfv	if (hw->mac.ops.config_collision_dist)
802177867Sjfv		hw->mac.ops.config_collision_dist(hw);
803169240Sjfv}
804169240Sjfv
805169240Sjfv/**
806169240Sjfv *  e1000_rar_set - Sets a receive address register
807169589Sjfv *  @hw: pointer to the HW structure
808169589Sjfv *  @addr: address to set the RAR to
809169589Sjfv *  @index: the RAR to set
810169240Sjfv *
811169240Sjfv *  Sets a Receive Address Register (RAR) to the specified address.
812169240Sjfv **/
813173788Sjfvvoid e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
814169240Sjfv{
815177867Sjfv	if (hw->mac.ops.rar_set)
816177867Sjfv		hw->mac.ops.rar_set(hw, addr, index);
817169240Sjfv}
818169240Sjfv
819169240Sjfv/**
820169240Sjfv *  e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
821169589Sjfv *  @hw: pointer to the HW structure
822169240Sjfv *
823169240Sjfv *  Ensures that the MDI/MDIX SW state is valid.
824169240Sjfv **/
825173788Sjfvs32 e1000_validate_mdi_setting(struct e1000_hw *hw)
826169240Sjfv{
827177867Sjfv	if (hw->mac.ops.validate_mdi_setting)
828177867Sjfv		return hw->mac.ops.validate_mdi_setting(hw);
829173788Sjfv
830173788Sjfv	return E1000_SUCCESS;
831169240Sjfv}
832169240Sjfv
833169240Sjfv/**
834169240Sjfv *  e1000_hash_mc_addr - Determines address location in multicast table
835169589Sjfv *  @hw: pointer to the HW structure
836169589Sjfv *  @mc_addr: Multicast address to hash.
837169240Sjfv *
838169240Sjfv *  This hashes an address to determine its location in the multicast
839169240Sjfv *  table. Currently no func pointer exists and all implementations
840169240Sjfv *  are handled in the generic version of this function.
841169240Sjfv **/
842173788Sjfvu32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
843169240Sjfv{
844169240Sjfv	return e1000_hash_mc_addr_generic(hw, mc_addr);
845169240Sjfv}
846169240Sjfv
847169240Sjfv/**
848169240Sjfv *  e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
849169589Sjfv *  @hw: pointer to the HW structure
850169240Sjfv *
851169240Sjfv *  Enables packet filtering on transmit packets if manageability is enabled
852169240Sjfv *  and host interface is enabled.
853169240Sjfv *  Currently no func pointer exists and all implementations are handled in the
854169240Sjfv *  generic version of this function.
855169240Sjfv **/
856173788Sjfvbool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
857169240Sjfv{
858169240Sjfv	return e1000_enable_tx_pkt_filtering_generic(hw);
859169240Sjfv}
860169240Sjfv
861169240Sjfv/**
862169240Sjfv *  e1000_mng_host_if_write - Writes to the manageability host interface
863169589Sjfv *  @hw: pointer to the HW structure
864169589Sjfv *  @buffer: pointer to the host interface buffer
865169589Sjfv *  @length: size of the buffer
866169589Sjfv *  @offset: location in the buffer to write to
867169589Sjfv *  @sum: sum of the data (not checksum)
868169240Sjfv *
869169240Sjfv *  This function writes the buffer content at the offset given on the host if.
870169240Sjfv *  It also does alignment considerations to do the writes in most efficient
871169240Sjfv *  way.  Also fills up the sum of the buffer in *buffer parameter.
872169240Sjfv **/
873228386Sjfvs32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
874228386Sjfv			    u16 offset, u8 *sum)
875169240Sjfv{
876177867Sjfv	if (hw->mac.ops.mng_host_if_write)
877177867Sjfv		return hw->mac.ops.mng_host_if_write(hw, buffer, length,
878228386Sjfv						     offset, sum);
879173788Sjfv
880173788Sjfv	return E1000_NOT_IMPLEMENTED;
881169240Sjfv}
882169240Sjfv
883169240Sjfv/**
884169240Sjfv *  e1000_mng_write_cmd_header - Writes manageability command header
885169589Sjfv *  @hw: pointer to the HW structure
886169589Sjfv *  @hdr: pointer to the host interface command header
887169240Sjfv *
888169240Sjfv *  Writes the command header after does the checksum calculation.
889169240Sjfv **/
890173788Sjfvs32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
891228386Sjfv			       struct e1000_host_mng_command_header *hdr)
892169240Sjfv{
893177867Sjfv	if (hw->mac.ops.mng_write_cmd_header)
894177867Sjfv		return hw->mac.ops.mng_write_cmd_header(hw, hdr);
895173788Sjfv
896173788Sjfv	return E1000_NOT_IMPLEMENTED;
897169240Sjfv}
898169240Sjfv
899169240Sjfv/**
900169240Sjfv *  e1000_mng_enable_host_if - Checks host interface is enabled
901169589Sjfv *  @hw: pointer to the HW structure
902169240Sjfv *
903169240Sjfv *  Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
904169240Sjfv *
905176667Sjfv *  This function checks whether the HOST IF is enabled for command operation
906169240Sjfv *  and also checks whether the previous command is completed.  It busy waits
907169240Sjfv *  in case of previous command is not completed.
908169240Sjfv **/
909228386Sjfvs32 e1000_mng_enable_host_if(struct e1000_hw *hw)
910169240Sjfv{
911177867Sjfv	if (hw->mac.ops.mng_enable_host_if)
912177867Sjfv		return hw->mac.ops.mng_enable_host_if(hw);
913173788Sjfv
914173788Sjfv	return E1000_NOT_IMPLEMENTED;
915169240Sjfv}
916169240Sjfv
917169240Sjfv/**
918169240Sjfv *  e1000_wait_autoneg - Waits for autonegotiation completion
919169589Sjfv *  @hw: pointer to the HW structure
920169240Sjfv *
921169240Sjfv *  Waits for autoneg to complete. Currently no func pointer exists and all
922169240Sjfv *  implementations are handled in the generic version of this function.
923169240Sjfv **/
924173788Sjfvs32 e1000_wait_autoneg(struct e1000_hw *hw)
925169240Sjfv{
926177867Sjfv	if (hw->mac.ops.wait_autoneg)
927177867Sjfv		return hw->mac.ops.wait_autoneg(hw);
928173788Sjfv
929173788Sjfv	return E1000_SUCCESS;
930169240Sjfv}
931169240Sjfv
932169240Sjfv/**
933169240Sjfv *  e1000_check_reset_block - Verifies PHY can be reset
934169589Sjfv *  @hw: pointer to the HW structure
935169240Sjfv *
936169240Sjfv *  Checks if the PHY is in a state that can be reset or if manageability
937169240Sjfv *  has it tied up. This is a function pointer entry point called by drivers.
938169240Sjfv **/
939173788Sjfvs32 e1000_check_reset_block(struct e1000_hw *hw)
940169240Sjfv{
941177867Sjfv	if (hw->phy.ops.check_reset_block)
942177867Sjfv		return hw->phy.ops.check_reset_block(hw);
943173788Sjfv
944173788Sjfv	return E1000_SUCCESS;
945169240Sjfv}
946169240Sjfv
947169240Sjfv/**
948169240Sjfv *  e1000_read_phy_reg - Reads PHY register
949169589Sjfv *  @hw: pointer to the HW structure
950169589Sjfv *  @offset: the register to read
951169589Sjfv *  @data: the buffer to store the 16-bit read.
952169240Sjfv *
953169240Sjfv *  Reads the PHY register and returns the value in data.
954169240Sjfv *  This is a function pointer entry point called by drivers.
955169240Sjfv **/
956173788Sjfvs32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
957169240Sjfv{
958177867Sjfv	if (hw->phy.ops.read_reg)
959177867Sjfv		return hw->phy.ops.read_reg(hw, offset, data);
960173788Sjfv
961173788Sjfv	return E1000_SUCCESS;
962169240Sjfv}
963169240Sjfv
964169240Sjfv/**
965169240Sjfv *  e1000_write_phy_reg - Writes PHY register
966169589Sjfv *  @hw: pointer to the HW structure
967169589Sjfv *  @offset: the register to write
968169589Sjfv *  @data: the value to write.
969169240Sjfv *
970169240Sjfv *  Writes the PHY register at offset with the value in data.
971169240Sjfv *  This is a function pointer entry point called by drivers.
972169240Sjfv **/
973173788Sjfvs32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
974169240Sjfv{
975177867Sjfv	if (hw->phy.ops.write_reg)
976177867Sjfv		return hw->phy.ops.write_reg(hw, offset, data);
977173788Sjfv
978173788Sjfv	return E1000_SUCCESS;
979169240Sjfv}
980169240Sjfv
981169240Sjfv/**
982177867Sjfv *  e1000_release_phy - Generic release PHY
983177867Sjfv *  @hw: pointer to the HW structure
984177867Sjfv *
985177867Sjfv *  Return if silicon family does not require a semaphore when accessing the
986177867Sjfv *  PHY.
987177867Sjfv **/
988177867Sjfvvoid e1000_release_phy(struct e1000_hw *hw)
989177867Sjfv{
990177867Sjfv	if (hw->phy.ops.release)
991177867Sjfv		hw->phy.ops.release(hw);
992177867Sjfv}
993177867Sjfv
994177867Sjfv/**
995177867Sjfv *  e1000_acquire_phy - Generic acquire PHY
996177867Sjfv *  @hw: pointer to the HW structure
997177867Sjfv *
998177867Sjfv *  Return success if silicon family does not require a semaphore when
999177867Sjfv *  accessing the PHY.
1000177867Sjfv **/
1001177867Sjfvs32 e1000_acquire_phy(struct e1000_hw *hw)
1002177867Sjfv{
1003177867Sjfv	if (hw->phy.ops.acquire)
1004177867Sjfv		return hw->phy.ops.acquire(hw);
1005177867Sjfv
1006177867Sjfv	return E1000_SUCCESS;
1007177867Sjfv}
1008177867Sjfv
1009177867Sjfv/**
1010185353Sjfv *  e1000_cfg_on_link_up - Configure PHY upon link up
1011185353Sjfv *  @hw: pointer to the HW structure
1012185353Sjfv **/
1013185353Sjfvs32 e1000_cfg_on_link_up(struct e1000_hw *hw)
1014185353Sjfv{
1015185353Sjfv	if (hw->phy.ops.cfg_on_link_up)
1016185353Sjfv		return hw->phy.ops.cfg_on_link_up(hw);
1017185353Sjfv
1018185353Sjfv	return E1000_SUCCESS;
1019185353Sjfv}
1020185353Sjfv
1021185353Sjfv/**
1022169240Sjfv *  e1000_read_kmrn_reg - Reads register using Kumeran interface
1023169589Sjfv *  @hw: pointer to the HW structure
1024169589Sjfv *  @offset: the register to read
1025169589Sjfv *  @data: the location to store the 16-bit value read.
1026169240Sjfv *
1027169240Sjfv *  Reads a register out of the Kumeran interface. Currently no func pointer
1028169240Sjfv *  exists and all implementations are handled in the generic version of
1029169240Sjfv *  this function.
1030169240Sjfv **/
1031173788Sjfvs32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
1032169240Sjfv{
1033169240Sjfv	return e1000_read_kmrn_reg_generic(hw, offset, data);
1034169240Sjfv}
1035169240Sjfv
1036169240Sjfv/**
1037169240Sjfv *  e1000_write_kmrn_reg - Writes register using Kumeran interface
1038169589Sjfv *  @hw: pointer to the HW structure
1039169589Sjfv *  @offset: the register to write
1040169589Sjfv *  @data: the value to write.
1041169240Sjfv *
1042169240Sjfv *  Writes a register to the Kumeran interface. Currently no func pointer
1043169240Sjfv *  exists and all implementations are handled in the generic version of
1044169240Sjfv *  this function.
1045169240Sjfv **/
1046173788Sjfvs32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
1047169240Sjfv{
1048169240Sjfv	return e1000_write_kmrn_reg_generic(hw, offset, data);
1049169240Sjfv}
1050169240Sjfv
1051169240Sjfv/**
1052169240Sjfv *  e1000_get_cable_length - Retrieves cable length estimation
1053169589Sjfv *  @hw: pointer to the HW structure
1054169240Sjfv *
1055169240Sjfv *  This function estimates the cable length and stores them in
1056169240Sjfv *  hw->phy.min_length and hw->phy.max_length. This is a function pointer
1057169240Sjfv *  entry point called by drivers.
1058169240Sjfv **/
1059173788Sjfvs32 e1000_get_cable_length(struct e1000_hw *hw)
1060169240Sjfv{
1061177867Sjfv	if (hw->phy.ops.get_cable_length)
1062177867Sjfv		return hw->phy.ops.get_cable_length(hw);
1063173788Sjfv
1064173788Sjfv	return E1000_SUCCESS;
1065169240Sjfv}
1066169240Sjfv
1067169240Sjfv/**
1068169240Sjfv *  e1000_get_phy_info - Retrieves PHY information from registers
1069169589Sjfv *  @hw: pointer to the HW structure
1070169240Sjfv *
1071169240Sjfv *  This function gets some information from various PHY registers and
1072169240Sjfv *  populates hw->phy values with it. This is a function pointer entry
1073169240Sjfv *  point called by drivers.
1074169240Sjfv **/
1075173788Sjfvs32 e1000_get_phy_info(struct e1000_hw *hw)
1076169240Sjfv{
1077177867Sjfv	if (hw->phy.ops.get_info)
1078177867Sjfv		return hw->phy.ops.get_info(hw);
1079173788Sjfv
1080173788Sjfv	return E1000_SUCCESS;
1081169240Sjfv}
1082169240Sjfv
1083169240Sjfv/**
1084169240Sjfv *  e1000_phy_hw_reset - Hard PHY reset
1085169589Sjfv *  @hw: pointer to the HW structure
1086169240Sjfv *
1087169240Sjfv *  Performs a hard PHY reset. This is a function pointer entry point called
1088169240Sjfv *  by drivers.
1089169240Sjfv **/
1090173788Sjfvs32 e1000_phy_hw_reset(struct e1000_hw *hw)
1091169240Sjfv{
1092177867Sjfv	if (hw->phy.ops.reset)
1093177867Sjfv		return hw->phy.ops.reset(hw);
1094173788Sjfv
1095173788Sjfv	return E1000_SUCCESS;
1096169240Sjfv}
1097169240Sjfv
1098169240Sjfv/**
1099169240Sjfv *  e1000_phy_commit - Soft PHY reset
1100169589Sjfv *  @hw: pointer to the HW structure
1101169240Sjfv *
1102169240Sjfv *  Performs a soft PHY reset on those that apply. This is a function pointer
1103169240Sjfv *  entry point called by drivers.
1104169240Sjfv **/
1105173788Sjfvs32 e1000_phy_commit(struct e1000_hw *hw)
1106169240Sjfv{
1107177867Sjfv	if (hw->phy.ops.commit)
1108177867Sjfv		return hw->phy.ops.commit(hw);
1109173788Sjfv
1110173788Sjfv	return E1000_SUCCESS;
1111169240Sjfv}
1112169240Sjfv
1113169240Sjfv/**
1114177867Sjfv *  e1000_set_d0_lplu_state - Sets low power link up state for D0
1115169589Sjfv *  @hw: pointer to the HW structure
1116169589Sjfv *  @active: boolean used to enable/disable lplu
1117169240Sjfv *
1118169240Sjfv *  Success returns 0, Failure returns 1
1119169240Sjfv *
1120169240Sjfv *  The low power link up (lplu) state is set to the power management level D0
1121177867Sjfv *  and SmartSpeed is disabled when active is TRUE, else clear lplu for D0
1122169240Sjfv *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
1123169240Sjfv *  is used during Dx states where the power conservation is most important.
1124169240Sjfv *  During driver activity, SmartSpeed should be enabled so performance is
1125169240Sjfv *  maintained.  This is a function pointer entry point called by drivers.
1126169240Sjfv **/
1127173788Sjfvs32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
1128169240Sjfv{
1129177867Sjfv	if (hw->phy.ops.set_d0_lplu_state)
1130177867Sjfv		return hw->phy.ops.set_d0_lplu_state(hw, active);
1131173788Sjfv
1132173788Sjfv	return E1000_SUCCESS;
1133169240Sjfv}
1134169240Sjfv
1135169240Sjfv/**
1136169240Sjfv *  e1000_set_d3_lplu_state - Sets low power link up state for D3
1137169589Sjfv *  @hw: pointer to the HW structure
1138169589Sjfv *  @active: boolean used to enable/disable lplu
1139169240Sjfv *
1140169240Sjfv *  Success returns 0, Failure returns 1
1141169240Sjfv *
1142169240Sjfv *  The low power link up (lplu) state is set to the power management level D3
1143177867Sjfv *  and SmartSpeed is disabled when active is TRUE, else clear lplu for D3
1144169240Sjfv *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
1145169240Sjfv *  is used during Dx states where the power conservation is most important.
1146169240Sjfv *  During driver activity, SmartSpeed should be enabled so performance is
1147169240Sjfv *  maintained.  This is a function pointer entry point called by drivers.
1148169240Sjfv **/
1149173788Sjfvs32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
1150169240Sjfv{
1151177867Sjfv	if (hw->phy.ops.set_d3_lplu_state)
1152177867Sjfv		return hw->phy.ops.set_d3_lplu_state(hw, active);
1153173788Sjfv
1154173788Sjfv	return E1000_SUCCESS;
1155169240Sjfv}
1156169240Sjfv
1157169240Sjfv/**
1158169240Sjfv *  e1000_read_mac_addr - Reads MAC address
1159169589Sjfv *  @hw: pointer to the HW structure
1160169240Sjfv *
1161169240Sjfv *  Reads the MAC address out of the adapter and stores it in the HW structure.
1162169240Sjfv *  Currently no func pointer exists and all implementations are handled in the
1163169240Sjfv *  generic version of this function.
1164169240Sjfv **/
1165173788Sjfvs32 e1000_read_mac_addr(struct e1000_hw *hw)
1166169240Sjfv{
1167177867Sjfv	if (hw->mac.ops.read_mac_addr)
1168177867Sjfv		return hw->mac.ops.read_mac_addr(hw);
1169173788Sjfv
1170169240Sjfv	return e1000_read_mac_addr_generic(hw);
1171169240Sjfv}
1172169240Sjfv
1173169240Sjfv/**
1174213234Sjfv *  e1000_read_pba_string - Read device part number string
1175213234Sjfv *  @hw: pointer to the HW structure
1176213234Sjfv *  @pba_num: pointer to device part number
1177213234Sjfv *  @pba_num_size: size of part number buffer
1178213234Sjfv *
1179213234Sjfv *  Reads the product board assembly (PBA) number from the EEPROM and stores
1180213234Sjfv *  the value in pba_num.
1181213234Sjfv *  Currently no func pointer exists and all implementations are handled in the
1182213234Sjfv *  generic version of this function.
1183213234Sjfv **/
1184213234Sjfvs32 e1000_read_pba_string(struct e1000_hw *hw, u8 *pba_num, u32 pba_num_size)
1185213234Sjfv{
1186213234Sjfv	return e1000_read_pba_string_generic(hw, pba_num, pba_num_size);
1187213234Sjfv}
1188213234Sjfv
1189213234Sjfv/**
1190213234Sjfv *  e1000_read_pba_length - Read device part number string length
1191213234Sjfv *  @hw: pointer to the HW structure
1192213234Sjfv *  @pba_num_size: size of part number buffer
1193213234Sjfv *
1194213234Sjfv *  Reads the product board assembly (PBA) number length from the EEPROM and
1195213234Sjfv *  stores the value in pba_num.
1196213234Sjfv *  Currently no func pointer exists and all implementations are handled in the
1197213234Sjfv *  generic version of this function.
1198213234Sjfv **/
1199213234Sjfvs32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size)
1200213234Sjfv{
1201213234Sjfv	return e1000_read_pba_length_generic(hw, pba_num_size);
1202213234Sjfv}
1203213234Sjfv
1204213234Sjfv/**
1205169240Sjfv *  e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
1206169589Sjfv *  @hw: pointer to the HW structure
1207169240Sjfv *
1208169240Sjfv *  Validates the NVM checksum is correct. This is a function pointer entry
1209169240Sjfv *  point called by drivers.
1210169240Sjfv **/
1211173788Sjfvs32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
1212169240Sjfv{
1213177867Sjfv	if (hw->nvm.ops.validate)
1214177867Sjfv		return hw->nvm.ops.validate(hw);
1215173788Sjfv
1216173788Sjfv	return -E1000_ERR_CONFIG;
1217169240Sjfv}
1218169240Sjfv
1219169240Sjfv/**
1220169240Sjfv *  e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
1221169589Sjfv *  @hw: pointer to the HW structure
1222169240Sjfv *
1223169240Sjfv *  Updates the NVM checksum. Currently no func pointer exists and all
1224169240Sjfv *  implementations are handled in the generic version of this function.
1225169240Sjfv **/
1226173788Sjfvs32 e1000_update_nvm_checksum(struct e1000_hw *hw)
1227169240Sjfv{
1228177867Sjfv	if (hw->nvm.ops.update)
1229177867Sjfv		return hw->nvm.ops.update(hw);
1230173788Sjfv
1231173788Sjfv	return -E1000_ERR_CONFIG;
1232169240Sjfv}
1233169240Sjfv
1234169240Sjfv/**
1235169240Sjfv *  e1000_reload_nvm - Reloads EEPROM
1236169589Sjfv *  @hw: pointer to the HW structure
1237169240Sjfv *
1238169240Sjfv *  Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1239169240Sjfv *  extended control register.
1240169240Sjfv **/
1241173788Sjfvvoid e1000_reload_nvm(struct e1000_hw *hw)
1242169240Sjfv{
1243177867Sjfv	if (hw->nvm.ops.reload)
1244177867Sjfv		hw->nvm.ops.reload(hw);
1245169240Sjfv}
1246169240Sjfv
1247169240Sjfv/**
1248169240Sjfv *  e1000_read_nvm - Reads NVM (EEPROM)
1249169589Sjfv *  @hw: pointer to the HW structure
1250169589Sjfv *  @offset: the word offset to read
1251169589Sjfv *  @words: number of 16-bit words to read
1252169589Sjfv *  @data: pointer to the properly sized buffer for the data.
1253169240Sjfv *
1254169240Sjfv *  Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1255169240Sjfv *  pointer entry point called by drivers.
1256169240Sjfv **/
1257173788Sjfvs32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1258169240Sjfv{
1259177867Sjfv	if (hw->nvm.ops.read)
1260177867Sjfv		return hw->nvm.ops.read(hw, offset, words, data);
1261173788Sjfv
1262173788Sjfv	return -E1000_ERR_CONFIG;
1263169240Sjfv}
1264169240Sjfv
1265169240Sjfv/**
1266169240Sjfv *  e1000_write_nvm - Writes to NVM (EEPROM)
1267169589Sjfv *  @hw: pointer to the HW structure
1268169589Sjfv *  @offset: the word offset to read
1269169589Sjfv *  @words: number of 16-bit words to write
1270169589Sjfv *  @data: pointer to the properly sized buffer for the data.
1271169240Sjfv *
1272169240Sjfv *  Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1273169240Sjfv *  pointer entry point called by drivers.
1274169240Sjfv **/
1275173788Sjfvs32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1276169240Sjfv{
1277177867Sjfv	if (hw->nvm.ops.write)
1278177867Sjfv		return hw->nvm.ops.write(hw, offset, words, data);
1279173788Sjfv
1280173788Sjfv	return E1000_SUCCESS;
1281169240Sjfv}
1282169240Sjfv
1283169240Sjfv/**
1284169240Sjfv *  e1000_write_8bit_ctrl_reg - Writes 8bit Control register
1285169589Sjfv *  @hw: pointer to the HW structure
1286169589Sjfv *  @reg: 32bit register offset
1287169589Sjfv *  @offset: the register to write
1288169589Sjfv *  @data: the value to write.
1289169240Sjfv *
1290169240Sjfv *  Writes the PHY register at offset with the value in data.
1291169240Sjfv *  This is a function pointer entry point called by drivers.
1292169240Sjfv **/
1293176667Sjfvs32 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset,
1294228386Sjfv			      u8 data)
1295169240Sjfv{
1296169240Sjfv	return e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data);
1297169240Sjfv}
1298173788Sjfv
1299173788Sjfv/**
1300173788Sjfv * e1000_power_up_phy - Restores link in case of PHY power down
1301173788Sjfv * @hw: pointer to the HW structure
1302173788Sjfv *
1303173788Sjfv * The phy may be powered down to save power, to turn off link when the
1304173788Sjfv * driver is unloaded, or wake on lan is not enabled (among others).
1305173788Sjfv **/
1306173788Sjfvvoid e1000_power_up_phy(struct e1000_hw *hw)
1307173788Sjfv{
1308177867Sjfv	if (hw->phy.ops.power_up)
1309177867Sjfv		hw->phy.ops.power_up(hw);
1310173788Sjfv
1311173788Sjfv	e1000_setup_link(hw);
1312173788Sjfv}
1313173788Sjfv
1314173788Sjfv/**
1315176667Sjfv * e1000_power_down_phy - Power down PHY
1316173788Sjfv * @hw: pointer to the HW structure
1317173788Sjfv *
1318173788Sjfv * The phy may be powered down to save power, to turn off link when the
1319173788Sjfv * driver is unloaded, or wake on lan is not enabled (among others).
1320173788Sjfv **/
1321173788Sjfvvoid e1000_power_down_phy(struct e1000_hw *hw)
1322173788Sjfv{
1323177867Sjfv	if (hw->phy.ops.power_down)
1324177867Sjfv		hw->phy.ops.power_down(hw);
1325173788Sjfv}
1326173788Sjfv
1327181027Sjfv/**
1328203049Sjfv *  e1000_power_up_fiber_serdes_link - Power up serdes link
1329203049Sjfv *  @hw: pointer to the HW structure
1330203049Sjfv *
1331203049Sjfv *  Power on the optics and PCS.
1332203049Sjfv **/
1333203049Sjfvvoid e1000_power_up_fiber_serdes_link(struct e1000_hw *hw)
1334203049Sjfv{
1335203049Sjfv	if (hw->mac.ops.power_up_serdes)
1336203049Sjfv		hw->mac.ops.power_up_serdes(hw);
1337203049Sjfv}
1338203049Sjfv
1339203049Sjfv/**
1340181027Sjfv *  e1000_shutdown_fiber_serdes_link - Remove link during power down
1341181027Sjfv *  @hw: pointer to the HW structure
1342181027Sjfv *
1343181027Sjfv *  Shutdown the optics and PCS on driver unload.
1344181027Sjfv **/
1345181027Sjfvvoid e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
1346181027Sjfv{
1347181027Sjfv	if (hw->mac.ops.shutdown_serdes)
1348181027Sjfv		hw->mac.ops.shutdown_serdes(hw);
1349181027Sjfv}
1350181027Sjfv
1351