Commit 67c5f644 authored by Scott Feldman's avatar Scott Feldman Committed by David Mosberger

Update e1000 gige net driver:

Feedback from review by Arjan @ Redhat:
o Cleanup: Removed unneccesary #ifdef/#endif wrappers for features 
  already part of kernel.
o Bug fix: Use kernel funcs pci_[clear|set]_mwi rather than using direct
  calls to pci_write_config_word.
o Bug fix: Added read-behind-write calls to post writes before delays.
o Bug fix: removed calls to mdelay in interrupt context.
o Clean up: removed calls to memset followed by mb() and replaced with
  direct clearing of descriptor bits.
parent 9beae32e
...@@ -109,9 +109,7 @@ ...@@ -109,9 +109,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/reboot.h> #include <linux/reboot.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
#ifdef NETIF_F_HW_VLAN_TX
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#endif
#define BAR_0 0 #define BAR_0 0
#define BAR_1 1 #define BAR_1 1
...@@ -199,9 +197,7 @@ struct e1000_adapter { ...@@ -199,9 +197,7 @@ struct e1000_adapter {
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct list_head proc_list_head; struct list_head proc_list_head;
#endif #endif
#ifdef NETIF_F_HW_VLAN_TX
struct vlan_group *vlgrp; struct vlan_group *vlgrp;
#endif
char *id_string; char *id_string;
uint32_t bd_number; uint32_t bd_number;
uint32_t rx_buffer_len; uint32_t rx_buffer_len;
...@@ -212,10 +208,8 @@ struct e1000_adapter { ...@@ -212,10 +208,8 @@ struct e1000_adapter {
spinlock_t stats_lock; spinlock_t stats_lock;
atomic_t irq_sem; atomic_t irq_sem;
#ifdef ETHTOOL_PHYS_ID
struct timer_list blink_timer; struct timer_list blink_timer;
unsigned long led_status; unsigned long led_status;
#endif
/* TX */ /* TX */
struct e1000_desc_ring tx_ring; struct e1000_desc_ring tx_ring;
......
...@@ -412,7 +412,6 @@ e1000_ethtool_swol(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol) ...@@ -412,7 +412,6 @@ e1000_ethtool_swol(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol)
return 0; return 0;
} }
#ifdef ETHTOOL_PHYS_ID
/* toggle LED 4 times per second = 2 "blinks" per second */ /* toggle LED 4 times per second = 2 "blinks" per second */
#define E1000_ID_INTERVAL (HZ/4) #define E1000_ID_INTERVAL (HZ/4)
...@@ -458,7 +457,6 @@ e1000_ethtool_led_blink(struct e1000_adapter *adapter, struct ethtool_value *id) ...@@ -458,7 +457,6 @@ e1000_ethtool_led_blink(struct e1000_adapter *adapter, struct ethtool_value *id)
return 0; return 0;
} }
#endif /* ETHTOOL_PHYS_ID */
int int
e1000_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr) e1000_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr)
...@@ -516,14 +514,12 @@ e1000_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr) ...@@ -516,14 +514,12 @@ e1000_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr)
e1000_up(adapter); e1000_up(adapter);
return 0; return 0;
} }
#ifdef ETHTOOL_PHYS_ID
case ETHTOOL_PHYS_ID: { case ETHTOOL_PHYS_ID: {
struct ethtool_value id; struct ethtool_value id;
if(copy_from_user(&id, addr, sizeof(id))) if(copy_from_user(&id, addr, sizeof(id)))
return -EFAULT; return -EFAULT;
return e1000_ethtool_led_blink(adapter, &id); return e1000_ethtool_led_blink(adapter, &id);
} }
#endif /* ETHTOOL_PHYS_ID */
case ETHTOOL_GLINK: { case ETHTOOL_GLINK: {
struct ethtool_value link = {ETHTOOL_GLINK}; struct ethtool_value link = {ETHTOOL_GLINK};
link.data = netif_carrier_ok(netdev); link.data = netif_carrier_ok(netdev);
......
...@@ -107,17 +107,13 @@ e1000_reset_hw(struct e1000_hw *hw) ...@@ -107,17 +107,13 @@ e1000_reset_hw(struct e1000_hw *hw)
uint32_t ctrl_ext; uint32_t ctrl_ext;
uint32_t icr; uint32_t icr;
uint32_t manc; uint32_t manc;
uint16_t pci_cmd_word;
DEBUGFUNC("e1000_reset_hw"); DEBUGFUNC("e1000_reset_hw");
/* For 82542 (rev 2.0), disable MWI before issuing a device reset */ /* For 82542 (rev 2.0), disable MWI before issuing a device reset */
if(hw->mac_type == e1000_82542_rev2_0) { if(hw->mac_type == e1000_82542_rev2_0) {
if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE) { DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
DEBUGOUT("Disabling MWI on 82542 rev 2.0\n"); e1000_pci_clear_mwi(hw);
pci_cmd_word = hw->pci_cmd_word & ~CMD_MEM_WRT_INVALIDATE;
e1000_write_pci_cfg(hw, PCI_COMMAND_REGISTER, &pci_cmd_word);
}
} }
/* Clear interrupt mask to stop board from generating interrupts */ /* Clear interrupt mask to stop board from generating interrupts */
...@@ -130,6 +126,7 @@ e1000_reset_hw(struct e1000_hw *hw) ...@@ -130,6 +126,7 @@ e1000_reset_hw(struct e1000_hw *hw)
*/ */
E1000_WRITE_REG(hw, RCTL, 0); E1000_WRITE_REG(hw, RCTL, 0);
E1000_WRITE_REG(hw, TCTL, E1000_TCTL_PSP); E1000_WRITE_REG(hw, TCTL, E1000_TCTL_PSP);
E1000_WRITE_FLUSH(hw);
/* The tbi_compatibility_on Flag must be cleared when Rctl is cleared. */ /* The tbi_compatibility_on Flag must be cleared when Rctl is cleared. */
hw->tbi_compatibility_on = FALSE; hw->tbi_compatibility_on = FALSE;
...@@ -159,6 +156,7 @@ e1000_reset_hw(struct e1000_hw *hw) ...@@ -159,6 +156,7 @@ e1000_reset_hw(struct e1000_hw *hw)
ctrl_ext = E1000_READ_REG(hw, CTRL_EXT); ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
ctrl_ext |= E1000_CTRL_EXT_EE_RST; ctrl_ext |= E1000_CTRL_EXT_EE_RST;
E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext); E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
E1000_WRITE_FLUSH(hw);
/* Wait for EEPROM reload */ /* Wait for EEPROM reload */
msec_delay(2); msec_delay(2);
} else { } else {
...@@ -180,7 +178,7 @@ e1000_reset_hw(struct e1000_hw *hw) ...@@ -180,7 +178,7 @@ e1000_reset_hw(struct e1000_hw *hw)
/* If MWI was previously enabled, reenable it. */ /* If MWI was previously enabled, reenable it. */
if(hw->mac_type == e1000_82542_rev2_0) { if(hw->mac_type == e1000_82542_rev2_0) {
if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE) if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
e1000_write_pci_cfg(hw, PCI_COMMAND_REGISTER, &hw->pci_cmd_word); e1000_pci_set_mwi(hw);
} }
} }
...@@ -201,7 +199,6 @@ e1000_init_hw(struct e1000_hw *hw) ...@@ -201,7 +199,6 @@ e1000_init_hw(struct e1000_hw *hw)
uint32_t ctrl, status; uint32_t ctrl, status;
uint32_t i; uint32_t i;
int32_t ret_val; int32_t ret_val;
uint16_t pci_cmd_word;
uint16_t pcix_cmd_word; uint16_t pcix_cmd_word;
uint16_t pcix_stat_hi_word; uint16_t pcix_stat_hi_word;
uint16_t cmd_mmrbc; uint16_t cmd_mmrbc;
...@@ -244,12 +241,10 @@ e1000_init_hw(struct e1000_hw *hw) ...@@ -244,12 +241,10 @@ e1000_init_hw(struct e1000_hw *hw)
/* For 82542 (rev 2.0), disable MWI and put the receiver into reset */ /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
if(hw->mac_type == e1000_82542_rev2_0) { if(hw->mac_type == e1000_82542_rev2_0) {
if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE) { DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
DEBUGOUT("Disabling MWI on 82542 rev 2.0\n"); e1000_pci_clear_mwi(hw);
pci_cmd_word = hw->pci_cmd_word & ~CMD_MEM_WRT_INVALIDATE;
e1000_write_pci_cfg(hw, PCI_COMMAND_REGISTER, &pci_cmd_word);
}
E1000_WRITE_REG(hw, RCTL, E1000_RCTL_RST); E1000_WRITE_REG(hw, RCTL, E1000_RCTL_RST);
E1000_WRITE_FLUSH(hw);
msec_delay(5); msec_delay(5);
} }
...@@ -261,9 +256,10 @@ e1000_init_hw(struct e1000_hw *hw) ...@@ -261,9 +256,10 @@ e1000_init_hw(struct e1000_hw *hw)
/* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */ /* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
if(hw->mac_type == e1000_82542_rev2_0) { if(hw->mac_type == e1000_82542_rev2_0) {
E1000_WRITE_REG(hw, RCTL, 0); E1000_WRITE_REG(hw, RCTL, 0);
E1000_WRITE_FLUSH(hw);
msec_delay(1); msec_delay(1);
if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE) if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
e1000_write_pci_cfg(hw, PCI_COMMAND_REGISTER, &hw->pci_cmd_word); e1000_pci_set_mwi(hw);
} }
/* Zero out the Multicast HASH table */ /* Zero out the Multicast HASH table */
...@@ -509,6 +505,7 @@ e1000_setup_fiber_link(struct e1000_hw *hw) ...@@ -509,6 +505,7 @@ e1000_setup_fiber_link(struct e1000_hw *hw)
E1000_WRITE_REG(hw, TXCW, txcw); E1000_WRITE_REG(hw, TXCW, txcw);
E1000_WRITE_REG(hw, CTRL, ctrl); E1000_WRITE_REG(hw, CTRL, ctrl);
E1000_WRITE_FLUSH(hw);
hw->txcw = txcw; hw->txcw = txcw;
msec_delay(1); msec_delay(1);
...@@ -1122,6 +1119,7 @@ e1000_config_collision_dist(struct e1000_hw *hw) ...@@ -1122,6 +1119,7 @@ e1000_config_collision_dist(struct e1000_hw *hw)
tctl |= E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT; tctl |= E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT;
E1000_WRITE_REG(hw, TCTL, tctl); E1000_WRITE_REG(hw, TCTL, tctl);
E1000_WRITE_FLUSH(hw);
} }
/****************************************************************************** /******************************************************************************
...@@ -1719,6 +1717,7 @@ e1000_raise_mdi_clk(struct e1000_hw *hw, ...@@ -1719,6 +1717,7 @@ e1000_raise_mdi_clk(struct e1000_hw *hw,
* bit), and then delay 2 microseconds. * bit), and then delay 2 microseconds.
*/ */
E1000_WRITE_REG(hw, CTRL, (*ctrl | E1000_CTRL_MDC)); E1000_WRITE_REG(hw, CTRL, (*ctrl | E1000_CTRL_MDC));
E1000_WRITE_FLUSH(hw);
usec_delay(2); usec_delay(2);
} }
...@@ -1736,6 +1735,7 @@ e1000_lower_mdi_clk(struct e1000_hw *hw, ...@@ -1736,6 +1735,7 @@ e1000_lower_mdi_clk(struct e1000_hw *hw,
* bit), and then delay 2 microseconds. * bit), and then delay 2 microseconds.
*/ */
E1000_WRITE_REG(hw, CTRL, (*ctrl & ~E1000_CTRL_MDC)); E1000_WRITE_REG(hw, CTRL, (*ctrl & ~E1000_CTRL_MDC));
E1000_WRITE_FLUSH(hw);
usec_delay(2); usec_delay(2);
} }
...@@ -1778,6 +1778,7 @@ e1000_shift_out_mdi_bits(struct e1000_hw *hw, ...@@ -1778,6 +1778,7 @@ e1000_shift_out_mdi_bits(struct e1000_hw *hw,
else ctrl &= ~E1000_CTRL_MDIO; else ctrl &= ~E1000_CTRL_MDIO;
E1000_WRITE_REG(hw, CTRL, ctrl); E1000_WRITE_REG(hw, CTRL, ctrl);
E1000_WRITE_FLUSH(hw);
usec_delay(2); usec_delay(2);
...@@ -1786,9 +1787,6 @@ e1000_shift_out_mdi_bits(struct e1000_hw *hw, ...@@ -1786,9 +1787,6 @@ e1000_shift_out_mdi_bits(struct e1000_hw *hw,
mask = mask >> 1; mask = mask >> 1;
} }
/* Clear the data bit just before leaving this routine. */
ctrl &= ~E1000_CTRL_MDIO;
} }
/****************************************************************************** /******************************************************************************
...@@ -1819,6 +1817,7 @@ e1000_shift_in_mdi_bits(struct e1000_hw *hw) ...@@ -1819,6 +1817,7 @@ e1000_shift_in_mdi_bits(struct e1000_hw *hw)
ctrl &= ~E1000_CTRL_MDIO; ctrl &= ~E1000_CTRL_MDIO;
E1000_WRITE_REG(hw, CTRL, ctrl); E1000_WRITE_REG(hw, CTRL, ctrl);
E1000_WRITE_FLUSH(hw);
/* Raise and Lower the clock before reading in the data. This accounts for /* Raise and Lower the clock before reading in the data. This accounts for
* the turnaround bits. The first clock occurred when we clocked out the * the turnaround bits. The first clock occurred when we clocked out the
...@@ -1839,9 +1838,6 @@ e1000_shift_in_mdi_bits(struct e1000_hw *hw) ...@@ -1839,9 +1838,6 @@ e1000_shift_in_mdi_bits(struct e1000_hw *hw)
e1000_raise_mdi_clk(hw, &ctrl); e1000_raise_mdi_clk(hw, &ctrl);
e1000_lower_mdi_clk(hw, &ctrl); e1000_lower_mdi_clk(hw, &ctrl);
/* Clear the MDIO bit just before leaving this routine. */
ctrl &= ~E1000_CTRL_MDIO;
return data; return data;
} }
...@@ -2015,8 +2011,10 @@ e1000_phy_hw_reset(struct e1000_hw *hw) ...@@ -2015,8 +2011,10 @@ e1000_phy_hw_reset(struct e1000_hw *hw)
*/ */
ctrl = E1000_READ_REG(hw, CTRL); ctrl = E1000_READ_REG(hw, CTRL);
E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PHY_RST); E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PHY_RST);
E1000_WRITE_FLUSH(hw);
msec_delay(10); msec_delay(10);
E1000_WRITE_REG(hw, CTRL, ctrl); E1000_WRITE_REG(hw, CTRL, ctrl);
E1000_WRITE_FLUSH(hw);
} else { } else {
/* Read the Extended Device Control Register, assert the PHY_RESET_DIR /* Read the Extended Device Control Register, assert the PHY_RESET_DIR
* bit to put the PHY into reset. Then, take it out of reset. * bit to put the PHY into reset. Then, take it out of reset.
...@@ -2025,9 +2023,11 @@ e1000_phy_hw_reset(struct e1000_hw *hw) ...@@ -2025,9 +2023,11 @@ e1000_phy_hw_reset(struct e1000_hw *hw)
ctrl_ext |= E1000_CTRL_EXT_SDP4_DIR; ctrl_ext |= E1000_CTRL_EXT_SDP4_DIR;
ctrl_ext &= ~E1000_CTRL_EXT_SDP4_DATA; ctrl_ext &= ~E1000_CTRL_EXT_SDP4_DATA;
E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext); E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
E1000_WRITE_FLUSH(hw);
msec_delay(10); msec_delay(10);
ctrl_ext |= E1000_CTRL_EXT_SDP4_DATA; ctrl_ext |= E1000_CTRL_EXT_SDP4_DATA;
E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext); E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
E1000_WRITE_FLUSH(hw);
} }
usec_delay(150); usec_delay(150);
} }
...@@ -2230,6 +2230,7 @@ e1000_raise_ee_clk(struct e1000_hw *hw, ...@@ -2230,6 +2230,7 @@ e1000_raise_ee_clk(struct e1000_hw *hw,
*/ */
*eecd = *eecd | E1000_EECD_SK; *eecd = *eecd | E1000_EECD_SK;
E1000_WRITE_REG(hw, EECD, *eecd); E1000_WRITE_REG(hw, EECD, *eecd);
E1000_WRITE_FLUSH(hw);
usec_delay(50); usec_delay(50);
} }
...@@ -2248,6 +2249,7 @@ e1000_lower_ee_clk(struct e1000_hw *hw, ...@@ -2248,6 +2249,7 @@ e1000_lower_ee_clk(struct e1000_hw *hw,
*/ */
*eecd = *eecd & ~E1000_EECD_SK; *eecd = *eecd & ~E1000_EECD_SK;
E1000_WRITE_REG(hw, EECD, *eecd); E1000_WRITE_REG(hw, EECD, *eecd);
E1000_WRITE_FLUSH(hw);
usec_delay(50); usec_delay(50);
} }
...@@ -2285,6 +2287,7 @@ e1000_shift_out_ee_bits(struct e1000_hw *hw, ...@@ -2285,6 +2287,7 @@ e1000_shift_out_ee_bits(struct e1000_hw *hw,
eecd |= E1000_EECD_DI; eecd |= E1000_EECD_DI;
E1000_WRITE_REG(hw, EECD, eecd); E1000_WRITE_REG(hw, EECD, eecd);
E1000_WRITE_FLUSH(hw);
usec_delay(50); usec_delay(50);
...@@ -2379,21 +2382,25 @@ e1000_standby_eeprom(struct e1000_hw *hw) ...@@ -2379,21 +2382,25 @@ e1000_standby_eeprom(struct e1000_hw *hw)
/* Deselct EEPROM */ /* Deselct EEPROM */
eecd &= ~(E1000_EECD_CS | E1000_EECD_SK); eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
E1000_WRITE_REG(hw, EECD, eecd); E1000_WRITE_REG(hw, EECD, eecd);
E1000_WRITE_FLUSH(hw);
usec_delay(50); usec_delay(50);
/* Clock high */ /* Clock high */
eecd |= E1000_EECD_SK; eecd |= E1000_EECD_SK;
E1000_WRITE_REG(hw, EECD, eecd); E1000_WRITE_REG(hw, EECD, eecd);
E1000_WRITE_FLUSH(hw);
usec_delay(50); usec_delay(50);
/* Select EEPROM */ /* Select EEPROM */
eecd |= E1000_EECD_CS; eecd |= E1000_EECD_CS;
E1000_WRITE_REG(hw, EECD, eecd); E1000_WRITE_REG(hw, EECD, eecd);
E1000_WRITE_FLUSH(hw);
usec_delay(50); usec_delay(50);
/* Clock low */ /* Clock low */
eecd &= ~E1000_EECD_SK; eecd &= ~E1000_EECD_SK;
E1000_WRITE_REG(hw, EECD, eecd); E1000_WRITE_REG(hw, EECD, eecd);
E1000_WRITE_FLUSH(hw);
usec_delay(50); usec_delay(50);
} }
...@@ -2412,11 +2419,13 @@ e1000_clock_eeprom(struct e1000_hw *hw) ...@@ -2412,11 +2419,13 @@ e1000_clock_eeprom(struct e1000_hw *hw)
/* Rising edge of clock */ /* Rising edge of clock */
eecd |= E1000_EECD_SK; eecd |= E1000_EECD_SK;
E1000_WRITE_REG(hw, EECD, eecd); E1000_WRITE_REG(hw, EECD, eecd);
E1000_WRITE_FLUSH(hw);
usec_delay(50); usec_delay(50);
/* Falling edge of clock */ /* Falling edge of clock */
eecd &= ~E1000_EECD_SK; eecd &= ~E1000_EECD_SK;
E1000_WRITE_REG(hw, EECD, eecd); E1000_WRITE_REG(hw, EECD, eecd);
E1000_WRITE_FLUSH(hw);
usec_delay(50); usec_delay(50);
} }
......
...@@ -264,6 +264,8 @@ void e1000_reset_adaptive(struct e1000_hw *hw); ...@@ -264,6 +264,8 @@ void e1000_reset_adaptive(struct e1000_hw *hw);
void e1000_update_adaptive(struct e1000_hw *hw); void e1000_update_adaptive(struct e1000_hw *hw);
void e1000_tbi_adjust_stats(struct e1000_hw *hw, struct e1000_hw_stats *stats, uint32_t frame_len, uint8_t * mac_addr); void e1000_tbi_adjust_stats(struct e1000_hw *hw, struct e1000_hw_stats *stats, uint32_t frame_len, uint8_t * mac_addr);
void e1000_get_bus_info(struct e1000_hw *hw); void e1000_get_bus_info(struct e1000_hw *hw);
void e1000_pci_set_mwi(struct e1000_hw *hw);
void e1000_pci_clear_mwi(struct e1000_hw *hw);
void e1000_read_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t * value); void e1000_read_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t * value);
void e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t * value); void e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t * value);
/* Port I/O is only supported on 82544 and newer */ /* Port I/O is only supported on 82544 and newer */
......
...@@ -196,11 +196,9 @@ static inline void e1000_rx_checksum(struct e1000_adapter *adapter, ...@@ -196,11 +196,9 @@ static inline void e1000_rx_checksum(struct e1000_adapter *adapter,
struct sk_buff *skb); struct sk_buff *skb);
static void e1000_tx_timeout(struct net_device *dev); static void e1000_tx_timeout(struct net_device *dev);
#ifdef NETIF_F_HW_VLAN_TX
static void e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp); static void e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
static void e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid); static void e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
static void e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid); static void e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
#endif
static int e1000_notify_reboot(struct notifier_block *, unsigned long event, void *ptr); static int e1000_notify_reboot(struct notifier_block *, unsigned long event, void *ptr);
static int e1000_suspend(struct pci_dev *pdev, uint32_t state); static int e1000_suspend(struct pci_dev *pdev, uint32_t state);
...@@ -422,11 +420,9 @@ e1000_probe(struct pci_dev *pdev, ...@@ -422,11 +420,9 @@ e1000_probe(struct pci_dev *pdev,
netdev->do_ioctl = &e1000_ioctl; netdev->do_ioctl = &e1000_ioctl;
netdev->tx_timeout = &e1000_tx_timeout; netdev->tx_timeout = &e1000_tx_timeout;
netdev->watchdog_timeo = HZ; netdev->watchdog_timeo = HZ;
#ifdef NETIF_F_HW_VLAN_TX
netdev->vlan_rx_register = e1000_vlan_rx_register; netdev->vlan_rx_register = e1000_vlan_rx_register;
netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid; netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid; netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
#endif
netdev->irq = pdev->irq; netdev->irq = pdev->irq;
netdev->mem_start = mmio_start; netdev->mem_start = mmio_start;
...@@ -440,15 +436,11 @@ e1000_probe(struct pci_dev *pdev, ...@@ -440,15 +436,11 @@ e1000_probe(struct pci_dev *pdev,
e1000_sw_init(adapter); e1000_sw_init(adapter);
if(adapter->hw.mac_type >= e1000_82543) { if(adapter->hw.mac_type >= e1000_82543) {
#ifdef NETIF_F_HW_VLAN_TX
netdev->features = NETIF_F_SG | netdev->features = NETIF_F_SG |
NETIF_F_HW_CSUM | NETIF_F_HW_CSUM |
NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_TX |
NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_RX |
NETIF_F_HW_VLAN_FILTER; NETIF_F_HW_VLAN_FILTER;
#else
netdev->features = NETIF_F_SG | NETIF_F_HW_CSUM;
#endif
} else { } else {
netdev->features = NETIF_F_SG; netdev->features = NETIF_F_SG;
} }
...@@ -582,18 +574,12 @@ e1000_sw_init(struct e1000_adapter *adapter) ...@@ -582,18 +574,12 @@ e1000_sw_init(struct e1000_adapter *adapter)
/* PCI config space info */ /* PCI config space info */
uint16_t *vendor = &hw->vendor_id; pci_read_config_word(pdev, PCI_VENDOR_ID, &hw->vendor_id);
uint16_t *device = &hw->device_id; pci_read_config_word(pdev, PCI_DEVICE_ID, &hw->device_id);
uint16_t *subvendor = &hw->subsystem_vendor_id; pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID,
uint16_t *subsystem = &hw->subsystem_id; &hw->subsystem_vendor_id);
uint8_t *revision = &hw->revision_id; pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &hw->subsystem_id);
pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
pci_read_config_word(pdev, PCI_VENDOR_ID, vendor);
pci_read_config_word(pdev, PCI_DEVICE_ID, device);
pci_read_config_byte(pdev, PCI_REVISION_ID, revision);
pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, subvendor);
pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, subsystem);
pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word); pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
adapter->rx_buffer_len = E1000_RXBUFFER_2048; adapter->rx_buffer_len = E1000_RXBUFFER_2048;
...@@ -603,9 +589,9 @@ e1000_sw_init(struct e1000_adapter *adapter) ...@@ -603,9 +589,9 @@ e1000_sw_init(struct e1000_adapter *adapter)
/* identify the MAC */ /* identify the MAC */
switch (*device) { switch (hw->device_id) {
case E1000_DEV_ID_82542: case E1000_DEV_ID_82542:
switch (*revision) { switch (hw->revision_id) {
case E1000_82542_2_0_REV_ID: case E1000_82542_2_0_REV_ID:
hw->mac_type = e1000_82542_rev2_0; hw->mac_type = e1000_82542_rev2_0;
break; break;
...@@ -639,7 +625,7 @@ e1000_sw_init(struct e1000_adapter *adapter) ...@@ -639,7 +625,7 @@ e1000_sw_init(struct e1000_adapter *adapter)
hw->mac_type = e1000_82546; hw->mac_type = e1000_82546;
break; break;
default: default:
/* should never have loaded on this device */ E1000_ERR("Should never have loaded on this device\n");
BUG(); BUG();
} }
...@@ -1138,20 +1124,16 @@ e1000_clean_rx_ring(struct e1000_adapter *adapter) ...@@ -1138,20 +1124,16 @@ e1000_clean_rx_ring(struct e1000_adapter *adapter)
static void static void
e1000_enter_82542_rst(struct e1000_adapter *adapter) e1000_enter_82542_rst(struct e1000_adapter *adapter)
{ {
struct pci_dev *pdev = adapter->pdev;
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
uint16_t pci_command_word = adapter->hw.pci_cmd_word;
uint32_t rctl; uint32_t rctl;
if(pci_command_word & PCI_COMMAND_INVALIDATE) { e1000_pci_clear_mwi(&adapter->hw);
pci_command_word &= ~PCI_COMMAND_INVALIDATE;
pci_write_config_word(pdev, PCI_COMMAND, pci_command_word);
}
rctl = E1000_READ_REG(&adapter->hw, RCTL); rctl = E1000_READ_REG(&adapter->hw, RCTL);
rctl |= E1000_RCTL_RST; rctl |= E1000_RCTL_RST;
E1000_WRITE_REG(&adapter->hw, RCTL, rctl); E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
msec_delay(5); E1000_WRITE_FLUSH(&adapter->hw);
mdelay(5);
if(netif_running(netdev)) if(netif_running(netdev))
e1000_clean_rx_ring(adapter); e1000_clean_rx_ring(adapter);
...@@ -1160,18 +1142,17 @@ e1000_enter_82542_rst(struct e1000_adapter *adapter) ...@@ -1160,18 +1142,17 @@ e1000_enter_82542_rst(struct e1000_adapter *adapter)
static void static void
e1000_leave_82542_rst(struct e1000_adapter *adapter) e1000_leave_82542_rst(struct e1000_adapter *adapter)
{ {
struct pci_dev *pdev = adapter->pdev;
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
uint16_t pci_command_word = adapter->hw.pci_cmd_word;
uint32_t rctl; uint32_t rctl;
rctl = E1000_READ_REG(&adapter->hw, RCTL); rctl = E1000_READ_REG(&adapter->hw, RCTL);
rctl &= ~E1000_RCTL_RST; rctl &= ~E1000_RCTL_RST;
E1000_WRITE_REG(&adapter->hw, RCTL, rctl); E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
msec_delay(5); E1000_WRITE_FLUSH(&adapter->hw);
mdelay(5);
if(pci_command_word & PCI_COMMAND_INVALIDATE) if(adapter->hw.pci_cmd_word & PCI_COMMAND_INVALIDATE)
pci_write_config_word(pdev, PCI_COMMAND, pci_command_word); e1000_pci_set_mwi(&adapter->hw);
if(netif_running(netdev)) { if(netif_running(netdev)) {
e1000_configure_rx(adapter); e1000_configure_rx(adapter);
...@@ -1478,6 +1459,7 @@ e1000_tx_queue(struct e1000_adapter *adapter, int count, int tx_flags) ...@@ -1478,6 +1459,7 @@ e1000_tx_queue(struct e1000_adapter *adapter, int count, int tx_flags)
tx_ring->next_to_use = i; tx_ring->next_to_use = i;
E1000_WRITE_REG(&adapter->hw, TDT, i); E1000_WRITE_REG(&adapter->hw, TDT, i);
E1000_WRITE_FLUSH(&adapter->hw);
} }
#define TXD_USE_COUNT(S, X) (((S) / (X)) + (((S) % (X)) ? 1 : 0)) #define TXD_USE_COUNT(S, X) (((S) / (X)) + (((S) % (X)) ? 1 : 0))
...@@ -1507,12 +1489,10 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) ...@@ -1507,12 +1489,10 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
if(e1000_tx_csum(adapter, skb)) if(e1000_tx_csum(adapter, skb))
tx_flags |= E1000_TX_FLAGS_CSUM; tx_flags |= E1000_TX_FLAGS_CSUM;
#ifdef NETIF_F_HW_VLAN_TX
if(adapter->vlgrp && vlan_tx_tag_present(skb)) { if(adapter->vlgrp && vlan_tx_tag_present(skb)) {
tx_flags |= E1000_TX_FLAGS_VLAN; tx_flags |= E1000_TX_FLAGS_VLAN;
tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT); tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
} }
#endif
count = e1000_tx_map(adapter, skb); count = e1000_tx_map(adapter, skb);
...@@ -1748,6 +1728,7 @@ e1000_irq_disable(struct e1000_adapter *adapter) ...@@ -1748,6 +1728,7 @@ e1000_irq_disable(struct e1000_adapter *adapter)
{ {
atomic_inc(&adapter->irq_sem); atomic_inc(&adapter->irq_sem);
E1000_WRITE_REG(&adapter->hw, IMC, ~0); E1000_WRITE_REG(&adapter->hw, IMC, ~0);
E1000_WRITE_FLUSH(&adapter->hw);
synchronize_irq(adapter->netdev->irq); synchronize_irq(adapter->netdev->irq);
} }
...@@ -1759,8 +1740,10 @@ e1000_irq_disable(struct e1000_adapter *adapter) ...@@ -1759,8 +1740,10 @@ e1000_irq_disable(struct e1000_adapter *adapter)
static inline void static inline void
e1000_irq_enable(struct e1000_adapter *adapter) e1000_irq_enable(struct e1000_adapter *adapter)
{ {
if(atomic_dec_and_test(&adapter->irq_sem)) if(atomic_dec_and_test(&adapter->irq_sem)) {
E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK); E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK);
E1000_WRITE_FLUSH(&adapter->hw);
}
} }
/** /**
...@@ -1828,8 +1811,7 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter) ...@@ -1828,8 +1811,7 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
tx_ring->buffer_info[i].skb = NULL; tx_ring->buffer_info[i].skb = NULL;
} }
memset(tx_desc, 0, sizeof(struct e1000_tx_desc)); tx_desc->upper.data = 0;
mb();
i = (i + 1) % tx_ring->count; i = (i + 1) % tx_ring->count;
tx_desc = E1000_TX_DESC(*tx_ring, i); tx_desc = E1000_TX_DESC(*tx_ring, i);
...@@ -1882,8 +1864,7 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter) ...@@ -1882,8 +1864,7 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter)
E1000_DBG("Receive packet consumed multiple buffers\n"); E1000_DBG("Receive packet consumed multiple buffers\n");
dev_kfree_skb_irq(skb); dev_kfree_skb_irq(skb);
memset(rx_desc, 0, sizeof(struct e1000_rx_desc)); rx_desc->status = 0;
mb();
rx_ring->buffer_info[i].skb = NULL; rx_ring->buffer_info[i].skb = NULL;
i = (i + 1) % rx_ring->count; i = (i + 1) % rx_ring->count;
...@@ -1911,8 +1892,7 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter) ...@@ -1911,8 +1892,7 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter)
} else { } else {
dev_kfree_skb_irq(skb); dev_kfree_skb_irq(skb);
memset(rx_desc, 0, sizeof(struct e1000_rx_desc)); rx_desc->status = 0;
mb();
rx_ring->buffer_info[i].skb = NULL; rx_ring->buffer_info[i].skb = NULL;
i = (i + 1) % rx_ring->count; i = (i + 1) % rx_ring->count;
...@@ -1929,20 +1909,15 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter) ...@@ -1929,20 +1909,15 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter)
e1000_rx_checksum(adapter, rx_desc, skb); e1000_rx_checksum(adapter, rx_desc, skb);
skb->protocol = eth_type_trans(skb, netdev); skb->protocol = eth_type_trans(skb, netdev);
#ifdef NETIF_F_HW_VLAN_TX
if(adapter->vlgrp && (rx_desc->status & E1000_RXD_STAT_VP)) { if(adapter->vlgrp && (rx_desc->status & E1000_RXD_STAT_VP)) {
vlan_hwaccel_rx(skb, adapter->vlgrp, vlan_hwaccel_rx(skb, adapter->vlgrp,
(rx_desc->special & E1000_RXD_SPC_VLAN_MASK)); (rx_desc->special & E1000_RXD_SPC_VLAN_MASK));
} else { } else {
netif_rx(skb); netif_rx(skb);
} }
#else
netif_rx(skb);
#endif
netdev->last_rx = jiffies; netdev->last_rx = jiffies;
memset(rx_desc, 0, sizeof(struct e1000_rx_desc)); rx_desc->status = 0;
mb();
rx_ring->buffer_info[i].skb = NULL; rx_ring->buffer_info[i].skb = NULL;
i = (i + 1) % rx_ring->count; i = (i + 1) % rx_ring->count;
...@@ -2066,6 +2041,22 @@ e1000_rx_checksum(struct e1000_adapter *adapter, ...@@ -2066,6 +2041,22 @@ e1000_rx_checksum(struct e1000_adapter *adapter,
} }
} }
void
e1000_pci_set_mwi(struct e1000_hw *hw)
{
struct e1000_adapter *adapter = hw->back;
pci_set_mwi(adapter->pdev);
}
void
e1000_pci_clear_mwi(struct e1000_hw *hw)
{
struct e1000_adapter *adapter = hw->back;
pci_clear_mwi(adapter->pdev);
}
void void
e1000_read_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value) e1000_read_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
{ {
...@@ -2094,7 +2085,6 @@ e1000_io_write(struct e1000_hw *hw, uint32_t port, uint32_t value) ...@@ -2094,7 +2085,6 @@ e1000_io_write(struct e1000_hw *hw, uint32_t port, uint32_t value)
outl(value, port); outl(value, port);
} }
#ifdef NETIF_F_HW_VLAN_TX
static void static void
e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp) e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
{ {
...@@ -2170,7 +2160,6 @@ e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid) ...@@ -2170,7 +2160,6 @@ e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
vfta &= ~(1 << (vid & 0x1F)); vfta &= ~(1 << (vid & 0x1F));
e1000_write_vfta(&adapter->hw, index, vfta); e1000_write_vfta(&adapter->hw, index, vfta);
} }
#endif
static int static int
e1000_notify_reboot(struct notifier_block *nb, unsigned long event, void *p) e1000_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
......
...@@ -88,7 +88,8 @@ ...@@ -88,7 +88,8 @@
#define usec_delay(x) udelay(x) #define usec_delay(x) udelay(x)
#ifndef msec_delay #ifndef msec_delay
#define msec_delay(x) do { if(in_interrupt()) { \ #define msec_delay(x) do { if(in_interrupt()) { \
mdelay(x); \ /* Don't mdelay in interrupt context! */ \
BUG(); \
} else { \ } else { \
set_current_state(TASK_UNINTERRUPTIBLE); \ set_current_state(TASK_UNINTERRUPTIBLE); \
schedule_timeout((x * HZ)/1000); \ schedule_timeout((x * HZ)/1000); \
...@@ -140,4 +141,6 @@ typedef enum { ...@@ -140,4 +141,6 @@ typedef enum {
readl((a)->hw_addr + E1000_##reg + ((offset) << 2)) : \ readl((a)->hw_addr + E1000_##reg + ((offset) << 2)) : \
readl((a)->hw_addr + E1000_82542_##reg + ((offset) << 2))) readl((a)->hw_addr + E1000_82542_##reg + ((offset) << 2)))
#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS);
#endif /* _E1000_OSDEP_H_ */ #endif /* _E1000_OSDEP_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment