15779Sxy150489 /*
25779Sxy150489 * CDDL HEADER START
35779Sxy150489 *
45779Sxy150489 * The contents of this file are subject to the terms of the
55779Sxy150489 * Common Development and Distribution License (the "License").
65779Sxy150489 * You may not use this file except in compliance with the License.
75779Sxy150489 *
8*12111SGuoqing.Zhu@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*12111SGuoqing.Zhu@Sun.COM * or http://www.opensolaris.org/os/licensing.
105779Sxy150489 * See the License for the specific language governing permissions
115779Sxy150489 * and limitations under the License.
125779Sxy150489 *
13*12111SGuoqing.Zhu@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
14*12111SGuoqing.Zhu@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155779Sxy150489 * If applicable, add the following below this CDDL HEADER, with the
165779Sxy150489 * fields enclosed by brackets "[]" replaced with your own identifying
175779Sxy150489 * information: Portions Copyright [yyyy] [name of copyright owner]
185779Sxy150489 *
195779Sxy150489 * CDDL HEADER END
205779Sxy150489 */
215779Sxy150489
225779Sxy150489 /*
23*12111SGuoqing.Zhu@Sun.COM * Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
245779Sxy150489 */
255779Sxy150489
26*12111SGuoqing.Zhu@Sun.COM /*
27*12111SGuoqing.Zhu@Sun.COM * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28*12111SGuoqing.Zhu@Sun.COM */
29*12111SGuoqing.Zhu@Sun.COM
30*12111SGuoqing.Zhu@Sun.COM /* IntelVersion: 1.129.2.1 v3_3_14_3_BHSW1 */
315779Sxy150489
325779Sxy150489 #include "igb_api.h"
335779Sxy150489
345779Sxy150489 /*
355779Sxy150489 * e1000_init_mac_params - Initialize MAC function pointers
365779Sxy150489 * @hw: pointer to the HW structure
375779Sxy150489 *
385779Sxy150489 * This function initializes the function pointers for the MAC
395779Sxy150489 * set of functions. Called by drivers or by e1000_setup_init_funcs.
405779Sxy150489 */
415779Sxy150489 s32
e1000_init_mac_params(struct e1000_hw * hw)425779Sxy150489 e1000_init_mac_params(struct e1000_hw *hw)
435779Sxy150489 {
445779Sxy150489 s32 ret_val = E1000_SUCCESS;
455779Sxy150489
468571SChenlu.Chen@Sun.COM if (hw->mac.ops.init_params) {
478571SChenlu.Chen@Sun.COM ret_val = hw->mac.ops.init_params(hw);
485779Sxy150489 if (ret_val) {
495779Sxy150489 DEBUGOUT("MAC Initialization Error\n");
505779Sxy150489 goto out;
515779Sxy150489 }
525779Sxy150489 } else {
535779Sxy150489 DEBUGOUT("mac.init_mac_params was NULL\n");
545779Sxy150489 ret_val = -E1000_ERR_CONFIG;
555779Sxy150489 }
565779Sxy150489
575779Sxy150489 out:
585779Sxy150489 return (ret_val);
595779Sxy150489 }
605779Sxy150489
615779Sxy150489 /*
625779Sxy150489 * e1000_init_nvm_params - Initialize NVM function pointers
635779Sxy150489 * @hw: pointer to the HW structure
645779Sxy150489 *
655779Sxy150489 * This function initializes the function pointers for the NVM
665779Sxy150489 * set of functions. Called by drivers or by e1000_setup_init_funcs.
675779Sxy150489 */
685779Sxy150489 s32
e1000_init_nvm_params(struct e1000_hw * hw)695779Sxy150489 e1000_init_nvm_params(struct e1000_hw *hw)
705779Sxy150489 {
715779Sxy150489 s32 ret_val = E1000_SUCCESS;
725779Sxy150489
738571SChenlu.Chen@Sun.COM if (hw->nvm.ops.init_params) {
748571SChenlu.Chen@Sun.COM ret_val = hw->nvm.ops.init_params(hw);
755779Sxy150489 if (ret_val) {
765779Sxy150489 DEBUGOUT("NVM Initialization Error\n");
775779Sxy150489 goto out;
785779Sxy150489 }
795779Sxy150489 } else {
805779Sxy150489 DEBUGOUT("nvm.init_nvm_params was NULL\n");
815779Sxy150489 ret_val = -E1000_ERR_CONFIG;
825779Sxy150489 }
835779Sxy150489
845779Sxy150489 out:
855779Sxy150489 return (ret_val);
865779Sxy150489 }
875779Sxy150489
885779Sxy150489 /*
895779Sxy150489 * e1000_init_phy_params - Initialize PHY function pointers
905779Sxy150489 * @hw: pointer to the HW structure
915779Sxy150489 *
925779Sxy150489 * This function initializes the function pointers for the PHY
935779Sxy150489 * set of functions. Called by drivers or by e1000_setup_init_funcs.
945779Sxy150489 */
955779Sxy150489 s32
e1000_init_phy_params(struct e1000_hw * hw)965779Sxy150489 e1000_init_phy_params(struct e1000_hw *hw)
975779Sxy150489 {
985779Sxy150489 s32 ret_val = E1000_SUCCESS;
995779Sxy150489
1008571SChenlu.Chen@Sun.COM if (hw->phy.ops.init_params) {
1018571SChenlu.Chen@Sun.COM ret_val = hw->phy.ops.init_params(hw);
1025779Sxy150489 if (ret_val) {
1035779Sxy150489 DEBUGOUT("PHY Initialization Error\n");
1045779Sxy150489 goto out;
1055779Sxy150489 }
1065779Sxy150489 } else {
1075779Sxy150489 DEBUGOUT("phy.init_phy_params was NULL\n");
1085779Sxy150489 ret_val = -E1000_ERR_CONFIG;
1095779Sxy150489 }
1105779Sxy150489
1115779Sxy150489 out:
1125779Sxy150489 return (ret_val);
1135779Sxy150489 }
1145779Sxy150489
1155779Sxy150489 /*
1165779Sxy150489 * e1000_set_mac_type - Sets MAC type
1175779Sxy150489 * @hw: pointer to the HW structure
1185779Sxy150489 *
1195779Sxy150489 * This function sets the mac type of the adapter based on the
1205779Sxy150489 * device ID stored in the hw structure.
1215779Sxy150489 * MUST BE FIRST FUNCTION CALLED (explicitly or through
1225779Sxy150489 * e1000_setup_init_funcs()).
1235779Sxy150489 */
1245779Sxy150489 s32
e1000_set_mac_type(struct e1000_hw * hw)1255779Sxy150489 e1000_set_mac_type(struct e1000_hw *hw)
1265779Sxy150489 {
1275779Sxy150489 struct e1000_mac_info *mac = &hw->mac;
1285779Sxy150489 s32 ret_val = E1000_SUCCESS;
1295779Sxy150489
1305779Sxy150489 DEBUGFUNC("e1000_set_mac_type");
1315779Sxy150489
1325779Sxy150489 switch (hw->device_id) {
1335779Sxy150489 case E1000_DEV_ID_82575EB_COPPER:
1345779Sxy150489 case E1000_DEV_ID_82575EB_FIBER_SERDES:
1355779Sxy150489 case E1000_DEV_ID_82575GB_QUAD_COPPER:
1365779Sxy150489 mac->type = e1000_82575;
1375779Sxy150489 break;
1388571SChenlu.Chen@Sun.COM case E1000_DEV_ID_82576:
1398571SChenlu.Chen@Sun.COM case E1000_DEV_ID_82576_FIBER:
1408571SChenlu.Chen@Sun.COM case E1000_DEV_ID_82576_SERDES:
1418571SChenlu.Chen@Sun.COM case E1000_DEV_ID_82576_QUAD_COPPER:
14210319SJason.Xu@Sun.COM case E1000_DEV_ID_82576_NS:
14311155SJason.Xu@Sun.COM case E1000_DEV_ID_82576_NS_SERDES:
14410319SJason.Xu@Sun.COM case E1000_DEV_ID_82576_SERDES_QUAD:
1458571SChenlu.Chen@Sun.COM mac->type = e1000_82576;
1468571SChenlu.Chen@Sun.COM break;
14711155SJason.Xu@Sun.COM case E1000_DEV_ID_82580_COPPER:
14811155SJason.Xu@Sun.COM case E1000_DEV_ID_82580_FIBER:
14911155SJason.Xu@Sun.COM case E1000_DEV_ID_82580_SERDES:
15011155SJason.Xu@Sun.COM case E1000_DEV_ID_82580_SGMII:
15111155SJason.Xu@Sun.COM case E1000_DEV_ID_82580_COPPER_DUAL:
15211155SJason.Xu@Sun.COM mac->type = e1000_82580;
15311155SJason.Xu@Sun.COM break;
1545779Sxy150489 default:
1555779Sxy150489 /* Should never have loaded on this device */
1565779Sxy150489 ret_val = -E1000_ERR_MAC_INIT;
1575779Sxy150489 break;
1585779Sxy150489 }
1595779Sxy150489
1605779Sxy150489 return (ret_val);
1615779Sxy150489 }
1625779Sxy150489
1635779Sxy150489 /*
1645779Sxy150489 * e1000_setup_init_funcs - Initializes function pointers
1655779Sxy150489 * @hw: pointer to the HW structure
1668571SChenlu.Chen@Sun.COM * @init_device: true will initialize the rest of the function pointers
1678571SChenlu.Chen@Sun.COM * getting the device ready for use. false will only set
1685779Sxy150489 * MAC type and the function pointers for the other init
1698571SChenlu.Chen@Sun.COM * functions. Passing false will not generate any hardware
1705779Sxy150489 * reads or writes.
1715779Sxy150489 *
1725779Sxy150489 * This function must be called by a driver in order to use the rest
1735779Sxy150489 * of the 'shared' code files. Called by drivers only.
1745779Sxy150489 */
1755779Sxy150489 s32
e1000_setup_init_funcs(struct e1000_hw * hw,bool init_device)1765779Sxy150489 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
1775779Sxy150489 {
1785779Sxy150489 s32 ret_val;
1795779Sxy150489
1805779Sxy150489 /* Can't do much good without knowing the MAC type. */
1815779Sxy150489 ret_val = e1000_set_mac_type(hw);
1825779Sxy150489 if (ret_val) {
1835779Sxy150489 DEBUGOUT("ERROR: MAC type could not be set properly.\n");
1845779Sxy150489 goto out;
1855779Sxy150489 }
1865779Sxy150489
1875779Sxy150489 if (!hw->hw_addr) {
1885779Sxy150489 DEBUGOUT("ERROR: Registers not mapped\n");
1895779Sxy150489 ret_val = -E1000_ERR_CONFIG;
1905779Sxy150489 goto out;
1915779Sxy150489 }
1925779Sxy150489
1935779Sxy150489 /*
1948571SChenlu.Chen@Sun.COM * Init function pointers to generic implementations. We do this first
1958571SChenlu.Chen@Sun.COM * allowing a driver module to override it afterward.
1965779Sxy150489 */
1978571SChenlu.Chen@Sun.COM e1000_init_mac_ops_generic(hw);
1988571SChenlu.Chen@Sun.COM e1000_init_phy_ops_generic(hw);
1998571SChenlu.Chen@Sun.COM e1000_init_nvm_ops_generic(hw);
2005779Sxy150489
2015779Sxy150489 /*
2025779Sxy150489 * Set up the init function pointers. These are functions within the
2035779Sxy150489 * adapter family file that sets up function pointers for the rest of
2045779Sxy150489 * the functions in that family.
2055779Sxy150489 */
2065779Sxy150489 switch (hw->mac.type) {
2075779Sxy150489 case e1000_82575:
2088571SChenlu.Chen@Sun.COM case e1000_82576:
20911155SJason.Xu@Sun.COM case e1000_82580:
2105779Sxy150489 e1000_init_function_pointers_82575(hw);
2115779Sxy150489 break;
2125779Sxy150489 default:
2135779Sxy150489 DEBUGOUT("Hardware not supported\n");
2145779Sxy150489 ret_val = -E1000_ERR_CONFIG;
2155779Sxy150489 break;
2165779Sxy150489 }
2175779Sxy150489
2185779Sxy150489 /*
2195779Sxy150489 * Initialize the rest of the function pointers. These require some
2205779Sxy150489 * register reads/writes in some cases.
2215779Sxy150489 */
2225779Sxy150489 if (!(ret_val) && init_device) {
2235779Sxy150489 ret_val = e1000_init_mac_params(hw);
2245779Sxy150489 if (ret_val)
2255779Sxy150489 goto out;
2265779Sxy150489
2275779Sxy150489 ret_val = e1000_init_nvm_params(hw);
2285779Sxy150489 if (ret_val)
2295779Sxy150489 goto out;
2305779Sxy150489
2315779Sxy150489 ret_val = e1000_init_phy_params(hw);
2325779Sxy150489 if (ret_val)
2335779Sxy150489 goto out;
2345779Sxy150489
2355779Sxy150489 }
2365779Sxy150489
2375779Sxy150489 out:
2385779Sxy150489 return (ret_val);
2395779Sxy150489 }
2405779Sxy150489
2415779Sxy150489 /*
2425779Sxy150489 * e1000_get_bus_info - Obtain bus information for adapter
2435779Sxy150489 * @hw: pointer to the HW structure
2445779Sxy150489 *
2455779Sxy150489 * This will obtain information about the HW bus for which the
2468571SChenlu.Chen@Sun.COM * adapter is attached and stores it in the hw structure. This is a
2475779Sxy150489 * function pointer entry point called by drivers.
2485779Sxy150489 */
2495779Sxy150489 s32
e1000_get_bus_info(struct e1000_hw * hw)2505779Sxy150489 e1000_get_bus_info(struct e1000_hw *hw)
2515779Sxy150489 {
2528571SChenlu.Chen@Sun.COM if (hw->mac.ops.get_bus_info)
2538571SChenlu.Chen@Sun.COM return (hw->mac.ops.get_bus_info(hw));
2545779Sxy150489
2555779Sxy150489 return (E1000_SUCCESS);
2565779Sxy150489 }
2575779Sxy150489
2585779Sxy150489 /*
2595779Sxy150489 * e1000_clear_vfta - Clear VLAN filter table
2605779Sxy150489 * @hw: pointer to the HW structure
2615779Sxy150489 *
2625779Sxy150489 * This clears the VLAN filter table on the adapter. This is a function
2635779Sxy150489 * pointer entry point called by drivers.
2645779Sxy150489 */
2655779Sxy150489 void
e1000_clear_vfta(struct e1000_hw * hw)2665779Sxy150489 e1000_clear_vfta(struct e1000_hw *hw)
2675779Sxy150489 {
2688571SChenlu.Chen@Sun.COM if (hw->mac.ops.clear_vfta)
2698571SChenlu.Chen@Sun.COM hw->mac.ops.clear_vfta(hw);
2705779Sxy150489 }
2715779Sxy150489
2725779Sxy150489 /*
2735779Sxy150489 * e1000_write_vfta - Write value to VLAN filter table
2745779Sxy150489 * @hw: pointer to the HW structure
2755779Sxy150489 * @offset: the 32-bit offset in which to write the value to.
2765779Sxy150489 * @value: the 32-bit value to write at location offset.
2775779Sxy150489 *
2785779Sxy150489 * This writes a 32-bit value to a 32-bit offset in the VLAN filter
2795779Sxy150489 * table. This is a function pointer entry point called by drivers.
2805779Sxy150489 */
2815779Sxy150489 void
e1000_write_vfta(struct e1000_hw * hw,u32 offset,u32 value)2825779Sxy150489 e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
2835779Sxy150489 {
2848571SChenlu.Chen@Sun.COM if (hw->mac.ops.write_vfta)
2858571SChenlu.Chen@Sun.COM hw->mac.ops.write_vfta(hw, offset, value);
2865779Sxy150489 }
2875779Sxy150489
2885779Sxy150489 /*
2895779Sxy150489 * e1000_update_mc_addr_list - Update Multicast addresses
2905779Sxy150489 * @hw: pointer to the HW structure
2915779Sxy150489 * @mc_addr_list: array of multicast addresses to program
2925779Sxy150489 * @mc_addr_count: number of multicast addresses to program
2935779Sxy150489 *
29410319SJason.Xu@Sun.COM * Updates the Multicast Table Array.
2955779Sxy150489 * The caller must have a packed mc_addr_list of multicast addresses.
2965779Sxy150489 */
2975779Sxy150489 void
e1000_update_mc_addr_list(struct e1000_hw * hw,u8 * mc_addr_list,u32 mc_addr_count)2985779Sxy150489 e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
29910319SJason.Xu@Sun.COM u32 mc_addr_count)
3005779Sxy150489 {
3018571SChenlu.Chen@Sun.COM if (hw->mac.ops.update_mc_addr_list)
3028571SChenlu.Chen@Sun.COM hw->mac.ops.update_mc_addr_list(hw,
30310319SJason.Xu@Sun.COM mc_addr_list, mc_addr_count);
3045779Sxy150489 }
3055779Sxy150489
3065779Sxy150489 /*
3075779Sxy150489 * e1000_force_mac_fc - Force MAC flow control
3085779Sxy150489 * @hw: pointer to the HW structure
3095779Sxy150489 *
3105779Sxy150489 * Force the MAC's flow control settings. Currently no func pointer exists
3115779Sxy150489 * and all implementations are handled in the generic version of this
3125779Sxy150489 * function.
3135779Sxy150489 */
3145779Sxy150489 s32
e1000_force_mac_fc(struct e1000_hw * hw)3155779Sxy150489 e1000_force_mac_fc(struct e1000_hw *hw)
3165779Sxy150489 {
3175779Sxy150489 return (e1000_force_mac_fc_generic(hw));
3185779Sxy150489 }
3195779Sxy150489
3205779Sxy150489 /*
3215779Sxy150489 * e1000_check_for_link - Check/Store link connection
3225779Sxy150489 * @hw: pointer to the HW structure
3235779Sxy150489 *
3245779Sxy150489 * This checks the link condition of the adapter and stores the
3255779Sxy150489 * results in the hw->mac structure. This is a function pointer entry
3265779Sxy150489 * point called by drivers.
3275779Sxy150489 */
3285779Sxy150489 s32
e1000_check_for_link(struct e1000_hw * hw)3295779Sxy150489 e1000_check_for_link(struct e1000_hw *hw)
3305779Sxy150489 {
3318571SChenlu.Chen@Sun.COM if (hw->mac.ops.check_for_link)
3328571SChenlu.Chen@Sun.COM return (hw->mac.ops.check_for_link(hw));
3335779Sxy150489
3345779Sxy150489 return (-E1000_ERR_CONFIG);
3355779Sxy150489 }
3365779Sxy150489
3375779Sxy150489 /*
3385779Sxy150489 * e1000_check_mng_mode - Check management mode
3395779Sxy150489 * @hw: pointer to the HW structure
3405779Sxy150489 *
3415779Sxy150489 * This checks if the adapter has manageability enabled.
3425779Sxy150489 * This is a function pointer entry point called by drivers.
3435779Sxy150489 */
3445779Sxy150489 bool
e1000_check_mng_mode(struct e1000_hw * hw)3455779Sxy150489 e1000_check_mng_mode(struct e1000_hw *hw)
3465779Sxy150489 {
3478571SChenlu.Chen@Sun.COM if (hw->mac.ops.check_mng_mode)
3488571SChenlu.Chen@Sun.COM return (hw->mac.ops.check_mng_mode(hw));
3495779Sxy150489
3508571SChenlu.Chen@Sun.COM return (false);
3515779Sxy150489 }
3525779Sxy150489
3535779Sxy150489 /*
3545779Sxy150489 * e1000_mng_write_dhcp_info - Writes DHCP info to host interface
3555779Sxy150489 * @hw: pointer to the HW structure
3565779Sxy150489 * @buffer: pointer to the host interface
3575779Sxy150489 * @length: size of the buffer
3585779Sxy150489 *
3595779Sxy150489 * Writes the DHCP information to the host interface.
3605779Sxy150489 */
3615779Sxy150489 s32
e1000_mng_write_dhcp_info(struct e1000_hw * hw,u8 * buffer,u16 length)3625779Sxy150489 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
3635779Sxy150489 {
3645779Sxy150489 return (e1000_mng_write_dhcp_info_generic(hw, buffer, length));
3655779Sxy150489 }
3665779Sxy150489
3675779Sxy150489 /*
3685779Sxy150489 * e1000_reset_hw - Reset hardware
3695779Sxy150489 * @hw: pointer to the HW structure
3705779Sxy150489 *
3715779Sxy150489 * This resets the hardware into a known state. This is a function pointer
3725779Sxy150489 * entry point called by drivers.
3735779Sxy150489 */
3745779Sxy150489 s32
e1000_reset_hw(struct e1000_hw * hw)3755779Sxy150489 e1000_reset_hw(struct e1000_hw *hw)
3765779Sxy150489 {
3778571SChenlu.Chen@Sun.COM if (hw->mac.ops.reset_hw)
3788571SChenlu.Chen@Sun.COM return (hw->mac.ops.reset_hw(hw));
3795779Sxy150489
3805779Sxy150489 return (-E1000_ERR_CONFIG);
3815779Sxy150489 }
3825779Sxy150489
3835779Sxy150489 /*
3845779Sxy150489 * e1000_init_hw - Initialize hardware
3855779Sxy150489 * @hw: pointer to the HW structure
3865779Sxy150489 *
3875779Sxy150489 * This inits the hardware readying it for operation. This is a function
3885779Sxy150489 * pointer entry point called by drivers.
3895779Sxy150489 */
3905779Sxy150489 s32
e1000_init_hw(struct e1000_hw * hw)3915779Sxy150489 e1000_init_hw(struct e1000_hw *hw)
3925779Sxy150489 {
3938571SChenlu.Chen@Sun.COM if (hw->mac.ops.init_hw)
3948571SChenlu.Chen@Sun.COM return (hw->mac.ops.init_hw(hw));
3955779Sxy150489
3965779Sxy150489 return (-E1000_ERR_CONFIG);
3975779Sxy150489 }
3985779Sxy150489
3995779Sxy150489 /*
4005779Sxy150489 * e1000_setup_link - Configures link and flow control
4015779Sxy150489 * @hw: pointer to the HW structure
4025779Sxy150489 *
4035779Sxy150489 * This configures link and flow control settings for the adapter. This
4045779Sxy150489 * is a function pointer entry point called by drivers. While modules can
4055779Sxy150489 * also call this, they probably call their own version of this function.
4065779Sxy150489 */
4075779Sxy150489 s32
e1000_setup_link(struct e1000_hw * hw)4085779Sxy150489 e1000_setup_link(struct e1000_hw *hw)
4095779Sxy150489 {
4108571SChenlu.Chen@Sun.COM if (hw->mac.ops.setup_link)
4118571SChenlu.Chen@Sun.COM return (hw->mac.ops.setup_link(hw));
4125779Sxy150489
4135779Sxy150489 return (-E1000_ERR_CONFIG);
4145779Sxy150489 }
4155779Sxy150489
4165779Sxy150489 /*
4175779Sxy150489 * e1000_get_speed_and_duplex - Returns current speed and duplex
4185779Sxy150489 * @hw: pointer to the HW structure
4195779Sxy150489 * @speed: pointer to a 16-bit value to store the speed
4205779Sxy150489 * @duplex: pointer to a 16-bit value to store the duplex.
4215779Sxy150489 *
4225779Sxy150489 * This returns the speed and duplex of the adapter in the two 'out'
4235779Sxy150489 * variables passed in. This is a function pointer entry point called
4245779Sxy150489 * by drivers.
4255779Sxy150489 */
4265779Sxy150489 s32
e1000_get_speed_and_duplex(struct e1000_hw * hw,u16 * speed,u16 * duplex)4275779Sxy150489 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
4285779Sxy150489 {
4298571SChenlu.Chen@Sun.COM if (hw->mac.ops.get_link_up_info)
4308571SChenlu.Chen@Sun.COM return (hw->mac.ops.get_link_up_info(hw, speed, duplex));
4315779Sxy150489
4325779Sxy150489 return (-E1000_ERR_CONFIG);
4335779Sxy150489 }
4345779Sxy150489
4355779Sxy150489 /*
4365779Sxy150489 * e1000_setup_led - Configures SW controllable LED
4375779Sxy150489 * @hw: pointer to the HW structure
4385779Sxy150489 *
4395779Sxy150489 * This prepares the SW controllable LED for use and saves the current state
4405779Sxy150489 * of the LED so it can be later restored. This is a function pointer entry
4415779Sxy150489 * point called by drivers.
4425779Sxy150489 */
4435779Sxy150489 s32
e1000_setup_led(struct e1000_hw * hw)4445779Sxy150489 e1000_setup_led(struct e1000_hw *hw)
4455779Sxy150489 {
4468571SChenlu.Chen@Sun.COM if (hw->mac.ops.setup_led)
4478571SChenlu.Chen@Sun.COM return (hw->mac.ops.setup_led(hw));
4485779Sxy150489
4495779Sxy150489 return (E1000_SUCCESS);
4505779Sxy150489 }
4515779Sxy150489
4525779Sxy150489 /*
4535779Sxy150489 * e1000_cleanup_led - Restores SW controllable LED
4545779Sxy150489 * @hw: pointer to the HW structure
4555779Sxy150489 *
4565779Sxy150489 * This restores the SW controllable LED to the value saved off by
4575779Sxy150489 * e1000_setup_led. This is a function pointer entry point called by drivers.
4585779Sxy150489 */
4595779Sxy150489 s32
e1000_cleanup_led(struct e1000_hw * hw)4605779Sxy150489 e1000_cleanup_led(struct e1000_hw *hw)
4615779Sxy150489 {
4628571SChenlu.Chen@Sun.COM if (hw->mac.ops.cleanup_led)
4638571SChenlu.Chen@Sun.COM return (hw->mac.ops.cleanup_led(hw));
4645779Sxy150489
4655779Sxy150489 return (E1000_SUCCESS);
4665779Sxy150489 }
4675779Sxy150489
4685779Sxy150489 /*
4695779Sxy150489 * e1000_blink_led - Blink SW controllable LED
4705779Sxy150489 * @hw: pointer to the HW structure
4715779Sxy150489 *
4725779Sxy150489 * This starts the adapter LED blinking. Request the LED to be setup first
4735779Sxy150489 * and cleaned up after. This is a function pointer entry point called by
4745779Sxy150489 * drivers.
4755779Sxy150489 */
4765779Sxy150489 s32
e1000_blink_led(struct e1000_hw * hw)4775779Sxy150489 e1000_blink_led(struct e1000_hw *hw)
4785779Sxy150489 {
4798571SChenlu.Chen@Sun.COM if (hw->mac.ops.blink_led)
4808571SChenlu.Chen@Sun.COM return (hw->mac.ops.blink_led(hw));
4815779Sxy150489
4825779Sxy150489 return (E1000_SUCCESS);
4835779Sxy150489 }
4845779Sxy150489
4855779Sxy150489 /*
48610319SJason.Xu@Sun.COM * e1000_id_led_init - store LED configurations in SW
48710319SJason.Xu@Sun.COM * @hw: pointer to the HW structure
48810319SJason.Xu@Sun.COM *
48910319SJason.Xu@Sun.COM * Initializes the LED config in SW. This is a function pointer entry point
49010319SJason.Xu@Sun.COM * called by drivers.
49110319SJason.Xu@Sun.COM */
49210319SJason.Xu@Sun.COM s32
e1000_id_led_init(struct e1000_hw * hw)49310319SJason.Xu@Sun.COM e1000_id_led_init(struct e1000_hw *hw)
49410319SJason.Xu@Sun.COM {
49510319SJason.Xu@Sun.COM if (hw->mac.ops.id_led_init)
49610319SJason.Xu@Sun.COM return (hw->mac.ops.id_led_init(hw));
49710319SJason.Xu@Sun.COM
49810319SJason.Xu@Sun.COM return (E1000_SUCCESS);
49910319SJason.Xu@Sun.COM }
50010319SJason.Xu@Sun.COM
50110319SJason.Xu@Sun.COM /*
5025779Sxy150489 * e1000_led_on - Turn on SW controllable LED
5035779Sxy150489 * @hw: pointer to the HW structure
5045779Sxy150489 *
5055779Sxy150489 * Turns the SW defined LED on. This is a function pointer entry point
5065779Sxy150489 * called by drivers.
5075779Sxy150489 */
5085779Sxy150489 s32
e1000_led_on(struct e1000_hw * hw)5095779Sxy150489 e1000_led_on(struct e1000_hw *hw)
5105779Sxy150489 {
5118571SChenlu.Chen@Sun.COM if (hw->mac.ops.led_on)
5128571SChenlu.Chen@Sun.COM return (hw->mac.ops.led_on(hw));
5135779Sxy150489
5145779Sxy150489 return (E1000_SUCCESS);
5155779Sxy150489 }
5165779Sxy150489
5175779Sxy150489 /*
5185779Sxy150489 * e1000_led_off - Turn off SW controllable LED
5195779Sxy150489 * @hw: pointer to the HW structure
5205779Sxy150489 *
5215779Sxy150489 * Turns the SW defined LED off. This is a function pointer entry point
5225779Sxy150489 * called by drivers.
5235779Sxy150489 */
5245779Sxy150489 s32
e1000_led_off(struct e1000_hw * hw)5255779Sxy150489 e1000_led_off(struct e1000_hw *hw)
5265779Sxy150489 {
5278571SChenlu.Chen@Sun.COM if (hw->mac.ops.led_off)
5288571SChenlu.Chen@Sun.COM return (hw->mac.ops.led_off(hw));
5295779Sxy150489
5305779Sxy150489 return (E1000_SUCCESS);
5315779Sxy150489 }
5325779Sxy150489
5335779Sxy150489 /*
5345779Sxy150489 * e1000_reset_adaptive - Reset adaptive IFS
5355779Sxy150489 * @hw: pointer to the HW structure
5365779Sxy150489 *
5375779Sxy150489 * Resets the adaptive IFS. Currently no func pointer exists and all
5385779Sxy150489 * implementations are handled in the generic version of this function.
5395779Sxy150489 */
5405779Sxy150489 void
e1000_reset_adaptive(struct e1000_hw * hw)5415779Sxy150489 e1000_reset_adaptive(struct e1000_hw *hw)
5425779Sxy150489 {
5435779Sxy150489 e1000_reset_adaptive_generic(hw);
5445779Sxy150489 }
5455779Sxy150489
5465779Sxy150489 /*
5475779Sxy150489 * e1000_update_adaptive - Update adaptive IFS
5485779Sxy150489 * @hw: pointer to the HW structure
5495779Sxy150489 *
5505779Sxy150489 * Updates adapter IFS. Currently no func pointer exists and all
5515779Sxy150489 * implementations are handled in the generic version of this function.
5525779Sxy150489 */
5535779Sxy150489 void
e1000_update_adaptive(struct e1000_hw * hw)5545779Sxy150489 e1000_update_adaptive(struct e1000_hw *hw)
5555779Sxy150489 {
5565779Sxy150489 e1000_update_adaptive_generic(hw);
5575779Sxy150489 }
5585779Sxy150489
5595779Sxy150489 /*
5605779Sxy150489 * e1000_disable_pcie_master - Disable PCI-Express master access
5615779Sxy150489 * @hw: pointer to the HW structure
5625779Sxy150489 *
5635779Sxy150489 * Disables PCI-Express master access and verifies there are no pending
5645779Sxy150489 * requests. Currently no func pointer exists and all implementations are
5655779Sxy150489 * handled in the generic version of this function.
5665779Sxy150489 */
5675779Sxy150489 s32
e1000_disable_pcie_master(struct e1000_hw * hw)5685779Sxy150489 e1000_disable_pcie_master(struct e1000_hw *hw)
5695779Sxy150489 {
5705779Sxy150489 return (e1000_disable_pcie_master_generic(hw));
5715779Sxy150489 }
5725779Sxy150489
5735779Sxy150489 /*
5745779Sxy150489 * e1000_config_collision_dist - Configure collision distance
5755779Sxy150489 * @hw: pointer to the HW structure
5765779Sxy150489 *
5775779Sxy150489 * Configures the collision distance to the default value and is used
5785779Sxy150489 * during link setup.
5795779Sxy150489 */
5805779Sxy150489 void
e1000_config_collision_dist(struct e1000_hw * hw)5815779Sxy150489 e1000_config_collision_dist(struct e1000_hw *hw)
5825779Sxy150489 {
5838571SChenlu.Chen@Sun.COM if (hw->mac.ops.config_collision_dist)
5848571SChenlu.Chen@Sun.COM hw->mac.ops.config_collision_dist(hw);
5855779Sxy150489 }
5865779Sxy150489
5875779Sxy150489 /*
5885779Sxy150489 * e1000_rar_set - Sets a receive address register
5895779Sxy150489 * @hw: pointer to the HW structure
5905779Sxy150489 * @addr: address to set the RAR to
5915779Sxy150489 * @index: the RAR to set
5925779Sxy150489 *
5935779Sxy150489 * Sets a Receive Address Register (RAR) to the specified address.
5945779Sxy150489 */
5955779Sxy150489 void
e1000_rar_set(struct e1000_hw * hw,u8 * addr,u32 index)5965779Sxy150489 e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
5975779Sxy150489 {
5988571SChenlu.Chen@Sun.COM if (hw->mac.ops.rar_set)
5998571SChenlu.Chen@Sun.COM hw->mac.ops.rar_set(hw, addr, index);
6005779Sxy150489 }
6015779Sxy150489
6025779Sxy150489 /*
6035779Sxy150489 * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
6045779Sxy150489 * @hw: pointer to the HW structure
6055779Sxy150489 *
6065779Sxy150489 * Ensures that the MDI/MDIX SW state is valid.
6075779Sxy150489 */
6085779Sxy150489 s32
e1000_validate_mdi_setting(struct e1000_hw * hw)6095779Sxy150489 e1000_validate_mdi_setting(struct e1000_hw *hw)
6105779Sxy150489 {
6118571SChenlu.Chen@Sun.COM if (hw->mac.ops.validate_mdi_setting)
6128571SChenlu.Chen@Sun.COM return (hw->mac.ops.validate_mdi_setting(hw));
6135779Sxy150489
6145779Sxy150489 return (E1000_SUCCESS);
6155779Sxy150489 }
6165779Sxy150489
6175779Sxy150489 /*
6185779Sxy150489 * e1000_mta_set - Sets multicast table bit
6195779Sxy150489 * @hw: pointer to the HW structure
6205779Sxy150489 * @hash_value: Multicast hash value.
6215779Sxy150489 *
6225779Sxy150489 * This sets the bit in the multicast table corresponding to the
6235779Sxy150489 * hash value. This is a function pointer entry point called by drivers.
6245779Sxy150489 */
6255779Sxy150489 void
e1000_mta_set(struct e1000_hw * hw,u32 hash_value)6265779Sxy150489 e1000_mta_set(struct e1000_hw *hw, u32 hash_value)
6275779Sxy150489 {
6288571SChenlu.Chen@Sun.COM if (hw->mac.ops.mta_set)
6298571SChenlu.Chen@Sun.COM hw->mac.ops.mta_set(hw, hash_value);
6305779Sxy150489 }
6315779Sxy150489
6325779Sxy150489 /*
6335779Sxy150489 * e1000_hash_mc_addr - Determines address location in multicast table
6345779Sxy150489 * @hw: pointer to the HW structure
6355779Sxy150489 * @mc_addr: Multicast address to hash.
6365779Sxy150489 *
6375779Sxy150489 * This hashes an address to determine its location in the multicast
6385779Sxy150489 * table. Currently no func pointer exists and all implementations
6395779Sxy150489 * are handled in the generic version of this function.
6405779Sxy150489 */
6415779Sxy150489 u32
e1000_hash_mc_addr(struct e1000_hw * hw,u8 * mc_addr)6425779Sxy150489 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
6435779Sxy150489 {
6445779Sxy150489 return (e1000_hash_mc_addr_generic(hw, mc_addr));
6455779Sxy150489 }
6465779Sxy150489
6475779Sxy150489 /*
6485779Sxy150489 * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
6495779Sxy150489 * @hw: pointer to the HW structure
6505779Sxy150489 *
6515779Sxy150489 * Enables packet filtering on transmit packets if manageability is enabled
6525779Sxy150489 * and host interface is enabled.
6535779Sxy150489 * Currently no func pointer exists and all implementations are handled in the
6545779Sxy150489 * generic version of this function.
6555779Sxy150489 */
6565779Sxy150489 bool
e1000_enable_tx_pkt_filtering(struct e1000_hw * hw)6575779Sxy150489 e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
6585779Sxy150489 {
6595779Sxy150489 return (e1000_enable_tx_pkt_filtering_generic(hw));
6605779Sxy150489 }
6615779Sxy150489
6625779Sxy150489 /*
6635779Sxy150489 * e1000_mng_host_if_write - Writes to the manageability host interface
6645779Sxy150489 * @hw: pointer to the HW structure
6655779Sxy150489 * @buffer: pointer to the host interface buffer
6665779Sxy150489 * @length: size of the buffer
6675779Sxy150489 * @offset: location in the buffer to write to
6685779Sxy150489 * @sum: sum of the data (not checksum)
6695779Sxy150489 *
6705779Sxy150489 * This function writes the buffer content at the offset given on the host if.
6715779Sxy150489 * It also does alignment considerations to do the writes in most efficient
6725779Sxy150489 * way. Also fills up the sum of the buffer in *buffer parameter.
6735779Sxy150489 */
6745779Sxy150489 s32
e1000_mng_host_if_write(struct e1000_hw * hw,u8 * buffer,u16 length,u16 offset,u8 * sum)6755779Sxy150489 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
6765779Sxy150489 u16 offset, u8 *sum)
6775779Sxy150489 {
6788571SChenlu.Chen@Sun.COM if (hw->mac.ops.mng_host_if_write)
6798571SChenlu.Chen@Sun.COM return (hw->mac.ops.mng_host_if_write(hw, buffer, length,
6808571SChenlu.Chen@Sun.COM offset, sum));
6815779Sxy150489
6825779Sxy150489 return (E1000_NOT_IMPLEMENTED);
6835779Sxy150489 }
6845779Sxy150489
6855779Sxy150489 /*
6865779Sxy150489 * e1000_mng_write_cmd_header - Writes manageability command header
6875779Sxy150489 * @hw: pointer to the HW structure
6885779Sxy150489 * @hdr: pointer to the host interface command header
6895779Sxy150489 *
6905779Sxy150489 * Writes the command header after does the checksum calculation.
6915779Sxy150489 */
6925779Sxy150489 s32
e1000_mng_write_cmd_header(struct e1000_hw * hw,struct e1000_host_mng_command_header * hdr)6935779Sxy150489 e1000_mng_write_cmd_header(struct e1000_hw *hw,
6945779Sxy150489 struct e1000_host_mng_command_header *hdr)
6955779Sxy150489 {
6968571SChenlu.Chen@Sun.COM if (hw->mac.ops.mng_write_cmd_header)
6978571SChenlu.Chen@Sun.COM return (hw->mac.ops.mng_write_cmd_header(hw, hdr));
6985779Sxy150489
6995779Sxy150489 return (E1000_NOT_IMPLEMENTED);
7005779Sxy150489 }
7015779Sxy150489
7025779Sxy150489 /*
7035779Sxy150489 * e1000_mng_enable_host_if - Checks host interface is enabled
7045779Sxy150489 * @hw: pointer to the HW structure
7055779Sxy150489 *
7065779Sxy150489 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
7075779Sxy150489 *
7088571SChenlu.Chen@Sun.COM * This function checks whether the HOST IF is enabled for command operation
7095779Sxy150489 * and also checks whether the previous command is completed. It busy waits
7105779Sxy150489 * in case of previous command is not completed.
7115779Sxy150489 */
7125779Sxy150489 s32
e1000_mng_enable_host_if(struct e1000_hw * hw)7135779Sxy150489 e1000_mng_enable_host_if(struct e1000_hw *hw)
7145779Sxy150489 {
7158571SChenlu.Chen@Sun.COM if (hw->mac.ops.mng_enable_host_if)
7168571SChenlu.Chen@Sun.COM return (hw->mac.ops.mng_enable_host_if(hw));
7175779Sxy150489
7185779Sxy150489 return (E1000_NOT_IMPLEMENTED);
7195779Sxy150489 }
7205779Sxy150489
7215779Sxy150489 /*
7225779Sxy150489 * e1000_wait_autoneg - Waits for autonegotiation completion
7235779Sxy150489 * @hw: pointer to the HW structure
7245779Sxy150489 *
7255779Sxy150489 * Waits for autoneg to complete. Currently no func pointer exists and all
7265779Sxy150489 * implementations are handled in the generic version of this function.
7275779Sxy150489 */
7285779Sxy150489 s32
e1000_wait_autoneg(struct e1000_hw * hw)7295779Sxy150489 e1000_wait_autoneg(struct e1000_hw *hw)
7305779Sxy150489 {
7318571SChenlu.Chen@Sun.COM if (hw->mac.ops.wait_autoneg)
7328571SChenlu.Chen@Sun.COM return (hw->mac.ops.wait_autoneg(hw));
7335779Sxy150489
7345779Sxy150489 return (E1000_SUCCESS);
7355779Sxy150489 }
7365779Sxy150489
7375779Sxy150489 /*
7385779Sxy150489 * e1000_check_reset_block - Verifies PHY can be reset
7395779Sxy150489 * @hw: pointer to the HW structure
7405779Sxy150489 *
7415779Sxy150489 * Checks if the PHY is in a state that can be reset or if manageability
7425779Sxy150489 * has it tied up. This is a function pointer entry point called by drivers.
7435779Sxy150489 */
7445779Sxy150489 s32
e1000_check_reset_block(struct e1000_hw * hw)7455779Sxy150489 e1000_check_reset_block(struct e1000_hw *hw)
7465779Sxy150489 {
7478571SChenlu.Chen@Sun.COM if (hw->phy.ops.check_reset_block)
7488571SChenlu.Chen@Sun.COM return (hw->phy.ops.check_reset_block(hw));
7495779Sxy150489
7505779Sxy150489 return (E1000_SUCCESS);
7515779Sxy150489 }
7525779Sxy150489
7535779Sxy150489 /*
7545779Sxy150489 * e1000_read_phy_reg - Reads PHY register
7555779Sxy150489 * @hw: pointer to the HW structure
7565779Sxy150489 * @offset: the register to read
7575779Sxy150489 * @data: the buffer to store the 16-bit read.
7585779Sxy150489 *
7595779Sxy150489 * Reads the PHY register and returns the value in data.
7605779Sxy150489 * This is a function pointer entry point called by drivers.
7615779Sxy150489 */
7625779Sxy150489 s32
e1000_read_phy_reg(struct e1000_hw * hw,u32 offset,u16 * data)7635779Sxy150489 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
7645779Sxy150489 {
7658571SChenlu.Chen@Sun.COM if (hw->phy.ops.read_reg)
7668571SChenlu.Chen@Sun.COM return (hw->phy.ops.read_reg(hw, offset, data));
7675779Sxy150489
7685779Sxy150489 return (E1000_SUCCESS);
7695779Sxy150489 }
7705779Sxy150489
7715779Sxy150489 /*
7725779Sxy150489 * e1000_write_phy_reg - Writes PHY register
7735779Sxy150489 * @hw: pointer to the HW structure
7745779Sxy150489 * @offset: the register to write
7755779Sxy150489 * @data: the value to write.
7765779Sxy150489 *
7775779Sxy150489 * Writes the PHY register at offset with the value in data.
7785779Sxy150489 * This is a function pointer entry point called by drivers.
7795779Sxy150489 */
7805779Sxy150489 s32
e1000_write_phy_reg(struct e1000_hw * hw,u32 offset,u16 data)7815779Sxy150489 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
7825779Sxy150489 {
7838571SChenlu.Chen@Sun.COM if (hw->phy.ops.write_reg)
7848571SChenlu.Chen@Sun.COM return (hw->phy.ops.write_reg(hw, offset, data));
7858571SChenlu.Chen@Sun.COM
7868571SChenlu.Chen@Sun.COM return (E1000_SUCCESS);
7878571SChenlu.Chen@Sun.COM }
7888571SChenlu.Chen@Sun.COM
7898571SChenlu.Chen@Sun.COM /*
7908571SChenlu.Chen@Sun.COM * e1000_release_phy - Generic release PHY
7918571SChenlu.Chen@Sun.COM * @hw: pointer to the HW structure
7928571SChenlu.Chen@Sun.COM *
7938571SChenlu.Chen@Sun.COM * Return if silicon family does not require a semaphore when accessing the
7948571SChenlu.Chen@Sun.COM * PHY.
7958571SChenlu.Chen@Sun.COM */
7968571SChenlu.Chen@Sun.COM void
e1000_release_phy(struct e1000_hw * hw)7978571SChenlu.Chen@Sun.COM e1000_release_phy(struct e1000_hw *hw)
7988571SChenlu.Chen@Sun.COM {
7998571SChenlu.Chen@Sun.COM if (hw->phy.ops.release)
8008571SChenlu.Chen@Sun.COM hw->phy.ops.release(hw);
8018571SChenlu.Chen@Sun.COM }
8028571SChenlu.Chen@Sun.COM
8038571SChenlu.Chen@Sun.COM /*
8048571SChenlu.Chen@Sun.COM * e1000_acquire_phy - Generic acquire PHY
8058571SChenlu.Chen@Sun.COM * @hw: pointer to the HW structure
8068571SChenlu.Chen@Sun.COM *
8078571SChenlu.Chen@Sun.COM * Return success if silicon family does not require a semaphore when
8088571SChenlu.Chen@Sun.COM * accessing the PHY.
8098571SChenlu.Chen@Sun.COM */
8108571SChenlu.Chen@Sun.COM s32
e1000_acquire_phy(struct e1000_hw * hw)8118571SChenlu.Chen@Sun.COM e1000_acquire_phy(struct e1000_hw *hw)
8128571SChenlu.Chen@Sun.COM {
8138571SChenlu.Chen@Sun.COM if (hw->phy.ops.acquire)
8148571SChenlu.Chen@Sun.COM return (hw->phy.ops.acquire(hw));
8155779Sxy150489
8165779Sxy150489 return (E1000_SUCCESS);
8175779Sxy150489 }
8185779Sxy150489
8195779Sxy150489 /*
8205779Sxy150489 * e1000_read_kmrn_reg - Reads register using Kumeran interface
8215779Sxy150489 * @hw: pointer to the HW structure
8225779Sxy150489 * @offset: the register to read
8235779Sxy150489 * @data: the location to store the 16-bit value read.
8245779Sxy150489 *
8255779Sxy150489 * Reads a register out of the Kumeran interface. Currently no func pointer
8265779Sxy150489 * exists and all implementations are handled in the generic version of
8275779Sxy150489 * this function.
8285779Sxy150489 */
8295779Sxy150489 s32
e1000_read_kmrn_reg(struct e1000_hw * hw,u32 offset,u16 * data)8305779Sxy150489 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
8315779Sxy150489 {
8325779Sxy150489 return (e1000_read_kmrn_reg_generic(hw, offset, data));
8335779Sxy150489 }
8345779Sxy150489
8355779Sxy150489 /*
8365779Sxy150489 * e1000_write_kmrn_reg - Writes register using Kumeran interface
8375779Sxy150489 * @hw: pointer to the HW structure
8385779Sxy150489 * @offset: the register to write
8395779Sxy150489 * @data: the value to write.
8405779Sxy150489 *
8415779Sxy150489 * Writes a register to the Kumeran interface. Currently no func pointer
8425779Sxy150489 * exists and all implementations are handled in the generic version of
8435779Sxy150489 * this function.
8445779Sxy150489 */
8455779Sxy150489 s32
e1000_write_kmrn_reg(struct e1000_hw * hw,u32 offset,u16 data)8465779Sxy150489 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
8475779Sxy150489 {
8485779Sxy150489 return (e1000_write_kmrn_reg_generic(hw, offset, data));
8495779Sxy150489 }
8505779Sxy150489
8515779Sxy150489 /*
8525779Sxy150489 * e1000_get_cable_length - Retrieves cable length estimation
8535779Sxy150489 * @hw: pointer to the HW structure
8545779Sxy150489 *
8555779Sxy150489 * This function estimates the cable length and stores them in
8565779Sxy150489 * hw->phy.min_length and hw->phy.max_length. This is a function pointer
8575779Sxy150489 * entry point called by drivers.
8585779Sxy150489 */
8595779Sxy150489 s32
e1000_get_cable_length(struct e1000_hw * hw)8605779Sxy150489 e1000_get_cable_length(struct e1000_hw *hw)
8615779Sxy150489 {
8628571SChenlu.Chen@Sun.COM if (hw->phy.ops.get_cable_length)
8638571SChenlu.Chen@Sun.COM return (hw->phy.ops.get_cable_length(hw));
8645779Sxy150489
8655779Sxy150489 return (E1000_SUCCESS);
8665779Sxy150489 }
8675779Sxy150489
8685779Sxy150489 /*
8695779Sxy150489 * e1000_get_phy_info - Retrieves PHY information from registers
8705779Sxy150489 * @hw: pointer to the HW structure
8715779Sxy150489 *
8725779Sxy150489 * This function gets some information from various PHY registers and
8735779Sxy150489 * populates hw->phy values with it. This is a function pointer entry
8745779Sxy150489 * point called by drivers.
8755779Sxy150489 */
8765779Sxy150489 s32
e1000_get_phy_info(struct e1000_hw * hw)8775779Sxy150489 e1000_get_phy_info(struct e1000_hw *hw)
8785779Sxy150489 {
8798571SChenlu.Chen@Sun.COM if (hw->phy.ops.get_info)
8808571SChenlu.Chen@Sun.COM return (hw->phy.ops.get_info(hw));
8815779Sxy150489
8825779Sxy150489 return (E1000_SUCCESS);
8835779Sxy150489 }
8845779Sxy150489
8855779Sxy150489 /*
8865779Sxy150489 * e1000_phy_hw_reset - Hard PHY reset
8875779Sxy150489 * @hw: pointer to the HW structure
8885779Sxy150489 *
8895779Sxy150489 * Performs a hard PHY reset. This is a function pointer entry point called
8905779Sxy150489 * by drivers.
8915779Sxy150489 */
8925779Sxy150489 s32
e1000_phy_hw_reset(struct e1000_hw * hw)8935779Sxy150489 e1000_phy_hw_reset(struct e1000_hw *hw)
8945779Sxy150489 {
8958571SChenlu.Chen@Sun.COM if (hw->phy.ops.reset)
8968571SChenlu.Chen@Sun.COM return (hw->phy.ops.reset(hw));
8975779Sxy150489
8985779Sxy150489 return (E1000_SUCCESS);
8995779Sxy150489 }
9005779Sxy150489
9015779Sxy150489 /*
9025779Sxy150489 * e1000_phy_commit - Soft PHY reset
9035779Sxy150489 * @hw: pointer to the HW structure
9045779Sxy150489 *
9055779Sxy150489 * Performs a soft PHY reset on those that apply. This is a function pointer
9065779Sxy150489 * entry point called by drivers.
9075779Sxy150489 */
9085779Sxy150489 s32
e1000_phy_commit(struct e1000_hw * hw)9095779Sxy150489 e1000_phy_commit(struct e1000_hw *hw)
9105779Sxy150489 {
9118571SChenlu.Chen@Sun.COM if (hw->phy.ops.commit)
9128571SChenlu.Chen@Sun.COM return (hw->phy.ops.commit(hw));
9135779Sxy150489
9145779Sxy150489 return (E1000_SUCCESS);
9155779Sxy150489 }
9165779Sxy150489
9175779Sxy150489 /*
9188571SChenlu.Chen@Sun.COM * e1000_set_d0_lplu_state - Sets low power link up state for D0
9195779Sxy150489 * @hw: pointer to the HW structure
9205779Sxy150489 * @active: boolean used to enable/disable lplu
9215779Sxy150489 *
9225779Sxy150489 * Success returns 0, Failure returns 1
9235779Sxy150489 *
9245779Sxy150489 * The low power link up (lplu) state is set to the power management level D0
9255779Sxy150489 * and SmartSpeed is disabled when active is true, else clear lplu for D0
9265779Sxy150489 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
9275779Sxy150489 * is used during Dx states where the power conservation is most important.
9285779Sxy150489 * During driver activity, SmartSpeed should be enabled so performance is
9295779Sxy150489 * maintained. This is a function pointer entry point called by drivers.
9305779Sxy150489 */
9315779Sxy150489 s32
e1000_set_d0_lplu_state(struct e1000_hw * hw,bool active)9325779Sxy150489 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
9335779Sxy150489 {
9348571SChenlu.Chen@Sun.COM if (hw->phy.ops.set_d0_lplu_state)
9358571SChenlu.Chen@Sun.COM return (hw->phy.ops.set_d0_lplu_state(hw, active));
9365779Sxy150489
9375779Sxy150489 return (E1000_SUCCESS);
9385779Sxy150489 }
9395779Sxy150489
9405779Sxy150489 /*
9415779Sxy150489 * e1000_set_d3_lplu_state - Sets low power link up state for D3
9425779Sxy150489 * @hw: pointer to the HW structure
9435779Sxy150489 * @active: boolean used to enable/disable lplu
9445779Sxy150489 *
9455779Sxy150489 * Success returns 0, Failure returns 1
9465779Sxy150489 *
9475779Sxy150489 * The low power link up (lplu) state is set to the power management level D3
9485779Sxy150489 * and SmartSpeed is disabled when active is true, else clear lplu for D3
9495779Sxy150489 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
9505779Sxy150489 * is used during Dx states where the power conservation is most important.
9515779Sxy150489 * During driver activity, SmartSpeed should be enabled so performance is
9525779Sxy150489 * maintained. This is a function pointer entry point called by drivers.
9535779Sxy150489 */
9545779Sxy150489 s32
e1000_set_d3_lplu_state(struct e1000_hw * hw,bool active)9555779Sxy150489 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
9565779Sxy150489 {
9578571SChenlu.Chen@Sun.COM if (hw->phy.ops.set_d3_lplu_state)
9588571SChenlu.Chen@Sun.COM return (hw->phy.ops.set_d3_lplu_state(hw, active));
9595779Sxy150489
9605779Sxy150489 return (E1000_SUCCESS);
9615779Sxy150489 }
9625779Sxy150489
9635779Sxy150489 /*
9645779Sxy150489 * e1000_read_mac_addr - Reads MAC address
9655779Sxy150489 * @hw: pointer to the HW structure
9665779Sxy150489 *
9675779Sxy150489 * Reads the MAC address out of the adapter and stores it in the HW structure.
9685779Sxy150489 * Currently no func pointer exists and all implementations are handled in the
9695779Sxy150489 * generic version of this function.
9705779Sxy150489 */
9715779Sxy150489 s32
e1000_read_mac_addr(struct e1000_hw * hw)9725779Sxy150489 e1000_read_mac_addr(struct e1000_hw *hw)
9735779Sxy150489 {
9748571SChenlu.Chen@Sun.COM if (hw->mac.ops.read_mac_addr)
9758571SChenlu.Chen@Sun.COM return (hw->mac.ops.read_mac_addr(hw));
9765779Sxy150489
9775779Sxy150489 return (e1000_read_mac_addr_generic(hw));
9785779Sxy150489 }
9795779Sxy150489
9805779Sxy150489 /*
9815779Sxy150489 * e1000_read_pba_num - Read device part number
9825779Sxy150489 * @hw: pointer to the HW structure
9835779Sxy150489 * @pba_num: pointer to device part number
9845779Sxy150489 *
9855779Sxy150489 * Reads the product board assembly (PBA) number from the EEPROM and stores
9865779Sxy150489 * the value in pba_num.
9875779Sxy150489 * Currently no func pointer exists and all implementations are handled in the
9885779Sxy150489 * generic version of this function.
9895779Sxy150489 */
9905779Sxy150489 s32
e1000_read_pba_num(struct e1000_hw * hw,u32 * pba_num)9915779Sxy150489 e1000_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
9925779Sxy150489 {
9935779Sxy150489 return (e1000_read_pba_num_generic(hw, pba_num));
9945779Sxy150489 }
9955779Sxy150489
9965779Sxy150489 /*
9975779Sxy150489 * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
9985779Sxy150489 * @hw: pointer to the HW structure
9995779Sxy150489 *
10005779Sxy150489 * Validates the NVM checksum is correct. This is a function pointer entry
10015779Sxy150489 * point called by drivers.
10025779Sxy150489 */
10035779Sxy150489 s32
e1000_validate_nvm_checksum(struct e1000_hw * hw)10045779Sxy150489 e1000_validate_nvm_checksum(struct e1000_hw *hw)
10055779Sxy150489 {
10068571SChenlu.Chen@Sun.COM if (hw->nvm.ops.validate)
10078571SChenlu.Chen@Sun.COM return (hw->nvm.ops.validate(hw));
10085779Sxy150489
10095779Sxy150489 return (-E1000_ERR_CONFIG);
10105779Sxy150489 }
10115779Sxy150489
10125779Sxy150489 /*
10135779Sxy150489 * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
10145779Sxy150489 * @hw: pointer to the HW structure
10155779Sxy150489 *
10165779Sxy150489 * Updates the NVM checksum. Currently no func pointer exists and all
10175779Sxy150489 * implementations are handled in the generic version of this function.
10185779Sxy150489 */
10195779Sxy150489 s32
e1000_update_nvm_checksum(struct e1000_hw * hw)10205779Sxy150489 e1000_update_nvm_checksum(struct e1000_hw *hw)
10215779Sxy150489 {
10228571SChenlu.Chen@Sun.COM if (hw->nvm.ops.update)
10238571SChenlu.Chen@Sun.COM return (hw->nvm.ops.update(hw));
10245779Sxy150489
10255779Sxy150489 return (-E1000_ERR_CONFIG);
10265779Sxy150489 }
10275779Sxy150489
10285779Sxy150489 /*
10295779Sxy150489 * e1000_reload_nvm - Reloads EEPROM
10305779Sxy150489 * @hw: pointer to the HW structure
10315779Sxy150489 *
10325779Sxy150489 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
10335779Sxy150489 * extended control register.
10345779Sxy150489 */
10355779Sxy150489 void
e1000_reload_nvm(struct e1000_hw * hw)10365779Sxy150489 e1000_reload_nvm(struct e1000_hw *hw)
10375779Sxy150489 {
10388571SChenlu.Chen@Sun.COM if (hw->nvm.ops.reload)
10398571SChenlu.Chen@Sun.COM hw->nvm.ops.reload(hw);
10405779Sxy150489 }
10415779Sxy150489
10425779Sxy150489 /*
10435779Sxy150489 * e1000_read_nvm - Reads NVM (EEPROM)
10445779Sxy150489 * @hw: pointer to the HW structure
10455779Sxy150489 * @offset: the word offset to read
10465779Sxy150489 * @words: number of 16-bit words to read
10475779Sxy150489 * @data: pointer to the properly sized buffer for the data.
10485779Sxy150489 *
10495779Sxy150489 * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
10505779Sxy150489 * pointer entry point called by drivers.
10515779Sxy150489 */
10525779Sxy150489 s32
e1000_read_nvm(struct e1000_hw * hw,u16 offset,u16 words,u16 * data)10535779Sxy150489 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
10545779Sxy150489 {
10558571SChenlu.Chen@Sun.COM if (hw->nvm.ops.read)
10568571SChenlu.Chen@Sun.COM return (hw->nvm.ops.read(hw, offset, words, data));
10575779Sxy150489
10585779Sxy150489 return (-E1000_ERR_CONFIG);
10595779Sxy150489 }
10605779Sxy150489
10615779Sxy150489 /*
10625779Sxy150489 * e1000_write_nvm - Writes to NVM (EEPROM)
10635779Sxy150489 * @hw: pointer to the HW structure
10645779Sxy150489 * @offset: the word offset to read
10655779Sxy150489 * @words: number of 16-bit words to write
10665779Sxy150489 * @data: pointer to the properly sized buffer for the data.
10675779Sxy150489 *
10685779Sxy150489 * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
10695779Sxy150489 * pointer entry point called by drivers.
10705779Sxy150489 */
10715779Sxy150489 s32
e1000_write_nvm(struct e1000_hw * hw,u16 offset,u16 words,u16 * data)10725779Sxy150489 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
10735779Sxy150489 {
10748571SChenlu.Chen@Sun.COM if (hw->nvm.ops.write)
10758571SChenlu.Chen@Sun.COM return (hw->nvm.ops.write(hw, offset, words, data));
10765779Sxy150489
10775779Sxy150489 return (E1000_SUCCESS);
10785779Sxy150489 }
10795779Sxy150489
10805779Sxy150489 /*
10815779Sxy150489 * e1000_write_8bit_ctrl_reg - Writes 8bit Control register
10825779Sxy150489 * @hw: pointer to the HW structure
10835779Sxy150489 * @reg: 32bit register offset
10845779Sxy150489 * @offset: the register to write
10855779Sxy150489 * @data: the value to write.
10865779Sxy150489 *
10875779Sxy150489 * Writes the PHY register at offset with the value in data.
10885779Sxy150489 * This is a function pointer entry point called by drivers.
10895779Sxy150489 */
10905779Sxy150489 s32
e1000_write_8bit_ctrl_reg(struct e1000_hw * hw,u32 reg,u32 offset,u8 data)10915779Sxy150489 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset, u8 data)
10925779Sxy150489 {
10935779Sxy150489 return (e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data));
10945779Sxy150489 }
10955779Sxy150489
10965779Sxy150489 /*
10975779Sxy150489 * e1000_power_up_phy - Restores link in case of PHY power down
10985779Sxy150489 * @hw: pointer to the HW structure
10995779Sxy150489 *
11005779Sxy150489 * The phy may be powered down to save power, to turn off link when the
11015779Sxy150489 * driver is unloaded, or wake on lan is not enabled (among others).
11025779Sxy150489 */
11035779Sxy150489 void
e1000_power_up_phy(struct e1000_hw * hw)11045779Sxy150489 e1000_power_up_phy(struct e1000_hw *hw)
11055779Sxy150489 {
11068571SChenlu.Chen@Sun.COM if (hw->phy.ops.power_up)
11078571SChenlu.Chen@Sun.COM hw->phy.ops.power_up(hw);
11085779Sxy150489
11095779Sxy150489 (void) e1000_setup_link(hw);
11105779Sxy150489 }
11115779Sxy150489
11125779Sxy150489 /*
11135779Sxy150489 * e1000_power_down_phy - Power down PHY
11145779Sxy150489 * @hw: pointer to the HW structure
11155779Sxy150489 *
11165779Sxy150489 * The phy may be powered down to save power, to turn off link when the
11175779Sxy150489 * driver is unloaded, or wake on lan is not enabled (among others).
11185779Sxy150489 */
11195779Sxy150489 void
e1000_power_down_phy(struct e1000_hw * hw)11205779Sxy150489 e1000_power_down_phy(struct e1000_hw *hw)
11215779Sxy150489 {
11228571SChenlu.Chen@Sun.COM if (hw->phy.ops.power_down)
11238571SChenlu.Chen@Sun.COM hw->phy.ops.power_down(hw);
11245779Sxy150489 }
11258571SChenlu.Chen@Sun.COM
11268571SChenlu.Chen@Sun.COM /*
11278571SChenlu.Chen@Sun.COM * e1000_shutdown_fiber_serdes_link - Remove link during power down
11288571SChenlu.Chen@Sun.COM * @hw: pointer to the HW structure
11298571SChenlu.Chen@Sun.COM *
11308571SChenlu.Chen@Sun.COM * Shutdown the optics and PCS on driver unload.
11318571SChenlu.Chen@Sun.COM */
11328571SChenlu.Chen@Sun.COM void
e1000_shutdown_fiber_serdes_link(struct e1000_hw * hw)11338571SChenlu.Chen@Sun.COM e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
11348571SChenlu.Chen@Sun.COM {
11358571SChenlu.Chen@Sun.COM if (hw->mac.ops.shutdown_serdes)
11368571SChenlu.Chen@Sun.COM hw->mac.ops.shutdown_serdes(hw);
11378571SChenlu.Chen@Sun.COM }
1138