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