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