xref: /onnv-gate/usr/src/uts/common/io/igb/igb_api.c (revision 10319:0355b7a83c0d)
15779Sxy150489 /*
25779Sxy150489  * CDDL HEADER START
35779Sxy150489  *
48571SChenlu.Chen@Sun.COM  * Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
55779Sxy150489  * The contents of this file are subject to the terms of the
65779Sxy150489  * Common Development and Distribution License (the "License").
75779Sxy150489  * You may not use this file except in compliance with the License.
85779Sxy150489  *
95779Sxy150489  * You can obtain a copy of the license at:
105779Sxy150489  *	http://www.opensolaris.org/os/licensing.
115779Sxy150489  * See the License for the specific language governing permissions
125779Sxy150489  * and limitations under the License.
135779Sxy150489  *
145779Sxy150489  * When using or redistributing this file, you may do so under the
155779Sxy150489  * License only. No other modification of this header is permitted.
165779Sxy150489  *
175779Sxy150489  * If applicable, add the following below this CDDL HEADER, with the
185779Sxy150489  * fields enclosed by brackets "[]" replaced with your own identifying
195779Sxy150489  * information: Portions Copyright [yyyy] [name of copyright owner]
205779Sxy150489  *
215779Sxy150489  * CDDL HEADER END
225779Sxy150489  */
235779Sxy150489 
245779Sxy150489 /*
258571SChenlu.Chen@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
265779Sxy150489  * Use is subject to license terms of the CDDL.
275779Sxy150489  */
285779Sxy150489 
29*10319SJason.Xu@Sun.COM /* IntelVersion: 1.122 v2-9-8_2009-6-12 */
305779Sxy150489 
315779Sxy150489 #include "igb_api.h"
325779Sxy150489 
335779Sxy150489 /*
345779Sxy150489  * e1000_init_mac_params - Initialize MAC function pointers
355779Sxy150489  * @hw: pointer to the HW structure
365779Sxy150489  *
375779Sxy150489  * This function initializes the function pointers for the MAC
385779Sxy150489  * set of functions.  Called by drivers or by e1000_setup_init_funcs.
395779Sxy150489  */
405779Sxy150489 s32
415779Sxy150489 e1000_init_mac_params(struct e1000_hw *hw)
425779Sxy150489 {
435779Sxy150489 	s32 ret_val = E1000_SUCCESS;
445779Sxy150489 
458571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.init_params) {
468571SChenlu.Chen@Sun.COM 		ret_val = hw->mac.ops.init_params(hw);
475779Sxy150489 		if (ret_val) {
485779Sxy150489 			DEBUGOUT("MAC Initialization Error\n");
495779Sxy150489 			goto out;
505779Sxy150489 		}
515779Sxy150489 	} else {
525779Sxy150489 		DEBUGOUT("mac.init_mac_params was NULL\n");
535779Sxy150489 		ret_val = -E1000_ERR_CONFIG;
545779Sxy150489 	}
555779Sxy150489 
565779Sxy150489 out:
575779Sxy150489 	return (ret_val);
585779Sxy150489 }
595779Sxy150489 
605779Sxy150489 /*
615779Sxy150489  * e1000_init_nvm_params - Initialize NVM function pointers
625779Sxy150489  * @hw: pointer to the HW structure
635779Sxy150489  *
645779Sxy150489  * This function initializes the function pointers for the NVM
655779Sxy150489  * set of functions.  Called by drivers or by e1000_setup_init_funcs.
665779Sxy150489  */
675779Sxy150489 s32
685779Sxy150489 e1000_init_nvm_params(struct e1000_hw *hw)
695779Sxy150489 {
705779Sxy150489 	s32 ret_val = E1000_SUCCESS;
715779Sxy150489 
728571SChenlu.Chen@Sun.COM 	if (hw->nvm.ops.init_params) {
738571SChenlu.Chen@Sun.COM 		ret_val = hw->nvm.ops.init_params(hw);
745779Sxy150489 		if (ret_val) {
755779Sxy150489 			DEBUGOUT("NVM Initialization Error\n");
765779Sxy150489 			goto out;
775779Sxy150489 		}
785779Sxy150489 	} else {
795779Sxy150489 		DEBUGOUT("nvm.init_nvm_params was NULL\n");
805779Sxy150489 		ret_val = -E1000_ERR_CONFIG;
815779Sxy150489 	}
825779Sxy150489 
835779Sxy150489 out:
845779Sxy150489 	return (ret_val);
855779Sxy150489 }
865779Sxy150489 
875779Sxy150489 /*
885779Sxy150489  * e1000_init_phy_params - Initialize PHY function pointers
895779Sxy150489  * @hw: pointer to the HW structure
905779Sxy150489  *
915779Sxy150489  * This function initializes the function pointers for the PHY
925779Sxy150489  * set of functions.  Called by drivers or by e1000_setup_init_funcs.
935779Sxy150489  */
945779Sxy150489 s32
955779Sxy150489 e1000_init_phy_params(struct e1000_hw *hw)
965779Sxy150489 {
975779Sxy150489 	s32 ret_val = E1000_SUCCESS;
985779Sxy150489 
998571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.init_params) {
1008571SChenlu.Chen@Sun.COM 		ret_val = hw->phy.ops.init_params(hw);
1015779Sxy150489 		if (ret_val) {
1025779Sxy150489 			DEBUGOUT("PHY Initialization Error\n");
1035779Sxy150489 			goto out;
1045779Sxy150489 		}
1055779Sxy150489 	} else {
1065779Sxy150489 		DEBUGOUT("phy.init_phy_params was NULL\n");
1075779Sxy150489 		ret_val =  -E1000_ERR_CONFIG;
1085779Sxy150489 	}
1095779Sxy150489 
1105779Sxy150489 out:
1115779Sxy150489 	return (ret_val);
1125779Sxy150489 }
1135779Sxy150489 
1145779Sxy150489 /*
1155779Sxy150489  * e1000_set_mac_type - Sets MAC type
1165779Sxy150489  * @hw: pointer to the HW structure
1175779Sxy150489  *
1185779Sxy150489  * This function sets the mac type of the adapter based on the
1195779Sxy150489  * device ID stored in the hw structure.
1205779Sxy150489  * MUST BE FIRST FUNCTION CALLED (explicitly or through
1215779Sxy150489  * e1000_setup_init_funcs()).
1225779Sxy150489  */
1235779Sxy150489 s32
1245779Sxy150489 e1000_set_mac_type(struct e1000_hw *hw)
1255779Sxy150489 {
1265779Sxy150489 	struct e1000_mac_info *mac = &hw->mac;
1275779Sxy150489 	s32 ret_val = E1000_SUCCESS;
1285779Sxy150489 
1295779Sxy150489 	DEBUGFUNC("e1000_set_mac_type");
1305779Sxy150489 
1315779Sxy150489 	switch (hw->device_id) {
1325779Sxy150489 	case E1000_DEV_ID_82575EB_COPPER:
1335779Sxy150489 	case E1000_DEV_ID_82575EB_FIBER_SERDES:
1345779Sxy150489 	case E1000_DEV_ID_82575GB_QUAD_COPPER:
1355779Sxy150489 		mac->type = e1000_82575;
1365779Sxy150489 		break;
1378571SChenlu.Chen@Sun.COM 	case E1000_DEV_ID_82576:
1388571SChenlu.Chen@Sun.COM 	case E1000_DEV_ID_82576_FIBER:
1398571SChenlu.Chen@Sun.COM 	case E1000_DEV_ID_82576_SERDES:
1408571SChenlu.Chen@Sun.COM 	case E1000_DEV_ID_82576_QUAD_COPPER:
141*10319SJason.Xu@Sun.COM 	case E1000_DEV_ID_82576_NS:
142*10319SJason.Xu@Sun.COM 	case E1000_DEV_ID_82576_SERDES_QUAD:
1438571SChenlu.Chen@Sun.COM 		mac->type = e1000_82576;
1448571SChenlu.Chen@Sun.COM 		break;
1455779Sxy150489 	default:
1465779Sxy150489 		/* Should never have loaded on this device */
1475779Sxy150489 		ret_val = -E1000_ERR_MAC_INIT;
1485779Sxy150489 		break;
1495779Sxy150489 	}
1505779Sxy150489 
1515779Sxy150489 	return (ret_val);
1525779Sxy150489 }
1535779Sxy150489 
1545779Sxy150489 /*
1555779Sxy150489  * e1000_setup_init_funcs - Initializes function pointers
1565779Sxy150489  * @hw: pointer to the HW structure
1578571SChenlu.Chen@Sun.COM  * @init_device: true will initialize the rest of the function pointers
1588571SChenlu.Chen@Sun.COM  *		getting the device ready for use.  false will only set
1595779Sxy150489  *		MAC type and the function pointers for the other init
1608571SChenlu.Chen@Sun.COM  *		functions.  Passing false will not generate any hardware
1615779Sxy150489  *		reads or writes.
1625779Sxy150489  *
1635779Sxy150489  * This function must be called by a driver in order to use the rest
1645779Sxy150489  * of the 'shared' code files. Called by drivers only.
1655779Sxy150489  */
1665779Sxy150489 s32
1675779Sxy150489 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
1685779Sxy150489 {
1695779Sxy150489 	s32 ret_val;
1705779Sxy150489 
1715779Sxy150489 	/* Can't do much good without knowing the MAC type. */
1725779Sxy150489 	ret_val = e1000_set_mac_type(hw);
1735779Sxy150489 	if (ret_val) {
1745779Sxy150489 		DEBUGOUT("ERROR: MAC type could not be set properly.\n");
1755779Sxy150489 		goto out;
1765779Sxy150489 	}
1775779Sxy150489 
1785779Sxy150489 	if (!hw->hw_addr) {
1795779Sxy150489 		DEBUGOUT("ERROR: Registers not mapped\n");
1805779Sxy150489 		ret_val = -E1000_ERR_CONFIG;
1815779Sxy150489 		goto out;
1825779Sxy150489 	}
1835779Sxy150489 
1845779Sxy150489 	/*
1858571SChenlu.Chen@Sun.COM 	 * Init function pointers to generic implementations. We do this first
1868571SChenlu.Chen@Sun.COM 	 * allowing a driver module to override it afterward.
1875779Sxy150489 	 */
1888571SChenlu.Chen@Sun.COM 	e1000_init_mac_ops_generic(hw);
1898571SChenlu.Chen@Sun.COM 	e1000_init_phy_ops_generic(hw);
1908571SChenlu.Chen@Sun.COM 	e1000_init_nvm_ops_generic(hw);
1915779Sxy150489 
1925779Sxy150489 	/*
1935779Sxy150489 	 * Set up the init function pointers. These are functions within the
1945779Sxy150489 	 * adapter family file that sets up function pointers for the rest of
1955779Sxy150489 	 * the functions in that family.
1965779Sxy150489 	 */
1975779Sxy150489 	switch (hw->mac.type) {
1985779Sxy150489 	case e1000_82575:
1998571SChenlu.Chen@Sun.COM 	case e1000_82576:
2005779Sxy150489 		e1000_init_function_pointers_82575(hw);
2015779Sxy150489 		break;
2025779Sxy150489 	default:
2035779Sxy150489 		DEBUGOUT("Hardware not supported\n");
2045779Sxy150489 		ret_val = -E1000_ERR_CONFIG;
2055779Sxy150489 		break;
2065779Sxy150489 	}
2075779Sxy150489 
2085779Sxy150489 	/*
2095779Sxy150489 	 * Initialize the rest of the function pointers. These require some
2105779Sxy150489 	 * register reads/writes in some cases.
2115779Sxy150489 	 */
2125779Sxy150489 	if (!(ret_val) && init_device) {
2135779Sxy150489 		ret_val = e1000_init_mac_params(hw);
2145779Sxy150489 		if (ret_val)
2155779Sxy150489 			goto out;
2165779Sxy150489 
2175779Sxy150489 		ret_val = e1000_init_nvm_params(hw);
2185779Sxy150489 		if (ret_val)
2195779Sxy150489 			goto out;
2205779Sxy150489 
2215779Sxy150489 		ret_val = e1000_init_phy_params(hw);
2225779Sxy150489 		if (ret_val)
2235779Sxy150489 			goto out;
2245779Sxy150489 
2255779Sxy150489 	}
2265779Sxy150489 
2275779Sxy150489 out:
2285779Sxy150489 	return (ret_val);
2295779Sxy150489 }
2305779Sxy150489 
2315779Sxy150489 /*
2325779Sxy150489  * e1000_get_bus_info - Obtain bus information for adapter
2335779Sxy150489  * @hw: pointer to the HW structure
2345779Sxy150489  *
2355779Sxy150489  * This will obtain information about the HW bus for which the
2368571SChenlu.Chen@Sun.COM  * adapter is attached and stores it in the hw structure. This is a
2375779Sxy150489  * function pointer entry point called by drivers.
2385779Sxy150489  */
2395779Sxy150489 s32
2405779Sxy150489 e1000_get_bus_info(struct e1000_hw *hw)
2415779Sxy150489 {
2428571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.get_bus_info)
2438571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.get_bus_info(hw));
2445779Sxy150489 
2455779Sxy150489 	return (E1000_SUCCESS);
2465779Sxy150489 }
2475779Sxy150489 
2485779Sxy150489 /*
2495779Sxy150489  * e1000_clear_vfta - Clear VLAN filter table
2505779Sxy150489  * @hw: pointer to the HW structure
2515779Sxy150489  *
2525779Sxy150489  * This clears the VLAN filter table on the adapter. This is a function
2535779Sxy150489  * pointer entry point called by drivers.
2545779Sxy150489  */
2555779Sxy150489 void
2565779Sxy150489 e1000_clear_vfta(struct e1000_hw *hw)
2575779Sxy150489 {
2588571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.clear_vfta)
2598571SChenlu.Chen@Sun.COM 		hw->mac.ops.clear_vfta(hw);
2605779Sxy150489 }
2615779Sxy150489 
2625779Sxy150489 /*
2635779Sxy150489  * e1000_write_vfta - Write value to VLAN filter table
2645779Sxy150489  * @hw: pointer to the HW structure
2655779Sxy150489  * @offset: the 32-bit offset in which to write the value to.
2665779Sxy150489  * @value: the 32-bit value to write at location offset.
2675779Sxy150489  *
2685779Sxy150489  * This writes a 32-bit value to a 32-bit offset in the VLAN filter
2695779Sxy150489  * table. This is a function pointer entry point called by drivers.
2705779Sxy150489  */
2715779Sxy150489 void
2725779Sxy150489 e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
2735779Sxy150489 {
2748571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.write_vfta)
2758571SChenlu.Chen@Sun.COM 		hw->mac.ops.write_vfta(hw, offset, value);
2765779Sxy150489 }
2775779Sxy150489 
2785779Sxy150489 /*
2795779Sxy150489  * e1000_update_mc_addr_list - Update Multicast addresses
2805779Sxy150489  * @hw: pointer to the HW structure
2815779Sxy150489  * @mc_addr_list: array of multicast addresses to program
2825779Sxy150489  * @mc_addr_count: number of multicast addresses to program
2835779Sxy150489  *
284*10319SJason.Xu@Sun.COM  * Updates the Multicast Table Array.
2855779Sxy150489  * The caller must have a packed mc_addr_list of multicast addresses.
2865779Sxy150489  */
2875779Sxy150489 void
2885779Sxy150489 e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
289*10319SJason.Xu@Sun.COM     u32 mc_addr_count)
2905779Sxy150489 {
2918571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.update_mc_addr_list)
2928571SChenlu.Chen@Sun.COM 		hw->mac.ops.update_mc_addr_list(hw,
293*10319SJason.Xu@Sun.COM 		    mc_addr_list, mc_addr_count);
2945779Sxy150489 }
2955779Sxy150489 
2965779Sxy150489 /*
2975779Sxy150489  * e1000_force_mac_fc - Force MAC flow control
2985779Sxy150489  * @hw: pointer to the HW structure
2995779Sxy150489  *
3005779Sxy150489  * Force the MAC's flow control settings. Currently no func pointer exists
3015779Sxy150489  * and all implementations are handled in the generic version of this
3025779Sxy150489  * function.
3035779Sxy150489  */
3045779Sxy150489 s32
3055779Sxy150489 e1000_force_mac_fc(struct e1000_hw *hw)
3065779Sxy150489 {
3075779Sxy150489 	return (e1000_force_mac_fc_generic(hw));
3085779Sxy150489 }
3095779Sxy150489 
3105779Sxy150489 /*
3115779Sxy150489  * e1000_check_for_link - Check/Store link connection
3125779Sxy150489  * @hw: pointer to the HW structure
3135779Sxy150489  *
3145779Sxy150489  * This checks the link condition of the adapter and stores the
3155779Sxy150489  * results in the hw->mac structure. This is a function pointer entry
3165779Sxy150489  * point called by drivers.
3175779Sxy150489  */
3185779Sxy150489 s32
3195779Sxy150489 e1000_check_for_link(struct e1000_hw *hw)
3205779Sxy150489 {
3218571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.check_for_link)
3228571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.check_for_link(hw));
3235779Sxy150489 
3245779Sxy150489 	return (-E1000_ERR_CONFIG);
3255779Sxy150489 }
3265779Sxy150489 
3275779Sxy150489 /*
3285779Sxy150489  * e1000_check_mng_mode - Check management mode
3295779Sxy150489  * @hw: pointer to the HW structure
3305779Sxy150489  *
3315779Sxy150489  * This checks if the adapter has manageability enabled.
3325779Sxy150489  * This is a function pointer entry point called by drivers.
3335779Sxy150489  */
3345779Sxy150489 bool
3355779Sxy150489 e1000_check_mng_mode(struct e1000_hw *hw)
3365779Sxy150489 {
3378571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.check_mng_mode)
3388571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.check_mng_mode(hw));
3395779Sxy150489 
3408571SChenlu.Chen@Sun.COM 	return (false);
3415779Sxy150489 }
3425779Sxy150489 
3435779Sxy150489 /*
3445779Sxy150489  * e1000_mng_write_dhcp_info - Writes DHCP info to host interface
3455779Sxy150489  * @hw: pointer to the HW structure
3465779Sxy150489  * @buffer: pointer to the host interface
3475779Sxy150489  * @length: size of the buffer
3485779Sxy150489  *
3495779Sxy150489  * Writes the DHCP information to the host interface.
3505779Sxy150489  */
3515779Sxy150489 s32
3525779Sxy150489 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
3535779Sxy150489 {
3545779Sxy150489 	return (e1000_mng_write_dhcp_info_generic(hw, buffer, length));
3555779Sxy150489 }
3565779Sxy150489 
3575779Sxy150489 /*
3585779Sxy150489  * e1000_reset_hw - Reset hardware
3595779Sxy150489  * @hw: pointer to the HW structure
3605779Sxy150489  *
3615779Sxy150489  * This resets the hardware into a known state. This is a function pointer
3625779Sxy150489  * entry point called by drivers.
3635779Sxy150489  */
3645779Sxy150489 s32
3655779Sxy150489 e1000_reset_hw(struct e1000_hw *hw)
3665779Sxy150489 {
3678571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.reset_hw)
3688571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.reset_hw(hw));
3695779Sxy150489 
3705779Sxy150489 	return (-E1000_ERR_CONFIG);
3715779Sxy150489 }
3725779Sxy150489 
3735779Sxy150489 /*
3745779Sxy150489  * e1000_init_hw - Initialize hardware
3755779Sxy150489  * @hw: pointer to the HW structure
3765779Sxy150489  *
3775779Sxy150489  * This inits the hardware readying it for operation. This is a function
3785779Sxy150489  * pointer entry point called by drivers.
3795779Sxy150489  */
3805779Sxy150489 s32
3815779Sxy150489 e1000_init_hw(struct e1000_hw *hw)
3825779Sxy150489 {
3838571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.init_hw)
3848571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.init_hw(hw));
3855779Sxy150489 
3865779Sxy150489 	return (-E1000_ERR_CONFIG);
3875779Sxy150489 }
3885779Sxy150489 
3895779Sxy150489 /*
3905779Sxy150489  * e1000_setup_link - Configures link and flow control
3915779Sxy150489  * @hw: pointer to the HW structure
3925779Sxy150489  *
3935779Sxy150489  * This configures link and flow control settings for the adapter. This
3945779Sxy150489  * is a function pointer entry point called by drivers. While modules can
3955779Sxy150489  * also call this, they probably call their own version of this function.
3965779Sxy150489  */
3975779Sxy150489 s32
3985779Sxy150489 e1000_setup_link(struct e1000_hw *hw)
3995779Sxy150489 {
4008571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.setup_link)
4018571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.setup_link(hw));
4025779Sxy150489 
4035779Sxy150489 	return (-E1000_ERR_CONFIG);
4045779Sxy150489 }
4055779Sxy150489 
4065779Sxy150489 /*
4075779Sxy150489  * e1000_get_speed_and_duplex - Returns current speed and duplex
4085779Sxy150489  * @hw: pointer to the HW structure
4095779Sxy150489  * @speed: pointer to a 16-bit value to store the speed
4105779Sxy150489  * @duplex: pointer to a 16-bit value to store the duplex.
4115779Sxy150489  *
4125779Sxy150489  * This returns the speed and duplex of the adapter in the two 'out'
4135779Sxy150489  * variables passed in. This is a function pointer entry point called
4145779Sxy150489  * by drivers.
4155779Sxy150489  */
4165779Sxy150489 s32
4175779Sxy150489 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
4185779Sxy150489 {
4198571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.get_link_up_info)
4208571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.get_link_up_info(hw, speed, duplex));
4215779Sxy150489 
4225779Sxy150489 	return (-E1000_ERR_CONFIG);
4235779Sxy150489 }
4245779Sxy150489 
4255779Sxy150489 /*
4265779Sxy150489  * e1000_setup_led - Configures SW controllable LED
4275779Sxy150489  * @hw: pointer to the HW structure
4285779Sxy150489  *
4295779Sxy150489  * This prepares the SW controllable LED for use and saves the current state
4305779Sxy150489  * of the LED so it can be later restored. This is a function pointer entry
4315779Sxy150489  * point called by drivers.
4325779Sxy150489  */
4335779Sxy150489 s32
4345779Sxy150489 e1000_setup_led(struct e1000_hw *hw)
4355779Sxy150489 {
4368571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.setup_led)
4378571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.setup_led(hw));
4385779Sxy150489 
4395779Sxy150489 	return (E1000_SUCCESS);
4405779Sxy150489 }
4415779Sxy150489 
4425779Sxy150489 /*
4435779Sxy150489  * e1000_cleanup_led - Restores SW controllable LED
4445779Sxy150489  * @hw: pointer to the HW structure
4455779Sxy150489  *
4465779Sxy150489  * This restores the SW controllable LED to the value saved off by
4475779Sxy150489  * e1000_setup_led. This is a function pointer entry point called by drivers.
4485779Sxy150489  */
4495779Sxy150489 s32
4505779Sxy150489 e1000_cleanup_led(struct e1000_hw *hw)
4515779Sxy150489 {
4528571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.cleanup_led)
4538571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.cleanup_led(hw));
4545779Sxy150489 
4555779Sxy150489 	return (E1000_SUCCESS);
4565779Sxy150489 }
4575779Sxy150489 
4585779Sxy150489 /*
4595779Sxy150489  * e1000_blink_led - Blink SW controllable LED
4605779Sxy150489  * @hw: pointer to the HW structure
4615779Sxy150489  *
4625779Sxy150489  * This starts the adapter LED blinking. Request the LED to be setup first
4635779Sxy150489  * and cleaned up after. This is a function pointer entry point called by
4645779Sxy150489  * drivers.
4655779Sxy150489  */
4665779Sxy150489 s32
4675779Sxy150489 e1000_blink_led(struct e1000_hw *hw)
4685779Sxy150489 {
4698571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.blink_led)
4708571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.blink_led(hw));
4715779Sxy150489 
4725779Sxy150489 	return (E1000_SUCCESS);
4735779Sxy150489 }
4745779Sxy150489 
4755779Sxy150489 /*
476*10319SJason.Xu@Sun.COM  * e1000_id_led_init - store LED configurations in SW
477*10319SJason.Xu@Sun.COM  * @hw: pointer to the HW structure
478*10319SJason.Xu@Sun.COM  *
479*10319SJason.Xu@Sun.COM  * Initializes the LED config in SW. This is a function pointer entry point
480*10319SJason.Xu@Sun.COM  * called by drivers.
481*10319SJason.Xu@Sun.COM  */
482*10319SJason.Xu@Sun.COM s32
483*10319SJason.Xu@Sun.COM e1000_id_led_init(struct e1000_hw *hw)
484*10319SJason.Xu@Sun.COM {
485*10319SJason.Xu@Sun.COM 	if (hw->mac.ops.id_led_init)
486*10319SJason.Xu@Sun.COM 		return (hw->mac.ops.id_led_init(hw));
487*10319SJason.Xu@Sun.COM 
488*10319SJason.Xu@Sun.COM 	return (E1000_SUCCESS);
489*10319SJason.Xu@Sun.COM }
490*10319SJason.Xu@Sun.COM 
491*10319SJason.Xu@Sun.COM /*
4925779Sxy150489  * e1000_led_on - Turn on SW controllable LED
4935779Sxy150489  * @hw: pointer to the HW structure
4945779Sxy150489  *
4955779Sxy150489  * Turns the SW defined LED on. This is a function pointer entry point
4965779Sxy150489  * called by drivers.
4975779Sxy150489  */
4985779Sxy150489 s32
4995779Sxy150489 e1000_led_on(struct e1000_hw *hw)
5005779Sxy150489 {
5018571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.led_on)
5028571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.led_on(hw));
5035779Sxy150489 
5045779Sxy150489 	return (E1000_SUCCESS);
5055779Sxy150489 }
5065779Sxy150489 
5075779Sxy150489 /*
5085779Sxy150489  * e1000_led_off - Turn off SW controllable LED
5095779Sxy150489  * @hw: pointer to the HW structure
5105779Sxy150489  *
5115779Sxy150489  * Turns the SW defined LED off. This is a function pointer entry point
5125779Sxy150489  * called by drivers.
5135779Sxy150489  */
5145779Sxy150489 s32
5155779Sxy150489 e1000_led_off(struct e1000_hw *hw)
5165779Sxy150489 {
5178571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.led_off)
5188571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.led_off(hw));
5195779Sxy150489 
5205779Sxy150489 	return (E1000_SUCCESS);
5215779Sxy150489 }
5225779Sxy150489 
5235779Sxy150489 /*
5245779Sxy150489  * e1000_reset_adaptive - Reset adaptive IFS
5255779Sxy150489  * @hw: pointer to the HW structure
5265779Sxy150489  *
5275779Sxy150489  * Resets the adaptive IFS. Currently no func pointer exists and all
5285779Sxy150489  * implementations are handled in the generic version of this function.
5295779Sxy150489  */
5305779Sxy150489 void
5315779Sxy150489 e1000_reset_adaptive(struct e1000_hw *hw)
5325779Sxy150489 {
5335779Sxy150489 	e1000_reset_adaptive_generic(hw);
5345779Sxy150489 }
5355779Sxy150489 
5365779Sxy150489 /*
5375779Sxy150489  * e1000_update_adaptive - Update adaptive IFS
5385779Sxy150489  * @hw: pointer to the HW structure
5395779Sxy150489  *
5405779Sxy150489  * Updates adapter IFS. Currently no func pointer exists and all
5415779Sxy150489  * implementations are handled in the generic version of this function.
5425779Sxy150489  */
5435779Sxy150489 void
5445779Sxy150489 e1000_update_adaptive(struct e1000_hw *hw)
5455779Sxy150489 {
5465779Sxy150489 	e1000_update_adaptive_generic(hw);
5475779Sxy150489 }
5485779Sxy150489 
5495779Sxy150489 /*
5505779Sxy150489  * e1000_disable_pcie_master - Disable PCI-Express master access
5515779Sxy150489  * @hw: pointer to the HW structure
5525779Sxy150489  *
5535779Sxy150489  * Disables PCI-Express master access and verifies there are no pending
5545779Sxy150489  * requests. Currently no func pointer exists and all implementations are
5555779Sxy150489  * handled in the generic version of this function.
5565779Sxy150489  */
5575779Sxy150489 s32
5585779Sxy150489 e1000_disable_pcie_master(struct e1000_hw *hw)
5595779Sxy150489 {
5605779Sxy150489 	return (e1000_disable_pcie_master_generic(hw));
5615779Sxy150489 }
5625779Sxy150489 
5635779Sxy150489 /*
5645779Sxy150489  * e1000_config_collision_dist - Configure collision distance
5655779Sxy150489  * @hw: pointer to the HW structure
5665779Sxy150489  *
5675779Sxy150489  * Configures the collision distance to the default value and is used
5685779Sxy150489  * during link setup.
5695779Sxy150489  */
5705779Sxy150489 void
5715779Sxy150489 e1000_config_collision_dist(struct e1000_hw *hw)
5725779Sxy150489 {
5738571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.config_collision_dist)
5748571SChenlu.Chen@Sun.COM 		hw->mac.ops.config_collision_dist(hw);
5755779Sxy150489 }
5765779Sxy150489 
5775779Sxy150489 /*
5785779Sxy150489  * e1000_rar_set - Sets a receive address register
5795779Sxy150489  * @hw: pointer to the HW structure
5805779Sxy150489  * @addr: address to set the RAR to
5815779Sxy150489  * @index: the RAR to set
5825779Sxy150489  *
5835779Sxy150489  * Sets a Receive Address Register (RAR) to the specified address.
5845779Sxy150489  */
5855779Sxy150489 void
5865779Sxy150489 e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
5875779Sxy150489 {
5888571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.rar_set)
5898571SChenlu.Chen@Sun.COM 		hw->mac.ops.rar_set(hw, addr, index);
5905779Sxy150489 }
5915779Sxy150489 
5925779Sxy150489 /*
5935779Sxy150489  * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
5945779Sxy150489  * @hw: pointer to the HW structure
5955779Sxy150489  *
5965779Sxy150489  * Ensures that the MDI/MDIX SW state is valid.
5975779Sxy150489  */
5985779Sxy150489 s32
5995779Sxy150489 e1000_validate_mdi_setting(struct e1000_hw *hw)
6005779Sxy150489 {
6018571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.validate_mdi_setting)
6028571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.validate_mdi_setting(hw));
6035779Sxy150489 
6045779Sxy150489 	return (E1000_SUCCESS);
6055779Sxy150489 }
6065779Sxy150489 
6075779Sxy150489 /*
6085779Sxy150489  * e1000_mta_set - Sets multicast table bit
6095779Sxy150489  * @hw: pointer to the HW structure
6105779Sxy150489  * @hash_value: Multicast hash value.
6115779Sxy150489  *
6125779Sxy150489  * This sets the bit in the multicast table corresponding to the
6135779Sxy150489  * hash value.  This is a function pointer entry point called by drivers.
6145779Sxy150489  */
6155779Sxy150489 void
6165779Sxy150489 e1000_mta_set(struct e1000_hw *hw, u32 hash_value)
6175779Sxy150489 {
6188571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.mta_set)
6198571SChenlu.Chen@Sun.COM 		hw->mac.ops.mta_set(hw, hash_value);
6205779Sxy150489 }
6215779Sxy150489 
6225779Sxy150489 /*
6235779Sxy150489  * e1000_hash_mc_addr - Determines address location in multicast table
6245779Sxy150489  * @hw: pointer to the HW structure
6255779Sxy150489  * @mc_addr: Multicast address to hash.
6265779Sxy150489  *
6275779Sxy150489  * This hashes an address to determine its location in the multicast
6285779Sxy150489  * table. Currently no func pointer exists and all implementations
6295779Sxy150489  * are handled in the generic version of this function.
6305779Sxy150489  */
6315779Sxy150489 u32
6325779Sxy150489 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
6335779Sxy150489 {
6345779Sxy150489 	return (e1000_hash_mc_addr_generic(hw, mc_addr));
6355779Sxy150489 }
6365779Sxy150489 
6375779Sxy150489 /*
6385779Sxy150489  * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
6395779Sxy150489  * @hw: pointer to the HW structure
6405779Sxy150489  *
6415779Sxy150489  * Enables packet filtering on transmit packets if manageability is enabled
6425779Sxy150489  * and host interface is enabled.
6435779Sxy150489  * Currently no func pointer exists and all implementations are handled in the
6445779Sxy150489  * generic version of this function.
6455779Sxy150489  */
6465779Sxy150489 bool
6475779Sxy150489 e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
6485779Sxy150489 {
6495779Sxy150489 	return (e1000_enable_tx_pkt_filtering_generic(hw));
6505779Sxy150489 }
6515779Sxy150489 
6525779Sxy150489 /*
6535779Sxy150489  * e1000_mng_host_if_write - Writes to the manageability host interface
6545779Sxy150489  * @hw: pointer to the HW structure
6555779Sxy150489  * @buffer: pointer to the host interface buffer
6565779Sxy150489  * @length: size of the buffer
6575779Sxy150489  * @offset: location in the buffer to write to
6585779Sxy150489  * @sum: sum of the data (not checksum)
6595779Sxy150489  *
6605779Sxy150489  * This function writes the buffer content at the offset given on the host if.
6615779Sxy150489  * It also does alignment considerations to do the writes in most efficient
6625779Sxy150489  * way.  Also fills up the sum of the buffer in *buffer parameter.
6635779Sxy150489  */
6645779Sxy150489 s32
6655779Sxy150489 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
6665779Sxy150489     u16 offset, u8 *sum)
6675779Sxy150489 {
6688571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.mng_host_if_write)
6698571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.mng_host_if_write(hw, buffer, length,
6708571SChenlu.Chen@Sun.COM 		    offset, sum));
6715779Sxy150489 
6725779Sxy150489 	return (E1000_NOT_IMPLEMENTED);
6735779Sxy150489 }
6745779Sxy150489 
6755779Sxy150489 /*
6765779Sxy150489  * e1000_mng_write_cmd_header - Writes manageability command header
6775779Sxy150489  * @hw: pointer to the HW structure
6785779Sxy150489  * @hdr: pointer to the host interface command header
6795779Sxy150489  *
6805779Sxy150489  * Writes the command header after does the checksum calculation.
6815779Sxy150489  */
6825779Sxy150489 s32
6835779Sxy150489 e1000_mng_write_cmd_header(struct e1000_hw *hw,
6845779Sxy150489     struct e1000_host_mng_command_header *hdr)
6855779Sxy150489 {
6868571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.mng_write_cmd_header)
6878571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.mng_write_cmd_header(hw, hdr));
6885779Sxy150489 
6895779Sxy150489 	return (E1000_NOT_IMPLEMENTED);
6905779Sxy150489 }
6915779Sxy150489 
6925779Sxy150489 /*
6935779Sxy150489  * e1000_mng_enable_host_if - Checks host interface is enabled
6945779Sxy150489  * @hw: pointer to the HW structure
6955779Sxy150489  *
6965779Sxy150489  * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
6975779Sxy150489  *
6988571SChenlu.Chen@Sun.COM  * This function checks whether the HOST IF is enabled for command operation
6995779Sxy150489  * and also checks whether the previous command is completed.  It busy waits
7005779Sxy150489  * in case of previous command is not completed.
7015779Sxy150489  */
7025779Sxy150489 s32
7035779Sxy150489 e1000_mng_enable_host_if(struct e1000_hw *hw)
7045779Sxy150489 {
7058571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.mng_enable_host_if)
7068571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.mng_enable_host_if(hw));
7075779Sxy150489 
7085779Sxy150489 	return (E1000_NOT_IMPLEMENTED);
7095779Sxy150489 }
7105779Sxy150489 
7115779Sxy150489 /*
7125779Sxy150489  * e1000_wait_autoneg - Waits for autonegotiation completion
7135779Sxy150489  * @hw: pointer to the HW structure
7145779Sxy150489  *
7155779Sxy150489  * Waits for autoneg to complete. Currently no func pointer exists and all
7165779Sxy150489  * implementations are handled in the generic version of this function.
7175779Sxy150489  */
7185779Sxy150489 s32
7195779Sxy150489 e1000_wait_autoneg(struct e1000_hw *hw)
7205779Sxy150489 {
7218571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.wait_autoneg)
7228571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.wait_autoneg(hw));
7235779Sxy150489 
7245779Sxy150489 	return (E1000_SUCCESS);
7255779Sxy150489 }
7265779Sxy150489 
7275779Sxy150489 /*
7285779Sxy150489  * e1000_check_reset_block - Verifies PHY can be reset
7295779Sxy150489  * @hw: pointer to the HW structure
7305779Sxy150489  *
7315779Sxy150489  * Checks if the PHY is in a state that can be reset or if manageability
7325779Sxy150489  * has it tied up. This is a function pointer entry point called by drivers.
7335779Sxy150489  */
7345779Sxy150489 s32
7355779Sxy150489 e1000_check_reset_block(struct e1000_hw *hw)
7365779Sxy150489 {
7378571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.check_reset_block)
7388571SChenlu.Chen@Sun.COM 		return (hw->phy.ops.check_reset_block(hw));
7395779Sxy150489 
7405779Sxy150489 	return (E1000_SUCCESS);
7415779Sxy150489 }
7425779Sxy150489 
7435779Sxy150489 /*
7445779Sxy150489  * e1000_read_phy_reg - Reads PHY register
7455779Sxy150489  * @hw: pointer to the HW structure
7465779Sxy150489  * @offset: the register to read
7475779Sxy150489  * @data: the buffer to store the 16-bit read.
7485779Sxy150489  *
7495779Sxy150489  * Reads the PHY register and returns the value in data.
7505779Sxy150489  * This is a function pointer entry point called by drivers.
7515779Sxy150489  */
7525779Sxy150489 s32
7535779Sxy150489 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
7545779Sxy150489 {
7558571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.read_reg)
7568571SChenlu.Chen@Sun.COM 		return (hw->phy.ops.read_reg(hw, offset, data));
7575779Sxy150489 
7585779Sxy150489 	return (E1000_SUCCESS);
7595779Sxy150489 }
7605779Sxy150489 
7615779Sxy150489 /*
7625779Sxy150489  * e1000_write_phy_reg - Writes PHY register
7635779Sxy150489  * @hw: pointer to the HW structure
7645779Sxy150489  * @offset: the register to write
7655779Sxy150489  * @data: the value to write.
7665779Sxy150489  *
7675779Sxy150489  * Writes the PHY register at offset with the value in data.
7685779Sxy150489  * This is a function pointer entry point called by drivers.
7695779Sxy150489  */
7705779Sxy150489 s32
7715779Sxy150489 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
7725779Sxy150489 {
7738571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.write_reg)
7748571SChenlu.Chen@Sun.COM 		return (hw->phy.ops.write_reg(hw, offset, data));
7758571SChenlu.Chen@Sun.COM 
7768571SChenlu.Chen@Sun.COM 	return (E1000_SUCCESS);
7778571SChenlu.Chen@Sun.COM }
7788571SChenlu.Chen@Sun.COM 
7798571SChenlu.Chen@Sun.COM /*
7808571SChenlu.Chen@Sun.COM  * e1000_release_phy - Generic release PHY
7818571SChenlu.Chen@Sun.COM  * @hw: pointer to the HW structure
7828571SChenlu.Chen@Sun.COM  *
7838571SChenlu.Chen@Sun.COM  * Return if silicon family does not require a semaphore when accessing the
7848571SChenlu.Chen@Sun.COM  * PHY.
7858571SChenlu.Chen@Sun.COM  */
7868571SChenlu.Chen@Sun.COM void
7878571SChenlu.Chen@Sun.COM e1000_release_phy(struct e1000_hw *hw)
7888571SChenlu.Chen@Sun.COM {
7898571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.release)
7908571SChenlu.Chen@Sun.COM 		hw->phy.ops.release(hw);
7918571SChenlu.Chen@Sun.COM }
7928571SChenlu.Chen@Sun.COM 
7938571SChenlu.Chen@Sun.COM /*
7948571SChenlu.Chen@Sun.COM  * e1000_acquire_phy - Generic acquire PHY
7958571SChenlu.Chen@Sun.COM  * @hw: pointer to the HW structure
7968571SChenlu.Chen@Sun.COM  *
7978571SChenlu.Chen@Sun.COM  * Return success if silicon family does not require a semaphore when
7988571SChenlu.Chen@Sun.COM  * accessing the PHY.
7998571SChenlu.Chen@Sun.COM  */
8008571SChenlu.Chen@Sun.COM s32
8018571SChenlu.Chen@Sun.COM e1000_acquire_phy(struct e1000_hw *hw)
8028571SChenlu.Chen@Sun.COM {
8038571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.acquire)
8048571SChenlu.Chen@Sun.COM 		return (hw->phy.ops.acquire(hw));
8055779Sxy150489 
8065779Sxy150489 	return (E1000_SUCCESS);
8075779Sxy150489 }
8085779Sxy150489 
8095779Sxy150489 /*
8105779Sxy150489  * e1000_read_kmrn_reg - Reads register using Kumeran interface
8115779Sxy150489  * @hw: pointer to the HW structure
8125779Sxy150489  * @offset: the register to read
8135779Sxy150489  * @data: the location to store the 16-bit value read.
8145779Sxy150489  *
8155779Sxy150489  * Reads a register out of the Kumeran interface. Currently no func pointer
8165779Sxy150489  * exists and all implementations are handled in the generic version of
8175779Sxy150489  * this function.
8185779Sxy150489  */
8195779Sxy150489 s32
8205779Sxy150489 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
8215779Sxy150489 {
8225779Sxy150489 	return (e1000_read_kmrn_reg_generic(hw, offset, data));
8235779Sxy150489 }
8245779Sxy150489 
8255779Sxy150489 /*
8265779Sxy150489  * e1000_write_kmrn_reg - Writes register using Kumeran interface
8275779Sxy150489  * @hw: pointer to the HW structure
8285779Sxy150489  * @offset: the register to write
8295779Sxy150489  * @data: the value to write.
8305779Sxy150489  *
8315779Sxy150489  * Writes a register to the Kumeran interface. Currently no func pointer
8325779Sxy150489  * exists and all implementations are handled in the generic version of
8335779Sxy150489  * this function.
8345779Sxy150489  */
8355779Sxy150489 s32
8365779Sxy150489 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
8375779Sxy150489 {
8385779Sxy150489 	return (e1000_write_kmrn_reg_generic(hw, offset, data));
8395779Sxy150489 }
8405779Sxy150489 
8415779Sxy150489 /*
8425779Sxy150489  * e1000_get_cable_length - Retrieves cable length estimation
8435779Sxy150489  * @hw: pointer to the HW structure
8445779Sxy150489  *
8455779Sxy150489  * This function estimates the cable length and stores them in
8465779Sxy150489  * hw->phy.min_length and hw->phy.max_length. This is a function pointer
8475779Sxy150489  * entry point called by drivers.
8485779Sxy150489  */
8495779Sxy150489 s32
8505779Sxy150489 e1000_get_cable_length(struct e1000_hw *hw)
8515779Sxy150489 {
8528571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.get_cable_length)
8538571SChenlu.Chen@Sun.COM 		return (hw->phy.ops.get_cable_length(hw));
8545779Sxy150489 
8555779Sxy150489 	return (E1000_SUCCESS);
8565779Sxy150489 }
8575779Sxy150489 
8585779Sxy150489 /*
8595779Sxy150489  * e1000_get_phy_info - Retrieves PHY information from registers
8605779Sxy150489  * @hw: pointer to the HW structure
8615779Sxy150489  *
8625779Sxy150489  * This function gets some information from various PHY registers and
8635779Sxy150489  * populates hw->phy values with it. This is a function pointer entry
8645779Sxy150489  * point called by drivers.
8655779Sxy150489  */
8665779Sxy150489 s32
8675779Sxy150489 e1000_get_phy_info(struct e1000_hw *hw)
8685779Sxy150489 {
8698571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.get_info)
8708571SChenlu.Chen@Sun.COM 		return (hw->phy.ops.get_info(hw));
8715779Sxy150489 
8725779Sxy150489 	return (E1000_SUCCESS);
8735779Sxy150489 }
8745779Sxy150489 
8755779Sxy150489 /*
8765779Sxy150489  * e1000_phy_hw_reset - Hard PHY reset
8775779Sxy150489  * @hw: pointer to the HW structure
8785779Sxy150489  *
8795779Sxy150489  * Performs a hard PHY reset. This is a function pointer entry point called
8805779Sxy150489  * by drivers.
8815779Sxy150489  */
8825779Sxy150489 s32
8835779Sxy150489 e1000_phy_hw_reset(struct e1000_hw *hw)
8845779Sxy150489 {
8858571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.reset)
8868571SChenlu.Chen@Sun.COM 		return (hw->phy.ops.reset(hw));
8875779Sxy150489 
8885779Sxy150489 	return (E1000_SUCCESS);
8895779Sxy150489 }
8905779Sxy150489 
8915779Sxy150489 /*
8925779Sxy150489  * e1000_phy_commit - Soft PHY reset
8935779Sxy150489  * @hw: pointer to the HW structure
8945779Sxy150489  *
8955779Sxy150489  * Performs a soft PHY reset on those that apply. This is a function pointer
8965779Sxy150489  * entry point called by drivers.
8975779Sxy150489  */
8985779Sxy150489 s32
8995779Sxy150489 e1000_phy_commit(struct e1000_hw *hw)
9005779Sxy150489 {
9018571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.commit)
9028571SChenlu.Chen@Sun.COM 		return (hw->phy.ops.commit(hw));
9035779Sxy150489 
9045779Sxy150489 	return (E1000_SUCCESS);
9055779Sxy150489 }
9065779Sxy150489 
9075779Sxy150489 /*
9088571SChenlu.Chen@Sun.COM  * e1000_set_d0_lplu_state - Sets low power link up state for D0
9095779Sxy150489  * @hw: pointer to the HW structure
9105779Sxy150489  * @active: boolean used to enable/disable lplu
9115779Sxy150489  *
9125779Sxy150489  * Success returns 0, Failure returns 1
9135779Sxy150489  *
9145779Sxy150489  * The low power link up (lplu) state is set to the power management level D0
9155779Sxy150489  * and SmartSpeed is disabled when active is true, else clear lplu for D0
9165779Sxy150489  * and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
9175779Sxy150489  * is used during Dx states where the power conservation is most important.
9185779Sxy150489  * During driver activity, SmartSpeed should be enabled so performance is
9195779Sxy150489  * maintained.  This is a function pointer entry point called by drivers.
9205779Sxy150489  */
9215779Sxy150489 s32
9225779Sxy150489 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
9235779Sxy150489 {
9248571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.set_d0_lplu_state)
9258571SChenlu.Chen@Sun.COM 		return (hw->phy.ops.set_d0_lplu_state(hw, active));
9265779Sxy150489 
9275779Sxy150489 	return (E1000_SUCCESS);
9285779Sxy150489 }
9295779Sxy150489 
9305779Sxy150489 /*
9315779Sxy150489  * e1000_set_d3_lplu_state - Sets low power link up state for D3
9325779Sxy150489  * @hw: pointer to the HW structure
9335779Sxy150489  * @active: boolean used to enable/disable lplu
9345779Sxy150489  *
9355779Sxy150489  * Success returns 0, Failure returns 1
9365779Sxy150489  *
9375779Sxy150489  * The low power link up (lplu) state is set to the power management level D3
9385779Sxy150489  * and SmartSpeed is disabled when active is true, else clear lplu for D3
9395779Sxy150489  * and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
9405779Sxy150489  * is used during Dx states where the power conservation is most important.
9415779Sxy150489  * During driver activity, SmartSpeed should be enabled so performance is
9425779Sxy150489  * maintained.  This is a function pointer entry point called by drivers.
9435779Sxy150489  */
9445779Sxy150489 s32
9455779Sxy150489 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
9465779Sxy150489 {
9478571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.set_d3_lplu_state)
9488571SChenlu.Chen@Sun.COM 		return (hw->phy.ops.set_d3_lplu_state(hw, active));
9495779Sxy150489 
9505779Sxy150489 	return (E1000_SUCCESS);
9515779Sxy150489 }
9525779Sxy150489 
9535779Sxy150489 /*
9545779Sxy150489  * e1000_read_mac_addr - Reads MAC address
9555779Sxy150489  * @hw: pointer to the HW structure
9565779Sxy150489  *
9575779Sxy150489  * Reads the MAC address out of the adapter and stores it in the HW structure.
9585779Sxy150489  * Currently no func pointer exists and all implementations are handled in the
9595779Sxy150489  * generic version of this function.
9605779Sxy150489  */
9615779Sxy150489 s32
9625779Sxy150489 e1000_read_mac_addr(struct e1000_hw *hw)
9635779Sxy150489 {
9648571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.read_mac_addr)
9658571SChenlu.Chen@Sun.COM 		return (hw->mac.ops.read_mac_addr(hw));
9665779Sxy150489 
9675779Sxy150489 	return (e1000_read_mac_addr_generic(hw));
9685779Sxy150489 }
9695779Sxy150489 
9705779Sxy150489 /*
9715779Sxy150489  * e1000_read_pba_num - Read device part number
9725779Sxy150489  * @hw: pointer to the HW structure
9735779Sxy150489  * @pba_num: pointer to device part number
9745779Sxy150489  *
9755779Sxy150489  * Reads the product board assembly (PBA) number from the EEPROM and stores
9765779Sxy150489  * the value in pba_num.
9775779Sxy150489  * Currently no func pointer exists and all implementations are handled in the
9785779Sxy150489  * generic version of this function.
9795779Sxy150489  */
9805779Sxy150489 s32
9815779Sxy150489 e1000_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
9825779Sxy150489 {
9835779Sxy150489 	return (e1000_read_pba_num_generic(hw, pba_num));
9845779Sxy150489 }
9855779Sxy150489 
9865779Sxy150489 /*
9875779Sxy150489  * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
9885779Sxy150489  * @hw: pointer to the HW structure
9895779Sxy150489  *
9905779Sxy150489  * Validates the NVM checksum is correct. This is a function pointer entry
9915779Sxy150489  * point called by drivers.
9925779Sxy150489  */
9935779Sxy150489 s32
9945779Sxy150489 e1000_validate_nvm_checksum(struct e1000_hw *hw)
9955779Sxy150489 {
9968571SChenlu.Chen@Sun.COM 	if (hw->nvm.ops.validate)
9978571SChenlu.Chen@Sun.COM 		return (hw->nvm.ops.validate(hw));
9985779Sxy150489 
9995779Sxy150489 	return (-E1000_ERR_CONFIG);
10005779Sxy150489 }
10015779Sxy150489 
10025779Sxy150489 /*
10035779Sxy150489  * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
10045779Sxy150489  * @hw: pointer to the HW structure
10055779Sxy150489  *
10065779Sxy150489  * Updates the NVM checksum. Currently no func pointer exists and all
10075779Sxy150489  * implementations are handled in the generic version of this function.
10085779Sxy150489  */
10095779Sxy150489 s32
10105779Sxy150489 e1000_update_nvm_checksum(struct e1000_hw *hw)
10115779Sxy150489 {
10128571SChenlu.Chen@Sun.COM 	if (hw->nvm.ops.update)
10138571SChenlu.Chen@Sun.COM 		return (hw->nvm.ops.update(hw));
10145779Sxy150489 
10155779Sxy150489 	return (-E1000_ERR_CONFIG);
10165779Sxy150489 }
10175779Sxy150489 
10185779Sxy150489 /*
10195779Sxy150489  * e1000_reload_nvm - Reloads EEPROM
10205779Sxy150489  * @hw: pointer to the HW structure
10215779Sxy150489  *
10225779Sxy150489  * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
10235779Sxy150489  * extended control register.
10245779Sxy150489  */
10255779Sxy150489 void
10265779Sxy150489 e1000_reload_nvm(struct e1000_hw *hw)
10275779Sxy150489 {
10288571SChenlu.Chen@Sun.COM 	if (hw->nvm.ops.reload)
10298571SChenlu.Chen@Sun.COM 		hw->nvm.ops.reload(hw);
10305779Sxy150489 }
10315779Sxy150489 
10325779Sxy150489 /*
10335779Sxy150489  * e1000_read_nvm - Reads NVM (EEPROM)
10345779Sxy150489  * @hw: pointer to the HW structure
10355779Sxy150489  * @offset: the word offset to read
10365779Sxy150489  * @words: number of 16-bit words to read
10375779Sxy150489  * @data: pointer to the properly sized buffer for the data.
10385779Sxy150489  *
10395779Sxy150489  * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
10405779Sxy150489  * pointer entry point called by drivers.
10415779Sxy150489  */
10425779Sxy150489 s32
10435779Sxy150489 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
10445779Sxy150489 {
10458571SChenlu.Chen@Sun.COM 	if (hw->nvm.ops.read)
10468571SChenlu.Chen@Sun.COM 		return (hw->nvm.ops.read(hw, offset, words, data));
10475779Sxy150489 
10485779Sxy150489 	return (-E1000_ERR_CONFIG);
10495779Sxy150489 }
10505779Sxy150489 
10515779Sxy150489 /*
10525779Sxy150489  * e1000_write_nvm - Writes to NVM (EEPROM)
10535779Sxy150489  * @hw: pointer to the HW structure
10545779Sxy150489  * @offset: the word offset to read
10555779Sxy150489  * @words: number of 16-bit words to write
10565779Sxy150489  * @data: pointer to the properly sized buffer for the data.
10575779Sxy150489  *
10585779Sxy150489  * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
10595779Sxy150489  * pointer entry point called by drivers.
10605779Sxy150489  */
10615779Sxy150489 s32
10625779Sxy150489 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
10635779Sxy150489 {
10648571SChenlu.Chen@Sun.COM 	if (hw->nvm.ops.write)
10658571SChenlu.Chen@Sun.COM 		return (hw->nvm.ops.write(hw, offset, words, data));
10665779Sxy150489 
10675779Sxy150489 	return (E1000_SUCCESS);
10685779Sxy150489 }
10695779Sxy150489 
10705779Sxy150489 /*
10715779Sxy150489  * e1000_write_8bit_ctrl_reg - Writes 8bit Control register
10725779Sxy150489  * @hw: pointer to the HW structure
10735779Sxy150489  * @reg: 32bit register offset
10745779Sxy150489  * @offset: the register to write
10755779Sxy150489  * @data: the value to write.
10765779Sxy150489  *
10775779Sxy150489  * Writes the PHY register at offset with the value in data.
10785779Sxy150489  * This is a function pointer entry point called by drivers.
10795779Sxy150489  */
10805779Sxy150489 s32
10815779Sxy150489 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset, u8 data)
10825779Sxy150489 {
10835779Sxy150489 	return (e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data));
10845779Sxy150489 }
10855779Sxy150489 
10865779Sxy150489 /*
10875779Sxy150489  * e1000_power_up_phy - Restores link in case of PHY power down
10885779Sxy150489  * @hw: pointer to the HW structure
10895779Sxy150489  *
10905779Sxy150489  * The phy may be powered down to save power, to turn off link when the
10915779Sxy150489  * driver is unloaded, or wake on lan is not enabled (among others).
10925779Sxy150489  */
10935779Sxy150489 void
10945779Sxy150489 e1000_power_up_phy(struct e1000_hw *hw)
10955779Sxy150489 {
10968571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.power_up)
10978571SChenlu.Chen@Sun.COM 		hw->phy.ops.power_up(hw);
10985779Sxy150489 
10995779Sxy150489 	(void) e1000_setup_link(hw);
11005779Sxy150489 }
11015779Sxy150489 
11025779Sxy150489 /*
11035779Sxy150489  * e1000_power_down_phy - Power down PHY
11045779Sxy150489  * @hw: pointer to the HW structure
11055779Sxy150489  *
11065779Sxy150489  * The phy may be powered down to save power, to turn off link when the
11075779Sxy150489  * driver is unloaded, or wake on lan is not enabled (among others).
11085779Sxy150489  */
11095779Sxy150489 void
11105779Sxy150489 e1000_power_down_phy(struct e1000_hw *hw)
11115779Sxy150489 {
11128571SChenlu.Chen@Sun.COM 	if (hw->phy.ops.power_down)
11138571SChenlu.Chen@Sun.COM 		hw->phy.ops.power_down(hw);
11145779Sxy150489 }
11158571SChenlu.Chen@Sun.COM 
11168571SChenlu.Chen@Sun.COM /*
11178571SChenlu.Chen@Sun.COM  * e1000_shutdown_fiber_serdes_link - Remove link during power down
11188571SChenlu.Chen@Sun.COM  * @hw: pointer to the HW structure
11198571SChenlu.Chen@Sun.COM  *
11208571SChenlu.Chen@Sun.COM  * Shutdown the optics and PCS on driver unload.
11218571SChenlu.Chen@Sun.COM  */
11228571SChenlu.Chen@Sun.COM void
11238571SChenlu.Chen@Sun.COM e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
11248571SChenlu.Chen@Sun.COM {
11258571SChenlu.Chen@Sun.COM 	if (hw->mac.ops.shutdown_serdes)
11268571SChenlu.Chen@Sun.COM 		hw->mac.ops.shutdown_serdes(hw);
11278571SChenlu.Chen@Sun.COM }
1128