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