aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tg3.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r--drivers/net/tg3.c207
1 files changed, 125 insertions, 82 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 9488f49ea569..e5e901ecd808 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -64,8 +64,8 @@
64 64
65#define DRV_MODULE_NAME "tg3" 65#define DRV_MODULE_NAME "tg3"
66#define PFX DRV_MODULE_NAME ": " 66#define PFX DRV_MODULE_NAME ": "
67#define DRV_MODULE_VERSION "3.75" 67#define DRV_MODULE_VERSION "3.76"
68#define DRV_MODULE_RELDATE "March 23, 2007" 68#define DRV_MODULE_RELDATE "May 5, 2007"
69 69
70#define TG3_DEF_MAC_MODE 0 70#define TG3_DEF_MAC_MODE 0
71#define TG3_DEF_RX_MODE 0 71#define TG3_DEF_RX_MODE 0
@@ -1300,9 +1300,11 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
1300 msleep(1); 1300 msleep(1);
1301 } 1301 }
1302 } 1302 }
1303 tg3_write_mem(tp, NIC_SRAM_WOL_MBOX, WOL_SIGNATURE | 1303 if (tp->tg3_flags & TG3_FLAG_WOL_CAP)
1304 WOL_DRV_STATE_SHUTDOWN | 1304 tg3_write_mem(tp, NIC_SRAM_WOL_MBOX, WOL_SIGNATURE |
1305 WOL_DRV_WOL | WOL_SET_MAGIC_PKT); 1305 WOL_DRV_STATE_SHUTDOWN |
1306 WOL_DRV_WOL |
1307 WOL_SET_MAGIC_PKT);
1306 1308
1307 pci_read_config_word(tp->pdev, pm + PCI_PM_PMC, &power_caps); 1309 pci_read_config_word(tp->pdev, pm + PCI_PM_PMC, &power_caps);
1308 1310
@@ -2593,10 +2595,8 @@ static int tg3_setup_fiber_by_hand(struct tg3 *tp, u32 mac_status)
2593{ 2595{
2594 int current_link_up = 0; 2596 int current_link_up = 0;
2595 2597
2596 if (!(mac_status & MAC_STATUS_PCS_SYNCED)) { 2598 if (!(mac_status & MAC_STATUS_PCS_SYNCED))
2597 tp->tg3_flags &= ~TG3_FLAG_GOT_SERDES_FLOWCTL;
2598 goto out; 2599 goto out;
2599 }
2600 2600
2601 if (tp->link_config.autoneg == AUTONEG_ENABLE) { 2601 if (tp->link_config.autoneg == AUTONEG_ENABLE) {
2602 u32 flags; 2602 u32 flags;
@@ -2614,7 +2614,6 @@ static int tg3_setup_fiber_by_hand(struct tg3 *tp, u32 mac_status)
2614 2614
2615 tg3_setup_flow_control(tp, local_adv, remote_adv); 2615 tg3_setup_flow_control(tp, local_adv, remote_adv);
2616 2616
2617 tp->tg3_flags |= TG3_FLAG_GOT_SERDES_FLOWCTL;
2618 current_link_up = 1; 2617 current_link_up = 1;
2619 } 2618 }
2620 for (i = 0; i < 30; i++) { 2619 for (i = 0; i < 30; i++) {
@@ -2637,7 +2636,6 @@ static int tg3_setup_fiber_by_hand(struct tg3 *tp, u32 mac_status)
2637 } else { 2636 } else {
2638 /* Forcing 1000FD link up. */ 2637 /* Forcing 1000FD link up. */
2639 current_link_up = 1; 2638 current_link_up = 1;
2640 tp->tg3_flags |= TG3_FLAG_GOT_SERDES_FLOWCTL;
2641 2639
2642 tw32_f(MAC_MODE, (tp->mac_mode | MAC_MODE_SEND_CONFIGS)); 2640 tw32_f(MAC_MODE, (tp->mac_mode | MAC_MODE_SEND_CONFIGS));
2643 udelay(40); 2641 udelay(40);
@@ -3021,6 +3019,16 @@ static int tg3_setup_phy(struct tg3 *tp, int force_reset)
3021 } 3019 }
3022 } 3020 }
3023 3021
3022 if (tp->tg3_flags & TG3_FLAG_ASPM_WORKAROUND) {
3023 u32 val = tr32(PCIE_PWR_MGMT_THRESH);
3024 if (!netif_carrier_ok(tp->dev))
3025 val = (val & ~PCIE_PWR_MGMT_L1_THRESH_MSK) |
3026 tp->pwrmgmt_thresh;
3027 else
3028 val |= PCIE_PWR_MGMT_L1_THRESH_MSK;
3029 tw32(PCIE_PWR_MGMT_THRESH, val);
3030 }
3031
3024 return err; 3032 return err;
3025} 3033}
3026 3034
@@ -3582,8 +3590,12 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id)
3582 * Writing non-zero to intr-mbox-0 additional tells the 3590 * Writing non-zero to intr-mbox-0 additional tells the
3583 * NIC to stop sending us irqs, engaging "in-intr-handler" 3591 * NIC to stop sending us irqs, engaging "in-intr-handler"
3584 * event coalescing. 3592 * event coalescing.
3593 *
3594 * Flush the mailbox to de-assert the IRQ immediately to prevent
3595 * spurious interrupts. The flush impacts performance but
3596 * excessive spurious interrupts can be worse in some cases.
3585 */ 3597 */
3586 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001); 3598 tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);
3587 if (tg3_irq_sync(tp)) 3599 if (tg3_irq_sync(tp))
3588 goto out; 3600 goto out;
3589 sblk->status &= ~SD_STATUS_UPDATED; 3601 sblk->status &= ~SD_STATUS_UPDATED;
@@ -3627,8 +3639,12 @@ static irqreturn_t tg3_interrupt_tagged(int irq, void *dev_id)
3627 * writing non-zero to intr-mbox-0 additional tells the 3639 * writing non-zero to intr-mbox-0 additional tells the
3628 * NIC to stop sending us irqs, engaging "in-intr-handler" 3640 * NIC to stop sending us irqs, engaging "in-intr-handler"
3629 * event coalescing. 3641 * event coalescing.
3642 *
3643 * Flush the mailbox to de-assert the IRQ immediately to prevent
3644 * spurious interrupts. The flush impacts performance but
3645 * excessive spurious interrupts can be worse in some cases.
3630 */ 3646 */
3631 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001); 3647 tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);
3632 if (tg3_irq_sync(tp)) 3648 if (tg3_irq_sync(tp))
3633 goto out; 3649 goto out;
3634 if (netif_rx_schedule_prep(dev)) { 3650 if (netif_rx_schedule_prep(dev)) {
@@ -3895,8 +3911,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3895 entry = tp->tx_prod; 3911 entry = tp->tx_prod;
3896 base_flags = 0; 3912 base_flags = 0;
3897 mss = 0; 3913 mss = 0;
3898 if (skb->len > (tp->dev->mtu + ETH_HLEN) && 3914 if ((mss = skb_shinfo(skb)->gso_size) != 0) {
3899 (mss = skb_shinfo(skb)->gso_size) != 0) {
3900 int tcp_opt_len, ip_tcp_len; 3915 int tcp_opt_len, ip_tcp_len;
3901 3916
3902 if (skb_header_cloned(skb) && 3917 if (skb_header_cloned(skb) &&
@@ -4053,8 +4068,7 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
4053 if (skb->ip_summed == CHECKSUM_PARTIAL) 4068 if (skb->ip_summed == CHECKSUM_PARTIAL)
4054 base_flags |= TXD_FLAG_TCPUDP_CSUM; 4069 base_flags |= TXD_FLAG_TCPUDP_CSUM;
4055 mss = 0; 4070 mss = 0;
4056 if (skb->len > (tp->dev->mtu + ETH_HLEN) && 4071 if ((mss = skb_shinfo(skb)->gso_size) != 0) {
4057 (mss = skb_shinfo(skb)->gso_size) != 0) {
4058 struct iphdr *iph; 4072 struct iphdr *iph;
4059 int tcp_opt_len, ip_tcp_len, hdr_len; 4073 int tcp_opt_len, ip_tcp_len, hdr_len;
4060 4074
@@ -5934,7 +5948,7 @@ static int tg3_load_tso_firmware(struct tg3 *tp)
5934 5948
5935 5949
5936/* tp->lock is held. */ 5950/* tp->lock is held. */
5937static void __tg3_set_mac_addr(struct tg3 *tp) 5951static void __tg3_set_mac_addr(struct tg3 *tp, int skip_mac_1)
5938{ 5952{
5939 u32 addr_high, addr_low; 5953 u32 addr_high, addr_low;
5940 int i; 5954 int i;
@@ -5946,6 +5960,8 @@ static void __tg3_set_mac_addr(struct tg3 *tp)
5946 (tp->dev->dev_addr[4] << 8) | 5960 (tp->dev->dev_addr[4] << 8) |
5947 (tp->dev->dev_addr[5] << 0)); 5961 (tp->dev->dev_addr[5] << 0));
5948 for (i = 0; i < 4; i++) { 5962 for (i = 0; i < 4; i++) {
5963 if (i == 1 && skip_mac_1)
5964 continue;
5949 tw32(MAC_ADDR_0_HIGH + (i * 8), addr_high); 5965 tw32(MAC_ADDR_0_HIGH + (i * 8), addr_high);
5950 tw32(MAC_ADDR_0_LOW + (i * 8), addr_low); 5966 tw32(MAC_ADDR_0_LOW + (i * 8), addr_low);
5951 } 5967 }
@@ -5972,7 +5988,7 @@ static int tg3_set_mac_addr(struct net_device *dev, void *p)
5972{ 5988{
5973 struct tg3 *tp = netdev_priv(dev); 5989 struct tg3 *tp = netdev_priv(dev);
5974 struct sockaddr *addr = p; 5990 struct sockaddr *addr = p;
5975 int err = 0; 5991 int err = 0, skip_mac_1 = 0;
5976 5992
5977 if (!is_valid_ether_addr(addr->sa_data)) 5993 if (!is_valid_ether_addr(addr->sa_data))
5978 return -EINVAL; 5994 return -EINVAL;
@@ -5983,22 +5999,21 @@ static int tg3_set_mac_addr(struct net_device *dev, void *p)
5983 return 0; 5999 return 0;
5984 6000
5985 if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) { 6001 if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) {
5986 /* Reset chip so that ASF can re-init any MAC addresses it 6002 u32 addr0_high, addr0_low, addr1_high, addr1_low;
5987 * needs.
5988 */
5989 tg3_netif_stop(tp);
5990 tg3_full_lock(tp, 1);
5991 6003
5992 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 6004 addr0_high = tr32(MAC_ADDR_0_HIGH);
5993 err = tg3_restart_hw(tp, 0); 6005 addr0_low = tr32(MAC_ADDR_0_LOW);
5994 if (!err) 6006 addr1_high = tr32(MAC_ADDR_1_HIGH);
5995 tg3_netif_start(tp); 6007 addr1_low = tr32(MAC_ADDR_1_LOW);
5996 tg3_full_unlock(tp); 6008
5997 } else { 6009 /* Skip MAC addr 1 if ASF is using it. */
5998 spin_lock_bh(&tp->lock); 6010 if ((addr0_high != addr1_high || addr0_low != addr1_low) &&
5999 __tg3_set_mac_addr(tp); 6011 !(addr1_high == 0 && addr1_low == 0))
6000 spin_unlock_bh(&tp->lock); 6012 skip_mac_1 = 1;
6001 } 6013 }
6014 spin_lock_bh(&tp->lock);
6015 __tg3_set_mac_addr(tp, skip_mac_1);
6016 spin_unlock_bh(&tp->lock);
6002 6017
6003 return err; 6018 return err;
6004} 6019}
@@ -6315,7 +6330,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6315 tp->rx_jumbo_ptr); 6330 tp->rx_jumbo_ptr);
6316 6331
6317 /* Initialize MAC address and backoff seed. */ 6332 /* Initialize MAC address and backoff seed. */
6318 __tg3_set_mac_addr(tp); 6333 __tg3_set_mac_addr(tp, 0);
6319 6334
6320 /* MTU + ethernet header + FCS + optional VLAN tag */ 6335 /* MTU + ethernet header + FCS + optional VLAN tag */
6321 tw32(MAC_RX_MTU_SIZE, tp->dev->mtu + ETH_HLEN + 8); 6336 tw32(MAC_RX_MTU_SIZE, tp->dev->mtu + ETH_HLEN + 8);
@@ -6346,8 +6361,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6346 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) || 6361 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) ||
6347 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) { 6362 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) {
6348 if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE && 6363 if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE &&
6349 (tp->pci_chip_rev_id == CHIPREV_ID_5705_A1 || 6364 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
6350 tp->pci_chip_rev_id == CHIPREV_ID_5705_A2)) {
6351 rdmac_mode |= RDMAC_MODE_FIFO_SIZE_128; 6365 rdmac_mode |= RDMAC_MODE_FIFO_SIZE_128;
6352 } else if (!(tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) && 6366 } else if (!(tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) &&
6353 !(tp->tg3_flags2 & TG3_FLG2_IS_5788)) { 6367 !(tp->tg3_flags2 & TG3_FLG2_IS_5788)) {
@@ -6457,6 +6471,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6457 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) 6471 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
6458 gpio_mask |= GRC_LCLCTRL_GPIO_UART_SEL; 6472 gpio_mask |= GRC_LCLCTRL_GPIO_UART_SEL;
6459 6473
6474 tp->grc_local_ctrl &= ~gpio_mask;
6460 tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask; 6475 tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask;
6461 6476
6462 /* GPIO1 must be driven high for eeprom write protect */ 6477 /* GPIO1 must be driven high for eeprom write protect */
@@ -7036,11 +7051,7 @@ static int tg3_open(struct net_device *dev)
7036 if (err) 7051 if (err)
7037 return err; 7052 return err;
7038 7053
7039 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && 7054 if (tp->tg3_flags & TG3_FLAG_SUPPORT_MSI) {
7040 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_AX) &&
7041 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_BX) &&
7042 !((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) &&
7043 (tp->pdev_peer == tp->pdev))) {
7044 /* All MSI supporting chips should support tagged 7055 /* All MSI supporting chips should support tagged
7045 * status. Assert that this is the case. 7056 * status. Assert that this is the case.
7046 */ 7057 */
@@ -7399,9 +7410,7 @@ static int tg3_close(struct net_device *dev)
7399 7410
7400 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 7411 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
7401 tg3_free_rings(tp); 7412 tg3_free_rings(tp);
7402 tp->tg3_flags &= 7413 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;
7403 ~(TG3_FLAG_INIT_COMPLETE |
7404 TG3_FLAG_GOT_SERDES_FLOWCTL);
7405 7414
7406 tg3_full_unlock(tp); 7415 tg3_full_unlock(tp);
7407 7416
@@ -8036,7 +8045,10 @@ static void tg3_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
8036{ 8045{
8037 struct tg3 *tp = netdev_priv(dev); 8046 struct tg3 *tp = netdev_priv(dev);
8038 8047
8039 wol->supported = WAKE_MAGIC; 8048 if (tp->tg3_flags & TG3_FLAG_WOL_CAP)
8049 wol->supported = WAKE_MAGIC;
8050 else
8051 wol->supported = 0;
8040 wol->wolopts = 0; 8052 wol->wolopts = 0;
8041 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) 8053 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE)
8042 wol->wolopts = WAKE_MAGIC; 8054 wol->wolopts = WAKE_MAGIC;
@@ -8050,8 +8062,7 @@ static int tg3_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
8050 if (wol->wolopts & ~WAKE_MAGIC) 8062 if (wol->wolopts & ~WAKE_MAGIC)
8051 return -EINVAL; 8063 return -EINVAL;
8052 if ((wol->wolopts & WAKE_MAGIC) && 8064 if ((wol->wolopts & WAKE_MAGIC) &&
8053 tp->tg3_flags2 & TG3_FLG2_ANY_SERDES && 8065 !(tp->tg3_flags & TG3_FLAG_WOL_CAP))
8054 !(tp->tg3_flags & TG3_FLAG_SERDES_WOL_CAP))
8055 return -EINVAL; 8066 return -EINVAL;
8056 8067
8057 spin_lock_bh(&tp->lock); 8068 spin_lock_bh(&tp->lock);
@@ -9289,7 +9300,7 @@ static void __devinit tg3_get_nvram_size(struct tg3 *tp)
9289 return; 9300 return;
9290 } 9301 }
9291 } 9302 }
9292 tp->nvram_size = 0x20000; 9303 tp->nvram_size = 0x80000;
9293} 9304}
9294 9305
9295static void __devinit tg3_get_nvram_info(struct tg3 *tp) 9306static void __devinit tg3_get_nvram_info(struct tg3 *tp)
@@ -9408,33 +9419,31 @@ static void __devinit tg3_get_5752_nvram_info(struct tg3 *tp)
9408 9419
9409static void __devinit tg3_get_5755_nvram_info(struct tg3 *tp) 9420static void __devinit tg3_get_5755_nvram_info(struct tg3 *tp)
9410{ 9421{
9411 u32 nvcfg1; 9422 u32 nvcfg1, protect = 0;
9412 9423
9413 nvcfg1 = tr32(NVRAM_CFG1); 9424 nvcfg1 = tr32(NVRAM_CFG1);
9414 9425
9415 /* NVRAM protection for TPM */ 9426 /* NVRAM protection for TPM */
9416 if (nvcfg1 & (1 << 27)) 9427 if (nvcfg1 & (1 << 27)) {
9417 tp->tg3_flags2 |= TG3_FLG2_PROTECTED_NVRAM; 9428 tp->tg3_flags2 |= TG3_FLG2_PROTECTED_NVRAM;
9429 protect = 1;
9430 }
9418 9431
9419 switch (nvcfg1 & NVRAM_CFG1_5752VENDOR_MASK) { 9432 nvcfg1 &= NVRAM_CFG1_5752VENDOR_MASK;
9420 case FLASH_5755VENDOR_ATMEL_EEPROM_64KHZ: 9433 switch (nvcfg1) {
9421 case FLASH_5755VENDOR_ATMEL_EEPROM_376KHZ:
9422 tp->nvram_jedecnum = JEDEC_ATMEL;
9423 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
9424 tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE;
9425
9426 nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS;
9427 tw32(NVRAM_CFG1, nvcfg1);
9428 break;
9429 case FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED:
9430 case FLASH_5755VENDOR_ATMEL_FLASH_1: 9434 case FLASH_5755VENDOR_ATMEL_FLASH_1:
9431 case FLASH_5755VENDOR_ATMEL_FLASH_2: 9435 case FLASH_5755VENDOR_ATMEL_FLASH_2:
9432 case FLASH_5755VENDOR_ATMEL_FLASH_3: 9436 case FLASH_5755VENDOR_ATMEL_FLASH_3:
9433 case FLASH_5755VENDOR_ATMEL_FLASH_4:
9434 tp->nvram_jedecnum = JEDEC_ATMEL; 9437 tp->nvram_jedecnum = JEDEC_ATMEL;
9435 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; 9438 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
9436 tp->tg3_flags2 |= TG3_FLG2_FLASH; 9439 tp->tg3_flags2 |= TG3_FLG2_FLASH;
9437 tp->nvram_pagesize = 264; 9440 tp->nvram_pagesize = 264;
9441 if (nvcfg1 == FLASH_5755VENDOR_ATMEL_FLASH_1)
9442 tp->nvram_size = (protect ? 0x3e200 : 0x80000);
9443 else if (nvcfg1 == FLASH_5755VENDOR_ATMEL_FLASH_2)
9444 tp->nvram_size = (protect ? 0x1f200 : 0x40000);
9445 else
9446 tp->nvram_size = (protect ? 0x1f200 : 0x20000);
9438 break; 9447 break;
9439 case FLASH_5752VENDOR_ST_M45PE10: 9448 case FLASH_5752VENDOR_ST_M45PE10:
9440 case FLASH_5752VENDOR_ST_M45PE20: 9449 case FLASH_5752VENDOR_ST_M45PE20:
@@ -9443,6 +9452,12 @@ static void __devinit tg3_get_5755_nvram_info(struct tg3 *tp)
9443 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; 9452 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
9444 tp->tg3_flags2 |= TG3_FLG2_FLASH; 9453 tp->tg3_flags2 |= TG3_FLG2_FLASH;
9445 tp->nvram_pagesize = 256; 9454 tp->nvram_pagesize = 256;
9455 if (nvcfg1 == FLASH_5752VENDOR_ST_M45PE10)
9456 tp->nvram_size = (protect ? 0x10000 : 0x20000);
9457 else if (nvcfg1 == FLASH_5752VENDOR_ST_M45PE20)
9458 tp->nvram_size = (protect ? 0x10000 : 0x40000);
9459 else
9460 tp->nvram_size = (protect ? 0x20000 : 0x80000);
9446 break; 9461 break;
9447 } 9462 }
9448} 9463}
@@ -9518,6 +9533,8 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
9518 } 9533 }
9519 tg3_enable_nvram_access(tp); 9534 tg3_enable_nvram_access(tp);
9520 9535
9536 tp->nvram_size = 0;
9537
9521 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) 9538 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
9522 tg3_get_5752_nvram_info(tp); 9539 tg3_get_5752_nvram_info(tp);
9523 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) 9540 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
@@ -9529,7 +9546,8 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
9529 else 9546 else
9530 tg3_get_nvram_info(tp); 9547 tg3_get_nvram_info(tp);
9531 9548
9532 tg3_get_nvram_size(tp); 9549 if (tp->nvram_size == 0)
9550 tg3_get_nvram_size(tp);
9533 9551
9534 tg3_disable_nvram_access(tp); 9552 tg3_disable_nvram_access(tp);
9535 tg3_nvram_unlock(tp); 9553 tg3_nvram_unlock(tp);
@@ -9996,14 +10014,16 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
9996 tp->phy_id = PHY_ID_INVALID; 10014 tp->phy_id = PHY_ID_INVALID;
9997 tp->led_ctrl = LED_CTRL_MODE_PHY_1; 10015 tp->led_ctrl = LED_CTRL_MODE_PHY_1;
9998 10016
9999 /* Assume an onboard device by default. */ 10017 /* Assume an onboard device and WOL capable by default. */
10000 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT; 10018 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT | TG3_FLAG_WOL_CAP;
10001 10019
10002 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { 10020 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
10003 if (!(tr32(PCIE_TRANSACTION_CFG) & PCIE_TRANS_CFG_LOM)) { 10021 if (!(tr32(PCIE_TRANSACTION_CFG) & PCIE_TRANS_CFG_LOM)) {
10004 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT; 10022 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT;
10005 tp->tg3_flags2 |= TG3_FLG2_IS_NIC; 10023 tp->tg3_flags2 |= TG3_FLG2_IS_NIC;
10006 } 10024 }
10025 if (tr32(VCPU_CFGSHDW) & VCPU_CFGSHDW_ASPM_DBNC)
10026 tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND;
10007 return; 10027 return;
10008 } 10028 }
10009 10029
@@ -10120,8 +10140,9 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
10120 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) 10140 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
10121 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE; 10141 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE;
10122 } 10142 }
10123 if (nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL) 10143 if (tp->tg3_flags2 & TG3_FLG2_ANY_SERDES &&
10124 tp->tg3_flags |= TG3_FLAG_SERDES_WOL_CAP; 10144 !(nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL))
10145 tp->tg3_flags &= ~TG3_FLAG_WOL_CAP;
10125 10146
10126 if (cfg2 & (1 << 17)) 10147 if (cfg2 & (1 << 17))
10127 tp->tg3_flags2 |= TG3_FLG2_CAPACITIVE_COUPLING; 10148 tp->tg3_flags2 |= TG3_FLG2_CAPACITIVE_COUPLING;
@@ -10130,6 +10151,14 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
10130 /* bootcode if bit 18 is set */ 10151 /* bootcode if bit 18 is set */
10131 if (cfg2 & (1 << 18)) 10152 if (cfg2 & (1 << 18))
10132 tp->tg3_flags2 |= TG3_FLG2_SERDES_PREEMPHASIS; 10153 tp->tg3_flags2 |= TG3_FLG2_SERDES_PREEMPHASIS;
10154
10155 if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {
10156 u32 cfg3;
10157
10158 tg3_read_mem(tp, NIC_SRAM_DATA_CFG_3, &cfg3);
10159 if (cfg3 & NIC_SRAM_ASPM_DEBOUNCE)
10160 tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND;
10161 }
10133 } 10162 }
10134} 10163}
10135 10164
@@ -10399,6 +10428,8 @@ static void __devinit tg3_read_fw_ver(struct tg3 *tp)
10399 } 10428 }
10400} 10429}
10401 10430
10431static struct pci_dev * __devinit tg3_find_peer(struct tg3 *);
10432
10402static int __devinit tg3_get_invariants(struct tg3 *tp) 10433static int __devinit tg3_get_invariants(struct tg3 *tp)
10403{ 10434{
10404 static struct pci_device_id write_reorder_chipsets[] = { 10435 static struct pci_device_id write_reorder_chipsets[] = {
@@ -10554,6 +10585,10 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10554 tp->pci_hdr_type = (cacheline_sz_reg >> 16) & 0xff; 10585 tp->pci_hdr_type = (cacheline_sz_reg >> 16) & 0xff;
10555 tp->pci_bist = (cacheline_sz_reg >> 24) & 0xff; 10586 tp->pci_bist = (cacheline_sz_reg >> 24) & 0xff;
10556 10587
10588 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
10589 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714))
10590 tp->pdev_peer = tg3_find_peer(tp);
10591
10557 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 || 10592 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 ||
10558 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || 10593 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 ||
10559 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || 10594 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
@@ -10567,6 +10602,14 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10567 tp->tg3_flags2 |= TG3_FLG2_5705_PLUS; 10602 tp->tg3_flags2 |= TG3_FLG2_5705_PLUS;
10568 10603
10569 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) { 10604 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) {
10605 tp->tg3_flags |= TG3_FLAG_SUPPORT_MSI;
10606 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5750_AX ||
10607 GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5750_BX ||
10608 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714 &&
10609 tp->pci_chip_rev_id <= CHIPREV_ID_5714_A2 &&
10610 tp->pdev_peer == tp->pdev))
10611 tp->tg3_flags &= ~TG3_FLAG_SUPPORT_MSI;
10612
10570 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || 10613 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
10571 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 || 10614 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 ||
10572 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { 10615 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
@@ -10668,17 +10711,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10668 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5700_BX) 10711 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5700_BX)
10669 tp->tg3_flags |= TG3_FLAG_TXD_MBOX_HWBUG; 10712 tp->tg3_flags |= TG3_FLAG_TXD_MBOX_HWBUG;
10670 10713
10671 /* Back to back register writes can cause problems on this chip,
10672 * the workaround is to read back all reg writes except those to
10673 * mailbox regs. See tg3_write_indirect_reg32().
10674 *
10675 * PCI Express 5750_A0 rev chips need this workaround too.
10676 */
10677 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 ||
10678 ((tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) &&
10679 tp->pci_chip_rev_id == CHIPREV_ID_5750_A0))
10680 tp->tg3_flags |= TG3_FLAG_5701_REG_WRITE_BUG;
10681
10682 if ((pci_state_reg & PCISTATE_BUS_SPEED_HIGH) != 0) 10714 if ((pci_state_reg & PCISTATE_BUS_SPEED_HIGH) != 0)
10683 tp->tg3_flags |= TG3_FLAG_PCI_HIGH_SPEED; 10715 tp->tg3_flags |= TG3_FLAG_PCI_HIGH_SPEED;
10684 if ((pci_state_reg & PCISTATE_BUS_32BIT) != 0) 10716 if ((pci_state_reg & PCISTATE_BUS_32BIT) != 0)
@@ -10702,8 +10734,19 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10702 /* Various workaround register access methods */ 10734 /* Various workaround register access methods */
10703 if (tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) 10735 if (tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG)
10704 tp->write32 = tg3_write_indirect_reg32; 10736 tp->write32 = tg3_write_indirect_reg32;
10705 else if (tp->tg3_flags & TG3_FLAG_5701_REG_WRITE_BUG) 10737 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 ||
10738 ((tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) &&
10739 tp->pci_chip_rev_id == CHIPREV_ID_5750_A0)) {
10740 /*
10741 * Back to back register writes can cause problems on these
10742 * chips, the workaround is to read back all reg writes
10743 * except those to mailbox regs.
10744 *
10745 * See tg3_write_indirect_reg32().
10746 */
10706 tp->write32 = tg3_write_flush_reg32; 10747 tp->write32 = tg3_write_flush_reg32;
10748 }
10749
10707 10750
10708 if ((tp->tg3_flags & TG3_FLAG_TXD_MBOX_HWBUG) || 10751 if ((tp->tg3_flags & TG3_FLAG_TXD_MBOX_HWBUG) ||
10709 (tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)) { 10752 (tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)) {
@@ -10983,6 +11026,10 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10983 */ 11026 */
10984 tp->tg3_flags &= ~TG3_FLAG_WOL_ENABLE; 11027 tp->tg3_flags &= ~TG3_FLAG_WOL_ENABLE;
10985 11028
11029 if (tp->tg3_flags & TG3_FLAG_ASPM_WORKAROUND)
11030 tp->pwrmgmt_thresh = tr32(PCIE_PWR_MGMT_THRESH) &
11031 PCIE_PWR_MGMT_L1_THRESH_MSK;
11032
10986 return err; 11033 return err;
10987} 11034}
10988 11035
@@ -11892,10 +11939,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11892 tp->rx_pending = 63; 11939 tp->rx_pending = 63;
11893 } 11940 }
11894 11941
11895 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
11896 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714))
11897 tp->pdev_peer = tg3_find_peer(tp);
11898
11899 err = tg3_get_device_address(tp); 11942 err = tg3_get_device_address(tp);
11900 if (err) { 11943 if (err) {
11901 printk(KERN_ERR PFX "Could not obtain valid ethernet address, " 11944 printk(KERN_ERR PFX "Could not obtain valid ethernet address, "