xref: /onnv-gate/usr/src/uts/common/io/igb/igb_api.c (revision 5779:e875a8701bfc)
1 /*
2  * CDDL HEADER START
3  *
4  * Copyright(c) 2007-2008 Intel Corporation. All rights reserved.
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at:
10  *	http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When using or redistributing this file, you may do so under the
15  * License only. No other modification of this header is permitted.
16  *
17  * If applicable, add the following below this CDDL HEADER, with the
18  * fields enclosed by brackets "[]" replaced with your own identifying
19  * information: Portions Copyright [yyyy] [name of copyright owner]
20  *
21  * CDDL HEADER END
22  */
23 
24 /*
25  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms of the CDDL.
27  */
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include "igb_api.h"
32 #include "igb_mac.h"
33 #include "igb_nvm.h"
34 #include "igb_phy.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
44 e1000_init_mac_params(struct e1000_hw *hw)
45 {
46 	s32 ret_val = E1000_SUCCESS;
47 
48 	if (hw->func.init_mac_params) {
49 		ret_val = hw->func.init_mac_params(hw);
50 		if (ret_val) {
51 			DEBUGOUT("MAC Initialization Error\n");
52 			goto out;
53 		}
54 	} else {
55 		DEBUGOUT("mac.init_mac_params was NULL\n");
56 		ret_val = -E1000_ERR_CONFIG;
57 	}
58 
59 out:
60 	return (ret_val);
61 }
62 
63 /*
64  * e1000_init_nvm_params - Initialize NVM function pointers
65  * @hw: pointer to the HW structure
66  *
67  * This function initializes the function pointers for the NVM
68  * set of functions.  Called by drivers or by e1000_setup_init_funcs.
69  */
70 s32
71 e1000_init_nvm_params(struct e1000_hw *hw)
72 {
73 	s32 ret_val = E1000_SUCCESS;
74 
75 	if (hw->func.init_nvm_params) {
76 		ret_val = hw->func.init_nvm_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
98 e1000_init_phy_params(struct e1000_hw *hw)
99 {
100 	s32 ret_val = E1000_SUCCESS;
101 
102 	if (hw->func.init_phy_params) {
103 		ret_val = hw->func.init_phy_params(hw);
104 		if (ret_val) {
105 			DEBUGOUT("PHY Initialization Error\n");
106 			goto out;
107 		}
108 	} else {
109 		DEBUGOUT("phy.init_phy_params was NULL\n");
110 		ret_val =  -E1000_ERR_CONFIG;
111 	}
112 
113 out:
114 	return (ret_val);
115 }
116 
117 /*
118  * e1000_set_mac_type - Sets MAC type
119  * @hw: pointer to the HW structure
120  *
121  * This function sets the mac type of the adapter based on the
122  * device ID stored in the hw structure.
123  * MUST BE FIRST FUNCTION CALLED (explicitly or through
124  * e1000_setup_init_funcs()).
125  */
126 s32
127 e1000_set_mac_type(struct e1000_hw *hw)
128 {
129 	struct e1000_mac_info *mac = &hw->mac;
130 	s32 ret_val = E1000_SUCCESS;
131 
132 	DEBUGFUNC("e1000_set_mac_type");
133 
134 	switch (hw->device_id) {
135 	case E1000_DEV_ID_82575EB_COPPER:
136 	case E1000_DEV_ID_82575EB_FIBER_SERDES:
137 	case E1000_DEV_ID_82575GB_QUAD_COPPER:
138 		mac->type = e1000_82575;
139 		break;
140 	default:
141 		/* Should never have loaded on this device */
142 		ret_val = -E1000_ERR_MAC_INIT;
143 		break;
144 	}
145 
146 	return (ret_val);
147 }
148 
149 /*
150  * e1000_setup_init_funcs - Initializes function pointers
151  * @hw: pointer to the HW structure
152  * @init_device: TRUE will initialize the rest of the function pointers
153  *		getting the device ready for use.  FALSE will only set
154  *		MAC type and the function pointers for the other init
155  *		functions.  Passing FALSE will not generate any hardware
156  *		reads or writes.
157  *
158  * This function must be called by a driver in order to use the rest
159  * of the 'shared' code files. Called by drivers only.
160  */
161 s32
162 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
163 {
164 	s32 ret_val;
165 
166 	/* Can't do much good without knowing the MAC type. */
167 	ret_val = e1000_set_mac_type(hw);
168 	if (ret_val) {
169 		DEBUGOUT("ERROR: MAC type could not be set properly.\n");
170 		goto out;
171 	}
172 
173 	if (!hw->hw_addr) {
174 		DEBUGOUT("ERROR: Registers not mapped\n");
175 		ret_val = -E1000_ERR_CONFIG;
176 		goto out;
177 	}
178 
179 	/*
180 	 * Init some generic function pointers that are currently all pointing
181 	 * to generic implementations. We do this first allowing a driver
182 	 * module to override it afterwards.
183 	 */
184 	hw->func.config_collision_dist = e1000_config_collision_dist_generic;
185 	hw->func.rar_set = e1000_rar_set_generic;
186 	hw->func.validate_mdi_setting = e1000_validate_mdi_setting_generic;
187 	hw->func.mng_host_if_write = e1000_mng_host_if_write_generic;
188 	hw->func.mng_write_cmd_header = e1000_mng_write_cmd_header_generic;
189 	hw->func.mng_enable_host_if = e1000_mng_enable_host_if_generic;
190 	hw->func.wait_autoneg = e1000_wait_autoneg_generic;
191 	hw->func.reload_nvm = e1000_reload_nvm_generic;
192 
193 	/*
194 	 * Set up the init function pointers. These are functions within the
195 	 * adapter family file that sets up function pointers for the rest of
196 	 * the functions in that family.
197 	 */
198 	switch (hw->mac.type) {
199 	case e1000_82575:
200 		e1000_init_function_pointers_82575(hw);
201 		break;
202 	default:
203 		DEBUGOUT("Hardware not supported\n");
204 		ret_val = -E1000_ERR_CONFIG;
205 		break;
206 	}
207 
208 	/*
209 	 * Initialize the rest of the function pointers. These require some
210 	 * register reads/writes in some cases.
211 	 */
212 	if (!(ret_val) && init_device) {
213 		ret_val = e1000_init_mac_params(hw);
214 		if (ret_val)
215 			goto out;
216 
217 		ret_val = e1000_init_nvm_params(hw);
218 		if (ret_val)
219 			goto out;
220 
221 		ret_val = e1000_init_phy_params(hw);
222 		if (ret_val)
223 			goto out;
224 
225 	}
226 
227 out:
228 	return (ret_val);
229 }
230 
231 /*
232  * e1000_remove_device - Free device specific structure
233  * @hw: pointer to the HW structure
234  *
235  * If a device specific structure was allocated, this function will
236  * free it. This is a function pointer entry point called by drivers.
237  */
238 void
239 e1000_remove_device(struct e1000_hw *hw)
240 {
241 	if (hw->func.remove_device)
242 		hw->func.remove_device(hw);
243 }
244 
245 /*
246  * e1000_get_bus_info - Obtain bus information for adapter
247  * @hw: pointer to the HW structure
248  *
249  * This will obtain information about the HW bus for which the
250  * adaper is attached and stores it in the hw structure. This is a
251  * function pointer entry point called by drivers.
252  */
253 s32
254 e1000_get_bus_info(struct e1000_hw *hw)
255 {
256 	if (hw->func.get_bus_info)
257 		return (hw->func.get_bus_info(hw));
258 
259 	return (E1000_SUCCESS);
260 }
261 
262 /*
263  * e1000_clear_vfta - Clear VLAN filter table
264  * @hw: pointer to the HW structure
265  *
266  * This clears the VLAN filter table on the adapter. This is a function
267  * pointer entry point called by drivers.
268  */
269 void
270 e1000_clear_vfta(struct e1000_hw *hw)
271 {
272 	if (hw->func.clear_vfta)
273 		hw->func.clear_vfta(hw);
274 }
275 
276 /*
277  * e1000_write_vfta - Write value to VLAN filter table
278  * @hw: pointer to the HW structure
279  * @offset: the 32-bit offset in which to write the value to.
280  * @value: the 32-bit value to write at location offset.
281  *
282  * This writes a 32-bit value to a 32-bit offset in the VLAN filter
283  * table. This is a function pointer entry point called by drivers.
284  */
285 void
286 e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
287 {
288 	if (hw->func.write_vfta)
289 		hw->func.write_vfta(hw, offset, value);
290 }
291 
292 /*
293  * e1000_update_mc_addr_list - Update Multicast addresses
294  * @hw: pointer to the HW structure
295  * @mc_addr_list: array of multicast addresses to program
296  * @mc_addr_count: number of multicast addresses to program
297  * @rar_used_count: the first RAR register free to program
298  * @rar_count: total number of supported Receive Address Registers
299  *
300  * Updates the Receive Address Registers and Multicast Table Array.
301  * The caller must have a packed mc_addr_list of multicast addresses.
302  * The parameter rar_count will usually be hw->mac.rar_entry_count
303  * unless there are workarounds that change this.  Currently no func pointer
304  * exists and all implementations are handled in the generic version of this
305  * function.
306  */
307 void
308 e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
309     u32 mc_addr_count, u32 rar_used_count, u32 rar_count)
310 {
311 	if (hw->func.update_mc_addr_list)
312 		hw->func.update_mc_addr_list(hw,
313 		    mc_addr_list,
314 		    mc_addr_count,
315 		    rar_used_count,
316 		    rar_count);
317 }
318 
319 /*
320  * e1000_force_mac_fc - Force MAC flow control
321  * @hw: pointer to the HW structure
322  *
323  * Force the MAC's flow control settings. Currently no func pointer exists
324  * and all implementations are handled in the generic version of this
325  * function.
326  */
327 s32
328 e1000_force_mac_fc(struct e1000_hw *hw)
329 {
330 	return (e1000_force_mac_fc_generic(hw));
331 }
332 
333 /*
334  * e1000_check_for_link - Check/Store link connection
335  * @hw: pointer to the HW structure
336  *
337  * This checks the link condition of the adapter and stores the
338  * results in the hw->mac structure. This is a function pointer entry
339  * point called by drivers.
340  */
341 s32
342 e1000_check_for_link(struct e1000_hw *hw)
343 {
344 	if (hw->func.check_for_link)
345 		return (hw->func.check_for_link(hw));
346 
347 	return (-E1000_ERR_CONFIG);
348 }
349 
350 /*
351  * e1000_check_mng_mode - Check management mode
352  * @hw: pointer to the HW structure
353  *
354  * This checks if the adapter has manageability enabled.
355  * This is a function pointer entry point called by drivers.
356  */
357 bool
358 e1000_check_mng_mode(struct e1000_hw *hw)
359 {
360 	if (hw->func.check_mng_mode)
361 		return (hw->func.check_mng_mode(hw));
362 
363 	return (FALSE);
364 }
365 
366 /*
367  * e1000_mng_write_dhcp_info - Writes DHCP info to host interface
368  * @hw: pointer to the HW structure
369  * @buffer: pointer to the host interface
370  * @length: size of the buffer
371  *
372  * Writes the DHCP information to the host interface.
373  */
374 s32
375 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
376 {
377 	return (e1000_mng_write_dhcp_info_generic(hw, buffer, length));
378 }
379 
380 /*
381  * e1000_reset_hw - Reset hardware
382  * @hw: pointer to the HW structure
383  *
384  * This resets the hardware into a known state. This is a function pointer
385  * entry point called by drivers.
386  */
387 s32
388 e1000_reset_hw(struct e1000_hw *hw)
389 {
390 	if (hw->func.reset_hw)
391 		return (hw->func.reset_hw(hw));
392 
393 	return (-E1000_ERR_CONFIG);
394 }
395 
396 /*
397  * e1000_init_hw - Initialize hardware
398  * @hw: pointer to the HW structure
399  *
400  * This inits the hardware readying it for operation. This is a function
401  * pointer entry point called by drivers.
402  */
403 s32
404 e1000_init_hw(struct e1000_hw *hw)
405 {
406 	if (hw->func.init_hw)
407 		return (hw->func.init_hw(hw));
408 
409 	return (-E1000_ERR_CONFIG);
410 }
411 
412 /*
413  * e1000_setup_link - Configures link and flow control
414  * @hw: pointer to the HW structure
415  *
416  * This configures link and flow control settings for the adapter. This
417  * is a function pointer entry point called by drivers. While modules can
418  * also call this, they probably call their own version of this function.
419  */
420 s32
421 e1000_setup_link(struct e1000_hw *hw)
422 {
423 	if (hw->func.setup_link)
424 		return (hw->func.setup_link(hw));
425 
426 	return (-E1000_ERR_CONFIG);
427 }
428 
429 /*
430  * e1000_get_speed_and_duplex - Returns current speed and duplex
431  * @hw: pointer to the HW structure
432  * @speed: pointer to a 16-bit value to store the speed
433  * @duplex: pointer to a 16-bit value to store the duplex.
434  *
435  * This returns the speed and duplex of the adapter in the two 'out'
436  * variables passed in. This is a function pointer entry point called
437  * by drivers.
438  */
439 s32
440 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
441 {
442 	if (hw->func.get_link_up_info)
443 		return (hw->func.get_link_up_info(hw, speed, duplex));
444 
445 	return (-E1000_ERR_CONFIG);
446 }
447 
448 /*
449  * e1000_setup_led - Configures SW controllable LED
450  * @hw: pointer to the HW structure
451  *
452  * This prepares the SW controllable LED for use and saves the current state
453  * of the LED so it can be later restored. This is a function pointer entry
454  * point called by drivers.
455  */
456 s32
457 e1000_setup_led(struct e1000_hw *hw)
458 {
459 	if (hw->func.setup_led)
460 		return (hw->func.setup_led(hw));
461 
462 	return (E1000_SUCCESS);
463 }
464 
465 /*
466  * e1000_cleanup_led - Restores SW controllable LED
467  * @hw: pointer to the HW structure
468  *
469  * This restores the SW controllable LED to the value saved off by
470  * e1000_setup_led. This is a function pointer entry point called by drivers.
471  */
472 s32
473 e1000_cleanup_led(struct e1000_hw *hw)
474 {
475 	if (hw->func.cleanup_led)
476 		return (hw->func.cleanup_led(hw));
477 
478 	return (E1000_SUCCESS);
479 }
480 
481 /*
482  * e1000_blink_led - Blink SW controllable LED
483  * @hw: pointer to the HW structure
484  *
485  * This starts the adapter LED blinking. Request the LED to be setup first
486  * and cleaned up after. This is a function pointer entry point called by
487  * drivers.
488  */
489 s32
490 e1000_blink_led(struct e1000_hw *hw)
491 {
492 	if (hw->func.blink_led)
493 		return (hw->func.blink_led(hw));
494 
495 	return (E1000_SUCCESS);
496 }
497 
498 /*
499  * e1000_led_on - Turn on SW controllable LED
500  * @hw: pointer to the HW structure
501  *
502  * Turns the SW defined LED on. This is a function pointer entry point
503  * called by drivers.
504  */
505 s32
506 e1000_led_on(struct e1000_hw *hw)
507 {
508 	if (hw->func.led_on)
509 		return (hw->func.led_on(hw));
510 
511 	return (E1000_SUCCESS);
512 }
513 
514 /*
515  * e1000_led_off - Turn off SW controllable LED
516  * @hw: pointer to the HW structure
517  *
518  * Turns the SW defined LED off. This is a function pointer entry point
519  * called by drivers.
520  */
521 s32
522 e1000_led_off(struct e1000_hw *hw)
523 {
524 	if (hw->func.led_off)
525 		return (hw->func.led_off(hw));
526 
527 	return (E1000_SUCCESS);
528 }
529 
530 /*
531  * e1000_reset_adaptive - Reset adaptive IFS
532  * @hw: pointer to the HW structure
533  *
534  * Resets the adaptive IFS. Currently no func pointer exists and all
535  * implementations are handled in the generic version of this function.
536  */
537 void
538 e1000_reset_adaptive(struct e1000_hw *hw)
539 {
540 	e1000_reset_adaptive_generic(hw);
541 }
542 
543 /*
544  * e1000_update_adaptive - Update adaptive IFS
545  * @hw: pointer to the HW structure
546  *
547  * Updates adapter IFS. Currently no func pointer exists and all
548  * implementations are handled in the generic version of this function.
549  */
550 void
551 e1000_update_adaptive(struct e1000_hw *hw)
552 {
553 	e1000_update_adaptive_generic(hw);
554 }
555 
556 /*
557  * e1000_disable_pcie_master - Disable PCI-Express master access
558  * @hw: pointer to the HW structure
559  *
560  * Disables PCI-Express master access and verifies there are no pending
561  * requests. Currently no func pointer exists and all implementations are
562  * handled in the generic version of this function.
563  */
564 s32
565 e1000_disable_pcie_master(struct e1000_hw *hw)
566 {
567 	return (e1000_disable_pcie_master_generic(hw));
568 }
569 
570 /*
571  * e1000_config_collision_dist - Configure collision distance
572  * @hw: pointer to the HW structure
573  *
574  * Configures the collision distance to the default value and is used
575  * during link setup.
576  */
577 void
578 e1000_config_collision_dist(struct e1000_hw *hw)
579 {
580 	if (hw->func.config_collision_dist)
581 		hw->func.config_collision_dist(hw);
582 }
583 
584 /*
585  * e1000_rar_set - Sets a receive address register
586  * @hw: pointer to the HW structure
587  * @addr: address to set the RAR to
588  * @index: the RAR to set
589  *
590  * Sets a Receive Address Register (RAR) to the specified address.
591  */
592 void
593 e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
594 {
595 	if (hw->func.rar_set)
596 		hw->func.rar_set(hw, addr, index);
597 }
598 
599 /*
600  * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
601  * @hw: pointer to the HW structure
602  *
603  * Ensures that the MDI/MDIX SW state is valid.
604  */
605 s32
606 e1000_validate_mdi_setting(struct e1000_hw *hw)
607 {
608 	if (hw->func.validate_mdi_setting)
609 		return (hw->func.validate_mdi_setting(hw));
610 
611 	return (E1000_SUCCESS);
612 }
613 
614 /*
615  * e1000_mta_set - Sets multicast table bit
616  * @hw: pointer to the HW structure
617  * @hash_value: Multicast hash value.
618  *
619  * This sets the bit in the multicast table corresponding to the
620  * hash value.  This is a function pointer entry point called by drivers.
621  */
622 void
623 e1000_mta_set(struct e1000_hw *hw, u32 hash_value)
624 {
625 	if (hw->func.mta_set)
626 		hw->func.mta_set(hw, hash_value);
627 }
628 
629 /*
630  * e1000_hash_mc_addr - Determines address location in multicast table
631  * @hw: pointer to the HW structure
632  * @mc_addr: Multicast address to hash.
633  *
634  * This hashes an address to determine its location in the multicast
635  * table. Currently no func pointer exists and all implementations
636  * are handled in the generic version of this function.
637  */
638 u32
639 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
640 {
641 	return (e1000_hash_mc_addr_generic(hw, mc_addr));
642 }
643 
644 /*
645  * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
646  * @hw: pointer to the HW structure
647  *
648  * Enables packet filtering on transmit packets if manageability is enabled
649  * and host interface is enabled.
650  * Currently no func pointer exists and all implementations are handled in the
651  * generic version of this function.
652  */
653 bool
654 e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
655 {
656 	return (e1000_enable_tx_pkt_filtering_generic(hw));
657 }
658 
659 /*
660  * e1000_mng_host_if_write - Writes to the manageability host interface
661  * @hw: pointer to the HW structure
662  * @buffer: pointer to the host interface buffer
663  * @length: size of the buffer
664  * @offset: location in the buffer to write to
665  * @sum: sum of the data (not checksum)
666  *
667  * This function writes the buffer content at the offset given on the host if.
668  * It also does alignment considerations to do the writes in most efficient
669  * way.  Also fills up the sum of the buffer in *buffer parameter.
670  */
671 s32
672 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
673     u16 offset, u8 *sum)
674 {
675 	if (hw->func.mng_host_if_write)
676 		return (hw->func.mng_host_if_write(hw, buffer, length, offset,
677 		    sum));
678 
679 	return (E1000_NOT_IMPLEMENTED);
680 }
681 
682 /*
683  * e1000_mng_write_cmd_header - Writes manageability command header
684  * @hw: pointer to the HW structure
685  * @hdr: pointer to the host interface command header
686  *
687  * Writes the command header after does the checksum calculation.
688  */
689 s32
690 e1000_mng_write_cmd_header(struct e1000_hw *hw,
691     struct e1000_host_mng_command_header *hdr)
692 {
693 	if (hw->func.mng_write_cmd_header)
694 		return (hw->func.mng_write_cmd_header(hw, hdr));
695 
696 	return (E1000_NOT_IMPLEMENTED);
697 }
698 
699 /*
700  * e1000_mng_enable_host_if - Checks host interface is enabled
701  * @hw: pointer to the HW structure
702  *
703  * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
704  *
705  * This function checks whether the HOST IF is enabled for command operaton
706  * and also checks whether the previous command is completed.  It busy waits
707  * in case of previous command is not completed.
708  */
709 s32
710 e1000_mng_enable_host_if(struct e1000_hw *hw)
711 {
712 	if (hw->func.mng_enable_host_if)
713 		return (hw->func.mng_enable_host_if(hw));
714 
715 	return (E1000_NOT_IMPLEMENTED);
716 }
717 
718 /*
719  * e1000_wait_autoneg - Waits for autonegotiation completion
720  * @hw: pointer to the HW structure
721  *
722  * Waits for autoneg to complete. Currently no func pointer exists and all
723  * implementations are handled in the generic version of this function.
724  */
725 s32
726 e1000_wait_autoneg(struct e1000_hw *hw)
727 {
728 	if (hw->func.wait_autoneg)
729 		return (hw->func.wait_autoneg(hw));
730 
731 	return (E1000_SUCCESS);
732 }
733 
734 /*
735  * e1000_check_reset_block - Verifies PHY can be reset
736  * @hw: pointer to the HW structure
737  *
738  * Checks if the PHY is in a state that can be reset or if manageability
739  * has it tied up. This is a function pointer entry point called by drivers.
740  */
741 s32
742 e1000_check_reset_block(struct e1000_hw *hw)
743 {
744 	if (hw->func.check_reset_block)
745 		return (hw->func.check_reset_block(hw));
746 
747 	return (E1000_SUCCESS);
748 }
749 
750 /*
751  * e1000_read_phy_reg - Reads PHY register
752  * @hw: pointer to the HW structure
753  * @offset: the register to read
754  * @data: the buffer to store the 16-bit read.
755  *
756  * Reads the PHY register and returns the value in data.
757  * This is a function pointer entry point called by drivers.
758  */
759 s32
760 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
761 {
762 	if (hw->func.read_phy_reg)
763 		return (hw->func.read_phy_reg(hw, offset, data));
764 
765 	return (E1000_SUCCESS);
766 }
767 
768 /*
769  * e1000_write_phy_reg - Writes PHY register
770  * @hw: pointer to the HW structure
771  * @offset: the register to write
772  * @data: the value to write.
773  *
774  * Writes the PHY register at offset with the value in data.
775  * This is a function pointer entry point called by drivers.
776  */
777 s32
778 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
779 {
780 	if (hw->func.write_phy_reg)
781 		return (hw->func.write_phy_reg(hw, offset, data));
782 
783 	return (E1000_SUCCESS);
784 }
785 
786 /*
787  * e1000_read_kmrn_reg - Reads register using Kumeran interface
788  * @hw: pointer to the HW structure
789  * @offset: the register to read
790  * @data: the location to store the 16-bit value read.
791  *
792  * Reads a register out of the Kumeran interface. Currently no func pointer
793  * exists and all implementations are handled in the generic version of
794  * this function.
795  */
796 s32
797 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
798 {
799 	return (e1000_read_kmrn_reg_generic(hw, offset, data));
800 }
801 
802 /*
803  * e1000_write_kmrn_reg - Writes register using Kumeran interface
804  * @hw: pointer to the HW structure
805  * @offset: the register to write
806  * @data: the value to write.
807  *
808  * Writes a register to the Kumeran interface. Currently no func pointer
809  * exists and all implementations are handled in the generic version of
810  * this function.
811  */
812 s32
813 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
814 {
815 	return (e1000_write_kmrn_reg_generic(hw, offset, data));
816 }
817 
818 /*
819  * e1000_get_cable_length - Retrieves cable length estimation
820  * @hw: pointer to the HW structure
821  *
822  * This function estimates the cable length and stores them in
823  * hw->phy.min_length and hw->phy.max_length. This is a function pointer
824  * entry point called by drivers.
825  */
826 s32
827 e1000_get_cable_length(struct e1000_hw *hw)
828 {
829 	if (hw->func.get_cable_length)
830 		return (hw->func.get_cable_length(hw));
831 
832 	return (E1000_SUCCESS);
833 }
834 
835 /*
836  * e1000_get_phy_info - Retrieves PHY information from registers
837  * @hw: pointer to the HW structure
838  *
839  * This function gets some information from various PHY registers and
840  * populates hw->phy values with it. This is a function pointer entry
841  * point called by drivers.
842  */
843 s32
844 e1000_get_phy_info(struct e1000_hw *hw)
845 {
846 	if (hw->func.get_phy_info)
847 		return (hw->func.get_phy_info(hw));
848 
849 	return (E1000_SUCCESS);
850 }
851 
852 /*
853  * e1000_phy_hw_reset - Hard PHY reset
854  * @hw: pointer to the HW structure
855  *
856  * Performs a hard PHY reset. This is a function pointer entry point called
857  * by drivers.
858  */
859 s32
860 e1000_phy_hw_reset(struct e1000_hw *hw)
861 {
862 	if (hw->func.reset_phy)
863 		return (hw->func.reset_phy(hw));
864 
865 	return (E1000_SUCCESS);
866 }
867 
868 /*
869  * e1000_phy_commit - Soft PHY reset
870  * @hw: pointer to the HW structure
871  *
872  * Performs a soft PHY reset on those that apply. This is a function pointer
873  * entry point called by drivers.
874  */
875 s32
876 e1000_phy_commit(struct e1000_hw *hw)
877 {
878 	if (hw->func.commit_phy)
879 		return (hw->func.commit_phy(hw));
880 
881 	return (E1000_SUCCESS);
882 }
883 
884 /*
885  * e1000_set_d3_lplu_state - Sets low power link up state for D0
886  * @hw: pointer to the HW structure
887  * @active: boolean used to enable/disable lplu
888  *
889  * Success returns 0, Failure returns 1
890  *
891  * The low power link up (lplu) state is set to the power management level D0
892  * and SmartSpeed is disabled when active is true, else clear lplu for D0
893  * and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
894  * is used during Dx states where the power conservation is most important.
895  * During driver activity, SmartSpeed should be enabled so performance is
896  * maintained.  This is a function pointer entry point called by drivers.
897  */
898 s32
899 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
900 {
901 	if (hw->func.set_d0_lplu_state)
902 		return (hw->func.set_d0_lplu_state(hw, active));
903 
904 	return (E1000_SUCCESS);
905 }
906 
907 /*
908  * e1000_set_d3_lplu_state - Sets low power link up state for D3
909  * @hw: pointer to the HW structure
910  * @active: boolean used to enable/disable lplu
911  *
912  * Success returns 0, Failure returns 1
913  *
914  * The low power link up (lplu) state is set to the power management level D3
915  * and SmartSpeed is disabled when active is true, else clear lplu for D3
916  * and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
917  * is used during Dx states where the power conservation is most important.
918  * During driver activity, SmartSpeed should be enabled so performance is
919  * maintained.  This is a function pointer entry point called by drivers.
920  */
921 s32
922 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
923 {
924 	if (hw->func.set_d3_lplu_state)
925 		return (hw->func.set_d3_lplu_state(hw, active));
926 
927 	return (E1000_SUCCESS);
928 }
929 
930 /*
931  * e1000_read_mac_addr - Reads MAC address
932  * @hw: pointer to the HW structure
933  *
934  * Reads the MAC address out of the adapter and stores it in the HW structure.
935  * Currently no func pointer exists and all implementations are handled in the
936  * generic version of this function.
937  */
938 s32
939 e1000_read_mac_addr(struct e1000_hw *hw)
940 {
941 	if (hw->func.read_mac_addr)
942 		return (hw->func.read_mac_addr(hw));
943 
944 	return (e1000_read_mac_addr_generic(hw));
945 }
946 
947 /*
948  * e1000_read_pba_num - Read device part number
949  * @hw: pointer to the HW structure
950  * @pba_num: pointer to device part number
951  *
952  * Reads the product board assembly (PBA) number from the EEPROM and stores
953  * the value in pba_num.
954  * Currently no func pointer exists and all implementations are handled in the
955  * generic version of this function.
956  */
957 s32
958 e1000_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
959 {
960 	return (e1000_read_pba_num_generic(hw, pba_num));
961 }
962 
963 /*
964  * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
965  * @hw: pointer to the HW structure
966  *
967  * Validates the NVM checksum is correct. This is a function pointer entry
968  * point called by drivers.
969  */
970 s32
971 e1000_validate_nvm_checksum(struct e1000_hw *hw)
972 {
973 	if (hw->func.validate_nvm)
974 		return (hw->func.validate_nvm(hw));
975 
976 	return (-E1000_ERR_CONFIG);
977 }
978 
979 /*
980  * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
981  * @hw: pointer to the HW structure
982  *
983  * Updates the NVM checksum. Currently no func pointer exists and all
984  * implementations are handled in the generic version of this function.
985  */
986 s32
987 e1000_update_nvm_checksum(struct e1000_hw *hw)
988 {
989 	if (hw->func.update_nvm)
990 		return (hw->func.update_nvm(hw));
991 
992 	return (-E1000_ERR_CONFIG);
993 }
994 
995 /*
996  * e1000_reload_nvm - Reloads EEPROM
997  * @hw: pointer to the HW structure
998  *
999  * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1000  * extended control register.
1001  */
1002 void
1003 e1000_reload_nvm(struct e1000_hw *hw)
1004 {
1005 	if (hw->func.reload_nvm)
1006 		hw->func.reload_nvm(hw);
1007 }
1008 
1009 /*
1010  * e1000_read_nvm - Reads NVM (EEPROM)
1011  * @hw: pointer to the HW structure
1012  * @offset: the word offset to read
1013  * @words: number of 16-bit words to read
1014  * @data: pointer to the properly sized buffer for the data.
1015  *
1016  * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1017  * pointer entry point called by drivers.
1018  */
1019 s32
1020 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1021 {
1022 	if (hw->func.read_nvm)
1023 		return (hw->func.read_nvm(hw, offset, words, data));
1024 
1025 	return (-E1000_ERR_CONFIG);
1026 }
1027 
1028 /*
1029  * e1000_write_nvm - Writes to NVM (EEPROM)
1030  * @hw: pointer to the HW structure
1031  * @offset: the word offset to read
1032  * @words: number of 16-bit words to write
1033  * @data: pointer to the properly sized buffer for the data.
1034  *
1035  * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1036  * pointer entry point called by drivers.
1037  */
1038 s32
1039 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1040 {
1041 	if (hw->func.write_nvm)
1042 		return (hw->func.write_nvm(hw, offset, words, data));
1043 
1044 	return (E1000_SUCCESS);
1045 }
1046 
1047 /*
1048  * e1000_write_8bit_ctrl_reg - Writes 8bit Control register
1049  * @hw: pointer to the HW structure
1050  * @reg: 32bit register offset
1051  * @offset: the register to write
1052  * @data: the value to write.
1053  *
1054  * Writes the PHY register at offset with the value in data.
1055  * This is a function pointer entry point called by drivers.
1056  */
1057 s32
1058 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset, u8 data)
1059 {
1060 	return (e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data));
1061 }
1062 
1063 /*
1064  * e1000_power_up_phy - Restores link in case of PHY power down
1065  * @hw: pointer to the HW structure
1066  *
1067  * The phy may be powered down to save power, to turn off link when the
1068  * driver is unloaded, or wake on lan is not enabled (among others).
1069  */
1070 void
1071 e1000_power_up_phy(struct e1000_hw *hw)
1072 {
1073 	if (hw->func.power_up_phy)
1074 		hw->func.power_up_phy(hw);
1075 
1076 	(void) e1000_setup_link(hw);
1077 }
1078 
1079 /*
1080  * e1000_power_down_phy - Power down PHY
1081  * @hw: pointer to the HW structure
1082  *
1083  * The phy may be powered down to save power, to turn off link when the
1084  * driver is unloaded, or wake on lan is not enabled (among others).
1085  */
1086 void
1087 e1000_power_down_phy(struct e1000_hw *hw)
1088 {
1089 	if (hw->func.power_down_phy)
1090 		hw->func.power_down_phy(hw);
1091 }
1092