xref: /onnv-gate/usr/src/uts/common/io/e1000g/e1000_api.c (revision 6735:ba4d622bb38a)
1 /*
2  * This file is provided under a CDDLv1 license.  When using or
3  * redistributing this file, you may do so under this license.
4  * In redistributing this file this license must be included
5  * and no other modification of this header file is permitted.
6  *
7  * CDDL LICENSE SUMMARY
8  *
9  * Copyright(c) 1999 - 2008 Intel Corporation. All rights reserved.
10  *
11  * The contents of this file are subject to the terms of Version
12  * 1.0 of the Common Development and Distribution License (the "License").
13  *
14  * You should have received a copy of the License with this software.
15  * You can obtain a copy of the License at
16  *	http://www.opensolaris.org/os/licensing.
17  * See the License for the specific language governing permissions
18  * and limitations under the License.
19  */
20 
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms of the CDDLv1.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 /*
29  * IntelVersion: 1.79 v2008-02-29
30  */
31 
32 #include "e1000_api.h"
33 #include "e1000_mac.h"
34 #include "e1000_nvm.h"
35 #include "e1000_phy.h"
36 
37 /*
38  * e1000_init_mac_params - Initialize MAC function pointers
39  * @hw: pointer to the HW structure
40  *
41  * This function initializes the function pointers for the MAC
42  * set of functions.  Called by drivers or by e1000_setup_init_funcs.
43  */
44 s32
45 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
72 e1000_init_nvm_params(struct e1000_hw *hw)
73 {
74 	s32 ret_val = E1000_SUCCESS;
75 
76 	if (hw->nvm.ops.init_params) {
77 		ret_val = hw->nvm.ops.init_params(hw);
78 		if (ret_val) {
79 			DEBUGOUT("NVM Initialization Error\n");
80 			goto out;
81 		}
82 	} else {
83 		DEBUGOUT("nvm.init_nvm_params was NULL\n");
84 		ret_val = -E1000_ERR_CONFIG;
85 	}
86 
87 out:
88 	return (ret_val);
89 }
90 
91 /*
92  * e1000_init_phy_params - Initialize PHY function pointers
93  * @hw: pointer to the HW structure
94  *
95  * This function initializes the function pointers for the PHY
96  * set of functions.  Called by drivers or by e1000_setup_init_funcs.
97  */
98 s32
99 e1000_init_phy_params(struct e1000_hw *hw)
100 {
101 	s32 ret_val = E1000_SUCCESS;
102 
103 	if (hw->phy.ops.init_params) {
104 		ret_val = hw->phy.ops.init_params(hw);
105 		if (ret_val) {
106 			DEBUGOUT("PHY Initialization Error\n");
107 			goto out;
108 		}
109 	} else {
110 		DEBUGOUT("phy.init_phy_params was NULL\n");
111 		ret_val = -E1000_ERR_CONFIG;
112 	}
113 
114 out:
115 	return (ret_val);
116 }
117 
118 /*
119  * e1000_set_mac_type - Sets MAC type
120  * @hw: pointer to the HW structure
121  *
122  * This function sets the mac type of the adapter based on the
123  * device ID stored in the hw structure.
124  * MUST BE FIRST FUNCTION CALLED (explicitly or through
125  * e1000_setup_init_funcs()).
126  */
127 s32
128 e1000_set_mac_type(struct e1000_hw *hw)
129 {
130 	struct e1000_mac_info *mac = &hw->mac;
131 	s32 ret_val = E1000_SUCCESS;
132 
133 	DEBUGFUNC("e1000_set_mac_type");
134 
135 	switch (hw->device_id) {
136 	case E1000_DEV_ID_82542:
137 		mac->type = e1000_82542;
138 		break;
139 	case E1000_DEV_ID_82543GC_FIBER:
140 	case E1000_DEV_ID_82543GC_COPPER:
141 		mac->type = e1000_82543;
142 		break;
143 	case E1000_DEV_ID_82544EI_COPPER:
144 	case E1000_DEV_ID_82544EI_FIBER:
145 	case E1000_DEV_ID_82544GC_COPPER:
146 	case E1000_DEV_ID_82544GC_LOM:
147 		mac->type = e1000_82544;
148 		break;
149 	case E1000_DEV_ID_82540EM:
150 	case E1000_DEV_ID_82540EM_LOM:
151 	case E1000_DEV_ID_82540EP:
152 	case E1000_DEV_ID_82540EP_LOM:
153 	case E1000_DEV_ID_82540EP_LP:
154 		mac->type = e1000_82540;
155 		break;
156 	case E1000_DEV_ID_82545EM_COPPER:
157 	case E1000_DEV_ID_82545EM_FIBER:
158 		mac->type = e1000_82545;
159 		break;
160 	case E1000_DEV_ID_82545GM_COPPER:
161 	case E1000_DEV_ID_82545GM_FIBER:
162 	case E1000_DEV_ID_82545GM_SERDES:
163 		mac->type = e1000_82545_rev_3;
164 		break;
165 	case E1000_DEV_ID_82546EB_COPPER:
166 	case E1000_DEV_ID_82546EB_FIBER:
167 	case E1000_DEV_ID_82546EB_QUAD_COPPER:
168 		mac->type = e1000_82546;
169 		break;
170 	case E1000_DEV_ID_82546GB_COPPER:
171 	case E1000_DEV_ID_82546GB_FIBER:
172 	case E1000_DEV_ID_82546GB_SERDES:
173 	case E1000_DEV_ID_82546GB_PCIE:
174 	case E1000_DEV_ID_82546GB_QUAD_COPPER:
175 	case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
176 		mac->type = e1000_82546_rev_3;
177 		break;
178 	case E1000_DEV_ID_82541EI:
179 	case E1000_DEV_ID_82541EI_MOBILE:
180 	case E1000_DEV_ID_82541ER_LOM:
181 		mac->type = e1000_82541;
182 		break;
183 	case E1000_DEV_ID_82541ER:
184 	case E1000_DEV_ID_82541GI:
185 	case E1000_DEV_ID_82541GI_LF:
186 	case E1000_DEV_ID_82541GI_MOBILE:
187 		mac->type = e1000_82541_rev_2;
188 		break;
189 	case E1000_DEV_ID_82547EI:
190 	case E1000_DEV_ID_82547EI_MOBILE:
191 		mac->type = e1000_82547;
192 		break;
193 	case E1000_DEV_ID_82547GI:
194 		mac->type = e1000_82547_rev_2;
195 		break;
196 	case E1000_DEV_ID_82571EB_COPPER:
197 	case E1000_DEV_ID_82571EB_FIBER:
198 	case E1000_DEV_ID_82571EB_SERDES:
199 	case E1000_DEV_ID_82571EB_SERDES_DUAL:
200 	case E1000_DEV_ID_82571EB_SERDES_QUAD:
201 	case E1000_DEV_ID_82571EB_QUAD_COPPER:
202 	case E1000_DEV_ID_82571PT_QUAD_COPPER:
203 	case E1000_DEV_ID_82571EB_QUAD_FIBER:
204 	case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
205 		mac->type = e1000_82571;
206 		break;
207 	case E1000_DEV_ID_82572EI:
208 	case E1000_DEV_ID_82572EI_COPPER:
209 	case E1000_DEV_ID_82572EI_FIBER:
210 	case E1000_DEV_ID_82572EI_SERDES:
211 		mac->type = e1000_82572;
212 		break;
213 	case E1000_DEV_ID_82573E:
214 	case E1000_DEV_ID_82573E_IAMT:
215 	case E1000_DEV_ID_82573L:
216 		mac->type = e1000_82573;
217 		break;
218 	case E1000_DEV_ID_80003ES2LAN_COPPER_DPT:
219 	case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
220 	case E1000_DEV_ID_80003ES2LAN_COPPER_SPT:
221 	case E1000_DEV_ID_80003ES2LAN_SERDES_SPT:
222 		mac->type = e1000_80003es2lan;
223 		break;
224 	case E1000_DEV_ID_ICH8_IFE:
225 	case E1000_DEV_ID_ICH8_IFE_GT:
226 	case E1000_DEV_ID_ICH8_IFE_G:
227 	case E1000_DEV_ID_ICH8_IGP_M:
228 	case E1000_DEV_ID_ICH8_IGP_M_AMT:
229 	case E1000_DEV_ID_ICH8_IGP_AMT:
230 	case E1000_DEV_ID_ICH8_IGP_C:
231 		mac->type = e1000_ich8lan;
232 		break;
233 	case E1000_DEV_ID_ICH9_IFE:
234 	case E1000_DEV_ID_ICH9_IFE_GT:
235 	case E1000_DEV_ID_ICH9_IFE_G:
236 	case E1000_DEV_ID_ICH9_IGP_M:
237 	case E1000_DEV_ID_ICH9_IGP_M_AMT:
238 	case E1000_DEV_ID_ICH9_IGP_M_V:
239 	case E1000_DEV_ID_ICH9_IGP_AMT:
240 	case E1000_DEV_ID_ICH9_BM:
241 	case E1000_DEV_ID_ICH9_IGP_C:
242 	case E1000_DEV_ID_MCCREARY:
243 		mac->type = e1000_ich9lan;
244 		break;
245 	default:
246 		/* Should never have loaded on this device */
247 		ret_val = -E1000_ERR_MAC_INIT;
248 		break;
249 	}
250 
251 	return (ret_val);
252 }
253 
254 /*
255  * e1000_setup_init_funcs - Initializes function pointers
256  * @hw: pointer to the HW structure
257  * @init_device: TRUE will initialize the rest of the function pointers
258  *                getting the device ready for use.  FALSE will only set
259  *                MAC type and the function pointers for the other init
260  *                functions.  Passing FALSE will not generate any hardware
261  *                reads or writes.
262  *
263  * This function must be called by a driver in order to use the rest
264  * of the 'shared' code files. Called by drivers only.
265  */
266 s32
267 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
268 {
269 	s32 ret_val;
270 
271 	/* Can't do much good without knowing the MAC type. */
272 	ret_val = e1000_set_mac_type(hw);
273 	if (ret_val) {
274 		DEBUGOUT("ERROR: MAC type could not be set properly.\n");
275 		goto out;
276 	}
277 	if (!hw->hw_addr) {
278 		DEBUGOUT("ERROR: Registers not mapped\n");
279 		ret_val = -E1000_ERR_CONFIG;
280 		goto out;
281 	}
282 
283 	/*
284 	 * Init function pointers to generic implementations. We do this first
285 	 * allowing a driver module to override it afterward.
286 	 */
287 	e1000_init_mac_ops_generic(hw);
288 	e1000_init_phy_ops_generic(hw);
289 	e1000_init_nvm_ops_generic(hw);
290 
291 	/*
292 	 * Set up the init function pointers. These are functions within the
293 	 * adapter family file that sets up function pointers for the rest of
294 	 * the functions in that family.
295 	 */
296 	switch (hw->mac.type) {
297 	case e1000_82542:
298 		e1000_init_function_pointers_82542(hw);
299 		break;
300 	case e1000_82543:
301 	case e1000_82544:
302 		e1000_init_function_pointers_82543(hw);
303 		break;
304 	case e1000_82540:
305 	case e1000_82545:
306 	case e1000_82545_rev_3:
307 	case e1000_82546:
308 	case e1000_82546_rev_3:
309 		e1000_init_function_pointers_82540(hw);
310 		break;
311 	case e1000_82541:
312 	case e1000_82541_rev_2:
313 	case e1000_82547:
314 	case e1000_82547_rev_2:
315 		e1000_init_function_pointers_82541(hw);
316 		break;
317 	case e1000_82571:
318 	case e1000_82572:
319 	case e1000_82573:
320 		e1000_init_function_pointers_82571(hw);
321 		break;
322 	case e1000_80003es2lan:
323 		e1000_init_function_pointers_80003es2lan(hw);
324 		break;
325 	case e1000_ich8lan:
326 	case e1000_ich9lan:
327 		e1000_init_function_pointers_ich8lan(hw);
328 		break;
329 	default:
330 		DEBUGOUT("Hardware not supported\n");
331 		ret_val = -E1000_ERR_CONFIG;
332 		break;
333 	}
334 
335 	/*
336 	 * Initialize the rest of the function pointers. These require some
337 	 * register reads/writes in some cases.
338 	 */
339 	if (!(ret_val) && init_device) {
340 		ret_val = e1000_init_mac_params(hw);
341 		if (ret_val)
342 			goto out;
343 
344 		ret_val = e1000_init_nvm_params(hw);
345 		if (ret_val)
346 			goto out;
347 
348 		ret_val = e1000_init_phy_params(hw);
349 		if (ret_val)
350 			goto out;
351 
352 	}
353 
354 out:
355 	return (ret_val);
356 }
357 
358 /*
359  * e1000_remove_device - Free device specific structure
360  * @hw: pointer to the HW structure
361  *
362  * If a device specific structure was allocated, this function will
363  * free it. This is a function pointer entry point called by drivers.
364  */
365 void
366 e1000_remove_device(struct e1000_hw *hw)
367 {
368 	if (hw->mac.ops.remove_device)
369 		hw->mac.ops.remove_device(hw);
370 }
371 
372 /*
373  * e1000_get_bus_info - Obtain bus information for adapter
374  * @hw: pointer to the HW structure
375  *
376  * This will obtain information about the HW bus for which the
377  * adapter is attached and stores it in the hw structure. This is a
378  * function pointer entry point called by drivers.
379  */
380 s32
381 e1000_get_bus_info(struct e1000_hw *hw)
382 {
383 	if (hw->mac.ops.get_bus_info)
384 		return (hw->mac.ops.get_bus_info(hw));
385 
386 	return (E1000_SUCCESS);
387 }
388 
389 /*
390  * e1000_clear_vfta - Clear VLAN filter table
391  * @hw: pointer to the HW structure
392  *
393  * This clears the VLAN filter table on the adapter. This is a function
394  * pointer entry point called by drivers.
395  */
396 void
397 e1000_clear_vfta(struct e1000_hw *hw)
398 {
399 	if (hw->mac.ops.clear_vfta)
400 		hw->mac.ops.clear_vfta(hw);
401 }
402 
403 /*
404  * e1000_write_vfta - Write value to VLAN filter table
405  * @hw: pointer to the HW structure
406  * @offset: the 32-bit offset in which to write the value to.
407  * @value: the 32-bit value to write at location offset.
408  *
409  * This writes a 32-bit value to a 32-bit offset in the VLAN filter
410  * table. This is a function pointer entry point called by drivers.
411  */
412 void
413 e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
414 {
415 	if (hw->mac.ops.write_vfta)
416 		hw->mac.ops.write_vfta(hw, offset, value);
417 }
418 
419 /*
420  * e1000_update_mc_addr_list - Update Multicast addresses
421  * @hw: pointer to the HW structure
422  * @mc_addr_list: array of multicast addresses to program
423  * @mc_addr_count: number of multicast addresses to program
424  * @rar_used_count: the first RAR register free to program
425  * @rar_count: total number of supported Receive Address Registers
426  *
427  * Updates the Receive Address Registers and Multicast Table Array.
428  * The caller must have a packed mc_addr_list of multicast addresses.
429  * The parameter rar_count will usually be hw->mac.rar_entry_count
430  * unless there are workarounds that change this.  Currently no func pointer
431  * exists and all implementations are handled in the generic version of this
432  * function.
433  */
434 void
435 e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
436     u32 mc_addr_count, u32 rar_used_count, u32 rar_count)
437 {
438 	if (hw->mac.ops.update_mc_addr_list)
439 		hw->mac.ops.update_mc_addr_list(hw,
440 		    mc_addr_list,
441 		    mc_addr_count,
442 		    rar_used_count,
443 		    rar_count);
444 }
445 
446 /*
447  * e1000_force_mac_fc - Force MAC flow control
448  * @hw: pointer to the HW structure
449  *
450  * Force the MAC's flow control settings. Currently no func pointer exists
451  * and all implementations are handled in the generic version of this
452  * function.
453  */
454 s32
455 e1000_force_mac_fc(struct e1000_hw *hw)
456 {
457 	return (e1000_force_mac_fc_generic(hw));
458 }
459 
460 /*
461  * e1000_check_for_link - Check/Store link connection
462  * @hw: pointer to the HW structure
463  *
464  * This checks the link condition of the adapter and stores the
465  * results in the hw->mac structure. This is a function pointer entry
466  * point called by drivers.
467  */
468 s32
469 e1000_check_for_link(struct e1000_hw *hw)
470 {
471 	if (hw->mac.ops.check_for_link)
472 		return (hw->mac.ops.check_for_link(hw));
473 
474 	return (-E1000_ERR_CONFIG);
475 }
476 
477 /*
478  * e1000_check_mng_mode - Check management mode
479  * @hw: pointer to the HW structure
480  *
481  * This checks if the adapter has manageability enabled.
482  * This is a function pointer entry point called by drivers.
483  */
484 bool
485 e1000_check_mng_mode(struct e1000_hw *hw)
486 {
487 	if (hw->mac.ops.check_mng_mode)
488 		return (hw->mac.ops.check_mng_mode(hw));
489 
490 	return (FALSE);
491 }
492 
493 /*
494  * e1000_mng_write_dhcp_info - Writes DHCP info to host interface
495  * @hw: pointer to the HW structure
496  * @buffer: pointer to the host interface
497  * @length: size of the buffer
498  *
499  * Writes the DHCP information to the host interface.
500  */
501 s32
502 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
503 {
504 	return (e1000_mng_write_dhcp_info_generic(hw, buffer, length));
505 }
506 
507 /*
508  * e1000_reset_hw - Reset hardware
509  * @hw: pointer to the HW structure
510  *
511  * This resets the hardware into a known state. This is a function pointer
512  * entry point called by drivers.
513  */
514 s32
515 e1000_reset_hw(struct e1000_hw *hw)
516 {
517 	if (hw->mac.ops.reset_hw)
518 		return (hw->mac.ops.reset_hw(hw));
519 
520 	return (-E1000_ERR_CONFIG);
521 }
522 
523 /*
524  * e1000_init_hw - Initialize hardware
525  * @hw: pointer to the HW structure
526  *
527  * This inits the hardware readying it for operation. This is a function
528  * pointer entry point called by drivers.
529  */
530 s32
531 e1000_init_hw(struct e1000_hw *hw)
532 {
533 	if (hw->mac.ops.init_hw)
534 		return (hw->mac.ops.init_hw(hw));
535 
536 	return (-E1000_ERR_CONFIG);
537 }
538 
539 /*
540  * e1000_setup_link - Configures link and flow control
541  * @hw: pointer to the HW structure
542  *
543  * This configures link and flow control settings for the adapter. This
544  * is a function pointer entry point called by drivers. While modules can
545  * also call this, they probably call their own version of this function.
546  */
547 s32
548 e1000_setup_link(struct e1000_hw *hw)
549 {
550 	if (hw->mac.ops.setup_link)
551 		return (hw->mac.ops.setup_link(hw));
552 
553 	return (-E1000_ERR_CONFIG);
554 }
555 
556 /*
557  * e1000_get_speed_and_duplex - Returns current speed and duplex
558  * @hw: pointer to the HW structure
559  * @speed: pointer to a 16-bit value to store the speed
560  * @duplex: pointer to a 16-bit value to store the duplex.
561  *
562  * This returns the speed and duplex of the adapter in the two 'out'
563  * variables passed in. This is a function pointer entry point called
564  * by drivers.
565  */
566 s32
567 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
568 {
569 	if (hw->mac.ops.get_link_up_info)
570 		return (hw->mac.ops.get_link_up_info(hw, speed, duplex));
571 
572 	return (-E1000_ERR_CONFIG);
573 }
574 
575 /*
576  * e1000_setup_led - Configures SW controllable LED
577  * @hw: pointer to the HW structure
578  *
579  * This prepares the SW controllable LED for use and saves the current state
580  * of the LED so it can be later restored. This is a function pointer entry
581  * point called by drivers.
582  */
583 s32
584 e1000_setup_led(struct e1000_hw *hw)
585 {
586 	if (hw->mac.ops.setup_led)
587 		return (hw->mac.ops.setup_led(hw));
588 
589 	return (E1000_SUCCESS);
590 }
591 
592 /*
593  * e1000_cleanup_led - Restores SW controllable LED
594  * @hw: pointer to the HW structure
595  *
596  * This restores the SW controllable LED to the value saved off by
597  * e1000_setup_led. This is a function pointer entry point called by drivers.
598  */
599 s32
600 e1000_cleanup_led(struct e1000_hw *hw)
601 {
602 	if (hw->mac.ops.cleanup_led)
603 		return (hw->mac.ops.cleanup_led(hw));
604 
605 	return (E1000_SUCCESS);
606 }
607 
608 /*
609  * e1000_blink_led - Blink SW controllable LED
610  * @hw: pointer to the HW structure
611  *
612  * This starts the adapter LED blinking. Request the LED to be setup first
613  * and cleaned up after. This is a function pointer entry point called by
614  * drivers.
615  */
616 s32
617 e1000_blink_led(struct e1000_hw *hw)
618 {
619 	if (hw->mac.ops.blink_led)
620 		return (hw->mac.ops.blink_led(hw));
621 
622 	return (E1000_SUCCESS);
623 }
624 
625 /*
626  * e1000_led_on - Turn on SW controllable LED
627  * @hw: pointer to the HW structure
628  *
629  * Turns the SW defined LED on. This is a function pointer entry point
630  * called by drivers.
631  */
632 s32
633 e1000_led_on(struct e1000_hw *hw)
634 {
635 	if (hw->mac.ops.led_on)
636 		return (hw->mac.ops.led_on(hw));
637 
638 	return (E1000_SUCCESS);
639 }
640 
641 /*
642  * e1000_led_off - Turn off SW controllable LED
643  * @hw: pointer to the HW structure
644  *
645  * Turns the SW defined LED off. This is a function pointer entry point
646  * called by drivers.
647  */
648 s32
649 e1000_led_off(struct e1000_hw *hw)
650 {
651 	if (hw->mac.ops.led_off)
652 		return (hw->mac.ops.led_off(hw));
653 
654 	return (E1000_SUCCESS);
655 }
656 
657 /*
658  * e1000_reset_adaptive - Reset adaptive IFS
659  * @hw: pointer to the HW structure
660  *
661  * Resets the adaptive IFS. Currently no func pointer exists and all
662  * implementations are handled in the generic version of this function.
663  */
664 void
665 e1000_reset_adaptive(struct e1000_hw *hw)
666 {
667 	e1000_reset_adaptive_generic(hw);
668 }
669 
670 /*
671  * e1000_update_adaptive - Update adaptive IFS
672  * @hw: pointer to the HW structure
673  *
674  * Updates adapter IFS. Currently no func pointer exists and all
675  * implementations are handled in the generic version of this function.
676  */
677 void
678 e1000_update_adaptive(struct e1000_hw *hw)
679 {
680 	e1000_update_adaptive_generic(hw);
681 }
682 
683 /*
684  * e1000_disable_pcie_master - Disable PCI-Express master access
685  * @hw: pointer to the HW structure
686  *
687  * Disables PCI-Express master access and verifies there are no pending
688  * requests. Currently no func pointer exists and all implementations are
689  * handled in the generic version of this function.
690  */
691 s32
692 e1000_disable_pcie_master(struct e1000_hw *hw)
693 {
694 	return (e1000_disable_pcie_master_generic(hw));
695 }
696 
697 /*
698  * e1000_config_collision_dist - Configure collision distance
699  * @hw: pointer to the HW structure
700  *
701  * Configures the collision distance to the default value and is used
702  * during link setup.
703  */
704 void
705 e1000_config_collision_dist(struct e1000_hw *hw)
706 {
707 	if (hw->mac.ops.config_collision_dist)
708 		hw->mac.ops.config_collision_dist(hw);
709 }
710 
711 /*
712  * e1000_rar_set - Sets a receive address register
713  * @hw: pointer to the HW structure
714  * @addr: address to set the RAR to
715  * @index: the RAR to set
716  *
717  * Sets a Receive Address Register (RAR) to the specified address.
718  */
719 void
720 e1000_rar_set(struct e1000_hw *hw, u8 * addr, u32 index)
721 {
722 	if (hw->mac.ops.rar_set)
723 		hw->mac.ops.rar_set(hw, addr, index);
724 }
725 
726 /*
727  * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
728  * @hw: pointer to the HW structure
729  *
730  * Ensures that the MDI/MDIX SW state is valid.
731  */
732 s32
733 e1000_validate_mdi_setting(struct e1000_hw *hw)
734 {
735 	if (hw->mac.ops.validate_mdi_setting)
736 		return (hw->mac.ops.validate_mdi_setting(hw));
737 
738 	return (E1000_SUCCESS);
739 }
740 
741 /*
742  * e1000_mta_set - Sets multicast table bit
743  * @hw: pointer to the HW structure
744  * @hash_value: Multicast hash value.
745  *
746  * This sets the bit in the multicast table corresponding to the
747  * hash value.  This is a function pointer entry point called by drivers.
748  */
749 void
750 e1000_mta_set(struct e1000_hw *hw, u32 hash_value)
751 {
752 	if (hw->mac.ops.mta_set)
753 		hw->mac.ops.mta_set(hw, hash_value);
754 }
755 
756 /*
757  * e1000_hash_mc_addr - Determines address location in multicast table
758  * @hw: pointer to the HW structure
759  * @mc_addr: Multicast address to hash.
760  *
761  * This hashes an address to determine its location in the multicast
762  * table. Currently no func pointer exists and all implementations
763  * are handled in the generic version of this function.
764  */
765 u32
766 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
767 {
768 	return (e1000_hash_mc_addr_generic(hw, mc_addr));
769 }
770 
771 /*
772  * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
773  * @hw: pointer to the HW structure
774  *
775  * Enables packet filtering on transmit packets if manageability is enabled
776  * and host interface is enabled.
777  * Currently no func pointer exists and all implementations are handled in the
778  * generic version of this function.
779  */
780 bool
781 e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
782 {
783 	return (e1000_enable_tx_pkt_filtering_generic(hw));
784 }
785 
786 /*
787  * e1000_mng_host_if_write - Writes to the manageability host interface
788  * @hw: pointer to the HW structure
789  * @buffer: pointer to the host interface buffer
790  * @length: size of the buffer
791  * @offset: location in the buffer to write to
792  * @sum: sum of the data (not checksum)
793  *
794  * This function writes the buffer content at the offset given on the host if.
795  * It also does alignment considerations to do the writes in most efficient
796  * way.  Also fills up the sum of the buffer in *buffer parameter.
797  */
798 s32
799 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
800     u16 offset, u8 *sum)
801 {
802 	if (hw->mac.ops.mng_host_if_write)
803 		return (hw->mac.ops.mng_host_if_write(hw, buffer, length,
804 		    offset, sum));
805 
806 	return (E1000_NOT_IMPLEMENTED);
807 }
808 
809 /*
810  * e1000_mng_write_cmd_header - Writes manageability command header
811  * @hw: pointer to the HW structure
812  * @hdr: pointer to the host interface command header
813  *
814  * Writes the command header after does the checksum calculation.
815  */
816 s32
817 e1000_mng_write_cmd_header(struct e1000_hw *hw,
818     struct e1000_host_mng_command_header *hdr)
819 {
820 	if (hw->mac.ops.mng_write_cmd_header)
821 		return (hw->mac.ops.mng_write_cmd_header(hw, hdr));
822 
823 	return (E1000_NOT_IMPLEMENTED);
824 }
825 
826 /*
827  * e1000_mng_enable_host_if - Checks host interface is enabled
828  * @hw: pointer to the HW structure
829  *
830  * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
831  *
832  * This function checks whether the HOST IF is enabled for command operation
833  * and also checks whether the previous command is completed.  It busy waits
834  * in case of previous command is not completed.
835  */
836 s32
837 e1000_mng_enable_host_if(struct e1000_hw *hw)
838 {
839 	if (hw->mac.ops.mng_enable_host_if)
840 		return (hw->mac.ops.mng_enable_host_if(hw));
841 
842 	return (E1000_NOT_IMPLEMENTED);
843 }
844 
845 /*
846  * e1000_wait_autoneg - Waits for autonegotiation completion
847  * @hw: pointer to the HW structure
848  *
849  * Waits for autoneg to complete. Currently no func pointer exists and all
850  * implementations are handled in the generic version of this function.
851  */
852 s32
853 e1000_wait_autoneg(struct e1000_hw *hw)
854 {
855 	if (hw->mac.ops.wait_autoneg)
856 		return (hw->mac.ops.wait_autoneg(hw));
857 
858 	return (E1000_SUCCESS);
859 }
860 
861 /*
862  * e1000_check_reset_block - Verifies PHY can be reset
863  * @hw: pointer to the HW structure
864  *
865  * Checks if the PHY is in a state that can be reset or if manageability
866  * has it tied up. This is a function pointer entry point called by drivers.
867  */
868 s32
869 e1000_check_reset_block(struct e1000_hw *hw)
870 {
871 	if (hw->phy.ops.check_reset_block)
872 		return (hw->phy.ops.check_reset_block(hw));
873 
874 	return (E1000_SUCCESS);
875 }
876 
877 /*
878  * e1000_read_phy_reg - Reads PHY register
879  * @hw: pointer to the HW structure
880  * @offset: the register to read
881  * @data: the buffer to store the 16-bit read.
882  *
883  * Reads the PHY register and returns the value in data.
884  * This is a function pointer entry point called by drivers.
885  */
886 s32
887 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
888 {
889 	if (hw->phy.ops.read_reg)
890 		return (hw->phy.ops.read_reg(hw, offset, data));
891 
892 	return (E1000_SUCCESS);
893 }
894 
895 /*
896  * e1000_write_phy_reg - Writes PHY register
897  * @hw: pointer to the HW structure
898  * @offset: the register to write
899  * @data: the value to write.
900  *
901  * Writes the PHY register at offset with the value in data.
902  * This is a function pointer entry point called by drivers.
903  */
904 s32
905 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
906 {
907 	if (hw->phy.ops.write_reg)
908 		return (hw->phy.ops.write_reg(hw, offset, data));
909 
910 	return (E1000_SUCCESS);
911 }
912 
913 /*
914  * e1000_release_phy - Generic release PHY
915  * @hw: pointer to the HW structure
916  *
917  * Return if silicon family does not require a semaphore when accessing the
918  * PHY.
919  */
920 void
921 e1000_release_phy(struct e1000_hw *hw)
922 {
923 	if (hw->phy.ops.release)
924 		hw->phy.ops.release(hw);
925 }
926 
927 /*
928  * e1000_acquire_phy - Generic acquire PHY
929  * @hw: pointer to the HW structure
930  *
931  * Return success if silicon family does not require a semaphore when
932  * accessing the PHY.
933  */
934 s32
935 e1000_acquire_phy(struct e1000_hw *hw)
936 {
937 	if (hw->phy.ops.acquire)
938 		return (hw->phy.ops.acquire(hw));
939 
940 	return (E1000_SUCCESS);
941 }
942 
943 /*
944  * e1000_read_kmrn_reg - Reads register using Kumeran interface
945  * @hw: pointer to the HW structure
946  * @offset: the register to read
947  * @data: the location to store the 16-bit value read.
948  *
949  * Reads a register out of the Kumeran interface. Currently no func pointer
950  * exists and all implementations are handled in the generic version of
951  * this function.
952  */
953 s32
954 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
955 {
956 	return (e1000_read_kmrn_reg_generic(hw, offset, data));
957 }
958 
959 /*
960  * e1000_write_kmrn_reg - Writes register using Kumeran interface
961  * @hw: pointer to the HW structure
962  * @offset: the register to write
963  * @data: the value to write.
964  *
965  * Writes a register to the Kumeran interface. Currently no func pointer
966  * exists and all implementations are handled in the generic version of
967  * this function.
968  */
969 s32
970 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
971 {
972 	return (e1000_write_kmrn_reg_generic(hw, offset, data));
973 }
974 
975 /*
976  * e1000_get_cable_length - Retrieves cable length estimation
977  * @hw: pointer to the HW structure
978  *
979  * This function estimates the cable length and stores them in
980  * hw->phy.min_length and hw->phy.max_length. This is a function pointer
981  * entry point called by drivers.
982  */
983 s32
984 e1000_get_cable_length(struct e1000_hw *hw)
985 {
986 	if (hw->phy.ops.get_cable_length)
987 		return (hw->phy.ops.get_cable_length(hw));
988 
989 	return (E1000_SUCCESS);
990 }
991 
992 /*
993  * e1000_get_phy_info - Retrieves PHY information from registers
994  * @hw: pointer to the HW structure
995  *
996  * This function gets some information from various PHY registers and
997  * populates hw->phy values with it. This is a function pointer entry
998  * point called by drivers.
999  */
1000 s32
1001 e1000_get_phy_info(struct e1000_hw *hw)
1002 {
1003 	if (hw->phy.ops.get_info)
1004 		return (hw->phy.ops.get_info(hw));
1005 
1006 	return (E1000_SUCCESS);
1007 }
1008 
1009 /*
1010  * e1000_phy_hw_reset - Hard PHY reset
1011  * @hw: pointer to the HW structure
1012  *
1013  * Performs a hard PHY reset. This is a function pointer entry point called
1014  * by drivers.
1015  */
1016 s32
1017 e1000_phy_hw_reset(struct e1000_hw *hw)
1018 {
1019 	if (hw->phy.ops.reset)
1020 		return (hw->phy.ops.reset(hw));
1021 
1022 	return (E1000_SUCCESS);
1023 }
1024 
1025 /*
1026  * e1000_phy_commit - Soft PHY reset
1027  * @hw: pointer to the HW structure
1028  *
1029  * Performs a soft PHY reset on those that apply. This is a function pointer
1030  * entry point called by drivers.
1031  */
1032 s32
1033 e1000_phy_commit(struct e1000_hw *hw)
1034 {
1035 	if (hw->phy.ops.commit)
1036 		return (hw->phy.ops.commit(hw));
1037 
1038 	return (E1000_SUCCESS);
1039 }
1040 
1041 /*
1042  * e1000_set_d0_lplu_state - Sets low power link up state for D0
1043  * @hw: pointer to the HW structure
1044  * @active: boolean used to enable/disable lplu
1045  *
1046  * Success returns 0, Failure returns 1
1047  *
1048  * The low power link up (lplu) state is set to the power management level D0
1049  * and SmartSpeed is disabled when active is true, else clear lplu for D0
1050  * and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
1051  * is used during Dx states where the power conservation is most important.
1052  * During driver activity, SmartSpeed should be enabled so performance is
1053  * maintained.  This is a function pointer entry point called by drivers.
1054  */
1055 s32
1056 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
1057 {
1058 	if (hw->phy.ops.set_d0_lplu_state)
1059 		return (hw->phy.ops.set_d0_lplu_state(hw, active));
1060 
1061 	return (E1000_SUCCESS);
1062 }
1063 
1064 /*
1065  * e1000_set_d3_lplu_state - Sets low power link up state for D3
1066  * @hw: pointer to the HW structure
1067  * @active: boolean used to enable/disable lplu
1068  *
1069  * Success returns 0, Failure returns 1
1070  *
1071  * The low power link up (lplu) state is set to the power management level D3
1072  * and SmartSpeed is disabled when active is true, else clear lplu for D3
1073  * and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
1074  * is used during Dx states where the power conservation is most important.
1075  * During driver activity, SmartSpeed should be enabled so performance is
1076  * maintained.  This is a function pointer entry point called by drivers.
1077  */
1078 s32
1079 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
1080 {
1081 	if (hw->phy.ops.set_d3_lplu_state)
1082 		return (hw->phy.ops.set_d3_lplu_state(hw, active));
1083 
1084 	return (E1000_SUCCESS);
1085 }
1086 
1087 /*
1088  * e1000_read_mac_addr - Reads MAC address
1089  * @hw: pointer to the HW structure
1090  *
1091  * Reads the MAC address out of the adapter and stores it in the HW structure.
1092  * Currently no func pointer exists and all implementations are handled in the
1093  * generic version of this function.
1094  */
1095 s32
1096 e1000_read_mac_addr(struct e1000_hw *hw)
1097 {
1098 	if (hw->mac.ops.read_mac_addr)
1099 		return (hw->mac.ops.read_mac_addr(hw));
1100 
1101 	return (e1000_read_mac_addr_generic(hw));
1102 }
1103 
1104 /*
1105  * e1000_read_pba_num - Read device part number
1106  * @hw: pointer to the HW structure
1107  * @pba_num: pointer to device part number
1108  *
1109  * Reads the product board assembly (PBA) number from the EEPROM and stores
1110  * the value in pba_num.
1111  * Currently no func pointer exists and all implementations are handled in the
1112  * generic version of this function.
1113  */
1114 s32
1115 e1000_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
1116 {
1117 	return (e1000_read_pba_num_generic(hw, pba_num));
1118 }
1119 
1120 /*
1121  * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
1122  * @hw: pointer to the HW structure
1123  *
1124  * Validates the NVM checksum is correct. This is a function pointer entry
1125  * point called by drivers.
1126  */
1127 s32
1128 e1000_validate_nvm_checksum(struct e1000_hw *hw)
1129 {
1130 	if (hw->nvm.ops.validate)
1131 		return (hw->nvm.ops.validate(hw));
1132 
1133 	return (-E1000_ERR_CONFIG);
1134 }
1135 
1136 /*
1137  * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
1138  * @hw: pointer to the HW structure
1139  *
1140  * Updates the NVM checksum. Currently no func pointer exists and all
1141  * implementations are handled in the generic version of this function.
1142  */
1143 s32
1144 e1000_update_nvm_checksum(struct e1000_hw *hw)
1145 {
1146 	if (hw->nvm.ops.update)
1147 		return (hw->nvm.ops.update(hw));
1148 
1149 	return (-E1000_ERR_CONFIG);
1150 }
1151 
1152 /*
1153  * e1000_reload_nvm - Reloads EEPROM
1154  * @hw: pointer to the HW structure
1155  *
1156  * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1157  * extended control register.
1158  */
1159 void
1160 e1000_reload_nvm(struct e1000_hw *hw)
1161 {
1162 	if (hw->nvm.ops.reload)
1163 		hw->nvm.ops.reload(hw);
1164 }
1165 
1166 /*
1167  * e1000_read_nvm - Reads NVM (EEPROM)
1168  * @hw: pointer to the HW structure
1169  * @offset: the word offset to read
1170  * @words: number of 16-bit words to read
1171  * @data: pointer to the properly sized buffer for the data.
1172  *
1173  * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1174  * pointer entry point called by drivers.
1175  */
1176 s32
1177 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1178 {
1179 	if (hw->nvm.ops.read)
1180 		return (hw->nvm.ops.read(hw, offset, words, data));
1181 
1182 	return (-E1000_ERR_CONFIG);
1183 }
1184 
1185 /*
1186  * e1000_write_nvm - Writes to NVM (EEPROM)
1187  * @hw: pointer to the HW structure
1188  * @offset: the word offset to read
1189  * @words: number of 16-bit words to write
1190  * @data: pointer to the properly sized buffer for the data.
1191  *
1192  * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1193  * pointer entry point called by drivers.
1194  */
1195 s32
1196 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1197 {
1198 	if (hw->nvm.ops.write)
1199 		return (hw->nvm.ops.write(hw, offset, words, data));
1200 
1201 	return (E1000_SUCCESS);
1202 }
1203 
1204 /*
1205  * e1000_write_8bit_ctrl_reg - Writes 8bit Control register
1206  * @hw: pointer to the HW structure
1207  * @reg: 32bit register offset
1208  * @offset: the register to write
1209  * @data: the value to write.
1210  *
1211  * Writes the PHY register at offset with the value in data.
1212  * This is a function pointer entry point called by drivers.
1213  */
1214 s32
1215 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset, u8 data)
1216 {
1217 	return (e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data));
1218 }
1219 
1220 /*
1221  * e1000_power_up_phy - Restores link in case of PHY power down
1222  * @hw: pointer to the HW structure
1223  *
1224  * The phy may be powered down to save power, to turn off link when the
1225  * driver is unloaded, or wake on lan is not enabled (among others).
1226  */
1227 void
1228 e1000_power_up_phy(struct e1000_hw *hw)
1229 {
1230 	if (hw->phy.ops.power_up)
1231 		hw->phy.ops.power_up(hw);
1232 
1233 	e1000_setup_link(hw);
1234 }
1235 
1236 /*
1237  * e1000_power_down_phy - Power down PHY
1238  * @hw: pointer to the HW structure
1239  *
1240  * The phy may be powered down to save power, to turn off link when the
1241  * driver is unloaded, or wake on lan is not enabled (among others).
1242  */
1243 void
1244 e1000_power_down_phy(struct e1000_hw *hw)
1245 {
1246 	if (hw->phy.ops.power_down)
1247 		hw->phy.ops.power_down(hw);
1248 }
1249