e1000_api.c revision 218530
1177867Sjfv/******************************************************************************
2169240Sjfv
3203049Sjfv  Copyright (c) 2001-2010, 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 218530 2011-02-11 01:00:26Z 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:
280213234Sjfv	case E1000_DEV_ID_ICH10_HANKSVILLE:
281178523Sjfv		mac->type = e1000_ich10lan;
282178523Sjfv		break;
283194865Sjfv	case E1000_DEV_ID_PCH_D_HV_DM:
284194865Sjfv	case E1000_DEV_ID_PCH_D_HV_DC:
285194865Sjfv	case E1000_DEV_ID_PCH_M_HV_LM:
286194865Sjfv	case E1000_DEV_ID_PCH_M_HV_LC:
287194865Sjfv		mac->type = e1000_pchlan;
288194865Sjfv		break;
289213234Sjfv	case E1000_DEV_ID_PCH2_LV_LM:
290213234Sjfv	case E1000_DEV_ID_PCH2_LV_V:
291213234Sjfv		mac->type = e1000_pch2lan;
292213234Sjfv		break;
293177867Sjfv	case E1000_DEV_ID_82575EB_COPPER:
294177867Sjfv	case E1000_DEV_ID_82575EB_FIBER_SERDES:
295177867Sjfv	case E1000_DEV_ID_82575GB_QUAD_COPPER:
296190872Sjfv	case E1000_DEV_ID_82575GB_QUAD_COPPER_PM:
297177867Sjfv		mac->type = e1000_82575;
298169240Sjfv		break;
299181027Sjfv	case E1000_DEV_ID_82576:
300181027Sjfv	case E1000_DEV_ID_82576_FIBER:
301181027Sjfv	case E1000_DEV_ID_82576_SERDES:
302181027Sjfv	case E1000_DEV_ID_82576_QUAD_COPPER:
303213234Sjfv	case E1000_DEV_ID_82576_QUAD_COPPER_ET2:
304190872Sjfv	case E1000_DEV_ID_82576_NS:
305200243Sjfv	case E1000_DEV_ID_82576_NS_SERDES:
306194865Sjfv	case E1000_DEV_ID_82576_SERDES_QUAD:
307181027Sjfv		mac->type = e1000_82576;
308181027Sjfv		break;
309200243Sjfv	case E1000_DEV_ID_82580_COPPER:
310200243Sjfv	case E1000_DEV_ID_82580_FIBER:
311200243Sjfv	case E1000_DEV_ID_82580_SERDES:
312200243Sjfv	case E1000_DEV_ID_82580_SGMII:
313200243Sjfv	case E1000_DEV_ID_82580_COPPER_DUAL:
314213234Sjfv	case E1000_DEV_ID_82580_QUAD_FIBER:
315215789Sjfv	case E1000_DEV_ID_DH89XXCC_SGMII:
316215789Sjfv	case E1000_DEV_ID_DH89XXCC_SERDES:
317218530Sjfv	case E1000_DEV_ID_DH89XXCC_BACKPLANE:
318218530Sjfv	case E1000_DEV_ID_DH89XXCC_SFP:
319200243Sjfv		mac->type = e1000_82580;
320200243Sjfv		break;
321218530Sjfv	case E1000_DEV_ID_I350_COPPER:
322218530Sjfv	case E1000_DEV_ID_I350_FIBER:
323218530Sjfv	case E1000_DEV_ID_I350_SERDES:
324218530Sjfv	case E1000_DEV_ID_I350_SGMII:
325218530Sjfv		mac->type = e1000_i350;
326218530Sjfv		break;
327209616Sjfv	case E1000_DEV_ID_82576_VF:
328209616Sjfv		mac->type = e1000_vfadapt;
329209616Sjfv		break;
330218530Sjfv	case E1000_DEV_ID_I350_VF:
331218530Sjfv		mac->type = e1000_vfadapt_i350;
332218530Sjfv		break;
333169240Sjfv	default:
334169240Sjfv		/* Should never have loaded on this device */
335169240Sjfv		ret_val = -E1000_ERR_MAC_INIT;
336169240Sjfv		break;
337169240Sjfv	}
338169240Sjfv
339169240Sjfv	return ret_val;
340169240Sjfv}
341169240Sjfv
342169240Sjfv/**
343169240Sjfv *  e1000_setup_init_funcs - Initializes function pointers
344169589Sjfv *  @hw: pointer to the HW structure
345169589Sjfv *  @init_device: TRUE will initialize the rest of the function pointers
346169240Sjfv *                 getting the device ready for use.  FALSE will only set
347169240Sjfv *                 MAC type and the function pointers for the other init
348169240Sjfv *                 functions.  Passing FALSE will not generate any hardware
349169240Sjfv *                 reads or writes.
350169240Sjfv *
351169240Sjfv *  This function must be called by a driver in order to use the rest
352169240Sjfv *  of the 'shared' code files. Called by drivers only.
353169240Sjfv **/
354173788Sjfvs32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
355169240Sjfv{
356169240Sjfv	s32 ret_val;
357169240Sjfv
358173788Sjfv	/* Can't do much good without knowing the MAC type. */
359169240Sjfv	ret_val = e1000_set_mac_type(hw);
360169240Sjfv	if (ret_val) {
361169240Sjfv		DEBUGOUT("ERROR: MAC type could not be set properly.\n");
362169240Sjfv		goto out;
363169240Sjfv	}
364169240Sjfv
365169240Sjfv	if (!hw->hw_addr) {
366169240Sjfv		DEBUGOUT("ERROR: Registers not mapped\n");
367169240Sjfv		ret_val = -E1000_ERR_CONFIG;
368169240Sjfv		goto out;
369169240Sjfv	}
370169240Sjfv
371173788Sjfv	/*
372177867Sjfv	 * Init function pointers to generic implementations. We do this first
373177867Sjfv	 * allowing a driver module to override it afterward.
374169240Sjfv	 */
375177867Sjfv	e1000_init_mac_ops_generic(hw);
376177867Sjfv	e1000_init_phy_ops_generic(hw);
377177867Sjfv	e1000_init_nvm_ops_generic(hw);
378209616Sjfv	e1000_init_mbx_ops_generic(hw);
379169240Sjfv
380173788Sjfv	/*
381173788Sjfv	 * Set up the init function pointers. These are functions within the
382169240Sjfv	 * adapter family file that sets up function pointers for the rest of
383169240Sjfv	 * the functions in that family.
384169240Sjfv	 */
385169240Sjfv	switch (hw->mac.type) {
386169240Sjfv	case e1000_82542:
387169240Sjfv		e1000_init_function_pointers_82542(hw);
388169240Sjfv		break;
389169240Sjfv	case e1000_82543:
390169240Sjfv	case e1000_82544:
391169240Sjfv		e1000_init_function_pointers_82543(hw);
392169240Sjfv		break;
393169240Sjfv	case e1000_82540:
394169240Sjfv	case e1000_82545:
395169240Sjfv	case e1000_82545_rev_3:
396169240Sjfv	case e1000_82546:
397169240Sjfv	case e1000_82546_rev_3:
398169240Sjfv		e1000_init_function_pointers_82540(hw);
399169240Sjfv		break;
400169240Sjfv	case e1000_82541:
401169240Sjfv	case e1000_82541_rev_2:
402169240Sjfv	case e1000_82547:
403169240Sjfv	case e1000_82547_rev_2:
404169240Sjfv		e1000_init_function_pointers_82541(hw);
405169240Sjfv		break;
406169240Sjfv	case e1000_82571:
407169240Sjfv	case e1000_82572:
408169240Sjfv	case e1000_82573:
409178523Sjfv	case e1000_82574:
410194865Sjfv	case e1000_82583:
411169240Sjfv		e1000_init_function_pointers_82571(hw);
412169240Sjfv		break;
413169240Sjfv	case e1000_80003es2lan:
414169240Sjfv		e1000_init_function_pointers_80003es2lan(hw);
415169240Sjfv		break;
416169240Sjfv	case e1000_ich8lan:
417169240Sjfv	case e1000_ich9lan:
418178523Sjfv	case e1000_ich10lan:
419194865Sjfv	case e1000_pchlan:
420213234Sjfv	case e1000_pch2lan:
421169240Sjfv		e1000_init_function_pointers_ich8lan(hw);
422169240Sjfv		break;
423177867Sjfv	case e1000_82575:
424181027Sjfv	case e1000_82576:
425200243Sjfv	case e1000_82580:
426218530Sjfv	case e1000_i350:
427177867Sjfv		e1000_init_function_pointers_82575(hw);
428177867Sjfv		break;
429209616Sjfv	case e1000_vfadapt:
430209616Sjfv		e1000_init_function_pointers_vf(hw);
431209616Sjfv		break;
432218530Sjfv	case e1000_vfadapt_i350:
433218530Sjfv		e1000_init_function_pointers_vf(hw);
434218530Sjfv		break;
435169240Sjfv	default:
436169240Sjfv		DEBUGOUT("Hardware not supported\n");
437169240Sjfv		ret_val = -E1000_ERR_CONFIG;
438169240Sjfv		break;
439169240Sjfv	}
440169240Sjfv
441173788Sjfv	/*
442173788Sjfv	 * Initialize the rest of the function pointers. These require some
443169240Sjfv	 * register reads/writes in some cases.
444169240Sjfv	 */
445173788Sjfv	if (!(ret_val) && init_device) {
446169240Sjfv		ret_val = e1000_init_mac_params(hw);
447169240Sjfv		if (ret_val)
448169240Sjfv			goto out;
449169240Sjfv
450169240Sjfv		ret_val = e1000_init_nvm_params(hw);
451169240Sjfv		if (ret_val)
452169240Sjfv			goto out;
453169240Sjfv
454169240Sjfv		ret_val = e1000_init_phy_params(hw);
455169240Sjfv		if (ret_val)
456169240Sjfv			goto out;
457209616Sjfv
458209616Sjfv		ret_val = e1000_init_mbx_params(hw);
459209616Sjfv		if (ret_val)
460209616Sjfv			goto out;
461169240Sjfv	}
462169240Sjfv
463169240Sjfvout:
464169240Sjfv	return ret_val;
465169240Sjfv}
466169240Sjfv
467169240Sjfv/**
468169240Sjfv *  e1000_get_bus_info - Obtain bus information for adapter
469169589Sjfv *  @hw: pointer to the HW structure
470169240Sjfv *
471169240Sjfv *  This will obtain information about the HW bus for which the
472176667Sjfv *  adapter is attached and stores it in the hw structure. This is a
473169240Sjfv *  function pointer entry point called by drivers.
474169240Sjfv **/
475173788Sjfvs32 e1000_get_bus_info(struct e1000_hw *hw)
476169240Sjfv{
477177867Sjfv	if (hw->mac.ops.get_bus_info)
478177867Sjfv		return hw->mac.ops.get_bus_info(hw);
479173788Sjfv
480173788Sjfv	return E1000_SUCCESS;
481169240Sjfv}
482169240Sjfv
483169240Sjfv/**
484169240Sjfv *  e1000_clear_vfta - Clear VLAN filter table
485169589Sjfv *  @hw: pointer to the HW structure
486169240Sjfv *
487169240Sjfv *  This clears the VLAN filter table on the adapter. This is a function
488169240Sjfv *  pointer entry point called by drivers.
489169240Sjfv **/
490173788Sjfvvoid e1000_clear_vfta(struct e1000_hw *hw)
491169240Sjfv{
492177867Sjfv	if (hw->mac.ops.clear_vfta)
493178523Sjfv		hw->mac.ops.clear_vfta(hw);
494169240Sjfv}
495169240Sjfv
496169240Sjfv/**
497169240Sjfv *  e1000_write_vfta - Write value to VLAN filter table
498169589Sjfv *  @hw: pointer to the HW structure
499169589Sjfv *  @offset: the 32-bit offset in which to write the value to.
500169589Sjfv *  @value: the 32-bit value to write at location offset.
501169240Sjfv *
502169240Sjfv *  This writes a 32-bit value to a 32-bit offset in the VLAN filter
503169240Sjfv *  table. This is a function pointer entry point called by drivers.
504169240Sjfv **/
505173788Sjfvvoid e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
506169240Sjfv{
507177867Sjfv	if (hw->mac.ops.write_vfta)
508177867Sjfv		hw->mac.ops.write_vfta(hw, offset, value);
509169240Sjfv}
510169240Sjfv
511169240Sjfv/**
512173788Sjfv *  e1000_update_mc_addr_list - Update Multicast addresses
513169589Sjfv *  @hw: pointer to the HW structure
514169589Sjfv *  @mc_addr_list: array of multicast addresses to program
515169589Sjfv *  @mc_addr_count: number of multicast addresses to program
516169240Sjfv *
517190872Sjfv *  Updates the Multicast Table Array.
518169240Sjfv *  The caller must have a packed mc_addr_list of multicast addresses.
519169240Sjfv **/
520173788Sjfvvoid e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
521190872Sjfv                               u32 mc_addr_count)
522169240Sjfv{
523177867Sjfv	if (hw->mac.ops.update_mc_addr_list)
524190872Sjfv		hw->mac.ops.update_mc_addr_list(hw, mc_addr_list,
525190872Sjfv		                                mc_addr_count);
526169240Sjfv}
527169240Sjfv
528169240Sjfv/**
529169240Sjfv *  e1000_force_mac_fc - Force MAC flow control
530169589Sjfv *  @hw: pointer to the HW structure
531169240Sjfv *
532169240Sjfv *  Force the MAC's flow control settings. Currently no func pointer exists
533169240Sjfv *  and all implementations are handled in the generic version of this
534169240Sjfv *  function.
535169240Sjfv **/
536173788Sjfvs32 e1000_force_mac_fc(struct e1000_hw *hw)
537169240Sjfv{
538169240Sjfv	return e1000_force_mac_fc_generic(hw);
539169240Sjfv}
540169240Sjfv
541169240Sjfv/**
542169240Sjfv *  e1000_check_for_link - Check/Store link connection
543169589Sjfv *  @hw: pointer to the HW structure
544169240Sjfv *
545169240Sjfv *  This checks the link condition of the adapter and stores the
546169240Sjfv *  results in the hw->mac structure. This is a function pointer entry
547169240Sjfv *  point called by drivers.
548169240Sjfv **/
549173788Sjfvs32 e1000_check_for_link(struct e1000_hw *hw)
550169240Sjfv{
551177867Sjfv	if (hw->mac.ops.check_for_link)
552177867Sjfv		return hw->mac.ops.check_for_link(hw);
553173788Sjfv
554173788Sjfv	return -E1000_ERR_CONFIG;
555169240Sjfv}
556169240Sjfv
557169240Sjfv/**
558169240Sjfv *  e1000_check_mng_mode - Check management mode
559169589Sjfv *  @hw: pointer to the HW structure
560169240Sjfv *
561169240Sjfv *  This checks if the adapter has manageability enabled.
562169240Sjfv *  This is a function pointer entry point called by drivers.
563169240Sjfv **/
564173788Sjfvbool e1000_check_mng_mode(struct e1000_hw *hw)
565169240Sjfv{
566177867Sjfv	if (hw->mac.ops.check_mng_mode)
567177867Sjfv		return hw->mac.ops.check_mng_mode(hw);
568173788Sjfv
569173788Sjfv	return FALSE;
570169240Sjfv}
571169240Sjfv
572169240Sjfv/**
573169240Sjfv *  e1000_mng_write_dhcp_info - Writes DHCP info to host interface
574169589Sjfv *  @hw: pointer to the HW structure
575169589Sjfv *  @buffer: pointer to the host interface
576169589Sjfv *  @length: size of the buffer
577169240Sjfv *
578169240Sjfv *  Writes the DHCP information to the host interface.
579169240Sjfv **/
580173788Sjfvs32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
581169240Sjfv{
582169240Sjfv	return e1000_mng_write_dhcp_info_generic(hw, buffer, length);
583169240Sjfv}
584169240Sjfv
585169240Sjfv/**
586169240Sjfv *  e1000_reset_hw - Reset hardware
587169589Sjfv *  @hw: pointer to the HW structure
588169240Sjfv *
589169240Sjfv *  This resets the hardware into a known state. This is a function pointer
590169240Sjfv *  entry point called by drivers.
591169240Sjfv **/
592173788Sjfvs32 e1000_reset_hw(struct e1000_hw *hw)
593169240Sjfv{
594177867Sjfv	if (hw->mac.ops.reset_hw)
595177867Sjfv		return hw->mac.ops.reset_hw(hw);
596173788Sjfv
597173788Sjfv	return -E1000_ERR_CONFIG;
598169240Sjfv}
599169240Sjfv
600169240Sjfv/**
601169240Sjfv *  e1000_init_hw - Initialize hardware
602169589Sjfv *  @hw: pointer to the HW structure
603169240Sjfv *
604169240Sjfv *  This inits the hardware readying it for operation. This is a function
605169240Sjfv *  pointer entry point called by drivers.
606169240Sjfv **/
607173788Sjfvs32 e1000_init_hw(struct e1000_hw *hw)
608169240Sjfv{
609177867Sjfv	if (hw->mac.ops.init_hw)
610177867Sjfv		return hw->mac.ops.init_hw(hw);
611173788Sjfv
612173788Sjfv	return -E1000_ERR_CONFIG;
613169240Sjfv}
614169240Sjfv
615169240Sjfv/**
616169240Sjfv *  e1000_setup_link - Configures link and flow control
617169589Sjfv *  @hw: pointer to the HW structure
618169240Sjfv *
619169240Sjfv *  This configures link and flow control settings for the adapter. This
620169240Sjfv *  is a function pointer entry point called by drivers. While modules can
621169240Sjfv *  also call this, they probably call their own version of this function.
622169240Sjfv **/
623173788Sjfvs32 e1000_setup_link(struct e1000_hw *hw)
624169240Sjfv{
625177867Sjfv	if (hw->mac.ops.setup_link)
626177867Sjfv		return hw->mac.ops.setup_link(hw);
627173788Sjfv
628173788Sjfv	return -E1000_ERR_CONFIG;
629169240Sjfv}
630169240Sjfv
631169240Sjfv/**
632169240Sjfv *  e1000_get_speed_and_duplex - Returns current speed and duplex
633169589Sjfv *  @hw: pointer to the HW structure
634169589Sjfv *  @speed: pointer to a 16-bit value to store the speed
635169589Sjfv *  @duplex: pointer to a 16-bit value to store the duplex.
636169240Sjfv *
637169240Sjfv *  This returns the speed and duplex of the adapter in the two 'out'
638169240Sjfv *  variables passed in. This is a function pointer entry point called
639169240Sjfv *  by drivers.
640169240Sjfv **/
641173788Sjfvs32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
642169240Sjfv{
643177867Sjfv	if (hw->mac.ops.get_link_up_info)
644177867Sjfv		return hw->mac.ops.get_link_up_info(hw, speed, duplex);
645173788Sjfv
646173788Sjfv	return -E1000_ERR_CONFIG;
647169240Sjfv}
648169240Sjfv
649169240Sjfv/**
650169240Sjfv *  e1000_setup_led - Configures SW controllable LED
651169589Sjfv *  @hw: pointer to the HW structure
652169240Sjfv *
653169240Sjfv *  This prepares the SW controllable LED for use and saves the current state
654169240Sjfv *  of the LED so it can be later restored. This is a function pointer entry
655169240Sjfv *  point called by drivers.
656169240Sjfv **/
657173788Sjfvs32 e1000_setup_led(struct e1000_hw *hw)
658169240Sjfv{
659177867Sjfv	if (hw->mac.ops.setup_led)
660177867Sjfv		return hw->mac.ops.setup_led(hw);
661173788Sjfv
662173788Sjfv	return E1000_SUCCESS;
663169240Sjfv}
664169240Sjfv
665169240Sjfv/**
666169240Sjfv *  e1000_cleanup_led - Restores SW controllable LED
667169589Sjfv *  @hw: pointer to the HW structure
668169240Sjfv *
669169240Sjfv *  This restores the SW controllable LED to the value saved off by
670169240Sjfv *  e1000_setup_led. This is a function pointer entry point called by drivers.
671169240Sjfv **/
672173788Sjfvs32 e1000_cleanup_led(struct e1000_hw *hw)
673169240Sjfv{
674177867Sjfv	if (hw->mac.ops.cleanup_led)
675177867Sjfv		return hw->mac.ops.cleanup_led(hw);
676173788Sjfv
677173788Sjfv	return E1000_SUCCESS;
678169240Sjfv}
679169240Sjfv
680169240Sjfv/**
681169240Sjfv *  e1000_blink_led - Blink SW controllable LED
682169589Sjfv *  @hw: pointer to the HW structure
683169240Sjfv *
684169240Sjfv *  This starts the adapter LED blinking. Request the LED to be setup first
685169240Sjfv *  and cleaned up after. This is a function pointer entry point called by
686169240Sjfv *  drivers.
687169240Sjfv **/
688173788Sjfvs32 e1000_blink_led(struct e1000_hw *hw)
689169240Sjfv{
690177867Sjfv	if (hw->mac.ops.blink_led)
691177867Sjfv		return hw->mac.ops.blink_led(hw);
692173788Sjfv
693173788Sjfv	return E1000_SUCCESS;
694169240Sjfv}
695169240Sjfv
696169240Sjfv/**
697190872Sjfv *  e1000_id_led_init - store LED configurations in SW
698190872Sjfv *  @hw: pointer to the HW structure
699190872Sjfv *
700190872Sjfv *  Initializes the LED config in SW. This is a function pointer entry point
701190872Sjfv *  called by drivers.
702190872Sjfv **/
703190872Sjfvs32 e1000_id_led_init(struct e1000_hw *hw)
704190872Sjfv{
705190872Sjfv	if (hw->mac.ops.id_led_init)
706190872Sjfv		return hw->mac.ops.id_led_init(hw);
707190872Sjfv
708190872Sjfv	return E1000_SUCCESS;
709190872Sjfv}
710190872Sjfv
711190872Sjfv/**
712169240Sjfv *  e1000_led_on - Turn on SW controllable LED
713169589Sjfv *  @hw: pointer to the HW structure
714169240Sjfv *
715169240Sjfv *  Turns the SW defined LED on. This is a function pointer entry point
716169240Sjfv *  called by drivers.
717169240Sjfv **/
718173788Sjfvs32 e1000_led_on(struct e1000_hw *hw)
719169240Sjfv{
720177867Sjfv	if (hw->mac.ops.led_on)
721177867Sjfv		return hw->mac.ops.led_on(hw);
722173788Sjfv
723173788Sjfv	return E1000_SUCCESS;
724169240Sjfv}
725169240Sjfv
726169240Sjfv/**
727169240Sjfv *  e1000_led_off - Turn off SW controllable LED
728169589Sjfv *  @hw: pointer to the HW structure
729169240Sjfv *
730169240Sjfv *  Turns the SW defined LED off. This is a function pointer entry point
731169240Sjfv *  called by drivers.
732169240Sjfv **/
733173788Sjfvs32 e1000_led_off(struct e1000_hw *hw)
734169240Sjfv{
735177867Sjfv	if (hw->mac.ops.led_off)
736177867Sjfv		return hw->mac.ops.led_off(hw);
737173788Sjfv
738173788Sjfv	return E1000_SUCCESS;
739169240Sjfv}
740169240Sjfv
741169240Sjfv/**
742169240Sjfv *  e1000_reset_adaptive - Reset adaptive IFS
743169589Sjfv *  @hw: pointer to the HW structure
744169240Sjfv *
745169240Sjfv *  Resets the adaptive IFS. Currently no func pointer exists and all
746169240Sjfv *  implementations are handled in the generic version of this function.
747169240Sjfv **/
748173788Sjfvvoid e1000_reset_adaptive(struct e1000_hw *hw)
749169240Sjfv{
750169240Sjfv	e1000_reset_adaptive_generic(hw);
751169240Sjfv}
752169240Sjfv
753169240Sjfv/**
754169240Sjfv *  e1000_update_adaptive - Update adaptive IFS
755169589Sjfv *  @hw: pointer to the HW structure
756169240Sjfv *
757169240Sjfv *  Updates adapter IFS. Currently no func pointer exists and all
758169240Sjfv *  implementations are handled in the generic version of this function.
759169240Sjfv **/
760173788Sjfvvoid e1000_update_adaptive(struct e1000_hw *hw)
761169240Sjfv{
762169240Sjfv	e1000_update_adaptive_generic(hw);
763169240Sjfv}
764169240Sjfv
765169240Sjfv/**
766169240Sjfv *  e1000_disable_pcie_master - Disable PCI-Express master access
767169589Sjfv *  @hw: pointer to the HW structure
768169240Sjfv *
769169240Sjfv *  Disables PCI-Express master access and verifies there are no pending
770169240Sjfv *  requests. Currently no func pointer exists and all implementations are
771169240Sjfv *  handled in the generic version of this function.
772169240Sjfv **/
773173788Sjfvs32 e1000_disable_pcie_master(struct e1000_hw *hw)
774169240Sjfv{
775169240Sjfv	return e1000_disable_pcie_master_generic(hw);
776169240Sjfv}
777169240Sjfv
778169240Sjfv/**
779169240Sjfv *  e1000_config_collision_dist - Configure collision distance
780169589Sjfv *  @hw: pointer to the HW structure
781169240Sjfv *
782169240Sjfv *  Configures the collision distance to the default value and is used
783169240Sjfv *  during link setup.
784169240Sjfv **/
785173788Sjfvvoid e1000_config_collision_dist(struct e1000_hw *hw)
786169240Sjfv{
787177867Sjfv	if (hw->mac.ops.config_collision_dist)
788177867Sjfv		hw->mac.ops.config_collision_dist(hw);
789169240Sjfv}
790169240Sjfv
791169240Sjfv/**
792169240Sjfv *  e1000_rar_set - Sets a receive address register
793169589Sjfv *  @hw: pointer to the HW structure
794169589Sjfv *  @addr: address to set the RAR to
795169589Sjfv *  @index: the RAR to set
796169240Sjfv *
797169240Sjfv *  Sets a Receive Address Register (RAR) to the specified address.
798169240Sjfv **/
799173788Sjfvvoid e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
800169240Sjfv{
801177867Sjfv	if (hw->mac.ops.rar_set)
802177867Sjfv		hw->mac.ops.rar_set(hw, addr, index);
803169240Sjfv}
804169240Sjfv
805169240Sjfv/**
806169240Sjfv *  e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
807169589Sjfv *  @hw: pointer to the HW structure
808169240Sjfv *
809169240Sjfv *  Ensures that the MDI/MDIX SW state is valid.
810169240Sjfv **/
811173788Sjfvs32 e1000_validate_mdi_setting(struct e1000_hw *hw)
812169240Sjfv{
813177867Sjfv	if (hw->mac.ops.validate_mdi_setting)
814177867Sjfv		return hw->mac.ops.validate_mdi_setting(hw);
815173788Sjfv
816173788Sjfv	return E1000_SUCCESS;
817169240Sjfv}
818169240Sjfv
819169240Sjfv/**
820169240Sjfv *  e1000_hash_mc_addr - Determines address location in multicast table
821169589Sjfv *  @hw: pointer to the HW structure
822169589Sjfv *  @mc_addr: Multicast address to hash.
823169240Sjfv *
824169240Sjfv *  This hashes an address to determine its location in the multicast
825169240Sjfv *  table. Currently no func pointer exists and all implementations
826169240Sjfv *  are handled in the generic version of this function.
827169240Sjfv **/
828173788Sjfvu32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
829169240Sjfv{
830169240Sjfv	return e1000_hash_mc_addr_generic(hw, mc_addr);
831169240Sjfv}
832169240Sjfv
833169240Sjfv/**
834169240Sjfv *  e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
835169589Sjfv *  @hw: pointer to the HW structure
836169240Sjfv *
837169240Sjfv *  Enables packet filtering on transmit packets if manageability is enabled
838169240Sjfv *  and host interface is enabled.
839169240Sjfv *  Currently no func pointer exists and all implementations are handled in the
840169240Sjfv *  generic version of this function.
841169240Sjfv **/
842173788Sjfvbool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
843169240Sjfv{
844169240Sjfv	return e1000_enable_tx_pkt_filtering_generic(hw);
845169240Sjfv}
846169240Sjfv
847169240Sjfv/**
848169240Sjfv *  e1000_mng_host_if_write - Writes to the manageability host interface
849169589Sjfv *  @hw: pointer to the HW structure
850169589Sjfv *  @buffer: pointer to the host interface buffer
851169589Sjfv *  @length: size of the buffer
852169589Sjfv *  @offset: location in the buffer to write to
853169589Sjfv *  @sum: sum of the data (not checksum)
854169240Sjfv *
855169240Sjfv *  This function writes the buffer content at the offset given on the host if.
856169240Sjfv *  It also does alignment considerations to do the writes in most efficient
857169240Sjfv *  way.  Also fills up the sum of the buffer in *buffer parameter.
858169240Sjfv **/
859173788Sjfvs32 e1000_mng_host_if_write(struct e1000_hw * hw, u8 *buffer, u16 length,
860173788Sjfv                            u16 offset, u8 *sum)
861169240Sjfv{
862177867Sjfv	if (hw->mac.ops.mng_host_if_write)
863177867Sjfv		return hw->mac.ops.mng_host_if_write(hw, buffer, length,
864177867Sjfv		                                     offset, sum);
865173788Sjfv
866173788Sjfv	return E1000_NOT_IMPLEMENTED;
867169240Sjfv}
868169240Sjfv
869169240Sjfv/**
870169240Sjfv *  e1000_mng_write_cmd_header - Writes manageability command header
871169589Sjfv *  @hw: pointer to the HW structure
872169589Sjfv *  @hdr: pointer to the host interface command header
873169240Sjfv *
874169240Sjfv *  Writes the command header after does the checksum calculation.
875169240Sjfv **/
876173788Sjfvs32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
877173788Sjfv                               struct e1000_host_mng_command_header *hdr)
878169240Sjfv{
879177867Sjfv	if (hw->mac.ops.mng_write_cmd_header)
880177867Sjfv		return hw->mac.ops.mng_write_cmd_header(hw, hdr);
881173788Sjfv
882173788Sjfv	return E1000_NOT_IMPLEMENTED;
883169240Sjfv}
884169240Sjfv
885169240Sjfv/**
886169240Sjfv *  e1000_mng_enable_host_if - Checks host interface is enabled
887169589Sjfv *  @hw: pointer to the HW structure
888169240Sjfv *
889169240Sjfv *  Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
890169240Sjfv *
891176667Sjfv *  This function checks whether the HOST IF is enabled for command operation
892169240Sjfv *  and also checks whether the previous command is completed.  It busy waits
893169240Sjfv *  in case of previous command is not completed.
894169240Sjfv **/
895173788Sjfvs32 e1000_mng_enable_host_if(struct e1000_hw * hw)
896169240Sjfv{
897177867Sjfv	if (hw->mac.ops.mng_enable_host_if)
898177867Sjfv		return hw->mac.ops.mng_enable_host_if(hw);
899173788Sjfv
900173788Sjfv	return E1000_NOT_IMPLEMENTED;
901169240Sjfv}
902169240Sjfv
903169240Sjfv/**
904169240Sjfv *  e1000_wait_autoneg - Waits for autonegotiation completion
905169589Sjfv *  @hw: pointer to the HW structure
906169240Sjfv *
907169240Sjfv *  Waits for autoneg to complete. Currently no func pointer exists and all
908169240Sjfv *  implementations are handled in the generic version of this function.
909169240Sjfv **/
910173788Sjfvs32 e1000_wait_autoneg(struct e1000_hw *hw)
911169240Sjfv{
912177867Sjfv	if (hw->mac.ops.wait_autoneg)
913177867Sjfv		return hw->mac.ops.wait_autoneg(hw);
914173788Sjfv
915173788Sjfv	return E1000_SUCCESS;
916169240Sjfv}
917169240Sjfv
918169240Sjfv/**
919169240Sjfv *  e1000_check_reset_block - Verifies PHY can be reset
920169589Sjfv *  @hw: pointer to the HW structure
921169240Sjfv *
922169240Sjfv *  Checks if the PHY is in a state that can be reset or if manageability
923169240Sjfv *  has it tied up. This is a function pointer entry point called by drivers.
924169240Sjfv **/
925173788Sjfvs32 e1000_check_reset_block(struct e1000_hw *hw)
926169240Sjfv{
927177867Sjfv	if (hw->phy.ops.check_reset_block)
928177867Sjfv		return hw->phy.ops.check_reset_block(hw);
929173788Sjfv
930173788Sjfv	return E1000_SUCCESS;
931169240Sjfv}
932169240Sjfv
933169240Sjfv/**
934169240Sjfv *  e1000_read_phy_reg - Reads PHY register
935169589Sjfv *  @hw: pointer to the HW structure
936169589Sjfv *  @offset: the register to read
937169589Sjfv *  @data: the buffer to store the 16-bit read.
938169240Sjfv *
939169240Sjfv *  Reads the PHY register and returns the value in data.
940169240Sjfv *  This is a function pointer entry point called by drivers.
941169240Sjfv **/
942173788Sjfvs32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
943169240Sjfv{
944177867Sjfv	if (hw->phy.ops.read_reg)
945177867Sjfv		return hw->phy.ops.read_reg(hw, offset, data);
946173788Sjfv
947173788Sjfv	return E1000_SUCCESS;
948169240Sjfv}
949169240Sjfv
950169240Sjfv/**
951169240Sjfv *  e1000_write_phy_reg - Writes PHY register
952169589Sjfv *  @hw: pointer to the HW structure
953169589Sjfv *  @offset: the register to write
954169589Sjfv *  @data: the value to write.
955169240Sjfv *
956169240Sjfv *  Writes the PHY register at offset with the value in data.
957169240Sjfv *  This is a function pointer entry point called by drivers.
958169240Sjfv **/
959173788Sjfvs32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
960169240Sjfv{
961177867Sjfv	if (hw->phy.ops.write_reg)
962177867Sjfv		return hw->phy.ops.write_reg(hw, offset, data);
963173788Sjfv
964173788Sjfv	return E1000_SUCCESS;
965169240Sjfv}
966169240Sjfv
967169240Sjfv/**
968177867Sjfv *  e1000_release_phy - Generic release PHY
969177867Sjfv *  @hw: pointer to the HW structure
970177867Sjfv *
971177867Sjfv *  Return if silicon family does not require a semaphore when accessing the
972177867Sjfv *  PHY.
973177867Sjfv **/
974177867Sjfvvoid e1000_release_phy(struct e1000_hw *hw)
975177867Sjfv{
976177867Sjfv	if (hw->phy.ops.release)
977177867Sjfv		hw->phy.ops.release(hw);
978177867Sjfv}
979177867Sjfv
980177867Sjfv/**
981177867Sjfv *  e1000_acquire_phy - Generic acquire PHY
982177867Sjfv *  @hw: pointer to the HW structure
983177867Sjfv *
984177867Sjfv *  Return success if silicon family does not require a semaphore when
985177867Sjfv *  accessing the PHY.
986177867Sjfv **/
987177867Sjfvs32 e1000_acquire_phy(struct e1000_hw *hw)
988177867Sjfv{
989177867Sjfv	if (hw->phy.ops.acquire)
990177867Sjfv		return hw->phy.ops.acquire(hw);
991177867Sjfv
992177867Sjfv	return E1000_SUCCESS;
993177867Sjfv}
994177867Sjfv
995177867Sjfv/**
996185353Sjfv *  e1000_cfg_on_link_up - Configure PHY upon link up
997185353Sjfv *  @hw: pointer to the HW structure
998185353Sjfv **/
999185353Sjfvs32 e1000_cfg_on_link_up(struct e1000_hw *hw)
1000185353Sjfv{
1001185353Sjfv	if (hw->phy.ops.cfg_on_link_up)
1002185353Sjfv		return hw->phy.ops.cfg_on_link_up(hw);
1003185353Sjfv
1004185353Sjfv	return E1000_SUCCESS;
1005185353Sjfv}
1006185353Sjfv
1007185353Sjfv/**
1008169240Sjfv *  e1000_read_kmrn_reg - Reads register using Kumeran interface
1009169589Sjfv *  @hw: pointer to the HW structure
1010169589Sjfv *  @offset: the register to read
1011169589Sjfv *  @data: the location to store the 16-bit value read.
1012169240Sjfv *
1013169240Sjfv *  Reads a register out of the Kumeran interface. Currently no func pointer
1014169240Sjfv *  exists and all implementations are handled in the generic version of
1015169240Sjfv *  this function.
1016169240Sjfv **/
1017173788Sjfvs32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
1018169240Sjfv{
1019169240Sjfv	return e1000_read_kmrn_reg_generic(hw, offset, data);
1020169240Sjfv}
1021169240Sjfv
1022169240Sjfv/**
1023169240Sjfv *  e1000_write_kmrn_reg - Writes register using Kumeran interface
1024169589Sjfv *  @hw: pointer to the HW structure
1025169589Sjfv *  @offset: the register to write
1026169589Sjfv *  @data: the value to write.
1027169240Sjfv *
1028169240Sjfv *  Writes a register to the Kumeran interface. Currently no func pointer
1029169240Sjfv *  exists and all implementations are handled in the generic version of
1030169240Sjfv *  this function.
1031169240Sjfv **/
1032173788Sjfvs32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
1033169240Sjfv{
1034169240Sjfv	return e1000_write_kmrn_reg_generic(hw, offset, data);
1035169240Sjfv}
1036169240Sjfv
1037169240Sjfv/**
1038169240Sjfv *  e1000_get_cable_length - Retrieves cable length estimation
1039169589Sjfv *  @hw: pointer to the HW structure
1040169240Sjfv *
1041169240Sjfv *  This function estimates the cable length and stores them in
1042169240Sjfv *  hw->phy.min_length and hw->phy.max_length. This is a function pointer
1043169240Sjfv *  entry point called by drivers.
1044169240Sjfv **/
1045173788Sjfvs32 e1000_get_cable_length(struct e1000_hw *hw)
1046169240Sjfv{
1047177867Sjfv	if (hw->phy.ops.get_cable_length)
1048177867Sjfv		return hw->phy.ops.get_cable_length(hw);
1049173788Sjfv
1050173788Sjfv	return E1000_SUCCESS;
1051169240Sjfv}
1052169240Sjfv
1053169240Sjfv/**
1054169240Sjfv *  e1000_get_phy_info - Retrieves PHY information from registers
1055169589Sjfv *  @hw: pointer to the HW structure
1056169240Sjfv *
1057169240Sjfv *  This function gets some information from various PHY registers and
1058169240Sjfv *  populates hw->phy values with it. This is a function pointer entry
1059169240Sjfv *  point called by drivers.
1060169240Sjfv **/
1061173788Sjfvs32 e1000_get_phy_info(struct e1000_hw *hw)
1062169240Sjfv{
1063177867Sjfv	if (hw->phy.ops.get_info)
1064177867Sjfv		return hw->phy.ops.get_info(hw);
1065173788Sjfv
1066173788Sjfv	return E1000_SUCCESS;
1067169240Sjfv}
1068169240Sjfv
1069169240Sjfv/**
1070169240Sjfv *  e1000_phy_hw_reset - Hard PHY reset
1071169589Sjfv *  @hw: pointer to the HW structure
1072169240Sjfv *
1073169240Sjfv *  Performs a hard PHY reset. This is a function pointer entry point called
1074169240Sjfv *  by drivers.
1075169240Sjfv **/
1076173788Sjfvs32 e1000_phy_hw_reset(struct e1000_hw *hw)
1077169240Sjfv{
1078177867Sjfv	if (hw->phy.ops.reset)
1079177867Sjfv		return hw->phy.ops.reset(hw);
1080173788Sjfv
1081173788Sjfv	return E1000_SUCCESS;
1082169240Sjfv}
1083169240Sjfv
1084169240Sjfv/**
1085169240Sjfv *  e1000_phy_commit - Soft PHY reset
1086169589Sjfv *  @hw: pointer to the HW structure
1087169240Sjfv *
1088169240Sjfv *  Performs a soft PHY reset on those that apply. This is a function pointer
1089169240Sjfv *  entry point called by drivers.
1090169240Sjfv **/
1091173788Sjfvs32 e1000_phy_commit(struct e1000_hw *hw)
1092169240Sjfv{
1093177867Sjfv	if (hw->phy.ops.commit)
1094177867Sjfv		return hw->phy.ops.commit(hw);
1095173788Sjfv
1096173788Sjfv	return E1000_SUCCESS;
1097169240Sjfv}
1098169240Sjfv
1099169240Sjfv/**
1100177867Sjfv *  e1000_set_d0_lplu_state - Sets low power link up state for D0
1101169589Sjfv *  @hw: pointer to the HW structure
1102169589Sjfv *  @active: boolean used to enable/disable lplu
1103169240Sjfv *
1104169240Sjfv *  Success returns 0, Failure returns 1
1105169240Sjfv *
1106169240Sjfv *  The low power link up (lplu) state is set to the power management level D0
1107177867Sjfv *  and SmartSpeed is disabled when active is TRUE, else clear lplu for D0
1108169240Sjfv *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
1109169240Sjfv *  is used during Dx states where the power conservation is most important.
1110169240Sjfv *  During driver activity, SmartSpeed should be enabled so performance is
1111169240Sjfv *  maintained.  This is a function pointer entry point called by drivers.
1112169240Sjfv **/
1113173788Sjfvs32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
1114169240Sjfv{
1115177867Sjfv	if (hw->phy.ops.set_d0_lplu_state)
1116177867Sjfv		return hw->phy.ops.set_d0_lplu_state(hw, active);
1117173788Sjfv
1118173788Sjfv	return E1000_SUCCESS;
1119169240Sjfv}
1120169240Sjfv
1121169240Sjfv/**
1122169240Sjfv *  e1000_set_d3_lplu_state - Sets low power link up state for D3
1123169589Sjfv *  @hw: pointer to the HW structure
1124169589Sjfv *  @active: boolean used to enable/disable lplu
1125169240Sjfv *
1126169240Sjfv *  Success returns 0, Failure returns 1
1127169240Sjfv *
1128169240Sjfv *  The low power link up (lplu) state is set to the power management level D3
1129177867Sjfv *  and SmartSpeed is disabled when active is TRUE, else clear lplu for D3
1130169240Sjfv *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
1131169240Sjfv *  is used during Dx states where the power conservation is most important.
1132169240Sjfv *  During driver activity, SmartSpeed should be enabled so performance is
1133169240Sjfv *  maintained.  This is a function pointer entry point called by drivers.
1134169240Sjfv **/
1135173788Sjfvs32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
1136169240Sjfv{
1137177867Sjfv	if (hw->phy.ops.set_d3_lplu_state)
1138177867Sjfv		return hw->phy.ops.set_d3_lplu_state(hw, active);
1139173788Sjfv
1140173788Sjfv	return E1000_SUCCESS;
1141169240Sjfv}
1142169240Sjfv
1143169240Sjfv/**
1144169240Sjfv *  e1000_read_mac_addr - Reads MAC address
1145169589Sjfv *  @hw: pointer to the HW structure
1146169240Sjfv *
1147169240Sjfv *  Reads the MAC address out of the adapter and stores it in the HW structure.
1148169240Sjfv *  Currently no func pointer exists and all implementations are handled in the
1149169240Sjfv *  generic version of this function.
1150169240Sjfv **/
1151173788Sjfvs32 e1000_read_mac_addr(struct e1000_hw *hw)
1152169240Sjfv{
1153177867Sjfv	if (hw->mac.ops.read_mac_addr)
1154177867Sjfv		return hw->mac.ops.read_mac_addr(hw);
1155173788Sjfv
1156169240Sjfv	return e1000_read_mac_addr_generic(hw);
1157169240Sjfv}
1158169240Sjfv
1159169240Sjfv/**
1160213234Sjfv *  e1000_read_pba_string - Read device part number string
1161213234Sjfv *  @hw: pointer to the HW structure
1162213234Sjfv *  @pba_num: pointer to device part number
1163213234Sjfv *  @pba_num_size: size of part number buffer
1164213234Sjfv *
1165213234Sjfv *  Reads the product board assembly (PBA) number from the EEPROM and stores
1166213234Sjfv *  the value in pba_num.
1167213234Sjfv *  Currently no func pointer exists and all implementations are handled in the
1168213234Sjfv *  generic version of this function.
1169213234Sjfv **/
1170213234Sjfvs32 e1000_read_pba_string(struct e1000_hw *hw, u8 *pba_num, u32 pba_num_size)
1171213234Sjfv{
1172213234Sjfv	return e1000_read_pba_string_generic(hw, pba_num, pba_num_size);
1173213234Sjfv}
1174213234Sjfv
1175213234Sjfv/**
1176213234Sjfv *  e1000_read_pba_length - Read device part number string length
1177213234Sjfv *  @hw: pointer to the HW structure
1178213234Sjfv *  @pba_num_size: size of part number buffer
1179213234Sjfv *
1180213234Sjfv *  Reads the product board assembly (PBA) number length from the EEPROM and
1181213234Sjfv *  stores the value in pba_num.
1182213234Sjfv *  Currently no func pointer exists and all implementations are handled in the
1183213234Sjfv *  generic version of this function.
1184213234Sjfv **/
1185213234Sjfvs32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size)
1186213234Sjfv{
1187213234Sjfv	return e1000_read_pba_length_generic(hw, pba_num_size);
1188213234Sjfv}
1189213234Sjfv
1190213234Sjfv/**
1191169240Sjfv *  e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
1192169589Sjfv *  @hw: pointer to the HW structure
1193169240Sjfv *
1194169240Sjfv *  Validates the NVM checksum is correct. This is a function pointer entry
1195169240Sjfv *  point called by drivers.
1196169240Sjfv **/
1197173788Sjfvs32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
1198169240Sjfv{
1199177867Sjfv	if (hw->nvm.ops.validate)
1200177867Sjfv		return hw->nvm.ops.validate(hw);
1201173788Sjfv
1202173788Sjfv	return -E1000_ERR_CONFIG;
1203169240Sjfv}
1204169240Sjfv
1205169240Sjfv/**
1206169240Sjfv *  e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
1207169589Sjfv *  @hw: pointer to the HW structure
1208169240Sjfv *
1209169240Sjfv *  Updates the NVM checksum. Currently no func pointer exists and all
1210169240Sjfv *  implementations are handled in the generic version of this function.
1211169240Sjfv **/
1212173788Sjfvs32 e1000_update_nvm_checksum(struct e1000_hw *hw)
1213169240Sjfv{
1214177867Sjfv	if (hw->nvm.ops.update)
1215177867Sjfv		return hw->nvm.ops.update(hw);
1216173788Sjfv
1217173788Sjfv	return -E1000_ERR_CONFIG;
1218169240Sjfv}
1219169240Sjfv
1220169240Sjfv/**
1221169240Sjfv *  e1000_reload_nvm - Reloads EEPROM
1222169589Sjfv *  @hw: pointer to the HW structure
1223169240Sjfv *
1224169240Sjfv *  Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1225169240Sjfv *  extended control register.
1226169240Sjfv **/
1227173788Sjfvvoid e1000_reload_nvm(struct e1000_hw *hw)
1228169240Sjfv{
1229177867Sjfv	if (hw->nvm.ops.reload)
1230177867Sjfv		hw->nvm.ops.reload(hw);
1231169240Sjfv}
1232169240Sjfv
1233169240Sjfv/**
1234169240Sjfv *  e1000_read_nvm - Reads NVM (EEPROM)
1235169589Sjfv *  @hw: pointer to the HW structure
1236169589Sjfv *  @offset: the word offset to read
1237169589Sjfv *  @words: number of 16-bit words to read
1238169589Sjfv *  @data: pointer to the properly sized buffer for the data.
1239169240Sjfv *
1240169240Sjfv *  Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1241169240Sjfv *  pointer entry point called by drivers.
1242169240Sjfv **/
1243173788Sjfvs32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1244169240Sjfv{
1245177867Sjfv	if (hw->nvm.ops.read)
1246177867Sjfv		return hw->nvm.ops.read(hw, offset, words, data);
1247173788Sjfv
1248173788Sjfv	return -E1000_ERR_CONFIG;
1249169240Sjfv}
1250169240Sjfv
1251169240Sjfv/**
1252169240Sjfv *  e1000_write_nvm - Writes to NVM (EEPROM)
1253169589Sjfv *  @hw: pointer to the HW structure
1254169589Sjfv *  @offset: the word offset to read
1255169589Sjfv *  @words: number of 16-bit words to write
1256169589Sjfv *  @data: pointer to the properly sized buffer for the data.
1257169240Sjfv *
1258169240Sjfv *  Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1259169240Sjfv *  pointer entry point called by drivers.
1260169240Sjfv **/
1261173788Sjfvs32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1262169240Sjfv{
1263177867Sjfv	if (hw->nvm.ops.write)
1264177867Sjfv		return hw->nvm.ops.write(hw, offset, words, data);
1265173788Sjfv
1266173788Sjfv	return E1000_SUCCESS;
1267169240Sjfv}
1268169240Sjfv
1269169240Sjfv/**
1270169240Sjfv *  e1000_write_8bit_ctrl_reg - Writes 8bit Control register
1271169589Sjfv *  @hw: pointer to the HW structure
1272169589Sjfv *  @reg: 32bit register offset
1273169589Sjfv *  @offset: the register to write
1274169589Sjfv *  @data: the value to write.
1275169240Sjfv *
1276169240Sjfv *  Writes the PHY register at offset with the value in data.
1277169240Sjfv *  This is a function pointer entry point called by drivers.
1278169240Sjfv **/
1279176667Sjfvs32 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset,
1280176667Sjfv                              u8 data)
1281169240Sjfv{
1282169240Sjfv	return e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data);
1283169240Sjfv}
1284173788Sjfv
1285173788Sjfv/**
1286173788Sjfv * e1000_power_up_phy - Restores link in case of PHY power down
1287173788Sjfv * @hw: pointer to the HW structure
1288173788Sjfv *
1289173788Sjfv * The phy may be powered down to save power, to turn off link when the
1290173788Sjfv * driver is unloaded, or wake on lan is not enabled (among others).
1291173788Sjfv **/
1292173788Sjfvvoid e1000_power_up_phy(struct e1000_hw *hw)
1293173788Sjfv{
1294177867Sjfv	if (hw->phy.ops.power_up)
1295177867Sjfv		hw->phy.ops.power_up(hw);
1296173788Sjfv
1297173788Sjfv	e1000_setup_link(hw);
1298173788Sjfv}
1299173788Sjfv
1300173788Sjfv/**
1301176667Sjfv * e1000_power_down_phy - Power down PHY
1302173788Sjfv * @hw: pointer to the HW structure
1303173788Sjfv *
1304173788Sjfv * The phy may be powered down to save power, to turn off link when the
1305173788Sjfv * driver is unloaded, or wake on lan is not enabled (among others).
1306173788Sjfv **/
1307173788Sjfvvoid e1000_power_down_phy(struct e1000_hw *hw)
1308173788Sjfv{
1309177867Sjfv	if (hw->phy.ops.power_down)
1310177867Sjfv		hw->phy.ops.power_down(hw);
1311173788Sjfv}
1312173788Sjfv
1313181027Sjfv/**
1314203049Sjfv *  e1000_power_up_fiber_serdes_link - Power up serdes link
1315203049Sjfv *  @hw: pointer to the HW structure
1316203049Sjfv *
1317203049Sjfv *  Power on the optics and PCS.
1318203049Sjfv **/
1319203049Sjfvvoid e1000_power_up_fiber_serdes_link(struct e1000_hw *hw)
1320203049Sjfv{
1321203049Sjfv	if (hw->mac.ops.power_up_serdes)
1322203049Sjfv		hw->mac.ops.power_up_serdes(hw);
1323203049Sjfv}
1324203049Sjfv
1325203049Sjfv/**
1326181027Sjfv *  e1000_shutdown_fiber_serdes_link - Remove link during power down
1327181027Sjfv *  @hw: pointer to the HW structure
1328181027Sjfv *
1329181027Sjfv *  Shutdown the optics and PCS on driver unload.
1330181027Sjfv **/
1331181027Sjfvvoid e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
1332181027Sjfv{
1333181027Sjfv	if (hw->mac.ops.shutdown_serdes)
1334181027Sjfv		hw->mac.ops.shutdown_serdes(hw);
1335181027Sjfv}
1336181027Sjfv
1337