summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/io/igb/igb_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common/io/igb/igb_api.c')
-rw-r--r--usr/src/uts/common/io/igb/igb_api.c279
1 files changed, 152 insertions, 127 deletions
diff --git a/usr/src/uts/common/io/igb/igb_api.c b/usr/src/uts/common/io/igb/igb_api.c
index 3b2fc40a1b..76d8f60e77 100644
--- a/usr/src/uts/common/io/igb/igb_api.c
+++ b/usr/src/uts/common/io/igb/igb_api.c
@@ -1,7 +1,7 @@
/*
* CDDL HEADER START
*
- * Copyright(c) 2007-2008 Intel Corporation. All rights reserved.
+ * Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
@@ -22,18 +22,13 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms of the CDDL.
*/
-/* IntelVersion: 1.73 v2007-12-10_dragonlake5 */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
+/* IntelVersion: 1.107 v2008-10-7 */
#include "igb_api.h"
-#include "igb_mac.h"
-#include "igb_nvm.h"
-#include "igb_phy.h"
/*
* e1000_init_mac_params - Initialize MAC function pointers
@@ -47,8 +42,8 @@ e1000_init_mac_params(struct e1000_hw *hw)
{
s32 ret_val = E1000_SUCCESS;
- if (hw->func.init_mac_params) {
- ret_val = hw->func.init_mac_params(hw);
+ if (hw->mac.ops.init_params) {
+ ret_val = hw->mac.ops.init_params(hw);
if (ret_val) {
DEBUGOUT("MAC Initialization Error\n");
goto out;
@@ -74,8 +69,8 @@ e1000_init_nvm_params(struct e1000_hw *hw)
{
s32 ret_val = E1000_SUCCESS;
- if (hw->func.init_nvm_params) {
- ret_val = hw->func.init_nvm_params(hw);
+ if (hw->nvm.ops.init_params) {
+ ret_val = hw->nvm.ops.init_params(hw);
if (ret_val) {
DEBUGOUT("NVM Initialization Error\n");
goto out;
@@ -101,8 +96,8 @@ e1000_init_phy_params(struct e1000_hw *hw)
{
s32 ret_val = E1000_SUCCESS;
- if (hw->func.init_phy_params) {
- ret_val = hw->func.init_phy_params(hw);
+ if (hw->phy.ops.init_params) {
+ ret_val = hw->phy.ops.init_params(hw);
if (ret_val) {
DEBUGOUT("PHY Initialization Error\n");
goto out;
@@ -139,6 +134,12 @@ e1000_set_mac_type(struct e1000_hw *hw)
case E1000_DEV_ID_82575GB_QUAD_COPPER:
mac->type = e1000_82575;
break;
+ case E1000_DEV_ID_82576:
+ case E1000_DEV_ID_82576_FIBER:
+ case E1000_DEV_ID_82576_SERDES:
+ case E1000_DEV_ID_82576_QUAD_COPPER:
+ mac->type = e1000_82576;
+ break;
default:
/* Should never have loaded on this device */
ret_val = -E1000_ERR_MAC_INIT;
@@ -151,10 +152,10 @@ e1000_set_mac_type(struct e1000_hw *hw)
/*
* e1000_setup_init_funcs - Initializes function pointers
* @hw: pointer to the HW structure
- * @init_device: TRUE will initialize the rest of the function pointers
- * getting the device ready for use. FALSE will only set
+ * @init_device: true will initialize the rest of the function pointers
+ * getting the device ready for use. false will only set
* MAC type and the function pointers for the other init
- * functions. Passing FALSE will not generate any hardware
+ * functions. Passing false will not generate any hardware
* reads or writes.
*
* This function must be called by a driver in order to use the rest
@@ -179,18 +180,12 @@ e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
}
/*
- * Init some generic function pointers that are currently all pointing
- * to generic implementations. We do this first allowing a driver
- * module to override it afterwards.
+ * Init function pointers to generic implementations. We do this first
+ * allowing a driver module to override it afterward.
*/
- hw->func.config_collision_dist = e1000_config_collision_dist_generic;
- hw->func.rar_set = e1000_rar_set_generic;
- hw->func.validate_mdi_setting = e1000_validate_mdi_setting_generic;
- hw->func.mng_host_if_write = e1000_mng_host_if_write_generic;
- hw->func.mng_write_cmd_header = e1000_mng_write_cmd_header_generic;
- hw->func.mng_enable_host_if = e1000_mng_enable_host_if_generic;
- hw->func.wait_autoneg = e1000_wait_autoneg_generic;
- hw->func.reload_nvm = e1000_reload_nvm_generic;
+ e1000_init_mac_ops_generic(hw);
+ e1000_init_phy_ops_generic(hw);
+ e1000_init_nvm_ops_generic(hw);
/*
* Set up the init function pointers. These are functions within the
@@ -199,6 +194,7 @@ e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
*/
switch (hw->mac.type) {
case e1000_82575:
+ case e1000_82576:
e1000_init_function_pointers_82575(hw);
break;
default:
@@ -231,32 +227,18 @@ out:
}
/*
- * e1000_remove_device - Free device specific structure
- * @hw: pointer to the HW structure
- *
- * If a device specific structure was allocated, this function will
- * free it. This is a function pointer entry point called by drivers.
- */
-void
-e1000_remove_device(struct e1000_hw *hw)
-{
- if (hw->func.remove_device)
- hw->func.remove_device(hw);
-}
-
-/*
* e1000_get_bus_info - Obtain bus information for adapter
* @hw: pointer to the HW structure
*
* This will obtain information about the HW bus for which the
- * adaper is attached and stores it in the hw structure. This is a
+ * adapter is attached and stores it in the hw structure. This is a
* function pointer entry point called by drivers.
*/
s32
e1000_get_bus_info(struct e1000_hw *hw)
{
- if (hw->func.get_bus_info)
- return (hw->func.get_bus_info(hw));
+ if (hw->mac.ops.get_bus_info)
+ return (hw->mac.ops.get_bus_info(hw));
return (E1000_SUCCESS);
}
@@ -271,8 +253,8 @@ e1000_get_bus_info(struct e1000_hw *hw)
void
e1000_clear_vfta(struct e1000_hw *hw)
{
- if (hw->func.clear_vfta)
- hw->func.clear_vfta(hw);
+ if (hw->mac.ops.clear_vfta)
+ hw->mac.ops.clear_vfta(hw);
}
/*
@@ -287,8 +269,8 @@ e1000_clear_vfta(struct e1000_hw *hw)
void
e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
{
- if (hw->func.write_vfta)
- hw->func.write_vfta(hw, offset, value);
+ if (hw->mac.ops.write_vfta)
+ hw->mac.ops.write_vfta(hw, offset, value);
}
/*
@@ -310,8 +292,8 @@ void
e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
u32 mc_addr_count, u32 rar_used_count, u32 rar_count)
{
- if (hw->func.update_mc_addr_list)
- hw->func.update_mc_addr_list(hw,
+ if (hw->mac.ops.update_mc_addr_list)
+ hw->mac.ops.update_mc_addr_list(hw,
mc_addr_list,
mc_addr_count,
rar_used_count,
@@ -343,8 +325,8 @@ e1000_force_mac_fc(struct e1000_hw *hw)
s32
e1000_check_for_link(struct e1000_hw *hw)
{
- if (hw->func.check_for_link)
- return (hw->func.check_for_link(hw));
+ if (hw->mac.ops.check_for_link)
+ return (hw->mac.ops.check_for_link(hw));
return (-E1000_ERR_CONFIG);
}
@@ -359,10 +341,10 @@ e1000_check_for_link(struct e1000_hw *hw)
bool
e1000_check_mng_mode(struct e1000_hw *hw)
{
- if (hw->func.check_mng_mode)
- return (hw->func.check_mng_mode(hw));
+ if (hw->mac.ops.check_mng_mode)
+ return (hw->mac.ops.check_mng_mode(hw));
- return (FALSE);
+ return (false);
}
/*
@@ -389,8 +371,8 @@ e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
s32
e1000_reset_hw(struct e1000_hw *hw)
{
- if (hw->func.reset_hw)
- return (hw->func.reset_hw(hw));
+ if (hw->mac.ops.reset_hw)
+ return (hw->mac.ops.reset_hw(hw));
return (-E1000_ERR_CONFIG);
}
@@ -405,8 +387,8 @@ e1000_reset_hw(struct e1000_hw *hw)
s32
e1000_init_hw(struct e1000_hw *hw)
{
- if (hw->func.init_hw)
- return (hw->func.init_hw(hw));
+ if (hw->mac.ops.init_hw)
+ return (hw->mac.ops.init_hw(hw));
return (-E1000_ERR_CONFIG);
}
@@ -422,8 +404,8 @@ e1000_init_hw(struct e1000_hw *hw)
s32
e1000_setup_link(struct e1000_hw *hw)
{
- if (hw->func.setup_link)
- return (hw->func.setup_link(hw));
+ if (hw->mac.ops.setup_link)
+ return (hw->mac.ops.setup_link(hw));
return (-E1000_ERR_CONFIG);
}
@@ -441,8 +423,8 @@ e1000_setup_link(struct e1000_hw *hw)
s32
e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
{
- if (hw->func.get_link_up_info)
- return (hw->func.get_link_up_info(hw, speed, duplex));
+ if (hw->mac.ops.get_link_up_info)
+ return (hw->mac.ops.get_link_up_info(hw, speed, duplex));
return (-E1000_ERR_CONFIG);
}
@@ -458,8 +440,8 @@ e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
s32
e1000_setup_led(struct e1000_hw *hw)
{
- if (hw->func.setup_led)
- return (hw->func.setup_led(hw));
+ if (hw->mac.ops.setup_led)
+ return (hw->mac.ops.setup_led(hw));
return (E1000_SUCCESS);
}
@@ -474,8 +456,8 @@ e1000_setup_led(struct e1000_hw *hw)
s32
e1000_cleanup_led(struct e1000_hw *hw)
{
- if (hw->func.cleanup_led)
- return (hw->func.cleanup_led(hw));
+ if (hw->mac.ops.cleanup_led)
+ return (hw->mac.ops.cleanup_led(hw));
return (E1000_SUCCESS);
}
@@ -491,8 +473,8 @@ e1000_cleanup_led(struct e1000_hw *hw)
s32
e1000_blink_led(struct e1000_hw *hw)
{
- if (hw->func.blink_led)
- return (hw->func.blink_led(hw));
+ if (hw->mac.ops.blink_led)
+ return (hw->mac.ops.blink_led(hw));
return (E1000_SUCCESS);
}
@@ -507,8 +489,8 @@ e1000_blink_led(struct e1000_hw *hw)
s32
e1000_led_on(struct e1000_hw *hw)
{
- if (hw->func.led_on)
- return (hw->func.led_on(hw));
+ if (hw->mac.ops.led_on)
+ return (hw->mac.ops.led_on(hw));
return (E1000_SUCCESS);
}
@@ -523,8 +505,8 @@ e1000_led_on(struct e1000_hw *hw)
s32
e1000_led_off(struct e1000_hw *hw)
{
- if (hw->func.led_off)
- return (hw->func.led_off(hw));
+ if (hw->mac.ops.led_off)
+ return (hw->mac.ops.led_off(hw));
return (E1000_SUCCESS);
}
@@ -579,8 +561,8 @@ e1000_disable_pcie_master(struct e1000_hw *hw)
void
e1000_config_collision_dist(struct e1000_hw *hw)
{
- if (hw->func.config_collision_dist)
- hw->func.config_collision_dist(hw);
+ if (hw->mac.ops.config_collision_dist)
+ hw->mac.ops.config_collision_dist(hw);
}
/*
@@ -594,8 +576,8 @@ e1000_config_collision_dist(struct e1000_hw *hw)
void
e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
{
- if (hw->func.rar_set)
- hw->func.rar_set(hw, addr, index);
+ if (hw->mac.ops.rar_set)
+ hw->mac.ops.rar_set(hw, addr, index);
}
/*
@@ -607,8 +589,8 @@ e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
s32
e1000_validate_mdi_setting(struct e1000_hw *hw)
{
- if (hw->func.validate_mdi_setting)
- return (hw->func.validate_mdi_setting(hw));
+ if (hw->mac.ops.validate_mdi_setting)
+ return (hw->mac.ops.validate_mdi_setting(hw));
return (E1000_SUCCESS);
}
@@ -624,8 +606,8 @@ e1000_validate_mdi_setting(struct e1000_hw *hw)
void
e1000_mta_set(struct e1000_hw *hw, u32 hash_value)
{
- if (hw->func.mta_set)
- hw->func.mta_set(hw, hash_value);
+ if (hw->mac.ops.mta_set)
+ hw->mac.ops.mta_set(hw, hash_value);
}
/*
@@ -674,9 +656,9 @@ s32
e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
u16 offset, u8 *sum)
{
- if (hw->func.mng_host_if_write)
- return (hw->func.mng_host_if_write(hw, buffer, length, offset,
- sum));
+ if (hw->mac.ops.mng_host_if_write)
+ return (hw->mac.ops.mng_host_if_write(hw, buffer, length,
+ offset, sum));
return (E1000_NOT_IMPLEMENTED);
}
@@ -692,8 +674,8 @@ s32
e1000_mng_write_cmd_header(struct e1000_hw *hw,
struct e1000_host_mng_command_header *hdr)
{
- if (hw->func.mng_write_cmd_header)
- return (hw->func.mng_write_cmd_header(hw, hdr));
+ if (hw->mac.ops.mng_write_cmd_header)
+ return (hw->mac.ops.mng_write_cmd_header(hw, hdr));
return (E1000_NOT_IMPLEMENTED);
}
@@ -704,15 +686,15 @@ e1000_mng_write_cmd_header(struct e1000_hw *hw,
*
* Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
*
- * This function checks whether the HOST IF is enabled for command operaton
+ * This function checks whether the HOST IF is enabled for command operation
* and also checks whether the previous command is completed. It busy waits
* in case of previous command is not completed.
*/
s32
e1000_mng_enable_host_if(struct e1000_hw *hw)
{
- if (hw->func.mng_enable_host_if)
- return (hw->func.mng_enable_host_if(hw));
+ if (hw->mac.ops.mng_enable_host_if)
+ return (hw->mac.ops.mng_enable_host_if(hw));
return (E1000_NOT_IMPLEMENTED);
}
@@ -727,8 +709,8 @@ e1000_mng_enable_host_if(struct e1000_hw *hw)
s32
e1000_wait_autoneg(struct e1000_hw *hw)
{
- if (hw->func.wait_autoneg)
- return (hw->func.wait_autoneg(hw));
+ if (hw->mac.ops.wait_autoneg)
+ return (hw->mac.ops.wait_autoneg(hw));
return (E1000_SUCCESS);
}
@@ -743,8 +725,8 @@ e1000_wait_autoneg(struct e1000_hw *hw)
s32
e1000_check_reset_block(struct e1000_hw *hw)
{
- if (hw->func.check_reset_block)
- return (hw->func.check_reset_block(hw));
+ if (hw->phy.ops.check_reset_block)
+ return (hw->phy.ops.check_reset_block(hw));
return (E1000_SUCCESS);
}
@@ -761,8 +743,8 @@ e1000_check_reset_block(struct e1000_hw *hw)
s32
e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
{
- if (hw->func.read_phy_reg)
- return (hw->func.read_phy_reg(hw, offset, data));
+ if (hw->phy.ops.read_reg)
+ return (hw->phy.ops.read_reg(hw, offset, data));
return (E1000_SUCCESS);
}
@@ -779,8 +761,38 @@ e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
s32
e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
{
- if (hw->func.write_phy_reg)
- return (hw->func.write_phy_reg(hw, offset, data));
+ if (hw->phy.ops.write_reg)
+ return (hw->phy.ops.write_reg(hw, offset, data));
+
+ return (E1000_SUCCESS);
+}
+
+/*
+ * e1000_release_phy - Generic release PHY
+ * @hw: pointer to the HW structure
+ *
+ * Return if silicon family does not require a semaphore when accessing the
+ * PHY.
+ */
+void
+e1000_release_phy(struct e1000_hw *hw)
+{
+ if (hw->phy.ops.release)
+ hw->phy.ops.release(hw);
+}
+
+/*
+ * e1000_acquire_phy - Generic acquire PHY
+ * @hw: pointer to the HW structure
+ *
+ * Return success if silicon family does not require a semaphore when
+ * accessing the PHY.
+ */
+s32
+e1000_acquire_phy(struct e1000_hw *hw)
+{
+ if (hw->phy.ops.acquire)
+ return (hw->phy.ops.acquire(hw));
return (E1000_SUCCESS);
}
@@ -828,8 +840,8 @@ e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
s32
e1000_get_cable_length(struct e1000_hw *hw)
{
- if (hw->func.get_cable_length)
- return (hw->func.get_cable_length(hw));
+ if (hw->phy.ops.get_cable_length)
+ return (hw->phy.ops.get_cable_length(hw));
return (E1000_SUCCESS);
}
@@ -845,8 +857,8 @@ e1000_get_cable_length(struct e1000_hw *hw)
s32
e1000_get_phy_info(struct e1000_hw *hw)
{
- if (hw->func.get_phy_info)
- return (hw->func.get_phy_info(hw));
+ if (hw->phy.ops.get_info)
+ return (hw->phy.ops.get_info(hw));
return (E1000_SUCCESS);
}
@@ -861,8 +873,8 @@ e1000_get_phy_info(struct e1000_hw *hw)
s32
e1000_phy_hw_reset(struct e1000_hw *hw)
{
- if (hw->func.reset_phy)
- return (hw->func.reset_phy(hw));
+ if (hw->phy.ops.reset)
+ return (hw->phy.ops.reset(hw));
return (E1000_SUCCESS);
}
@@ -877,14 +889,14 @@ e1000_phy_hw_reset(struct e1000_hw *hw)
s32
e1000_phy_commit(struct e1000_hw *hw)
{
- if (hw->func.commit_phy)
- return (hw->func.commit_phy(hw));
+ if (hw->phy.ops.commit)
+ return (hw->phy.ops.commit(hw));
return (E1000_SUCCESS);
}
/*
- * e1000_set_d3_lplu_state - Sets low power link up state for D0
+ * e1000_set_d0_lplu_state - Sets low power link up state for D0
* @hw: pointer to the HW structure
* @active: boolean used to enable/disable lplu
*
@@ -900,8 +912,8 @@ e1000_phy_commit(struct e1000_hw *hw)
s32
e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
{
- if (hw->func.set_d0_lplu_state)
- return (hw->func.set_d0_lplu_state(hw, active));
+ if (hw->phy.ops.set_d0_lplu_state)
+ return (hw->phy.ops.set_d0_lplu_state(hw, active));
return (E1000_SUCCESS);
}
@@ -923,8 +935,8 @@ e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
s32
e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
{
- if (hw->func.set_d3_lplu_state)
- return (hw->func.set_d3_lplu_state(hw, active));
+ if (hw->phy.ops.set_d3_lplu_state)
+ return (hw->phy.ops.set_d3_lplu_state(hw, active));
return (E1000_SUCCESS);
}
@@ -940,8 +952,8 @@ e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
s32
e1000_read_mac_addr(struct e1000_hw *hw)
{
- if (hw->func.read_mac_addr)
- return (hw->func.read_mac_addr(hw));
+ if (hw->mac.ops.read_mac_addr)
+ return (hw->mac.ops.read_mac_addr(hw));
return (e1000_read_mac_addr_generic(hw));
}
@@ -972,8 +984,8 @@ e1000_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
s32
e1000_validate_nvm_checksum(struct e1000_hw *hw)
{
- if (hw->func.validate_nvm)
- return (hw->func.validate_nvm(hw));
+ if (hw->nvm.ops.validate)
+ return (hw->nvm.ops.validate(hw));
return (-E1000_ERR_CONFIG);
}
@@ -988,8 +1000,8 @@ e1000_validate_nvm_checksum(struct e1000_hw *hw)
s32
e1000_update_nvm_checksum(struct e1000_hw *hw)
{
- if (hw->func.update_nvm)
- return (hw->func.update_nvm(hw));
+ if (hw->nvm.ops.update)
+ return (hw->nvm.ops.update(hw));
return (-E1000_ERR_CONFIG);
}
@@ -1004,8 +1016,8 @@ e1000_update_nvm_checksum(struct e1000_hw *hw)
void
e1000_reload_nvm(struct e1000_hw *hw)
{
- if (hw->func.reload_nvm)
- hw->func.reload_nvm(hw);
+ if (hw->nvm.ops.reload)
+ hw->nvm.ops.reload(hw);
}
/*
@@ -1021,8 +1033,8 @@ e1000_reload_nvm(struct e1000_hw *hw)
s32
e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
{
- if (hw->func.read_nvm)
- return (hw->func.read_nvm(hw, offset, words, data));
+ if (hw->nvm.ops.read)
+ return (hw->nvm.ops.read(hw, offset, words, data));
return (-E1000_ERR_CONFIG);
}
@@ -1040,8 +1052,8 @@ e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
s32
e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
{
- if (hw->func.write_nvm)
- return (hw->func.write_nvm(hw, offset, words, data));
+ if (hw->nvm.ops.write)
+ return (hw->nvm.ops.write(hw, offset, words, data));
return (E1000_SUCCESS);
}
@@ -1072,8 +1084,8 @@ e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset, u8 data)
void
e1000_power_up_phy(struct e1000_hw *hw)
{
- if (hw->func.power_up_phy)
- hw->func.power_up_phy(hw);
+ if (hw->phy.ops.power_up)
+ hw->phy.ops.power_up(hw);
(void) e1000_setup_link(hw);
}
@@ -1088,6 +1100,19 @@ e1000_power_up_phy(struct e1000_hw *hw)
void
e1000_power_down_phy(struct e1000_hw *hw)
{
- if (hw->func.power_down_phy)
- hw->func.power_down_phy(hw);
+ if (hw->phy.ops.power_down)
+ hw->phy.ops.power_down(hw);
+}
+
+/*
+ * e1000_shutdown_fiber_serdes_link - Remove link during power down
+ * @hw: pointer to the HW structure
+ *
+ * Shutdown the optics and PCS on driver unload.
+ */
+void
+e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
+{
+ if (hw->mac.ops.shutdown_serdes)
+ hw->mac.ops.shutdown_serdes(hw);
}