14919Sxy150489 /*
24919Sxy150489 * This file is provided under a CDDLv1 license. When using or
34919Sxy150489 * redistributing this file, you may do so under this license.
44919Sxy150489 * In redistributing this file this license must be included
54919Sxy150489 * and no other modification of this header file is permitted.
64919Sxy150489 *
74919Sxy150489 * CDDL LICENSE SUMMARY
84919Sxy150489 *
98479SChenlu.Chen@Sun.COM * Copyright(c) 1999 - 2009 Intel Corporation. All rights reserved.
104919Sxy150489 *
114919Sxy150489 * The contents of this file are subject to the terms of Version
124919Sxy150489 * 1.0 of the Common Development and Distribution License (the "License").
134919Sxy150489 *
144919Sxy150489 * You should have received a copy of the License with this software.
154919Sxy150489 * You can obtain a copy of the License at
164919Sxy150489 * http://www.opensolaris.org/os/licensing.
174919Sxy150489 * See the License for the specific language governing permissions
184919Sxy150489 * and limitations under the License.
194919Sxy150489 */
204919Sxy150489
214919Sxy150489 /*
228479SChenlu.Chen@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
234919Sxy150489 * Use is subject to license terms of the CDDLv1.
244919Sxy150489 */
254919Sxy150489
264919Sxy150489 /*
27*11020SMin.Xu@Sun.COM * IntelVersion: 1.125 v3-1-10-1_2009-9-18_Release14-6
284919Sxy150489 */
296735Scc210113
304919Sxy150489 #include "e1000_api.h"
314919Sxy150489
324919Sxy150489 /*
334919Sxy150489 * e1000_init_mac_params - Initialize MAC function pointers
344919Sxy150489 * @hw: pointer to the HW structure
354919Sxy150489 *
364919Sxy150489 * This function initializes the function pointers for the MAC
374919Sxy150489 * set of functions. Called by drivers or by e1000_setup_init_funcs.
384919Sxy150489 */
394919Sxy150489 s32
e1000_init_mac_params(struct e1000_hw * hw)404919Sxy150489 e1000_init_mac_params(struct e1000_hw *hw)
414919Sxy150489 {
424919Sxy150489 s32 ret_val = E1000_SUCCESS;
434919Sxy150489
446735Scc210113 if (hw->mac.ops.init_params) {
456735Scc210113 ret_val = hw->mac.ops.init_params(hw);
464919Sxy150489 if (ret_val) {
474919Sxy150489 DEBUGOUT("MAC Initialization Error\n");
484919Sxy150489 goto out;
494919Sxy150489 }
504919Sxy150489 } else {
514919Sxy150489 DEBUGOUT("mac.init_mac_params was NULL\n");
524919Sxy150489 ret_val = -E1000_ERR_CONFIG;
534919Sxy150489 }
544919Sxy150489
554919Sxy150489 out:
564919Sxy150489 return (ret_val);
574919Sxy150489 }
584919Sxy150489
594919Sxy150489 /*
604919Sxy150489 * e1000_init_nvm_params - Initialize NVM function pointers
614919Sxy150489 * @hw: pointer to the HW structure
624919Sxy150489 *
634919Sxy150489 * This function initializes the function pointers for the NVM
644919Sxy150489 * set of functions. Called by drivers or by e1000_setup_init_funcs.
654919Sxy150489 */
664919Sxy150489 s32
e1000_init_nvm_params(struct e1000_hw * hw)674919Sxy150489 e1000_init_nvm_params(struct e1000_hw *hw)
684919Sxy150489 {
694919Sxy150489 s32 ret_val = E1000_SUCCESS;
704919Sxy150489
716735Scc210113 if (hw->nvm.ops.init_params) {
726735Scc210113 ret_val = hw->nvm.ops.init_params(hw);
734919Sxy150489 if (ret_val) {
744919Sxy150489 DEBUGOUT("NVM Initialization Error\n");
754919Sxy150489 goto out;
764919Sxy150489 }
774919Sxy150489 } else {
784919Sxy150489 DEBUGOUT("nvm.init_nvm_params was NULL\n");
794919Sxy150489 ret_val = -E1000_ERR_CONFIG;
804919Sxy150489 }
814919Sxy150489
824919Sxy150489 out:
834919Sxy150489 return (ret_val);
844919Sxy150489 }
854919Sxy150489
864919Sxy150489 /*
874919Sxy150489 * e1000_init_phy_params - Initialize PHY function pointers
884919Sxy150489 * @hw: pointer to the HW structure
894919Sxy150489 *
904919Sxy150489 * This function initializes the function pointers for the PHY
914919Sxy150489 * set of functions. Called by drivers or by e1000_setup_init_funcs.
924919Sxy150489 */
934919Sxy150489 s32
e1000_init_phy_params(struct e1000_hw * hw)944919Sxy150489 e1000_init_phy_params(struct e1000_hw *hw)
954919Sxy150489 {
964919Sxy150489 s32 ret_val = E1000_SUCCESS;
974919Sxy150489
986735Scc210113 if (hw->phy.ops.init_params) {
996735Scc210113 ret_val = hw->phy.ops.init_params(hw);
1004919Sxy150489 if (ret_val) {
1014919Sxy150489 DEBUGOUT("PHY Initialization Error\n");
1024919Sxy150489 goto out;
1034919Sxy150489 }
1044919Sxy150489 } else {
1054919Sxy150489 DEBUGOUT("phy.init_phy_params was NULL\n");
1064919Sxy150489 ret_val = -E1000_ERR_CONFIG;
1074919Sxy150489 }
1084919Sxy150489
1094919Sxy150489 out:
1104919Sxy150489 return (ret_val);
1114919Sxy150489 }
1124919Sxy150489
1134919Sxy150489 /*
1144919Sxy150489 * e1000_set_mac_type - Sets MAC type
1154919Sxy150489 * @hw: pointer to the HW structure
1164919Sxy150489 *
1174919Sxy150489 * This function sets the mac type of the adapter based on the
1184919Sxy150489 * device ID stored in the hw structure.
1194919Sxy150489 * MUST BE FIRST FUNCTION CALLED (explicitly or through
1204919Sxy150489 * e1000_setup_init_funcs()).
1214919Sxy150489 */
1224919Sxy150489 s32
e1000_set_mac_type(struct e1000_hw * hw)1234919Sxy150489 e1000_set_mac_type(struct e1000_hw *hw)
1244919Sxy150489 {
1254919Sxy150489 struct e1000_mac_info *mac = &hw->mac;
1264919Sxy150489 s32 ret_val = E1000_SUCCESS;
1274919Sxy150489
1284919Sxy150489 DEBUGFUNC("e1000_set_mac_type");
1294919Sxy150489
1304919Sxy150489 switch (hw->device_id) {
1314919Sxy150489 case E1000_DEV_ID_82542:
1324919Sxy150489 mac->type = e1000_82542;
1334919Sxy150489 break;
1344919Sxy150489 case E1000_DEV_ID_82543GC_FIBER:
1354919Sxy150489 case E1000_DEV_ID_82543GC_COPPER:
1364919Sxy150489 mac->type = e1000_82543;
1374919Sxy150489 break;
1384919Sxy150489 case E1000_DEV_ID_82544EI_COPPER:
1394919Sxy150489 case E1000_DEV_ID_82544EI_FIBER:
1404919Sxy150489 case E1000_DEV_ID_82544GC_COPPER:
1414919Sxy150489 case E1000_DEV_ID_82544GC_LOM:
1424919Sxy150489 mac->type = e1000_82544;
1434919Sxy150489 break;
1444919Sxy150489 case E1000_DEV_ID_82540EM:
1454919Sxy150489 case E1000_DEV_ID_82540EM_LOM:
1464919Sxy150489 case E1000_DEV_ID_82540EP:
1474919Sxy150489 case E1000_DEV_ID_82540EP_LOM:
1484919Sxy150489 case E1000_DEV_ID_82540EP_LP:
1494919Sxy150489 mac->type = e1000_82540;
1504919Sxy150489 break;
1514919Sxy150489 case E1000_DEV_ID_82545EM_COPPER:
1524919Sxy150489 case E1000_DEV_ID_82545EM_FIBER:
1534919Sxy150489 mac->type = e1000_82545;
1544919Sxy150489 break;
1554919Sxy150489 case E1000_DEV_ID_82545GM_COPPER:
1564919Sxy150489 case E1000_DEV_ID_82545GM_FIBER:
1574919Sxy150489 case E1000_DEV_ID_82545GM_SERDES:
1584919Sxy150489 mac->type = e1000_82545_rev_3;
1594919Sxy150489 break;
1604919Sxy150489 case E1000_DEV_ID_82546EB_COPPER:
1614919Sxy150489 case E1000_DEV_ID_82546EB_FIBER:
1624919Sxy150489 case E1000_DEV_ID_82546EB_QUAD_COPPER:
1634919Sxy150489 mac->type = e1000_82546;
1644919Sxy150489 break;
1654919Sxy150489 case E1000_DEV_ID_82546GB_COPPER:
1664919Sxy150489 case E1000_DEV_ID_82546GB_FIBER:
1674919Sxy150489 case E1000_DEV_ID_82546GB_SERDES:
1684919Sxy150489 case E1000_DEV_ID_82546GB_PCIE:
1694919Sxy150489 case E1000_DEV_ID_82546GB_QUAD_COPPER:
1704919Sxy150489 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
1714919Sxy150489 mac->type = e1000_82546_rev_3;
1724919Sxy150489 break;
1734919Sxy150489 case E1000_DEV_ID_82541EI:
1744919Sxy150489 case E1000_DEV_ID_82541EI_MOBILE:
1754919Sxy150489 case E1000_DEV_ID_82541ER_LOM:
1764919Sxy150489 mac->type = e1000_82541;
1774919Sxy150489 break;
1784919Sxy150489 case E1000_DEV_ID_82541ER:
1794919Sxy150489 case E1000_DEV_ID_82541GI:
1804919Sxy150489 case E1000_DEV_ID_82541GI_LF:
1814919Sxy150489 case E1000_DEV_ID_82541GI_MOBILE:
1824919Sxy150489 mac->type = e1000_82541_rev_2;
1834919Sxy150489 break;
1844919Sxy150489 case E1000_DEV_ID_82547EI:
1854919Sxy150489 case E1000_DEV_ID_82547EI_MOBILE:
1864919Sxy150489 mac->type = e1000_82547;
1874919Sxy150489 break;
1884919Sxy150489 case E1000_DEV_ID_82547GI:
1894919Sxy150489 mac->type = e1000_82547_rev_2;
1904919Sxy150489 break;
1914919Sxy150489 case E1000_DEV_ID_82571EB_COPPER:
1924919Sxy150489 case E1000_DEV_ID_82571EB_FIBER:
1934919Sxy150489 case E1000_DEV_ID_82571EB_SERDES:
1944919Sxy150489 case E1000_DEV_ID_82571EB_SERDES_DUAL:
1954919Sxy150489 case E1000_DEV_ID_82571EB_SERDES_QUAD:
1964919Sxy150489 case E1000_DEV_ID_82571EB_QUAD_COPPER:
1974919Sxy150489 case E1000_DEV_ID_82571PT_QUAD_COPPER:
1984919Sxy150489 case E1000_DEV_ID_82571EB_QUAD_FIBER:
1994919Sxy150489 case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
2004919Sxy150489 mac->type = e1000_82571;
2014919Sxy150489 break;
2024919Sxy150489 case E1000_DEV_ID_82572EI:
2034919Sxy150489 case E1000_DEV_ID_82572EI_COPPER:
2044919Sxy150489 case E1000_DEV_ID_82572EI_FIBER:
2054919Sxy150489 case E1000_DEV_ID_82572EI_SERDES:
2064919Sxy150489 mac->type = e1000_82572;
2074919Sxy150489 break;
2084919Sxy150489 case E1000_DEV_ID_82573E:
2094919Sxy150489 case E1000_DEV_ID_82573E_IAMT:
2104919Sxy150489 case E1000_DEV_ID_82573L:
2114919Sxy150489 mac->type = e1000_82573;
2124919Sxy150489 break;
2137607STed.You@Sun.COM case E1000_DEV_ID_82574L:
21410680SMin.Xu@Sun.COM case E1000_DEV_ID_82574LA:
2157607STed.You@Sun.COM mac->type = e1000_82574;
2167607STed.You@Sun.COM break;
21710680SMin.Xu@Sun.COM case E1000_DEV_ID_82583V:
21810680SMin.Xu@Sun.COM mac->type = e1000_82583;
21910680SMin.Xu@Sun.COM break;
2204919Sxy150489 case E1000_DEV_ID_80003ES2LAN_COPPER_DPT:
2214919Sxy150489 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
2224919Sxy150489 case E1000_DEV_ID_80003ES2LAN_COPPER_SPT:
2234919Sxy150489 case E1000_DEV_ID_80003ES2LAN_SERDES_SPT:
2244919Sxy150489 mac->type = e1000_80003es2lan;
2254919Sxy150489 break;
2264919Sxy150489 case E1000_DEV_ID_ICH8_IFE:
2274919Sxy150489 case E1000_DEV_ID_ICH8_IFE_GT:
2284919Sxy150489 case E1000_DEV_ID_ICH8_IFE_G:
2294919Sxy150489 case E1000_DEV_ID_ICH8_IGP_M:
2304919Sxy150489 case E1000_DEV_ID_ICH8_IGP_M_AMT:
2314919Sxy150489 case E1000_DEV_ID_ICH8_IGP_AMT:
2324919Sxy150489 case E1000_DEV_ID_ICH8_IGP_C:
2334919Sxy150489 mac->type = e1000_ich8lan;
2344919Sxy150489 break;
2354919Sxy150489 case E1000_DEV_ID_ICH9_IFE:
2364919Sxy150489 case E1000_DEV_ID_ICH9_IFE_GT:
2374919Sxy150489 case E1000_DEV_ID_ICH9_IFE_G:
2385948Sml40262 case E1000_DEV_ID_ICH9_IGP_M:
2395948Sml40262 case E1000_DEV_ID_ICH9_IGP_M_AMT:
2406735Scc210113 case E1000_DEV_ID_ICH9_IGP_M_V:
2416735Scc210113 case E1000_DEV_ID_ICH9_IGP_AMT:
2426735Scc210113 case E1000_DEV_ID_ICH9_BM:
2434919Sxy150489 case E1000_DEV_ID_ICH9_IGP_C:
2447607STed.You@Sun.COM case E1000_DEV_ID_ICH10_R_BM_LM:
2457607STed.You@Sun.COM case E1000_DEV_ID_ICH10_R_BM_LF:
2467607STed.You@Sun.COM case E1000_DEV_ID_ICH10_R_BM_V:
2474919Sxy150489 mac->type = e1000_ich9lan;
2484919Sxy150489 break;
2497607STed.You@Sun.COM case E1000_DEV_ID_ICH10_D_BM_LM:
2507607STed.You@Sun.COM case E1000_DEV_ID_ICH10_D_BM_LF:
25110680SMin.Xu@Sun.COM case E1000_DEV_ID_ICH10_HANKSVILLE:
2527607STed.You@Sun.COM mac->type = e1000_ich10lan;
2537607STed.You@Sun.COM break;
25410680SMin.Xu@Sun.COM case E1000_DEV_ID_PCH_D_HV_DM:
25510680SMin.Xu@Sun.COM case E1000_DEV_ID_PCH_D_HV_DC:
25610680SMin.Xu@Sun.COM case E1000_DEV_ID_PCH_M_HV_LM:
25710680SMin.Xu@Sun.COM case E1000_DEV_ID_PCH_M_HV_LC:
25810680SMin.Xu@Sun.COM mac->type = e1000_pchlan;
25910680SMin.Xu@Sun.COM break;
2604919Sxy150489 default:
2614919Sxy150489 /* Should never have loaded on this device */
2624919Sxy150489 ret_val = -E1000_ERR_MAC_INIT;
2634919Sxy150489 break;
2644919Sxy150489 }
2654919Sxy150489
2664919Sxy150489 return (ret_val);
2674919Sxy150489 }
2684919Sxy150489
2694919Sxy150489 /*
2704919Sxy150489 * e1000_setup_init_funcs - Initializes function pointers
2714919Sxy150489 * @hw: pointer to the HW structure
2727607STed.You@Sun.COM * @init_device: true will initialize the rest of the function pointers
2737607STed.You@Sun.COM * getting the device ready for use. false will only set
2744919Sxy150489 * MAC type and the function pointers for the other init
2757607STed.You@Sun.COM * functions. Passing false will not generate any hardware
2764919Sxy150489 * reads or writes.
2774919Sxy150489 *
2784919Sxy150489 * This function must be called by a driver in order to use the rest
2794919Sxy150489 * of the 'shared' code files. Called by drivers only.
2804919Sxy150489 */
2814919Sxy150489 s32
e1000_setup_init_funcs(struct e1000_hw * hw,bool init_device)2826735Scc210113 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
2834919Sxy150489 {
2844919Sxy150489 s32 ret_val;
2854919Sxy150489
2864919Sxy150489 /* Can't do much good without knowing the MAC type. */
2874919Sxy150489 ret_val = e1000_set_mac_type(hw);
2884919Sxy150489 if (ret_val) {
2894919Sxy150489 DEBUGOUT("ERROR: MAC type could not be set properly.\n");
2904919Sxy150489 goto out;
2914919Sxy150489 }
29210680SMin.Xu@Sun.COM
2934919Sxy150489 if (!hw->hw_addr) {
2944919Sxy150489 DEBUGOUT("ERROR: Registers not mapped\n");
2954919Sxy150489 ret_val = -E1000_ERR_CONFIG;
2964919Sxy150489 goto out;
2974919Sxy150489 }
2984919Sxy150489
2994919Sxy150489 /*
3006735Scc210113 * Init function pointers to generic implementations. We do this first
3016735Scc210113 * allowing a driver module to override it afterward.
3024919Sxy150489 */
3036735Scc210113 e1000_init_mac_ops_generic(hw);
3046735Scc210113 e1000_init_phy_ops_generic(hw);
3056735Scc210113 e1000_init_nvm_ops_generic(hw);
3064919Sxy150489
3074919Sxy150489 /*
3084919Sxy150489 * Set up the init function pointers. These are functions within the
3094919Sxy150489 * adapter family file that sets up function pointers for the rest of
3104919Sxy150489 * the functions in that family.
3114919Sxy150489 */
3124919Sxy150489 switch (hw->mac.type) {
3134919Sxy150489 case e1000_82542:
3144919Sxy150489 e1000_init_function_pointers_82542(hw);
3154919Sxy150489 break;
3164919Sxy150489 case e1000_82543:
3174919Sxy150489 case e1000_82544:
3184919Sxy150489 e1000_init_function_pointers_82543(hw);
3194919Sxy150489 break;
3204919Sxy150489 case e1000_82540:
3214919Sxy150489 case e1000_82545:
3224919Sxy150489 case e1000_82545_rev_3:
3234919Sxy150489 case e1000_82546:
3244919Sxy150489 case e1000_82546_rev_3:
3254919Sxy150489 e1000_init_function_pointers_82540(hw);
3264919Sxy150489 break;
3274919Sxy150489 case e1000_82541:
3284919Sxy150489 case e1000_82541_rev_2:
3294919Sxy150489 case e1000_82547:
3304919Sxy150489 case e1000_82547_rev_2:
3314919Sxy150489 e1000_init_function_pointers_82541(hw);
3324919Sxy150489 break;
3334919Sxy150489 case e1000_82571:
3344919Sxy150489 case e1000_82572:
3354919Sxy150489 case e1000_82573:
3367607STed.You@Sun.COM case e1000_82574:
33710680SMin.Xu@Sun.COM case e1000_82583:
3384919Sxy150489 e1000_init_function_pointers_82571(hw);
3394919Sxy150489 break;
3404919Sxy150489 case e1000_80003es2lan:
3414919Sxy150489 e1000_init_function_pointers_80003es2lan(hw);
3424919Sxy150489 break;
3434919Sxy150489 case e1000_ich8lan:
3444919Sxy150489 case e1000_ich9lan:
3457607STed.You@Sun.COM case e1000_ich10lan:
34610680SMin.Xu@Sun.COM case e1000_pchlan:
3474919Sxy150489 e1000_init_function_pointers_ich8lan(hw);
3484919Sxy150489 break;
3494919Sxy150489 default:
3504919Sxy150489 DEBUGOUT("Hardware not supported\n");
3514919Sxy150489 ret_val = -E1000_ERR_CONFIG;
3524919Sxy150489 break;
3534919Sxy150489 }
3544919Sxy150489
3554919Sxy150489 /*
3564919Sxy150489 * Initialize the rest of the function pointers. These require some
3574919Sxy150489 * register reads/writes in some cases.
3584919Sxy150489 */
3594919Sxy150489 if (!(ret_val) && init_device) {
3604919Sxy150489 ret_val = e1000_init_mac_params(hw);
3614919Sxy150489 if (ret_val)
3624919Sxy150489 goto out;
3634919Sxy150489
3644919Sxy150489 ret_val = e1000_init_nvm_params(hw);
3654919Sxy150489 if (ret_val)
3664919Sxy150489 goto out;
3674919Sxy150489
3684919Sxy150489 ret_val = e1000_init_phy_params(hw);
3694919Sxy150489 if (ret_val)
3704919Sxy150489 goto out;
3714919Sxy150489 }
3724919Sxy150489
3734919Sxy150489 out:
3744919Sxy150489 return (ret_val);
3754919Sxy150489 }
3764919Sxy150489
3774919Sxy150489 /*
3784919Sxy150489 * e1000_get_bus_info - Obtain bus information for adapter
3794919Sxy150489 * @hw: pointer to the HW structure
3804919Sxy150489 *
3814919Sxy150489 * This will obtain information about the HW bus for which the
3826735Scc210113 * adapter is attached and stores it in the hw structure. This is a
3834919Sxy150489 * function pointer entry point called by drivers.
3844919Sxy150489 */
3854919Sxy150489 s32
e1000_get_bus_info(struct e1000_hw * hw)3864919Sxy150489 e1000_get_bus_info(struct e1000_hw *hw)
3874919Sxy150489 {
3886735Scc210113 if (hw->mac.ops.get_bus_info)
3896735Scc210113 return (hw->mac.ops.get_bus_info(hw));
3904919Sxy150489
3914919Sxy150489 return (E1000_SUCCESS);
3924919Sxy150489 }
3934919Sxy150489
3944919Sxy150489 /*
3954919Sxy150489 * e1000_clear_vfta - Clear VLAN filter table
3964919Sxy150489 * @hw: pointer to the HW structure
3974919Sxy150489 *
3984919Sxy150489 * This clears the VLAN filter table on the adapter. This is a function
3994919Sxy150489 * pointer entry point called by drivers.
4004919Sxy150489 */
4014919Sxy150489 void
e1000_clear_vfta(struct e1000_hw * hw)4024919Sxy150489 e1000_clear_vfta(struct e1000_hw *hw)
4034919Sxy150489 {
4046735Scc210113 if (hw->mac.ops.clear_vfta)
4056735Scc210113 hw->mac.ops.clear_vfta(hw);
4064919Sxy150489 }
4074919Sxy150489
4084919Sxy150489 /*
4094919Sxy150489 * e1000_write_vfta - Write value to VLAN filter table
4104919Sxy150489 * @hw: pointer to the HW structure
4114919Sxy150489 * @offset: the 32-bit offset in which to write the value to.
4124919Sxy150489 * @value: the 32-bit value to write at location offset.
4134919Sxy150489 *
4144919Sxy150489 * This writes a 32-bit value to a 32-bit offset in the VLAN filter
4154919Sxy150489 * table. This is a function pointer entry point called by drivers.
4164919Sxy150489 */
4174919Sxy150489 void
e1000_write_vfta(struct e1000_hw * hw,u32 offset,u32 value)4184919Sxy150489 e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
4194919Sxy150489 {
4206735Scc210113 if (hw->mac.ops.write_vfta)
4216735Scc210113 hw->mac.ops.write_vfta(hw, offset, value);
4224919Sxy150489 }
4234919Sxy150489
4244919Sxy150489 /*
4256735Scc210113 * e1000_update_mc_addr_list - Update Multicast addresses
4264919Sxy150489 * @hw: pointer to the HW structure
4274919Sxy150489 * @mc_addr_list: array of multicast addresses to program
4284919Sxy150489 * @mc_addr_count: number of multicast addresses to program
4294919Sxy150489 *
43010680SMin.Xu@Sun.COM * Updates the Multicast Table Array.
4314919Sxy150489 * The caller must have a packed mc_addr_list of multicast addresses.
4324919Sxy150489 */
4334919Sxy150489 void
e1000_update_mc_addr_list(struct e1000_hw * hw,u8 * mc_addr_list,u32 mc_addr_count)4346735Scc210113 e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
43510680SMin.Xu@Sun.COM u32 mc_addr_count)
4364919Sxy150489 {
4376735Scc210113 if (hw->mac.ops.update_mc_addr_list)
43810680SMin.Xu@Sun.COM hw->mac.ops.update_mc_addr_list(hw, mc_addr_list,
43910680SMin.Xu@Sun.COM mc_addr_count);
4404919Sxy150489 }
4414919Sxy150489
4424919Sxy150489 /*
4434919Sxy150489 * e1000_force_mac_fc - Force MAC flow control
4444919Sxy150489 * @hw: pointer to the HW structure
4454919Sxy150489 *
4464919Sxy150489 * Force the MAC's flow control settings. Currently no func pointer exists
4474919Sxy150489 * and all implementations are handled in the generic version of this
4484919Sxy150489 * function.
4494919Sxy150489 */
4504919Sxy150489 s32
e1000_force_mac_fc(struct e1000_hw * hw)4514919Sxy150489 e1000_force_mac_fc(struct e1000_hw *hw)
4524919Sxy150489 {
4534919Sxy150489 return (e1000_force_mac_fc_generic(hw));
4544919Sxy150489 }
4554919Sxy150489
4564919Sxy150489 /*
4574919Sxy150489 * e1000_check_for_link - Check/Store link connection
4584919Sxy150489 * @hw: pointer to the HW structure
4594919Sxy150489 *
4604919Sxy150489 * This checks the link condition of the adapter and stores the
4614919Sxy150489 * results in the hw->mac structure. This is a function pointer entry
4624919Sxy150489 * point called by drivers.
4634919Sxy150489 */
4644919Sxy150489 s32
e1000_check_for_link(struct e1000_hw * hw)4654919Sxy150489 e1000_check_for_link(struct e1000_hw *hw)
4664919Sxy150489 {
4676735Scc210113 if (hw->mac.ops.check_for_link)
4686735Scc210113 return (hw->mac.ops.check_for_link(hw));
4694919Sxy150489
4704919Sxy150489 return (-E1000_ERR_CONFIG);
4714919Sxy150489 }
4724919Sxy150489
4734919Sxy150489 /*
4744919Sxy150489 * e1000_check_mng_mode - Check management mode
4754919Sxy150489 * @hw: pointer to the HW structure
4764919Sxy150489 *
4774919Sxy150489 * This checks if the adapter has manageability enabled.
4784919Sxy150489 * This is a function pointer entry point called by drivers.
4794919Sxy150489 */
4806735Scc210113 bool
e1000_check_mng_mode(struct e1000_hw * hw)4814919Sxy150489 e1000_check_mng_mode(struct e1000_hw *hw)
4824919Sxy150489 {
4836735Scc210113 if (hw->mac.ops.check_mng_mode)
4846735Scc210113 return (hw->mac.ops.check_mng_mode(hw));
4854919Sxy150489
4867607STed.You@Sun.COM return (false);
4874919Sxy150489 }
4884919Sxy150489
4894919Sxy150489 /*
4904919Sxy150489 * e1000_mng_write_dhcp_info - Writes DHCP info to host interface
4914919Sxy150489 * @hw: pointer to the HW structure
4924919Sxy150489 * @buffer: pointer to the host interface
4934919Sxy150489 * @length: size of the buffer
4944919Sxy150489 *
4954919Sxy150489 * Writes the DHCP information to the host interface.
4964919Sxy150489 */
4974919Sxy150489 s32
e1000_mng_write_dhcp_info(struct e1000_hw * hw,u8 * buffer,u16 length)4986735Scc210113 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
4994919Sxy150489 {
5004919Sxy150489 return (e1000_mng_write_dhcp_info_generic(hw, buffer, length));
5014919Sxy150489 }
5024919Sxy150489
5034919Sxy150489 /*
5044919Sxy150489 * e1000_reset_hw - Reset hardware
5054919Sxy150489 * @hw: pointer to the HW structure
5064919Sxy150489 *
5074919Sxy150489 * This resets the hardware into a known state. This is a function pointer
5084919Sxy150489 * entry point called by drivers.
5094919Sxy150489 */
5104919Sxy150489 s32
e1000_reset_hw(struct e1000_hw * hw)5114919Sxy150489 e1000_reset_hw(struct e1000_hw *hw)
5124919Sxy150489 {
5136735Scc210113 if (hw->mac.ops.reset_hw)
5146735Scc210113 return (hw->mac.ops.reset_hw(hw));
5154919Sxy150489
5164919Sxy150489 return (-E1000_ERR_CONFIG);
5174919Sxy150489 }
5184919Sxy150489
5194919Sxy150489 /*
5204919Sxy150489 * e1000_init_hw - Initialize hardware
5214919Sxy150489 * @hw: pointer to the HW structure
5224919Sxy150489 *
5234919Sxy150489 * This inits the hardware readying it for operation. This is a function
5244919Sxy150489 * pointer entry point called by drivers.
5254919Sxy150489 */
5264919Sxy150489 s32
e1000_init_hw(struct e1000_hw * hw)5274919Sxy150489 e1000_init_hw(struct e1000_hw *hw)
5284919Sxy150489 {
5296735Scc210113 if (hw->mac.ops.init_hw)
5306735Scc210113 return (hw->mac.ops.init_hw(hw));
5314919Sxy150489
5324919Sxy150489 return (-E1000_ERR_CONFIG);
5334919Sxy150489 }
5344919Sxy150489
5354919Sxy150489 /*
5364919Sxy150489 * e1000_setup_link - Configures link and flow control
5374919Sxy150489 * @hw: pointer to the HW structure
5384919Sxy150489 *
5394919Sxy150489 * This configures link and flow control settings for the adapter. This
5404919Sxy150489 * is a function pointer entry point called by drivers. While modules can
5414919Sxy150489 * also call this, they probably call their own version of this function.
5424919Sxy150489 */
5434919Sxy150489 s32
e1000_setup_link(struct e1000_hw * hw)5444919Sxy150489 e1000_setup_link(struct e1000_hw *hw)
5454919Sxy150489 {
5466735Scc210113 if (hw->mac.ops.setup_link)
5476735Scc210113 return (hw->mac.ops.setup_link(hw));
5484919Sxy150489
5494919Sxy150489 return (-E1000_ERR_CONFIG);
5504919Sxy150489 }
5514919Sxy150489
5524919Sxy150489 /*
5534919Sxy150489 * e1000_get_speed_and_duplex - Returns current speed and duplex
5544919Sxy150489 * @hw: pointer to the HW structure
5554919Sxy150489 * @speed: pointer to a 16-bit value to store the speed
5564919Sxy150489 * @duplex: pointer to a 16-bit value to store the duplex.
5574919Sxy150489 *
5584919Sxy150489 * This returns the speed and duplex of the adapter in the two 'out'
5594919Sxy150489 * variables passed in. This is a function pointer entry point called
5604919Sxy150489 * by drivers.
5614919Sxy150489 */
5624919Sxy150489 s32
e1000_get_speed_and_duplex(struct e1000_hw * hw,u16 * speed,u16 * duplex)5636735Scc210113 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
5644919Sxy150489 {
5656735Scc210113 if (hw->mac.ops.get_link_up_info)
5666735Scc210113 return (hw->mac.ops.get_link_up_info(hw, speed, duplex));
5674919Sxy150489
5684919Sxy150489 return (-E1000_ERR_CONFIG);
5694919Sxy150489 }
5704919Sxy150489
5714919Sxy150489 /*
5724919Sxy150489 * e1000_setup_led - Configures SW controllable LED
5734919Sxy150489 * @hw: pointer to the HW structure
5744919Sxy150489 *
5754919Sxy150489 * This prepares the SW controllable LED for use and saves the current state
5764919Sxy150489 * of the LED so it can be later restored. This is a function pointer entry
5774919Sxy150489 * point called by drivers.
5784919Sxy150489 */
5794919Sxy150489 s32
e1000_setup_led(struct e1000_hw * hw)5804919Sxy150489 e1000_setup_led(struct e1000_hw *hw)
5814919Sxy150489 {
5826735Scc210113 if (hw->mac.ops.setup_led)
5836735Scc210113 return (hw->mac.ops.setup_led(hw));
5844919Sxy150489
5854919Sxy150489 return (E1000_SUCCESS);
5864919Sxy150489 }
5874919Sxy150489
5884919Sxy150489 /*
5894919Sxy150489 * e1000_cleanup_led - Restores SW controllable LED
5904919Sxy150489 * @hw: pointer to the HW structure
5914919Sxy150489 *
5924919Sxy150489 * This restores the SW controllable LED to the value saved off by
5934919Sxy150489 * e1000_setup_led. This is a function pointer entry point called by drivers.
5944919Sxy150489 */
5954919Sxy150489 s32
e1000_cleanup_led(struct e1000_hw * hw)5964919Sxy150489 e1000_cleanup_led(struct e1000_hw *hw)
5974919Sxy150489 {
5986735Scc210113 if (hw->mac.ops.cleanup_led)
5996735Scc210113 return (hw->mac.ops.cleanup_led(hw));
6004919Sxy150489
6014919Sxy150489 return (E1000_SUCCESS);
6024919Sxy150489 }
6034919Sxy150489
6044919Sxy150489 /*
6054919Sxy150489 * e1000_blink_led - Blink SW controllable LED
6064919Sxy150489 * @hw: pointer to the HW structure
6074919Sxy150489 *
6084919Sxy150489 * This starts the adapter LED blinking. Request the LED to be setup first
6094919Sxy150489 * and cleaned up after. This is a function pointer entry point called by
6104919Sxy150489 * drivers.
6114919Sxy150489 */
6124919Sxy150489 s32
e1000_blink_led(struct e1000_hw * hw)6134919Sxy150489 e1000_blink_led(struct e1000_hw *hw)
6144919Sxy150489 {
6156735Scc210113 if (hw->mac.ops.blink_led)
6166735Scc210113 return (hw->mac.ops.blink_led(hw));
6174919Sxy150489
6184919Sxy150489 return (E1000_SUCCESS);
6194919Sxy150489 }
6204919Sxy150489
6214919Sxy150489 /*
62210680SMin.Xu@Sun.COM * e1000_id_led_init - store LED configurations in SW
62310680SMin.Xu@Sun.COM * @hw: pointer to the HW structure
62410680SMin.Xu@Sun.COM *
62510680SMin.Xu@Sun.COM * Initializes the LED config in SW. This is a function pointer entry point
62610680SMin.Xu@Sun.COM * called by drivers.
62710680SMin.Xu@Sun.COM */
62810680SMin.Xu@Sun.COM s32
e1000_id_led_init(struct e1000_hw * hw)62910680SMin.Xu@Sun.COM e1000_id_led_init(struct e1000_hw *hw)
63010680SMin.Xu@Sun.COM {
63110680SMin.Xu@Sun.COM if (hw->mac.ops.id_led_init)
63210680SMin.Xu@Sun.COM return (hw->mac.ops.id_led_init(hw));
63310680SMin.Xu@Sun.COM
63410680SMin.Xu@Sun.COM return (E1000_SUCCESS);
63510680SMin.Xu@Sun.COM }
63610680SMin.Xu@Sun.COM
63710680SMin.Xu@Sun.COM /*
6384919Sxy150489 * e1000_led_on - Turn on SW controllable LED
6394919Sxy150489 * @hw: pointer to the HW structure
6404919Sxy150489 *
6414919Sxy150489 * Turns the SW defined LED on. This is a function pointer entry point
6424919Sxy150489 * called by drivers.
6434919Sxy150489 */
6444919Sxy150489 s32
e1000_led_on(struct e1000_hw * hw)6454919Sxy150489 e1000_led_on(struct e1000_hw *hw)
6464919Sxy150489 {
6476735Scc210113 if (hw->mac.ops.led_on)
6486735Scc210113 return (hw->mac.ops.led_on(hw));
6494919Sxy150489
6504919Sxy150489 return (E1000_SUCCESS);
6514919Sxy150489 }
6524919Sxy150489
6534919Sxy150489 /*
6544919Sxy150489 * e1000_led_off - Turn off SW controllable LED
6554919Sxy150489 * @hw: pointer to the HW structure
6564919Sxy150489 *
6574919Sxy150489 * Turns the SW defined LED off. This is a function pointer entry point
6584919Sxy150489 * called by drivers.
6594919Sxy150489 */
6604919Sxy150489 s32
e1000_led_off(struct e1000_hw * hw)6614919Sxy150489 e1000_led_off(struct e1000_hw *hw)
6624919Sxy150489 {
6636735Scc210113 if (hw->mac.ops.led_off)
6646735Scc210113 return (hw->mac.ops.led_off(hw));
6654919Sxy150489
6664919Sxy150489 return (E1000_SUCCESS);
6674919Sxy150489 }
6684919Sxy150489
6694919Sxy150489 /*
6704919Sxy150489 * e1000_reset_adaptive - Reset adaptive IFS
6714919Sxy150489 * @hw: pointer to the HW structure
6724919Sxy150489 *
6734919Sxy150489 * Resets the adaptive IFS. Currently no func pointer exists and all
6744919Sxy150489 * implementations are handled in the generic version of this function.
6754919Sxy150489 */
6764919Sxy150489 void
e1000_reset_adaptive(struct e1000_hw * hw)6774919Sxy150489 e1000_reset_adaptive(struct e1000_hw *hw)
6784919Sxy150489 {
6794919Sxy150489 e1000_reset_adaptive_generic(hw);
6804919Sxy150489 }
6814919Sxy150489
6824919Sxy150489 /*
6834919Sxy150489 * e1000_update_adaptive - Update adaptive IFS
6844919Sxy150489 * @hw: pointer to the HW structure
6854919Sxy150489 *
6864919Sxy150489 * Updates adapter IFS. Currently no func pointer exists and all
6874919Sxy150489 * implementations are handled in the generic version of this function.
6884919Sxy150489 */
6894919Sxy150489 void
e1000_update_adaptive(struct e1000_hw * hw)6904919Sxy150489 e1000_update_adaptive(struct e1000_hw *hw)
6914919Sxy150489 {
6924919Sxy150489 e1000_update_adaptive_generic(hw);
6934919Sxy150489 }
6944919Sxy150489
6954919Sxy150489 /*
6964919Sxy150489 * e1000_disable_pcie_master - Disable PCI-Express master access
6974919Sxy150489 * @hw: pointer to the HW structure
6984919Sxy150489 *
6994919Sxy150489 * Disables PCI-Express master access and verifies there are no pending
7004919Sxy150489 * requests. Currently no func pointer exists and all implementations are
7014919Sxy150489 * handled in the generic version of this function.
7024919Sxy150489 */
7034919Sxy150489 s32
e1000_disable_pcie_master(struct e1000_hw * hw)7044919Sxy150489 e1000_disable_pcie_master(struct e1000_hw *hw)
7054919Sxy150489 {
7064919Sxy150489 return (e1000_disable_pcie_master_generic(hw));
7074919Sxy150489 }
7084919Sxy150489
7094919Sxy150489 /*
7104919Sxy150489 * e1000_config_collision_dist - Configure collision distance
7114919Sxy150489 * @hw: pointer to the HW structure
7124919Sxy150489 *
7134919Sxy150489 * Configures the collision distance to the default value and is used
7144919Sxy150489 * during link setup.
7154919Sxy150489 */
7164919Sxy150489 void
e1000_config_collision_dist(struct e1000_hw * hw)7174919Sxy150489 e1000_config_collision_dist(struct e1000_hw *hw)
7184919Sxy150489 {
7196735Scc210113 if (hw->mac.ops.config_collision_dist)
7206735Scc210113 hw->mac.ops.config_collision_dist(hw);
7214919Sxy150489 }
7224919Sxy150489
7234919Sxy150489 /*
7244919Sxy150489 * e1000_rar_set - Sets a receive address register
7254919Sxy150489 * @hw: pointer to the HW structure
7264919Sxy150489 * @addr: address to set the RAR to
7274919Sxy150489 * @index: the RAR to set
7284919Sxy150489 *
7294919Sxy150489 * Sets a Receive Address Register (RAR) to the specified address.
7304919Sxy150489 */
7314919Sxy150489 void
e1000_rar_set(struct e1000_hw * hw,u8 * addr,u32 index)7324919Sxy150489 e1000_rar_set(struct e1000_hw *hw, u8 * addr, u32 index)
7334919Sxy150489 {
7346735Scc210113 if (hw->mac.ops.rar_set)
7356735Scc210113 hw->mac.ops.rar_set(hw, addr, index);
7364919Sxy150489 }
7374919Sxy150489
7384919Sxy150489 /*
7394919Sxy150489 * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
7404919Sxy150489 * @hw: pointer to the HW structure
7414919Sxy150489 *
7424919Sxy150489 * Ensures that the MDI/MDIX SW state is valid.
7434919Sxy150489 */
7444919Sxy150489 s32
e1000_validate_mdi_setting(struct e1000_hw * hw)7454919Sxy150489 e1000_validate_mdi_setting(struct e1000_hw *hw)
7464919Sxy150489 {
7476735Scc210113 if (hw->mac.ops.validate_mdi_setting)
7486735Scc210113 return (hw->mac.ops.validate_mdi_setting(hw));
7494919Sxy150489
7504919Sxy150489 return (E1000_SUCCESS);
7514919Sxy150489 }
7524919Sxy150489
7534919Sxy150489 /*
7544919Sxy150489 * e1000_mta_set - Sets multicast table bit
7554919Sxy150489 * @hw: pointer to the HW structure
7564919Sxy150489 * @hash_value: Multicast hash value.
7574919Sxy150489 *
7584919Sxy150489 * This sets the bit in the multicast table corresponding to the
7594919Sxy150489 * hash value. This is a function pointer entry point called by drivers.
7604919Sxy150489 */
7614919Sxy150489 void
e1000_mta_set(struct e1000_hw * hw,u32 hash_value)7624919Sxy150489 e1000_mta_set(struct e1000_hw *hw, u32 hash_value)
7634919Sxy150489 {
7646735Scc210113 if (hw->mac.ops.mta_set)
7656735Scc210113 hw->mac.ops.mta_set(hw, hash_value);
7664919Sxy150489 }
7674919Sxy150489
7684919Sxy150489 /*
7694919Sxy150489 * e1000_hash_mc_addr - Determines address location in multicast table
7704919Sxy150489 * @hw: pointer to the HW structure
7714919Sxy150489 * @mc_addr: Multicast address to hash.
7724919Sxy150489 *
7734919Sxy150489 * This hashes an address to determine its location in the multicast
7744919Sxy150489 * table. Currently no func pointer exists and all implementations
7754919Sxy150489 * are handled in the generic version of this function.
7764919Sxy150489 */
7774919Sxy150489 u32
e1000_hash_mc_addr(struct e1000_hw * hw,u8 * mc_addr)7784919Sxy150489 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
7794919Sxy150489 {
7804919Sxy150489 return (e1000_hash_mc_addr_generic(hw, mc_addr));
7814919Sxy150489 }
7824919Sxy150489
7834919Sxy150489 /*
7844919Sxy150489 * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
7854919Sxy150489 * @hw: pointer to the HW structure
7864919Sxy150489 *
7874919Sxy150489 * Enables packet filtering on transmit packets if manageability is enabled
7884919Sxy150489 * and host interface is enabled.
7894919Sxy150489 * Currently no func pointer exists and all implementations are handled in the
7904919Sxy150489 * generic version of this function.
7914919Sxy150489 */
7926735Scc210113 bool
e1000_enable_tx_pkt_filtering(struct e1000_hw * hw)7934919Sxy150489 e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
7944919Sxy150489 {
7954919Sxy150489 return (e1000_enable_tx_pkt_filtering_generic(hw));
7964919Sxy150489 }
7974919Sxy150489
7984919Sxy150489 /*
7994919Sxy150489 * e1000_mng_host_if_write - Writes to the manageability host interface
8004919Sxy150489 * @hw: pointer to the HW structure
8014919Sxy150489 * @buffer: pointer to the host interface buffer
8024919Sxy150489 * @length: size of the buffer
8034919Sxy150489 * @offset: location in the buffer to write to
8044919Sxy150489 * @sum: sum of the data (not checksum)
8054919Sxy150489 *
8064919Sxy150489 * This function writes the buffer content at the offset given on the host if.
8074919Sxy150489 * It also does alignment considerations to do the writes in most efficient
8084919Sxy150489 * way. Also fills up the sum of the buffer in *buffer parameter.
8094919Sxy150489 */
8104919Sxy150489 s32
e1000_mng_host_if_write(struct e1000_hw * hw,u8 * buffer,u16 length,u16 offset,u8 * sum)8114919Sxy150489 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
8124919Sxy150489 u16 offset, u8 *sum)
8134919Sxy150489 {
8146735Scc210113 if (hw->mac.ops.mng_host_if_write)
8156735Scc210113 return (hw->mac.ops.mng_host_if_write(hw, buffer, length,
8166735Scc210113 offset, sum));
8174919Sxy150489
8184919Sxy150489 return (E1000_NOT_IMPLEMENTED);
8194919Sxy150489 }
8204919Sxy150489
8214919Sxy150489 /*
8224919Sxy150489 * e1000_mng_write_cmd_header - Writes manageability command header
8234919Sxy150489 * @hw: pointer to the HW structure
8244919Sxy150489 * @hdr: pointer to the host interface command header
8254919Sxy150489 *
8264919Sxy150489 * Writes the command header after does the checksum calculation.
8274919Sxy150489 */
8284919Sxy150489 s32
e1000_mng_write_cmd_header(struct e1000_hw * hw,struct e1000_host_mng_command_header * hdr)8294919Sxy150489 e1000_mng_write_cmd_header(struct e1000_hw *hw,
8304919Sxy150489 struct e1000_host_mng_command_header *hdr)
8314919Sxy150489 {
8326735Scc210113 if (hw->mac.ops.mng_write_cmd_header)
8336735Scc210113 return (hw->mac.ops.mng_write_cmd_header(hw, hdr));
8344919Sxy150489
8354919Sxy150489 return (E1000_NOT_IMPLEMENTED);
8364919Sxy150489 }
8374919Sxy150489
8384919Sxy150489 /*
8394919Sxy150489 * e1000_mng_enable_host_if - Checks host interface is enabled
8404919Sxy150489 * @hw: pointer to the HW structure
8414919Sxy150489 *
8424919Sxy150489 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
8434919Sxy150489 *
8446735Scc210113 * This function checks whether the HOST IF is enabled for command operation
8454919Sxy150489 * and also checks whether the previous command is completed. It busy waits
8464919Sxy150489 * in case of previous command is not completed.
8474919Sxy150489 */
8484919Sxy150489 s32
e1000_mng_enable_host_if(struct e1000_hw * hw)8494919Sxy150489 e1000_mng_enable_host_if(struct e1000_hw *hw)
8504919Sxy150489 {
8516735Scc210113 if (hw->mac.ops.mng_enable_host_if)
8526735Scc210113 return (hw->mac.ops.mng_enable_host_if(hw));
8534919Sxy150489
8544919Sxy150489 return (E1000_NOT_IMPLEMENTED);
8554919Sxy150489 }
8564919Sxy150489
8574919Sxy150489 /*
8584919Sxy150489 * e1000_wait_autoneg - Waits for autonegotiation completion
8594919Sxy150489 * @hw: pointer to the HW structure
8604919Sxy150489 *
8614919Sxy150489 * Waits for autoneg to complete. Currently no func pointer exists and all
8624919Sxy150489 * implementations are handled in the generic version of this function.
8634919Sxy150489 */
8644919Sxy150489 s32
e1000_wait_autoneg(struct e1000_hw * hw)8654919Sxy150489 e1000_wait_autoneg(struct e1000_hw *hw)
8664919Sxy150489 {
8676735Scc210113 if (hw->mac.ops.wait_autoneg)
8686735Scc210113 return (hw->mac.ops.wait_autoneg(hw));
8694919Sxy150489
8704919Sxy150489 return (E1000_SUCCESS);
8714919Sxy150489 }
8724919Sxy150489
8734919Sxy150489 /*
8744919Sxy150489 * e1000_check_reset_block - Verifies PHY can be reset
8754919Sxy150489 * @hw: pointer to the HW structure
8764919Sxy150489 *
8774919Sxy150489 * Checks if the PHY is in a state that can be reset or if manageability
8784919Sxy150489 * has it tied up. This is a function pointer entry point called by drivers.
8794919Sxy150489 */
8804919Sxy150489 s32
e1000_check_reset_block(struct e1000_hw * hw)8814919Sxy150489 e1000_check_reset_block(struct e1000_hw *hw)
8824919Sxy150489 {
8836735Scc210113 if (hw->phy.ops.check_reset_block)
8846735Scc210113 return (hw->phy.ops.check_reset_block(hw));
8854919Sxy150489
8864919Sxy150489 return (E1000_SUCCESS);
8874919Sxy150489 }
8884919Sxy150489
8894919Sxy150489 /*
8904919Sxy150489 * e1000_read_phy_reg - Reads PHY register
8914919Sxy150489 * @hw: pointer to the HW structure
8924919Sxy150489 * @offset: the register to read
8934919Sxy150489 * @data: the buffer to store the 16-bit read.
8944919Sxy150489 *
8954919Sxy150489 * Reads the PHY register and returns the value in data.
8964919Sxy150489 * This is a function pointer entry point called by drivers.
8974919Sxy150489 */
8984919Sxy150489 s32
e1000_read_phy_reg(struct e1000_hw * hw,u32 offset,u16 * data)8994919Sxy150489 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
9004919Sxy150489 {
9016735Scc210113 if (hw->phy.ops.read_reg)
9026735Scc210113 return (hw->phy.ops.read_reg(hw, offset, data));
9034919Sxy150489
9044919Sxy150489 return (E1000_SUCCESS);
9054919Sxy150489 }
9064919Sxy150489
9074919Sxy150489 /*
9084919Sxy150489 * e1000_write_phy_reg - Writes PHY register
9094919Sxy150489 * @hw: pointer to the HW structure
9104919Sxy150489 * @offset: the register to write
9114919Sxy150489 * @data: the value to write.
9124919Sxy150489 *
9134919Sxy150489 * Writes the PHY register at offset with the value in data.
9144919Sxy150489 * This is a function pointer entry point called by drivers.
9154919Sxy150489 */
9164919Sxy150489 s32
e1000_write_phy_reg(struct e1000_hw * hw,u32 offset,u16 data)9174919Sxy150489 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
9184919Sxy150489 {
9196735Scc210113 if (hw->phy.ops.write_reg)
9206735Scc210113 return (hw->phy.ops.write_reg(hw, offset, data));
9216735Scc210113
9226735Scc210113 return (E1000_SUCCESS);
9236735Scc210113 }
9246735Scc210113
9256735Scc210113 /*
9266735Scc210113 * e1000_release_phy - Generic release PHY
9276735Scc210113 * @hw: pointer to the HW structure
9286735Scc210113 *
9296735Scc210113 * Return if silicon family does not require a semaphore when accessing the
9306735Scc210113 * PHY.
9316735Scc210113 */
9326735Scc210113 void
e1000_release_phy(struct e1000_hw * hw)9336735Scc210113 e1000_release_phy(struct e1000_hw *hw)
9346735Scc210113 {
9356735Scc210113 if (hw->phy.ops.release)
9366735Scc210113 hw->phy.ops.release(hw);
9376735Scc210113 }
9386735Scc210113
9396735Scc210113 /*
9406735Scc210113 * e1000_acquire_phy - Generic acquire PHY
9416735Scc210113 * @hw: pointer to the HW structure
9426735Scc210113 *
9436735Scc210113 * Return success if silicon family does not require a semaphore when
9446735Scc210113 * accessing the PHY.
9456735Scc210113 */
9466735Scc210113 s32
e1000_acquire_phy(struct e1000_hw * hw)9476735Scc210113 e1000_acquire_phy(struct e1000_hw *hw)
9486735Scc210113 {
9496735Scc210113 if (hw->phy.ops.acquire)
9506735Scc210113 return (hw->phy.ops.acquire(hw));
9514919Sxy150489
9524919Sxy150489 return (E1000_SUCCESS);
9534919Sxy150489 }
9544919Sxy150489
9554919Sxy150489 /*
9568479SChenlu.Chen@Sun.COM * e1000_cfg_on_link_up - Configure PHY upon link up
9578479SChenlu.Chen@Sun.COM * @hw: pointer to the HW structure
9588479SChenlu.Chen@Sun.COM */
9598479SChenlu.Chen@Sun.COM s32
e1000_cfg_on_link_up(struct e1000_hw * hw)9608479SChenlu.Chen@Sun.COM e1000_cfg_on_link_up(struct e1000_hw *hw)
9618479SChenlu.Chen@Sun.COM {
9628479SChenlu.Chen@Sun.COM if (hw->phy.ops.cfg_on_link_up)
9638479SChenlu.Chen@Sun.COM return (hw->phy.ops.cfg_on_link_up(hw));
9648479SChenlu.Chen@Sun.COM
9658479SChenlu.Chen@Sun.COM return (E1000_SUCCESS);
9668479SChenlu.Chen@Sun.COM }
9678479SChenlu.Chen@Sun.COM
9688479SChenlu.Chen@Sun.COM /*
9694919Sxy150489 * e1000_read_kmrn_reg - Reads register using Kumeran interface
9704919Sxy150489 * @hw: pointer to the HW structure
9714919Sxy150489 * @offset: the register to read
9724919Sxy150489 * @data: the location to store the 16-bit value read.
9734919Sxy150489 *
9744919Sxy150489 * Reads a register out of the Kumeran interface. Currently no func pointer
9754919Sxy150489 * exists and all implementations are handled in the generic version of
9764919Sxy150489 * this function.
9774919Sxy150489 */
9784919Sxy150489 s32
e1000_read_kmrn_reg(struct e1000_hw * hw,u32 offset,u16 * data)9794919Sxy150489 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
9804919Sxy150489 {
9814919Sxy150489 return (e1000_read_kmrn_reg_generic(hw, offset, data));
9824919Sxy150489 }
9834919Sxy150489
9844919Sxy150489 /*
9854919Sxy150489 * e1000_write_kmrn_reg - Writes register using Kumeran interface
9864919Sxy150489 * @hw: pointer to the HW structure
9874919Sxy150489 * @offset: the register to write
9884919Sxy150489 * @data: the value to write.
9894919Sxy150489 *
9904919Sxy150489 * Writes a register to the Kumeran interface. Currently no func pointer
9914919Sxy150489 * exists and all implementations are handled in the generic version of
9924919Sxy150489 * this function.
9934919Sxy150489 */
9944919Sxy150489 s32
e1000_write_kmrn_reg(struct e1000_hw * hw,u32 offset,u16 data)9954919Sxy150489 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
9964919Sxy150489 {
9974919Sxy150489 return (e1000_write_kmrn_reg_generic(hw, offset, data));
9984919Sxy150489 }
9994919Sxy150489
10004919Sxy150489 /*
10014919Sxy150489 * e1000_get_cable_length - Retrieves cable length estimation
10024919Sxy150489 * @hw: pointer to the HW structure
10034919Sxy150489 *
10044919Sxy150489 * This function estimates the cable length and stores them in
10054919Sxy150489 * hw->phy.min_length and hw->phy.max_length. This is a function pointer
10064919Sxy150489 * entry point called by drivers.
10074919Sxy150489 */
10084919Sxy150489 s32
e1000_get_cable_length(struct e1000_hw * hw)10094919Sxy150489 e1000_get_cable_length(struct e1000_hw *hw)
10104919Sxy150489 {
10116735Scc210113 if (hw->phy.ops.get_cable_length)
10126735Scc210113 return (hw->phy.ops.get_cable_length(hw));
10134919Sxy150489
10144919Sxy150489 return (E1000_SUCCESS);
10154919Sxy150489 }
10164919Sxy150489
10174919Sxy150489 /*
10184919Sxy150489 * e1000_get_phy_info - Retrieves PHY information from registers
10194919Sxy150489 * @hw: pointer to the HW structure
10204919Sxy150489 *
10214919Sxy150489 * This function gets some information from various PHY registers and
10224919Sxy150489 * populates hw->phy values with it. This is a function pointer entry
10234919Sxy150489 * point called by drivers.
10244919Sxy150489 */
10254919Sxy150489 s32
e1000_get_phy_info(struct e1000_hw * hw)10264919Sxy150489 e1000_get_phy_info(struct e1000_hw *hw)
10274919Sxy150489 {
10286735Scc210113 if (hw->phy.ops.get_info)
10296735Scc210113 return (hw->phy.ops.get_info(hw));
10304919Sxy150489
10314919Sxy150489 return (E1000_SUCCESS);
10324919Sxy150489 }
10334919Sxy150489
10344919Sxy150489 /*
10354919Sxy150489 * e1000_phy_hw_reset - Hard PHY reset
10364919Sxy150489 * @hw: pointer to the HW structure
10374919Sxy150489 *
10384919Sxy150489 * Performs a hard PHY reset. This is a function pointer entry point called
10394919Sxy150489 * by drivers.
10404919Sxy150489 */
10414919Sxy150489 s32
e1000_phy_hw_reset(struct e1000_hw * hw)10424919Sxy150489 e1000_phy_hw_reset(struct e1000_hw *hw)
10434919Sxy150489 {
10446735Scc210113 if (hw->phy.ops.reset)
10456735Scc210113 return (hw->phy.ops.reset(hw));
10464919Sxy150489
10474919Sxy150489 return (E1000_SUCCESS);
10484919Sxy150489 }
10494919Sxy150489
10504919Sxy150489 /*
10514919Sxy150489 * e1000_phy_commit - Soft PHY reset
10524919Sxy150489 * @hw: pointer to the HW structure
10534919Sxy150489 *
10544919Sxy150489 * Performs a soft PHY reset on those that apply. This is a function pointer
10554919Sxy150489 * entry point called by drivers.
10564919Sxy150489 */
10574919Sxy150489 s32
e1000_phy_commit(struct e1000_hw * hw)10584919Sxy150489 e1000_phy_commit(struct e1000_hw *hw)
10594919Sxy150489 {
10606735Scc210113 if (hw->phy.ops.commit)
10616735Scc210113 return (hw->phy.ops.commit(hw));
10624919Sxy150489
10634919Sxy150489 return (E1000_SUCCESS);
10644919Sxy150489 }
10654919Sxy150489
10664919Sxy150489 /*
10676735Scc210113 * e1000_set_d0_lplu_state - Sets low power link up state for D0
10684919Sxy150489 * @hw: pointer to the HW structure
10694919Sxy150489 * @active: boolean used to enable/disable lplu
10704919Sxy150489 *
10714919Sxy150489 * Success returns 0, Failure returns 1
10724919Sxy150489 *
10734919Sxy150489 * The low power link up (lplu) state is set to the power management level D0
10744919Sxy150489 * and SmartSpeed is disabled when active is true, else clear lplu for D0
10754919Sxy150489 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
10764919Sxy150489 * is used during Dx states where the power conservation is most important.
10774919Sxy150489 * During driver activity, SmartSpeed should be enabled so performance is
10784919Sxy150489 * maintained. This is a function pointer entry point called by drivers.
10794919Sxy150489 */
10804919Sxy150489 s32
e1000_set_d0_lplu_state(struct e1000_hw * hw,bool active)10816735Scc210113 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
10824919Sxy150489 {
10836735Scc210113 if (hw->phy.ops.set_d0_lplu_state)
10846735Scc210113 return (hw->phy.ops.set_d0_lplu_state(hw, active));
10854919Sxy150489
10864919Sxy150489 return (E1000_SUCCESS);
10874919Sxy150489 }
10884919Sxy150489
10894919Sxy150489 /*
10904919Sxy150489 * e1000_set_d3_lplu_state - Sets low power link up state for D3
10914919Sxy150489 * @hw: pointer to the HW structure
10924919Sxy150489 * @active: boolean used to enable/disable lplu
10934919Sxy150489 *
10944919Sxy150489 * Success returns 0, Failure returns 1
10954919Sxy150489 *
10964919Sxy150489 * The low power link up (lplu) state is set to the power management level D3
10974919Sxy150489 * and SmartSpeed is disabled when active is true, else clear lplu for D3
10984919Sxy150489 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
10994919Sxy150489 * is used during Dx states where the power conservation is most important.
11004919Sxy150489 * During driver activity, SmartSpeed should be enabled so performance is
11014919Sxy150489 * maintained. This is a function pointer entry point called by drivers.
11024919Sxy150489 */
11034919Sxy150489 s32
e1000_set_d3_lplu_state(struct e1000_hw * hw,bool active)11046735Scc210113 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
11054919Sxy150489 {
11066735Scc210113 if (hw->phy.ops.set_d3_lplu_state)
11076735Scc210113 return (hw->phy.ops.set_d3_lplu_state(hw, active));
11084919Sxy150489
11094919Sxy150489 return (E1000_SUCCESS);
11104919Sxy150489 }
11114919Sxy150489
11124919Sxy150489 /*
11134919Sxy150489 * e1000_read_mac_addr - Reads MAC address
11144919Sxy150489 * @hw: pointer to the HW structure
11154919Sxy150489 *
11164919Sxy150489 * Reads the MAC address out of the adapter and stores it in the HW structure.
11174919Sxy150489 * Currently no func pointer exists and all implementations are handled in the
11184919Sxy150489 * generic version of this function.
11194919Sxy150489 */
11204919Sxy150489 s32
e1000_read_mac_addr(struct e1000_hw * hw)11214919Sxy150489 e1000_read_mac_addr(struct e1000_hw *hw)
11224919Sxy150489 {
11236735Scc210113 if (hw->mac.ops.read_mac_addr)
11246735Scc210113 return (hw->mac.ops.read_mac_addr(hw));
11256735Scc210113
11264919Sxy150489 return (e1000_read_mac_addr_generic(hw));
11274919Sxy150489 }
11284919Sxy150489
11294919Sxy150489 /*
11306735Scc210113 * e1000_read_pba_num - Read device part number
11314919Sxy150489 * @hw: pointer to the HW structure
11326735Scc210113 * @pba_num: pointer to device part number
11334919Sxy150489 *
11344919Sxy150489 * Reads the product board assembly (PBA) number from the EEPROM and stores
11356735Scc210113 * the value in pba_num.
11364919Sxy150489 * Currently no func pointer exists and all implementations are handled in the
11374919Sxy150489 * generic version of this function.
11384919Sxy150489 */
11394919Sxy150489 s32
e1000_read_pba_num(struct e1000_hw * hw,u32 * pba_num)11406735Scc210113 e1000_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
11414919Sxy150489 {
11426735Scc210113 return (e1000_read_pba_num_generic(hw, pba_num));
11434919Sxy150489 }
11444919Sxy150489
11454919Sxy150489 /*
11464919Sxy150489 * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
11474919Sxy150489 * @hw: pointer to the HW structure
11484919Sxy150489 *
11494919Sxy150489 * Validates the NVM checksum is correct. This is a function pointer entry
11504919Sxy150489 * point called by drivers.
11514919Sxy150489 */
11524919Sxy150489 s32
e1000_validate_nvm_checksum(struct e1000_hw * hw)11534919Sxy150489 e1000_validate_nvm_checksum(struct e1000_hw *hw)
11544919Sxy150489 {
11556735Scc210113 if (hw->nvm.ops.validate)
11566735Scc210113 return (hw->nvm.ops.validate(hw));
11574919Sxy150489
11584919Sxy150489 return (-E1000_ERR_CONFIG);
11594919Sxy150489 }
11604919Sxy150489
11614919Sxy150489 /*
11624919Sxy150489 * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
11634919Sxy150489 * @hw: pointer to the HW structure
11644919Sxy150489 *
11654919Sxy150489 * Updates the NVM checksum. Currently no func pointer exists and all
11664919Sxy150489 * implementations are handled in the generic version of this function.
11674919Sxy150489 */
11684919Sxy150489 s32
e1000_update_nvm_checksum(struct e1000_hw * hw)11694919Sxy150489 e1000_update_nvm_checksum(struct e1000_hw *hw)
11704919Sxy150489 {
11716735Scc210113 if (hw->nvm.ops.update)
11726735Scc210113 return (hw->nvm.ops.update(hw));
11734919Sxy150489
11744919Sxy150489 return (-E1000_ERR_CONFIG);
11754919Sxy150489 }
11764919Sxy150489
11774919Sxy150489 /*
11784919Sxy150489 * e1000_reload_nvm - Reloads EEPROM
11794919Sxy150489 * @hw: pointer to the HW structure
11804919Sxy150489 *
11814919Sxy150489 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
11824919Sxy150489 * extended control register.
11834919Sxy150489 */
11844919Sxy150489 void
e1000_reload_nvm(struct e1000_hw * hw)11854919Sxy150489 e1000_reload_nvm(struct e1000_hw *hw)
11864919Sxy150489 {
11876735Scc210113 if (hw->nvm.ops.reload)
11886735Scc210113 hw->nvm.ops.reload(hw);
11894919Sxy150489 }
11904919Sxy150489
11914919Sxy150489 /*
11924919Sxy150489 * e1000_read_nvm - Reads NVM (EEPROM)
11934919Sxy150489 * @hw: pointer to the HW structure
11944919Sxy150489 * @offset: the word offset to read
11954919Sxy150489 * @words: number of 16-bit words to read
11964919Sxy150489 * @data: pointer to the properly sized buffer for the data.
11974919Sxy150489 *
11984919Sxy150489 * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
11994919Sxy150489 * pointer entry point called by drivers.
12004919Sxy150489 */
12014919Sxy150489 s32
e1000_read_nvm(struct e1000_hw * hw,u16 offset,u16 words,u16 * data)12024919Sxy150489 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
12034919Sxy150489 {
12046735Scc210113 if (hw->nvm.ops.read)
12056735Scc210113 return (hw->nvm.ops.read(hw, offset, words, data));
12064919Sxy150489
12074919Sxy150489 return (-E1000_ERR_CONFIG);
12084919Sxy150489 }
12094919Sxy150489
12104919Sxy150489 /*
12114919Sxy150489 * e1000_write_nvm - Writes to NVM (EEPROM)
12124919Sxy150489 * @hw: pointer to the HW structure
12134919Sxy150489 * @offset: the word offset to read
12144919Sxy150489 * @words: number of 16-bit words to write
12154919Sxy150489 * @data: pointer to the properly sized buffer for the data.
12164919Sxy150489 *
12174919Sxy150489 * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
12184919Sxy150489 * pointer entry point called by drivers.
12194919Sxy150489 */
12204919Sxy150489 s32
e1000_write_nvm(struct e1000_hw * hw,u16 offset,u16 words,u16 * data)12214919Sxy150489 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
12224919Sxy150489 {
12236735Scc210113 if (hw->nvm.ops.write)
12246735Scc210113 return (hw->nvm.ops.write(hw, offset, words, data));
12254919Sxy150489
12264919Sxy150489 return (E1000_SUCCESS);
12274919Sxy150489 }
12284919Sxy150489
12294919Sxy150489 /*
12306735Scc210113 * e1000_power_up_phy - Restores link in case of PHY power down
12316735Scc210113 * @hw: pointer to the HW structure
12326735Scc210113 *
12336735Scc210113 * The phy may be powered down to save power, to turn off link when the
12346735Scc210113 * driver is unloaded, or wake on lan is not enabled (among others).
12356735Scc210113 */
12366735Scc210113 void
e1000_power_up_phy(struct e1000_hw * hw)12376735Scc210113 e1000_power_up_phy(struct e1000_hw *hw)
12386735Scc210113 {
12396735Scc210113 if (hw->phy.ops.power_up)
12406735Scc210113 hw->phy.ops.power_up(hw);
12416735Scc210113
12427426SChenliang.Xu@Sun.COM (void) e1000_setup_link(hw);
12436735Scc210113 }
12446735Scc210113
12456735Scc210113 /*
12466735Scc210113 * e1000_power_down_phy - Power down PHY
12476735Scc210113 * @hw: pointer to the HW structure
12486735Scc210113 *
12496735Scc210113 * The phy may be powered down to save power, to turn off link when the
12506735Scc210113 * driver is unloaded, or wake on lan is not enabled (among others).
12516735Scc210113 */
12526735Scc210113 void
e1000_power_down_phy(struct e1000_hw * hw)12536735Scc210113 e1000_power_down_phy(struct e1000_hw *hw)
12546735Scc210113 {
12556735Scc210113 if (hw->phy.ops.power_down)
12566735Scc210113 hw->phy.ops.power_down(hw);
12576735Scc210113 }
1258