]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/e1000/e1000_api.c
Upgrade to OpenPAM Tabebuia.
[FreeBSD/FreeBSD.git] / sys / dev / e1000 / e1000_api.c
1 /******************************************************************************
2   SPDX-License-Identifier: BSD-3-Clause
3
4   Copyright (c) 2001-2015, Intel Corporation 
5   All rights reserved.
6   
7   Redistribution and use in source and binary forms, with or without 
8   modification, are permitted provided that the following conditions are met:
9   
10    1. Redistributions of source code must retain the above copyright notice, 
11       this list of conditions and the following disclaimer.
12   
13    2. Redistributions in binary form must reproduce the above copyright 
14       notice, this list of conditions and the following disclaimer in the 
15       documentation and/or other materials provided with the distribution.
16   
17    3. Neither the name of the Intel Corporation nor the names of its 
18       contributors may be used to endorse or promote products derived from 
19       this software without specific prior written permission.
20   
21   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
23   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
24   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
25   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
26   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
27   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
28   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
29   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
30   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31   POSSIBILITY OF SUCH DAMAGE.
32
33 ******************************************************************************/
34 /*$FreeBSD$*/
35
36 #include "e1000_api.h"
37
38 /**
39  *  e1000_init_mac_params - Initialize MAC function pointers
40  *  @hw: pointer to the HW structure
41  *
42  *  This function initializes the function pointers for the MAC
43  *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
44  **/
45 s32 e1000_init_mac_params(struct e1000_hw *hw)
46 {
47         s32 ret_val = E1000_SUCCESS;
48
49         if (hw->mac.ops.init_params) {
50                 ret_val = hw->mac.ops.init_params(hw);
51                 if (ret_val) {
52                         DEBUGOUT("MAC Initialization Error\n");
53                         goto out;
54                 }
55         } else {
56                 DEBUGOUT("mac.init_mac_params was NULL\n");
57                 ret_val = -E1000_ERR_CONFIG;
58         }
59
60 out:
61         return ret_val;
62 }
63
64 /**
65  *  e1000_init_nvm_params - Initialize NVM function pointers
66  *  @hw: pointer to the HW structure
67  *
68  *  This function initializes the function pointers for the NVM
69  *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
70  **/
71 s32 e1000_init_nvm_params(struct e1000_hw *hw)
72 {
73         s32 ret_val = E1000_SUCCESS;
74
75         if (hw->nvm.ops.init_params) {
76                 ret_val = hw->nvm.ops.init_params(hw);
77                 if (ret_val) {
78                         DEBUGOUT("NVM Initialization Error\n");
79                         goto out;
80                 }
81         } else {
82                 DEBUGOUT("nvm.init_nvm_params was NULL\n");
83                 ret_val = -E1000_ERR_CONFIG;
84         }
85
86 out:
87         return ret_val;
88 }
89
90 /**
91  *  e1000_init_phy_params - Initialize PHY function pointers
92  *  @hw: pointer to the HW structure
93  *
94  *  This function initializes the function pointers for the PHY
95  *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
96  **/
97 s32 e1000_init_phy_params(struct e1000_hw *hw)
98 {
99         s32 ret_val = E1000_SUCCESS;
100
101         if (hw->phy.ops.init_params) {
102                 ret_val = hw->phy.ops.init_params(hw);
103                 if (ret_val) {
104                         DEBUGOUT("PHY Initialization Error\n");
105                         goto out;
106                 }
107         } else {
108                 DEBUGOUT("phy.init_phy_params was NULL\n");
109                 ret_val =  -E1000_ERR_CONFIG;
110         }
111
112 out:
113         return ret_val;
114 }
115
116 /**
117  *  e1000_init_mbx_params - Initialize mailbox function pointers
118  *  @hw: pointer to the HW structure
119  *
120  *  This function initializes the function pointers for the PHY
121  *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
122  **/
123 s32 e1000_init_mbx_params(struct e1000_hw *hw)
124 {
125         s32 ret_val = E1000_SUCCESS;
126
127         if (hw->mbx.ops.init_params) {
128                 ret_val = hw->mbx.ops.init_params(hw);
129                 if (ret_val) {
130                         DEBUGOUT("Mailbox Initialization Error\n");
131                         goto out;
132                 }
133         } else {
134                 DEBUGOUT("mbx.init_mbx_params was NULL\n");
135                 ret_val =  -E1000_ERR_CONFIG;
136         }
137
138 out:
139         return ret_val;
140 }
141
142 /**
143  *  e1000_set_mac_type - Sets MAC type
144  *  @hw: pointer to the HW structure
145  *
146  *  This function sets the mac type of the adapter based on the
147  *  device ID stored in the hw structure.
148  *  MUST BE FIRST FUNCTION CALLED (explicitly or through
149  *  e1000_setup_init_funcs()).
150  **/
151 s32 e1000_set_mac_type(struct e1000_hw *hw)
152 {
153         struct e1000_mac_info *mac = &hw->mac;
154         s32 ret_val = E1000_SUCCESS;
155
156         DEBUGFUNC("e1000_set_mac_type");
157
158         switch (hw->device_id) {
159         case E1000_DEV_ID_82542:
160                 mac->type = e1000_82542;
161                 break;
162         case E1000_DEV_ID_82543GC_FIBER:
163         case E1000_DEV_ID_82543GC_COPPER:
164                 mac->type = e1000_82543;
165                 break;
166         case E1000_DEV_ID_82544EI_COPPER:
167         case E1000_DEV_ID_82544EI_FIBER:
168         case E1000_DEV_ID_82544GC_COPPER:
169         case E1000_DEV_ID_82544GC_LOM:
170                 mac->type = e1000_82544;
171                 break;
172         case E1000_DEV_ID_82540EM:
173         case E1000_DEV_ID_82540EM_LOM:
174         case E1000_DEV_ID_82540EP:
175         case E1000_DEV_ID_82540EP_LOM:
176         case E1000_DEV_ID_82540EP_LP:
177                 mac->type = e1000_82540;
178                 break;
179         case E1000_DEV_ID_82545EM_COPPER:
180         case E1000_DEV_ID_82545EM_FIBER:
181                 mac->type = e1000_82545;
182                 break;
183         case E1000_DEV_ID_82545GM_COPPER:
184         case E1000_DEV_ID_82545GM_FIBER:
185         case E1000_DEV_ID_82545GM_SERDES:
186                 mac->type = e1000_82545_rev_3;
187                 break;
188         case E1000_DEV_ID_82546EB_COPPER:
189         case E1000_DEV_ID_82546EB_FIBER:
190         case E1000_DEV_ID_82546EB_QUAD_COPPER:
191                 mac->type = e1000_82546;
192                 break;
193         case E1000_DEV_ID_82546GB_COPPER:
194         case E1000_DEV_ID_82546GB_FIBER:
195         case E1000_DEV_ID_82546GB_SERDES:
196         case E1000_DEV_ID_82546GB_PCIE:
197         case E1000_DEV_ID_82546GB_QUAD_COPPER:
198         case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
199                 mac->type = e1000_82546_rev_3;
200                 break;
201         case E1000_DEV_ID_82541EI:
202         case E1000_DEV_ID_82541EI_MOBILE:
203         case E1000_DEV_ID_82541ER_LOM:
204                 mac->type = e1000_82541;
205                 break;
206         case E1000_DEV_ID_82541ER:
207         case E1000_DEV_ID_82541GI:
208         case E1000_DEV_ID_82541GI_LF:
209         case E1000_DEV_ID_82541GI_MOBILE:
210                 mac->type = e1000_82541_rev_2;
211                 break;
212         case E1000_DEV_ID_82547EI:
213         case E1000_DEV_ID_82547EI_MOBILE:
214                 mac->type = e1000_82547;
215                 break;
216         case E1000_DEV_ID_82547GI:
217                 mac->type = e1000_82547_rev_2;
218                 break;
219         case E1000_DEV_ID_82571EB_COPPER:
220         case E1000_DEV_ID_82571EB_FIBER:
221         case E1000_DEV_ID_82571EB_SERDES:
222         case E1000_DEV_ID_82571EB_SERDES_DUAL:
223         case E1000_DEV_ID_82571EB_SERDES_QUAD:
224         case E1000_DEV_ID_82571EB_QUAD_COPPER:
225         case E1000_DEV_ID_82571PT_QUAD_COPPER:
226         case E1000_DEV_ID_82571EB_QUAD_FIBER:
227         case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
228                 mac->type = e1000_82571;
229                 break;
230         case E1000_DEV_ID_82572EI:
231         case E1000_DEV_ID_82572EI_COPPER:
232         case E1000_DEV_ID_82572EI_FIBER:
233         case E1000_DEV_ID_82572EI_SERDES:
234                 mac->type = e1000_82572;
235                 break;
236         case E1000_DEV_ID_82573E:
237         case E1000_DEV_ID_82573E_IAMT:
238         case E1000_DEV_ID_82573L:
239                 mac->type = e1000_82573;
240                 break;
241         case E1000_DEV_ID_82574L:
242         case E1000_DEV_ID_82574LA:
243                 mac->type = e1000_82574;
244                 break;
245         case E1000_DEV_ID_82583V:
246                 mac->type = e1000_82583;
247                 break;
248         case E1000_DEV_ID_80003ES2LAN_COPPER_DPT:
249         case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
250         case E1000_DEV_ID_80003ES2LAN_COPPER_SPT:
251         case E1000_DEV_ID_80003ES2LAN_SERDES_SPT:
252                 mac->type = e1000_80003es2lan;
253                 break;
254         case E1000_DEV_ID_ICH8_IFE:
255         case E1000_DEV_ID_ICH8_IFE_GT:
256         case E1000_DEV_ID_ICH8_IFE_G:
257         case E1000_DEV_ID_ICH8_IGP_M:
258         case E1000_DEV_ID_ICH8_IGP_M_AMT:
259         case E1000_DEV_ID_ICH8_IGP_AMT:
260         case E1000_DEV_ID_ICH8_IGP_C:
261         case E1000_DEV_ID_ICH8_82567V_3:
262                 mac->type = e1000_ich8lan;
263                 break;
264         case E1000_DEV_ID_ICH9_IFE:
265         case E1000_DEV_ID_ICH9_IFE_GT:
266         case E1000_DEV_ID_ICH9_IFE_G:
267         case E1000_DEV_ID_ICH9_IGP_M:
268         case E1000_DEV_ID_ICH9_IGP_M_AMT:
269         case E1000_DEV_ID_ICH9_IGP_M_V:
270         case E1000_DEV_ID_ICH9_IGP_AMT:
271         case E1000_DEV_ID_ICH9_BM:
272         case E1000_DEV_ID_ICH9_IGP_C:
273         case E1000_DEV_ID_ICH10_R_BM_LM:
274         case E1000_DEV_ID_ICH10_R_BM_LF:
275         case E1000_DEV_ID_ICH10_R_BM_V:
276                 mac->type = e1000_ich9lan;
277                 break;
278         case E1000_DEV_ID_ICH10_D_BM_LM:
279         case E1000_DEV_ID_ICH10_D_BM_LF:
280         case E1000_DEV_ID_ICH10_D_BM_V:
281                 mac->type = e1000_ich10lan;
282                 break;
283         case E1000_DEV_ID_PCH_D_HV_DM:
284         case E1000_DEV_ID_PCH_D_HV_DC:
285         case E1000_DEV_ID_PCH_M_HV_LM:
286         case E1000_DEV_ID_PCH_M_HV_LC:
287                 mac->type = e1000_pchlan;
288                 break;
289         case E1000_DEV_ID_PCH2_LV_LM:
290         case E1000_DEV_ID_PCH2_LV_V:
291                 mac->type = e1000_pch2lan;
292                 break;
293         case E1000_DEV_ID_PCH_LPT_I217_LM:
294         case E1000_DEV_ID_PCH_LPT_I217_V:
295         case E1000_DEV_ID_PCH_LPTLP_I218_LM:
296         case E1000_DEV_ID_PCH_LPTLP_I218_V:
297         case E1000_DEV_ID_PCH_I218_LM2:
298         case E1000_DEV_ID_PCH_I218_V2:
299         case E1000_DEV_ID_PCH_I218_LM3:
300         case E1000_DEV_ID_PCH_I218_V3:
301                 mac->type = e1000_pch_lpt;
302                 break;
303         case E1000_DEV_ID_PCH_SPT_I219_LM:
304         case E1000_DEV_ID_PCH_SPT_I219_V:
305         case E1000_DEV_ID_PCH_SPT_I219_LM2:
306         case E1000_DEV_ID_PCH_SPT_I219_V2:
307         case E1000_DEV_ID_PCH_LBG_I219_LM3:
308         case E1000_DEV_ID_PCH_SPT_I219_LM4:
309         case E1000_DEV_ID_PCH_SPT_I219_V4:
310         case E1000_DEV_ID_PCH_SPT_I219_LM5:
311         case E1000_DEV_ID_PCH_SPT_I219_V5:
312                 mac->type = e1000_pch_spt;
313                 break;
314         case E1000_DEV_ID_PCH_CNP_I219_LM6:
315         case E1000_DEV_ID_PCH_CNP_I219_V6:
316         case E1000_DEV_ID_PCH_CNP_I219_LM7:
317         case E1000_DEV_ID_PCH_CNP_I219_V7:
318         case E1000_DEV_ID_PCH_ICP_I219_LM8:
319         case E1000_DEV_ID_PCH_ICP_I219_V8:
320         case E1000_DEV_ID_PCH_ICP_I219_LM9:
321         case E1000_DEV_ID_PCH_ICP_I219_V9:
322                 mac->type = e1000_pch_cnp;
323                 break;
324         case E1000_DEV_ID_82575EB_COPPER:
325         case E1000_DEV_ID_82575EB_FIBER_SERDES:
326         case E1000_DEV_ID_82575GB_QUAD_COPPER:
327                 mac->type = e1000_82575;
328                 break;
329         case E1000_DEV_ID_82576:
330         case E1000_DEV_ID_82576_FIBER:
331         case E1000_DEV_ID_82576_SERDES:
332         case E1000_DEV_ID_82576_QUAD_COPPER:
333         case E1000_DEV_ID_82576_QUAD_COPPER_ET2:
334         case E1000_DEV_ID_82576_NS:
335         case E1000_DEV_ID_82576_NS_SERDES:
336         case E1000_DEV_ID_82576_SERDES_QUAD:
337                 mac->type = e1000_82576;
338                 break;
339         case E1000_DEV_ID_82580_COPPER:
340         case E1000_DEV_ID_82580_FIBER:
341         case E1000_DEV_ID_82580_SERDES:
342         case E1000_DEV_ID_82580_SGMII:
343         case E1000_DEV_ID_82580_COPPER_DUAL:
344         case E1000_DEV_ID_82580_QUAD_FIBER:
345         case E1000_DEV_ID_DH89XXCC_SGMII:
346         case E1000_DEV_ID_DH89XXCC_SERDES:
347         case E1000_DEV_ID_DH89XXCC_BACKPLANE:
348         case E1000_DEV_ID_DH89XXCC_SFP:
349                 mac->type = e1000_82580;
350                 break;
351         case E1000_DEV_ID_I350_COPPER:
352         case E1000_DEV_ID_I350_FIBER:
353         case E1000_DEV_ID_I350_SERDES:
354         case E1000_DEV_ID_I350_SGMII:
355         case E1000_DEV_ID_I350_DA4:
356                 mac->type = e1000_i350;
357                 break;
358         case E1000_DEV_ID_I210_COPPER_FLASHLESS:
359         case E1000_DEV_ID_I210_SERDES_FLASHLESS:
360         case E1000_DEV_ID_I210_COPPER:
361         case E1000_DEV_ID_I210_COPPER_OEM1:
362         case E1000_DEV_ID_I210_COPPER_IT:
363         case E1000_DEV_ID_I210_FIBER:
364         case E1000_DEV_ID_I210_SERDES:
365         case E1000_DEV_ID_I210_SGMII:
366                 mac->type = e1000_i210;
367                 break;
368         case E1000_DEV_ID_I211_COPPER:
369                 mac->type = e1000_i211;
370                 break;
371         case E1000_DEV_ID_82576_VF:
372         case E1000_DEV_ID_82576_VF_HV:
373                 mac->type = e1000_vfadapt;
374                 break;
375         case E1000_DEV_ID_I350_VF:
376         case E1000_DEV_ID_I350_VF_HV:
377                 mac->type = e1000_vfadapt_i350;
378                 break;
379
380         case E1000_DEV_ID_I354_BACKPLANE_1GBPS:
381         case E1000_DEV_ID_I354_SGMII:
382         case E1000_DEV_ID_I354_BACKPLANE_2_5GBPS:
383                 mac->type = e1000_i354;
384                 break;
385         default:
386                 /* Should never have loaded on this device */
387                 ret_val = -E1000_ERR_MAC_INIT;
388                 break;
389         }
390
391         return ret_val;
392 }
393
394 /**
395  *  e1000_setup_init_funcs - Initializes function pointers
396  *  @hw: pointer to the HW structure
397  *  @init_device: TRUE will initialize the rest of the function pointers
398  *                getting the device ready for use.  FALSE will only set
399  *                MAC type and the function pointers for the other init
400  *                functions.  Passing FALSE will not generate any hardware
401  *                reads or writes.
402  *
403  *  This function must be called by a driver in order to use the rest
404  *  of the 'shared' code files. Called by drivers only.
405  **/
406 s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
407 {
408         s32 ret_val;
409
410         /* Can't do much good without knowing the MAC type. */
411         ret_val = e1000_set_mac_type(hw);
412         if (ret_val) {
413                 DEBUGOUT("ERROR: MAC type could not be set properly.\n");
414                 goto out;
415         }
416
417         if (!hw->hw_addr) {
418                 DEBUGOUT("ERROR: Registers not mapped\n");
419                 ret_val = -E1000_ERR_CONFIG;
420                 goto out;
421         }
422
423         /*
424          * Init function pointers to generic implementations. We do this first
425          * allowing a driver module to override it afterward.
426          */
427         e1000_init_mac_ops_generic(hw);
428         e1000_init_phy_ops_generic(hw);
429         e1000_init_nvm_ops_generic(hw);
430         e1000_init_mbx_ops_generic(hw);
431
432         /*
433          * Set up the init function pointers. These are functions within the
434          * adapter family file that sets up function pointers for the rest of
435          * the functions in that family.
436          */
437         switch (hw->mac.type) {
438         case e1000_82542:
439                 e1000_init_function_pointers_82542(hw);
440                 break;
441         case e1000_82543:
442         case e1000_82544:
443                 e1000_init_function_pointers_82543(hw);
444                 break;
445         case e1000_82540:
446         case e1000_82545:
447         case e1000_82545_rev_3:
448         case e1000_82546:
449         case e1000_82546_rev_3:
450                 e1000_init_function_pointers_82540(hw);
451                 break;
452         case e1000_82541:
453         case e1000_82541_rev_2:
454         case e1000_82547:
455         case e1000_82547_rev_2:
456                 e1000_init_function_pointers_82541(hw);
457                 break;
458         case e1000_82571:
459         case e1000_82572:
460         case e1000_82573:
461         case e1000_82574:
462         case e1000_82583:
463                 e1000_init_function_pointers_82571(hw);
464                 break;
465         case e1000_80003es2lan:
466                 e1000_init_function_pointers_80003es2lan(hw);
467                 break;
468         case e1000_ich8lan:
469         case e1000_ich9lan:
470         case e1000_ich10lan:
471         case e1000_pchlan:
472         case e1000_pch2lan:
473         case e1000_pch_lpt:
474         case e1000_pch_spt:
475         case e1000_pch_cnp:
476                 e1000_init_function_pointers_ich8lan(hw);
477                 break;
478         case e1000_82575:
479         case e1000_82576:
480         case e1000_82580:
481         case e1000_i350:
482         case e1000_i354:
483                 e1000_init_function_pointers_82575(hw);
484                 break;
485         case e1000_i210:
486         case e1000_i211:
487                 e1000_init_function_pointers_i210(hw);
488                 break;
489         case e1000_vfadapt:
490                 e1000_init_function_pointers_vf(hw);
491                 break;
492         case e1000_vfadapt_i350:
493                 e1000_init_function_pointers_vf(hw);
494                 break;
495         default:
496                 DEBUGOUT("Hardware not supported\n");
497                 ret_val = -E1000_ERR_CONFIG;
498                 break;
499         }
500
501         /*
502          * Initialize the rest of the function pointers. These require some
503          * register reads/writes in some cases.
504          */
505         if (!(ret_val) && init_device) {
506                 ret_val = e1000_init_mac_params(hw);
507                 if (ret_val)
508                         goto out;
509
510                 ret_val = e1000_init_nvm_params(hw);
511                 if (ret_val)
512                         goto out;
513
514                 ret_val = e1000_init_phy_params(hw);
515                 if (ret_val)
516                         goto out;
517
518                 ret_val = e1000_init_mbx_params(hw);
519                 if (ret_val)
520                         goto out;
521         }
522
523 out:
524         return ret_val;
525 }
526
527 /**
528  *  e1000_get_bus_info - Obtain bus information for adapter
529  *  @hw: pointer to the HW structure
530  *
531  *  This will obtain information about the HW bus for which the
532  *  adapter is attached and stores it in the hw structure. This is a
533  *  function pointer entry point called by drivers.
534  **/
535 s32 e1000_get_bus_info(struct e1000_hw *hw)
536 {
537         if (hw->mac.ops.get_bus_info)
538                 return hw->mac.ops.get_bus_info(hw);
539
540         return E1000_SUCCESS;
541 }
542
543 /**
544  *  e1000_clear_vfta - Clear VLAN filter table
545  *  @hw: pointer to the HW structure
546  *
547  *  This clears the VLAN filter table on the adapter. This is a function
548  *  pointer entry point called by drivers.
549  **/
550 void e1000_clear_vfta(struct e1000_hw *hw)
551 {
552         if (hw->mac.ops.clear_vfta)
553                 hw->mac.ops.clear_vfta(hw);
554 }
555
556 /**
557  *  e1000_write_vfta - Write value to VLAN filter table
558  *  @hw: pointer to the HW structure
559  *  @offset: the 32-bit offset in which to write the value to.
560  *  @value: the 32-bit value to write at location offset.
561  *
562  *  This writes a 32-bit value to a 32-bit offset in the VLAN filter
563  *  table. This is a function pointer entry point called by drivers.
564  **/
565 void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
566 {
567         if (hw->mac.ops.write_vfta)
568                 hw->mac.ops.write_vfta(hw, offset, value);
569 }
570
571 /**
572  *  e1000_update_mc_addr_list - Update Multicast addresses
573  *  @hw: pointer to the HW structure
574  *  @mc_addr_list: array of multicast addresses to program
575  *  @mc_addr_count: number of multicast addresses to program
576  *
577  *  Updates the Multicast Table Array.
578  *  The caller must have a packed mc_addr_list of multicast addresses.
579  **/
580 void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
581                                u32 mc_addr_count)
582 {
583         if (hw->mac.ops.update_mc_addr_list)
584                 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list,
585                                                 mc_addr_count);
586 }
587
588 /**
589  *  e1000_force_mac_fc - Force MAC flow control
590  *  @hw: pointer to the HW structure
591  *
592  *  Force the MAC's flow control settings. Currently no func pointer exists
593  *  and all implementations are handled in the generic version of this
594  *  function.
595  **/
596 s32 e1000_force_mac_fc(struct e1000_hw *hw)
597 {
598         return e1000_force_mac_fc_generic(hw);
599 }
600
601 /**
602  *  e1000_check_for_link - Check/Store link connection
603  *  @hw: pointer to the HW structure
604  *
605  *  This checks the link condition of the adapter and stores the
606  *  results in the hw->mac structure. This is a function pointer entry
607  *  point called by drivers.
608  **/
609 s32 e1000_check_for_link(struct e1000_hw *hw)
610 {
611         if (hw->mac.ops.check_for_link)
612                 return hw->mac.ops.check_for_link(hw);
613
614         return -E1000_ERR_CONFIG;
615 }
616
617 /**
618  *  e1000_check_mng_mode - Check management mode
619  *  @hw: pointer to the HW structure
620  *
621  *  This checks if the adapter has manageability enabled.
622  *  This is a function pointer entry point called by drivers.
623  **/
624 bool e1000_check_mng_mode(struct e1000_hw *hw)
625 {
626         if (hw->mac.ops.check_mng_mode)
627                 return hw->mac.ops.check_mng_mode(hw);
628
629         return FALSE;
630 }
631
632 /**
633  *  e1000_mng_write_dhcp_info - Writes DHCP info to host interface
634  *  @hw: pointer to the HW structure
635  *  @buffer: pointer to the host interface
636  *  @length: size of the buffer
637  *
638  *  Writes the DHCP information to the host interface.
639  **/
640 s32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
641 {
642         return e1000_mng_write_dhcp_info_generic(hw, buffer, length);
643 }
644
645 /**
646  *  e1000_reset_hw - Reset hardware
647  *  @hw: pointer to the HW structure
648  *
649  *  This resets the hardware into a known state. This is a function pointer
650  *  entry point called by drivers.
651  **/
652 s32 e1000_reset_hw(struct e1000_hw *hw)
653 {
654         if (hw->mac.ops.reset_hw)
655                 return hw->mac.ops.reset_hw(hw);
656
657         return -E1000_ERR_CONFIG;
658 }
659
660 /**
661  *  e1000_init_hw - Initialize hardware
662  *  @hw: pointer to the HW structure
663  *
664  *  This inits the hardware readying it for operation. This is a function
665  *  pointer entry point called by drivers.
666  **/
667 s32 e1000_init_hw(struct e1000_hw *hw)
668 {
669         if (hw->mac.ops.init_hw)
670                 return hw->mac.ops.init_hw(hw);
671
672         return -E1000_ERR_CONFIG;
673 }
674
675 /**
676  *  e1000_setup_link - Configures link and flow control
677  *  @hw: pointer to the HW structure
678  *
679  *  This configures link and flow control settings for the adapter. This
680  *  is a function pointer entry point called by drivers. While modules can
681  *  also call this, they probably call their own version of this function.
682  **/
683 s32 e1000_setup_link(struct e1000_hw *hw)
684 {
685         if (hw->mac.ops.setup_link)
686                 return hw->mac.ops.setup_link(hw);
687
688         return -E1000_ERR_CONFIG;
689 }
690
691 /**
692  *  e1000_get_speed_and_duplex - Returns current speed and duplex
693  *  @hw: pointer to the HW structure
694  *  @speed: pointer to a 16-bit value to store the speed
695  *  @duplex: pointer to a 16-bit value to store the duplex.
696  *
697  *  This returns the speed and duplex of the adapter in the two 'out'
698  *  variables passed in. This is a function pointer entry point called
699  *  by drivers.
700  **/
701 s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
702 {
703         if (hw->mac.ops.get_link_up_info)
704                 return hw->mac.ops.get_link_up_info(hw, speed, duplex);
705
706         return -E1000_ERR_CONFIG;
707 }
708
709 /**
710  *  e1000_setup_led - Configures SW controllable LED
711  *  @hw: pointer to the HW structure
712  *
713  *  This prepares the SW controllable LED for use and saves the current state
714  *  of the LED so it can be later restored. This is a function pointer entry
715  *  point called by drivers.
716  **/
717 s32 e1000_setup_led(struct e1000_hw *hw)
718 {
719         if (hw->mac.ops.setup_led)
720                 return hw->mac.ops.setup_led(hw);
721
722         return E1000_SUCCESS;
723 }
724
725 /**
726  *  e1000_cleanup_led - Restores SW controllable LED
727  *  @hw: pointer to the HW structure
728  *
729  *  This restores the SW controllable LED to the value saved off by
730  *  e1000_setup_led. This is a function pointer entry point called by drivers.
731  **/
732 s32 e1000_cleanup_led(struct e1000_hw *hw)
733 {
734         if (hw->mac.ops.cleanup_led)
735                 return hw->mac.ops.cleanup_led(hw);
736
737         return E1000_SUCCESS;
738 }
739
740 /**
741  *  e1000_blink_led - Blink SW controllable LED
742  *  @hw: pointer to the HW structure
743  *
744  *  This starts the adapter LED blinking. Request the LED to be setup first
745  *  and cleaned up after. This is a function pointer entry point called by
746  *  drivers.
747  **/
748 s32 e1000_blink_led(struct e1000_hw *hw)
749 {
750         if (hw->mac.ops.blink_led)
751                 return hw->mac.ops.blink_led(hw);
752
753         return E1000_SUCCESS;
754 }
755
756 /**
757  *  e1000_id_led_init - store LED configurations in SW
758  *  @hw: pointer to the HW structure
759  *
760  *  Initializes the LED config in SW. This is a function pointer entry point
761  *  called by drivers.
762  **/
763 s32 e1000_id_led_init(struct e1000_hw *hw)
764 {
765         if (hw->mac.ops.id_led_init)
766                 return hw->mac.ops.id_led_init(hw);
767
768         return E1000_SUCCESS;
769 }
770
771 /**
772  *  e1000_led_on - Turn on SW controllable LED
773  *  @hw: pointer to the HW structure
774  *
775  *  Turns the SW defined LED on. This is a function pointer entry point
776  *  called by drivers.
777  **/
778 s32 e1000_led_on(struct e1000_hw *hw)
779 {
780         if (hw->mac.ops.led_on)
781                 return hw->mac.ops.led_on(hw);
782
783         return E1000_SUCCESS;
784 }
785
786 /**
787  *  e1000_led_off - Turn off SW controllable LED
788  *  @hw: pointer to the HW structure
789  *
790  *  Turns the SW defined LED off. This is a function pointer entry point
791  *  called by drivers.
792  **/
793 s32 e1000_led_off(struct e1000_hw *hw)
794 {
795         if (hw->mac.ops.led_off)
796                 return hw->mac.ops.led_off(hw);
797
798         return E1000_SUCCESS;
799 }
800
801 /**
802  *  e1000_reset_adaptive - Reset adaptive IFS
803  *  @hw: pointer to the HW structure
804  *
805  *  Resets the adaptive IFS. Currently no func pointer exists and all
806  *  implementations are handled in the generic version of this function.
807  **/
808 void e1000_reset_adaptive(struct e1000_hw *hw)
809 {
810         e1000_reset_adaptive_generic(hw);
811 }
812
813 /**
814  *  e1000_update_adaptive - Update adaptive IFS
815  *  @hw: pointer to the HW structure
816  *
817  *  Updates adapter IFS. Currently no func pointer exists and all
818  *  implementations are handled in the generic version of this function.
819  **/
820 void e1000_update_adaptive(struct e1000_hw *hw)
821 {
822         e1000_update_adaptive_generic(hw);
823 }
824
825 /**
826  *  e1000_disable_pcie_master - Disable PCI-Express master access
827  *  @hw: pointer to the HW structure
828  *
829  *  Disables PCI-Express master access and verifies there are no pending
830  *  requests. Currently no func pointer exists and all implementations are
831  *  handled in the generic version of this function.
832  **/
833 s32 e1000_disable_pcie_master(struct e1000_hw *hw)
834 {
835         return e1000_disable_pcie_master_generic(hw);
836 }
837
838 /**
839  *  e1000_config_collision_dist - Configure collision distance
840  *  @hw: pointer to the HW structure
841  *
842  *  Configures the collision distance to the default value and is used
843  *  during link setup.
844  **/
845 void e1000_config_collision_dist(struct e1000_hw *hw)
846 {
847         if (hw->mac.ops.config_collision_dist)
848                 hw->mac.ops.config_collision_dist(hw);
849 }
850
851 /**
852  *  e1000_rar_set - Sets a receive address register
853  *  @hw: pointer to the HW structure
854  *  @addr: address to set the RAR to
855  *  @index: the RAR to set
856  *
857  *  Sets a Receive Address Register (RAR) to the specified address.
858  **/
859 int e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
860 {
861         if (hw->mac.ops.rar_set)
862                 return hw->mac.ops.rar_set(hw, addr, index);
863
864         return E1000_SUCCESS;
865 }
866
867 /**
868  *  e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
869  *  @hw: pointer to the HW structure
870  *
871  *  Ensures that the MDI/MDIX SW state is valid.
872  **/
873 s32 e1000_validate_mdi_setting(struct e1000_hw *hw)
874 {
875         if (hw->mac.ops.validate_mdi_setting)
876                 return hw->mac.ops.validate_mdi_setting(hw);
877
878         return E1000_SUCCESS;
879 }
880
881 /**
882  *  e1000_hash_mc_addr - Determines address location in multicast table
883  *  @hw: pointer to the HW structure
884  *  @mc_addr: Multicast address to hash.
885  *
886  *  This hashes an address to determine its location in the multicast
887  *  table. Currently no func pointer exists and all implementations
888  *  are handled in the generic version of this function.
889  **/
890 u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
891 {
892         return e1000_hash_mc_addr_generic(hw, mc_addr);
893 }
894
895 /**
896  *  e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
897  *  @hw: pointer to the HW structure
898  *
899  *  Enables packet filtering on transmit packets if manageability is enabled
900  *  and host interface is enabled.
901  *  Currently no func pointer exists and all implementations are handled in the
902  *  generic version of this function.
903  **/
904 bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
905 {
906         return e1000_enable_tx_pkt_filtering_generic(hw);
907 }
908
909 /**
910  *  e1000_mng_host_if_write - Writes to the manageability host interface
911  *  @hw: pointer to the HW structure
912  *  @buffer: pointer to the host interface buffer
913  *  @length: size of the buffer
914  *  @offset: location in the buffer to write to
915  *  @sum: sum of the data (not checksum)
916  *
917  *  This function writes the buffer content at the offset given on the host if.
918  *  It also does alignment considerations to do the writes in most efficient
919  *  way.  Also fills up the sum of the buffer in *buffer parameter.
920  **/
921 s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
922                             u16 offset, u8 *sum)
923 {
924         return e1000_mng_host_if_write_generic(hw, buffer, length, offset, sum);
925 }
926
927 /**
928  *  e1000_mng_write_cmd_header - Writes manageability command header
929  *  @hw: pointer to the HW structure
930  *  @hdr: pointer to the host interface command header
931  *
932  *  Writes the command header after does the checksum calculation.
933  **/
934 s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
935                                struct e1000_host_mng_command_header *hdr)
936 {
937         return e1000_mng_write_cmd_header_generic(hw, hdr);
938 }
939
940 /**
941  *  e1000_mng_enable_host_if - Checks host interface is enabled
942  *  @hw: pointer to the HW structure
943  *
944  *  Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
945  *
946  *  This function checks whether the HOST IF is enabled for command operation
947  *  and also checks whether the previous command is completed.  It busy waits
948  *  in case of previous command is not completed.
949  **/
950 s32 e1000_mng_enable_host_if(struct e1000_hw *hw)
951 {
952         return e1000_mng_enable_host_if_generic(hw);
953 }
954
955 /**
956  *  e1000_set_obff_timer - Set Optimized Buffer Flush/Fill timer
957  *  @hw: pointer to the HW structure
958  *  @itr: u32 indicating itr value
959  *
960  *  Set the OBFF timer based on the given interrupt rate.
961  **/
962 s32 e1000_set_obff_timer(struct e1000_hw *hw, u32 itr)
963 {
964         if (hw->mac.ops.set_obff_timer)
965                 return hw->mac.ops.set_obff_timer(hw, itr);
966
967         return E1000_SUCCESS;
968 }
969
970 /**
971  *  e1000_check_reset_block - Verifies PHY can be reset
972  *  @hw: pointer to the HW structure
973  *
974  *  Checks if the PHY is in a state that can be reset or if manageability
975  *  has it tied up. This is a function pointer entry point called by drivers.
976  **/
977 s32 e1000_check_reset_block(struct e1000_hw *hw)
978 {
979         if (hw->phy.ops.check_reset_block)
980                 return hw->phy.ops.check_reset_block(hw);
981
982         return E1000_SUCCESS;
983 }
984
985 /**
986  *  e1000_read_phy_reg - Reads PHY register
987  *  @hw: pointer to the HW structure
988  *  @offset: the register to read
989  *  @data: the buffer to store the 16-bit read.
990  *
991  *  Reads the PHY register and returns the value in data.
992  *  This is a function pointer entry point called by drivers.
993  **/
994 s32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
995 {
996         if (hw->phy.ops.read_reg)
997                 return hw->phy.ops.read_reg(hw, offset, data);
998
999         return E1000_SUCCESS;
1000 }
1001
1002 /**
1003  *  e1000_write_phy_reg - Writes PHY register
1004  *  @hw: pointer to the HW structure
1005  *  @offset: the register to write
1006  *  @data: the value to write.
1007  *
1008  *  Writes the PHY register at offset with the value in data.
1009  *  This is a function pointer entry point called by drivers.
1010  **/
1011 s32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
1012 {
1013         if (hw->phy.ops.write_reg)
1014                 return hw->phy.ops.write_reg(hw, offset, data);
1015
1016         return E1000_SUCCESS;
1017 }
1018
1019 /**
1020  *  e1000_release_phy - Generic release PHY
1021  *  @hw: pointer to the HW structure
1022  *
1023  *  Return if silicon family does not require a semaphore when accessing the
1024  *  PHY.
1025  **/
1026 void e1000_release_phy(struct e1000_hw *hw)
1027 {
1028         if (hw->phy.ops.release)
1029                 hw->phy.ops.release(hw);
1030 }
1031
1032 /**
1033  *  e1000_acquire_phy - Generic acquire PHY
1034  *  @hw: pointer to the HW structure
1035  *
1036  *  Return success if silicon family does not require a semaphore when
1037  *  accessing the PHY.
1038  **/
1039 s32 e1000_acquire_phy(struct e1000_hw *hw)
1040 {
1041         if (hw->phy.ops.acquire)
1042                 return hw->phy.ops.acquire(hw);
1043
1044         return E1000_SUCCESS;
1045 }
1046
1047 /**
1048  *  e1000_cfg_on_link_up - Configure PHY upon link up
1049  *  @hw: pointer to the HW structure
1050  **/
1051 s32 e1000_cfg_on_link_up(struct e1000_hw *hw)
1052 {
1053         if (hw->phy.ops.cfg_on_link_up)
1054                 return hw->phy.ops.cfg_on_link_up(hw);
1055
1056         return E1000_SUCCESS;
1057 }
1058
1059 /**
1060  *  e1000_read_kmrn_reg - Reads register using Kumeran interface
1061  *  @hw: pointer to the HW structure
1062  *  @offset: the register to read
1063  *  @data: the location to store the 16-bit value read.
1064  *
1065  *  Reads a register out of the Kumeran interface. Currently no func pointer
1066  *  exists and all implementations are handled in the generic version of
1067  *  this function.
1068  **/
1069 s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
1070 {
1071         return e1000_read_kmrn_reg_generic(hw, offset, data);
1072 }
1073
1074 /**
1075  *  e1000_write_kmrn_reg - Writes register using Kumeran interface
1076  *  @hw: pointer to the HW structure
1077  *  @offset: the register to write
1078  *  @data: the value to write.
1079  *
1080  *  Writes a register to the Kumeran interface. Currently no func pointer
1081  *  exists and all implementations are handled in the generic version of
1082  *  this function.
1083  **/
1084 s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
1085 {
1086         return e1000_write_kmrn_reg_generic(hw, offset, data);
1087 }
1088
1089 /**
1090  *  e1000_get_cable_length - Retrieves cable length estimation
1091  *  @hw: pointer to the HW structure
1092  *
1093  *  This function estimates the cable length and stores them in
1094  *  hw->phy.min_length and hw->phy.max_length. This is a function pointer
1095  *  entry point called by drivers.
1096  **/
1097 s32 e1000_get_cable_length(struct e1000_hw *hw)
1098 {
1099         if (hw->phy.ops.get_cable_length)
1100                 return hw->phy.ops.get_cable_length(hw);
1101
1102         return E1000_SUCCESS;
1103 }
1104
1105 /**
1106  *  e1000_get_phy_info - Retrieves PHY information from registers
1107  *  @hw: pointer to the HW structure
1108  *
1109  *  This function gets some information from various PHY registers and
1110  *  populates hw->phy values with it. This is a function pointer entry
1111  *  point called by drivers.
1112  **/
1113 s32 e1000_get_phy_info(struct e1000_hw *hw)
1114 {
1115         if (hw->phy.ops.get_info)
1116                 return hw->phy.ops.get_info(hw);
1117
1118         return E1000_SUCCESS;
1119 }
1120
1121 /**
1122  *  e1000_phy_hw_reset - Hard PHY reset
1123  *  @hw: pointer to the HW structure
1124  *
1125  *  Performs a hard PHY reset. This is a function pointer entry point called
1126  *  by drivers.
1127  **/
1128 s32 e1000_phy_hw_reset(struct e1000_hw *hw)
1129 {
1130         if (hw->phy.ops.reset)
1131                 return hw->phy.ops.reset(hw);
1132
1133         return E1000_SUCCESS;
1134 }
1135
1136 /**
1137  *  e1000_phy_commit - Soft PHY reset
1138  *  @hw: pointer to the HW structure
1139  *
1140  *  Performs a soft PHY reset on those that apply. This is a function pointer
1141  *  entry point called by drivers.
1142  **/
1143 s32 e1000_phy_commit(struct e1000_hw *hw)
1144 {
1145         if (hw->phy.ops.commit)
1146                 return hw->phy.ops.commit(hw);
1147
1148         return E1000_SUCCESS;
1149 }
1150
1151 /**
1152  *  e1000_set_d0_lplu_state - Sets low power link up state for D0
1153  *  @hw: pointer to the HW structure
1154  *  @active: boolean used to enable/disable lplu
1155  *
1156  *  Success returns 0, Failure returns 1
1157  *
1158  *  The low power link up (lplu) state is set to the power management level D0
1159  *  and SmartSpeed is disabled when active is TRUE, else clear lplu for D0
1160  *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
1161  *  is used during Dx states where the power conservation is most important.
1162  *  During driver activity, SmartSpeed should be enabled so performance is
1163  *  maintained.  This is a function pointer entry point called by drivers.
1164  **/
1165 s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
1166 {
1167         if (hw->phy.ops.set_d0_lplu_state)
1168                 return hw->phy.ops.set_d0_lplu_state(hw, active);
1169
1170         return E1000_SUCCESS;
1171 }
1172
1173 /**
1174  *  e1000_set_d3_lplu_state - Sets low power link up state for D3
1175  *  @hw: pointer to the HW structure
1176  *  @active: boolean used to enable/disable lplu
1177  *
1178  *  Success returns 0, Failure returns 1
1179  *
1180  *  The low power link up (lplu) state is set to the power management level D3
1181  *  and SmartSpeed is disabled when active is TRUE, else clear lplu for D3
1182  *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
1183  *  is used during Dx states where the power conservation is most important.
1184  *  During driver activity, SmartSpeed should be enabled so performance is
1185  *  maintained.  This is a function pointer entry point called by drivers.
1186  **/
1187 s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
1188 {
1189         if (hw->phy.ops.set_d3_lplu_state)
1190                 return hw->phy.ops.set_d3_lplu_state(hw, active);
1191
1192         return E1000_SUCCESS;
1193 }
1194
1195 /**
1196  *  e1000_read_mac_addr - Reads MAC address
1197  *  @hw: pointer to the HW structure
1198  *
1199  *  Reads the MAC address out of the adapter and stores it in the HW structure.
1200  *  Currently no func pointer exists and all implementations are handled in the
1201  *  generic version of this function.
1202  **/
1203 s32 e1000_read_mac_addr(struct e1000_hw *hw)
1204 {
1205         if (hw->mac.ops.read_mac_addr)
1206                 return hw->mac.ops.read_mac_addr(hw);
1207
1208         return e1000_read_mac_addr_generic(hw);
1209 }
1210
1211 /**
1212  *  e1000_read_pba_string - Read device part number string
1213  *  @hw: pointer to the HW structure
1214  *  @pba_num: pointer to device part number
1215  *  @pba_num_size: size of part number buffer
1216  *
1217  *  Reads the product board assembly (PBA) number from the EEPROM and stores
1218  *  the value in pba_num.
1219  *  Currently no func pointer exists and all implementations are handled in the
1220  *  generic version of this function.
1221  **/
1222 s32 e1000_read_pba_string(struct e1000_hw *hw, u8 *pba_num, u32 pba_num_size)
1223 {
1224         return e1000_read_pba_string_generic(hw, pba_num, pba_num_size);
1225 }
1226
1227 /**
1228  *  e1000_read_pba_length - Read device part number string length
1229  *  @hw: pointer to the HW structure
1230  *  @pba_num_size: size of part number buffer
1231  *
1232  *  Reads the product board assembly (PBA) number length from the EEPROM and
1233  *  stores the value in pba_num.
1234  *  Currently no func pointer exists and all implementations are handled in the
1235  *  generic version of this function.
1236  **/
1237 s32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size)
1238 {
1239         return e1000_read_pba_length_generic(hw, pba_num_size);
1240 }
1241
1242 /**
1243  *  e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
1244  *  @hw: pointer to the HW structure
1245  *
1246  *  Validates the NVM checksum is correct. This is a function pointer entry
1247  *  point called by drivers.
1248  **/
1249 s32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
1250 {
1251         if (hw->nvm.ops.validate)
1252                 return hw->nvm.ops.validate(hw);
1253
1254         return -E1000_ERR_CONFIG;
1255 }
1256
1257 /**
1258  *  e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
1259  *  @hw: pointer to the HW structure
1260  *
1261  *  Updates the NVM checksum. Currently no func pointer exists and all
1262  *  implementations are handled in the generic version of this function.
1263  **/
1264 s32 e1000_update_nvm_checksum(struct e1000_hw *hw)
1265 {
1266         if (hw->nvm.ops.update)
1267                 return hw->nvm.ops.update(hw);
1268
1269         return -E1000_ERR_CONFIG;
1270 }
1271
1272 /**
1273  *  e1000_reload_nvm - Reloads EEPROM
1274  *  @hw: pointer to the HW structure
1275  *
1276  *  Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1277  *  extended control register.
1278  **/
1279 void e1000_reload_nvm(struct e1000_hw *hw)
1280 {
1281         if (hw->nvm.ops.reload)
1282                 hw->nvm.ops.reload(hw);
1283 }
1284
1285 /**
1286  *  e1000_read_nvm - Reads NVM (EEPROM)
1287  *  @hw: pointer to the HW structure
1288  *  @offset: the word offset to read
1289  *  @words: number of 16-bit words to read
1290  *  @data: pointer to the properly sized buffer for the data.
1291  *
1292  *  Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1293  *  pointer entry point called by drivers.
1294  **/
1295 s32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1296 {
1297         if (hw->nvm.ops.read)
1298                 return hw->nvm.ops.read(hw, offset, words, data);
1299
1300         return -E1000_ERR_CONFIG;
1301 }
1302
1303 /**
1304  *  e1000_write_nvm - Writes to NVM (EEPROM)
1305  *  @hw: pointer to the HW structure
1306  *  @offset: the word offset to read
1307  *  @words: number of 16-bit words to write
1308  *  @data: pointer to the properly sized buffer for the data.
1309  *
1310  *  Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1311  *  pointer entry point called by drivers.
1312  **/
1313 s32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1314 {
1315         if (hw->nvm.ops.write)
1316                 return hw->nvm.ops.write(hw, offset, words, data);
1317
1318         return E1000_SUCCESS;
1319 }
1320
1321 /**
1322  *  e1000_write_8bit_ctrl_reg - Writes 8bit Control register
1323  *  @hw: pointer to the HW structure
1324  *  @reg: 32bit register offset
1325  *  @offset: the register to write
1326  *  @data: the value to write.
1327  *
1328  *  Writes the PHY register at offset with the value in data.
1329  *  This is a function pointer entry point called by drivers.
1330  **/
1331 s32 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset,
1332                               u8 data)
1333 {
1334         return e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data);
1335 }
1336
1337 /**
1338  * e1000_power_up_phy - Restores link in case of PHY power down
1339  * @hw: pointer to the HW structure
1340  *
1341  * The phy may be powered down to save power, to turn off link when the
1342  * driver is unloaded, or wake on lan is not enabled (among others).
1343  **/
1344 void e1000_power_up_phy(struct e1000_hw *hw)
1345 {
1346         if (hw->phy.ops.power_up)
1347                 hw->phy.ops.power_up(hw);
1348
1349         e1000_setup_link(hw);
1350 }
1351
1352 /**
1353  * e1000_power_down_phy - Power down PHY
1354  * @hw: pointer to the HW structure
1355  *
1356  * The phy may be powered down to save power, to turn off link when the
1357  * driver is unloaded, or wake on lan is not enabled (among others).
1358  **/
1359 void e1000_power_down_phy(struct e1000_hw *hw)
1360 {
1361         if (hw->phy.ops.power_down)
1362                 hw->phy.ops.power_down(hw);
1363 }
1364
1365 /**
1366  *  e1000_power_up_fiber_serdes_link - Power up serdes link
1367  *  @hw: pointer to the HW structure
1368  *
1369  *  Power on the optics and PCS.
1370  **/
1371 void e1000_power_up_fiber_serdes_link(struct e1000_hw *hw)
1372 {
1373         if (hw->mac.ops.power_up_serdes)
1374                 hw->mac.ops.power_up_serdes(hw);
1375 }
1376
1377 /**
1378  *  e1000_shutdown_fiber_serdes_link - Remove link during power down
1379  *  @hw: pointer to the HW structure
1380  *
1381  *  Shutdown the optics and PCS on driver unload.
1382  **/
1383 void e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
1384 {
1385         if (hw->mac.ops.shutdown_serdes)
1386                 hw->mac.ops.shutdown_serdes(hw);
1387 }
1388