kni: update kernel driver ethtool baseline

Update the KNI kernel driver so it can compile on more modern kernels
Also, rebaseline the ethtool support off updated igb kernel drivers
so that we get the latest bug fixes and device support.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
This commit is contained in:
Bruce Richardson 2014-02-11 12:25:54 +00:00 committed by David Marchand
parent e01d69d51c
commit b9ee370557
38 changed files with 9176 additions and 4970 deletions

View File

@ -61,6 +61,7 @@ SRCS-y += ethtool/ixgbe/ixgbe_phy.c
SRCS-y += ethtool/ixgbe/kcompat.c SRCS-y += ethtool/ixgbe/kcompat.c
SRCS-y += ethtool/igb/e1000_82575.c SRCS-y += ethtool/igb/e1000_82575.c
SRCS-y += ethtool/igb/e1000_i210.c
SRCS-y += ethtool/igb/e1000_api.c SRCS-y += ethtool/igb/e1000_api.c
SRCS-y += ethtool/igb/e1000_mac.c SRCS-y += ethtool/igb/e1000_mac.c
SRCS-y += ethtool/igb/e1000_manage.c SRCS-y += ethtool/igb/e1000_manage.c
@ -68,11 +69,13 @@ SRCS-y += ethtool/igb/e1000_mbx.c
SRCS-y += ethtool/igb/e1000_nvm.c SRCS-y += ethtool/igb/e1000_nvm.c
SRCS-y += ethtool/igb/e1000_phy.c SRCS-y += ethtool/igb/e1000_phy.c
SRCS-y += ethtool/igb/igb_ethtool.c SRCS-y += ethtool/igb/igb_ethtool.c
SRCS-y += ethtool/igb/igb_hwmon.c
SRCS-y += ethtool/igb/igb_main.c SRCS-y += ethtool/igb/igb_main.c
SRCS-y += ethtool/igb/igb_debugfs.c
SRCS-y += ethtool/igb/igb_param.c SRCS-y += ethtool/igb/igb_param.c
SRCS-y += ethtool/igb/igb_procfs.c SRCS-y += ethtool/igb/igb_procfs.c
SRCS-y += ethtool/igb/igb_sysfs.c
SRCS-y += ethtool/igb/igb_vmdq.c SRCS-y += ethtool/igb/igb_vmdq.c
#SRCS-y += ethtool/igb/igb_ptp.c
#SRCS-y += ethtool/igb/kcompat.c #SRCS-y += ethtool/igb/kcompat.c
SRCS-y += kni_misc.c SRCS-y += kni_misc.c

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -31,9 +31,12 @@
* 82575GB Gigabit Network Connection * 82575GB Gigabit Network Connection
* 82576 Gigabit Network Connection * 82576 Gigabit Network Connection
* 82576 Quad Port Gigabit Mezzanine Adapter * 82576 Quad Port Gigabit Mezzanine Adapter
* 82580 Gigabit Network Connection
* I350 Gigabit Network Connection
*/ */
#include "e1000_api.h" #include "e1000_api.h"
#include "e1000_i210.h"
static s32 e1000_init_phy_params_82575(struct e1000_hw *hw); static s32 e1000_init_phy_params_82575(struct e1000_hw *hw);
static s32 e1000_init_mac_params_82575(struct e1000_hw *hw); static s32 e1000_init_mac_params_82575(struct e1000_hw *hw);
@ -42,6 +45,7 @@ static void e1000_release_phy_82575(struct e1000_hw *hw);
static s32 e1000_acquire_nvm_82575(struct e1000_hw *hw); static s32 e1000_acquire_nvm_82575(struct e1000_hw *hw);
static void e1000_release_nvm_82575(struct e1000_hw *hw); static void e1000_release_nvm_82575(struct e1000_hw *hw);
static s32 e1000_check_for_link_82575(struct e1000_hw *hw); static s32 e1000_check_for_link_82575(struct e1000_hw *hw);
static s32 e1000_check_for_link_media_swap(struct e1000_hw *hw);
static s32 e1000_get_cfg_done_82575(struct e1000_hw *hw); static s32 e1000_get_cfg_done_82575(struct e1000_hw *hw);
static s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed, static s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
u16 *duplex); u16 *duplex);
@ -134,6 +138,9 @@ static bool e1000_sgmii_uses_mdio_82575(struct e1000_hw *hw)
break; break;
case e1000_82580: case e1000_82580:
case e1000_i350: case e1000_i350:
case e1000_i354:
case e1000_i210:
case e1000_i211:
reg = E1000_READ_REG(hw, E1000_MDICNFG); reg = E1000_READ_REG(hw, E1000_MDICNFG);
ext_mdio = !!(reg & E1000_MDICNFG_EXT_MDIO); ext_mdio = !!(reg & E1000_MDICNFG_EXT_MDIO);
break; break;
@ -195,9 +202,15 @@ static s32 e1000_init_phy_params_82575(struct e1000_hw *hw)
switch (hw->mac.type) { switch (hw->mac.type) {
case e1000_82580: case e1000_82580:
case e1000_i350: case e1000_i350:
case e1000_i354:
phy->ops.read_reg = e1000_read_phy_reg_82580; phy->ops.read_reg = e1000_read_phy_reg_82580;
phy->ops.write_reg = e1000_write_phy_reg_82580; phy->ops.write_reg = e1000_write_phy_reg_82580;
break; break;
case e1000_i210:
case e1000_i211:
phy->ops.read_reg = e1000_read_phy_reg_gs40g;
phy->ops.write_reg = e1000_write_phy_reg_gs40g;
break;
default: default:
phy->ops.read_reg = e1000_read_phy_reg_igp; phy->ops.read_reg = e1000_read_phy_reg_igp;
phy->ops.write_reg = e1000_write_phy_reg_igp; phy->ops.write_reg = e1000_write_phy_reg_igp;
@ -209,6 +222,7 @@ static s32 e1000_init_phy_params_82575(struct e1000_hw *hw)
/* Verify phy id and set remaining function pointers */ /* Verify phy id and set remaining function pointers */
switch (phy->id) { switch (phy->id) {
case M88E1543_E_PHY_ID:
case I347AT4_E_PHY_ID: case I347AT4_E_PHY_ID:
case M88E1112_E_PHY_ID: case M88E1112_E_PHY_ID:
case M88E1340M_E_PHY_ID: case M88E1340M_E_PHY_ID:
@ -221,9 +235,35 @@ static s32 e1000_init_phy_params_82575(struct e1000_hw *hw)
phy->id == M88E1340M_E_PHY_ID) phy->id == M88E1340M_E_PHY_ID)
phy->ops.get_cable_length = phy->ops.get_cable_length =
e1000_get_cable_length_m88_gen2; e1000_get_cable_length_m88_gen2;
else if (phy->id == M88E1543_E_PHY_ID)
phy->ops.get_cable_length =
e1000_get_cable_length_m88_gen2;
else else
phy->ops.get_cable_length = e1000_get_cable_length_m88; phy->ops.get_cable_length = e1000_get_cable_length_m88;
phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88; phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
/* Check if this PHY is confgured for media swap. */
if (phy->id == M88E1112_E_PHY_ID) {
u16 data;
ret_val = phy->ops.write_reg(hw,
E1000_M88E1112_PAGE_ADDR,
2);
if (ret_val)
goto out;
ret_val = phy->ops.read_reg(hw,
E1000_M88E1112_MAC_CTRL_1,
&data);
if (ret_val)
goto out;
data = (data & E1000_M88E1112_MAC_CTRL_1_MODE_MASK) >>
E1000_M88E1112_MAC_CTRL_1_MODE_SHIFT;
if (data == E1000_M88E1112_AUTO_COPPER_SGMII ||
data == E1000_M88E1112_AUTO_COPPER_BASEX)
hw->mac.ops.check_for_link =
e1000_check_for_link_media_swap;
}
break; break;
case IGP03E1000_E_PHY_ID: case IGP03E1000_E_PHY_ID:
case IGP04E1000_E_PHY_ID: case IGP04E1000_E_PHY_ID:
@ -246,6 +286,15 @@ static s32 e1000_init_phy_params_82575(struct e1000_hw *hw)
phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82580; phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82580;
phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_82580; phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_82580;
break; break;
case I210_I_PHY_ID:
phy->type = e1000_phy_i210;
phy->ops.check_polarity = e1000_check_polarity_m88;
phy->ops.get_info = e1000_get_phy_info_m88;
phy->ops.get_cable_length = e1000_get_cable_length_m88_gen2;
phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82580;
phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_82580;
phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
break;
default: default:
ret_val = -E1000_ERR_PHY; ret_val = -E1000_ERR_PHY;
goto out; goto out;
@ -282,8 +331,10 @@ s32 e1000_init_nvm_params_82575(struct e1000_hw *hw)
size = 15; size = 15;
nvm->word_size = 1 << size; nvm->word_size = 1 << size;
if (hw->mac.type < e1000_i210) {
nvm->opcode_bits = 8; nvm->opcode_bits = 8;
nvm->delay_usec = 1; nvm->delay_usec = 1;
switch (nvm->override) { switch (nvm->override) {
case e1000_nvm_override_spi_large: case e1000_nvm_override_spi_large:
nvm->page_size = 32; nvm->page_size = 32;
@ -295,15 +346,18 @@ s32 e1000_init_nvm_params_82575(struct e1000_hw *hw)
break; break;
default: default:
nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8; nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8; nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ?
16 : 8;
break; break;
} }
nvm->type = e1000_nvm_eeprom_spi;
if (nvm->word_size == (1 << 15)) if (nvm->word_size == (1 << 15))
nvm->page_size = 128; nvm->page_size = 128;
nvm->type = e1000_nvm_eeprom_spi;
} else {
nvm->type = e1000_nvm_flash_hw;
}
/* Function Pointers */ /* Function Pointers */
nvm->ops.acquire = e1000_acquire_nvm_82575; nvm->ops.acquire = e1000_acquire_nvm_82575;
nvm->ops.release = e1000_release_nvm_82575; nvm->ops.release = e1000_release_nvm_82575;
@ -324,6 +378,7 @@ s32 e1000_init_nvm_params_82575(struct e1000_hw *hw)
nvm->ops.update = e1000_update_nvm_checksum_82580; nvm->ops.update = e1000_update_nvm_checksum_82580;
break; break;
case e1000_i350: case e1000_i350:
//case e1000_i354:
nvm->ops.validate = e1000_validate_nvm_checksum_i350; nvm->ops.validate = e1000_validate_nvm_checksum_i350;
nvm->ops.update = e1000_update_nvm_checksum_i350; nvm->ops.update = e1000_update_nvm_checksum_i350;
break; break;
@ -357,11 +412,16 @@ static s32 e1000_init_mac_params_82575(struct e1000_hw *hw)
mac->rar_entry_count = E1000_RAR_ENTRIES_82576; mac->rar_entry_count = E1000_RAR_ENTRIES_82576;
if (mac->type == e1000_82580) if (mac->type == e1000_82580)
mac->rar_entry_count = E1000_RAR_ENTRIES_82580; mac->rar_entry_count = E1000_RAR_ENTRIES_82580;
if (mac->type == e1000_i350) { if (mac->type == e1000_i350 || mac->type == e1000_i354)
mac->rar_entry_count = E1000_RAR_ENTRIES_I350; mac->rar_entry_count = E1000_RAR_ENTRIES_I350;
/* Enable EEE default settings for i350 */
/* Enable EEE default settings for EEE supported devices */
if (mac->type >= e1000_i350)
dev_spec->eee_disable = false; dev_spec->eee_disable = false;
}
/* Allow a single clear of the SW semaphore on I210 and newer */
if (mac->type >= e1000_i210)
dev_spec->clear_semaphore_once = true;
/* Set if part includes ASF firmware */ /* Set if part includes ASF firmware */
mac->asf_firmware_present = true; mac->asf_firmware_present = true;
@ -394,15 +454,13 @@ static s32 e1000_init_mac_params_82575(struct e1000_hw *hw)
mac->ops.power_up_serdes = e1000_power_up_serdes_link_82575; mac->ops.power_up_serdes = e1000_power_up_serdes_link_82575;
/* check for link */ /* check for link */
mac->ops.check_for_link = e1000_check_for_link_82575; mac->ops.check_for_link = e1000_check_for_link_82575;
/* receive address register setting */
mac->ops.rar_set = e1000_rar_set_generic;
/* read mac address */ /* read mac address */
mac->ops.read_mac_addr = e1000_read_mac_addr_82575; mac->ops.read_mac_addr = e1000_read_mac_addr_82575;
/* configure collision distance */ /* configure collision distance */
mac->ops.config_collision_dist = e1000_config_collision_dist_82575; mac->ops.config_collision_dist = e1000_config_collision_dist_82575;
/* multicast address update */ /* multicast address update */
mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic; mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
if (hw->mac.type == e1000_i350) { if (hw->mac.type == e1000_i350 || mac->type == e1000_i354) {
/* writing VFTA */ /* writing VFTA */
mac->ops.write_vfta = e1000_write_vfta_i350; mac->ops.write_vfta = e1000_write_vfta_i350;
/* clearing VFTA */ /* clearing VFTA */
@ -413,6 +471,9 @@ static s32 e1000_init_mac_params_82575(struct e1000_hw *hw)
/* clearing VFTA */ /* clearing VFTA */
mac->ops.clear_vfta = e1000_clear_vfta_generic; mac->ops.clear_vfta = e1000_clear_vfta_generic;
} }
if (hw->mac.type >= e1000_82580)
mac->ops.validate_mdi_setting =
e1000_validate_mdi_setting_crossover_generic;
/* ID LED init */ /* ID LED init */
mac->ops.id_led_init = e1000_id_led_init_generic; mac->ops.id_led_init = e1000_id_led_init_generic;
/* blink LED */ /* blink LED */
@ -436,6 +497,10 @@ static s32 e1000_init_mac_params_82575(struct e1000_hw *hw)
/* acquire SW_FW sync */ /* acquire SW_FW sync */
mac->ops.acquire_swfw_sync = e1000_acquire_swfw_sync_82575; mac->ops.acquire_swfw_sync = e1000_acquire_swfw_sync_82575;
mac->ops.release_swfw_sync = e1000_release_swfw_sync_82575; mac->ops.release_swfw_sync = e1000_release_swfw_sync_82575;
if (mac->type >= e1000_i210) {
mac->ops.acquire_swfw_sync = e1000_acquire_swfw_sync_i210;
mac->ops.release_swfw_sync = e1000_release_swfw_sync_i210;
}
/* set lan id for port to determine which phy lock to use */ /* set lan id for port to determine which phy lock to use */
hw->mac.ops.set_lan_id(hw); hw->mac.ops.set_lan_id(hw);
@ -586,6 +651,11 @@ static s32 e1000_get_phy_id_82575(struct e1000_hw *hw)
DEBUGFUNC("e1000_get_phy_id_82575"); DEBUGFUNC("e1000_get_phy_id_82575");
/* i354 devices can have a PHY that needs an extra read for id */
if (hw->mac.type == e1000_i354)
e1000_get_phy_id(hw);
/* /*
* For SGMII PHYs, we try the list of possible addresses until * For SGMII PHYs, we try the list of possible addresses until
* we find one that works. For non-SGMII PHYs * we find one that works. For non-SGMII PHYs
@ -609,6 +679,9 @@ static s32 e1000_get_phy_id_82575(struct e1000_hw *hw)
break; break;
case e1000_82580: case e1000_82580:
case e1000_i350: case e1000_i350:
case e1000_i354:
case e1000_i210:
case e1000_i211:
mdic = E1000_READ_REG(hw, E1000_MDICNFG); mdic = E1000_READ_REG(hw, E1000_MDICNFG);
mdic &= E1000_MDICNFG_PHY_MASK; mdic &= E1000_MDICNFG_PHY_MASK;
phy->addr = mdic >> E1000_MDICNFG_PHY_SHIFT; phy->addr = mdic >> E1000_MDICNFG_PHY_SHIFT;
@ -804,7 +877,7 @@ static s32 e1000_set_d0_lplu_state_82580(struct e1000_hw *hw, bool active)
{ {
struct e1000_phy_info *phy = &hw->phy; struct e1000_phy_info *phy = &hw->phy;
s32 ret_val = E1000_SUCCESS; s32 ret_val = E1000_SUCCESS;
u16 data; u32 data;
DEBUGFUNC("e1000_set_d0_lplu_state_82580"); DEBUGFUNC("e1000_set_d0_lplu_state_82580");
@ -852,7 +925,7 @@ s32 e1000_set_d3_lplu_state_82580(struct e1000_hw *hw, bool active)
{ {
struct e1000_phy_info *phy = &hw->phy; struct e1000_phy_info *phy = &hw->phy;
s32 ret_val = E1000_SUCCESS; s32 ret_val = E1000_SUCCESS;
u16 data; u32 data;
DEBUGFUNC("e1000_set_d3_lplu_state_82580"); DEBUGFUNC("e1000_set_d3_lplu_state_82580");
@ -1060,7 +1133,7 @@ static s32 e1000_get_cfg_done_82575(struct e1000_hw *hw)
DEBUGOUT("MNG configuration cycle has not completed.\n"); DEBUGOUT("MNG configuration cycle has not completed.\n");
/* If EEPROM is not marked present, init the PHY manually */ /* If EEPROM is not marked present, init the PHY manually */
if (((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0) && if (!(E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) &&
(hw->phy.type == e1000_phy_igp_3)) (hw->phy.type == e1000_phy_igp_3))
e1000_phy_init_script_igp3(hw); e1000_phy_init_script_igp3(hw);
@ -1118,6 +1191,15 @@ static s32 e1000_check_for_link_82575(struct e1000_hw *hw)
*/ */
hw->mac.get_link_status = !hw->mac.serdes_has_link; hw->mac.get_link_status = !hw->mac.serdes_has_link;
/*
* Configure Flow Control now that Auto-Neg has completed.
* First, we need to restore the desired flow control
* settings because we may have had to re-autoneg with a
* different link partner.
*/
ret_val = e1000_config_fc_after_link_up_generic(hw);
if (ret_val)
DEBUGOUT("Error configuring flow control\n");
} else { } else {
ret_val = e1000_check_for_copper_link_generic(hw); ret_val = e1000_check_for_copper_link_generic(hw);
} }
@ -1125,6 +1207,56 @@ static s32 e1000_check_for_link_82575(struct e1000_hw *hw)
return ret_val; return ret_val;
} }
/**
* e1000_check_for_link_media_swap - Check which M88E1112 interface linked
* @hw: pointer to the HW structure
*
* Poll the M88E1112 interfaces to see which interface achieved link.
*/
static s32 e1000_check_for_link_media_swap(struct e1000_hw *hw)
{
struct e1000_phy_info *phy = &hw->phy;
s32 ret_val;
u16 data;
u8 port = 0;
DEBUGFUNC("e1000_check_for_link_media_swap");
/* Check the copper medium. */
ret_val = phy->ops.write_reg(hw, E1000_M88E1112_PAGE_ADDR, 0);
if (ret_val)
return ret_val;
ret_val = phy->ops.read_reg(hw, E1000_M88E1112_STATUS, &data);
if (ret_val)
return ret_val;
if (data & E1000_M88E1112_STATUS_LINK)
port = E1000_MEDIA_PORT_COPPER;
/* Check the other medium. */
ret_val = phy->ops.write_reg(hw, E1000_M88E1112_PAGE_ADDR, 1);
if (ret_val)
return ret_val;
ret_val = phy->ops.read_reg(hw, E1000_M88E1112_STATUS, &data);
if (ret_val)
return ret_val;
if (data & E1000_M88E1112_STATUS_LINK)
port = E1000_MEDIA_PORT_OTHER;
/* Determine if a swap needs to happen. */
if (port && (hw->dev_spec._82575.media_port != port)) {
hw->dev_spec._82575.media_port = port;
hw->dev_spec._82575.media_changed = true;
} else {
ret_val = e1000_check_for_link_82575(hw);
}
return E1000_SUCCESS;
}
/** /**
* e1000_power_up_serdes_link_82575 - Power up the serdes link after shutdown * e1000_power_up_serdes_link_82575 - Power up the serdes link after shutdown
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
@ -1168,14 +1300,10 @@ static s32 e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
{ {
struct e1000_mac_info *mac = &hw->mac; struct e1000_mac_info *mac = &hw->mac;
u32 pcs; u32 pcs;
u32 status;
DEBUGFUNC("e1000_get_pcs_speed_and_duplex_82575"); DEBUGFUNC("e1000_get_pcs_speed_and_duplex_82575");
/* Set up defaults for the return values of this function */
mac->serdes_has_link = false;
*speed = 0;
*duplex = 0;
/* /*
* Read the PCS Status register for link state. For non-copper mode, * Read the PCS Status register for link state. For non-copper mode,
* the status register is not accurate. The PCS status register is * the status register is not accurate. The PCS status register is
@ -1202,6 +1330,23 @@ static s32 e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
*duplex = FULL_DUPLEX; *duplex = FULL_DUPLEX;
else else
*duplex = HALF_DUPLEX; *duplex = HALF_DUPLEX;
/* Check if it is an I354 2.5Gb backplane connection. */
if (mac->type == e1000_i354) {
status = E1000_READ_REG(hw, E1000_STATUS);
if ((status & E1000_STATUS_2P5_SKU) &&
!(status & E1000_STATUS_2P5_SKU_OVER)) {
*speed = SPEED_2500;
*duplex = FULL_DUPLEX;
DEBUGOUT("2500 Mbs, ");
DEBUGOUT("Full Duplex\n");
}
}
} else {
mac->serdes_has_link = false;
*speed = 0;
*duplex = 0;
} }
return E1000_SUCCESS; return E1000_SUCCESS;
@ -1294,7 +1439,7 @@ static s32 e1000_reset_hw_82575(struct e1000_hw *hw)
} }
/* If EEPROM is not present, run manual init scripts */ /* If EEPROM is not present, run manual init scripts */
if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0) if (!(E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES))
e1000_reset_init_script_82575(hw); e1000_reset_init_script_82575(hw);
/* Clear any pending interrupt events. */ /* Clear any pending interrupt events. */
@ -1374,6 +1519,7 @@ static s32 e1000_setup_copper_link_82575(struct e1000_hw *hw)
{ {
u32 ctrl; u32 ctrl;
s32 ret_val; s32 ret_val;
u32 phpm_reg;
DEBUGFUNC("e1000_setup_copper_link_82575"); DEBUGFUNC("e1000_setup_copper_link_82575");
@ -1382,6 +1528,20 @@ static s32 e1000_setup_copper_link_82575(struct e1000_hw *hw)
ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
E1000_WRITE_REG(hw, E1000_CTRL, ctrl); E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
/* Clear Go Link Disconnect bit on supported devices */
switch (hw->mac.type) {
case e1000_82580:
case e1000_i350:
case e1000_i210:
case e1000_i211:
phpm_reg = E1000_READ_REG(hw, E1000_82580_PHY_POWER_MGMT);
phpm_reg &= ~E1000_82580_PM_GO_LINKD;
E1000_WRITE_REG(hw, E1000_82580_PHY_POWER_MGMT, phpm_reg);
break;
default:
break;
}
ret_val = e1000_setup_serdes_link_82575(hw); ret_val = e1000_setup_serdes_link_82575(hw);
if (ret_val) if (ret_val)
goto out; goto out;
@ -1397,14 +1557,21 @@ static s32 e1000_setup_copper_link_82575(struct e1000_hw *hw)
} }
} }
switch (hw->phy.type) { switch (hw->phy.type) {
case e1000_phy_i210:
case e1000_phy_m88: case e1000_phy_m88:
if (hw->phy.id == I347AT4_E_PHY_ID || switch (hw->phy.id) {
hw->phy.id == M88E1112_E_PHY_ID || case I347AT4_E_PHY_ID:
hw->phy.id == M88E1340M_E_PHY_ID) case M88E1112_E_PHY_ID:
case M88E1340M_E_PHY_ID:
case M88E1543_E_PHY_ID:
case I210_I_PHY_ID:
ret_val = e1000_copper_link_setup_m88_gen2(hw); ret_val = e1000_copper_link_setup_m88_gen2(hw);
else break;
default:
ret_val = e1000_copper_link_setup_m88(hw); ret_val = e1000_copper_link_setup_m88(hw);
break; break;
}
break;
case e1000_phy_igp_3: case e1000_phy_igp_3:
ret_val = e1000_copper_link_setup_igp(hw); ret_val = e1000_copper_link_setup_igp(hw);
break; break;
@ -1435,7 +1602,7 @@ static s32 e1000_setup_copper_link_82575(struct e1000_hw *hw)
**/ **/
static s32 e1000_setup_serdes_link_82575(struct e1000_hw *hw) static s32 e1000_setup_serdes_link_82575(struct e1000_hw *hw)
{ {
u32 ctrl_ext, ctrl_reg, reg; u32 ctrl_ext, ctrl_reg, reg, anadv_reg;
bool pcs_autoneg; bool pcs_autoneg;
s32 ret_val = E1000_SUCCESS; s32 ret_val = E1000_SUCCESS;
u16 data; u16 data;
@ -1519,26 +1686,47 @@ static s32 e1000_setup_serdes_link_82575(struct e1000_hw *hw)
reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP | reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP |
E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK); E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK);
/*
* We force flow control to prevent the CTRL register values from being
* overwritten by the autonegotiated flow control values
*/
reg |= E1000_PCS_LCTL_FORCE_FCTRL;
if (pcs_autoneg) { if (pcs_autoneg) {
/* Set PCS register for autoneg */ /* Set PCS register for autoneg */
reg |= E1000_PCS_LCTL_AN_ENABLE | /* Enable Autoneg */ reg |= E1000_PCS_LCTL_AN_ENABLE | /* Enable Autoneg */
E1000_PCS_LCTL_AN_RESTART; /* Restart autoneg */ E1000_PCS_LCTL_AN_RESTART; /* Restart autoneg */
/* Disable force flow control for autoneg */
reg &= ~E1000_PCS_LCTL_FORCE_FCTRL;
/* Configure flow control advertisement for autoneg */
anadv_reg = E1000_READ_REG(hw, E1000_PCS_ANADV);
anadv_reg &= ~(E1000_TXCW_ASM_DIR | E1000_TXCW_PAUSE);
switch (hw->fc.requested_mode) {
case e1000_fc_full:
case e1000_fc_rx_pause:
anadv_reg |= E1000_TXCW_ASM_DIR;
anadv_reg |= E1000_TXCW_PAUSE;
break;
case e1000_fc_tx_pause:
anadv_reg |= E1000_TXCW_ASM_DIR;
break;
default:
break;
}
E1000_WRITE_REG(hw, E1000_PCS_ANADV, anadv_reg);
DEBUGOUT1("Configuring Autoneg:PCS_LCTL=0x%08X\n", reg); DEBUGOUT1("Configuring Autoneg:PCS_LCTL=0x%08X\n", reg);
} else { } else {
/* Set PCS register for forced link */ /* Set PCS register for forced link */
reg |= E1000_PCS_LCTL_FSD; /* Force Speed */ reg |= E1000_PCS_LCTL_FSD; /* Force Speed */
/* Force flow control for forced link */
reg |= E1000_PCS_LCTL_FORCE_FCTRL;
DEBUGOUT1("Configuring Forced Link:PCS_LCTL=0x%08X\n", reg); DEBUGOUT1("Configuring Forced Link:PCS_LCTL=0x%08X\n", reg);
} }
E1000_WRITE_REG(hw, E1000_PCS_LCTL, reg); E1000_WRITE_REG(hw, E1000_PCS_LCTL, reg);
if (!e1000_sgmii_active_82575(hw)) if (!pcs_autoneg && !e1000_sgmii_active_82575(hw))
e1000_force_mac_fc_generic(hw); e1000_force_mac_fc_generic(hw);
return ret_val; return ret_val;
@ -1557,140 +1745,70 @@ static s32 e1000_setup_serdes_link_82575(struct e1000_hw *hw)
**/ **/
static s32 e1000_get_media_type_82575(struct e1000_hw *hw) static s32 e1000_get_media_type_82575(struct e1000_hw *hw)
{ {
u32 lan_id = 0;
s32 ret_val = E1000_ERR_CONFIG;
struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575; struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
s32 ret_val = E1000_SUCCESS;
u32 ctrl_ext = 0; u32 ctrl_ext = 0;
u32 current_link_mode = 0; u32 link_mode = 0;
u16 init_ctrl_wd_3 = 0;
u8 init_ctrl_wd_3_offset = 0;
u8 init_ctrl_wd_3_bit_offset = 0;
/* Set internal phy as default */ /* Set internal phy as default */
dev_spec->sgmii_active = false; dev_spec->sgmii_active = false;
dev_spec->module_plugged = false; dev_spec->module_plugged = false;
/*
* Check if NVM access method is attached already.
* If it is then Init Control Word #3 is considered
* otherwise runtime CSR register content is taken.
*/
/* Get CSR setting */ /* Get CSR setting */
ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT); ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
/* Get link mode setting */ /* extract link mode setting */
if ((hw->nvm.ops.read) && (hw->nvm.ops.read != e1000_null_read_nvm)) { link_mode = ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK;
/* Take link mode from EEPROM */
/*
* Get LAN port ID to derive its
* adequate Init Control Word #3
*/
lan_id = ((E1000_READ_REG(hw, E1000_STATUS) &
E1000_STATUS_LAN_ID_MASK) >> E1000_STATUS_LAN_ID_OFFSET);
/*
* Derive Init Control Word #3 offset
* and mask to pick up link mode setting.
*/
if (hw->mac.type < e1000_82580) {
init_ctrl_wd_3_offset = lan_id ?
NVM_INIT_CONTROL3_PORT_A : NVM_INIT_CONTROL3_PORT_B;
init_ctrl_wd_3_bit_offset = NVM_WORD24_LNK_MODE_OFFSET;
} else {
init_ctrl_wd_3_offset =
NVM_82580_LAN_FUNC_OFFSET(lan_id) +
NVM_INIT_CONTROL3_PORT_A;
init_ctrl_wd_3_bit_offset =
NVM_WORD24_82580_LNK_MODE_OFFSET;
}
/* Read Init Control Word #3*/
hw->nvm.ops.read(hw, init_ctrl_wd_3_offset, 1, &init_ctrl_wd_3);
current_link_mode = init_ctrl_wd_3;
/*
* Switch to CSR for all but internal PHY.
*/
if ((init_ctrl_wd_3 << (E1000_CTRL_EXT_LINK_MODE_OFFSET -
init_ctrl_wd_3_bit_offset)) !=
E1000_CTRL_EXT_LINK_MODE_GMII) {
current_link_mode = ctrl_ext;
init_ctrl_wd_3_bit_offset =
E1000_CTRL_EXT_LINK_MODE_OFFSET;
}
} else {
/* Take link mode from CSR */
current_link_mode = ctrl_ext;
init_ctrl_wd_3_bit_offset = E1000_CTRL_EXT_LINK_MODE_OFFSET;
}
/*
* Align link mode bits to
* their CTRL_EXT location.
*/
current_link_mode <<= (E1000_CTRL_EXT_LINK_MODE_OFFSET -
init_ctrl_wd_3_bit_offset);
current_link_mode &= E1000_CTRL_EXT_LINK_MODE_MASK;
switch (current_link_mode) {
switch (link_mode) {
case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX: case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX:
hw->phy.media_type = e1000_media_type_internal_serdes; hw->phy.media_type = e1000_media_type_internal_serdes;
current_link_mode = E1000_CTRL_EXT_LINK_MODE_1000BASE_KX;
break; break;
case E1000_CTRL_EXT_LINK_MODE_GMII: case E1000_CTRL_EXT_LINK_MODE_GMII:
hw->phy.media_type = e1000_media_type_copper; hw->phy.media_type = e1000_media_type_copper;
current_link_mode = E1000_CTRL_EXT_LINK_MODE_GMII;
break; break;
case E1000_CTRL_EXT_LINK_MODE_SGMII: case E1000_CTRL_EXT_LINK_MODE_SGMII:
case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
/* Get phy control interface type set (MDIO vs. I2C)*/ /* Get phy control interface type set (MDIO vs. I2C)*/
if (e1000_sgmii_uses_mdio_82575(hw)) { if (e1000_sgmii_uses_mdio_82575(hw)) {
hw->phy.media_type = e1000_media_type_copper; hw->phy.media_type = e1000_media_type_copper;
dev_spec->sgmii_active = true; dev_spec->sgmii_active = true;
current_link_mode = E1000_CTRL_EXT_LINK_MODE_SGMII;
} else {
ret_val = e1000_set_sfp_media_type_82575(hw);
if (ret_val != E1000_SUCCESS)
goto out;
if (hw->phy.media_type ==
e1000_media_type_internal_serdes) {
current_link_mode =
E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES;
} else if (hw->phy.media_type ==
e1000_media_type_copper) {
current_link_mode =
E1000_CTRL_EXT_LINK_MODE_SGMII;
}
}
break; break;
default:
DEBUGOUT("Link mode mask doesn't fit bit field size\n");
goto out;
} }
/* fall through for I2C based SGMII */
case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
/* read media type from SFP EEPROM */
ret_val = e1000_set_sfp_media_type_82575(hw);
if ((ret_val != E1000_SUCCESS) ||
(hw->phy.media_type == e1000_media_type_unknown)) {
/* /*
* Do not change current link mode setting * If media type was not identified then return media
* if media type is fibre or has not been * type defined by the CTRL_EXT settings.
* recognized.
*/ */
if ((hw->phy.media_type != e1000_media_type_unknown) && hw->phy.media_type = e1000_media_type_internal_serdes;
(hw->phy.media_type != e1000_media_type_fiber)) {
/* Update link mode */ if (link_mode == E1000_CTRL_EXT_LINK_MODE_SGMII) {
ctrl_ext &= ~E1000_CTRL_EXT_LINK_MODE_MASK; hw->phy.media_type = e1000_media_type_copper;
E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext | dev_spec->sgmii_active = true;
current_link_mode);
} }
ret_val = E1000_SUCCESS; break;
out: }
/*
* If media type was not identified then return media type /* do not change link mode for 100BaseFX */
* defined by the CTRL_EXT settings. if (dev_spec->eth_flags.e100_base_fx)
*/ break;
if (hw->phy.media_type == e1000_media_type_unknown) {
if (current_link_mode == E1000_CTRL_EXT_LINK_MODE_SGMII) /* change current link mode setting */
hw->phy.media_type = e1000_media_type_copper; ctrl_ext &= ~E1000_CTRL_EXT_LINK_MODE_MASK;
if (hw->phy.media_type == e1000_media_type_copper)
ctrl_ext |= E1000_CTRL_EXT_LINK_MODE_SGMII;
else else
hw->phy.media_type = e1000_media_type_internal_serdes; ctrl_ext |= E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES;
E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
break;
} }
return ret_val; return ret_val;
@ -1708,34 +1826,46 @@ static s32 e1000_set_sfp_media_type_82575(struct e1000_hw *hw)
s32 ret_val = E1000_ERR_CONFIG; s32 ret_val = E1000_ERR_CONFIG;
u32 ctrl_ext = 0; u32 ctrl_ext = 0;
struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575; struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
struct sfp_e1000_flags eth_flags = {0}; struct sfp_e1000_flags *eth_flags = &dev_spec->eth_flags;
u8 tranceiver_type = 0; u8 tranceiver_type = 0;
s32 timeout = 3;
/* Turn I2C interface ON */ /* Turn I2C interface ON and power on sfp cage */
ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT); ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
ctrl_ext &= ~E1000_CTRL_EXT_SDP3_DATA;
E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext | E1000_CTRL_I2C_ENA); E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext | E1000_CTRL_I2C_ENA);
E1000_WRITE_FLUSH(hw);
/* Read SFP module data */ /* Read SFP module data */
while (timeout) {
ret_val = e1000_read_sfp_data_byte(hw, ret_val = e1000_read_sfp_data_byte(hw,
E1000_I2CCMD_SFP_DATA_ADDR(E1000_SFF_IDENTIFIER_OFFSET), E1000_I2CCMD_SFP_DATA_ADDR(E1000_SFF_IDENTIFIER_OFFSET),
&tranceiver_type); &tranceiver_type);
if (ret_val == E1000_SUCCESS)
break;
msec_delay(100);
timeout--;
}
if (ret_val != E1000_SUCCESS) if (ret_val != E1000_SUCCESS)
goto out; goto out;
ret_val = e1000_read_sfp_data_byte(hw, ret_val = e1000_read_sfp_data_byte(hw,
E1000_I2CCMD_SFP_DATA_ADDR(E1000_SFF_ETH_FLAGS_OFFSET), E1000_I2CCMD_SFP_DATA_ADDR(E1000_SFF_ETH_FLAGS_OFFSET),
(u8 *)&eth_flags); (u8 *)eth_flags);
if (ret_val != E1000_SUCCESS) if (ret_val != E1000_SUCCESS)
goto out; goto out;
/*
* Check if there is some SFP /* Check if there is some SFP module plugged and powered */
* module plugged and powered
*/
if ((tranceiver_type == E1000_SFF_IDENTIFIER_SFP) || if ((tranceiver_type == E1000_SFF_IDENTIFIER_SFP) ||
(tranceiver_type == E1000_SFF_IDENTIFIER_SFF)) { (tranceiver_type == E1000_SFF_IDENTIFIER_SFF)) {
dev_spec->module_plugged = true; dev_spec->module_plugged = true;
if (eth_flags.e1000_base_lx || eth_flags.e1000_base_sx) { if (eth_flags->e1000_base_lx || eth_flags->e1000_base_sx) {
hw->phy.media_type = e1000_media_type_internal_serdes; hw->phy.media_type = e1000_media_type_internal_serdes;
} else if (eth_flags.e1000_base_t) { } else if (eth_flags->e100_base_fx) {
dev_spec->sgmii_active = true;
hw->phy.media_type = e1000_media_type_internal_serdes;
} else if (eth_flags->e1000_base_t) {
dev_spec->sgmii_active = true; dev_spec->sgmii_active = true;
hw->phy.media_type = e1000_media_type_copper; hw->phy.media_type = e1000_media_type_copper;
} else { } else {
@ -2108,42 +2238,33 @@ static s32 e1000_set_pcie_completion_timeout(struct e1000_hw *hw)
**/ **/
void e1000_vmdq_set_anti_spoofing_pf(struct e1000_hw *hw, bool enable, int pf) void e1000_vmdq_set_anti_spoofing_pf(struct e1000_hw *hw, bool enable, int pf)
{ {
u32 dtxswc; u32 reg_val, reg_offset;
switch (hw->mac.type) { switch (hw->mac.type) {
case e1000_82576: case e1000_82576:
dtxswc = E1000_READ_REG(hw, E1000_DTXSWC); reg_offset = E1000_DTXSWC;
if (enable) {
dtxswc |= (E1000_DTXSWC_MAC_SPOOF_MASK |
E1000_DTXSWC_VLAN_SPOOF_MASK);
/* The PF can spoof - it has to in order to
* support emulation mode NICs */
dtxswc ^= (1 << pf | 1 << (pf +
E1000_DTXSWC_VLAN_SPOOF_SHIFT));
} else {
dtxswc &= ~(E1000_DTXSWC_MAC_SPOOF_MASK |
E1000_DTXSWC_VLAN_SPOOF_MASK);
}
E1000_WRITE_REG(hw, E1000_DTXSWC, dtxswc);
break; break;
case e1000_i350: case e1000_i350:
dtxswc = E1000_READ_REG(hw, E1000_TXSWC); case e1000_i354:
reg_offset = E1000_TXSWC;
break;
default:
return;
}
reg_val = E1000_READ_REG(hw, reg_offset);
if (enable) { if (enable) {
dtxswc |= (E1000_DTXSWC_MAC_SPOOF_MASK | reg_val |= (E1000_DTXSWC_MAC_SPOOF_MASK |
E1000_DTXSWC_VLAN_SPOOF_MASK); E1000_DTXSWC_VLAN_SPOOF_MASK);
/* The PF can spoof - it has to in order to /* The PF can spoof - it has to in order to
* support emulation mode NICs * support emulation mode NICs
*/ */
dtxswc ^= (1 << pf | 1 << (pf + reg_val ^= (1 << pf | 1 << (pf + MAX_NUM_VFS));
E1000_DTXSWC_VLAN_SPOOF_SHIFT));
} else { } else {
dtxswc &= ~(E1000_DTXSWC_MAC_SPOOF_MASK | reg_val &= ~(E1000_DTXSWC_MAC_SPOOF_MASK |
E1000_DTXSWC_VLAN_SPOOF_MASK); E1000_DTXSWC_VLAN_SPOOF_MASK);
} }
E1000_WRITE_REG(hw, E1000_TXSWC, dtxswc); E1000_WRITE_REG(hw, reg_offset, reg_val);
default:
break;
}
} }
/** /**
@ -2167,6 +2288,7 @@ void e1000_vmdq_set_loopback_pf(struct e1000_hw *hw, bool enable)
E1000_WRITE_REG(hw, E1000_DTXSWC, dtxswc); E1000_WRITE_REG(hw, E1000_DTXSWC, dtxswc);
break; break;
case e1000_i350: case e1000_i350:
case e1000_i354:
dtxswc = E1000_READ_REG(hw, E1000_TXSWC); dtxswc = E1000_READ_REG(hw, E1000_TXSWC);
if (enable) if (enable)
dtxswc |= E1000_DTXSWC_VMDQ_LOOPBACK_EN; dtxswc |= E1000_DTXSWC_VMDQ_LOOPBACK_EN;
@ -2312,6 +2434,10 @@ static s32 e1000_reset_hw_82580(struct e1000_hw *hw)
hw->dev_spec._82575.global_device_reset = false; hw->dev_spec._82575.global_device_reset = false;
/* 82580 does not reliably do global_device_reset due to hw errata */
if (hw->mac.type == e1000_82580)
global_device_reset = false;
/* Get current control state. */ /* Get current control state. */
ctrl = E1000_READ_REG(hw, E1000_CTRL); ctrl = E1000_READ_REG(hw, E1000_CTRL);
@ -2359,10 +2485,6 @@ static s32 e1000_reset_hw_82580(struct e1000_hw *hw)
DEBUGOUT("Auto Read Done did not complete\n"); DEBUGOUT("Auto Read Done did not complete\n");
} }
/* If EEPROM is not present, run manual init scripts */
if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0)
e1000_reset_init_script_82575(hw);
/* clear global device reset status bit */ /* clear global device reset status bit */
E1000_WRITE_REG(hw, E1000_STATUS, E1000_STAT_DEV_RST_SET); E1000_WRITE_REG(hw, E1000_STATUS, E1000_STAT_DEV_RST_SET);
@ -2539,7 +2661,7 @@ static s32 e1000_update_nvm_checksum_82580(struct e1000_hw *hw)
goto out; goto out;
} }
if ((nvm_data & NVM_COMPATIBILITY_BIT_MASK) == 0) { if (!(nvm_data & NVM_COMPATIBILITY_BIT_MASK)) {
/* set compatibility bit to validate checksums appropriately */ /* set compatibility bit to validate checksums appropriately */
nvm_data = nvm_data | NVM_COMPATIBILITY_BIT_MASK; nvm_data = nvm_data | NVM_COMPATIBILITY_BIT_MASK;
ret_val = hw->nvm.ops.write(hw, NVM_COMPATIBILITY_REG_3, 1, ret_val = hw->nvm.ops.write(hw, NVM_COMPATIBILITY_REG_3, 1,
@ -2616,6 +2738,45 @@ static s32 e1000_update_nvm_checksum_i350(struct e1000_hw *hw)
return ret_val; return ret_val;
} }
/**
* __e1000_access_emi_reg - Read/write EMI register
* @hw: pointer to the HW structure
* @addr: EMI address to program
* @data: pointer to value to read/write from/to the EMI address
* @read: boolean flag to indicate read or write
**/
static s32 __e1000_access_emi_reg(struct e1000_hw *hw, u16 address,
u16 *data, bool read)
{
s32 ret_val = E1000_SUCCESS;
DEBUGFUNC("__e1000_access_emi_reg");
ret_val = hw->phy.ops.write_reg(hw, E1000_EMIADD, address);
if (ret_val)
return ret_val;
if (read)
ret_val = hw->phy.ops.read_reg(hw, E1000_EMIDATA, data);
else
ret_val = hw->phy.ops.write_reg(hw, E1000_EMIDATA, *data);
return ret_val;
}
/**
* e1000_read_emi_reg - Read Extended Management Interface register
* @hw: pointer to the HW structure
* @addr: EMI address to program
* @data: value to be read from the EMI address
**/
s32 e1000_read_emi_reg(struct e1000_hw *hw, u16 addr, u16 *data)
{
DEBUGFUNC("e1000_read_emi_reg");
return __e1000_access_emi_reg(hw, addr, data, true);
}
/** /**
* e1000_set_eee_i350 - Enable/disable EEE support * e1000_set_eee_i350 - Enable/disable EEE support
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
@ -2638,10 +2799,15 @@ s32 e1000_set_eee_i350(struct e1000_hw *hw)
/* enable or disable per user setting */ /* enable or disable per user setting */
if (!(hw->dev_spec._82575.eee_disable)) { if (!(hw->dev_spec._82575.eee_disable)) {
u32 eee_su = E1000_READ_REG(hw, E1000_EEE_SU);
ipcnfg |= (E1000_IPCNFG_EEE_1G_AN | E1000_IPCNFG_EEE_100M_AN); ipcnfg |= (E1000_IPCNFG_EEE_1G_AN | E1000_IPCNFG_EEE_100M_AN);
eeer |= (E1000_EEER_TX_LPI_EN | E1000_EEER_RX_LPI_EN | eeer |= (E1000_EEER_TX_LPI_EN | E1000_EEER_RX_LPI_EN |
E1000_EEER_LPI_FC); E1000_EEER_LPI_FC);
/* This bit should not be set in normal operation. */
if (eee_su & E1000_EEE_SU_LPI_CLK_STP)
DEBUGOUT("LPI Clock Stop Bit should not be set!\n");
} else { } else {
ipcnfg &= ~(E1000_IPCNFG_EEE_1G_AN | E1000_IPCNFG_EEE_100M_AN); ipcnfg &= ~(E1000_IPCNFG_EEE_1G_AN | E1000_IPCNFG_EEE_100M_AN);
eeer &= ~(E1000_EEER_TX_LPI_EN | E1000_EEER_RX_LPI_EN | eeer &= ~(E1000_EEER_TX_LPI_EN | E1000_EEER_RX_LPI_EN |
@ -2656,6 +2822,112 @@ s32 e1000_set_eee_i350(struct e1000_hw *hw)
return ret_val; return ret_val;
} }
/**
* e1000_set_eee_i354 - Enable/disable EEE support
* @hw: pointer to the HW structure
*
* Enable/disable EEE legacy mode based on setting in dev_spec structure.
*
**/
s32 e1000_set_eee_i354(struct e1000_hw *hw)
{
struct e1000_phy_info *phy = &hw->phy;
s32 ret_val = E1000_SUCCESS;
u16 phy_data;
DEBUGFUNC("e1000_set_eee_i354");
if ((hw->phy.media_type != e1000_media_type_copper) ||
((phy->id != M88E1543_E_PHY_ID)))
goto out;
if (!hw->dev_spec._82575.eee_disable) {
/* Switch to PHY page 18. */
ret_val = phy->ops.write_reg(hw, E1000_M88E1543_PAGE_ADDR, 18);
if (ret_val)
goto out;
ret_val = phy->ops.read_reg(hw, E1000_M88E1543_EEE_CTRL_1,
&phy_data);
if (ret_val)
goto out;
phy_data |= E1000_M88E1543_EEE_CTRL_1_MS;
ret_val = phy->ops.write_reg(hw, E1000_M88E1543_EEE_CTRL_1,
phy_data);
if (ret_val)
goto out;
/* Return the PHY to page 0. */
ret_val = phy->ops.write_reg(hw, E1000_M88E1543_PAGE_ADDR, 0);
if (ret_val)
goto out;
/* Turn on EEE advertisement. */
ret_val = e1000_read_xmdio_reg(hw, E1000_EEE_ADV_ADDR_I354,
E1000_EEE_ADV_DEV_I354,
&phy_data);
if (ret_val)
goto out;
phy_data |= E1000_EEE_ADV_100_SUPPORTED |
E1000_EEE_ADV_1000_SUPPORTED;
ret_val = e1000_write_xmdio_reg(hw, E1000_EEE_ADV_ADDR_I354,
E1000_EEE_ADV_DEV_I354,
phy_data);
} else {
/* Turn off EEE advertisement. */
ret_val = e1000_read_xmdio_reg(hw, E1000_EEE_ADV_ADDR_I354,
E1000_EEE_ADV_DEV_I354,
&phy_data);
if (ret_val)
goto out;
phy_data &= ~(E1000_EEE_ADV_100_SUPPORTED |
E1000_EEE_ADV_1000_SUPPORTED);
ret_val = e1000_write_xmdio_reg(hw, E1000_EEE_ADV_ADDR_I354,
E1000_EEE_ADV_DEV_I354,
phy_data);
}
out:
return ret_val;
}
/**
* e1000_get_eee_status_i354 - Get EEE status
* @hw: pointer to the HW structure
* @status: EEE status
*
* Get EEE status by guessing based on whether Tx or Rx LPI indications have
* been received.
**/
s32 e1000_get_eee_status_i354(struct e1000_hw *hw, bool *status)
{
struct e1000_phy_info *phy = &hw->phy;
s32 ret_val = E1000_SUCCESS;
u16 phy_data;
DEBUGFUNC("e1000_get_eee_status_i354");
/* Check if EEE is supported on this device. */
if ((hw->phy.media_type != e1000_media_type_copper) ||
((phy->id != M88E1543_E_PHY_ID)))
goto out;
ret_val = e1000_read_xmdio_reg(hw, E1000_PCS_STATUS_ADDR_I354,
E1000_PCS_STATUS_DEV_I354,
&phy_data);
if (ret_val)
goto out;
*status = phy_data & (E1000_PCS_STATUS_TX_LPI_RCVD |
E1000_PCS_STATUS_RX_LPI_RCVD) ? true : false;
out:
return ret_val;
}
/* Due to a hw errata, if the host tries to configure the VFTA register /* Due to a hw errata, if the host tries to configure the VFTA register
* while performing queries from the BMC or DMA, then the VFTA in some * while performing queries from the BMC or DMA, then the VFTA in some
* cases won't be written. * cases won't be written.
@ -2752,7 +3024,7 @@ s32 e1000_read_i2c_byte_generic(struct e1000_hw *hw, u8 byte_offset,
u32 retry = 1; u32 retry = 1;
u16 swfw_mask = 0; u16 swfw_mask = 0;
bool nack = 1; bool nack = true;
DEBUGFUNC("e1000_read_i2c_byte_generic"); DEBUGFUNC("e1000_read_i2c_byte_generic");
@ -3023,7 +3295,7 @@ static s32 e1000_get_i2c_ack(struct e1000_hw *hw)
u32 i = 0; u32 i = 0;
u32 i2cctl = E1000_READ_REG(hw, E1000_I2CPARAMS); u32 i2cctl = E1000_READ_REG(hw, E1000_I2CPARAMS);
u32 timeout = 10; u32 timeout = 10;
bool ack = 1; bool ack = true;
DEBUGFUNC("e1000_get_i2c_ack"); DEBUGFUNC("e1000_get_i2c_ack");
@ -3043,7 +3315,7 @@ static s32 e1000_get_i2c_ack(struct e1000_hw *hw)
return E1000_ERR_I2C; return E1000_ERR_I2C;
ack = e1000_get_i2c_data(&i2cctl); ack = e1000_get_i2c_data(&i2cctl);
if (ack == 1) { if (ack) {
DEBUGOUT("I2C ack was not received.\n"); DEBUGOUT("I2C ack was not received.\n");
status = E1000_ERR_I2C; status = E1000_ERR_I2C;
} }

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -351,10 +351,13 @@ struct e1000_adv_tx_context_desc {
#define E1000_DCA_RXCTRL_DESC_DCA_EN (1 << 5) /* DCA Rx Desc enable */ #define E1000_DCA_RXCTRL_DESC_DCA_EN (1 << 5) /* DCA Rx Desc enable */
#define E1000_DCA_RXCTRL_HEAD_DCA_EN (1 << 6) /* DCA Rx Desc header ena */ #define E1000_DCA_RXCTRL_HEAD_DCA_EN (1 << 6) /* DCA Rx Desc header ena */
#define E1000_DCA_RXCTRL_DATA_DCA_EN (1 << 7) /* DCA Rx Desc payload ena */ #define E1000_DCA_RXCTRL_DATA_DCA_EN (1 << 7) /* DCA Rx Desc payload ena */
#define E1000_DCA_RXCTRL_DESC_RRO_EN (1 << 9) /* DCA Rx Desc Relax Order */
#define E1000_DCA_TXCTRL_CPUID_MASK 0x0000001F /* Tx CPUID Mask */ #define E1000_DCA_TXCTRL_CPUID_MASK 0x0000001F /* Tx CPUID Mask */
#define E1000_DCA_TXCTRL_DESC_DCA_EN (1 << 5) /* DCA Tx Desc enable */ #define E1000_DCA_TXCTRL_DESC_DCA_EN (1 << 5) /* DCA Tx Desc enable */
#define E1000_DCA_TXCTRL_DESC_RRO_EN (1 << 9) /* Tx rd Desc Relax Order */
#define E1000_DCA_TXCTRL_TX_WB_RO_EN (1 << 11) /* Tx Desc writeback RO bit */ #define E1000_DCA_TXCTRL_TX_WB_RO_EN (1 << 11) /* Tx Desc writeback RO bit */
#define E1000_DCA_TXCTRL_DATA_RRO_EN (1 << 13) /* Tx rd data Relax Order */
#define E1000_DCA_TXCTRL_CPUID_MASK_82576 0xFF000000 /* Tx CPUID Mask */ #define E1000_DCA_TXCTRL_CPUID_MASK_82576 0xFF000000 /* Tx CPUID Mask */
#define E1000_DCA_RXCTRL_CPUID_MASK_82576 0xFF000000 /* Rx CPUID Mask */ #define E1000_DCA_RXCTRL_CPUID_MASK_82576 0xFF000000 /* Rx CPUID Mask */
@ -468,7 +471,10 @@ void e1000_vmdq_set_replication_pf(struct e1000_hw *hw, bool enable);
s32 e1000_init_nvm_params_82575(struct e1000_hw *hw); s32 e1000_init_nvm_params_82575(struct e1000_hw *hw);
u16 e1000_rxpbs_adjust_82580(u32 data); u16 e1000_rxpbs_adjust_82580(u32 data);
s32 e1000_read_emi_reg(struct e1000_hw *hw, u16 addr, u16 *data);
s32 e1000_set_eee_i350(struct e1000_hw *); s32 e1000_set_eee_i350(struct e1000_hw *);
s32 e1000_set_eee_i354(struct e1000_hw *);
s32 e1000_get_eee_status_i354(struct e1000_hw *, bool *);
#define E1000_I2C_THERMAL_SENSOR_ADDR 0xF8 #define E1000_I2C_THERMAL_SENSOR_ADDR 0xF8
#define E1000_EMC_INTERNAL_DATA 0x00 #define E1000_EMC_INTERNAL_DATA 0x00
#define E1000_EMC_INTERNAL_THERM_LIMIT 0x20 #define E1000_EMC_INTERNAL_THERM_LIMIT 0x20

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -182,12 +182,25 @@ s32 e1000_set_mac_type(struct e1000_hw *hw)
case E1000_DEV_ID_I350_DA4: case E1000_DEV_ID_I350_DA4:
mac->type = e1000_i350; mac->type = e1000_i350;
break; break;
case E1000_DEV_ID_I210_COPPER_FLASHLESS:
case E1000_DEV_ID_I210_SERDES_FLASHLESS:
case E1000_DEV_ID_I210_COPPER:
case E1000_DEV_ID_I210_COPPER_OEM1:
case E1000_DEV_ID_I210_COPPER_IT:
case E1000_DEV_ID_I210_FIBER:
case E1000_DEV_ID_I210_SERDES:
case E1000_DEV_ID_I210_SGMII:
mac->type = e1000_i210;
break;
case E1000_DEV_ID_I211_COPPER:
mac->type = e1000_i211;
break;
case E1000_DEV_ID_I354_BACKPLANE_1GBPS: case E1000_DEV_ID_I354_BACKPLANE_1GBPS:
case E1000_DEV_ID_I354_SGMII: case E1000_DEV_ID_I354_SGMII:
case E1000_DEV_ID_I354_BACKPLANE_2_5GBPS: case E1000_DEV_ID_I354_BACKPLANE_2_5GBPS:
mac->type = e1000_i354; mac->type = e1000_i354;
break; break;
default: default:
/* Should never have loaded on this device */ /* Should never have loaded on this device */
ret_val = -E1000_ERR_MAC_INIT; ret_val = -E1000_ERR_MAC_INIT;
@ -245,8 +258,13 @@ s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
case e1000_82576: case e1000_82576:
case e1000_82580: case e1000_82580:
case e1000_i350: case e1000_i350:
case e1000_i354:
e1000_init_function_pointers_82575(hw); e1000_init_function_pointers_82575(hw);
break; break;
case e1000_i210:
case e1000_i211:
e1000_init_function_pointers_i210(hw);
break;
default: default:
DEBUGOUT("Hardware not supported\n"); DEBUGOUT("Hardware not supported\n");
ret_val = -E1000_ERR_CONFIG; ret_val = -E1000_ERR_CONFIG;
@ -674,11 +692,7 @@ bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length, s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
u16 offset, u8 *sum) u16 offset, u8 *sum)
{ {
if (hw->mac.ops.mng_host_if_write) return e1000_mng_host_if_write_generic(hw, buffer, length, offset, sum);
return hw->mac.ops.mng_host_if_write(hw, buffer, length,
offset, sum);
return E1000_NOT_IMPLEMENTED;
} }
/** /**
@ -691,10 +705,7 @@ s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
s32 e1000_mng_write_cmd_header(struct e1000_hw *hw, s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
struct e1000_host_mng_command_header *hdr) struct e1000_host_mng_command_header *hdr)
{ {
if (hw->mac.ops.mng_write_cmd_header) return e1000_mng_write_cmd_header_generic(hw, hdr);
return hw->mac.ops.mng_write_cmd_header(hw, hdr);
return E1000_NOT_IMPLEMENTED;
} }
/** /**
@ -709,25 +720,7 @@ s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
**/ **/
s32 e1000_mng_enable_host_if(struct e1000_hw *hw) s32 e1000_mng_enable_host_if(struct e1000_hw *hw)
{ {
if (hw->mac.ops.mng_enable_host_if) return e1000_mng_enable_host_if_generic(hw);
return hw->mac.ops.mng_enable_host_if(hw);
return E1000_NOT_IMPLEMENTED;
}
/**
* e1000_wait_autoneg - Waits for autonegotiation completion
* @hw: pointer to the HW structure
*
* Waits for autoneg to complete. Currently no func pointer exists and all
* implementations are handled in the generic version of this function.
**/
s32 e1000_wait_autoneg(struct e1000_hw *hw)
{
if (hw->mac.ops.wait_autoneg)
return hw->mac.ops.wait_autoneg(hw);
return E1000_SUCCESS;
} }
/** /**
@ -1164,3 +1157,4 @@ s32 e1000_init_thermal_sensor_thresh(struct e1000_hw *hw)
return E1000_SUCCESS; return E1000_SUCCESS;
} }

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -35,7 +35,9 @@ extern void e1000_rx_fifo_flush_82575(struct e1000_hw *hw);
extern void e1000_init_function_pointers_vf(struct e1000_hw *hw); extern void e1000_init_function_pointers_vf(struct e1000_hw *hw);
extern void e1000_power_up_fiber_serdes_link(struct e1000_hw *hw); extern void e1000_power_up_fiber_serdes_link(struct e1000_hw *hw);
extern void e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw); extern void e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw);
extern void e1000_init_function_pointers_i210(struct e1000_hw *hw);
s32 e1000_set_obff_timer(struct e1000_hw *hw, u32 itr);
s32 e1000_set_mac_type(struct e1000_hw *hw); s32 e1000_set_mac_type(struct e1000_hw *hw);
s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device); s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device);
s32 e1000_init_mac_params(struct e1000_hw *hw); s32 e1000_init_mac_params(struct e1000_hw *hw);
@ -89,7 +91,6 @@ s32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data); s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data);
s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data); s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data);
s32 e1000_write_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);
s32 e1000_wait_autoneg(struct e1000_hw *hw);
s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active); s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active);
s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active); s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active);
bool e1000_check_mng_mode(struct e1000_hw *hw); bool e1000_check_mng_mode(struct e1000_hw *hw);
@ -147,4 +148,10 @@ s32 e1000_init_thermal_sensor_thresh(struct e1000_hw *hw);
(((length) > min_frame_size) && \ (((length) > min_frame_size) && \
((length) <= (max_frame_size + VLAN_TAG_SIZE + 1))))) ((length) <= (max_frame_size + VLAN_TAG_SIZE + 1)))))
#ifndef E1000_MAX
#define E1000_MAX(a, b) ((a) > (b) ? (a) : (b))
#endif #endif
#ifndef E1000_DIVIDE_ROUND_UP
#define E1000_DIVIDE_ROUND_UP(a, b) (((a) + (b) - 1) / (b)) /* ceil(a/b) */
#endif
#endif /* _E1000_API_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -56,6 +56,15 @@ struct e1000_hw;
#define E1000_DEV_ID_I350_SERDES 0x1523 #define E1000_DEV_ID_I350_SERDES 0x1523
#define E1000_DEV_ID_I350_SGMII 0x1524 #define E1000_DEV_ID_I350_SGMII 0x1524
#define E1000_DEV_ID_I350_DA4 0x1546 #define E1000_DEV_ID_I350_DA4 0x1546
#define E1000_DEV_ID_I210_COPPER 0x1533
#define E1000_DEV_ID_I210_COPPER_OEM1 0x1534
#define E1000_DEV_ID_I210_COPPER_IT 0x1535
#define E1000_DEV_ID_I210_FIBER 0x1536
#define E1000_DEV_ID_I210_SERDES 0x1537
#define E1000_DEV_ID_I210_SGMII 0x1538
#define E1000_DEV_ID_I210_COPPER_FLASHLESS 0x157B
#define E1000_DEV_ID_I210_SERDES_FLASHLESS 0x157C
#define E1000_DEV_ID_I211_COPPER 0x1539
#define E1000_DEV_ID_I354_BACKPLANE_1GBPS 0x1F40 #define E1000_DEV_ID_I354_BACKPLANE_1GBPS 0x1F40
#define E1000_DEV_ID_I354_SGMII 0x1F41 #define E1000_DEV_ID_I354_SGMII 0x1F41
#define E1000_DEV_ID_I354_BACKPLANE_2_5GBPS 0x1F45 #define E1000_DEV_ID_I354_BACKPLANE_2_5GBPS 0x1F45
@ -63,6 +72,7 @@ struct e1000_hw;
#define E1000_DEV_ID_DH89XXCC_SERDES 0x043A #define E1000_DEV_ID_DH89XXCC_SERDES 0x043A
#define E1000_DEV_ID_DH89XXCC_BACKPLANE 0x043C #define E1000_DEV_ID_DH89XXCC_BACKPLANE 0x043C
#define E1000_DEV_ID_DH89XXCC_SFP 0x0440 #define E1000_DEV_ID_DH89XXCC_SFP 0x0440
#define E1000_REVISION_0 0 #define E1000_REVISION_0 0
#define E1000_REVISION_1 1 #define E1000_REVISION_1 1
#define E1000_REVISION_2 2 #define E1000_REVISION_2 2
@ -86,6 +96,8 @@ enum e1000_mac_type {
e1000_82580, e1000_82580,
e1000_i350, e1000_i350,
e1000_i354, e1000_i354,
e1000_i210,
e1000_i211,
e1000_num_macs /* List is 1-based, so subtract 1 for true count. */ e1000_num_macs /* List is 1-based, so subtract 1 for true count. */
}; };
@ -102,6 +114,7 @@ enum e1000_nvm_type {
e1000_nvm_none, e1000_nvm_none,
e1000_nvm_eeprom_spi, e1000_nvm_eeprom_spi,
e1000_nvm_flash_hw, e1000_nvm_flash_hw,
e1000_nvm_invm,
e1000_nvm_flash_sw e1000_nvm_flash_sw
}; };
@ -122,6 +135,7 @@ enum e1000_phy_type {
e1000_phy_ife, e1000_phy_ife,
e1000_phy_82580, e1000_phy_82580,
e1000_phy_vf, e1000_phy_vf,
e1000_phy_i210,
}; };
enum e1000_bus_type { enum e1000_bus_type {
@ -240,6 +254,10 @@ union e1000_rx_desc_extended {
}; };
#define MAX_PS_BUFFERS 4 #define MAX_PS_BUFFERS 4
/* Number of packet split data buffers (not including the header buffer) */
#define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
/* Receive Descriptor - Packet Split */ /* Receive Descriptor - Packet Split */
union e1000_rx_desc_packet_split { union e1000_rx_desc_packet_split {
struct { struct {
@ -264,7 +282,8 @@ union e1000_rx_desc_packet_split {
} middle; } middle;
struct { struct {
__le16 header_status; __le16 header_status;
__le16 length[3]; /* length of buffers 1-3 */ /* length of buffers 1-3 */
__le16 length[PS_PAGE_BUFFERS];
} upper; } upper;
__le64 reserved; __le64 reserved;
} wb; /* writeback */ } wb; /* writeback */
@ -477,13 +496,13 @@ struct e1000_host_mng_command_info {
#include "e1000_manage.h" #include "e1000_manage.h"
#include "e1000_mbx.h" #include "e1000_mbx.h"
/* Function pointers for the MAC. */
struct e1000_mac_operations { struct e1000_mac_operations {
/* Function pointers for the MAC. */
s32 (*init_params)(struct e1000_hw *); s32 (*init_params)(struct e1000_hw *);
s32 (*id_led_init)(struct e1000_hw *); s32 (*id_led_init)(struct e1000_hw *);
s32 (*blink_led)(struct e1000_hw *); s32 (*blink_led)(struct e1000_hw *);
bool (*check_mng_mode)(struct e1000_hw *);
s32 (*check_for_link)(struct e1000_hw *); s32 (*check_for_link)(struct e1000_hw *);
bool (*check_mng_mode)(struct e1000_hw *hw);
s32 (*cleanup_led)(struct e1000_hw *); s32 (*cleanup_led)(struct e1000_hw *);
void (*clear_hw_cntrs)(struct e1000_hw *); void (*clear_hw_cntrs)(struct e1000_hw *);
void (*clear_vfta)(struct e1000_hw *); void (*clear_vfta)(struct e1000_hw *);
@ -505,19 +524,13 @@ struct e1000_mac_operations {
void (*rar_set)(struct e1000_hw *, u8*, u32); void (*rar_set)(struct e1000_hw *, u8*, u32);
s32 (*read_mac_addr)(struct e1000_hw *); s32 (*read_mac_addr)(struct e1000_hw *);
s32 (*validate_mdi_setting)(struct e1000_hw *); s32 (*validate_mdi_setting)(struct e1000_hw *);
s32 (*mng_host_if_write)(struct e1000_hw *, u8*, u16, u16, u8*);
s32 (*mng_write_cmd_header)(struct e1000_hw *hw,
struct e1000_host_mng_command_header*);
s32 (*mng_enable_host_if)(struct e1000_hw *);
s32 (*wait_autoneg)(struct e1000_hw *);
s32 (*get_thermal_sensor_data)(struct e1000_hw *); s32 (*get_thermal_sensor_data)(struct e1000_hw *);
s32 (*init_thermal_sensor_thresh)(struct e1000_hw *); s32 (*init_thermal_sensor_thresh)(struct e1000_hw *);
s32 (*acquire_swfw_sync)(struct e1000_hw *, u16); s32 (*acquire_swfw_sync)(struct e1000_hw *, u16);
void (*release_swfw_sync)(struct e1000_hw *, u16); void (*release_swfw_sync)(struct e1000_hw *, u16);
}; };
/* /* When to use various PHY register access functions:
* When to use various PHY register access functions:
* *
* Func Caller * Func Caller
* Function Does Does When to use * Function Does Does When to use
@ -558,6 +571,7 @@ struct e1000_phy_operations {
s32 (*write_i2c_byte)(struct e1000_hw *, u8, u8, u8); s32 (*write_i2c_byte)(struct e1000_hw *, u8, u8, u8);
}; };
/* Function pointers for the NVM. */
struct e1000_nvm_operations { struct e1000_nvm_operations {
s32 (*init_params)(struct e1000_hw *); s32 (*init_params)(struct e1000_hw *);
s32 (*acquire)(struct e1000_hw *); s32 (*acquire)(struct e1000_hw *);
@ -729,7 +743,11 @@ struct e1000_dev_spec_82575 {
bool global_device_reset; bool global_device_reset;
bool eee_disable; bool eee_disable;
bool module_plugged; bool module_plugged;
bool clear_semaphore_once;
u32 mtu; u32 mtu;
struct sfp_e1000_flags eth_flags;
u8 media_port;
bool media_changed;
}; };
struct e1000_dev_spec_vf { struct e1000_dev_spec_vf {
@ -766,6 +784,7 @@ struct e1000_hw {
}; };
#include "e1000_82575.h" #include "e1000_82575.h"
#include "e1000_i210.h"
/* These functions must be implemented by drivers */ /* These functions must be implemented by drivers */
s32 e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value); s32 e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);

View File

@ -0,0 +1,909 @@
/*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information:
e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*******************************************************************************/
#include "e1000_api.h"
static s32 e1000_acquire_nvm_i210(struct e1000_hw *hw);
static void e1000_release_nvm_i210(struct e1000_hw *hw);
static s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw);
static s32 e1000_write_nvm_srwr(struct e1000_hw *hw, u16 offset, u16 words,
u16 *data);
static s32 e1000_pool_flash_update_done_i210(struct e1000_hw *hw);
static s32 e1000_valid_led_default_i210(struct e1000_hw *hw, u16 *data);
/**
* e1000_acquire_nvm_i210 - Request for access to EEPROM
* @hw: pointer to the HW structure
*
* Acquire the necessary semaphores for exclusive access to the EEPROM.
* Set the EEPROM access request bit and wait for EEPROM access grant bit.
* Return successful if access grant bit set, else clear the request for
* EEPROM access and return -E1000_ERR_NVM (-1).
**/
static s32 e1000_acquire_nvm_i210(struct e1000_hw *hw)
{
s32 ret_val;
DEBUGFUNC("e1000_acquire_nvm_i210");
ret_val = e1000_acquire_swfw_sync_i210(hw, E1000_SWFW_EEP_SM);
return ret_val;
}
/**
* e1000_release_nvm_i210 - Release exclusive access to EEPROM
* @hw: pointer to the HW structure
*
* Stop any current commands to the EEPROM and clear the EEPROM request bit,
* then release the semaphores acquired.
**/
static void e1000_release_nvm_i210(struct e1000_hw *hw)
{
DEBUGFUNC("e1000_release_nvm_i210");
e1000_release_swfw_sync_i210(hw, E1000_SWFW_EEP_SM);
}
/**
* e1000_acquire_swfw_sync_i210 - Acquire SW/FW semaphore
* @hw: pointer to the HW structure
* @mask: specifies which semaphore to acquire
*
* Acquire the SW/FW semaphore to access the PHY or NVM. The mask
* will also specify which port we're acquiring the lock for.
**/
s32 e1000_acquire_swfw_sync_i210(struct e1000_hw *hw, u16 mask)
{
u32 swfw_sync;
u32 swmask = mask;
u32 fwmask = mask << 16;
s32 ret_val = E1000_SUCCESS;
s32 i = 0, timeout = 200; /* FIXME: find real value to use here */
DEBUGFUNC("e1000_acquire_swfw_sync_i210");
while (i < timeout) {
if (e1000_get_hw_semaphore_i210(hw)) {
ret_val = -E1000_ERR_SWFW_SYNC;
goto out;
}
swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC);
if (!(swfw_sync & (fwmask | swmask)))
break;
/*
* Firmware currently using resource (fwmask)
* or other software thread using resource (swmask)
*/
e1000_put_hw_semaphore_generic(hw);
msec_delay_irq(5);
i++;
}
if (i == timeout) {
DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n");
ret_val = -E1000_ERR_SWFW_SYNC;
goto out;
}
swfw_sync |= swmask;
E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync);
e1000_put_hw_semaphore_generic(hw);
out:
return ret_val;
}
/**
* e1000_release_swfw_sync_i210 - Release SW/FW semaphore
* @hw: pointer to the HW structure
* @mask: specifies which semaphore to acquire
*
* Release the SW/FW semaphore used to access the PHY or NVM. The mask
* will also specify which port we're releasing the lock for.
**/
void e1000_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask)
{
u32 swfw_sync;
DEBUGFUNC("e1000_release_swfw_sync_i210");
while (e1000_get_hw_semaphore_i210(hw) != E1000_SUCCESS)
; /* Empty */
swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC);
swfw_sync &= ~mask;
E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync);
e1000_put_hw_semaphore_generic(hw);
}
/**
* e1000_get_hw_semaphore_i210 - Acquire hardware semaphore
* @hw: pointer to the HW structure
*
* Acquire the HW semaphore to access the PHY or NVM
**/
static s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw)
{
u32 swsm;
s32 timeout = hw->nvm.word_size + 1;
s32 i = 0;
DEBUGFUNC("e1000_get_hw_semaphore_i210");
/* Get the SW semaphore */
while (i < timeout) {
swsm = E1000_READ_REG(hw, E1000_SWSM);
if (!(swsm & E1000_SWSM_SMBI))
break;
usec_delay(50);
i++;
}
if (i == timeout) {
/* In rare circumstances, the SW semaphore may already be held
* unintentionally. Clear the semaphore once before giving up.
*/
if (hw->dev_spec._82575.clear_semaphore_once) {
hw->dev_spec._82575.clear_semaphore_once = false;
e1000_put_hw_semaphore_generic(hw);
for (i = 0; i < timeout; i++) {
swsm = E1000_READ_REG(hw, E1000_SWSM);
if (!(swsm & E1000_SWSM_SMBI))
break;
usec_delay(50);
}
}
/* If we do not have the semaphore here, we have to give up. */
if (i == timeout) {
DEBUGOUT("Driver can't access device - SMBI bit is set.\n");
return -E1000_ERR_NVM;
}
}
/* Get the FW semaphore. */
for (i = 0; i < timeout; i++) {
swsm = E1000_READ_REG(hw, E1000_SWSM);
E1000_WRITE_REG(hw, E1000_SWSM, swsm | E1000_SWSM_SWESMBI);
/* Semaphore acquired if bit latched */
if (E1000_READ_REG(hw, E1000_SWSM) & E1000_SWSM_SWESMBI)
break;
usec_delay(50);
}
if (i == timeout) {
/* Release semaphores */
e1000_put_hw_semaphore_generic(hw);
DEBUGOUT("Driver can't access the NVM\n");
return -E1000_ERR_NVM;
}
return E1000_SUCCESS;
}
/**
* e1000_read_nvm_srrd_i210 - Reads Shadow Ram using EERD register
* @hw: pointer to the HW structure
* @offset: offset of word in the Shadow Ram to read
* @words: number of words to read
* @data: word read from the Shadow Ram
*
* Reads a 16 bit word from the Shadow Ram using the EERD register.
* Uses necessary synchronization semaphores.
**/
s32 e1000_read_nvm_srrd_i210(struct e1000_hw *hw, u16 offset, u16 words,
u16 *data)
{
s32 status = E1000_SUCCESS;
u16 i, count;
DEBUGFUNC("e1000_read_nvm_srrd_i210");
/* We cannot hold synchronization semaphores for too long,
* because of forceful takeover procedure. However it is more efficient
* to read in bursts than synchronizing access for each word. */
for (i = 0; i < words; i += E1000_EERD_EEWR_MAX_COUNT) {
count = (words - i) / E1000_EERD_EEWR_MAX_COUNT > 0 ?
E1000_EERD_EEWR_MAX_COUNT : (words - i);
if (hw->nvm.ops.acquire(hw) == E1000_SUCCESS) {
status = e1000_read_nvm_eerd(hw, offset, count,
data + i);
hw->nvm.ops.release(hw);
} else {
status = E1000_ERR_SWFW_SYNC;
}
if (status != E1000_SUCCESS)
break;
}
return status;
}
/**
* e1000_write_nvm_srwr_i210 - Write to Shadow RAM using EEWR
* @hw: pointer to the HW structure
* @offset: offset within the Shadow RAM to be written to
* @words: number of words to write
* @data: 16 bit word(s) to be written to the Shadow RAM
*
* Writes data to Shadow RAM at offset using EEWR register.
*
* If e1000_update_nvm_checksum is not called after this function , the
* data will not be committed to FLASH and also Shadow RAM will most likely
* contain an invalid checksum.
*
* If error code is returned, data and Shadow RAM may be inconsistent - buffer
* partially written.
**/
s32 e1000_write_nvm_srwr_i210(struct e1000_hw *hw, u16 offset, u16 words,
u16 *data)
{
s32 status = E1000_SUCCESS;
u16 i, count;
DEBUGFUNC("e1000_write_nvm_srwr_i210");
/* We cannot hold synchronization semaphores for too long,
* because of forceful takeover procedure. However it is more efficient
* to write in bursts than synchronizing access for each word. */
for (i = 0; i < words; i += E1000_EERD_EEWR_MAX_COUNT) {
count = (words - i) / E1000_EERD_EEWR_MAX_COUNT > 0 ?
E1000_EERD_EEWR_MAX_COUNT : (words - i);
if (hw->nvm.ops.acquire(hw) == E1000_SUCCESS) {
status = e1000_write_nvm_srwr(hw, offset, count,
data + i);
hw->nvm.ops.release(hw);
} else {
status = E1000_ERR_SWFW_SYNC;
}
if (status != E1000_SUCCESS)
break;
}
return status;
}
/**
* e1000_write_nvm_srwr - Write to Shadow Ram using EEWR
* @hw: pointer to the HW structure
* @offset: offset within the Shadow Ram to be written to
* @words: number of words to write
* @data: 16 bit word(s) to be written to the Shadow Ram
*
* Writes data to Shadow Ram at offset using EEWR register.
*
* If e1000_update_nvm_checksum is not called after this function , the
* Shadow Ram will most likely contain an invalid checksum.
**/
static s32 e1000_write_nvm_srwr(struct e1000_hw *hw, u16 offset, u16 words,
u16 *data)
{
struct e1000_nvm_info *nvm = &hw->nvm;
u32 i, k, eewr = 0;
u32 attempts = 100000;
s32 ret_val = E1000_SUCCESS;
DEBUGFUNC("e1000_write_nvm_srwr");
/*
* A check for invalid values: offset too large, too many words,
* too many words for the offset, and not enough words.
*/
if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
(words == 0)) {
DEBUGOUT("nvm parameter(s) out of bounds\n");
ret_val = -E1000_ERR_NVM;
goto out;
}
for (i = 0; i < words; i++) {
eewr = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) |
(data[i] << E1000_NVM_RW_REG_DATA) |
E1000_NVM_RW_REG_START;
E1000_WRITE_REG(hw, E1000_SRWR, eewr);
for (k = 0; k < attempts; k++) {
if (E1000_NVM_RW_REG_DONE &
E1000_READ_REG(hw, E1000_SRWR)) {
ret_val = E1000_SUCCESS;
break;
}
usec_delay(5);
}
if (ret_val != E1000_SUCCESS) {
DEBUGOUT("Shadow RAM write EEWR timed out\n");
break;
}
}
out:
return ret_val;
}
/** e1000_read_invm_word_i210 - Reads OTP
* @hw: pointer to the HW structure
* @address: the word address (aka eeprom offset) to read
* @data: pointer to the data read
*
* Reads 16-bit words from the OTP. Return error when the word is not
* stored in OTP.
**/
static s32 e1000_read_invm_word_i210(struct e1000_hw *hw, u8 address, u16 *data)
{
s32 status = -E1000_ERR_INVM_VALUE_NOT_FOUND;
u32 invm_dword;
u16 i;
u8 record_type, word_address;
DEBUGFUNC("e1000_read_invm_word_i210");
for (i = 0; i < E1000_INVM_SIZE; i++) {
invm_dword = E1000_READ_REG(hw, E1000_INVM_DATA_REG(i));
/* Get record type */
record_type = INVM_DWORD_TO_RECORD_TYPE(invm_dword);
if (record_type == E1000_INVM_UNINITIALIZED_STRUCTURE)
break;
if (record_type == E1000_INVM_CSR_AUTOLOAD_STRUCTURE)
i += E1000_INVM_CSR_AUTOLOAD_DATA_SIZE_IN_DWORDS;
if (record_type == E1000_INVM_RSA_KEY_SHA256_STRUCTURE)
i += E1000_INVM_RSA_KEY_SHA256_DATA_SIZE_IN_DWORDS;
if (record_type == E1000_INVM_WORD_AUTOLOAD_STRUCTURE) {
word_address = INVM_DWORD_TO_WORD_ADDRESS(invm_dword);
if (word_address == address) {
*data = INVM_DWORD_TO_WORD_DATA(invm_dword);
DEBUGOUT2("Read INVM Word 0x%02x = %x",
address, *data);
status = E1000_SUCCESS;
break;
}
}
}
if (status != E1000_SUCCESS)
DEBUGOUT1("Requested word 0x%02x not found in OTP\n", address);
return status;
}
/** e1000_read_invm_i210 - Read invm wrapper function for I210/I211
* @hw: pointer to the HW structure
* @address: the word address (aka eeprom offset) to read
* @data: pointer to the data read
*
* Wrapper function to return data formerly found in the NVM.
**/
static s32 e1000_read_invm_i210(struct e1000_hw *hw, u16 offset,
u16 E1000_UNUSEDARG words, u16 *data)
{
s32 ret_val = E1000_SUCCESS;
DEBUGFUNC("e1000_read_invm_i210");
/* Only the MAC addr is required to be present in the iNVM */
switch (offset) {
case NVM_MAC_ADDR:
ret_val = e1000_read_invm_word_i210(hw, (u8)offset, &data[0]);
ret_val |= e1000_read_invm_word_i210(hw, (u8)offset+1,
&data[1]);
ret_val |= e1000_read_invm_word_i210(hw, (u8)offset+2,
&data[2]);
if (ret_val != E1000_SUCCESS)
DEBUGOUT("MAC Addr not found in iNVM\n");
break;
case NVM_INIT_CTRL_2:
ret_val = e1000_read_invm_word_i210(hw, (u8)offset, data);
if (ret_val != E1000_SUCCESS) {
*data = NVM_INIT_CTRL_2_DEFAULT_I211;
ret_val = E1000_SUCCESS;
}
break;
case NVM_INIT_CTRL_4:
ret_val = e1000_read_invm_word_i210(hw, (u8)offset, data);
if (ret_val != E1000_SUCCESS) {
*data = NVM_INIT_CTRL_4_DEFAULT_I211;
ret_val = E1000_SUCCESS;
}
break;
case NVM_LED_1_CFG:
ret_val = e1000_read_invm_word_i210(hw, (u8)offset, data);
if (ret_val != E1000_SUCCESS) {
*data = NVM_LED_1_CFG_DEFAULT_I211;
ret_val = E1000_SUCCESS;
}
break;
case NVM_LED_0_2_CFG:
ret_val = e1000_read_invm_word_i210(hw, (u8)offset, data);
if (ret_val != E1000_SUCCESS) {
*data = NVM_LED_0_2_CFG_DEFAULT_I211;
ret_val = E1000_SUCCESS;
}
break;
case NVM_ID_LED_SETTINGS:
ret_val = e1000_read_invm_word_i210(hw, (u8)offset, data);
if (ret_val != E1000_SUCCESS) {
*data = ID_LED_RESERVED_FFFF;
ret_val = E1000_SUCCESS;
}
break;
case NVM_SUB_DEV_ID:
*data = hw->subsystem_device_id;
break;
case NVM_SUB_VEN_ID:
*data = hw->subsystem_vendor_id;
break;
case NVM_DEV_ID:
*data = hw->device_id;
break;
case NVM_VEN_ID:
*data = hw->vendor_id;
break;
default:
DEBUGOUT1("NVM word 0x%02x is not mapped.\n", offset);
*data = NVM_RESERVED_WORD;
break;
}
return ret_val;
}
/**
* e1000_read_invm_version - Reads iNVM version and image type
* @hw: pointer to the HW structure
* @invm_ver: version structure for the version read
*
* Reads iNVM version and image type.
**/
s32 e1000_read_invm_version(struct e1000_hw *hw,
struct e1000_fw_version *invm_ver)
{
u32 *record = NULL;
u32 *next_record = NULL;
u32 i = 0;
u32 invm_dword = 0;
u32 invm_blocks = E1000_INVM_SIZE - (E1000_INVM_ULT_BYTES_SIZE /
E1000_INVM_RECORD_SIZE_IN_BYTES);
u32 buffer[E1000_INVM_SIZE];
s32 status = -E1000_ERR_INVM_VALUE_NOT_FOUND;
u16 version = 0;
DEBUGFUNC("e1000_read_invm_version");
/* Read iNVM memory */
for (i = 0; i < E1000_INVM_SIZE; i++) {
invm_dword = E1000_READ_REG(hw, E1000_INVM_DATA_REG(i));
buffer[i] = invm_dword;
}
/* Read version number */
for (i = 1; i < invm_blocks; i++) {
record = &buffer[invm_blocks - i];
next_record = &buffer[invm_blocks - i + 1];
/* Check if we have first version location used */
if ((i == 1) && ((*record & E1000_INVM_VER_FIELD_ONE) == 0)) {
version = 0;
status = E1000_SUCCESS;
break;
}
/* Check if we have second version location used */
else if ((i == 1) &&
((*record & E1000_INVM_VER_FIELD_TWO) == 0)) {
version = (*record & E1000_INVM_VER_FIELD_ONE) >> 3;
status = E1000_SUCCESS;
break;
}
/*
* Check if we have odd version location
* used and it is the last one used
*/
else if ((((*record & E1000_INVM_VER_FIELD_ONE) == 0) &&
((*record & 0x3) == 0)) || (((*record & 0x3) != 0) &&
(i != 1))) {
version = (*next_record & E1000_INVM_VER_FIELD_TWO)
>> 13;
status = E1000_SUCCESS;
break;
}
/*
* Check if we have even version location
* used and it is the last one used
*/
else if (((*record & E1000_INVM_VER_FIELD_TWO) == 0) &&
((*record & 0x3) == 0)) {
version = (*record & E1000_INVM_VER_FIELD_ONE) >> 3;
status = E1000_SUCCESS;
break;
}
}
if (status == E1000_SUCCESS) {
invm_ver->invm_major = (version & E1000_INVM_MAJOR_MASK)
>> E1000_INVM_MAJOR_SHIFT;
invm_ver->invm_minor = version & E1000_INVM_MINOR_MASK;
}
/* Read Image Type */
for (i = 1; i < invm_blocks; i++) {
record = &buffer[invm_blocks - i];
next_record = &buffer[invm_blocks - i + 1];
/* Check if we have image type in first location used */
if ((i == 1) && ((*record & E1000_INVM_IMGTYPE_FIELD) == 0)) {
invm_ver->invm_img_type = 0;
status = E1000_SUCCESS;
break;
}
/* Check if we have image type in first location used */
else if ((((*record & 0x3) == 0) &&
((*record & E1000_INVM_IMGTYPE_FIELD) == 0)) ||
((((*record & 0x3) != 0) && (i != 1)))) {
invm_ver->invm_img_type =
(*next_record & E1000_INVM_IMGTYPE_FIELD) >> 23;
status = E1000_SUCCESS;
break;
}
}
return status;
}
/**
* e1000_validate_nvm_checksum_i210 - Validate EEPROM checksum
* @hw: pointer to the HW structure
*
* Calculates the EEPROM checksum by reading/adding each word of the EEPROM
* and then verifies that the sum of the EEPROM is equal to 0xBABA.
**/
s32 e1000_validate_nvm_checksum_i210(struct e1000_hw *hw)
{
s32 status = E1000_SUCCESS;
s32 (*read_op_ptr)(struct e1000_hw *, u16, u16, u16 *);
DEBUGFUNC("e1000_validate_nvm_checksum_i210");
if (hw->nvm.ops.acquire(hw) == E1000_SUCCESS) {
/*
* Replace the read function with semaphore grabbing with
* the one that skips this for a while.
* We have semaphore taken already here.
*/
read_op_ptr = hw->nvm.ops.read;
hw->nvm.ops.read = e1000_read_nvm_eerd;
status = e1000_validate_nvm_checksum_generic(hw);
/* Revert original read operation. */
hw->nvm.ops.read = read_op_ptr;
hw->nvm.ops.release(hw);
} else {
status = E1000_ERR_SWFW_SYNC;
}
return status;
}
/**
* e1000_update_nvm_checksum_i210 - Update EEPROM checksum
* @hw: pointer to the HW structure
*
* Updates the EEPROM checksum by reading/adding each word of the EEPROM
* up to the checksum. Then calculates the EEPROM checksum and writes the
* value to the EEPROM. Next commit EEPROM data onto the Flash.
**/
s32 e1000_update_nvm_checksum_i210(struct e1000_hw *hw)
{
s32 ret_val = E1000_SUCCESS;
u16 checksum = 0;
u16 i, nvm_data;
DEBUGFUNC("e1000_update_nvm_checksum_i210");
/*
* Read the first word from the EEPROM. If this times out or fails, do
* not continue or we could be in for a very long wait while every
* EEPROM read fails
*/
ret_val = e1000_read_nvm_eerd(hw, 0, 1, &nvm_data);
if (ret_val != E1000_SUCCESS) {
DEBUGOUT("EEPROM read failed\n");
goto out;
}
if (hw->nvm.ops.acquire(hw) == E1000_SUCCESS) {
/*
* Do not use hw->nvm.ops.write, hw->nvm.ops.read
* because we do not want to take the synchronization
* semaphores twice here.
*/
for (i = 0; i < NVM_CHECKSUM_REG; i++) {
ret_val = e1000_read_nvm_eerd(hw, i, 1, &nvm_data);
if (ret_val) {
hw->nvm.ops.release(hw);
DEBUGOUT("NVM Read Error while updating checksum.\n");
goto out;
}
checksum += nvm_data;
}
checksum = (u16) NVM_SUM - checksum;
ret_val = e1000_write_nvm_srwr(hw, NVM_CHECKSUM_REG, 1,
&checksum);
if (ret_val != E1000_SUCCESS) {
hw->nvm.ops.release(hw);
DEBUGOUT("NVM Write Error while updating checksum.\n");
goto out;
}
hw->nvm.ops.release(hw);
ret_val = e1000_update_flash_i210(hw);
} else {
ret_val = E1000_ERR_SWFW_SYNC;
}
out:
return ret_val;
}
/**
* e1000_get_flash_presence_i210 - Check if flash device is detected.
* @hw: pointer to the HW structure
*
**/
bool e1000_get_flash_presence_i210(struct e1000_hw *hw)
{
u32 eec = 0;
bool ret_val = false;
DEBUGFUNC("e1000_get_flash_presence_i210");
eec = E1000_READ_REG(hw, E1000_EECD);
if (eec & E1000_EECD_FLASH_DETECTED_I210)
ret_val = true;
return ret_val;
}
/**
* e1000_update_flash_i210 - Commit EEPROM to the flash
* @hw: pointer to the HW structure
*
**/
s32 e1000_update_flash_i210(struct e1000_hw *hw)
{
s32 ret_val = E1000_SUCCESS;
u32 flup;
DEBUGFUNC("e1000_update_flash_i210");
ret_val = e1000_pool_flash_update_done_i210(hw);
if (ret_val == -E1000_ERR_NVM) {
DEBUGOUT("Flash update time out\n");
goto out;
}
flup = E1000_READ_REG(hw, E1000_EECD) | E1000_EECD_FLUPD_I210;
E1000_WRITE_REG(hw, E1000_EECD, flup);
ret_val = e1000_pool_flash_update_done_i210(hw);
if (ret_val == E1000_SUCCESS)
DEBUGOUT("Flash update complete\n");
else
DEBUGOUT("Flash update time out\n");
out:
return ret_val;
}
/**
* e1000_pool_flash_update_done_i210 - Pool FLUDONE status.
* @hw: pointer to the HW structure
*
**/
s32 e1000_pool_flash_update_done_i210(struct e1000_hw *hw)
{
s32 ret_val = -E1000_ERR_NVM;
u32 i, reg;
DEBUGFUNC("e1000_pool_flash_update_done_i210");
for (i = 0; i < E1000_FLUDONE_ATTEMPTS; i++) {
reg = E1000_READ_REG(hw, E1000_EECD);
if (reg & E1000_EECD_FLUDONE_I210) {
ret_val = E1000_SUCCESS;
break;
}
usec_delay(5);
}
return ret_val;
}
/**
* e1000_init_nvm_params_i210 - Initialize i210 NVM function pointers
* @hw: pointer to the HW structure
*
* Initialize the i210/i211 NVM parameters and function pointers.
**/
static s32 e1000_init_nvm_params_i210(struct e1000_hw *hw)
{
s32 ret_val = E1000_SUCCESS;
struct e1000_nvm_info *nvm = &hw->nvm;
DEBUGFUNC("e1000_init_nvm_params_i210");
ret_val = e1000_init_nvm_params_82575(hw);
nvm->ops.acquire = e1000_acquire_nvm_i210;
nvm->ops.release = e1000_release_nvm_i210;
nvm->ops.valid_led_default = e1000_valid_led_default_i210;
if (e1000_get_flash_presence_i210(hw)) {
hw->nvm.type = e1000_nvm_flash_hw;
nvm->ops.read = e1000_read_nvm_srrd_i210;
nvm->ops.write = e1000_write_nvm_srwr_i210;
nvm->ops.validate = e1000_validate_nvm_checksum_i210;
nvm->ops.update = e1000_update_nvm_checksum_i210;
} else {
hw->nvm.type = e1000_nvm_invm;
nvm->ops.read = e1000_read_invm_i210;
nvm->ops.write = e1000_null_write_nvm;
nvm->ops.validate = e1000_null_ops_generic;
nvm->ops.update = e1000_null_ops_generic;
}
return ret_val;
}
/**
* e1000_init_function_pointers_i210 - Init func ptrs.
* @hw: pointer to the HW structure
*
* Called to initialize all function pointers and parameters.
**/
void e1000_init_function_pointers_i210(struct e1000_hw *hw)
{
e1000_init_function_pointers_82575(hw);
hw->nvm.ops.init_params = e1000_init_nvm_params_i210;
return;
}
/**
* e1000_valid_led_default_i210 - Verify a valid default LED config
* @hw: pointer to the HW structure
* @data: pointer to the NVM (EEPROM)
*
* Read the EEPROM for the current default LED configuration. If the
* LED configuration is not valid, set to a valid LED configuration.
**/
static s32 e1000_valid_led_default_i210(struct e1000_hw *hw, u16 *data)
{
s32 ret_val;
DEBUGFUNC("e1000_valid_led_default_i210");
ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
if (ret_val) {
DEBUGOUT("NVM Read Error\n");
goto out;
}
if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF) {
switch (hw->phy.media_type) {
case e1000_media_type_internal_serdes:
*data = ID_LED_DEFAULT_I210_SERDES;
break;
case e1000_media_type_copper:
default:
*data = ID_LED_DEFAULT_I210;
break;
}
}
out:
return ret_val;
}
/**
* __e1000_access_xmdio_reg - Read/write XMDIO register
* @hw: pointer to the HW structure
* @address: XMDIO address to program
* @dev_addr: device address to program
* @data: pointer to value to read/write from/to the XMDIO address
* @read: boolean flag to indicate read or write
**/
static s32 __e1000_access_xmdio_reg(struct e1000_hw *hw, u16 address,
u8 dev_addr, u16 *data, bool read)
{
s32 ret_val = E1000_SUCCESS;
DEBUGFUNC("__e1000_access_xmdio_reg");
ret_val = hw->phy.ops.write_reg(hw, E1000_MMDAC, dev_addr);
if (ret_val)
return ret_val;
ret_val = hw->phy.ops.write_reg(hw, E1000_MMDAAD, address);
if (ret_val)
return ret_val;
ret_val = hw->phy.ops.write_reg(hw, E1000_MMDAC, E1000_MMDAC_FUNC_DATA |
dev_addr);
if (ret_val)
return ret_val;
if (read)
ret_val = hw->phy.ops.read_reg(hw, E1000_MMDAAD, data);
else
ret_val = hw->phy.ops.write_reg(hw, E1000_MMDAAD, *data);
if (ret_val)
return ret_val;
/* Recalibrate the device back to 0 */
ret_val = hw->phy.ops.write_reg(hw, E1000_MMDAC, 0);
if (ret_val)
return ret_val;
return ret_val;
}
/**
* e1000_read_xmdio_reg - Read XMDIO register
* @hw: pointer to the HW structure
* @addr: XMDIO address to program
* @dev_addr: device address to program
* @data: value to be read from the EMI address
**/
s32 e1000_read_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, u16 *data)
{
DEBUGFUNC("e1000_read_xmdio_reg");
return __e1000_access_xmdio_reg(hw, addr, dev_addr, data, true);
}
/**
* e1000_write_xmdio_reg - Write XMDIO register
* @hw: pointer to the HW structure
* @addr: XMDIO address to program
* @dev_addr: device address to program
* @data: value to be written to the XMDIO address
**/
s32 e1000_write_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, u16 data)
{
DEBUGFUNC("e1000_read_xmdio_reg");
return __e1000_access_xmdio_reg(hw, addr, dev_addr, &data, false);
}

View File

@ -0,0 +1,91 @@
/*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information:
e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*******************************************************************************/
#ifndef _E1000_I210_H_
#define _E1000_I210_H_
bool e1000_get_flash_presence_i210(struct e1000_hw *hw);
s32 e1000_update_flash_i210(struct e1000_hw *hw);
s32 e1000_update_nvm_checksum_i210(struct e1000_hw *hw);
s32 e1000_validate_nvm_checksum_i210(struct e1000_hw *hw);
s32 e1000_write_nvm_srwr_i210(struct e1000_hw *hw, u16 offset,
u16 words, u16 *data);
s32 e1000_read_nvm_srrd_i210(struct e1000_hw *hw, u16 offset,
u16 words, u16 *data);
s32 e1000_read_invm_version(struct e1000_hw *hw,
struct e1000_fw_version *invm_ver);
s32 e1000_acquire_swfw_sync_i210(struct e1000_hw *hw, u16 mask);
void e1000_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask);
s32 e1000_read_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr,
u16 *data);
s32 e1000_write_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr,
u16 data);
#define E1000_STM_OPCODE 0xDB00
#define E1000_EEPROM_FLASH_SIZE_WORD 0x11
#define INVM_DWORD_TO_RECORD_TYPE(invm_dword) \
(u8)((invm_dword) & 0x7)
#define INVM_DWORD_TO_WORD_ADDRESS(invm_dword) \
(u8)(((invm_dword) & 0x0000FE00) >> 9)
#define INVM_DWORD_TO_WORD_DATA(invm_dword) \
(u16)(((invm_dword) & 0xFFFF0000) >> 16)
enum E1000_INVM_STRUCTURE_TYPE {
E1000_INVM_UNINITIALIZED_STRUCTURE = 0x00,
E1000_INVM_WORD_AUTOLOAD_STRUCTURE = 0x01,
E1000_INVM_CSR_AUTOLOAD_STRUCTURE = 0x02,
E1000_INVM_PHY_REGISTER_AUTOLOAD_STRUCTURE = 0x03,
E1000_INVM_RSA_KEY_SHA256_STRUCTURE = 0x04,
E1000_INVM_INVALIDATED_STRUCTURE = 0x0F,
};
#define E1000_INVM_RSA_KEY_SHA256_DATA_SIZE_IN_DWORDS 8
#define E1000_INVM_CSR_AUTOLOAD_DATA_SIZE_IN_DWORDS 1
#define E1000_INVM_ULT_BYTES_SIZE 8
#define E1000_INVM_RECORD_SIZE_IN_BYTES 4
#define E1000_INVM_VER_FIELD_ONE 0x1FF8
#define E1000_INVM_VER_FIELD_TWO 0x7FE000
#define E1000_INVM_IMGTYPE_FIELD 0x1F800000
#define E1000_INVM_MAJOR_MASK 0x3F0
#define E1000_INVM_MINOR_MASK 0xF
#define E1000_INVM_MAJOR_SHIFT 4
#define ID_LED_DEFAULT_I210 ((ID_LED_OFF1_ON2 << 8) | \
(ID_LED_DEF1_DEF2 << 4) | \
(ID_LED_OFF1_OFF2))
#define ID_LED_DEFAULT_I210_SERDES ((ID_LED_DEF1_DEF2 << 8) | \
(ID_LED_DEF1_DEF2 << 4) | \
(ID_LED_OFF1_ON2))
/* NVM offset defaults for I211 devices */
#define NVM_INIT_CTRL_2_DEFAULT_I211 0X7243
#define NVM_INIT_CTRL_4_DEFAULT_I211 0x00C1
#define NVM_LED_1_CFG_DEFAULT_I211 0x0184
#define NVM_LED_0_2_CFG_DEFAULT_I211 0x200C
#endif

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -30,6 +30,7 @@
static s32 e1000_validate_mdi_setting_generic(struct e1000_hw *hw); static s32 e1000_validate_mdi_setting_generic(struct e1000_hw *hw);
static void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw); static void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw);
static void e1000_config_collision_dist_generic(struct e1000_hw *hw); static void e1000_config_collision_dist_generic(struct e1000_hw *hw);
static void e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index);
/** /**
* e1000_init_mac_ops_generic - Initialize MAC function pointers * e1000_init_mac_ops_generic - Initialize MAC function pointers
@ -62,12 +63,8 @@ void e1000_init_mac_ops_generic(struct e1000_hw *hw)
mac->ops.setup_link = e1000_null_ops_generic; mac->ops.setup_link = e1000_null_ops_generic;
mac->ops.get_link_up_info = e1000_null_link_info; mac->ops.get_link_up_info = e1000_null_link_info;
mac->ops.check_for_link = e1000_null_ops_generic; mac->ops.check_for_link = e1000_null_ops_generic;
mac->ops.wait_autoneg = e1000_wait_autoneg_generic;
/* Management */ /* Management */
mac->ops.check_mng_mode = e1000_null_mng_mode; mac->ops.check_mng_mode = e1000_null_mng_mode;
mac->ops.mng_host_if_write = e1000_mng_host_if_write_generic;
mac->ops.mng_write_cmd_header = e1000_mng_write_cmd_header_generic;
mac->ops.mng_enable_host_if = e1000_mng_enable_host_if_generic;
/* VLAN, MC, etc. */ /* VLAN, MC, etc. */
mac->ops.update_mc_addr_list = e1000_null_update_mc; mac->ops.update_mc_addr_list = e1000_null_update_mc;
mac->ops.clear_vfta = e1000_null_mac_generic; mac->ops.clear_vfta = e1000_null_mac_generic;
@ -80,7 +77,7 @@ void e1000_init_mac_ops_generic(struct e1000_hw *hw)
* e1000_null_ops_generic - No-op function, returns 0 * e1000_null_ops_generic - No-op function, returns 0
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
**/ **/
s32 e1000_null_ops_generic(struct e1000_hw *hw) s32 e1000_null_ops_generic(struct e1000_hw E1000_UNUSEDARG *hw)
{ {
DEBUGFUNC("e1000_null_ops_generic"); DEBUGFUNC("e1000_null_ops_generic");
return E1000_SUCCESS; return E1000_SUCCESS;
@ -90,7 +87,7 @@ s32 e1000_null_ops_generic(struct e1000_hw *hw)
* e1000_null_mac_generic - No-op function, return void * e1000_null_mac_generic - No-op function, return void
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
**/ **/
void e1000_null_mac_generic(struct e1000_hw *hw) void e1000_null_mac_generic(struct e1000_hw E1000_UNUSEDARG *hw)
{ {
DEBUGFUNC("e1000_null_mac_generic"); DEBUGFUNC("e1000_null_mac_generic");
return; return;
@ -100,7 +97,8 @@ void e1000_null_mac_generic(struct e1000_hw *hw)
* e1000_null_link_info - No-op function, return 0 * e1000_null_link_info - No-op function, return 0
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
**/ **/
s32 e1000_null_link_info(struct e1000_hw *hw, u16 *s, u16 *d) s32 e1000_null_link_info(struct e1000_hw E1000_UNUSEDARG *hw,
u16 E1000_UNUSEDARG *s, u16 E1000_UNUSEDARG *d)
{ {
DEBUGFUNC("e1000_null_link_info"); DEBUGFUNC("e1000_null_link_info");
return E1000_SUCCESS; return E1000_SUCCESS;
@ -110,7 +108,7 @@ s32 e1000_null_link_info(struct e1000_hw *hw, u16 *s, u16 *d)
* e1000_null_mng_mode - No-op function, return false * e1000_null_mng_mode - No-op function, return false
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
**/ **/
bool e1000_null_mng_mode(struct e1000_hw *hw) bool e1000_null_mng_mode(struct e1000_hw E1000_UNUSEDARG *hw)
{ {
DEBUGFUNC("e1000_null_mng_mode"); DEBUGFUNC("e1000_null_mng_mode");
return false; return false;
@ -120,7 +118,8 @@ bool e1000_null_mng_mode(struct e1000_hw *hw)
* e1000_null_update_mc - No-op function, return void * e1000_null_update_mc - No-op function, return void
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
**/ **/
void e1000_null_update_mc(struct e1000_hw *hw, u8 *h, u32 a) void e1000_null_update_mc(struct e1000_hw E1000_UNUSEDARG *hw,
u8 E1000_UNUSEDARG *h, u32 E1000_UNUSEDARG a)
{ {
DEBUGFUNC("e1000_null_update_mc"); DEBUGFUNC("e1000_null_update_mc");
return; return;
@ -130,7 +129,8 @@ void e1000_null_update_mc(struct e1000_hw *hw, u8 *h, u32 a)
* e1000_null_write_vfta - No-op function, return void * e1000_null_write_vfta - No-op function, return void
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
**/ **/
void e1000_null_write_vfta(struct e1000_hw *hw, u32 a, u32 b) void e1000_null_write_vfta(struct e1000_hw E1000_UNUSEDARG *hw,
u32 E1000_UNUSEDARG a, u32 E1000_UNUSEDARG b)
{ {
DEBUGFUNC("e1000_null_write_vfta"); DEBUGFUNC("e1000_null_write_vfta");
return; return;
@ -140,7 +140,8 @@ void e1000_null_write_vfta(struct e1000_hw *hw, u32 a, u32 b)
* e1000_null_rar_set - No-op function, return void * e1000_null_rar_set - No-op function, return void
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
**/ **/
void e1000_null_rar_set(struct e1000_hw *hw, u8 *h, u32 a) void e1000_null_rar_set(struct e1000_hw E1000_UNUSEDARG *hw,
u8 E1000_UNUSEDARG *h, u32 E1000_UNUSEDARG a)
{ {
DEBUGFUNC("e1000_null_rar_set"); DEBUGFUNC("e1000_null_rar_set");
return; return;
@ -205,8 +206,7 @@ static void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw)
struct e1000_bus_info *bus = &hw->bus; struct e1000_bus_info *bus = &hw->bus;
u32 reg; u32 reg;
/* /* The status register reports the correct function number
* The status register reports the correct function number
* for the device regardless of function swap state. * for the device regardless of function swap state.
*/ */
reg = E1000_READ_REG(hw, E1000_STATUS); reg = E1000_READ_REG(hw, E1000_STATUS);
@ -304,7 +304,7 @@ void e1000_init_rx_addrs_generic(struct e1000_hw *hw, u16 rar_count)
s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
{ {
u32 i; u32 i;
s32 ret_val = E1000_SUCCESS; s32 ret_val;
u16 offset, nvm_alt_mac_addr_offset, nvm_data; u16 offset, nvm_alt_mac_addr_offset, nvm_data;
u8 alt_mac_addr[ETH_ADDR_LEN]; u8 alt_mac_addr[ETH_ADDR_LEN];
@ -315,8 +315,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
return ret_val; return ret_val;
/* /* Alternate MAC address is handled by the option ROM for 82580
* Alternate MAC address is handled by the option ROM for 82580
* and newer. SW support not required. * and newer. SW support not required.
*/ */
if (hw->mac.type >= e1000_82580) if (hw->mac.type >= e1000_82580)
@ -359,8 +358,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
return E1000_SUCCESS; return E1000_SUCCESS;
} }
/* /* We have a valid alternate MAC address, and we want to treat it the
* We have a valid alternate MAC address, and we want to treat it the
* same as the normal permanent MAC address stored by the HW into the * same as the normal permanent MAC address stored by the HW into the
* RAR. Do this by mapping this address into RAR0. * RAR. Do this by mapping this address into RAR0.
*/ */
@ -378,14 +376,13 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
* Sets the receive address array register at index to the address passed * Sets the receive address array register at index to the address passed
* in by addr. * in by addr.
**/ **/
void e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index) static void e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index)
{ {
u32 rar_low, rar_high; u32 rar_low, rar_high;
DEBUGFUNC("e1000_rar_set_generic"); DEBUGFUNC("e1000_rar_set_generic");
/* /* HW expects these in little endian so we reverse the byte order
* HW expects these in little endian so we reverse the byte order
* from network order (big endian) to little endian * from network order (big endian) to little endian
*/ */
rar_low = ((u32) addr[0] | ((u32) addr[1] << 8) | rar_low = ((u32) addr[0] | ((u32) addr[1] << 8) |
@ -397,8 +394,7 @@ void e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index)
if (rar_low || rar_high) if (rar_low || rar_high)
rar_high |= E1000_RAH_AV; rar_high |= E1000_RAH_AV;
/* /* Some bridges will combine consecutive 32-bit writes into
* Some bridges will combine consecutive 32-bit writes into
* a single burst write, which will malfunction on some parts. * a single burst write, which will malfunction on some parts.
* The flushes avoid this. * The flushes avoid this.
*/ */
@ -426,15 +422,13 @@ u32 e1000_hash_mc_addr_generic(struct e1000_hw *hw, u8 *mc_addr)
/* Register count multiplied by bits per register */ /* Register count multiplied by bits per register */
hash_mask = (hw->mac.mta_reg_count * 32) - 1; hash_mask = (hw->mac.mta_reg_count * 32) - 1;
/* /* For a mc_filter_type of 0, bit_shift is the number of left-shifts
* For a mc_filter_type of 0, bit_shift is the number of left-shifts
* where 0xFF would still fall within the hash mask. * where 0xFF would still fall within the hash mask.
*/ */
while (hash_mask >> bit_shift != 0xFF) while (hash_mask >> bit_shift != 0xFF)
bit_shift++; bit_shift++;
/* /* The portion of the address that is used for the hash table
* The portion of the address that is used for the hash table
* is determined by the mc_filter_type setting. * is determined by the mc_filter_type setting.
* The algorithm is such that there is a total of 8 bits of shifting. * The algorithm is such that there is a total of 8 bits of shifting.
* The bit_shift for a mc_filter_type of 0 represents the number of * The bit_shift for a mc_filter_type of 0 represents the number of
@ -582,8 +576,7 @@ s32 e1000_check_for_copper_link_generic(struct e1000_hw *hw)
DEBUGFUNC("e1000_check_for_copper_link"); DEBUGFUNC("e1000_check_for_copper_link");
/* /* We only want to go out to the PHY registers to see if Auto-Neg
* We only want to go out to the PHY registers to see if Auto-Neg
* has completed and/or if our link status has changed. The * has completed and/or if our link status has changed. The
* get_link_status flag is set upon receiving a Link Status * get_link_status flag is set upon receiving a Link Status
* Change or Rx Sequence Error interrupt. * Change or Rx Sequence Error interrupt.
@ -591,8 +584,7 @@ s32 e1000_check_for_copper_link_generic(struct e1000_hw *hw)
if (!mac->get_link_status) if (!mac->get_link_status)
return E1000_SUCCESS; return E1000_SUCCESS;
/* /* First we want to see if the MII Status Register reports
* First we want to see if the MII Status Register reports
* link. If so, then we want to get the current speed/duplex * link. If so, then we want to get the current speed/duplex
* of the PHY. * of the PHY.
*/ */
@ -605,28 +597,24 @@ s32 e1000_check_for_copper_link_generic(struct e1000_hw *hw)
mac->get_link_status = false; mac->get_link_status = false;
/* /* Check if there was DownShift, must be checked
* Check if there was DownShift, must be checked
* immediately after link-up * immediately after link-up
*/ */
e1000_check_downshift_generic(hw); e1000_check_downshift_generic(hw);
/* /* If we are forcing speed/duplex, then we simply return since
* If we are forcing speed/duplex, then we simply return since
* we have already determined whether we have link or not. * we have already determined whether we have link or not.
*/ */
if (!mac->autoneg) if (!mac->autoneg)
return -E1000_ERR_CONFIG; return -E1000_ERR_CONFIG;
/* /* Auto-Neg is enabled. Auto Speed Detection takes care
* Auto-Neg is enabled. Auto Speed Detection takes care
* of MAC speed/duplex configuration. So we only need to * of MAC speed/duplex configuration. So we only need to
* configure Collision Distance in the MAC. * configure Collision Distance in the MAC.
*/ */
mac->ops.config_collision_dist(hw); mac->ops.config_collision_dist(hw);
/* /* Configure Flow Control now that Auto-Neg has completed.
* Configure Flow Control now that Auto-Neg has completed.
* First, we need to restore the desired flow control * First, we need to restore the desired flow control
* settings because we may have had to re-autoneg with a * settings because we may have had to re-autoneg with a
* different link partner. * different link partner.
@ -659,8 +647,7 @@ s32 e1000_check_for_fiber_link_generic(struct e1000_hw *hw)
status = E1000_READ_REG(hw, E1000_STATUS); status = E1000_READ_REG(hw, E1000_STATUS);
rxcw = E1000_READ_REG(hw, E1000_RXCW); rxcw = E1000_READ_REG(hw, E1000_RXCW);
/* /* If we don't have link (auto-negotiation failed or link partner
* If we don't have link (auto-negotiation failed or link partner
* cannot auto-negotiate), the cable is plugged in (we have signal), * cannot auto-negotiate), the cable is plugged in (we have signal),
* and our link partner is not trying to auto-negotiate with us (we * and our link partner is not trying to auto-negotiate with us (we
* are receiving idles or data), we need to force link up. We also * are receiving idles or data), we need to force link up. We also
@ -691,8 +678,7 @@ s32 e1000_check_for_fiber_link_generic(struct e1000_hw *hw)
return ret_val; return ret_val;
} }
} else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) { } else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
/* /* If we are forcing link and we are receiving /C/ ordered
* If we are forcing link and we are receiving /C/ ordered
* sets, re-enable auto-negotiation in the TXCW register * sets, re-enable auto-negotiation in the TXCW register
* and disable forced link in the Device Control register * and disable forced link in the Device Control register
* in an attempt to auto-negotiate with our link partner. * in an attempt to auto-negotiate with our link partner.
@ -728,8 +714,7 @@ s32 e1000_check_for_serdes_link_generic(struct e1000_hw *hw)
status = E1000_READ_REG(hw, E1000_STATUS); status = E1000_READ_REG(hw, E1000_STATUS);
rxcw = E1000_READ_REG(hw, E1000_RXCW); rxcw = E1000_READ_REG(hw, E1000_RXCW);
/* /* If we don't have link (auto-negotiation failed or link partner
* If we don't have link (auto-negotiation failed or link partner
* cannot auto-negotiate), and our link partner is not trying to * cannot auto-negotiate), and our link partner is not trying to
* auto-negotiate with us (we are receiving idles or data), * auto-negotiate with us (we are receiving idles or data),
* we need to force link up. We also need to give auto-negotiation * we need to force link up. We also need to give auto-negotiation
@ -758,8 +743,7 @@ s32 e1000_check_for_serdes_link_generic(struct e1000_hw *hw)
return ret_val; return ret_val;
} }
} else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) { } else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
/* /* If we are forcing link and we are receiving /C/ ordered
* If we are forcing link and we are receiving /C/ ordered
* sets, re-enable auto-negotiation in the TXCW register * sets, re-enable auto-negotiation in the TXCW register
* and disable forced link in the Device Control register * and disable forced link in the Device Control register
* in an attempt to auto-negotiate with our link partner. * in an attempt to auto-negotiate with our link partner.
@ -770,8 +754,7 @@ s32 e1000_check_for_serdes_link_generic(struct e1000_hw *hw)
mac->serdes_has_link = true; mac->serdes_has_link = true;
} else if (!(E1000_TXCW_ANE & E1000_READ_REG(hw, E1000_TXCW))) { } else if (!(E1000_TXCW_ANE & E1000_READ_REG(hw, E1000_TXCW))) {
/* /* If we force link for non-auto-negotiation switch, check
* If we force link for non-auto-negotiation switch, check
* link status based on MAC synchronization for internal * link status based on MAC synchronization for internal
* serdes media type. * serdes media type.
*/ */
@ -830,8 +813,7 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw)
DEBUGFUNC("e1000_set_default_fc_generic"); DEBUGFUNC("e1000_set_default_fc_generic");
/* /* Read and store word 0x0F of the EEPROM. This word contains bits
* Read and store word 0x0F of the EEPROM. This word contains bits
* that determine the hardware's default PAUSE (flow control) mode, * that determine the hardware's default PAUSE (flow control) mode,
* a bit that determines whether the HW defaults to enabling or * a bit that determines whether the HW defaults to enabling or
* disabling auto-negotiation, and the direction of the * disabling auto-negotiation, and the direction of the
@ -846,7 +828,7 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw)
return ret_val; return ret_val;
} }
if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 0) if (!(nvm_data & NVM_WORD0F_PAUSE_MASK))
hw->fc.requested_mode = e1000_fc_none; hw->fc.requested_mode = e1000_fc_none;
else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) ==
NVM_WORD0F_ASM_DIR) NVM_WORD0F_ASM_DIR)
@ -873,15 +855,13 @@ s32 e1000_setup_link_generic(struct e1000_hw *hw)
DEBUGFUNC("e1000_setup_link_generic"); DEBUGFUNC("e1000_setup_link_generic");
/* /* In the case of the phy reset being blocked, we already have a link.
* In the case of the phy reset being blocked, we already have a link.
* We do not need to set it up again. * We do not need to set it up again.
*/ */
if (hw->phy.ops.check_reset_block(hw)) if (hw->phy.ops.check_reset_block && hw->phy.ops.check_reset_block(hw))
return E1000_SUCCESS; return E1000_SUCCESS;
/* /* If requested flow control is set to default, set flow control
* If requested flow control is set to default, set flow control
* based on the EEPROM flow control settings. * based on the EEPROM flow control settings.
*/ */
if (hw->fc.requested_mode == e1000_fc_default) { if (hw->fc.requested_mode == e1000_fc_default) {
@ -890,8 +870,7 @@ s32 e1000_setup_link_generic(struct e1000_hw *hw)
return ret_val; return ret_val;
} }
/* /* Save off the requested flow control mode for use later. Depending
* Save off the requested flow control mode for use later. Depending
* on the link partner's capabilities, we may or may not use this mode. * on the link partner's capabilities, we may or may not use this mode.
*/ */
hw->fc.current_mode = hw->fc.requested_mode; hw->fc.current_mode = hw->fc.requested_mode;
@ -904,8 +883,7 @@ s32 e1000_setup_link_generic(struct e1000_hw *hw)
if (ret_val) if (ret_val)
return ret_val; return ret_val;
/* /* Initialize the flow control address, type, and PAUSE timer
* Initialize the flow control address, type, and PAUSE timer
* registers to their default values. This is done even if flow * registers to their default values. This is done even if flow
* control is disabled, because it does not hurt anything to * control is disabled, because it does not hurt anything to
* initialize these registers. * initialize these registers.
@ -934,8 +912,7 @@ static s32 e1000_commit_fc_settings_generic(struct e1000_hw *hw)
DEBUGFUNC("e1000_commit_fc_settings_generic"); DEBUGFUNC("e1000_commit_fc_settings_generic");
/* /* Check for a software override of the flow control settings, and
* Check for a software override of the flow control settings, and
* setup the device accordingly. If auto-negotiation is enabled, then * setup the device accordingly. If auto-negotiation is enabled, then
* software will have to set the "PAUSE" bits to the correct value in * software will have to set the "PAUSE" bits to the correct value in
* the Transmit Config Word Register (TXCW) and re-start auto- * the Transmit Config Word Register (TXCW) and re-start auto-
@ -957,8 +934,7 @@ static s32 e1000_commit_fc_settings_generic(struct e1000_hw *hw)
txcw = (E1000_TXCW_ANE | E1000_TXCW_FD); txcw = (E1000_TXCW_ANE | E1000_TXCW_FD);
break; break;
case e1000_fc_rx_pause: case e1000_fc_rx_pause:
/* /* Rx Flow control is enabled and Tx Flow control is disabled
* Rx Flow control is enabled and Tx Flow control is disabled
* by a software over-ride. Since there really isn't a way to * by a software over-ride. Since there really isn't a way to
* advertise that we are capable of Rx Pause ONLY, we will * advertise that we are capable of Rx Pause ONLY, we will
* advertise that we support both symmetric and asymmetric Rx * advertise that we support both symmetric and asymmetric Rx
@ -968,15 +944,13 @@ static s32 e1000_commit_fc_settings_generic(struct e1000_hw *hw)
txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK); txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
break; break;
case e1000_fc_tx_pause: case e1000_fc_tx_pause:
/* /* Tx Flow control is enabled, and Rx Flow control is disabled,
* Tx Flow control is enabled, and Rx Flow control is disabled,
* by a software over-ride. * by a software over-ride.
*/ */
txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR); txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR);
break; break;
case e1000_fc_full: case e1000_fc_full:
/* /* Flow control (both Rx and Tx) is enabled by a software
* Flow control (both Rx and Tx) is enabled by a software
* over-ride. * over-ride.
*/ */
txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK); txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
@ -1008,8 +982,7 @@ static s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw)
DEBUGFUNC("e1000_poll_fiber_serdes_link_generic"); DEBUGFUNC("e1000_poll_fiber_serdes_link_generic");
/* /* If we have a signal (the cable is plugged in, or assumed true for
* If we have a signal (the cable is plugged in, or assumed true for
* serdes media) then poll for a "Link-Up" indication in the Device * serdes media) then poll for a "Link-Up" indication in the Device
* Status Register. Time-out if a link isn't seen in 500 milliseconds * Status Register. Time-out if a link isn't seen in 500 milliseconds
* seconds (Auto-negotiation should complete in less than 500 * seconds (Auto-negotiation should complete in less than 500
@ -1024,8 +997,7 @@ static s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw)
if (i == FIBER_LINK_UP_LIMIT) { if (i == FIBER_LINK_UP_LIMIT) {
DEBUGOUT("Never got a valid link from auto-neg!!!\n"); DEBUGOUT("Never got a valid link from auto-neg!!!\n");
mac->autoneg_failed = true; mac->autoneg_failed = true;
/* /* AutoNeg failed to achieve a link, so we'll call
* AutoNeg failed to achieve a link, so we'll call
* mac->check_for_link. This routine will force the * mac->check_for_link. This routine will force the
* link up if we detect a signal. This will allow us to * link up if we detect a signal. This will allow us to
* communicate with non-autonegotiating link partners. * communicate with non-autonegotiating link partners.
@ -1069,8 +1041,7 @@ s32 e1000_setup_fiber_serdes_link_generic(struct e1000_hw *hw)
if (ret_val) if (ret_val)
return ret_val; return ret_val;
/* /* Since auto-negotiation is enabled, take the link out of reset (the
* Since auto-negotiation is enabled, take the link out of reset (the
* link will be in reset, because we previously reset the chip). This * link will be in reset, because we previously reset the chip). This
* will restart auto-negotiation. If auto-negotiation is successful * will restart auto-negotiation. If auto-negotiation is successful
* then the link-up status bit will be set and the flow control enable * then the link-up status bit will be set and the flow control enable
@ -1082,8 +1053,7 @@ s32 e1000_setup_fiber_serdes_link_generic(struct e1000_hw *hw)
E1000_WRITE_FLUSH(hw); E1000_WRITE_FLUSH(hw);
msec_delay(1); msec_delay(1);
/* /* For these adapters, the SW definable pin 1 is set when the optics
* For these adapters, the SW definable pin 1 is set when the optics
* detect a signal. If we have a signal, then poll for a "Link-Up" * detect a signal. If we have a signal, then poll for a "Link-Up"
* indication. * indication.
*/ */
@ -1133,16 +1103,14 @@ s32 e1000_set_fc_watermarks_generic(struct e1000_hw *hw)
DEBUGFUNC("e1000_set_fc_watermarks_generic"); DEBUGFUNC("e1000_set_fc_watermarks_generic");
/* /* Set the flow control receive threshold registers. Normally,
* Set the flow control receive threshold registers. Normally,
* these registers will be set to a default threshold that may be * these registers will be set to a default threshold that may be
* adjusted later by the driver's runtime code. However, if the * adjusted later by the driver's runtime code. However, if the
* ability to transmit pause frames is not enabled, then these * ability to transmit pause frames is not enabled, then these
* registers will be set to 0. * registers will be set to 0.
*/ */
if (hw->fc.current_mode & e1000_fc_tx_pause) { if (hw->fc.current_mode & e1000_fc_tx_pause) {
/* /* We need to set up the Receive Threshold high and low water
* We need to set up the Receive Threshold high and low water
* marks as well as (optionally) enabling the transmission of * marks as well as (optionally) enabling the transmission of
* XON frames. * XON frames.
*/ */
@ -1176,8 +1144,7 @@ s32 e1000_force_mac_fc_generic(struct e1000_hw *hw)
ctrl = E1000_READ_REG(hw, E1000_CTRL); ctrl = E1000_READ_REG(hw, E1000_CTRL);
/* /* Because we didn't get link via the internal auto-negotiation
* Because we didn't get link via the internal auto-negotiation
* mechanism (we either forced link or we got link via PHY * mechanism (we either forced link or we got link via PHY
* auto-neg), we have to manually enable/disable transmit an * auto-neg), we have to manually enable/disable transmit an
* receive flow control. * receive flow control.
@ -1235,13 +1202,13 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
{ {
struct e1000_mac_info *mac = &hw->mac; struct e1000_mac_info *mac = &hw->mac;
s32 ret_val = E1000_SUCCESS; s32 ret_val = E1000_SUCCESS;
u32 pcs_status_reg, pcs_adv_reg, pcs_lp_ability_reg, pcs_ctrl_reg;
u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg; u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg;
u16 speed, duplex; u16 speed, duplex;
DEBUGFUNC("e1000_config_fc_after_link_up_generic"); DEBUGFUNC("e1000_config_fc_after_link_up_generic");
/* /* Check for the case where we have fiber media and auto-neg failed
* Check for the case where we have fiber media and auto-neg failed
* so we had to force link. In this case, we need to force the * so we had to force link. In this case, we need to force the
* configuration of the MAC to match the "fc" parameter. * configuration of the MAC to match the "fc" parameter.
*/ */
@ -1259,15 +1226,13 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
return ret_val; return ret_val;
} }
/* /* Check for the case where we have copper media and auto-neg is
* Check for the case where we have copper media and auto-neg is
* enabled. In this case, we need to check and see if Auto-Neg * enabled. In this case, we need to check and see if Auto-Neg
* has completed, and if so, how the PHY and link partner has * has completed, and if so, how the PHY and link partner has
* flow control configured. * flow control configured.
*/ */
if ((hw->phy.media_type == e1000_media_type_copper) && mac->autoneg) { if ((hw->phy.media_type == e1000_media_type_copper) && mac->autoneg) {
/* /* Read the MII Status Register and check to see if AutoNeg
* Read the MII Status Register and check to see if AutoNeg
* has completed. We read this twice because this reg has * has completed. We read this twice because this reg has
* some "sticky" (latched) bits. * some "sticky" (latched) bits.
*/ */
@ -1283,8 +1248,7 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
return ret_val; return ret_val;
} }
/* /* The AutoNeg process has completed, so we now need to
* The AutoNeg process has completed, so we now need to
* read both the Auto Negotiation Advertisement * read both the Auto Negotiation Advertisement
* Register (Address 4) and the Auto_Negotiation Base * Register (Address 4) and the Auto_Negotiation Base
* Page Ability Register (Address 5) to determine how * Page Ability Register (Address 5) to determine how
@ -1299,8 +1263,7 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
if (ret_val) if (ret_val)
return ret_val; return ret_val;
/* /* Two bits in the Auto Negotiation Advertisement Register
* Two bits in the Auto Negotiation Advertisement Register
* (Address 4) and two bits in the Auto Negotiation Base * (Address 4) and two bits in the Auto Negotiation Base
* Page Ability Register (Address 5) determine flow control * Page Ability Register (Address 5) determine flow control
* for both the PHY and the link partner. The following * for both the PHY and the link partner. The following
@ -1335,8 +1298,7 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
*/ */
if ((mii_nway_adv_reg & NWAY_AR_PAUSE) && if ((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) { (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) {
/* /* Now we need to check if the user selected Rx ONLY
* Now we need to check if the user selected Rx ONLY
* of pause frames. In this case, we had to advertise * of pause frames. In this case, we had to advertise
* FULL flow control because we could not advertise Rx * FULL flow control because we could not advertise Rx
* ONLY. Hence, we must now check to see if we need to * ONLY. Hence, we must now check to see if we need to
@ -1350,8 +1312,7 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
DEBUGOUT("Flow Control = Rx PAUSE frames only.\n"); DEBUGOUT("Flow Control = Rx PAUSE frames only.\n");
} }
} }
/* /* For receiving PAUSE frames ONLY.
* For receiving PAUSE frames ONLY.
* *
* LOCAL DEVICE | LINK PARTNER * LOCAL DEVICE | LINK PARTNER
* PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
@ -1365,8 +1326,7 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
hw->fc.current_mode = e1000_fc_tx_pause; hw->fc.current_mode = e1000_fc_tx_pause;
DEBUGOUT("Flow Control = Tx PAUSE frames only.\n"); DEBUGOUT("Flow Control = Tx PAUSE frames only.\n");
} }
/* /* For transmitting PAUSE frames ONLY.
* For transmitting PAUSE frames ONLY.
* *
* LOCAL DEVICE | LINK PARTNER * LOCAL DEVICE | LINK PARTNER
* PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
@ -1380,16 +1340,14 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
hw->fc.current_mode = e1000_fc_rx_pause; hw->fc.current_mode = e1000_fc_rx_pause;
DEBUGOUT("Flow Control = Rx PAUSE frames only.\n"); DEBUGOUT("Flow Control = Rx PAUSE frames only.\n");
} else { } else {
/* /* Per the IEEE spec, at this point flow control
* Per the IEEE spec, at this point flow control
* should be disabled. * should be disabled.
*/ */
hw->fc.current_mode = e1000_fc_none; hw->fc.current_mode = e1000_fc_none;
DEBUGOUT("Flow Control = NONE.\n"); DEBUGOUT("Flow Control = NONE.\n");
} }
/* /* Now we need to do one last check... If we auto-
* Now we need to do one last check... If we auto-
* negotiated to HALF DUPLEX, flow control should not be * negotiated to HALF DUPLEX, flow control should not be
* enabled per IEEE 802.3 spec. * enabled per IEEE 802.3 spec.
*/ */
@ -1402,8 +1360,7 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
if (duplex == HALF_DUPLEX) if (duplex == HALF_DUPLEX)
hw->fc.current_mode = e1000_fc_none; hw->fc.current_mode = e1000_fc_none;
/* /* Now we call a subroutine to actually force the MAC
* Now we call a subroutine to actually force the MAC
* controller to use the correct flow control settings. * controller to use the correct flow control settings.
*/ */
ret_val = e1000_force_mac_fc_generic(hw); ret_val = e1000_force_mac_fc_generic(hw);
@ -1413,6 +1370,130 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
} }
} }
/* Check for the case where we have SerDes media and auto-neg is
* enabled. In this case, we need to check and see if Auto-Neg
* has completed, and if so, how the PHY and link partner has
* flow control configured.
*/
if ((hw->phy.media_type == e1000_media_type_internal_serdes) &&
mac->autoneg) {
/* Read the PCS_LSTS and check to see if AutoNeg
* has completed.
*/
pcs_status_reg = E1000_READ_REG(hw, E1000_PCS_LSTAT);
if (!(pcs_status_reg & E1000_PCS_LSTS_AN_COMPLETE)) {
DEBUGOUT("PCS Auto Neg has not completed.\n");
return ret_val;
}
/* The AutoNeg process has completed, so we now need to
* read both the Auto Negotiation Advertisement
* Register (PCS_ANADV) and the Auto_Negotiation Base
* Page Ability Register (PCS_LPAB) to determine how
* flow control was negotiated.
*/
pcs_adv_reg = E1000_READ_REG(hw, E1000_PCS_ANADV);
pcs_lp_ability_reg = E1000_READ_REG(hw, E1000_PCS_LPAB);
/* Two bits in the Auto Negotiation Advertisement Register
* (PCS_ANADV) and two bits in the Auto Negotiation Base
* Page Ability Register (PCS_LPAB) determine flow control
* for both the PHY and the link partner. The following
* table, taken out of the IEEE 802.3ab/D6.0 dated March 25,
* 1999, describes these PAUSE resolution bits and how flow
* control is determined based upon these settings.
* NOTE: DC = Don't Care
*
* LOCAL DEVICE | LINK PARTNER
* PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution
*-------|---------|-------|---------|--------------------
* 0 | 0 | DC | DC | e1000_fc_none
* 0 | 1 | 0 | DC | e1000_fc_none
* 0 | 1 | 1 | 0 | e1000_fc_none
* 0 | 1 | 1 | 1 | e1000_fc_tx_pause
* 1 | 0 | 0 | DC | e1000_fc_none
* 1 | DC | 1 | DC | e1000_fc_full
* 1 | 1 | 0 | 0 | e1000_fc_none
* 1 | 1 | 0 | 1 | e1000_fc_rx_pause
*
* Are both PAUSE bits set to 1? If so, this implies
* Symmetric Flow Control is enabled at both ends. The
* ASM_DIR bits are irrelevant per the spec.
*
* For Symmetric Flow Control:
*
* LOCAL DEVICE | LINK PARTNER
* PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
*-------|---------|-------|---------|--------------------
* 1 | DC | 1 | DC | e1000_fc_full
*
*/
if ((pcs_adv_reg & E1000_TXCW_PAUSE) &&
(pcs_lp_ability_reg & E1000_TXCW_PAUSE)) {
/* Now we need to check if the user selected Rx ONLY
* of pause frames. In this case, we had to advertise
* FULL flow control because we could not advertise Rx
* ONLY. Hence, we must now check to see if we need to
* turn OFF the TRANSMISSION of PAUSE frames.
*/
if (hw->fc.requested_mode == e1000_fc_full) {
hw->fc.current_mode = e1000_fc_full;
DEBUGOUT("Flow Control = FULL.\n");
} else {
hw->fc.current_mode = e1000_fc_rx_pause;
DEBUGOUT("Flow Control = Rx PAUSE frames only.\n");
}
}
/* For receiving PAUSE frames ONLY.
*
* LOCAL DEVICE | LINK PARTNER
* PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
*-------|---------|-------|---------|--------------------
* 0 | 1 | 1 | 1 | e1000_fc_tx_pause
*/
else if (!(pcs_adv_reg & E1000_TXCW_PAUSE) &&
(pcs_adv_reg & E1000_TXCW_ASM_DIR) &&
(pcs_lp_ability_reg & E1000_TXCW_PAUSE) &&
(pcs_lp_ability_reg & E1000_TXCW_ASM_DIR)) {
hw->fc.current_mode = e1000_fc_tx_pause;
DEBUGOUT("Flow Control = Tx PAUSE frames only.\n");
}
/* For transmitting PAUSE frames ONLY.
*
* LOCAL DEVICE | LINK PARTNER
* PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
*-------|---------|-------|---------|--------------------
* 1 | 1 | 0 | 1 | e1000_fc_rx_pause
*/
else if ((pcs_adv_reg & E1000_TXCW_PAUSE) &&
(pcs_adv_reg & E1000_TXCW_ASM_DIR) &&
!(pcs_lp_ability_reg & E1000_TXCW_PAUSE) &&
(pcs_lp_ability_reg & E1000_TXCW_ASM_DIR)) {
hw->fc.current_mode = e1000_fc_rx_pause;
DEBUGOUT("Flow Control = Rx PAUSE frames only.\n");
} else {
/* Per the IEEE spec, at this point flow control
* should be disabled.
*/
hw->fc.current_mode = e1000_fc_none;
DEBUGOUT("Flow Control = NONE.\n");
}
/* Now we call a subroutine to actually force the MAC
* controller to use the correct flow control settings.
*/
pcs_ctrl_reg = E1000_READ_REG(hw, E1000_PCS_LCTL);
pcs_ctrl_reg |= E1000_PCS_LCTL_FORCE_FCTRL;
E1000_WRITE_REG(hw, E1000_PCS_LCTL, pcs_ctrl_reg);
ret_val = e1000_force_mac_fc_generic(hw);
if (ret_val) {
DEBUGOUT("Error forcing flow control settings\n");
return ret_val;
}
}
return E1000_SUCCESS; return E1000_SUCCESS;
} }
@ -1464,7 +1545,7 @@ s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
* Sets the speed and duplex to gigabit full duplex (the only possible option) * Sets the speed and duplex to gigabit full duplex (the only possible option)
* for fiber/serdes links. * for fiber/serdes links.
**/ **/
s32 e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw *hw, s32 e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw E1000_UNUSEDARG *hw,
u16 *speed, u16 *duplex) u16 *speed, u16 *duplex)
{ {
DEBUGFUNC("e1000_get_speed_and_duplex_fiber_serdes_generic"); DEBUGFUNC("e1000_get_speed_and_duplex_fiber_serdes_generic");
@ -1729,16 +1810,28 @@ s32 e1000_blink_led_generic(struct e1000_hw *hw)
ledctl_blink = E1000_LEDCTL_LED0_BLINK | ledctl_blink = E1000_LEDCTL_LED0_BLINK |
(E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT); (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT);
} else { } else {
/* /* Set the blink bit for each LED that's "on" (0x0E)
* set the blink bit for each LED that's "on" (0x0E) * (or "off" if inverted) in ledctl_mode2. The blink
* in ledctl_mode2 * logic in hardware only works when mode is set to "on"
* so it must be changed accordingly when the mode is
* "off" and inverted.
*/ */
ledctl_blink = hw->mac.ledctl_mode2; ledctl_blink = hw->mac.ledctl_mode2;
for (i = 0; i < 4; i++) for (i = 0; i < 32; i += 8) {
if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) == u32 mode = (hw->mac.ledctl_mode2 >> i) &
E1000_LEDCTL_MODE_LED_ON) E1000_LEDCTL_LED0_MODE_MASK;
ledctl_blink |= (E1000_LEDCTL_LED0_BLINK << u32 led_default = hw->mac.ledctl_default >> i;
(i * 8));
if ((!(led_default & E1000_LEDCTL_LED0_IVRT) &&
(mode == E1000_LEDCTL_MODE_LED_ON)) ||
((led_default & E1000_LEDCTL_LED0_IVRT) &&
(mode == E1000_LEDCTL_MODE_LED_OFF))) {
ledctl_blink &=
~(E1000_LEDCTL_LED0_MODE_MASK << i);
ledctl_blink |= (E1000_LEDCTL_LED0_BLINK |
E1000_LEDCTL_MODE_LED_ON) << i;
}
}
} }
E1000_WRITE_REG(hw, E1000_LEDCTL, ledctl_blink); E1000_WRITE_REG(hw, E1000_LEDCTL, ledctl_blink);
@ -1951,6 +2044,20 @@ static s32 e1000_validate_mdi_setting_generic(struct e1000_hw *hw)
return E1000_SUCCESS; return E1000_SUCCESS;
} }
/**
* e1000_validate_mdi_setting_crossover_generic - Verify MDI/MDIx settings
* @hw: pointer to the HW structure
*
* Validate the MDI/MDIx setting, allowing for auto-crossover during forced
* operation.
**/
s32 e1000_validate_mdi_setting_crossover_generic(struct e1000_hw E1000_UNUSEDARG *hw)
{
DEBUGFUNC("e1000_validate_mdi_setting_crossover_generic");
return E1000_SUCCESS;
}
/** /**
* e1000_write_8bit_ctrl_reg_generic - Write a 8bit CTRL register * e1000_write_8bit_ctrl_reg_generic - Write a 8bit CTRL register
* @hw: pointer to the HW structure * @hw: pointer to the HW structure

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -28,10 +28,6 @@
#ifndef _E1000_MAC_H_ #ifndef _E1000_MAC_H_
#define _E1000_MAC_H_ #define _E1000_MAC_H_
/*
* Functions that should not be called directly from drivers but can be used
* by other files in this 'shared code'
*/
void e1000_init_mac_ops_generic(struct e1000_hw *hw); void e1000_init_mac_ops_generic(struct e1000_hw *hw);
void e1000_null_mac_generic(struct e1000_hw *hw); void e1000_null_mac_generic(struct e1000_hw *hw);
s32 e1000_null_ops_generic(struct e1000_hw *hw); s32 e1000_null_ops_generic(struct e1000_hw *hw);
@ -65,6 +61,7 @@ s32 e1000_set_fc_watermarks_generic(struct e1000_hw *hw);
s32 e1000_setup_fiber_serdes_link_generic(struct e1000_hw *hw); s32 e1000_setup_fiber_serdes_link_generic(struct e1000_hw *hw);
s32 e1000_setup_led_generic(struct e1000_hw *hw); s32 e1000_setup_led_generic(struct e1000_hw *hw);
s32 e1000_setup_link_generic(struct e1000_hw *hw); s32 e1000_setup_link_generic(struct e1000_hw *hw);
s32 e1000_validate_mdi_setting_crossover_generic(struct e1000_hw *hw);
s32 e1000_write_8bit_ctrl_reg_generic(struct e1000_hw *hw, u32 reg, s32 e1000_write_8bit_ctrl_reg_generic(struct e1000_hw *hw, u32 reg,
u32 offset, u8 data); u32 offset, u8 data);
@ -73,9 +70,7 @@ u32 e1000_hash_mc_addr_generic(struct e1000_hw *hw, u8 *mc_addr);
void e1000_clear_hw_cntrs_base_generic(struct e1000_hw *hw); void e1000_clear_hw_cntrs_base_generic(struct e1000_hw *hw);
void e1000_clear_vfta_generic(struct e1000_hw *hw); void e1000_clear_vfta_generic(struct e1000_hw *hw);
void e1000_init_rx_addrs_generic(struct e1000_hw *hw, u16 rar_count); void e1000_init_rx_addrs_generic(struct e1000_hw *hw, u16 rar_count);
void e1000_pcix_mmrbc_workaround_generic(struct e1000_hw *hw);
void e1000_put_hw_semaphore_generic(struct e1000_hw *hw); void e1000_put_hw_semaphore_generic(struct e1000_hw *hw);
void e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index);
s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw); s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw);
void e1000_reset_adaptive_generic(struct e1000_hw *hw); void e1000_reset_adaptive_generic(struct e1000_hw *hw);
void e1000_set_pcie_no_snoop_generic(struct e1000_hw *hw, u32 no_snoop); void e1000_set_pcie_no_snoop_generic(struct e1000_hw *hw, u32 no_snoop);

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -75,7 +75,7 @@ s32 e1000_mng_enable_host_if_generic(struct e1000_hw *hw)
/* Check that the host interface is enabled. */ /* Check that the host interface is enabled. */
hicr = E1000_READ_REG(hw, E1000_HICR); hicr = E1000_READ_REG(hw, E1000_HICR);
if ((hicr & E1000_HICR_EN) == 0) { if (!(hicr & E1000_HICR_EN)) {
DEBUGOUT("E1000_HOST_EN bit disabled.\n"); DEBUGOUT("E1000_HOST_EN bit disabled.\n");
return -E1000_ERR_HOST_INTERFACE_COMMAND; return -E1000_ERR_HOST_INTERFACE_COMMAND;
} }
@ -138,11 +138,10 @@ bool e1000_enable_tx_pkt_filtering_generic(struct e1000_hw *hw)
return hw->mac.tx_pkt_filtering; return hw->mac.tx_pkt_filtering;
} }
/* /* If we can't read from the host interface for whatever
* If we can't read from the host interface for whatever
* reason, disable filtering. * reason, disable filtering.
*/ */
ret_val = hw->mac.ops.mng_enable_host_if(hw); ret_val = e1000_mng_enable_host_if_generic(hw);
if (ret_val != E1000_SUCCESS) { if (ret_val != E1000_SUCCESS) {
hw->mac.tx_pkt_filtering = false; hw->mac.tx_pkt_filtering = false;
return hw->mac.tx_pkt_filtering; return hw->mac.tx_pkt_filtering;
@ -158,8 +157,7 @@ bool e1000_enable_tx_pkt_filtering_generic(struct e1000_hw *hw)
hdr->checksum = 0; hdr->checksum = 0;
csum = e1000_calculate_checksum((u8 *)hdr, csum = e1000_calculate_checksum((u8 *)hdr,
E1000_MNG_DHCP_COOKIE_LENGTH); E1000_MNG_DHCP_COOKIE_LENGTH);
/* /* If either the checksums or signature don't match, then
* If either the checksums or signature don't match, then
* the cookie area isn't considered valid, in which case we * the cookie area isn't considered valid, in which case we
* take the safe route of assuming Tx filtering is enabled. * take the safe route of assuming Tx filtering is enabled.
*/ */
@ -252,8 +250,7 @@ s32 e1000_mng_host_if_write_generic(struct e1000_hw *hw, u8 *buffer,
/* Calculate length in DWORDs */ /* Calculate length in DWORDs */
length >>= 2; length >>= 2;
/* /* The device driver writes the relevant command block into the
* The device driver writes the relevant command block into the
* ram area. * ram area.
*/ */
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
@ -305,18 +302,18 @@ s32 e1000_mng_write_dhcp_info_generic(struct e1000_hw *hw, u8 *buffer,
hdr.checksum = 0; hdr.checksum = 0;
/* Enable the host interface */ /* Enable the host interface */
ret_val = hw->mac.ops.mng_enable_host_if(hw); ret_val = e1000_mng_enable_host_if_generic(hw);
if (ret_val) if (ret_val)
return ret_val; return ret_val;
/* Populate the host interface with the contents of "buffer". */ /* Populate the host interface with the contents of "buffer". */
ret_val = hw->mac.ops.mng_host_if_write(hw, buffer, length, ret_val = e1000_mng_host_if_write_generic(hw, buffer, length,
sizeof(hdr), &(hdr.checksum)); sizeof(hdr), &(hdr.checksum));
if (ret_val) if (ret_val)
return ret_val; return ret_val;
/* Write the manageability command header */ /* Write the manageability command header */
ret_val = hw->mac.ops.mng_write_cmd_header(hw, &hdr); ret_val = e1000_mng_write_cmd_header_generic(hw, &hdr);
if (ret_val) if (ret_val)
return ret_val; return ret_val;
@ -398,7 +395,7 @@ s32 e1000_host_interface_command(struct e1000_hw *hw, u8 *buffer, u32 length)
/* Check that the host interface is enabled. */ /* Check that the host interface is enabled. */
hicr = E1000_READ_REG(hw, E1000_HICR); hicr = E1000_READ_REG(hw, E1000_HICR);
if ((hicr & E1000_HICR_EN) == 0) { if (!(hicr & E1000_HICR_EN)) {
DEBUGOUT("E1000_HOST_EN bit disabled.\n"); DEBUGOUT("E1000_HOST_EN bit disabled.\n");
return -E1000_ERR_HOST_INTERFACE_COMMAND; return -E1000_ERR_HOST_INTERFACE_COMMAND;
} }
@ -406,8 +403,7 @@ s32 e1000_host_interface_command(struct e1000_hw *hw, u8 *buffer, u32 length)
/* Calculate length in DWORDs */ /* Calculate length in DWORDs */
length >>= 2; length >>= 2;
/* /* The device driver writes the relevant command block
* The device driver writes the relevant command block
* into the ram area. * into the ram area.
*/ */
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
@ -438,4 +434,123 @@ s32 e1000_host_interface_command(struct e1000_hw *hw, u8 *buffer, u32 length)
return E1000_SUCCESS; return E1000_SUCCESS;
} }
/**
* e1000_load_firmware - Writes proxy FW code buffer to host interface
* and execute.
* @hw: pointer to the HW structure
* @buffer: contains a firmware to write
* @length: the byte length of the buffer, must be multiple of 4 bytes
*
* Upon success returns E1000_SUCCESS, returns E1000_ERR_CONFIG if not enabled
* in HW else returns E1000_ERR_HOST_INTERFACE_COMMAND.
**/
s32 e1000_load_firmware(struct e1000_hw *hw, u8 *buffer, u32 length)
{
u32 hicr, hibba, fwsm, icr, i;
DEBUGFUNC("e1000_load_firmware");
if (hw->mac.type < e1000_i210) {
DEBUGOUT("Hardware doesn't support loading FW by the driver\n");
return -E1000_ERR_CONFIG;
}
/* Check that the host interface is enabled. */
hicr = E1000_READ_REG(hw, E1000_HICR);
if (!(hicr & E1000_HICR_EN)) {
DEBUGOUT("E1000_HOST_EN bit disabled.\n");
return -E1000_ERR_CONFIG;
}
if (!(hicr & E1000_HICR_MEMORY_BASE_EN)) {
DEBUGOUT("E1000_HICR_MEMORY_BASE_EN bit disabled.\n");
return -E1000_ERR_CONFIG;
}
if (length == 0 || length & 0x3 || length > E1000_HI_FW_MAX_LENGTH) {
DEBUGOUT("Buffer length failure.\n");
return -E1000_ERR_INVALID_ARGUMENT;
}
/* Clear notification from ROM-FW by reading ICR register */
icr = E1000_READ_REG(hw, E1000_ICR_V2);
/* Reset ROM-FW */
hicr = E1000_READ_REG(hw, E1000_HICR);
hicr |= E1000_HICR_FW_RESET_ENABLE;
E1000_WRITE_REG(hw, E1000_HICR, hicr);
hicr |= E1000_HICR_FW_RESET;
E1000_WRITE_REG(hw, E1000_HICR, hicr);
E1000_WRITE_FLUSH(hw);
/* Wait till MAC notifies about its readiness after ROM-FW reset */
for (i = 0; i < (E1000_HI_COMMAND_TIMEOUT * 2); i++) {
icr = E1000_READ_REG(hw, E1000_ICR_V2);
if (icr & E1000_ICR_MNG)
break;
msec_delay(1);
}
/* Check for timeout */
if (i == E1000_HI_COMMAND_TIMEOUT) {
DEBUGOUT("FW reset failed.\n");
return -E1000_ERR_HOST_INTERFACE_COMMAND;
}
/* Wait till MAC is ready to accept new FW code */
for (i = 0; i < E1000_HI_COMMAND_TIMEOUT; i++) {
fwsm = E1000_READ_REG(hw, E1000_FWSM);
if ((fwsm & E1000_FWSM_FW_VALID) &&
((fwsm & E1000_FWSM_MODE_MASK) >> E1000_FWSM_MODE_SHIFT ==
E1000_FWSM_HI_EN_ONLY_MODE))
break;
msec_delay(1);
}
/* Check for timeout */
if (i == E1000_HI_COMMAND_TIMEOUT) {
DEBUGOUT("FW reset failed.\n");
return -E1000_ERR_HOST_INTERFACE_COMMAND;
}
/* Calculate length in DWORDs */
length >>= 2;
/* The device driver writes the relevant FW code block
* into the ram area in DWORDs via 1kB ram addressing window.
*/
for (i = 0; i < length; i++) {
if (!(i % E1000_HI_FW_BLOCK_DWORD_LENGTH)) {
/* Point to correct 1kB ram window */
hibba = E1000_HI_FW_BASE_ADDRESS +
((E1000_HI_FW_BLOCK_DWORD_LENGTH << 2) *
(i / E1000_HI_FW_BLOCK_DWORD_LENGTH));
E1000_WRITE_REG(hw, E1000_HIBBA, hibba);
}
E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF,
i % E1000_HI_FW_BLOCK_DWORD_LENGTH,
*((u32 *)buffer + i));
}
/* Setting this bit tells the ARC that a new FW is ready to execute. */
hicr = E1000_READ_REG(hw, E1000_HICR);
E1000_WRITE_REG(hw, E1000_HICR, hicr | E1000_HICR_C);
for (i = 0; i < E1000_HI_COMMAND_TIMEOUT; i++) {
hicr = E1000_READ_REG(hw, E1000_HICR);
if (!(hicr & E1000_HICR_C))
break;
msec_delay(1);
}
/* Check for successful FW start. */
if (i == E1000_HI_COMMAND_TIMEOUT) {
DEBUGOUT("New FW did not start within timeout period.\n");
return -E1000_ERR_HOST_INTERFACE_COMMAND;
}
return E1000_SUCCESS;
}

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -40,6 +40,7 @@ s32 e1000_mng_write_dhcp_info_generic(struct e1000_hw *hw,
bool e1000_enable_mng_pass_thru(struct e1000_hw *hw); bool e1000_enable_mng_pass_thru(struct e1000_hw *hw);
u8 e1000_calculate_checksum(u8 *buffer, u32 length); u8 e1000_calculate_checksum(u8 *buffer, u32 length);
s32 e1000_host_interface_command(struct e1000_hw *hw, u8 *buffer, u32 length); s32 e1000_host_interface_command(struct e1000_hw *hw, u8 *buffer, u32 length);
s32 e1000_load_firmware(struct e1000_hw *hw, u8 *buffer, u32 length);
enum e1000_mng_mode { enum e1000_mng_mode {
e1000_mng_mode_none = 0, e1000_mng_mode_none = 0,
@ -53,6 +54,8 @@ enum e1000_mng_mode {
#define E1000_FWSM_MODE_MASK 0xE #define E1000_FWSM_MODE_MASK 0xE
#define E1000_FWSM_MODE_SHIFT 1 #define E1000_FWSM_MODE_SHIFT 1
#define E1000_FWSM_FW_VALID 0x00008000
#define E1000_FWSM_HI_EN_ONLY_MODE 0x4
#define E1000_MNG_IAMT_MODE 0x3 #define E1000_MNG_IAMT_MODE 0x3
#define E1000_MNG_DHCP_COOKIE_LENGTH 0x10 #define E1000_MNG_DHCP_COOKIE_LENGTH 0x10
@ -69,6 +72,10 @@ enum e1000_mng_mode {
#define E1000_HI_MAX_BLOCK_BYTE_LENGTH 1792 /* Num of bytes in range */ #define E1000_HI_MAX_BLOCK_BYTE_LENGTH 1792 /* Num of bytes in range */
#define E1000_HI_MAX_BLOCK_DWORD_LENGTH 448 /* Num of dwords in range */ #define E1000_HI_MAX_BLOCK_DWORD_LENGTH 448 /* Num of dwords in range */
#define E1000_HI_COMMAND_TIMEOUT 500 /* Process HI cmd limit */ #define E1000_HI_COMMAND_TIMEOUT 500 /* Process HI cmd limit */
#define E1000_HI_FW_BASE_ADDRESS 0x10000
#define E1000_HI_FW_MAX_LENGTH (64 * 1024) /* Num of bytes */
#define E1000_HI_FW_BLOCK_DWORD_LENGTH 256 /* Num of DWORDs per page */
#define E1000_HICR_MEMORY_BASE_EN 0x200 /* MB Enable bit - RO */
#define E1000_HICR_EN 0x01 /* Enable bit - RO */ #define E1000_HICR_EN 0x01 /* Enable bit - RO */
/* Driver sets this bit when done to put command in RAM */ /* Driver sets this bit when done to put command in RAM */
#define E1000_HICR_C 0x02 #define E1000_HICR_C 0x02

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -31,7 +31,8 @@
* e1000_null_mbx_check_for_flag - No-op function, return 0 * e1000_null_mbx_check_for_flag - No-op function, return 0
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
**/ **/
static s32 e1000_null_mbx_check_for_flag(struct e1000_hw *hw, u16 mbx_id) static s32 e1000_null_mbx_check_for_flag(struct e1000_hw E1000_UNUSEDARG *hw,
u16 E1000_UNUSEDARG mbx_id)
{ {
DEBUGFUNC("e1000_null_mbx_check_flag"); DEBUGFUNC("e1000_null_mbx_check_flag");
@ -42,8 +43,10 @@ static s32 e1000_null_mbx_check_for_flag(struct e1000_hw *hw, u16 mbx_id)
* e1000_null_mbx_transact - No-op function, return 0 * e1000_null_mbx_transact - No-op function, return 0
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
**/ **/
static s32 e1000_null_mbx_transact(struct e1000_hw *hw, u32 *msg, u16 size, static s32 e1000_null_mbx_transact(struct e1000_hw E1000_UNUSEDARG *hw,
u16 mbx_id) u32 E1000_UNUSEDARG *msg,
u16 E1000_UNUSEDARG size,
u16 E1000_UNUSEDARG mbx_id)
{ {
DEBUGFUNC("e1000_null_mbx_rw_msg"); DEBUGFUNC("e1000_null_mbx_rw_msg");
@ -497,6 +500,7 @@ s32 e1000_init_mbx_params_pf(struct e1000_hw *hw)
switch (hw->mac.type) { switch (hw->mac.type) {
case e1000_82576: case e1000_82576:
case e1000_i350: case e1000_i350:
case e1000_i354:
mbx->timeout = 0; mbx->timeout = 0;
mbx->usec_delay = 0; mbx->usec_delay = 0;

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -56,7 +56,9 @@ void e1000_init_nvm_ops_generic(struct e1000_hw *hw)
* e1000_null_nvm_read - No-op function, return 0 * e1000_null_nvm_read - No-op function, return 0
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
**/ **/
s32 e1000_null_read_nvm(struct e1000_hw *hw, u16 a, u16 b, u16 *c) s32 e1000_null_read_nvm(struct e1000_hw E1000_UNUSEDARG *hw,
u16 E1000_UNUSEDARG a, u16 E1000_UNUSEDARG b,
u16 E1000_UNUSEDARG *c)
{ {
DEBUGFUNC("e1000_null_read_nvm"); DEBUGFUNC("e1000_null_read_nvm");
return E1000_SUCCESS; return E1000_SUCCESS;
@ -66,7 +68,7 @@ s32 e1000_null_read_nvm(struct e1000_hw *hw, u16 a, u16 b, u16 *c)
* e1000_null_nvm_generic - No-op function, return void * e1000_null_nvm_generic - No-op function, return void
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
**/ **/
void e1000_null_nvm_generic(struct e1000_hw *hw) void e1000_null_nvm_generic(struct e1000_hw E1000_UNUSEDARG *hw)
{ {
DEBUGFUNC("e1000_null_nvm_generic"); DEBUGFUNC("e1000_null_nvm_generic");
return; return;
@ -76,7 +78,8 @@ void e1000_null_nvm_generic(struct e1000_hw *hw)
* e1000_null_led_default - No-op function, return 0 * e1000_null_led_default - No-op function, return 0
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
**/ **/
s32 e1000_null_led_default(struct e1000_hw *hw, u16 *data) s32 e1000_null_led_default(struct e1000_hw E1000_UNUSEDARG *hw,
u16 E1000_UNUSEDARG *data)
{ {
DEBUGFUNC("e1000_null_led_default"); DEBUGFUNC("e1000_null_led_default");
return E1000_SUCCESS; return E1000_SUCCESS;
@ -86,7 +89,9 @@ s32 e1000_null_led_default(struct e1000_hw *hw, u16 *data)
* e1000_null_write_nvm - No-op function, return 0 * e1000_null_write_nvm - No-op function, return 0
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
**/ **/
s32 e1000_null_write_nvm(struct e1000_hw *hw, u16 a, u16 b, u16 *c) s32 e1000_null_write_nvm(struct e1000_hw E1000_UNUSEDARG *hw,
u16 E1000_UNUSEDARG a, u16 E1000_UNUSEDARG b,
u16 E1000_UNUSEDARG *c)
{ {
DEBUGFUNC("e1000_null_write_nvm"); DEBUGFUNC("e1000_null_write_nvm");
return E1000_SUCCESS; return E1000_SUCCESS;
@ -359,8 +364,7 @@ static s32 e1000_ready_nvm_eeprom(struct e1000_hw *hw)
E1000_WRITE_FLUSH(hw); E1000_WRITE_FLUSH(hw);
usec_delay(1); usec_delay(1);
/* /* Read "Status Register" repeatedly until the LSB is cleared.
* Read "Status Register" repeatedly until the LSB is cleared.
* The EEPROM will signal that the command has been completed * The EEPROM will signal that the command has been completed
* by clearing bit 0 of the internal status register. If it's * by clearing bit 0 of the internal status register. If it's
* not cleared within 'timeout', then error out. * not cleared within 'timeout', then error out.
@ -405,8 +409,7 @@ s32 e1000_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
DEBUGFUNC("e1000_read_nvm_spi"); DEBUGFUNC("e1000_read_nvm_spi");
/* /* A check for invalid values: offset too large, too many words,
* A check for invalid values: offset too large, too many words,
* and not enough words. * and not enough words.
*/ */
if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
@ -432,8 +435,7 @@ s32 e1000_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
e1000_shift_out_eec_bits(hw, read_opcode, nvm->opcode_bits); e1000_shift_out_eec_bits(hw, read_opcode, nvm->opcode_bits);
e1000_shift_out_eec_bits(hw, (u16)(offset*2), nvm->address_bits); e1000_shift_out_eec_bits(hw, (u16)(offset*2), nvm->address_bits);
/* /* Read the data. SPI NVMs increment the address with each byte
* Read the data. SPI NVMs increment the address with each byte
* read and will roll over if reading beyond the end. This allows * read and will roll over if reading beyond the end. This allows
* us to read the whole NVM from any offset * us to read the whole NVM from any offset
*/ */
@ -465,8 +467,7 @@ s32 e1000_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
DEBUGFUNC("e1000_read_nvm_eerd"); DEBUGFUNC("e1000_read_nvm_eerd");
/* /* A check for invalid values: offset too large, too many words,
* A check for invalid values: offset too large, too many words,
* too many words for the offset, and not enough words. * too many words for the offset, and not enough words.
*/ */
if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
@ -506,13 +507,12 @@ s32 e1000_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
s32 e1000_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) s32 e1000_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
{ {
struct e1000_nvm_info *nvm = &hw->nvm; struct e1000_nvm_info *nvm = &hw->nvm;
s32 ret_val; s32 ret_val = -E1000_ERR_NVM;
u16 widx = 0; u16 widx = 0;
DEBUGFUNC("e1000_write_nvm_spi"); DEBUGFUNC("e1000_write_nvm_spi");
/* /* A check for invalid values: offset too large, too many words,
* A check for invalid values: offset too large, too many words,
* and not enough words. * and not enough words.
*/ */
if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
@ -521,16 +521,18 @@ s32 e1000_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
return -E1000_ERR_NVM; return -E1000_ERR_NVM;
} }
while (widx < words) {
u8 write_opcode = NVM_WRITE_OPCODE_SPI;
ret_val = nvm->ops.acquire(hw); ret_val = nvm->ops.acquire(hw);
if (ret_val) if (ret_val)
return ret_val; return ret_val;
while (widx < words) {
u8 write_opcode = NVM_WRITE_OPCODE_SPI;
ret_val = e1000_ready_nvm_eeprom(hw); ret_val = e1000_ready_nvm_eeprom(hw);
if (ret_val) if (ret_val) {
goto release; nvm->ops.release(hw);
return ret_val;
}
e1000_standby_nvm(hw); e1000_standby_nvm(hw);
@ -540,8 +542,7 @@ s32 e1000_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
e1000_standby_nvm(hw); e1000_standby_nvm(hw);
/* /* Some SPI eeproms use the 8th address bit embedded in the
* Some SPI eeproms use the 8th address bit embedded in the
* opcode * opcode
*/ */
if ((nvm->address_bits == 8) && (offset >= 128)) if ((nvm->address_bits == 8) && (offset >= 128))
@ -564,11 +565,9 @@ s32 e1000_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
break; break;
} }
} }
}
msec_delay(10); msec_delay(10);
release:
nvm->ops.release(hw); nvm->ops.release(hw);
}
return ret_val; return ret_val;
} }
@ -610,16 +609,15 @@ s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num,
return ret_val; return ret_val;
} }
/* /* if nvm_data is not ptr guard the PBA must be in legacy format which
* if nvm_data is not ptr guard the PBA must be in legacy format which
* means pba_ptr is actually our second data word for the PBA number * means pba_ptr is actually our second data word for the PBA number
* and we can decode it into an ascii string * and we can decode it into an ascii string
*/ */
if (nvm_data != NVM_PBA_PTR_GUARD) { if (nvm_data != NVM_PBA_PTR_GUARD) {
DEBUGOUT("NVM PBA number is not stored as string\n"); DEBUGOUT("NVM PBA number is not stored as string\n");
/* we will need 11 characters to store the PBA */ /* make sure callers buffer is big enough to store the PBA */
if (pba_num_size < 11) { if (pba_num_size < E1000_PBANUM_LENGTH) {
DEBUGOUT("PBA string buffer too small\n"); DEBUGOUT("PBA string buffer too small\n");
return E1000_ERR_NO_SPACE; return E1000_ERR_NO_SPACE;
} }
@ -720,7 +718,7 @@ s32 e1000_read_pba_length_generic(struct e1000_hw *hw, u32 *pba_num_size)
/* if data is not ptr guard the PBA must be in legacy format */ /* if data is not ptr guard the PBA must be in legacy format */
if (nvm_data != NVM_PBA_PTR_GUARD) { if (nvm_data != NVM_PBA_PTR_GUARD) {
*pba_num_size = 11; *pba_num_size = E1000_PBANUM_LENGTH;
return E1000_SUCCESS; return E1000_SUCCESS;
} }
@ -735,8 +733,7 @@ s32 e1000_read_pba_length_generic(struct e1000_hw *hw, u32 *pba_num_size)
return -E1000_ERR_NVM_PBA_SECTION; return -E1000_ERR_NVM_PBA_SECTION;
} }
/* /* Convert from length in u16 values to u8 chars, add 1 for NULL,
* Convert from length in u16 values to u8 chars, add 1 for NULL,
* and subtract 2 because length field is included in length. * and subtract 2 because length field is included in length.
*/ */
*pba_num_size = ((u32)length * 2) - 1; *pba_num_size = ((u32)length * 2) - 1;
@ -744,6 +741,10 @@ s32 e1000_read_pba_length_generic(struct e1000_hw *hw, u32 *pba_num_size)
return E1000_SUCCESS; return E1000_SUCCESS;
} }
/** /**
* e1000_read_mac_addr_generic - Read device MAC address * e1000_read_mac_addr_generic - Read device MAC address
* @hw: pointer to the HW structure * @hw: pointer to the HW structure
@ -857,3 +858,110 @@ static void e1000_reload_nvm_generic(struct e1000_hw *hw)
E1000_WRITE_FLUSH(hw); E1000_WRITE_FLUSH(hw);
} }
/**
* e1000_get_fw_version - Get firmware version information
* @hw: pointer to the HW structure
* @fw_vers: pointer to output version structure
*
* unsupported/not present features return 0 in version structure
**/
void e1000_get_fw_version(struct e1000_hw *hw, struct e1000_fw_version *fw_vers)
{
u16 eeprom_verh, eeprom_verl, etrack_test, fw_version;
u8 q, hval, rem, result;
u16 comb_verh, comb_verl, comb_offset;
memset(fw_vers, 0, sizeof(struct e1000_fw_version));
/* basic eeprom version numbers, bits used vary by part and by tool
* used to create the nvm images */
/* Check which data format we have */
hw->nvm.ops.read(hw, NVM_ETRACK_HIWORD, 1, &etrack_test);
switch (hw->mac.type) {
case e1000_i211:
e1000_read_invm_version(hw, fw_vers);
return;
case e1000_82575:
case e1000_82576:
case e1000_82580:
/* Use this format, unless EETRACK ID exists,
* then use alternate format
*/
if ((etrack_test & NVM_MAJOR_MASK) != NVM_ETRACK_VALID) {
hw->nvm.ops.read(hw, NVM_VERSION, 1, &fw_version);
fw_vers->eep_major = (fw_version & NVM_MAJOR_MASK)
>> NVM_MAJOR_SHIFT;
fw_vers->eep_minor = (fw_version & NVM_MINOR_MASK)
>> NVM_MINOR_SHIFT;
fw_vers->eep_build = (fw_version & NVM_IMAGE_ID_MASK);
goto etrack_id;
}
break;
case e1000_i210:
if (!(e1000_get_flash_presence_i210(hw))) {
e1000_read_invm_version(hw, fw_vers);
return;
}
/* fall through */
case e1000_i350:
case e1000_i354:
/* find combo image version */
hw->nvm.ops.read(hw, NVM_COMB_VER_PTR, 1, &comb_offset);
if ((comb_offset != 0x0) &&
(comb_offset != NVM_VER_INVALID)) {
hw->nvm.ops.read(hw, (NVM_COMB_VER_OFF + comb_offset
+ 1), 1, &comb_verh);
hw->nvm.ops.read(hw, (NVM_COMB_VER_OFF + comb_offset),
1, &comb_verl);
/* get Option Rom version if it exists and is valid */
if ((comb_verh && comb_verl) &&
((comb_verh != NVM_VER_INVALID) &&
(comb_verl != NVM_VER_INVALID))) {
fw_vers->or_valid = true;
fw_vers->or_major =
comb_verl >> NVM_COMB_VER_SHFT;
fw_vers->or_build =
(comb_verl << NVM_COMB_VER_SHFT)
| (comb_verh >> NVM_COMB_VER_SHFT);
fw_vers->or_patch =
comb_verh & NVM_COMB_VER_MASK;
}
}
break;
default:
return;
}
hw->nvm.ops.read(hw, NVM_VERSION, 1, &fw_version);
fw_vers->eep_major = (fw_version & NVM_MAJOR_MASK)
>> NVM_MAJOR_SHIFT;
/* check for old style version format in newer images*/
if ((fw_version & NVM_NEW_DEC_MASK) == 0x0) {
eeprom_verl = (fw_version & NVM_COMB_VER_MASK);
} else {
eeprom_verl = (fw_version & NVM_MINOR_MASK)
>> NVM_MINOR_SHIFT;
}
/* Convert minor value to hex before assigning to output struct
* Val to be converted will not be higher than 99, per tool output
*/
q = eeprom_verl / NVM_HEX_CONV;
hval = q * NVM_HEX_TENS;
rem = eeprom_verl % NVM_HEX_CONV;
result = hval + rem;
fw_vers->eep_minor = result;
etrack_id:
if ((etrack_test & NVM_MAJOR_MASK) == NVM_ETRACK_VALID) {
hw->nvm.ops.read(hw, NVM_ETRACK_WORD, 1, &eeprom_verl);
hw->nvm.ops.read(hw, (NVM_ETRACK_WORD + 1), 1, &eeprom_verh);
fw_vers->etrack_id = (eeprom_verh << NVM_ETRACK_SHIFT)
| eeprom_verl;
}
return;
}

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -28,6 +28,24 @@
#ifndef _E1000_NVM_H_ #ifndef _E1000_NVM_H_
#define _E1000_NVM_H_ #define _E1000_NVM_H_
struct e1000_fw_version {
u32 etrack_id;
u16 eep_major;
u16 eep_minor;
u16 eep_build;
u8 invm_major;
u8 invm_minor;
u8 invm_img_type;
bool or_valid;
u16 or_major;
u16 or_build;
u16 or_patch;
};
void e1000_init_nvm_ops_generic(struct e1000_hw *hw); void e1000_init_nvm_ops_generic(struct e1000_hw *hw);
s32 e1000_null_read_nvm(struct e1000_hw *hw, u16 a, u16 b, u16 *c); s32 e1000_null_read_nvm(struct e1000_hw *hw, u16 a, u16 b, u16 *c);
void e1000_null_nvm_generic(struct e1000_hw *hw); void e1000_null_nvm_generic(struct e1000_hw *hw);
@ -49,6 +67,9 @@ s32 e1000_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words,
u16 *data); u16 *data);
s32 e1000_update_nvm_checksum_generic(struct e1000_hw *hw); s32 e1000_update_nvm_checksum_generic(struct e1000_hw *hw);
void e1000_release_nvm_generic(struct e1000_hw *hw); void e1000_release_nvm_generic(struct e1000_hw *hw);
void e1000_get_fw_version(struct e1000_hw *hw,
struct e1000_fw_version *fw_vers);
#define E1000_STM_OPCODE 0xDB00 #define E1000_STM_OPCODE 0xDB00
#endif #endif

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -45,6 +45,7 @@
#endif #endif
#define usec_delay(x) udelay(x) #define usec_delay(x) udelay(x)
#define usec_delay_irq(x) udelay(x)
#ifndef msec_delay #ifndef msec_delay
#define msec_delay(x) do { \ #define msec_delay(x) do { \
/* Don't mdelay in interrupt context! */ \ /* Don't mdelay in interrupt context! */ \
@ -71,10 +72,19 @@
#endif #endif
#ifdef DEBUG
#define DEBUGOUT(S) printk(KERN_DEBUG S)
#define DEBUGOUT1(S, A...) printk(KERN_DEBUG S, ## A)
#else
#define DEBUGOUT(S) #define DEBUGOUT(S)
#define DEBUGOUT1(S, A...) #define DEBUGOUT1(S, A...)
#endif
#ifdef DEBUG_FUNC
#define DEBUGFUNC(F) DEBUGOUT(F "\n")
#else
#define DEBUGFUNC(F) #define DEBUGFUNC(F)
#endif
#define DEBUGOUT2 DEBUGOUT1 #define DEBUGOUT2 DEBUGOUT1
#define DEBUGOUT3 DEBUGOUT2 #define DEBUGOUT3 DEBUGOUT2
#define DEBUGOUT7 DEBUGOUT3 #define DEBUGOUT7 DEBUGOUT3

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -69,13 +69,11 @@ s32 e1000_read_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 *data);
s32 e1000_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data); s32 e1000_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data);
s32 e1000_set_d3_lplu_state_generic(struct e1000_hw *hw, bool active); s32 e1000_set_d3_lplu_state_generic(struct e1000_hw *hw, bool active);
s32 e1000_setup_copper_link_generic(struct e1000_hw *hw); s32 e1000_setup_copper_link_generic(struct e1000_hw *hw);
s32 e1000_wait_autoneg_generic(struct e1000_hw *hw);
s32 e1000_write_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 data); s32 e1000_write_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 data);
s32 e1000_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 data); s32 e1000_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 data);
s32 e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data); s32 e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data);
s32 e1000_write_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 data); s32 e1000_write_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 data);
s32 e1000_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data); s32 e1000_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data);
s32 e1000_phy_reset_dsp(struct e1000_hw *hw);
s32 e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, s32 e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
u32 usec_interval, bool *success); u32 usec_interval, bool *success);
s32 e1000_phy_init_script_igp3(struct e1000_hw *hw); s32 e1000_phy_init_script_igp3(struct e1000_hw *hw);
@ -96,6 +94,12 @@ s32 e1000_check_polarity_82577(struct e1000_hw *hw);
s32 e1000_get_phy_info_82577(struct e1000_hw *hw); s32 e1000_get_phy_info_82577(struct e1000_hw *hw);
s32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw); s32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw);
s32 e1000_get_cable_length_82577(struct e1000_hw *hw); s32 e1000_get_cable_length_82577(struct e1000_hw *hw);
s32 e1000_write_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 data);
s32 e1000_read_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 *data);
s32 e1000_read_phy_reg_mphy(struct e1000_hw *hw, u32 address, u32 *data);
s32 e1000_write_phy_reg_mphy(struct e1000_hw *hw, u32 address, u32 data,
bool line_override);
bool e1000_is_mphy_ready(struct e1000_hw *hw);
#define E1000_MAX_PHY_ADDR 8 #define E1000_MAX_PHY_ADDR 8
@ -104,20 +108,29 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw);
#define IGP01E1000_PHY_PORT_STATUS 0x11 /* Status */ #define IGP01E1000_PHY_PORT_STATUS 0x11 /* Status */
#define IGP01E1000_PHY_PORT_CTRL 0x12 /* Control */ #define IGP01E1000_PHY_PORT_CTRL 0x12 /* Control */
#define IGP01E1000_PHY_LINK_HEALTH 0x13 /* PHY Link Health */ #define IGP01E1000_PHY_LINK_HEALTH 0x13 /* PHY Link Health */
#define IGP01E1000_GMII_FIFO 0x14 /* GMII FIFO */
#define IGP01E1000_PHY_CHANNEL_QUALITY 0x15 /* PHY Channel Quality */
#define IGP02E1000_PHY_POWER_MGMT 0x19 /* Power Management */ #define IGP02E1000_PHY_POWER_MGMT 0x19 /* Power Management */
#define IGP01E1000_PHY_PAGE_SELECT 0x1F /* Page Select */ #define IGP01E1000_PHY_PAGE_SELECT 0x1F /* Page Select */
#define BM_PHY_PAGE_SELECT 22 /* Page Select for BM */ #define BM_PHY_PAGE_SELECT 22 /* Page Select for BM */
#define IGP_PAGE_SHIFT 5 #define IGP_PAGE_SHIFT 5
#define PHY_REG_MASK 0x1F #define PHY_REG_MASK 0x1F
/* GS40G - I210 PHY defines */
#define GS40G_PAGE_SELECT 0x16
#define GS40G_PAGE_SHIFT 16
#define GS40G_OFFSET_MASK 0xFFFF
#define GS40G_PAGE_2 0x20000
#define GS40G_MAC_REG2 0x15
#define GS40G_MAC_LB 0x4140
#define GS40G_MAC_SPEED_1G 0X0006
#define GS40G_COPPER_SPEC 0x0010
#define GS40G_CS_POWER_DOWN 0x0002
#define HV_INTC_FC_PAGE_START 768 #define HV_INTC_FC_PAGE_START 768
#define I82578_ADDR_REG 29 #define I82578_ADDR_REG 29
#define I82577_ADDR_REG 16 #define I82577_ADDR_REG 16
#define I82577_CFG_REG 22 #define I82577_CFG_REG 22
#define I82577_CFG_ASSERT_CRS_ON_TX (1 << 15) #define I82577_CFG_ASSERT_CRS_ON_TX (1 << 15)
#define I82577_CFG_ENABLE_DOWNSHIFT (3 << 10) /* auto downshift 100/10 */ #define I82577_CFG_ENABLE_DOWNSHIFT (3 << 10) /* auto downshift */
#define I82577_CTRL_REG 23 #define I82577_CTRL_REG 23
/* 82577 specific PHY registers */ /* 82577 specific PHY registers */
@ -131,11 +144,11 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw);
#define I82577_PHY_STATUS2_MDIX 0x0800 #define I82577_PHY_STATUS2_MDIX 0x0800
#define I82577_PHY_STATUS2_SPEED_MASK 0x0300 #define I82577_PHY_STATUS2_SPEED_MASK 0x0300
#define I82577_PHY_STATUS2_SPEED_1000MBPS 0x0200 #define I82577_PHY_STATUS2_SPEED_1000MBPS 0x0200
#define I82577_PHY_STATUS2_SPEED_100MBPS 0x0100
/* I82577 PHY Control 2 */ /* I82577 PHY Control 2 */
#define I82577_PHY_CTRL2_AUTO_MDIX 0x0400 #define I82577_PHY_CTRL2_MANUAL_MDIX 0x0200
#define I82577_PHY_CTRL2_FORCE_MDI_MDIX 0x0200 #define I82577_PHY_CTRL2_AUTO_MDI_MDIX 0x0400
#define I82577_PHY_CTRL2_MDIX_CFG_MASK 0x0600
/* I82577 PHY Diagnostics Status */ /* I82577 PHY Diagnostics Status */
#define I82577_DSTATUS_CABLE_LENGTH 0x03FC #define I82577_DSTATUS_CABLE_LENGTH 0x03FC
@ -146,6 +159,13 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw);
#define E1000_82580_PM_SPD 0x0001 /* Smart Power Down */ #define E1000_82580_PM_SPD 0x0001 /* Smart Power Down */
#define E1000_82580_PM_D0_LPLU 0x0002 /* For D0a states */ #define E1000_82580_PM_D0_LPLU 0x0002 /* For D0a states */
#define E1000_82580_PM_D3_LPLU 0x0004 /* For all other states */ #define E1000_82580_PM_D3_LPLU 0x0004 /* For all other states */
#define E1000_82580_PM_GO_LINKD 0x0020 /* Go Link Disconnect */
#define E1000_MPHY_DIS_ACCESS 0x80000000 /* disable_access bit */
#define E1000_MPHY_ENA_ACCESS 0x40000000 /* enable_access bit */
#define E1000_MPHY_BUSY 0x00010000 /* busy bit */
#define E1000_MPHY_ADDRESS_FNC_OVERRIDE 0x20000000 /* fnc_override bit */
#define E1000_MPHY_ADDRESS_MASK 0x0000FFFF /* address mask */
#define IGP01E1000_PHY_PCS_INIT_REG 0x00B4 #define IGP01E1000_PHY_PCS_INIT_REG 0x00B4
#define IGP01E1000_PHY_POLARITY_MASK 0x0078 #define IGP01E1000_PHY_POLARITY_MASK 0x0078
@ -155,10 +175,6 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw);
#define IGP01E1000_PSCFR_SMART_SPEED 0x0080 #define IGP01E1000_PSCFR_SMART_SPEED 0x0080
/* Enable flexible speed on link-up */
#define IGP01E1000_GMII_FLEX_SPD 0x0010
#define IGP01E1000_GMII_SPD 0x0020 /* Enable SPD */
#define IGP02E1000_PM_SPD 0x0001 /* Smart Power Down */ #define IGP02E1000_PM_SPD 0x0001 /* Smart Power Down */
#define IGP02E1000_PM_D0_LPLU 0x0002 /* For D0a states */ #define IGP02E1000_PM_D0_LPLU 0x0002 /* For D0a states */
#define IGP02E1000_PM_D3_LPLU 0x0004 /* For all other states */ #define IGP02E1000_PM_D3_LPLU 0x0004 /* For all other states */
@ -176,13 +192,10 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw);
#define IGP02E1000_PHY_AGC_C 0x14B1 #define IGP02E1000_PHY_AGC_C 0x14B1
#define IGP02E1000_PHY_AGC_D 0x18B1 #define IGP02E1000_PHY_AGC_D 0x18B1
#define IGP02E1000_AGC_LENGTH_SHIFT 9 /* Course - 15:13, Fine - 12:9 */ #define IGP02E1000_AGC_LENGTH_SHIFT 9 /* Course=15:13, Fine=12:9 */
#define IGP02E1000_AGC_LENGTH_MASK 0x7F #define IGP02E1000_AGC_LENGTH_MASK 0x7F
#define IGP02E1000_AGC_RANGE 15 #define IGP02E1000_AGC_RANGE 15
#define IGP03E1000_PHY_MISC_CTRL 0x1B
#define IGP03E1000_PHY_MISC_DUPLEX_MANUAL_SET 0x1000 /* Manually Set Duplex */
#define E1000_CABLE_LENGTH_UNDEFINED 0xFF #define E1000_CABLE_LENGTH_UNDEFINED 0xFF
#define E1000_KMRNCTRLSTA_OFFSET 0x001F0000 #define E1000_KMRNCTRLSTA_OFFSET 0x001F0000
@ -195,8 +208,8 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw);
#define E1000_KMRNCTRLSTA_DIAG_NELPBK 0x1000 /* Nearend Loopback mode */ #define E1000_KMRNCTRLSTA_DIAG_NELPBK 0x1000 /* Nearend Loopback mode */
#define IFE_PHY_EXTENDED_STATUS_CONTROL 0x10 #define IFE_PHY_EXTENDED_STATUS_CONTROL 0x10
#define IFE_PHY_SPECIAL_CONTROL 0x11 /* 100BaseTx PHY Special Control */ #define IFE_PHY_SPECIAL_CONTROL 0x11 /* 100BaseTx PHY Special Ctrl */
#define IFE_PHY_SPECIAL_CONTROL_LED 0x1B /* PHY Special and LED Control */ #define IFE_PHY_SPECIAL_CONTROL_LED 0x1B /* PHY Special and LED Ctrl */
#define IFE_PHY_MDIX_CONTROL 0x1C /* MDI/MDI-X Control */ #define IFE_PHY_MDIX_CONTROL 0x1C /* MDI/MDI-X Control */
/* IFE PHY Extended Status Control */ /* IFE PHY Extended Status Control */
@ -205,7 +218,6 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw);
/* IFE PHY Special Control */ /* IFE PHY Special Control */
#define IFE_PSC_AUTO_POLARITY_DISABLE 0x0010 #define IFE_PSC_AUTO_POLARITY_DISABLE 0x0010
#define IFE_PSC_FORCE_POLARITY 0x0020 #define IFE_PSC_FORCE_POLARITY 0x0020
#define IFE_PSC_DISABLE_DYNAMIC_POWER_DOWN 0x0100
/* IFE PHY Special Control and LED Control */ /* IFE PHY Special Control and LED Control */
#define IFE_PSCL_PROBE_MODE 0x0020 #define IFE_PSCL_PROBE_MODE 0x0020

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -29,7 +29,6 @@
#define _E1000_REGS_H_ #define _E1000_REGS_H_
#define E1000_CTRL 0x00000 /* Device Control - RW */ #define E1000_CTRL 0x00000 /* Device Control - RW */
#define E1000_CTRL_DUP 0x00004 /* Device Control Duplicate (Shadow) - RW */
#define E1000_STATUS 0x00008 /* Device Status - RO */ #define E1000_STATUS 0x00008 /* Device Status - RO */
#define E1000_EECD 0x00010 /* EEPROM/Flash Control - RW */ #define E1000_EECD 0x00010 /* EEPROM/Flash Control - RW */
#define E1000_EERD 0x00014 /* EEPROM Read - RW */ #define E1000_EERD 0x00014 /* EEPROM Read - RW */
@ -43,14 +42,15 @@
#define E1000_BARCTRL 0x5BBC /* BAR ctrl reg */ #define E1000_BARCTRL 0x5BBC /* BAR ctrl reg */
#define E1000_BARCTRL_FLSIZE 0x0700 /* BAR ctrl Flsize */ #define E1000_BARCTRL_FLSIZE 0x0700 /* BAR ctrl Flsize */
#define E1000_BARCTRL_CSRSIZE 0x2000 /* BAR ctrl CSR size */ #define E1000_BARCTRL_CSRSIZE 0x2000 /* BAR ctrl CSR size */
#define E1000_MPHY_ADDR_CTRL 0x0024 /* GbE MPHY Address Control */
#define E1000_MPHY_DATA 0x0E10 /* GBE MPHY Data */
#define E1000_MPHY_STAT 0x0E0C /* GBE MPHY Statistics */
#define E1000_PPHY_CTRL 0x5b48 /* PCIe PHY Control */
#define E1000_I350_BARCTRL 0x5BFC /* BAR ctrl reg */ #define E1000_I350_BARCTRL 0x5BFC /* BAR ctrl reg */
#define E1000_I350_DTXMXPKTSZ 0x355C /* Maximum sent packet size reg*/ #define E1000_I350_DTXMXPKTSZ 0x355C /* Maximum sent packet size reg*/
#define E1000_SCTL 0x00024 /* SerDes Control - RW */ #define E1000_SCTL 0x00024 /* SerDes Control - RW */
#define E1000_FCAL 0x00028 /* Flow Control Address Low - RW */ #define E1000_FCAL 0x00028 /* Flow Control Address Low - RW */
#define E1000_FCAH 0x0002C /* Flow Control Address High -RW */ #define E1000_FCAH 0x0002C /* Flow Control Address High -RW */
#define E1000_FEXT 0x0002C /* Future Extended - RW */
#define E1000_FEXTNVM4 0x00024 /* Future Extended NVM 4 - RW */
#define E1000_FEXTNVM 0x00028 /* Future Extended NVM - RW */
#define E1000_FCT 0x00030 /* Flow Control Type - RW */ #define E1000_FCT 0x00030 /* Flow Control Type - RW */
#define E1000_CONNSW 0x00034 /* Copper/Fiber switch control - RW */ #define E1000_CONNSW 0x00034 /* Copper/Fiber switch control - RW */
#define E1000_VET 0x00038 /* VLAN Ether Type - RW */ #define E1000_VET 0x00038 /* VLAN Ether Type - RW */
@ -77,9 +77,9 @@
#define E1000_TCTL 0x00400 /* Tx Control - RW */ #define E1000_TCTL 0x00400 /* Tx Control - RW */
#define E1000_TCTL_EXT 0x00404 /* Extended Tx Control - RW */ #define E1000_TCTL_EXT 0x00404 /* Extended Tx Control - RW */
#define E1000_TIPG 0x00410 /* Tx Inter-packet gap -RW */ #define E1000_TIPG 0x00410 /* Tx Inter-packet gap -RW */
#define E1000_TBT 0x00448 /* Tx Burst Timer - RW */
#define E1000_AIT 0x00458 /* Adaptive Interframe Spacing Throttle - RW */ #define E1000_AIT 0x00458 /* Adaptive Interframe Spacing Throttle - RW */
#define E1000_LEDCTL 0x00E00 /* LED Control - RW */ #define E1000_LEDCTL 0x00E00 /* LED Control - RW */
#define E1000_LEDMUX 0x08130 /* LED MUX Control */
#define E1000_EXTCNF_CTRL 0x00F00 /* Extended Configuration Control */ #define E1000_EXTCNF_CTRL 0x00F00 /* Extended Configuration Control */
#define E1000_EXTCNF_SIZE 0x00F08 /* Extended Configuration Size */ #define E1000_EXTCNF_SIZE 0x00F08 /* Extended Configuration Size */
#define E1000_PHY_CTRL 0x00F10 /* PHY Control Register in CSR */ #define E1000_PHY_CTRL 0x00F10 /* PHY Control Register in CSR */
@ -87,11 +87,7 @@
#define E1000_PBS 0x01008 /* Packet Buffer Size */ #define E1000_PBS 0x01008 /* Packet Buffer Size */
#define E1000_EEMNGCTL 0x01010 /* MNG EEprom Control */ #define E1000_EEMNGCTL 0x01010 /* MNG EEprom Control */
#define E1000_EEARBC 0x01024 /* EEPROM Auto Read Bus Control */ #define E1000_EEARBC 0x01024 /* EEPROM Auto Read Bus Control */
#define E1000_FLASHT 0x01028 /* FLASH Timer Register */
#define E1000_EEWR 0x0102C /* EEPROM Write Register - RW */ #define E1000_EEWR 0x0102C /* EEPROM Write Register - RW */
#define E1000_FLSWCTL 0x01030 /* FLASH control register */
#define E1000_FLSWDATA 0x01034 /* FLASH data register */
#define E1000_FLSWCNT 0x01038 /* FLASH Access Counter */
#define E1000_FLOP 0x0103C /* FLASH Opcode Register */ #define E1000_FLOP 0x0103C /* FLASH Opcode Register */
#define E1000_I2CCMD 0x01028 /* SFPI2C Command Register - RW */ #define E1000_I2CCMD 0x01028 /* SFPI2C Command Register - RW */
#define E1000_I2CPARAMS 0x0102C /* SFPI2C Parameters Register - RW */ #define E1000_I2CPARAMS 0x0102C /* SFPI2C Parameters Register - RW */
@ -117,7 +113,11 @@
#define E1000_FCRTL 0x02160 /* Flow Control Receive Threshold Low - RW */ #define E1000_FCRTL 0x02160 /* Flow Control Receive Threshold Low - RW */
#define E1000_FCRTH 0x02168 /* Flow Control Receive Threshold High - RW */ #define E1000_FCRTH 0x02168 /* Flow Control Receive Threshold High - RW */
#define E1000_PSRCTL 0x02170 /* Packet Split Receive Control - RW */ #define E1000_PSRCTL 0x02170 /* Packet Split Receive Control - RW */
#define E1000_RDFPCQ(_n) (0x02430 + (0x4 * (_n))) #define E1000_RDFH 0x02410 /* Rx Data FIFO Head - RW */
#define E1000_RDFT 0x02418 /* Rx Data FIFO Tail - RW */
#define E1000_RDFHS 0x02420 /* Rx Data FIFO Head Saved - RW */
#define E1000_RDFTS 0x02428 /* Rx Data FIFO Tail Saved - RW */
#define E1000_RDFPC 0x02430 /* Rx Data FIFO Packet Count - RW */
#define E1000_PBRTH 0x02458 /* PB Rx Arbitration Threshold - RW */ #define E1000_PBRTH 0x02458 /* PB Rx Arbitration Threshold - RW */
#define E1000_FCRTV 0x02460 /* Flow Control Refresh Timer Value - RW */ #define E1000_FCRTV 0x02460 /* Flow Control Refresh Timer Value - RW */
/* Split and Replication Rx Control - RW */ /* Split and Replication Rx Control - RW */
@ -132,8 +132,68 @@
#define E1000_PBRWAC 0x024E8 /* Rx packet buffer wrap around counter - RO */ #define E1000_PBRWAC 0x024E8 /* Rx packet buffer wrap around counter - RO */
#define E1000_RDTR 0x02820 /* Rx Delay Timer - RW */ #define E1000_RDTR 0x02820 /* Rx Delay Timer - RW */
#define E1000_RADV 0x0282C /* Rx Interrupt Absolute Delay Timer - RW */ #define E1000_RADV 0x0282C /* Rx Interrupt Absolute Delay Timer - RW */
/* #define E1000_EMIADD 0x10 /* Extended Memory Indirect Address */
* Convenience macros #define E1000_EMIDATA 0x11 /* Extended Memory Indirect Data */
#define E1000_SRWR 0x12018 /* Shadow Ram Write Register - RW */
#define E1000_I210_FLMNGCTL 0x12038
#define E1000_I210_FLMNGDATA 0x1203C
#define E1000_I210_FLMNGCNT 0x12040
#define E1000_I210_FLSWCTL 0x12048
#define E1000_I210_FLSWDATA 0x1204C
#define E1000_I210_FLSWCNT 0x12050
#define E1000_I210_FLA 0x1201C
#define E1000_INVM_DATA_REG(_n) (0x12120 + 4*(_n))
#define E1000_INVM_SIZE 64 /* Number of INVM Data Registers */
/* QAV Tx mode control register */
#define E1000_I210_TQAVCTRL 0x3570
/* QAV Tx mode control register bitfields masks */
/* QAV enable */
#define E1000_TQAVCTRL_MODE (1 << 0)
/* Fetching arbitration type */
#define E1000_TQAVCTRL_FETCH_ARB (1 << 4)
/* Fetching timer enable */
#define E1000_TQAVCTRL_FETCH_TIMER_ENABLE (1 << 5)
/* Launch arbitration type */
#define E1000_TQAVCTRL_LAUNCH_ARB (1 << 8)
/* Launch timer enable */
#define E1000_TQAVCTRL_LAUNCH_TIMER_ENABLE (1 << 9)
/* SP waits for SR enable */
#define E1000_TQAVCTRL_SP_WAIT_SR (1 << 10)
/* Fetching timer correction */
#define E1000_TQAVCTRL_FETCH_TIMER_DELTA_OFFSET 16
#define E1000_TQAVCTRL_FETCH_TIMER_DELTA \
(0xFFFF << E1000_TQAVCTRL_FETCH_TIMER_DELTA_OFFSET)
/* High credit registers where _n can be 0 or 1. */
#define E1000_I210_TQAVHC(_n) (0x300C + 0x40 * (_n))
/* Queues fetch arbitration priority control register */
#define E1000_I210_TQAVARBCTRL 0x3574
/* Queues priority masks where _n and _p can be 0-3. */
#define E1000_TQAVARBCTRL_QUEUE_PRI(_n, _p) ((_p) << (2 * _n))
/* QAV Tx mode control registers where _n can be 0 or 1. */
#define E1000_I210_TQAVCC(_n) (0x3004 + 0x40 * (_n))
/* QAV Tx mode control register bitfields masks */
#define E1000_TQAVCC_IDLE_SLOPE 0xFFFF /* Idle slope */
#define E1000_TQAVCC_KEEP_CREDITS (1 << 30) /* Keep credits opt enable */
#define E1000_TQAVCC_QUEUE_MODE (1 << 31) /* SP vs. SR Tx mode */
/* Good transmitted packets counter registers */
#define E1000_PQGPTC(_n) (0x010014 + (0x100 * (_n)))
/* Queues packet buffer size masks where _n can be 0-3 and _s 0-63 [kB] */
#define E1000_I210_TXPBS_SIZE(_n, _s) ((_s) << (6 * _n))
#define E1000_MMDAC 13 /* MMD Access Control */
#define E1000_MMDAAD 14 /* MMD Access Address/Data */
/* Convenience macros
* *
* Note: "_n" is the queue number of the register to be written to. * Note: "_n" is the queue number of the register to be written to.
* *
@ -181,7 +241,6 @@
#define E1000_TARC(_n) (0x03840 + ((_n) * 0x100)) #define E1000_TARC(_n) (0x03840 + ((_n) * 0x100))
#define E1000_RSRPD 0x02C00 /* Rx Small Packet Detect - RW */ #define E1000_RSRPD 0x02C00 /* Rx Small Packet Detect - RW */
#define E1000_RAID 0x02C08 /* Receive Ack Interrupt Delay - RW */ #define E1000_RAID 0x02C08 /* Receive Ack Interrupt Delay - RW */
#define E1000_TXDMAC 0x03000 /* Tx DMA Control - RW */
#define E1000_KABGTXD 0x03004 /* AFE Band Gap Transmit Ref Data */ #define E1000_KABGTXD 0x03004 /* AFE Band Gap Transmit Ref Data */
#define E1000_PSRTYPE(_i) (0x05480 + ((_i) * 4)) #define E1000_PSRTYPE(_i) (0x05480 + ((_i) * 4))
#define E1000_RAL(_i) (((_i) <= 15) ? (0x05400 + ((_i) * 8)) : \ #define E1000_RAL(_i) (((_i) <= 15) ? (0x05400 + ((_i) * 8)) : \
@ -218,7 +277,6 @@
#define E1000_DTXMXSZRQ 0x03540 #define E1000_DTXMXSZRQ 0x03540
#define E1000_TIDV 0x03820 /* Tx Interrupt Delay Value - RW */ #define E1000_TIDV 0x03820 /* Tx Interrupt Delay Value - RW */
#define E1000_TADV 0x0382C /* Tx Interrupt Absolute Delay Val - RW */ #define E1000_TADV 0x0382C /* Tx Interrupt Absolute Delay Val - RW */
#define E1000_TSPMT 0x03830 /* TCP Segmentation PAD & Min Threshold - RW */
#define E1000_CRCERRS 0x04000 /* CRC Error Count - R/clr */ #define E1000_CRCERRS 0x04000 /* CRC Error Count - R/clr */
#define E1000_ALGNERRC 0x04004 /* Alignment Error Count - R/clr */ #define E1000_ALGNERRC 0x04004 /* Alignment Error Count - R/clr */
#define E1000_SYMERRS 0x04008 /* Symbol Error Count - R/clr */ #define E1000_SYMERRS 0x04008 /* Symbol Error Count - R/clr */
@ -335,8 +393,7 @@
#define E1000_LSECTXKEY1(_n) (0x0B030 + (0x04 * (_n))) #define E1000_LSECTXKEY1(_n) (0x0B030 + (0x04 * (_n)))
#define E1000_LSECRXSA(_n) (0x0B310 + (0x04 * (_n))) /* Rx SAs - RW */ #define E1000_LSECRXSA(_n) (0x0B310 + (0x04 * (_n))) /* Rx SAs - RW */
#define E1000_LSECRXPN(_n) (0x0B330 + (0x04 * (_n))) /* Rx SAs - RW */ #define E1000_LSECRXPN(_n) (0x0B330 + (0x04 * (_n))) /* Rx SAs - RW */
/* /* LinkSec Rx Keys - where _n is the SA no. and _m the 4 dwords of the 128 bit
* LinkSec Rx Keys - where _n is the SA no. and _m the 4 dwords of the 128 bit
* key - RW. * key - RW.
*/ */
#define E1000_LSECRXKEY(_n, _m) (0x0B350 + (0x10 * (_n)) + (0x04 * (_m))) #define E1000_LSECRXKEY(_n, _m) (0x0B350 + (0x10 * (_n)) + (0x04 * (_m)))
@ -376,7 +433,6 @@
#define E1000_PCS_LPAB 0x0421C /* Link Partner Ability - RW */ #define E1000_PCS_LPAB 0x0421C /* Link Partner Ability - RW */
#define E1000_PCS_NPTX 0x04220 /* AN Next Page Transmit - RW */ #define E1000_PCS_NPTX 0x04220 /* AN Next Page Transmit - RW */
#define E1000_PCS_LPABNP 0x04224 /* Link Partner Ability Next Pg - RW */ #define E1000_PCS_LPABNP 0x04224 /* Link Partner Ability Next Pg - RW */
#define E1000_1GSTAT_RCV 0x04228 /* 1GSTAT Code Violation Pkt Cnt - RW */
#define E1000_RXCSUM 0x05000 /* Rx Checksum Control - RW */ #define E1000_RXCSUM 0x05000 /* Rx Checksum Control - RW */
#define E1000_RLPML 0x05004 /* Rx Long Packet Max Length */ #define E1000_RLPML 0x05004 /* Rx Long Packet Max Length */
#define E1000_RFCTL 0x05008 /* Receive Filter Control*/ #define E1000_RFCTL 0x05008 /* Receive Filter Control*/
@ -403,6 +459,7 @@
#define E1000_HOST_IF 0x08800 /* Host Interface */ #define E1000_HOST_IF 0x08800 /* Host Interface */
#define E1000_FFMT 0x09000 /* Flexible Filter Mask Table - RW Array */ #define E1000_FFMT 0x09000 /* Flexible Filter Mask Table - RW Array */
#define E1000_FFVT 0x09800 /* Flexible Filter Value Table - RW Array */ #define E1000_FFVT 0x09800 /* Flexible Filter Value Table - RW Array */
#define E1000_HIBBA 0x8F40 /* Host Interface Buffer Base Address */
/* Flexible Host Filter Table */ /* Flexible Host Filter Table */
#define E1000_FHFT(_n) (0x09000 + ((_n) * 0x100)) #define E1000_FHFT(_n) (0x09000 + ((_n) * 0x100))
/* Ext Flexible Host Filter Table */ /* Ext Flexible Host Filter Table */
@ -410,7 +467,6 @@
#define E1000_KMRNCTRLSTA 0x00034 /* MAC-PHY interface - RW */ #define E1000_KMRNCTRLSTA 0x00034 /* MAC-PHY interface - RW */
#define E1000_MDPHYA 0x0003C /* PHY address - RW */
#define E1000_MANC2H 0x05860 /* Management Control To Host - RW */ #define E1000_MANC2H 0x05860 /* Management Control To Host - RW */
/* Management Decision Filters */ /* Management Decision Filters */
#define E1000_MDEF(_n) (0x05890 + (4 * (_n))) #define E1000_MDEF(_n) (0x05890 + (4 * (_n)))
@ -443,15 +499,6 @@
#define E1000_IMIREXT(_i) (0x05AA0 + ((_i) * 4)) /* Immediate INTR Ext*/ #define E1000_IMIREXT(_i) (0x05AA0 + ((_i) * 4)) /* Immediate INTR Ext*/
#define E1000_IMIRVP 0x05AC0 /* Immediate INT Rx VLAN Priority -RW */ #define E1000_IMIRVP 0x05AC0 /* Immediate INT Rx VLAN Priority -RW */
#define E1000_MSIXBM(_i) (0x01600 + ((_i) * 4)) /* MSI-X Alloc Reg -RW */ #define E1000_MSIXBM(_i) (0x01600 + ((_i) * 4)) /* MSI-X Alloc Reg -RW */
/* MSI-X Table entry addr low reg - RW */
#define E1000_MSIXTADD(_i) (0x0C000 + ((_i) * 0x10))
/* MSI-X Table entry addr upper reg - RW */
#define E1000_MSIXTUADD(_i) (0x0C004 + ((_i) * 0x10))
/* MSI-X Table entry message reg - RW */
#define E1000_MSIXTMSG(_i) (0x0C008 + ((_i) * 0x10))
/* MSI-X Table entry vector ctrl reg - RW */
#define E1000_MSIXVCTRL(_i) (0x0C00C + ((_i) * 0x10))
#define E1000_MSIXPBA 0x0E000 /* MSI-X Pending bit array */
#define E1000_RETA(_i) (0x05C00 + ((_i) * 4)) /* Redirection Table - RW */ #define E1000_RETA(_i) (0x05C00 + ((_i) * 4)) /* Redirection Table - RW */
#define E1000_RSSRK(_i) (0x05C80 + ((_i) * 4)) /* RSS Random Key - RW */ #define E1000_RSSRK(_i) (0x05C80 + ((_i) * 4)) /* RSS Random Key - RW */
#define E1000_RSSIM 0x05864 /* RSS Interrupt Mask */ #define E1000_RSSIM 0x05864 /* RSS Interrupt Mask */
@ -501,8 +548,12 @@
#define E1000_SYSTIML 0x0B600 /* System time register Low - RO */ #define E1000_SYSTIML 0x0B600 /* System time register Low - RO */
#define E1000_SYSTIMH 0x0B604 /* System time register High - RO */ #define E1000_SYSTIMH 0x0B604 /* System time register High - RO */
#define E1000_TIMINCA 0x0B608 /* Increment attributes register - RW */ #define E1000_TIMINCA 0x0B608 /* Increment attributes register - RW */
#define E1000_TIMADJL 0x0B60C /* Time sync time adjustment offset Low - RW */
#define E1000_TIMADJH 0x0B610 /* Time sync time adjustment offset High - RW */
#define E1000_TSAUXC 0x0B640 /* Timesync Auxiliary Control register */ #define E1000_TSAUXC 0x0B640 /* Timesync Auxiliary Control register */
#define E1000_SYSTIMR 0x0B6F8 /* System time register Residue */ #define E1000_SYSTIMR 0x0B6F8 /* System time register Residue */
#define E1000_TSICR 0x0B66C /* Interrupt Cause Register */
#define E1000_TSIM 0x0B674 /* Interrupt Mask Register */
/* Filtering Registers */ /* Filtering Registers */
#define E1000_SAQF(_n) (0x05980 + (4 * (_n))) /* Source Address Queue Fltr */ #define E1000_SAQF(_n) (0x05980 + (4 * (_n))) /* Source Address Queue Fltr */
@ -591,4 +642,5 @@
#define E1000_O2BSPC 0x0415C /* OS2BMC packets transmitted by host */ #define E1000_O2BSPC 0x0415C /* OS2BMC packets transmitted by host */
#endif #endif

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -36,21 +36,17 @@
#include <net/tcp.h> #include <net/tcp.h>
#endif #endif
#undef HAVE_HW_TIME_STAMP
#ifdef HAVE_HW_TIME_STAMP
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#endif
#ifdef SIOCETHTOOL #ifdef SIOCETHTOOL
#include <linux/ethtool.h> #include <linux/ethtool.h>
#endif #endif
#undef HAVE_HW_TIME_STAMP
#ifdef HAVE_HW_TIME_STAMP
#include <linux/clocksource.h>
#include <linux/timecompare.h>
#include <linux/net_tstamp.h>
#endif
struct igb_adapter; struct igb_adapter;
#if defined(CONFIG_DCA) || defined(CONFIG_DCA_MODULE) #if defined(CONFIG_DCA) || defined(CONFIG_DCA_MODULE)
@ -60,11 +56,6 @@ struct igb_adapter;
#include <linux/dca.h> #include <linux/dca.h>
#endif #endif
#ifndef HAVE_HW_TIME_STAMP
#undef IGB_PER_PKT_TIMESTAMP
#endif
#include "kcompat.h" #include "kcompat.h"
#ifdef HAVE_SCTP #ifdef HAVE_SCTP
@ -84,6 +75,17 @@ struct igb_adapter;
printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \ printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \
__FUNCTION__ , ## args)) __FUNCTION__ , ## args))
#ifdef HAVE_PTP_1588_CLOCK
#include <linux/clocksource.h>
#include <linux/net_tstamp.h>
#include <linux/ptp_clock_kernel.h>
#endif /* HAVE_PTP_1588_CLOCK */
#ifdef HAVE_I2C_SUPPORT
#include <linux/i2c.h>
#include <linux/i2c-algo-bit.h>
#endif /* HAVE_I2C_SUPPORT */
/* Interrupt defines */ /* Interrupt defines */
#define IGB_START_ITR 648 /* ~6000 ints/sec */ #define IGB_START_ITR 648 /* ~6000 ints/sec */
#define IGB_4K_ITR 980 #define IGB_4K_ITR 980
@ -139,8 +141,10 @@ struct vf_data_storage {
u16 pf_vlan; /* When set, guest VLAN config not allowed. */ u16 pf_vlan; /* When set, guest VLAN config not allowed. */
u16 pf_qos; u16 pf_qos;
u16 tx_rate; u16 tx_rate;
#ifdef HAVE_VF_SPOOFCHK_CONFIGURE
bool spoofchk_enabled;
#endif
#endif #endif
struct pci_dev *vfdev;
}; };
#define IGB_VF_FLAG_CTS 0x00000001 /* VF is clear to send data */ #define IGB_VF_FLAG_CTS 0x00000001 /* VF is clear to send data */
@ -159,14 +163,12 @@ struct vf_data_storage {
* descriptors until either it has this many to write back, or the * descriptors until either it has this many to write back, or the
* ITR timer expires. * ITR timer expires.
*/ */
#define IGB_RX_PTHRESH 8 #define IGB_RX_PTHRESH ((hw->mac.type == e1000_i354) ? 12 : 8)
#define IGB_RX_HTHRESH 8 #define IGB_RX_HTHRESH 8
#define IGB_TX_PTHRESH 8 #define IGB_TX_PTHRESH ((hw->mac.type == e1000_i354) ? 20 : 8)
#define IGB_TX_HTHRESH 1 #define IGB_TX_HTHRESH 1
#define IGB_RX_WTHRESH ((hw->mac.type == e1000_82576 && \ #define IGB_RX_WTHRESH ((hw->mac.type == e1000_82576 && \
adapter->msix_entries) ? 1 : 4) adapter->msix_entries) ? 1 : 4)
#define IGB_TX_WTHRESH ((hw->mac.type == e1000_82576 && \
adapter->msix_entries) ? 1 : 16)
/* this is the size past which hardware will drop packets when setting LPE=0 */ /* this is the size past which hardware will drop packets when setting LPE=0 */
#define MAXIMUM_ETHERNET_VLAN_SIZE 1522 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
@ -178,9 +180,15 @@ struct vf_data_storage {
* i.e. RXBUFFER_512 --> size-1024 slab * i.e. RXBUFFER_512 --> size-1024 slab
*/ */
/* Supported Rx Buffer Sizes */ /* Supported Rx Buffer Sizes */
#define IGB_RXBUFFER_512 512 #define IGB_RXBUFFER_256 256
#define IGB_RXBUFFER_2048 2048
#define IGB_RXBUFFER_16384 16384 #define IGB_RXBUFFER_16384 16384
#define IGB_RX_HDR_LEN IGB_RXBUFFER_512 #define IGB_RX_HDR_LEN IGB_RXBUFFER_256
#if MAX_SKB_FRAGS < 8
#define IGB_RX_BUFSZ ALIGN(MAX_JUMBO_FRAME_SIZE / MAX_SKB_FRAGS, 1024)
#else
#define IGB_RX_BUFSZ IGB_RXBUFFER_2048
#endif
/* Packet Buffer allocations */ /* Packet Buffer allocations */
@ -190,15 +198,11 @@ struct vf_data_storage {
#define IGB_FC_PAUSE_TIME 0x0680 /* 858 usec */ #define IGB_FC_PAUSE_TIME 0x0680 /* 858 usec */
/* How many Tx Descriptors do we need to call netif_wake_queue ? */
#define IGB_TX_QUEUE_WAKE 32
/* How many Rx Buffers do we bundle into one write to the hardware ? */ /* How many Rx Buffers do we bundle into one write to the hardware ? */
#define IGB_RX_BUFFER_WRITE 16 /* Must be power of 2 */ #define IGB_RX_BUFFER_WRITE 16 /* Must be power of 2 */
#define IGB_EEPROM_APME 0x0400 #define IGB_EEPROM_APME 0x0400
#ifndef ETH_TP_MDI_X
#define AUTO_ALL_MODES 0 #define AUTO_ALL_MODES 0
#endif
#ifndef IGB_MASTER_SLAVE #ifndef IGB_MASTER_SLAVE
/* Switch to override PHY master/slave setting */ /* Switch to override PHY master/slave setting */
@ -212,7 +216,6 @@ struct vf_data_storage {
struct igb_lro_stats { struct igb_lro_stats {
u32 flushed; u32 flushed;
u32 coal; u32 coal;
u32 recycled;
}; };
/* /*
@ -238,10 +241,12 @@ struct igb_lro_list {
#endif /* IGB_NO_LRO */ #endif /* IGB_NO_LRO */
struct igb_cb { struct igb_cb {
#ifndef IGB_NO_LRO #ifndef IGB_NO_LRO
#ifdef CONFIG_IGB_DISABLE_PACKET_SPLIT
union { /* Union defining head/tail partner */ union { /* Union defining head/tail partner */
struct sk_buff *head; struct sk_buff *head;
struct sk_buff *tail; struct sk_buff *tail;
}; };
#endif
__be32 tsecr; /* timestamp echo response */ __be32 tsecr; /* timestamp echo response */
u32 tsval; /* timestamp value in host order */ u32 tsval; /* timestamp value in host order */
u32 next_seq; /* next expected sequence number */ u32 next_seq; /* next expected sequence number */
@ -255,14 +260,38 @@ struct igb_cb {
}; };
#define IGB_CB(skb) ((struct igb_cb *)(skb)->cb) #define IGB_CB(skb) ((struct igb_cb *)(skb)->cb)
#define IGB_TX_FLAGS_CSUM 0x00000001 enum igb_tx_flags {
#define IGB_TX_FLAGS_VLAN 0x00000002 /* cmd_type flags */
#define IGB_TX_FLAGS_TSO 0x00000004 IGB_TX_FLAGS_VLAN = 0x01,
#define IGB_TX_FLAGS_IPV4 0x00000008 IGB_TX_FLAGS_TSO = 0x02,
#define IGB_TX_FLAGS_TSTAMP 0x00000010 IGB_TX_FLAGS_TSTAMP = 0x04,
/* olinfo flags */
IGB_TX_FLAGS_IPV4 = 0x10,
IGB_TX_FLAGS_CSUM = 0x20,
};
/* VLAN info */
#define IGB_TX_FLAGS_VLAN_MASK 0xffff0000 #define IGB_TX_FLAGS_VLAN_MASK 0xffff0000
#define IGB_TX_FLAGS_VLAN_SHIFT 16 #define IGB_TX_FLAGS_VLAN_SHIFT 16
/*
* The largest size we can write to the descriptor is 65535. In order to
* maintain a power of two alignment we have to limit ourselves to 32K.
*/
#define IGB_MAX_TXD_PWR 15
#define IGB_MAX_DATA_PER_TXD (1 << IGB_MAX_TXD_PWR)
/* Tx Descriptors needed, worst case */
#define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IGB_MAX_DATA_PER_TXD)
#ifndef MAX_SKB_FRAGS
#define DESC_NEEDED 4
#elif (MAX_SKB_FRAGS < 16)
#define DESC_NEEDED ((MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE)) + 4)
#else
#define DESC_NEEDED (MAX_SKB_FRAGS + 4)
#endif
/* wrapper around a pointer to a socket buffer, /* wrapper around a pointer to a socket buffer,
* so a DMA handle can be stored along with the buffer */ * so a DMA handle can be stored along with the buffer */
struct igb_tx_buffer { struct igb_tx_buffer {
@ -278,11 +307,11 @@ struct igb_tx_buffer {
}; };
struct igb_rx_buffer { struct igb_rx_buffer {
struct sk_buff *skb;
dma_addr_t dma; dma_addr_t dma;
#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT #ifdef CONFIG_IGB_DISABLE_PACKET_SPLIT
struct sk_buff *skb;
#else
struct page *page; struct page *page;
dma_addr_t page_dma;
u32 page_offset; u32 page_offset;
#endif #endif
}; };
@ -299,6 +328,14 @@ struct igb_rx_queue_stats {
u64 drops; u64 drops;
u64 csum_err; u64 csum_err;
u64 alloc_failed; u64 alloc_failed;
u64 ipv4_packets; /* IPv4 headers processed */
u64 ipv4e_packets; /* IPv4E headers with extensions processed */
u64 ipv6_packets; /* IPv6 headers processed */
u64 ipv6e_packets; /* IPv6E headers with extensions processed */
u64 tcp_packets; /* TCP headers processed */
u64 udp_packets; /* UDP headers processed */
u64 sctp_packets; /* SCTP headers processed */
u64 nfs_packets; /* NFS headers processe */
}; };
struct igb_ring_container { struct igb_ring_container {
@ -310,29 +347,6 @@ struct igb_ring_container {
u8 itr; /* current ITR setting for ring */ u8 itr; /* current ITR setting for ring */
}; };
struct igb_q_vector {
struct igb_adapter *adapter; /* backlink */
int cpu; /* CPU for DCA */
u32 eims_value; /* EIMS mask value */
struct igb_ring_container rx, tx;
struct napi_struct napi;
int numa_node;
u16 itr_val;
u8 set_itr;
void __iomem *itr_register;
#ifndef IGB_NO_LRO
struct igb_lro_list *lrolist; /* LRO list for queue vector*/
#endif
char name[IFNAMSIZ + 9];
#ifndef HAVE_NETDEV_NAPI_LIST
struct net_device poll_dev;
#endif
} ____cacheline_internodealigned_in_smp;
struct igb_ring { struct igb_ring {
struct igb_q_vector *q_vector; /* backlink to q_vector */ struct igb_q_vector *q_vector; /* backlink to q_vector */
struct net_device *netdev; /* back pointer to net_device */ struct net_device *netdev; /* back pointer to net_device */
@ -341,18 +355,23 @@ struct igb_ring {
struct igb_tx_buffer *tx_buffer_info; struct igb_tx_buffer *tx_buffer_info;
struct igb_rx_buffer *rx_buffer_info; struct igb_rx_buffer *rx_buffer_info;
}; };
#ifdef HAVE_PTP_1588_CLOCK
unsigned long last_rx_timestamp;
#endif /* HAVE_PTP_1588_CLOCK */
void *desc; /* descriptor ring memory */ void *desc; /* descriptor ring memory */
unsigned long flags; /* ring specific flags */ unsigned long flags; /* ring specific flags */
void __iomem *tail; /* pointer to ring tail register */ void __iomem *tail; /* pointer to ring tail register */
dma_addr_t dma; /* phys address of the ring */
unsigned int size; /* length of desc. ring in bytes */
u16 count; /* number of desc. in the ring */ u16 count; /* number of desc. in the ring */
u8 queue_index; /* logical index of the ring*/ u8 queue_index; /* logical index of the ring*/
u8 reg_idx; /* physical index of the ring */ u8 reg_idx; /* physical index of the ring */
u32 size; /* length of desc. ring in bytes */
/* everything past this point are written often */ /* everything past this point are written often */
u16 next_to_clean ____cacheline_aligned_in_smp; u16 next_to_clean;
u16 next_to_use; u16 next_to_use;
u16 next_to_alloc;
union { union {
/* TX */ /* TX */
@ -364,6 +383,8 @@ struct igb_ring {
struct igb_rx_queue_stats rx_stats; struct igb_rx_queue_stats rx_stats;
#ifdef CONFIG_IGB_DISABLE_PACKET_SPLIT #ifdef CONFIG_IGB_DISABLE_PACKET_SPLIT
u16 rx_buffer_len; u16 rx_buffer_len;
#else
struct sk_buff *skb;
#endif #endif
}; };
}; };
@ -371,12 +392,32 @@ struct igb_ring {
struct net_device *vmdq_netdev; struct net_device *vmdq_netdev;
int vqueue_index; /* queue index for virtual netdev */ int vqueue_index; /* queue index for virtual netdev */
#endif #endif
/* Items past this point are only used during ring alloc / free */
dma_addr_t dma; /* phys address of the ring */
int numa_node; /* node to alloc ring memory on */
} ____cacheline_internodealigned_in_smp; } ____cacheline_internodealigned_in_smp;
struct igb_q_vector {
struct igb_adapter *adapter; /* backlink */
int cpu; /* CPU for DCA */
u32 eims_value; /* EIMS mask value */
u16 itr_val;
u8 set_itr;
void __iomem *itr_register;
struct igb_ring_container rx, tx;
struct napi_struct napi;
#ifndef IGB_NO_LRO
struct igb_lro_list lrolist; /* LRO list for queue vector*/
#endif
char name[IFNAMSIZ + 9];
#ifndef HAVE_NETDEV_NAPI_LIST
struct net_device poll_dev;
#endif
/* for dynamic allocation of rings associated with this q_vector */
struct igb_ring ring[0] ____cacheline_internodealigned_in_smp;
};
enum e1000_ring_flags_t { enum e1000_ring_flags_t {
#ifndef HAVE_NDO_SET_FEATURES #ifndef HAVE_NDO_SET_FEATURES
IGB_RING_FLAG_RX_CSUM, IGB_RING_FLAG_RX_CSUM,
@ -386,6 +427,7 @@ enum e1000_ring_flags_t {
IGB_RING_FLAG_TX_CTX_IDX, IGB_RING_FLAG_TX_CTX_IDX,
IGB_RING_FLAG_TX_DETECT_HANG, IGB_RING_FLAG_TX_DETECT_HANG,
}; };
struct igb_mac_addr { struct igb_mac_addr {
u8 addr[ETH_ALEN]; u8 addr[ETH_ALEN];
u16 queue; u16 queue;
@ -448,6 +490,26 @@ struct igb_therm_proc_data
// #endif /* IGB_PROCFS */ // #endif /* IGB_PROCFS */
// #endif /* EXT_THERMAL_SENSOR_SUPPORT */ // #endif /* EXT_THERMAL_SENSOR_SUPPORT */
#ifdef IGB_HWMON
#define IGB_HWMON_TYPE_LOC 0
#define IGB_HWMON_TYPE_TEMP 1
#define IGB_HWMON_TYPE_CAUTION 2
#define IGB_HWMON_TYPE_MAX 3
struct hwmon_attr {
struct device_attribute dev_attr;
struct e1000_hw *hw;
struct e1000_thermal_diode_data *sensor;
char name[12];
};
struct hwmon_buff {
struct device *device;
struct hwmon_attr *hwmon_list;
unsigned int n_hwmon;
};
#endif /* IGB_HWMON */
/* board specific private data structure */ /* board specific private data structure */
struct igb_adapter { struct igb_adapter {
#ifdef HAVE_VLAN_RX_REGISTER #ifdef HAVE_VLAN_RX_REGISTER
@ -496,6 +558,10 @@ struct igb_adapter {
bool fc_autoneg; bool fc_autoneg;
u8 tx_timeout_factor; u8 tx_timeout_factor;
#ifdef DEBUG
bool tx_hang_detected;
bool disable_hw_reset;
#endif
u32 max_frame_size; u32 max_frame_size;
/* OS defined structs */ /* OS defined structs */
@ -506,12 +572,6 @@ struct igb_adapter {
#ifndef IGB_NO_LRO #ifndef IGB_NO_LRO
struct igb_lro_stats lro_stats; struct igb_lro_stats lro_stats;
#endif #endif
#ifdef HAVE_HW_TIME_STAMP
struct cyclecounter cycles;
struct timecounter clock;
struct timecompare compare;
struct hwtstamp_config hwtstamp_config;
#endif
/* structs defined in e1000_hw.h */ /* structs defined in e1000_hw.h */
struct e1000_hw hw; struct e1000_hw hw;
@ -532,8 +592,6 @@ struct igb_adapter {
u32 eims_other; u32 eims_other;
/* to not mess up cache alignment, always add to the bottom */ /* to not mess up cache alignment, always add to the bottom */
u32 eeprom_wol;
u32 *config_space; u32 *config_space;
u16 tx_ring_count; u16 tx_ring_count;
u16 rx_ring_count; u16 rx_ring_count;
@ -549,8 +607,7 @@ struct igb_adapter {
int int_mode; int int_mode;
u32 rss_queues; u32 rss_queues;
u32 vmdq_pools; u32 vmdq_pools;
u16 fw_version; char fw_version[32];
int node;
u32 wvbr; u32 wvbr;
struct igb_mac_addr *mac_table; struct igb_mac_addr *mac_table;
#ifdef CONFIG_IGB_VMDQ_NETDEV #ifdef CONFIG_IGB_VMDQ_NETDEV
@ -562,17 +619,46 @@ struct igb_adapter {
/* External Thermal Sensor support flag */ /* External Thermal Sensor support flag */
bool ets; bool ets;
#ifdef IGB_SYSFS #ifdef IGB_HWMON
struct kobject *info_kobj; struct hwmon_buff igb_hwmon_buff;
struct kobject *therm_kobj[E1000_MAX_SENSORS]; #else /* IGB_HWMON */
#else /* IGB_SYSFS */
#ifdef IGB_PROCFS #ifdef IGB_PROCFS
struct proc_dir_entry *eth_dir; struct proc_dir_entry *eth_dir;
struct proc_dir_entry *info_dir; struct proc_dir_entry *info_dir;
struct proc_dir_entry *therm_dir[E1000_MAX_SENSORS]; struct proc_dir_entry *therm_dir[E1000_MAX_SENSORS];
struct igb_therm_proc_data therm_data[E1000_MAX_SENSORS]; struct igb_therm_proc_data therm_data[E1000_MAX_SENSORS];
bool old_lsc;
#endif /* IGB_PROCFS */ #endif /* IGB_PROCFS */
#endif /* IGB_SYSFS */ #endif /* IGB_HWMON */
u32 etrack_id;
#ifdef HAVE_PTP_1588_CLOCK
struct ptp_clock *ptp_clock;
struct ptp_clock_info ptp_caps;
struct delayed_work ptp_overflow_work;
struct work_struct ptp_tx_work;
struct sk_buff *ptp_tx_skb;
unsigned long ptp_tx_start;
unsigned long last_rx_ptp_check;
spinlock_t tmreg_lock;
struct cyclecounter cc;
struct timecounter tc;
u32 tx_hwtstamp_timeouts;
u32 rx_hwtstamp_cleared;
#endif /* HAVE_PTP_1588_CLOCK */
#ifdef HAVE_I2C_SUPPORT
struct i2c_algo_bit_data i2c_algo;
struct i2c_adapter i2c_adap;
struct i2c_client *i2c_client;
#endif /* HAVE_I2C_SUPPORT */
unsigned long link_check_timeout;
int devrc;
int copper_tries;
u16 eee_advert;
}; };
#ifdef CONFIG_IGB_VMDQ_NETDEV #ifdef CONFIG_IGB_VMDQ_NETDEV
@ -591,16 +677,28 @@ struct igb_vmdq_adapter {
}; };
#endif #endif
#define IGB_FLAG_HAS_MSI (1 << 0) #define IGB_FLAG_HAS_MSI (1 << 0)
#define IGB_FLAG_MSI_ENABLE (1 << 1) #define IGB_FLAG_DCA_ENABLED (1 << 1)
#define IGB_FLAG_DCA_ENABLED (1 << 2) #define IGB_FLAG_LLI_PUSH (1 << 2)
#define IGB_FLAG_LLI_PUSH (1 << 3) #define IGB_FLAG_QUAD_PORT_A (1 << 3)
#define IGB_FLAG_QUAD_PORT_A (1 << 4) #define IGB_FLAG_QUEUE_PAIRS (1 << 4)
#define IGB_FLAG_QUEUE_PAIRS (1 << 5) #define IGB_FLAG_EEE (1 << 5)
#define IGB_FLAG_EEE (1 << 6) #define IGB_FLAG_DMAC (1 << 6)
#define IGB_FLAG_DMAC (1 << 7) #define IGB_FLAG_DETECT_BAD_DMA (1 << 7)
#define IGB_FLAG_DETECT_BAD_DMA (1 << 8) #define IGB_FLAG_PTP (1 << 8)
#define IGB_FLAG_RSS_FIELD_IPV4_UDP (1 << 9)
#define IGB_FLAG_RSS_FIELD_IPV6_UDP (1 << 10)
#define IGB_FLAG_WOL_SUPPORTED (1 << 11)
#define IGB_FLAG_NEED_LINK_UPDATE (1 << 12)
#define IGB_FLAG_LOOPBACK_ENABLE (1 << 13)
#define IGB_FLAG_MEDIA_RESET (1 << 14)
#define IGB_FLAG_MAS_ENABLE (1 << 15)
/* Media Auto Sense */
#define IGB_MAS_ENABLE_0 0X0001
#define IGB_MAS_ENABLE_1 0X0002
#define IGB_MAS_ENABLE_2 0X0004
#define IGB_MAS_ENABLE_3 0X0008
#define IGB_MIN_TXPBSIZE 20408 #define IGB_MIN_TXPBSIZE 20408
#define IGB_TX_BUF_4096 4096 #define IGB_TX_BUF_4096 4096
@ -622,7 +720,6 @@ struct igb_vmdq_adapter {
#define IGB_DMAC_9000 9000 #define IGB_DMAC_9000 9000
#define IGB_DMAC_MAX 10000 #define IGB_DMAC_MAX 10000
#define IGB_82576_TSYNC_SHIFT 19 #define IGB_82576_TSYNC_SHIFT 19
#define IGB_82580_TSYNC_SHIFT 24 #define IGB_82580_TSYNC_SHIFT 24
#define IGB_TS_HDR_LEN 16 #define IGB_TS_HDR_LEN 16
@ -650,6 +747,8 @@ struct e1000_fw_hdr {
} cmd_or_resp; } cmd_or_resp;
u8 checksum; u8 checksum;
}; };
#pragma pack(push,1)
struct e1000_fw_drv_info { struct e1000_fw_drv_info {
struct e1000_fw_hdr hdr; struct e1000_fw_hdr hdr;
u8 port_num; u8 port_num;
@ -657,6 +756,8 @@ struct e1000_fw_drv_info {
u16 pad; /* end spacing to ensure length is mult. of dword */ u16 pad; /* end spacing to ensure length is mult. of dword */
u8 pad2; /* end spacing to ensure length is mult. of dword2 */ u8 pad2; /* end spacing to ensure length is mult. of dword2 */
}; };
#pragma pack(pop)
enum e1000_state_t { enum e1000_state_t {
__IGB_TESTING, __IGB_TESTING,
__IGB_RESETTING, __IGB_RESETTING,
@ -689,6 +790,42 @@ extern bool igb_has_link(struct igb_adapter *adapter);
extern void igb_set_ethtool_ops(struct net_device *); extern void igb_set_ethtool_ops(struct net_device *);
extern void igb_check_options(struct igb_adapter *); extern void igb_check_options(struct igb_adapter *);
extern void igb_power_up_link(struct igb_adapter *); extern void igb_power_up_link(struct igb_adapter *);
#ifdef HAVE_PTP_1588_CLOCK
extern void igb_ptp_init(struct igb_adapter *adapter);
extern void igb_ptp_stop(struct igb_adapter *adapter);
extern void igb_ptp_reset(struct igb_adapter *adapter);
extern void igb_ptp_tx_work(struct work_struct *work);
extern void igb_ptp_rx_hang(struct igb_adapter *adapter);
extern void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter);
extern void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,
struct sk_buff *skb);
extern void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector,
unsigned char *va,
struct sk_buff *skb);
static inline void igb_ptp_rx_hwtstamp(struct igb_ring *rx_ring,
union e1000_adv_rx_desc *rx_desc,
struct sk_buff *skb)
{
if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) {
#ifdef CONFIG_IGB_DISABLE_PACKET_SPLIT
igb_ptp_rx_pktstamp(rx_ring->q_vector, skb->data, skb);
skb_pull(skb, IGB_TS_HDR_LEN);
#endif
return;
}
if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TS))
igb_ptp_rx_rgtstamp(rx_ring->q_vector, skb);
/* Update the last_rx_timestamp timer in order to enable watchdog check
* for error case of latched timestamp on a dropped packet.
*/
rx_ring->last_rx_timestamp = jiffies;
}
extern int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
struct ifreq *ifr, int cmd);
#endif /* HAVE_PTP_1588_CLOCK */
#ifdef ETHTOOL_OPS_COMPAT #ifdef ETHTOOL_OPS_COMPAT
extern int ethtool_ioctl(struct ifreq *); extern int ethtool_ioctl(struct ifreq *);
#endif #endif
@ -703,8 +840,9 @@ extern void igb_enable_vlan_tags(struct igb_adapter *adapter);
extern void igb_vlan_mode(struct net_device *, u32); extern void igb_vlan_mode(struct net_device *, u32);
#endif #endif
#define E1000_PCS_CFG_IGN_SD 1
#ifdef IGB_SYSFS #ifdef IGB_HWMON
void igb_sysfs_exit(struct igb_adapter *adapter); void igb_sysfs_exit(struct igb_adapter *adapter);
int igb_sysfs_init(struct igb_adapter *adapter); int igb_sysfs_init(struct igb_adapter *adapter);
#else #else
@ -714,5 +852,8 @@ void igb_procfs_exit(struct igb_adapter* adapter);
int igb_procfs_topdir_init(void); int igb_procfs_topdir_init(void);
void igb_procfs_topdir_exit(void); void igb_procfs_topdir_exit(void);
#endif /* IGB_PROCFS */ #endif /* IGB_PROCFS */
#endif /* IGB_SYSFS */ #endif /* IGB_HWMON */
#endif /* _IGB_H_ */ #endif /* _IGB_H_ */

View File

@ -0,0 +1,29 @@
/*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information:
e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*******************************************************************************/
#include "igb.h"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,260 @@
/*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information:
e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*******************************************************************************/
#include "igb.h"
#include "e1000_82575.h"
#include "e1000_hw.h"
#ifdef IGB_HWMON
#include <linux/module.h>
#include <linux/types.h>
#include <linux/sysfs.h>
#include <linux/kobject.h>
#include <linux/device.h>
#include <linux/netdevice.h>
#include <linux/hwmon.h>
#include <linux/pci.h>
#ifdef HAVE_I2C_SUPPORT
static struct i2c_board_info i350_sensor_info = {
I2C_BOARD_INFO("i350bb", (0Xf8 >> 1)),
};
#endif /* HAVE_I2C_SUPPORT */
/* hwmon callback functions */
static ssize_t igb_hwmon_show_location(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct hwmon_attr *igb_attr = container_of(attr, struct hwmon_attr,
dev_attr);
return sprintf(buf, "loc%u\n",
igb_attr->sensor->location);
}
static ssize_t igb_hwmon_show_temp(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct hwmon_attr *igb_attr = container_of(attr, struct hwmon_attr,
dev_attr);
unsigned int value;
/* reset the temp field */
igb_attr->hw->mac.ops.get_thermal_sensor_data(igb_attr->hw);
value = igb_attr->sensor->temp;
/* display millidegree */
value *= 1000;
return sprintf(buf, "%u\n", value);
}
static ssize_t igb_hwmon_show_cautionthresh(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct hwmon_attr *igb_attr = container_of(attr, struct hwmon_attr,
dev_attr);
unsigned int value = igb_attr->sensor->caution_thresh;
/* display millidegree */
value *= 1000;
return sprintf(buf, "%u\n", value);
}
static ssize_t igb_hwmon_show_maxopthresh(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct hwmon_attr *igb_attr = container_of(attr, struct hwmon_attr,
dev_attr);
unsigned int value = igb_attr->sensor->max_op_thresh;
/* display millidegree */
value *= 1000;
return sprintf(buf, "%u\n", value);
}
/* igb_add_hwmon_attr - Create hwmon attr table for a hwmon sysfs file.
* @ adapter: pointer to the adapter structure
* @ offset: offset in the eeprom sensor data table
* @ type: type of sensor data to display
*
* For each file we want in hwmon's sysfs interface we need a device_attribute
* This is included in our hwmon_attr struct that contains the references to
* the data structures we need to get the data to display.
*/
static int igb_add_hwmon_attr(struct igb_adapter *adapter,
unsigned int offset, int type) {
int rc;
unsigned int n_attr;
struct hwmon_attr *igb_attr;
n_attr = adapter->igb_hwmon_buff.n_hwmon;
igb_attr = &adapter->igb_hwmon_buff.hwmon_list[n_attr];
switch (type) {
case IGB_HWMON_TYPE_LOC:
igb_attr->dev_attr.show = igb_hwmon_show_location;
snprintf(igb_attr->name, sizeof(igb_attr->name),
"temp%u_label", offset);
break;
case IGB_HWMON_TYPE_TEMP:
igb_attr->dev_attr.show = igb_hwmon_show_temp;
snprintf(igb_attr->name, sizeof(igb_attr->name),
"temp%u_input", offset);
break;
case IGB_HWMON_TYPE_CAUTION:
igb_attr->dev_attr.show = igb_hwmon_show_cautionthresh;
snprintf(igb_attr->name, sizeof(igb_attr->name),
"temp%u_max", offset);
break;
case IGB_HWMON_TYPE_MAX:
igb_attr->dev_attr.show = igb_hwmon_show_maxopthresh;
snprintf(igb_attr->name, sizeof(igb_attr->name),
"temp%u_crit", offset);
break;
default:
rc = -EPERM;
return rc;
}
/* These always the same regardless of type */
igb_attr->sensor =
&adapter->hw.mac.thermal_sensor_data.sensor[offset];
igb_attr->hw = &adapter->hw;
igb_attr->dev_attr.store = NULL;
igb_attr->dev_attr.attr.mode = S_IRUGO;
igb_attr->dev_attr.attr.name = igb_attr->name;
sysfs_attr_init(&igb_attr->dev_attr.attr);
rc = device_create_file(&adapter->pdev->dev,
&igb_attr->dev_attr);
if (rc == 0)
++adapter->igb_hwmon_buff.n_hwmon;
return rc;
}
static void igb_sysfs_del_adapter(struct igb_adapter *adapter)
{
int i;
if (adapter == NULL)
return;
for (i = 0; i < adapter->igb_hwmon_buff.n_hwmon; i++) {
device_remove_file(&adapter->pdev->dev,
&adapter->igb_hwmon_buff.hwmon_list[i].dev_attr);
}
kfree(adapter->igb_hwmon_buff.hwmon_list);
if (adapter->igb_hwmon_buff.device)
hwmon_device_unregister(adapter->igb_hwmon_buff.device);
}
/* called from igb_main.c */
void igb_sysfs_exit(struct igb_adapter *adapter)
{
igb_sysfs_del_adapter(adapter);
}
/* called from igb_main.c */
int igb_sysfs_init(struct igb_adapter *adapter)
{
struct hwmon_buff *igb_hwmon = &adapter->igb_hwmon_buff;
unsigned int i;
int n_attrs;
int rc = 0;
#ifdef HAVE_I2C_SUPPORT
struct i2c_client *client = NULL;
#endif /* HAVE_I2C_SUPPORT */
/* If this method isn't defined we don't support thermals */
if (adapter->hw.mac.ops.init_thermal_sensor_thresh == NULL)
goto exit;
/* Don't create thermal hwmon interface if no sensors present */
rc = (adapter->hw.mac.ops.init_thermal_sensor_thresh(&adapter->hw));
if (rc)
goto exit;
#ifdef HAVE_I2C_SUPPORT
/* init i2c_client */
client = i2c_new_device(&adapter->i2c_adap, &i350_sensor_info);
if (client == NULL) {
dev_info(&adapter->pdev->dev,
"Failed to create new i2c device..\n");
goto exit;
}
adapter->i2c_client = client;
#endif /* HAVE_I2C_SUPPORT */
/* Allocation space for max attributes
* max num sensors * values (loc, temp, max, caution)
*/
n_attrs = E1000_MAX_SENSORS * 4;
igb_hwmon->hwmon_list = kcalloc(n_attrs, sizeof(struct hwmon_attr),
GFP_KERNEL);
if (!igb_hwmon->hwmon_list) {
rc = -ENOMEM;
goto err;
}
igb_hwmon->device = hwmon_device_register(&adapter->pdev->dev);
if (IS_ERR(igb_hwmon->device)) {
rc = PTR_ERR(igb_hwmon->device);
goto err;
}
for (i = 0; i < E1000_MAX_SENSORS; i++) {
/* Only create hwmon sysfs entries for sensors that have
* meaningful data.
*/
if (adapter->hw.mac.thermal_sensor_data.sensor[i].location == 0)
continue;
/* Bail if any hwmon attr struct fails to initialize */
rc = igb_add_hwmon_attr(adapter, i, IGB_HWMON_TYPE_CAUTION);
rc |= igb_add_hwmon_attr(adapter, i, IGB_HWMON_TYPE_LOC);
rc |= igb_add_hwmon_attr(adapter, i, IGB_HWMON_TYPE_TEMP);
rc |= igb_add_hwmon_attr(adapter, i, IGB_HWMON_TYPE_MAX);
if (rc)
goto err;
}
goto exit;
err:
igb_sysfs_del_adapter(adapter);
exit:
return rc;
}
#endif /* IGB_HWMON */

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -59,12 +59,12 @@
*/ */
#define IGB_PARAM(X, desc) \ #define IGB_PARAM(X, desc) \
static const int __devinitdata X[IGB_MAX_NIC+1] = IGB_PARAM_INIT; \ static const int X[IGB_MAX_NIC+1] = IGB_PARAM_INIT; \
MODULE_PARM(X, "1-" __MODULE_STRING(IGB_MAX_NIC) "i"); \ MODULE_PARM(X, "1-" __MODULE_STRING(IGB_MAX_NIC) "i"); \
MODULE_PARM_DESC(X, desc); MODULE_PARM_DESC(X, desc);
#else #else
#define IGB_PARAM(X, desc) \ #define IGB_PARAM(X, desc) \
static int __devinitdata X[IGB_MAX_NIC+1] = IGB_PARAM_INIT; \ static int X[IGB_MAX_NIC+1] = IGB_PARAM_INIT; \
static unsigned int num_##X; \ static unsigned int num_##X; \
module_param_array_named(X, X, int, &num_##X, 0); \ module_param_array_named(X, X, int, &num_##X, 0); \
MODULE_PARM_DESC(X, desc); MODULE_PARM_DESC(X, desc);
@ -134,7 +134,7 @@ IGB_PARAM(LLISize, "Low Latency Interrupt on Packet Size (0-1500), default 0=off
* *
* Default Value: 1 * Default Value: 1
*/ */
IGB_PARAM(RSS, "Number of Receive-Side Scaling Descriptor Queues (0-8), default 1=number of cpus"); IGB_PARAM(RSS, "Number of Receive-Side Scaling Descriptor Queues (0-8), default 1, 0=number of cpus");
#define DEFAULT_RSS 1 #define DEFAULT_RSS 1
#define MAX_RSS 8 #define MAX_RSS 8
@ -175,6 +175,25 @@ IGB_PARAM(max_vfs, "Number of Virtual Functions: 0 = disable, 1-7 enable, defaul
IGB_PARAM(MDD, "Malicious Driver Detection (0/1), default 1 = enabled. " IGB_PARAM(MDD, "Malicious Driver Detection (0/1), default 1 = enabled. "
"Only available when max_vfs is greater than 0"); "Only available when max_vfs is greater than 0");
#ifdef DEBUG
/* Disable Hardware Reset on Tx Hang
*
* Valid Range: 0, 1
*
* Default Value: 0 (disabled, i.e. h/w will reset)
*/
IGB_PARAM(DisableHwReset, "Disable reset of hardware on Tx hang");
/* Dump Transmit and Receive buffers
*
* Valid Range: 0, 1
*
* Default Value: 0
*/
IGB_PARAM(DumpBuffers, "Dump Tx/Rx buffers on Tx hang or by request");
#endif /* DEBUG */
/* QueuePairs (Enable TX/RX queue pairs for interrupt handling) /* QueuePairs (Enable TX/RX queue pairs for interrupt handling)
* *
@ -182,7 +201,7 @@ IGB_PARAM(MDD, "Malicious Driver Detection (0/1), default 1 = enabled. "
* *
* Default Value: 1 * Default Value: 1
*/ */
IGB_PARAM(QueuePairs, "Enable TX/RX queue pairs for interrupt handling (0,1), default 1=on"); IGB_PARAM(QueuePairs, "Enable Tx/Rx queue pairs for interrupt handling (0,1), default 1=on");
#define DEFAULT_QUEUE_PAIRS 1 #define DEFAULT_QUEUE_PAIRS 1
#define MAX_QUEUE_PAIRS 1 #define MAX_QUEUE_PAIRS 1
@ -236,7 +255,7 @@ struct igb_option {
} arg; } arg;
}; };
static int __devinit igb_validate_option(unsigned int *value, static int igb_validate_option(unsigned int *value,
struct igb_option *opt, struct igb_option *opt,
struct igb_adapter *adapter) struct igb_adapter *adapter)
{ {
@ -297,7 +316,7 @@ static int __devinit igb_validate_option(unsigned int *value,
* in a variable in the adapter structure. * in a variable in the adapter structure.
**/ **/
void __devinit igb_check_options(struct igb_adapter *adapter) void igb_check_options(struct igb_adapter *adapter)
{ {
int bd = adapter->bd_number; int bd = adapter->bd_number;
struct e1000_hw *hw = &adapter->hw; struct e1000_hw *hw = &adapter->hw;
@ -330,7 +349,7 @@ void __devinit igb_check_options(struct igb_adapter *adapter)
case 0: case 0:
DPRINTK(PROBE, INFO, "%s turned off\n", DPRINTK(PROBE, INFO, "%s turned off\n",
opt.name); opt.name);
if(hw->mac.type >= e1000_i350) if (hw->mac.type >= e1000_i350)
adapter->dmac = IGB_DMAC_DISABLE; adapter->dmac = IGB_DMAC_DISABLE;
adapter->rx_itr_setting = itr; adapter->rx_itr_setting = itr;
break; break;
@ -489,6 +508,9 @@ void __devinit igb_check_options(struct igb_adapter *adapter)
switch (hw->mac.type) { switch (hw->mac.type) {
case e1000_82575: case e1000_82575:
case e1000_82580: case e1000_82580:
case e1000_i210:
case e1000_i211:
case e1000_i354:
adapter->vfs_allocated_count = 0; adapter->vfs_allocated_count = 0;
DPRINTK(PROBE, INFO, "SR-IOV option max_vfs not supported.\n"); DPRINTK(PROBE, INFO, "SR-IOV option max_vfs not supported.\n");
default: default:
@ -505,6 +527,8 @@ void __devinit igb_check_options(struct igb_adapter *adapter)
.arg = { .r = { .min = MIN_VMDQ, .arg = { .r = { .min = MIN_VMDQ,
.max = (MAX_VMDQ - adapter->vfs_allocated_count) } } .max = (MAX_VMDQ - adapter->vfs_allocated_count) } }
}; };
if ((hw->mac.type != e1000_i210) ||
(hw->mac.type != e1000_i211)) {
#ifdef module_param_array #ifdef module_param_array
if (num_VMDQ > bd) { if (num_VMDQ > bd) {
#endif #endif
@ -529,6 +553,11 @@ void __devinit igb_check_options(struct igb_adapter *adapter)
adapter->vmdq_pools = 0; adapter->vmdq_pools = 0;
} }
#endif #endif
} else {
DPRINTK(PROBE, INFO, "VMDq option is not supported.\n");
adapter->vmdq_pools = opt.def;
}
} }
{ /* RSS - Enable RSS multiqueue receives */ { /* RSS - Enable RSS multiqueue receives */
struct igb_option opt = { struct igb_option opt = {
@ -540,30 +569,48 @@ void __devinit igb_check_options(struct igb_adapter *adapter)
.max = MAX_RSS } } .max = MAX_RSS } }
}; };
if (adapter->vmdq_pools) {
switch (hw->mac.type) { switch (hw->mac.type) {
#ifndef CONFIG_IGB_VMDQ_NETDEV
case e1000_82576:
opt.arg.r.max = 2;
break;
case e1000_82575: case e1000_82575:
#ifndef CONFIG_IGB_VMDQ_NETDEV
if (!!adapter->vmdq_pools) {
if (adapter->vmdq_pools <= 2) {
if (adapter->vmdq_pools == 2) if (adapter->vmdq_pools == 2)
opt.arg.r.max = 3; opt.arg.r.max = 3;
if (adapter->vmdq_pools <= 2) } else {
opt.arg.r.max = 1;
}
} else {
opt.arg.r.max = 4;
}
#else
opt.arg.r.max = !!adapter->vmdq_pools ? 1 : 4;
#endif /* CONFIG_IGB_VMDQ_NETDEV */
break; break;
#endif case e1000_i210:
opt.arg.r.max = 4;
break;
case e1000_i211:
opt.arg.r.max = 2;
break;
case e1000_82576:
#ifndef CONFIG_IGB_VMDQ_NETDEV
if (!!adapter->vmdq_pools)
opt.arg.r.max = 2;
break;
#endif /* CONFIG_IGB_VMDQ_NETDEV */
case e1000_82580:
case e1000_i350:
case e1000_i354:
default: default:
if (!!adapter->vmdq_pools)
opt.arg.r.max = 1; opt.arg.r.max = 1;
break; break;
} }
}
switch (hw->mac.type) { if (adapter->int_mode != IGB_INT_MODE_MSIX) {
case e1000_82575: DPRINTK(PROBE, INFO, "RSS is not supported when in MSI/Legacy Interrupt mode, %s\n",
opt.arg.r.max = 4; opt.err);
break; opt.arg.r.max = 1;
default:
break;
} }
#ifdef module_param_array #ifdef module_param_array
@ -587,10 +634,10 @@ void __devinit igb_check_options(struct igb_adapter *adapter)
} }
#endif #endif
} }
{ /* QueuePairs - Enable TX/RX queue pairs for interrupt handling */ { /* QueuePairs - Enable Tx/Rx queue pairs for interrupt handling */
struct igb_option opt = { struct igb_option opt = {
.type = enable_option, .type = enable_option,
.name = "QueuePairs - TX/RX queue pairs for interrupt handling", .name = "QueuePairs - Tx/Rx queue pairs for interrupt handling",
.err = "defaulting to Enabled", .err = "defaulting to Enabled",
.def = OPTION_ENABLED .def = OPTION_ENABLED
}; };
@ -599,20 +646,32 @@ void __devinit igb_check_options(struct igb_adapter *adapter)
#endif #endif
unsigned int qp = QueuePairs[bd]; unsigned int qp = QueuePairs[bd];
/* /*
* we must enable queue pairs if the number of queues * We must enable queue pairs if the number of queues
* exceeds the number of avaialble interrupts. We are * exceeds the number of available interrupts. We are
* limited to 10, or 3 per unallocated vf. * limited to 10, or 3 per unallocated vf. On I210 and
* I211 devices, we are limited to 5 interrupts.
* However, since I211 only supports 2 queues, we do not
* need to check and override the user option.
*/ */
if ((adapter->rss_queues > 4) ||
(adapter->vmdq_pools > 4) ||
((adapter->rss_queues > 1) &&
((adapter->vmdq_pools > 3) ||
(adapter->vfs_allocated_count > 6)))) {
if (qp == OPTION_DISABLED) { if (qp == OPTION_DISABLED) {
if (adapter->rss_queues > 4)
qp = OPTION_ENABLED; qp = OPTION_ENABLED;
DPRINTK(PROBE, INFO,
"Number of queues exceeds available interrupts, %s\n",opt.err); if (adapter->vmdq_pools > 4)
} qp = OPTION_ENABLED;
if (adapter->rss_queues > 1 &&
(adapter->vmdq_pools > 3 ||
adapter->vfs_allocated_count > 6))
qp = OPTION_ENABLED;
if (hw->mac.type == e1000_i210 &&
adapter->rss_queues > 2)
qp = OPTION_ENABLED;
if (qp == OPTION_ENABLED)
DPRINTK(PROBE, INFO, "Number of queues exceeds available interrupts, %s\n",
opt.err);
} }
igb_validate_option(&qp, &opt, adapter); igb_validate_option(&qp, &opt, adapter);
adapter->flags |= qp ? IGB_FLAG_QUEUE_PAIRS : 0; adapter->flags |= qp ? IGB_FLAG_QUEUE_PAIRS : 0;
@ -762,52 +821,6 @@ void __devinit igb_check_options(struct igb_adapter *adapter)
#endif #endif
} }
#endif /* IGB_NO_LRO */ #endif /* IGB_NO_LRO */
{ /* Node assignment */
static struct igb_option opt = {
.type = range_option,
.name = "Node to start on",
.err = "defaulting to -1",
#ifdef HAVE_EARLY_VMALLOC_NODE
.def = 0,
#else
.def = -1,
#endif
.arg = { .r = { .min = 0,
.max = (MAX_NUMNODES - 1)}}
};
int node_param = opt.def;
/* if the default was zero then we need to set the
* default value to an online node, which is not
* necessarily zero, and the constant initializer
* above can't take first_online_node */
if (node_param == 0)
/* must set opt.def for validate */
opt.def = node_param = first_online_node;
#ifdef module_param_array
if (num_Node > bd) {
#endif
node_param = Node[bd];
igb_validate_option((uint *)&node_param, &opt, adapter);
if (node_param != OPTION_UNSET) {
DPRINTK(PROBE, INFO, "node set to %d\n", node_param);
}
#ifdef module_param_array
}
#endif
/* check sanity of the value */
if (node_param != -1 && !node_online(node_param)) {
DPRINTK(PROBE, INFO,
"ignoring node set to invalid value %d\n",
node_param);
node_param = opt.def;
}
adapter->node = node_param;
}
{ /* MDD - Enable Malicious Driver Detection. Only available when { /* MDD - Enable Malicious Driver Detection. Only available when
SR-IOV is enabled. */ SR-IOV is enabled. */
struct igb_option opt = { struct igb_option opt = {

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -30,7 +30,7 @@
#include "e1000_hw.h" #include "e1000_hw.h"
#ifdef IGB_PROCFS #ifdef IGB_PROCFS
#ifndef IGB_SYSFS #ifndef IGB_HWMON
#include <linux/module.h> #include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
@ -40,24 +40,6 @@
static struct proc_dir_entry *igb_top_dir = NULL; static struct proc_dir_entry *igb_top_dir = NULL;
static struct net_device_stats *procfs_get_stats(struct net_device *netdev)
{
#ifndef HAVE_NETDEV_STATS_IN_NETDEV
struct igb_adapter *adapter;
#endif
if (netdev == NULL)
return NULL;
#ifdef HAVE_NETDEV_STATS_IN_NETDEV
/* only return the current stats */
return &netdev->stats;
#else
adapter = netdev_priv(netdev);
/* only return the current stats */
return &adapter->net_stats;
#endif /* HAVE_NETDEV_STATS_IN_NETDEV */
}
bool igb_thermal_present(struct igb_adapter *adapter) bool igb_thermal_present(struct igb_adapter *adapter)
{ {
@ -85,17 +67,47 @@ bool igb_thermal_present(struct igb_adapter *adapter)
return true; return true;
} }
static int igb_fwbanner(char *page, char **start, off_t off, int count,
static int igb_macburn(char *page, char **start, off_t off, int count,
int *eof, void *data) int *eof, void *data)
{ {
struct e1000_hw *hw;
struct igb_adapter *adapter = (struct igb_adapter *)data; struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL) if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n"); return snprintf(page, count, "error: no adapter\n");
return snprintf(page, count, "%d.%d-%d\n", hw = &adapter->hw;
(adapter->fw_version & 0xF000) >> 12, if (hw == NULL)
(adapter->fw_version & 0x0FF0) >> 4, return snprintf(page, count, "error: no hw data\n");
adapter->fw_version & 0x000F);
return snprintf(page, count, "0x%02X%02X%02X%02X%02X%02X\n",
(unsigned int)hw->mac.perm_addr[0],
(unsigned int)hw->mac.perm_addr[1],
(unsigned int)hw->mac.perm_addr[2],
(unsigned int)hw->mac.perm_addr[3],
(unsigned int)hw->mac.perm_addr[4],
(unsigned int)hw->mac.perm_addr[5]);
}
static int igb_macadmn(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct e1000_hw *hw;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
hw = &adapter->hw;
if (hw == NULL)
return snprintf(page, count, "error: no hw data\n");
return snprintf(page, count, "0x%02X%02X%02X%02X%02X%02X\n",
(unsigned int)hw->mac.addr[0],
(unsigned int)hw->mac.addr[1],
(unsigned int)hw->mac.addr[2],
(unsigned int)hw->mac.addr[3],
(unsigned int)hw->mac.addr[4],
(unsigned int)hw->mac.addr[5]);
} }
static int igb_numeports(char *page, char **start, off_t off, int count, static int igb_numeports(char *page, char **start, off_t off, int count,
@ -127,573 +139,6 @@ static int igb_porttype(char *page, char **start, off_t off, int count,
test_bit(__IGB_DOWN, &adapter->state)); test_bit(__IGB_DOWN, &adapter->state));
} }
static int igb_portspeed(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
int speed = 0;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
switch (adapter->link_speed) {
case E1000_STATUS_SPEED_10:
speed = 10;
break;
case E1000_STATUS_SPEED_100:
speed = 100;
break;
case E1000_STATUS_SPEED_1000:
speed = 1000;
break;
}
return snprintf(page, count, "%d\n", speed);
}
static int igb_wqlflag(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
return snprintf(page, count, "%d\n", adapter->wol);
}
static int igb_xflowctl(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct e1000_hw *hw;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
hw = &adapter->hw;
if (hw == NULL)
return snprintf(page, count, "error: no hw data\n");
return snprintf(page, count, "%d\n", hw->fc.current_mode);
}
static int igb_rxdrops(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
struct net_device_stats *net_stats;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
net_stats = procfs_get_stats(adapter->netdev);
if (net_stats == NULL)
return snprintf(page, count, "error: no net stats\n");
return snprintf(page, count, "%lu\n",
net_stats->rx_dropped);
}
static int igb_rxerrors(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
struct net_device_stats *net_stats;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
net_stats = procfs_get_stats(adapter->netdev);
if (net_stats == NULL)
return snprintf(page, count, "error: no net stats\n");
return snprintf(page, count, "%lu\n", net_stats->rx_errors);
}
static int igb_rxupacks(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct e1000_hw *hw;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
hw = &adapter->hw;
if (hw == NULL)
return snprintf(page, count, "error: no hw data\n");
return snprintf(page, count, "%d\n", E1000_READ_REG(hw, E1000_TPR));
}
static int igb_rxmpacks(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct e1000_hw *hw;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
hw = &adapter->hw;
if (hw == NULL)
return snprintf(page, count, "error: no hw data\n");
return snprintf(page, count, "%d\n",
E1000_READ_REG(hw, E1000_MPRC));
}
static int igb_rxbpacks(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct e1000_hw *hw;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
hw = &adapter->hw;
if (hw == NULL)
return snprintf(page, count, "error: no hw data\n");
return snprintf(page, count, "%d\n",
E1000_READ_REG(hw, E1000_BPRC));
}
static int igb_txupacks(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct e1000_hw *hw;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
hw = &adapter->hw;
if (hw == NULL)
return snprintf(page, count, "error: no hw data\n");
return snprintf(page, count, "%d\n", E1000_READ_REG(hw, E1000_TPT));
}
static int igb_txmpacks(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct e1000_hw *hw;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
hw = &adapter->hw;
if (hw == NULL)
return snprintf(page, count, "error: no hw data\n");
return snprintf(page, count, "%d\n",
E1000_READ_REG(hw, E1000_MPTC));
}
static int igb_txbpacks(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct e1000_hw *hw;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
hw = &adapter->hw;
if (hw == NULL)
return snprintf(page, count, "error: no hw data\n");
return snprintf(page, count, "%d\n",
E1000_READ_REG(hw, E1000_BPTC));
}
static int igb_txerrors(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
struct net_device_stats *net_stats;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
net_stats = procfs_get_stats(adapter->netdev);
if (net_stats == NULL)
return snprintf(page, count, "error: no net stats\n");
return snprintf(page, count, "%lu\n",
net_stats->tx_errors);
}
static int igb_txdrops(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
struct net_device_stats *net_stats;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
net_stats = procfs_get_stats(adapter->netdev);
if (net_stats == NULL)
return snprintf(page, count, "error: no net stats\n");
return snprintf(page, count, "%lu\n",
net_stats->tx_dropped);
}
static int igb_rxframes(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
struct net_device_stats *net_stats;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
net_stats = procfs_get_stats(adapter->netdev);
if (net_stats == NULL)
return snprintf(page, count, "error: no net stats\n");
return snprintf(page, count, "%lu\n",
net_stats->rx_packets);
}
static int igb_rxbytes(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
struct net_device_stats *net_stats;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
net_stats = procfs_get_stats(adapter->netdev);
if (net_stats == NULL)
return snprintf(page, count, "error: no net stats\n");
return snprintf(page, count, "%lu\n",
net_stats->rx_bytes);
}
static int igb_txframes(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
struct net_device_stats *net_stats;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
net_stats = procfs_get_stats(adapter->netdev);
if (net_stats == NULL)
return snprintf(page, count, "error: no net stats\n");
return snprintf(page, count, "%lu\n",
net_stats->tx_packets);
}
static int igb_txbytes(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
struct net_device_stats *net_stats;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
net_stats = procfs_get_stats(adapter->netdev);
if (net_stats == NULL)
return snprintf(page, count, "error: no net stats\n");
return snprintf(page, count, "%lu\n",
net_stats->tx_bytes);
}
static int igb_linkstat(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
int bitmask = 0;
struct e1000_hw *hw;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
hw = &adapter->hw;
if (hw == NULL)
return snprintf(page, count, "error: no hw data\n");
if (test_bit(__IGB_DOWN, &adapter->state))
bitmask |= 1;
if (igb_has_link(adapter))
bitmask |= 2;
return snprintf(page, count, "0x%X\n", bitmask);
}
static int igb_funcid(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
struct net_device* netdev;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
netdev = adapter->netdev;
if (netdev == NULL)
return snprintf(page, count, "error: no net device\n");
return snprintf(page, count, "0x%lX\n", netdev->base_addr);
}
static int igb_funcvers(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
struct net_device* netdev;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
netdev = adapter->netdev;
if (netdev == NULL)
return snprintf(page, count, "error: no net device\n");
return snprintf(page, count, "%s\n", igb_driver_version);
}
static int igb_macburn(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct e1000_hw *hw;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
hw = &adapter->hw;
if (hw == NULL)
return snprintf(page, count, "error: no hw data\n");
return snprintf(page, count, "0x%X%X%X%X%X%X\n",
(unsigned int)hw->mac.perm_addr[0],
(unsigned int)hw->mac.perm_addr[1],
(unsigned int)hw->mac.perm_addr[2],
(unsigned int)hw->mac.perm_addr[3],
(unsigned int)hw->mac.perm_addr[4],
(unsigned int)hw->mac.perm_addr[5]);
}
static int igb_macadmn(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct e1000_hw *hw;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
hw = &adapter->hw;
if (hw == NULL)
return snprintf(page, count, "error: no hw data\n");
return snprintf(page, count, "0x%X%X%X%X%X%X\n",
(unsigned int)hw->mac.addr[0],
(unsigned int)hw->mac.addr[1],
(unsigned int)hw->mac.addr[2],
(unsigned int)hw->mac.addr[3],
(unsigned int)hw->mac.addr[4],
(unsigned int)hw->mac.addr[5]);
}
static int igb_maclla1(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct e1000_hw *hw;
u16 eeprom_buff[6];
int first_word = 0x37;
int word_count = 6;
int rc;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
hw = &adapter->hw;
if (hw == NULL)
return snprintf(page, count, "error: no hw data\n");
rc = e1000_read_nvm(hw, first_word, word_count,
eeprom_buff);
if (rc != E1000_SUCCESS)
return 0;
switch (hw->bus.func) {
case 0:
return snprintf(page, count, "0x%04X%04X%04X\n",
eeprom_buff[0],
eeprom_buff[1],
eeprom_buff[2]);
case 1:
return snprintf(page, count, "0x%04X%04X%04X\n",
eeprom_buff[3],
eeprom_buff[4],
eeprom_buff[5]);
}
return snprintf(page, count, "unexpected port %d\n", hw->bus.func);
}
static int igb_mtusize(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
struct net_device* netdev;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
netdev = adapter->netdev;
if (netdev == NULL)
return snprintf(page, count, "error: no net device\n");
return snprintf(page, count, "%d\n", netdev->mtu);
}
static int igb_featflag(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
int bitmask = 0;
#ifndef HAVE_NDO_SET_FEATURES
struct igb_ring *ring;
#endif
struct igb_adapter *adapter = (struct igb_adapter *)data;
struct net_device *netdev;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
netdev = adapter->netdev;
if (netdev == NULL)
return snprintf(page, count, "error: no net device\n");
#ifndef HAVE_NDO_SET_FEATURES
/* igb_get_rx_csum(netdev) doesn't compile so hard code */
ring = adapter->rx_ring[0];
bitmask = test_bit(IGB_RING_FLAG_RX_CSUM, &ring->flags);
return snprintf(page, count, "%d\n", bitmask);
#else
if (netdev->features & NETIF_F_RXCSUM)
bitmask |= 1;
return snprintf(page, count, "%d\n", bitmask);
#endif
}
static int igb_lsominct(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
return snprintf(page, count, "%d\n", 1);
}
static int igb_prommode(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
struct net_device *netdev;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
netdev = adapter->netdev;
if (netdev == NULL)
return snprintf(page, count, "error: no net device\n");
return snprintf(page, count, "%d\n",
netdev->flags & IFF_PROMISC);
}
static int igb_txdscqsz(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
return snprintf(page, count, "%d\n", adapter->tx_ring[0]->count);
}
static int igb_rxdscqsz(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
return snprintf(page, count, "%d\n", adapter->rx_ring[0]->count);
}
static int igb_rxqavg(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
int index;
int totaldiff = 0;
u16 ntc;
u16 ntu;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
if (adapter->num_rx_queues <= 0)
return snprintf(page, count,
"can't calculate, number of queues %d\n",
adapter->num_rx_queues);
for (index = 0; index < adapter->num_rx_queues; index++) {
ntc = adapter->rx_ring[index]->next_to_clean;
ntu = adapter->rx_ring[index]->next_to_use;
if (ntc >= ntu)
totaldiff += (ntc - ntu);
else
totaldiff += (adapter->rx_ring[index]->count
- ntu + ntc);
}
if (adapter->num_rx_queues <= 0)
return snprintf(page, count,
"can't calculate, number of queues %d\n",
adapter->num_rx_queues);
return snprintf(page, count, "%d\n", totaldiff/adapter->num_rx_queues);
}
static int igb_txqavg(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
int index;
int totaldiff = 0;
u16 ntc;
u16 ntu;
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
if (adapter->num_tx_queues <= 0)
return snprintf(page, count,
"can't calculate, number of queues %d\n",
adapter->num_tx_queues);
for (index = 0; index < adapter->num_tx_queues; index++) {
ntc = adapter->tx_ring[index]->next_to_clean;
ntu = adapter->tx_ring[index]->next_to_use;
if (ntc >= ntu)
totaldiff += (ntc - ntu);
else
totaldiff += (adapter->tx_ring[index]->count
- ntu + ntc);
}
if (adapter->num_tx_queues <= 0)
return snprintf(page, count,
"can't calculate, number of queues %d\n",
adapter->num_tx_queues);
return snprintf(page, count, "%d\n",
totaldiff/adapter->num_tx_queues);
}
static int igb_iovotype(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
return snprintf(page, count, "2\n");
}
static int igb_funcnbr(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct igb_adapter *adapter = (struct igb_adapter *)data;
if (adapter == NULL)
return snprintf(page, count, "error: no adapter\n");
return snprintf(page, count, "%d\n", adapter->vfs_allocated_count);
}
static int igb_therm_location(char *page, char **start, off_t off, static int igb_therm_location(char *page, char **start, off_t off,
int count, int *eof, void *data) int count, int *eof, void *data)
{ {
@ -755,42 +200,10 @@ struct igb_proc_type{
}; };
struct igb_proc_type igb_proc_entries[] = { struct igb_proc_type igb_proc_entries[] = {
{"fwbanner", &igb_fwbanner},
{"numeports", &igb_numeports}, {"numeports", &igb_numeports},
{"porttype", &igb_porttype}, {"porttype", &igb_porttype},
{"portspeed", &igb_portspeed},
{"wqlflag", &igb_wqlflag},
{"xflowctl", &igb_xflowctl},
{"rxdrops", &igb_rxdrops},
{"rxerrors", &igb_rxerrors},
{"rxupacks", &igb_rxupacks},
{"rxmpacks", &igb_rxmpacks},
{"rxbpacks", &igb_rxbpacks},
{"txdrops", &igb_txdrops},
{"txerrors", &igb_txerrors},
{"txupacks", &igb_txupacks},
{"txmpacks", &igb_txmpacks},
{"txbpacks", &igb_txbpacks},
{"rxframes", &igb_rxframes},
{"rxbytes", &igb_rxbytes},
{"txframes", &igb_txframes},
{"txbytes", &igb_txbytes},
{"linkstat", &igb_linkstat},
{"funcid", &igb_funcid},
{"funcvers", &igb_funcvers},
{"macburn", &igb_macburn}, {"macburn", &igb_macburn},
{"macadmn", &igb_macadmn}, {"macadmn", &igb_macadmn},
{"maclla1", &igb_maclla1},
{"mtusize", &igb_mtusize},
{"featflag", &igb_featflag},
{"lsominct", &igb_lsominct},
{"prommode", &igb_prommode},
{"txdscqsz", &igb_txdscqsz},
{"rxdscqsz", &igb_rxdscqsz},
{"txqavg", &igb_txqavg},
{"rxqavg", &igb_rxqavg},
{"iovotype", &igb_iovotype},
{"funcnbr", &igb_funcnbr},
{"", NULL} {"", NULL}
}; };
@ -856,7 +269,6 @@ int igb_procfs_topdir_init(void)
void igb_procfs_topdir_exit(void) void igb_procfs_topdir_exit(void)
{ {
// remove_proc_entry("driver", proc_root_driver);
remove_proc_entry("driver/igb", NULL); remove_proc_entry("driver/igb", NULL);
} }
@ -947,5 +359,5 @@ int igb_procfs_init(struct igb_adapter *adapter)
return rc; return rc;
} }
#endif /* !IGB_SYSFS */ #endif /* !IGB_HWMON */
#endif /* IGB_PROCFS */ #endif /* IGB_PROCFS */

View File

@ -0,0 +1,944 @@
/*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information:
e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*******************************************************************************/
/******************************************************************************
Copyright(c) 2011 Richard Cochran <richardcochran@gmail.com> for some of the
82576 and 82580 code
******************************************************************************/
#include "igb.h"
#include <linux/module.h>
#include <linux/device.h>
#include <linux/pci.h>
#include <linux/ptp_classify.h>
#define INCVALUE_MASK 0x7fffffff
#define ISGN 0x80000000
/*
* The 82580 timesync updates the system timer every 8ns by 8ns,
* and this update value cannot be reprogrammed.
*
* Neither the 82576 nor the 82580 offer registers wide enough to hold
* nanoseconds time values for very long. For the 82580, SYSTIM always
* counts nanoseconds, but the upper 24 bits are not availible. The
* frequency is adjusted by changing the 32 bit fractional nanoseconds
* register, TIMINCA.
*
* For the 82576, the SYSTIM register time unit is affect by the
* choice of the 24 bit TININCA:IV (incvalue) field. Five bits of this
* field are needed to provide the nominal 16 nanosecond period,
* leaving 19 bits for fractional nanoseconds.
*
* We scale the NIC clock cycle by a large factor so that relatively
* small clock corrections can be added or subtracted at each clock
* tick. The drawbacks of a large factor are a) that the clock
* register overflows more quickly (not such a big deal) and b) that
* the increment per tick has to fit into 24 bits. As a result we
* need to use a shift of 19 so we can fit a value of 16 into the
* TIMINCA register.
*
*
* SYSTIMH SYSTIML
* +--------------+ +---+---+------+
* 82576 | 32 | | 8 | 5 | 19 |
* +--------------+ +---+---+------+
* \________ 45 bits _______/ fract
*
* +----------+---+ +--------------+
* 82580 | 24 | 8 | | 32 |
* +----------+---+ +--------------+
* reserved \______ 40 bits _____/
*
*
* The 45 bit 82576 SYSTIM overflows every
* 2^45 * 10^-9 / 3600 = 9.77 hours.
*
* The 40 bit 82580 SYSTIM overflows every
* 2^40 * 10^-9 / 60 = 18.3 minutes.
*/
#define IGB_SYSTIM_OVERFLOW_PERIOD (HZ * 60 * 9)
#define IGB_PTP_TX_TIMEOUT (HZ * 15)
#define INCPERIOD_82576 (1 << E1000_TIMINCA_16NS_SHIFT)
#define INCVALUE_82576_MASK ((1 << E1000_TIMINCA_16NS_SHIFT) - 1)
#define INCVALUE_82576 (16 << IGB_82576_TSYNC_SHIFT)
#define IGB_NBITS_82580 40
/*
* SYSTIM read access for the 82576
*/
static cycle_t igb_ptp_read_82576(const struct cyclecounter *cc)
{
struct igb_adapter *igb = container_of(cc, struct igb_adapter, cc);
struct e1000_hw *hw = &igb->hw;
u64 val;
u32 lo, hi;
lo = E1000_READ_REG(hw, E1000_SYSTIML);
hi = E1000_READ_REG(hw, E1000_SYSTIMH);
val = ((u64) hi) << 32;
val |= lo;
return val;
}
/*
* SYSTIM read access for the 82580
*/
static cycle_t igb_ptp_read_82580(const struct cyclecounter *cc)
{
struct igb_adapter *igb = container_of(cc, struct igb_adapter, cc);
struct e1000_hw *hw = &igb->hw;
u64 val;
u32 lo, hi;
/* The timestamp latches on lowest register read. For the 82580
* the lowest register is SYSTIMR instead of SYSTIML. However we only
* need to provide nanosecond resolution, so we just ignore it.
*/
E1000_READ_REG(hw, E1000_SYSTIMR);
lo = E1000_READ_REG(hw, E1000_SYSTIML);
hi = E1000_READ_REG(hw, E1000_SYSTIMH);
val = ((u64) hi) << 32;
val |= lo;
return val;
}
/*
* SYSTIM read access for I210/I211
*/
static void igb_ptp_read_i210(struct igb_adapter *adapter, struct timespec *ts)
{
struct e1000_hw *hw = &adapter->hw;
u32 sec, nsec;
/* The timestamp latches on lowest register read. For I210/I211, the
* lowest register is SYSTIMR. Since we only need to provide nanosecond
* resolution, we can ignore it.
*/
E1000_READ_REG(hw, E1000_SYSTIMR);
nsec = E1000_READ_REG(hw, E1000_SYSTIML);
sec = E1000_READ_REG(hw, E1000_SYSTIMH);
ts->tv_sec = sec;
ts->tv_nsec = nsec;
}
static void igb_ptp_write_i210(struct igb_adapter *adapter,
const struct timespec *ts)
{
struct e1000_hw *hw = &adapter->hw;
/*
* Writing the SYSTIMR register is not necessary as it only provides
* sub-nanosecond resolution.
*/
E1000_WRITE_REG(hw, E1000_SYSTIML, ts->tv_nsec);
E1000_WRITE_REG(hw, E1000_SYSTIMH, ts->tv_sec);
}
/**
* igb_ptp_systim_to_hwtstamp - convert system time value to hw timestamp
* @adapter: board private structure
* @hwtstamps: timestamp structure to update
* @systim: unsigned 64bit system time value.
*
* We need to convert the system time value stored in the RX/TXSTMP registers
* into a hwtstamp which can be used by the upper level timestamping functions.
*
* The 'tmreg_lock' spinlock is used to protect the consistency of the
* system time value. This is needed because reading the 64 bit time
* value involves reading two (or three) 32 bit registers. The first
* read latches the value. Ditto for writing.
*
* In addition, here have extended the system time with an overflow
* counter in software.
**/
static void igb_ptp_systim_to_hwtstamp(struct igb_adapter *adapter,
struct skb_shared_hwtstamps *hwtstamps,
u64 systim)
{
unsigned long flags;
u64 ns;
switch (adapter->hw.mac.type) {
case e1000_82576:
case e1000_82580:
case e1000_i350:
case e1000_i354:
spin_lock_irqsave(&adapter->tmreg_lock, flags);
ns = timecounter_cyc2time(&adapter->tc, systim);
spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
memset(hwtstamps, 0, sizeof(*hwtstamps));
hwtstamps->hwtstamp = ns_to_ktime(ns);
break;
case e1000_i210:
case e1000_i211:
memset(hwtstamps, 0, sizeof(*hwtstamps));
/* Upper 32 bits contain s, lower 32 bits contain ns. */
hwtstamps->hwtstamp = ktime_set(systim >> 32,
systim & 0xFFFFFFFF);
break;
default:
break;
}
}
/*
* PTP clock operations
*/
static int igb_ptp_adjfreq_82576(struct ptp_clock_info *ptp, s32 ppb)
{
struct igb_adapter *igb = container_of(ptp, struct igb_adapter,
ptp_caps);
struct e1000_hw *hw = &igb->hw;
int neg_adj = 0;
u64 rate;
u32 incvalue;
if (ppb < 0) {
neg_adj = 1;
ppb = -ppb;
}
rate = ppb;
rate <<= 14;
rate = div_u64(rate, 1953125);
incvalue = 16 << IGB_82576_TSYNC_SHIFT;
if (neg_adj)
incvalue -= rate;
else
incvalue += rate;
E1000_WRITE_REG(hw, E1000_TIMINCA, INCPERIOD_82576 | (incvalue & INCVALUE_82576_MASK));
return 0;
}
static int igb_ptp_adjfreq_82580(struct ptp_clock_info *ptp, s32 ppb)
{
struct igb_adapter *igb = container_of(ptp, struct igb_adapter,
ptp_caps);
struct e1000_hw *hw = &igb->hw;
int neg_adj = 0;
u64 rate;
u32 inca;
if (ppb < 0) {
neg_adj = 1;
ppb = -ppb;
}
rate = ppb;
rate <<= 26;
rate = div_u64(rate, 1953125);
/* At 2.5G speeds, the TIMINCA register on I354 updates the clock 2.5x
* as quickly. Account for this by dividing the adjustment by 2.5.
*/
if (hw->mac.type == e1000_i354) {
u32 status = E1000_READ_REG(hw, E1000_STATUS);
if ((status & E1000_STATUS_2P5_SKU) &&
!(status & E1000_STATUS_2P5_SKU_OVER)) {
rate <<= 1;
rate = div_u64(rate, 5);
}
}
inca = rate & INCVALUE_MASK;
if (neg_adj)
inca |= ISGN;
E1000_WRITE_REG(hw, E1000_TIMINCA, inca);
return 0;
}
static int igb_ptp_adjtime_82576(struct ptp_clock_info *ptp, s64 delta)
{
struct igb_adapter *igb = container_of(ptp, struct igb_adapter,
ptp_caps);
unsigned long flags;
s64 now;
spin_lock_irqsave(&igb->tmreg_lock, flags);
now = timecounter_read(&igb->tc);
now += delta;
timecounter_init(&igb->tc, &igb->cc, now);
spin_unlock_irqrestore(&igb->tmreg_lock, flags);
return 0;
}
static int igb_ptp_adjtime_i210(struct ptp_clock_info *ptp, s64 delta)
{
struct igb_adapter *igb = container_of(ptp, struct igb_adapter,
ptp_caps);
unsigned long flags;
struct timespec now, then = ns_to_timespec(delta);
spin_lock_irqsave(&igb->tmreg_lock, flags);
igb_ptp_read_i210(igb, &now);
now = timespec_add(now, then);
igb_ptp_write_i210(igb, (const struct timespec *)&now);
spin_unlock_irqrestore(&igb->tmreg_lock, flags);
return 0;
}
static int igb_ptp_gettime_82576(struct ptp_clock_info *ptp,
struct timespec *ts)
{
struct igb_adapter *igb = container_of(ptp, struct igb_adapter,
ptp_caps);
unsigned long flags;
u64 ns;
u32 remainder;
spin_lock_irqsave(&igb->tmreg_lock, flags);
ns = timecounter_read(&igb->tc);
spin_unlock_irqrestore(&igb->tmreg_lock, flags);
ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
ts->tv_nsec = remainder;
return 0;
}
static int igb_ptp_gettime_i210(struct ptp_clock_info *ptp,
struct timespec *ts)
{
struct igb_adapter *igb = container_of(ptp, struct igb_adapter,
ptp_caps);
unsigned long flags;
spin_lock_irqsave(&igb->tmreg_lock, flags);
igb_ptp_read_i210(igb, ts);
spin_unlock_irqrestore(&igb->tmreg_lock, flags);
return 0;
}
static int igb_ptp_settime_82576(struct ptp_clock_info *ptp,
const struct timespec *ts)
{
struct igb_adapter *igb = container_of(ptp, struct igb_adapter,
ptp_caps);
unsigned long flags;
u64 ns;
ns = ts->tv_sec * 1000000000ULL;
ns += ts->tv_nsec;
spin_lock_irqsave(&igb->tmreg_lock, flags);
timecounter_init(&igb->tc, &igb->cc, ns);
spin_unlock_irqrestore(&igb->tmreg_lock, flags);
return 0;
}
static int igb_ptp_settime_i210(struct ptp_clock_info *ptp,
const struct timespec *ts)
{
struct igb_adapter *igb = container_of(ptp, struct igb_adapter,
ptp_caps);
unsigned long flags;
spin_lock_irqsave(&igb->tmreg_lock, flags);
igb_ptp_write_i210(igb, ts);
spin_unlock_irqrestore(&igb->tmreg_lock, flags);
return 0;
}
static int igb_ptp_enable(struct ptp_clock_info *ptp,
struct ptp_clock_request *rq, int on)
{
return -EOPNOTSUPP;
}
/**
* igb_ptp_tx_work
* @work: pointer to work struct
*
* This work function polls the TSYNCTXCTL valid bit to determine when a
* timestamp has been taken for the current stored skb.
*/
void igb_ptp_tx_work(struct work_struct *work)
{
struct igb_adapter *adapter = container_of(work, struct igb_adapter,
ptp_tx_work);
struct e1000_hw *hw = &adapter->hw;
u32 tsynctxctl;
if (!adapter->ptp_tx_skb)
return;
if (time_is_before_jiffies(adapter->ptp_tx_start +
IGB_PTP_TX_TIMEOUT)) {
dev_kfree_skb_any(adapter->ptp_tx_skb);
adapter->ptp_tx_skb = NULL;
adapter->tx_hwtstamp_timeouts++;
dev_warn(&adapter->pdev->dev, "clearing Tx timestamp hang");
return;
}
tsynctxctl = E1000_READ_REG(hw, E1000_TSYNCTXCTL);
if (tsynctxctl & E1000_TSYNCTXCTL_VALID)
igb_ptp_tx_hwtstamp(adapter);
else
/* reschedule to check later */
schedule_work(&adapter->ptp_tx_work);
}
static void igb_ptp_overflow_check(struct work_struct *work)
{
struct igb_adapter *igb =
container_of(work, struct igb_adapter, ptp_overflow_work.work);
struct timespec ts;
igb->ptp_caps.gettime(&igb->ptp_caps, &ts);
pr_debug("igb overflow check at %ld.%09lu\n", ts.tv_sec, ts.tv_nsec);
schedule_delayed_work(&igb->ptp_overflow_work,
IGB_SYSTIM_OVERFLOW_PERIOD);
}
/**
* igb_ptp_rx_hang - detect error case when Rx timestamp registers latched
* @adapter: private network adapter structure
*
* This watchdog task is scheduled to detect error case where hardware has
* dropped an Rx packet that was timestamped when the ring is full. The
* particular error is rare but leaves the device in a state unable to timestamp
* any future packets.
*/
void igb_ptp_rx_hang(struct igb_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
struct igb_ring *rx_ring;
u32 tsyncrxctl = E1000_READ_REG(hw, E1000_TSYNCRXCTL);
unsigned long rx_event;
int n;
if (hw->mac.type != e1000_82576)
return;
/* If we don't have a valid timestamp in the registers, just update the
* timeout counter and exit
*/
if (!(tsyncrxctl & E1000_TSYNCRXCTL_VALID)) {
adapter->last_rx_ptp_check = jiffies;
return;
}
/* Determine the most recent watchdog or rx_timestamp event */
rx_event = adapter->last_rx_ptp_check;
for (n = 0; n < adapter->num_rx_queues; n++) {
rx_ring = adapter->rx_ring[n];
if (time_after(rx_ring->last_rx_timestamp, rx_event))
rx_event = rx_ring->last_rx_timestamp;
}
/* Only need to read the high RXSTMP register to clear the lock */
if (time_is_before_jiffies(rx_event + 5 * HZ)) {
E1000_READ_REG(hw, E1000_RXSTMPH);
adapter->last_rx_ptp_check = jiffies;
adapter->rx_hwtstamp_cleared++;
dev_warn(&adapter->pdev->dev, "clearing Rx timestamp hang");
}
}
/**
* igb_ptp_tx_hwtstamp - utility function which checks for TX time stamp
* @adapter: Board private structure.
*
* If we were asked to do hardware stamping and such a time stamp is
* available, then it must have been for this skb here because we only
* allow only one such packet into the queue.
*/
void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
struct skb_shared_hwtstamps shhwtstamps;
u64 regval;
regval = E1000_READ_REG(hw, E1000_TXSTMPL);
regval |= (u64)E1000_READ_REG(hw, E1000_TXSTMPH) << 32;
igb_ptp_systim_to_hwtstamp(adapter, &shhwtstamps, regval);
skb_tstamp_tx(adapter->ptp_tx_skb, &shhwtstamps);
dev_kfree_skb_any(adapter->ptp_tx_skb);
adapter->ptp_tx_skb = NULL;
}
/**
* igb_ptp_rx_pktstamp - retrieve Rx per packet timestamp
* @q_vector: Pointer to interrupt specific structure
* @va: Pointer to address containing Rx buffer
* @skb: Buffer containing timestamp and packet
*
* This function is meant to retrieve a timestamp from the first buffer of an
* incoming frame. The value is stored in little endian format starting on
* byte 8.
*/
void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector,
unsigned char *va,
struct sk_buff *skb)
{
__le64 *regval = (__le64 *)va;
/*
* The timestamp is recorded in little endian format.
* DWORD: 0 1 2 3
* Field: Reserved Reserved SYSTIML SYSTIMH
*/
igb_ptp_systim_to_hwtstamp(q_vector->adapter, skb_hwtstamps(skb),
le64_to_cpu(regval[1]));
}
/**
* igb_ptp_rx_rgtstamp - retrieve Rx timestamp stored in register
* @q_vector: Pointer to interrupt specific structure
* @skb: Buffer containing timestamp and packet
*
* This function is meant to retrieve a timestamp from the internal registers
* of the adapter and store it in the skb.
*/
void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,
struct sk_buff *skb)
{
struct igb_adapter *adapter = q_vector->adapter;
struct e1000_hw *hw = &adapter->hw;
u64 regval;
/*
* If this bit is set, then the RX registers contain the time stamp. No
* other packet will be time stamped until we read these registers, so
* read the registers to make them available again. Because only one
* packet can be time stamped at a time, we know that the register
* values must belong to this one here and therefore we don't need to
* compare any of the additional attributes stored for it.
*
* If nothing went wrong, then it should have a shared tx_flags that we
* can turn into a skb_shared_hwtstamps.
*/
if (!(E1000_READ_REG(hw, E1000_TSYNCRXCTL) & E1000_TSYNCRXCTL_VALID))
return;
regval = E1000_READ_REG(hw, E1000_RXSTMPL);
regval |= (u64)E1000_READ_REG(hw, E1000_RXSTMPH) << 32;
igb_ptp_systim_to_hwtstamp(adapter, skb_hwtstamps(skb), regval);
}
/**
* igb_ptp_hwtstamp_ioctl - control hardware time stamping
* @netdev:
* @ifreq:
* @cmd:
*
* Outgoing time stamping can be enabled and disabled. Play nice and
* disable it when requested, although it shouldn't case any overhead
* when no packet needs it. At most one packet in the queue may be
* marked for time stamping, otherwise it would be impossible to tell
* for sure to which packet the hardware time stamp belongs.
*
* Incoming time stamping has to be configured via the hardware
* filters. Not all combinations are supported, in particular event
* type has to be specified. Matching the kind of event packet is
* not supported, with the exception of "all V2 events regardless of
* level 2 or 4".
*
**/
int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
struct ifreq *ifr, int cmd)
{
struct igb_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
struct hwtstamp_config config;
u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED;
u32 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED;
u32 tsync_rx_cfg = 0;
bool is_l4 = false;
bool is_l2 = false;
u32 regval;
if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
return -EFAULT;
/* reserved for future extensions */
if (config.flags)
return -EINVAL;
switch (config.tx_type) {
case HWTSTAMP_TX_OFF:
tsync_tx_ctl = 0;
case HWTSTAMP_TX_ON:
break;
default:
return -ERANGE;
}
switch (config.rx_filter) {
case HWTSTAMP_FILTER_NONE:
tsync_rx_ctl = 0;
break;
case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L4_V1;
tsync_rx_cfg = E1000_TSYNCRXCFG_PTP_V1_SYNC_MESSAGE;
is_l4 = true;
break;
case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L4_V1;
tsync_rx_cfg = E1000_TSYNCRXCFG_PTP_V1_DELAY_REQ_MESSAGE;
is_l4 = true;
break;
case HWTSTAMP_FILTER_PTP_V2_EVENT:
case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
case HWTSTAMP_FILTER_PTP_V2_SYNC:
case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_EVENT_V2;
config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
is_l2 = true;
is_l4 = true;
break;
case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
case HWTSTAMP_FILTER_ALL:
/*
* 82576 cannot timestamp all packets, which it needs to do to
* support both V1 Sync and Delay_Req messages
*/
if (hw->mac.type != e1000_82576) {
tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL;
config.rx_filter = HWTSTAMP_FILTER_ALL;
break;
}
/* fall through */
default:
config.rx_filter = HWTSTAMP_FILTER_NONE;
return -ERANGE;
}
if (hw->mac.type == e1000_82575) {
if (tsync_rx_ctl | tsync_tx_ctl)
return -EINVAL;
return 0;
}
/*
* Per-packet timestamping only works if all packets are
* timestamped, so enable timestamping in all packets as
* long as one rx filter was configured.
*/
if ((hw->mac.type >= e1000_82580) && tsync_rx_ctl) {
tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED;
tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL;
config.rx_filter = HWTSTAMP_FILTER_ALL;
is_l2 = true;
is_l4 = true;
if ((hw->mac.type == e1000_i210) ||
(hw->mac.type == e1000_i211)) {
regval = E1000_READ_REG(hw, E1000_RXPBS);
regval |= E1000_RXPBS_CFG_TS_EN;
E1000_WRITE_REG(hw, E1000_RXPBS, regval);
}
}
/* enable/disable TX */
regval = E1000_READ_REG(hw, E1000_TSYNCTXCTL);
regval &= ~E1000_TSYNCTXCTL_ENABLED;
regval |= tsync_tx_ctl;
E1000_WRITE_REG(hw, E1000_TSYNCTXCTL, regval);
/* enable/disable RX */
regval = E1000_READ_REG(hw, E1000_TSYNCRXCTL);
regval &= ~(E1000_TSYNCRXCTL_ENABLED | E1000_TSYNCRXCTL_TYPE_MASK);
regval |= tsync_rx_ctl;
E1000_WRITE_REG(hw, E1000_TSYNCRXCTL, regval);
/* define which PTP packets are time stamped */
E1000_WRITE_REG(hw, E1000_TSYNCRXCFG, tsync_rx_cfg);
/* define ethertype filter for timestamped packets */
if (is_l2)
E1000_WRITE_REG(hw, E1000_ETQF(3),
(E1000_ETQF_FILTER_ENABLE | /* enable filter */
E1000_ETQF_1588 | /* enable timestamping */
ETH_P_1588)); /* 1588 eth protocol type */
else
E1000_WRITE_REG(hw, E1000_ETQF(3), 0);
/* L4 Queue Filter[3]: filter by destination port and protocol */
if (is_l4) {
u32 ftqf = (IPPROTO_UDP /* UDP */
| E1000_FTQF_VF_BP /* VF not compared */
| E1000_FTQF_1588_TIME_STAMP /* Enable Timestamping */
| E1000_FTQF_MASK); /* mask all inputs */
ftqf &= ~E1000_FTQF_MASK_PROTO_BP; /* enable protocol check */
E1000_WRITE_REG(hw, E1000_IMIR(3), htons(PTP_EV_PORT));
E1000_WRITE_REG(hw, E1000_IMIREXT(3),
(E1000_IMIREXT_SIZE_BP | E1000_IMIREXT_CTRL_BP));
if (hw->mac.type == e1000_82576) {
/* enable source port check */
E1000_WRITE_REG(hw, E1000_SPQF(3), htons(PTP_EV_PORT));
ftqf &= ~E1000_FTQF_MASK_SOURCE_PORT_BP;
}
E1000_WRITE_REG(hw, E1000_FTQF(3), ftqf);
} else {
E1000_WRITE_REG(hw, E1000_FTQF(3), E1000_FTQF_MASK);
}
E1000_WRITE_FLUSH(hw);
/* clear TX/RX time stamp registers, just to be sure */
regval = E1000_READ_REG(hw, E1000_TXSTMPL);
regval = E1000_READ_REG(hw, E1000_TXSTMPH);
regval = E1000_READ_REG(hw, E1000_RXSTMPL);
regval = E1000_READ_REG(hw, E1000_RXSTMPH);
return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
-EFAULT : 0;
}
void igb_ptp_init(struct igb_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
struct net_device *netdev = adapter->netdev;
switch (hw->mac.type) {
case e1000_82576:
snprintf(adapter->ptp_caps.name, 16, "%pm", netdev->dev_addr);
adapter->ptp_caps.owner = THIS_MODULE;
adapter->ptp_caps.max_adj = 999999881;
adapter->ptp_caps.n_ext_ts = 0;
adapter->ptp_caps.pps = 0;
adapter->ptp_caps.adjfreq = igb_ptp_adjfreq_82576;
adapter->ptp_caps.adjtime = igb_ptp_adjtime_82576;
adapter->ptp_caps.gettime = igb_ptp_gettime_82576;
adapter->ptp_caps.settime = igb_ptp_settime_82576;
adapter->ptp_caps.enable = igb_ptp_enable;
adapter->cc.read = igb_ptp_read_82576;
adapter->cc.mask = CLOCKSOURCE_MASK(64);
adapter->cc.mult = 1;
adapter->cc.shift = IGB_82576_TSYNC_SHIFT;
/* Dial the nominal frequency. */
E1000_WRITE_REG(hw, E1000_TIMINCA, INCPERIOD_82576 |
INCVALUE_82576);
break;
case e1000_82580:
case e1000_i350:
case e1000_i354:
snprintf(adapter->ptp_caps.name, 16, "%pm", netdev->dev_addr);
adapter->ptp_caps.owner = THIS_MODULE;
adapter->ptp_caps.max_adj = 62499999;
adapter->ptp_caps.n_ext_ts = 0;
adapter->ptp_caps.pps = 0;
adapter->ptp_caps.adjfreq = igb_ptp_adjfreq_82580;
adapter->ptp_caps.adjtime = igb_ptp_adjtime_82576;
adapter->ptp_caps.gettime = igb_ptp_gettime_82576;
adapter->ptp_caps.settime = igb_ptp_settime_82576;
adapter->ptp_caps.enable = igb_ptp_enable;
adapter->cc.read = igb_ptp_read_82580;
adapter->cc.mask = CLOCKSOURCE_MASK(IGB_NBITS_82580);
adapter->cc.mult = 1;
adapter->cc.shift = 0;
/* Enable the timer functions by clearing bit 31. */
E1000_WRITE_REG(hw, E1000_TSAUXC, 0x0);
break;
case e1000_i210:
case e1000_i211:
snprintf(adapter->ptp_caps.name, 16, "%pm", netdev->dev_addr);
adapter->ptp_caps.owner = THIS_MODULE;
adapter->ptp_caps.max_adj = 62499999;
adapter->ptp_caps.n_ext_ts = 0;
adapter->ptp_caps.pps = 0;
adapter->ptp_caps.adjfreq = igb_ptp_adjfreq_82580;
adapter->ptp_caps.adjtime = igb_ptp_adjtime_i210;
adapter->ptp_caps.gettime = igb_ptp_gettime_i210;
adapter->ptp_caps.settime = igb_ptp_settime_i210;
adapter->ptp_caps.enable = igb_ptp_enable;
/* Enable the timer functions by clearing bit 31. */
E1000_WRITE_REG(hw, E1000_TSAUXC, 0x0);
break;
default:
adapter->ptp_clock = NULL;
return;
}
E1000_WRITE_FLUSH(hw);
spin_lock_init(&adapter->tmreg_lock);
INIT_WORK(&adapter->ptp_tx_work, igb_ptp_tx_work);
/* Initialize the clock and overflow work for devices that need it. */
if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211)) {
struct timespec ts = ktime_to_timespec(ktime_get_real());
igb_ptp_settime_i210(&adapter->ptp_caps, &ts);
} else {
timecounter_init(&adapter->tc, &adapter->cc,
ktime_to_ns(ktime_get_real()));
INIT_DELAYED_WORK(&adapter->ptp_overflow_work,
igb_ptp_overflow_check);
schedule_delayed_work(&adapter->ptp_overflow_work,
IGB_SYSTIM_OVERFLOW_PERIOD);
}
/* Initialize the time sync interrupts for devices that support it. */
if (hw->mac.type >= e1000_82580) {
E1000_WRITE_REG(hw, E1000_TSIM, E1000_TSIM_TXTS);
E1000_WRITE_REG(hw, E1000_IMS, E1000_IMS_TS);
}
adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps,
&adapter->pdev->dev);
if (IS_ERR(adapter->ptp_clock)) {
adapter->ptp_clock = NULL;
dev_err(&adapter->pdev->dev, "ptp_clock_register failed\n");
} else {
dev_info(&adapter->pdev->dev, "added PHC on %s\n",
adapter->netdev->name);
adapter->flags |= IGB_FLAG_PTP;
}
}
/**
* igb_ptp_stop - Disable PTP device and stop the overflow check.
* @adapter: Board private structure.
*
* This function stops the PTP support and cancels the delayed work.
**/
void igb_ptp_stop(struct igb_adapter *adapter)
{
switch (adapter->hw.mac.type) {
case e1000_82576:
case e1000_82580:
case e1000_i350:
case e1000_i354:
cancel_delayed_work_sync(&adapter->ptp_overflow_work);
break;
case e1000_i210:
case e1000_i211:
/* No delayed work to cancel. */
break;
default:
return;
}
cancel_work_sync(&adapter->ptp_tx_work);
if (adapter->ptp_tx_skb) {
dev_kfree_skb_any(adapter->ptp_tx_skb);
adapter->ptp_tx_skb = NULL;
}
if (adapter->ptp_clock) {
ptp_clock_unregister(adapter->ptp_clock);
dev_info(&adapter->pdev->dev, "removed PHC on %s\n",
adapter->netdev->name);
adapter->flags &= ~IGB_FLAG_PTP;
}
}
/**
* igb_ptp_reset - Re-enable the adapter for PTP following a reset.
* @adapter: Board private structure.
*
* This function handles the reset work required to re-enable the PTP device.
**/
void igb_ptp_reset(struct igb_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
if (!(adapter->flags & IGB_FLAG_PTP))
return;
switch (adapter->hw.mac.type) {
case e1000_82576:
/* Dial the nominal frequency. */
E1000_WRITE_REG(hw, E1000_TIMINCA, INCPERIOD_82576 |
INCVALUE_82576);
break;
case e1000_82580:
case e1000_i350:
case e1000_i354:
case e1000_i210:
case e1000_i211:
/* Enable the timer functions and interrupts. */
E1000_WRITE_REG(hw, E1000_TSAUXC, 0x0);
E1000_WRITE_REG(hw, E1000_TSIM, E1000_TSIM_TXTS);
E1000_WRITE_REG(hw, E1000_IMS, E1000_IMS_TS);
break;
default:
/* No work to do. */
return;
}
/* Re-initialize the timer. */
if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211)) {
struct timespec ts = ktime_to_timespec(ktime_get_real());
igb_ptp_settime_i210(&adapter->ptp_caps, &ts);
} else {
timecounter_init(&adapter->tc, &adapter->cc,
ktime_to_ns(ktime_get_real()));
}
}

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -52,6 +52,36 @@ struct igb_reg_test {
#define TABLE64_TEST_LO 5 #define TABLE64_TEST_LO 5
#define TABLE64_TEST_HI 6 #define TABLE64_TEST_HI 6
/* i210 reg test */
static struct igb_reg_test reg_test_i210[] = {
{ E1000_FCAL, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
{ E1000_FCAH, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
{ E1000_FCT, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
{ E1000_RDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
{ E1000_RDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
{ E1000_RDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
/* RDH is read-only for i210, only test RDT. */
{ E1000_RDT(0), 0x100, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
{ E1000_FCRTH, 0x100, 1, PATTERN_TEST, 0x0003FFF0, 0x0003FFF0 },
{ E1000_FCTTV, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
{ E1000_TIPG, 0x100, 1, PATTERN_TEST, 0x3FFFFFFF, 0x3FFFFFFF },
{ E1000_TDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
{ E1000_TDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
{ E1000_TDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
{ E1000_TDT(0), 0x100, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
{ E1000_RCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
{ E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB0FE, 0x003FFFFB },
{ E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB0FE, 0xFFFFFFFF },
{ E1000_TCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
{ E1000_RA, 0, 16, TABLE64_TEST_LO,
0xFFFFFFFF, 0xFFFFFFFF },
{ E1000_RA, 0, 16, TABLE64_TEST_HI,
0x900FFFFF, 0xFFFFFFFF },
{ E1000_MTA, 0, 128, TABLE32_TEST,
0xFFFFFFFF, 0xFFFFFFFF },
{ 0, 0, 0, 0 }
};
/* i350 reg test */ /* i350 reg test */
static struct igb_reg_test reg_test_i350[] = { static struct igb_reg_test reg_test_i350[] = {
{ E1000_FCAL, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF }, { E1000_FCAL, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -601,6 +601,42 @@ size_t _kc_strlcpy(char *dest, const char *src, size_t size)
return ret; return ret;
} }
#ifndef do_div
#if BITS_PER_LONG == 32
uint32_t __attribute__((weak)) _kc__div64_32(uint64_t *n, uint32_t base)
{
uint64_t rem = *n;
uint64_t b = base;
uint64_t res, d = 1;
uint32_t high = rem >> 32;
/* Reduce the thing a bit first */
res = 0;
if (high >= base) {
high /= base;
res = (uint64_t) high << 32;
rem -= (uint64_t) (high*base) << 32;
}
while ((int64_t)b > 0 && b < rem) {
b = b+b;
d = d+d;
}
do {
if (rem >= b) {
rem -= b;
res += d;
}
b >>= 1;
d >>= 1;
} while (d);
*n = res;
return rem;
}
#endif /* BITS_PER_LONG == 32 */
#endif /* do_div */
#endif /* 2.6.0 => 2.4.6 */ #endif /* 2.6.0 => 2.4.6 */
/*****************************************************************************/ /*****************************************************************************/
@ -777,6 +813,14 @@ void *_kc_kmemdup(const void *src, size_t len, unsigned gfp)
} }
#endif /* <= 2.6.19 */ #endif /* <= 2.6.19 */
/*****************************************************************************/
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21) )
struct pci_dev *_kc_netdev_to_pdev(struct net_device *netdev)
{
return ((struct adapter_struct *)netdev_priv(netdev))->pdev;
}
#endif /* < 2.6.21 */
/*****************************************************************************/ /*****************************************************************************/
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) ) #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) )
/* hexdump code taken from lib/hexdump.c */ /* hexdump code taken from lib/hexdump.c */
@ -891,12 +935,57 @@ void _kc_print_hex_dump(const char *level,
} }
} }
} }
#ifdef HAVE_I2C_SUPPORT
struct i2c_client *
_kc_i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
{
struct i2c_client *client;
int status;
client = kzalloc(sizeof *client, GFP_KERNEL);
if (!client)
return NULL;
client->adapter = adap;
client->dev.platform_data = info->platform_data;
client->flags = info->flags;
client->addr = info->addr;
strlcpy(client->name, info->type, sizeof(client->name));
/* Check for address business */
status = i2c_check_addr(adap, client->addr);
if (status)
goto out_err;
client->dev.parent = &client->adapter->dev;
client->dev.bus = &i2c_bus_type;
status = i2c_attach_client(client);
if (status)
goto out_err;
dev_dbg(&adap->dev, "client [%s] registered with bus id %s\n",
client->name, dev_name(&client->dev));
return client;
out_err:
dev_err(&adap->dev, "Failed to register i2c client %s at 0x%02x "
"(%d)\n", client->name, client->addr, status);
kfree(client);
return NULL;
}
#endif /* HAVE_I2C_SUPPORT */
#endif /* < 2.6.22 */ #endif /* < 2.6.22 */
/*****************************************************************************/ /*****************************************************************************/
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) ) #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) )
#ifdef NAPI #ifdef NAPI
struct net_device *napi_to_poll_dev(struct napi_struct *napi) struct net_device *napi_to_poll_dev(const struct napi_struct *napi)
{ {
struct adapter_q_vector *q_vector = container_of(napi, struct adapter_q_vector *q_vector = container_of(napi,
struct adapter_q_vector, struct adapter_q_vector,
@ -1024,19 +1113,61 @@ _kc_pci_wake_from_d3(struct pci_dev *dev, bool enable)
out: out:
return err; return err;
} }
void _kc_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
int off, int size)
{
skb_fill_page_desc(skb, i, page, off, size);
skb->len += size;
skb->data_len += size;
skb->truesize += size;
}
#endif /* < 2.6.28 */ #endif /* < 2.6.28 */
/*****************************************************************************/
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) )
static void __kc_pci_set_master(struct pci_dev *pdev, bool enable)
{
u16 old_cmd, cmd;
pci_read_config_word(pdev, PCI_COMMAND, &old_cmd);
if (enable)
cmd = old_cmd | PCI_COMMAND_MASTER;
else
cmd = old_cmd & ~PCI_COMMAND_MASTER;
if (cmd != old_cmd) {
dev_dbg(pci_dev_to_dev(pdev), "%s bus mastering\n",
enable ? "enabling" : "disabling");
pci_write_config_word(pdev, PCI_COMMAND, cmd);
}
#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7) )
pdev->is_busmaster = enable;
#endif
}
void _kc_pci_clear_master(struct pci_dev *dev)
{
__kc_pci_set_master(dev, false);
}
#endif /* < 2.6.29 */
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34) )
#if (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6,0))
int _kc_pci_num_vf(struct pci_dev *dev)
{
int num_vf = 0;
#ifdef CONFIG_PCI_IOV
struct pci_dev *vfdev;
/* loop through all ethernet devices starting at PF dev */
vfdev = pci_get_class(PCI_CLASS_NETWORK_ETHERNET << 8, NULL);
while (vfdev) {
if (vfdev->is_virtfn && vfdev->physfn == dev)
num_vf++;
vfdev = pci_get_class(PCI_CLASS_NETWORK_ETHERNET << 8, vfdev);
}
#endif
return num_vf;
}
#endif /* RHEL_RELEASE_CODE */
#endif /* < 2.6.34 */
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) ) #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) )
#ifdef HAVE_TX_MQ #ifdef HAVE_TX_MQ
#if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0)))
#ifndef CONFIG_NETDEVICES_MULTIQUEUE #ifndef CONFIG_NETDEVICES_MULTIQUEUE
void _kc_netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) void _kc_netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
{ {
@ -1061,7 +1192,29 @@ void _kc_netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
} }
} }
#endif /* CONFIG_NETDEVICES_MULTIQUEUE */ #endif /* CONFIG_NETDEVICES_MULTIQUEUE */
#endif /* !(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0)) */
#endif /* HAVE_TX_MQ */ #endif /* HAVE_TX_MQ */
ssize_t _kc_simple_write_to_buffer(void *to, size_t available, loff_t *ppos,
const void __user *from, size_t count)
{
loff_t pos = *ppos;
size_t res;
if (pos < 0)
return -EINVAL;
if (pos >= available || !count)
return 0;
if (count > available - pos)
count = available - pos;
res = copy_from_user(to + pos, from, count);
if (res == count)
return -EFAULT;
count -= res;
*ppos = pos + count;
return count;
}
#endif /* < 2.6.35 */ #endif /* < 2.6.35 */
/*****************************************************************************/ /*****************************************************************************/
@ -1085,48 +1238,243 @@ int _kc_ethtool_op_set_flags(struct net_device *dev, u32 data, u32 supported)
} }
#endif /* < 2.6.36 */ #endif /* < 2.6.36 */
/*****************************************************************************/
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38) )
#ifdef HAVE_NETDEV_SELECT_QUEUE
#include <net/ip.h>
static u32 _kc_simple_tx_hashrnd;
static u32 _kc_simple_tx_hashrnd_initialized;
u16 ___kc_skb_tx_hash(struct net_device *dev, const struct sk_buff *skb,
u16 num_tx_queues)
{
u32 hash;
if (skb_rx_queue_recorded(skb)) {
hash = skb_get_rx_queue(skb);
while (unlikely(hash >= num_tx_queues))
hash -= num_tx_queues;
return hash;
}
if (unlikely(!_kc_simple_tx_hashrnd_initialized)) {
get_random_bytes(&_kc_simple_tx_hashrnd, 4);
_kc_simple_tx_hashrnd_initialized = 1;
}
if (skb->sk && skb->sk->sk_hash)
hash = skb->sk->sk_hash;
else
#ifdef NETIF_F_RXHASH
hash = (__force u16) skb->protocol ^ skb->rxhash;
#else
hash = skb->protocol;
#endif
hash = jhash_1word(hash, _kc_simple_tx_hashrnd);
return (u16) (((u64) hash * num_tx_queues) >> 32);
}
#endif /* HAVE_NETDEV_SELECT_QUEUE */
#endif /* < 2.6.38 */
/******************************************************************************/ /******************************************************************************/
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39) ) #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39) )
#if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(6,0))) #if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(6,0)))
#endif /* !(RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(6,0)) */ #endif /* !(RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(6,0)) */
#endif /* < 2.6.39 */ #endif /* < 2.6.39 */
/******************************************************************************/
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0) )
void _kc_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
int off, int size, unsigned int truesize)
{
skb_fill_page_desc(skb, i, page, off, size);
skb->len += size;
skb->data_len += size;
skb->truesize += truesize;
}
int _kc_simple_open(struct inode *inode, struct file *file)
{
if (inode->i_private)
file->private_data = inode->i_private;
return 0;
}
#endif /* < 3.4.0 */
/******************************************************************************/
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) )
#if !(SLE_VERSION_CODE && SLE_VERSION_CODE >= SLE_VERSION(11,3,0))
static inline int __kc_pcie_cap_version(struct pci_dev *dev)
{
int pos;
u16 reg16;
pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
if (!pos)
return 0;
pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &reg16);
return reg16 & PCI_EXP_FLAGS_VERS;
}
static inline bool __kc_pcie_cap_has_devctl(const struct pci_dev __always_unused *dev)
{
return true;
}
static inline bool __kc_pcie_cap_has_lnkctl(struct pci_dev *dev)
{
int type = pci_pcie_type(dev);
return __kc_pcie_cap_version(dev) > 1 ||
type == PCI_EXP_TYPE_ROOT_PORT ||
type == PCI_EXP_TYPE_ENDPOINT ||
type == PCI_EXP_TYPE_LEG_END;
}
static inline bool __kc_pcie_cap_has_sltctl(struct pci_dev *dev)
{
int type = pci_pcie_type(dev);
int pos;
u16 pcie_flags_reg;
pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
if (!pos)
return 0;
pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &pcie_flags_reg);
return __kc_pcie_cap_version(dev) > 1 ||
type == PCI_EXP_TYPE_ROOT_PORT ||
(type == PCI_EXP_TYPE_DOWNSTREAM &&
pcie_flags_reg & PCI_EXP_FLAGS_SLOT);
}
static inline bool __kc_pcie_cap_has_rtctl(struct pci_dev *dev)
{
int type = pci_pcie_type(dev);
return __kc_pcie_cap_version(dev) > 1 ||
type == PCI_EXP_TYPE_ROOT_PORT ||
type == PCI_EXP_TYPE_RC_EC;
}
static bool __kc_pcie_capability_reg_implemented(struct pci_dev *dev, int pos)
{
if (!pci_is_pcie(dev))
return false;
switch (pos) {
case PCI_EXP_FLAGS_TYPE:
return true;
case PCI_EXP_DEVCAP:
case PCI_EXP_DEVCTL:
case PCI_EXP_DEVSTA:
return __kc_pcie_cap_has_devctl(dev);
case PCI_EXP_LNKCAP:
case PCI_EXP_LNKCTL:
case PCI_EXP_LNKSTA:
return __kc_pcie_cap_has_lnkctl(dev);
case PCI_EXP_SLTCAP:
case PCI_EXP_SLTCTL:
case PCI_EXP_SLTSTA:
return __kc_pcie_cap_has_sltctl(dev);
case PCI_EXP_RTCTL:
case PCI_EXP_RTCAP:
case PCI_EXP_RTSTA:
return __kc_pcie_cap_has_rtctl(dev);
case PCI_EXP_DEVCAP2:
case PCI_EXP_DEVCTL2:
case PCI_EXP_LNKCAP2:
case PCI_EXP_LNKCTL2:
case PCI_EXP_LNKSTA2:
return __kc_pcie_cap_version(dev) > 1;
default:
return false;
}
}
/*
* Note that these accessor functions are only for the "PCI Express
* Capability" (see PCIe spec r3.0, sec 7.8). They do not apply to the
* other "PCI Express Extended Capabilities" (AER, VC, ACS, MFVC, etc.)
*/
int __kc_pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val)
{
int ret;
*val = 0;
if (pos & 1)
return -EINVAL;
if (__kc_pcie_capability_reg_implemented(dev, pos)) {
ret = pci_read_config_word(dev, pci_pcie_cap(dev) + pos, val);
/*
* Reset *val to 0 if pci_read_config_word() fails, it may
* have been written as 0xFFFF if hardware error happens
* during pci_read_config_word().
*/
if (ret)
*val = 0;
return ret;
}
/*
* For Functions that do not implement the Slot Capabilities,
* Slot Status, and Slot Control registers, these spaces must
* be hardwired to 0b, with the exception of the Presence Detect
* State bit in the Slot Status register of Downstream Ports,
* which must be hardwired to 1b. (PCIe Base Spec 3.0, sec 7.8)
*/
if (pci_is_pcie(dev) && pos == PCI_EXP_SLTSTA &&
pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) {
*val = PCI_EXP_SLTSTA_PDS;
}
return 0;
}
int __kc_pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val)
{
if (pos & 1)
return -EINVAL;
if (!__kc_pcie_capability_reg_implemented(dev, pos))
return 0;
return pci_write_config_word(dev, pci_pcie_cap(dev) + pos, val);
}
int __kc_pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos,
u16 clear, u16 set)
{
int ret;
u16 val;
ret = __kc_pcie_capability_read_word(dev, pos, &val);
if (!ret) {
val &= ~clear;
val |= set;
ret = __kc_pcie_capability_write_word(dev, pos, val);
}
return ret;
}
#endif /* !(SLE_VERSION_CODE && SLE_VERSION_CODE >= SLE_VERSION(11,3,0)) */
#endif /* < 3.7.0 */
/******************************************************************************/
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0) )
#endif /* 3.9.0 */
/*****************************************************************************/
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) )
#ifdef CONFIG_PCI_IOV
int __kc_pci_vfs_assigned(struct pci_dev *dev)
{
unsigned int vfs_assigned = 0;
#ifdef HAVE_PCI_DEV_FLAGS_ASSIGNED
int pos;
struct pci_dev *vfdev;
unsigned short dev_id;
/* only search if we are a PF */
if (!dev->is_physfn)
return 0;
/* find SR-IOV capability */
pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_SRIOV);
if (!pos)
return 0;
/*
* determine the device ID for the VFs, the vendor ID will be the
* same as the PF so there is no need to check for that one
*/
pci_read_config_word(dev, pos + PCI_SRIOV_VF_DID, &dev_id);
/* loop through all the VFs to see if we own any that are assigned */
vfdev = pci_get_device(dev->vendor, dev_id, NULL);
while (vfdev) {
/*
* It is considered assigned if it is a virtual function with
* our dev as the physical function and the assigned bit is set
*/
if (vfdev->is_virtfn && (vfdev->physfn == dev) &&
(vfdev->dev_flags & PCI_DEV_FLAGS_ASSIGNED))
vfs_assigned++;
vfdev = pci_get_device(dev->vendor, dev_id, vfdev);
}
#endif /* HAVE_PCI_DEV_FLAGS_ASSIGNED */
return vfs_assigned;
}
#endif /* CONFIG_PCI_IOV */
#endif /* 3.10.0 */

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver Intel(R) Gigabit Ethernet Linux driver
Copyright(c) 2007-2012 Intel Corporation. Copyright(c) 2007-2013 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,

View File

@ -378,6 +378,56 @@ int _kc_snprintf(char * buf, size_t size, const char *fmt, ...)
} }
#endif /* < 2.4.8 */ #endif /* < 2.4.8 */
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) )
#ifdef CONFIG_PCI_IOV
int __kc_pci_vfs_assigned(struct pci_dev *dev)
{
unsigned int vfs_assigned = 0;
#ifdef HAVE_PCI_DEV_FLAGS_ASSIGNED
int pos;
struct pci_dev *vfdev;
unsigned short dev_id;
/* only search if we are a PF */
if (!dev->is_physfn)
return 0;
/* find SR-IOV capability */
pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_SRIOV);
if (!pos)
return 0;
/*
* * determine the device ID for the VFs, the vendor ID will be the
* * same as the PF so there is no need to check for that one
* */
pci_read_config_word(dev, pos + PCI_SRIOV_VF_DID, &dev_id);
/* loop through all the VFs to see if we own any that are assigned */
vfdev = pci_get_device(dev->vendor, dev_id, NULL);
while (vfdev) {
/*
* * It is considered assigned if it is a virtual function with
* * our dev as the physical function and the assigned bit is set
* */
if (vfdev->is_virtfn && (vfdev->physfn == dev) &&
(vfdev->dev_flags & PCI_DEV_FLAGS_ASSIGNED))
vfs_assigned++;
vfdev = pci_get_device(dev->vendor, dev_id, vfdev);
}
#endif /* HAVE_PCI_DEV_FLAGS_ASSIGNED */
return vfs_assigned;
}
#endif /* CONFIG_PCI_IOV */
#endif /* 3.10.0 */
/*****************************************************************************/ /*****************************************************************************/
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,13) ) #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,13) )
@ -1040,7 +1090,9 @@ _kc_pci_wake_from_d3(struct pci_dev *dev, bool enable)
out: out:
return err; return err;
} }
#endif /* < 2.6.28 */
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0) )
void _kc_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, void _kc_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
int off, int size) int off, int size)
{ {
@ -1049,7 +1101,7 @@ void _kc_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
skb->data_len += size; skb->data_len += size;
skb->truesize += size; skb->truesize += size;
} }
#endif /* < 2.6.28 */ #endif /* < 3.4.0 */
/*****************************************************************************/ /*****************************************************************************/
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) ) #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) )

View File

@ -2372,11 +2372,12 @@ static inline void __kc_skb_queue_head_init(struct sk_buff_head *list)
} }
#define __skb_queue_head_init(_q) __kc_skb_queue_head_init(_q) #define __skb_queue_head_init(_q) __kc_skb_queue_head_init(_q)
#endif #endif
#endif /* < 2.6.28 */
#ifndef skb_add_rx_frag #ifndef skb_add_rx_frag
#define skb_add_rx_frag _kc_skb_add_rx_frag #define skb_add_rx_frag _kc_skb_add_rx_frag
extern void _kc_skb_add_rx_frag(struct sk_buff *, int, struct page *, int, int); extern void _kc_skb_add_rx_frag(struct sk_buff *, int, struct page *, int, int);
#endif #endif
#endif /* < 2.6.28 */
/*****************************************************************************/ /*****************************************************************************/
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) ) #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) )
@ -3116,4 +3117,16 @@ typedef u32 netdev_features_t;
#define NETIF_F_HW_VLAN_FILTER NETIF_F_HW_VLAN_CTAG_FILTER #define NETIF_F_HW_VLAN_FILTER NETIF_F_HW_VLAN_CTAG_FILTER
#endif /* >= 3.10.0 */ #endif /* >= 3.10.0 */
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) )
#ifdef CONFIG_PCI_IOV
extern int __kc_pci_vfs_assigned(struct pci_dev *dev);
#else
static inline int __kc_pci_vfs_assigned(struct pci_dev *dev)
{
return 0;
}
#endif
#define pci_vfs_assigned(dev) __kc_pci_vfs_assigned(dev)
#endif
#endif /* _KCOMPAT_H_ */ #endif /* _KCOMPAT_H_ */