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