diff options
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 648 |
1 files changed, 545 insertions, 103 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 6c6c5498899f..e03d1ae50c3e 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -69,8 +69,8 @@ | |||
69 | 69 | ||
70 | #define DRV_MODULE_NAME "tg3" | 70 | #define DRV_MODULE_NAME "tg3" |
71 | #define PFX DRV_MODULE_NAME ": " | 71 | #define PFX DRV_MODULE_NAME ": " |
72 | #define DRV_MODULE_VERSION "3.49" | 72 | #define DRV_MODULE_VERSION "3.52" |
73 | #define DRV_MODULE_RELDATE "Feb 2, 2006" | 73 | #define DRV_MODULE_RELDATE "Mar 06, 2006" |
74 | 74 | ||
75 | #define TG3_DEF_MAC_MODE 0 | 75 | #define TG3_DEF_MAC_MODE 0 |
76 | #define TG3_DEF_RX_MODE 0 | 76 | #define TG3_DEF_RX_MODE 0 |
@@ -221,10 +221,22 @@ static struct pci_device_id tg3_pci_tbl[] = { | |||
221 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | 221 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
222 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753F, | 222 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753F, |
223 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | 223 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
224 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5754, | ||
225 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
226 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5754M, | ||
227 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
228 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787, | ||
229 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
230 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M, | ||
231 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
224 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714, | 232 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714, |
225 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | 233 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
234 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714S, | ||
235 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
226 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5715, | 236 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5715, |
227 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | 237 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
238 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5715S, | ||
239 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
228 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5780, | 240 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5780, |
229 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | 241 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
230 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5780S, | 242 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5780S, |
@@ -534,6 +546,9 @@ static void tg3_enable_ints(struct tg3 *tp) | |||
534 | (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT)); | 546 | (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT)); |
535 | tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, | 547 | tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, |
536 | (tp->last_tag << 24)); | 548 | (tp->last_tag << 24)); |
549 | if (tp->tg3_flags2 & TG3_FLG2_1SHOT_MSI) | ||
550 | tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, | ||
551 | (tp->last_tag << 24)); | ||
537 | tg3_cond_int(tp); | 552 | tg3_cond_int(tp); |
538 | } | 553 | } |
539 | 554 | ||
@@ -1038,9 +1053,11 @@ static void tg3_frob_aux_power(struct tg3 *tp) | |||
1038 | struct net_device *dev_peer; | 1053 | struct net_device *dev_peer; |
1039 | 1054 | ||
1040 | dev_peer = pci_get_drvdata(tp->pdev_peer); | 1055 | dev_peer = pci_get_drvdata(tp->pdev_peer); |
1056 | /* remove_one() may have been run on the peer. */ | ||
1041 | if (!dev_peer) | 1057 | if (!dev_peer) |
1042 | BUG(); | 1058 | tp_peer = tp; |
1043 | tp_peer = netdev_priv(dev_peer); | 1059 | else |
1060 | tp_peer = netdev_priv(dev_peer); | ||
1044 | } | 1061 | } |
1045 | 1062 | ||
1046 | if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 || | 1063 | if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 || |
@@ -1131,7 +1148,7 @@ static int tg3_halt_cpu(struct tg3 *, u32); | |||
1131 | static int tg3_nvram_lock(struct tg3 *); | 1148 | static int tg3_nvram_lock(struct tg3 *); |
1132 | static void tg3_nvram_unlock(struct tg3 *); | 1149 | static void tg3_nvram_unlock(struct tg3 *); |
1133 | 1150 | ||
1134 | static int tg3_set_power_state(struct tg3 *tp, int state) | 1151 | static int tg3_set_power_state(struct tg3 *tp, pci_power_t state) |
1135 | { | 1152 | { |
1136 | u32 misc_host_ctrl; | 1153 | u32 misc_host_ctrl; |
1137 | u16 power_control, power_caps; | 1154 | u16 power_control, power_caps; |
@@ -1150,7 +1167,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state) | |||
1150 | power_control |= PCI_PM_CTRL_PME_STATUS; | 1167 | power_control |= PCI_PM_CTRL_PME_STATUS; |
1151 | power_control &= ~(PCI_PM_CTRL_STATE_MASK); | 1168 | power_control &= ~(PCI_PM_CTRL_STATE_MASK); |
1152 | switch (state) { | 1169 | switch (state) { |
1153 | case 0: | 1170 | case PCI_D0: |
1154 | power_control |= 0; | 1171 | power_control |= 0; |
1155 | pci_write_config_word(tp->pdev, | 1172 | pci_write_config_word(tp->pdev, |
1156 | pm + PCI_PM_CTRL, | 1173 | pm + PCI_PM_CTRL, |
@@ -1163,15 +1180,15 @@ static int tg3_set_power_state(struct tg3 *tp, int state) | |||
1163 | 1180 | ||
1164 | return 0; | 1181 | return 0; |
1165 | 1182 | ||
1166 | case 1: | 1183 | case PCI_D1: |
1167 | power_control |= 1; | 1184 | power_control |= 1; |
1168 | break; | 1185 | break; |
1169 | 1186 | ||
1170 | case 2: | 1187 | case PCI_D2: |
1171 | power_control |= 2; | 1188 | power_control |= 2; |
1172 | break; | 1189 | break; |
1173 | 1190 | ||
1174 | case 3: | 1191 | case PCI_D3hot: |
1175 | power_control |= 3; | 1192 | power_control |= 3; |
1176 | break; | 1193 | break; |
1177 | 1194 | ||
@@ -2680,6 +2697,12 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset) | |||
2680 | 2697 | ||
2681 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); | 2698 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); |
2682 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); | 2699 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); |
2700 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) { | ||
2701 | if (tr32(MAC_TX_STATUS) & TX_STATUS_LINK_UP) | ||
2702 | bmsr |= BMSR_LSTATUS; | ||
2703 | else | ||
2704 | bmsr &= ~BMSR_LSTATUS; | ||
2705 | } | ||
2683 | 2706 | ||
2684 | err |= tg3_readphy(tp, MII_BMCR, &bmcr); | 2707 | err |= tg3_readphy(tp, MII_BMCR, &bmcr); |
2685 | 2708 | ||
@@ -2748,6 +2771,13 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset) | |||
2748 | bmcr = new_bmcr; | 2771 | bmcr = new_bmcr; |
2749 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); | 2772 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); |
2750 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); | 2773 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); |
2774 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == | ||
2775 | ASIC_REV_5714) { | ||
2776 | if (tr32(MAC_TX_STATUS) & TX_STATUS_LINK_UP) | ||
2777 | bmsr |= BMSR_LSTATUS; | ||
2778 | else | ||
2779 | bmsr &= ~BMSR_LSTATUS; | ||
2780 | } | ||
2751 | tp->tg3_flags2 &= ~TG3_FLG2_PARALLEL_DETECT; | 2781 | tp->tg3_flags2 &= ~TG3_FLG2_PARALLEL_DETECT; |
2752 | } | 2782 | } |
2753 | } | 2783 | } |
@@ -3338,6 +3368,23 @@ static inline void tg3_full_unlock(struct tg3 *tp) | |||
3338 | spin_unlock_bh(&tp->lock); | 3368 | spin_unlock_bh(&tp->lock); |
3339 | } | 3369 | } |
3340 | 3370 | ||
3371 | /* One-shot MSI handler - Chip automatically disables interrupt | ||
3372 | * after sending MSI so driver doesn't have to do it. | ||
3373 | */ | ||
3374 | static irqreturn_t tg3_msi_1shot(int irq, void *dev_id, struct pt_regs *regs) | ||
3375 | { | ||
3376 | struct net_device *dev = dev_id; | ||
3377 | struct tg3 *tp = netdev_priv(dev); | ||
3378 | |||
3379 | prefetch(tp->hw_status); | ||
3380 | prefetch(&tp->rx_rcb[tp->rx_rcb_ptr]); | ||
3381 | |||
3382 | if (likely(!tg3_irq_sync(tp))) | ||
3383 | netif_rx_schedule(dev); /* schedule NAPI poll */ | ||
3384 | |||
3385 | return IRQ_HANDLED; | ||
3386 | } | ||
3387 | |||
3341 | /* MSI ISR - No need to check for interrupt sharing and no need to | 3388 | /* MSI ISR - No need to check for interrupt sharing and no need to |
3342 | * flush status block and interrupt mailbox. PCI ordering rules | 3389 | * flush status block and interrupt mailbox. PCI ordering rules |
3343 | * guarantee that MSI will arrive after the status block. | 3390 | * guarantee that MSI will arrive after the status block. |
@@ -3628,11 +3675,139 @@ static void tg3_set_txd(struct tg3 *tp, int entry, | |||
3628 | txd->vlan_tag = vlan_tag << TXD_VLAN_TAG_SHIFT; | 3675 | txd->vlan_tag = vlan_tag << TXD_VLAN_TAG_SHIFT; |
3629 | } | 3676 | } |
3630 | 3677 | ||
3678 | /* hard_start_xmit for devices that don't have any bugs and | ||
3679 | * support TG3_FLG2_HW_TSO_2 only. | ||
3680 | */ | ||
3631 | static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) | 3681 | static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) |
3632 | { | 3682 | { |
3633 | struct tg3 *tp = netdev_priv(dev); | 3683 | struct tg3 *tp = netdev_priv(dev); |
3634 | dma_addr_t mapping; | 3684 | dma_addr_t mapping; |
3635 | u32 len, entry, base_flags, mss; | 3685 | u32 len, entry, base_flags, mss; |
3686 | |||
3687 | len = skb_headlen(skb); | ||
3688 | |||
3689 | /* No BH disabling for tx_lock here. We are running in BH disabled | ||
3690 | * context and TX reclaim runs via tp->poll inside of a software | ||
3691 | * interrupt. Furthermore, IRQ processing runs lockless so we have | ||
3692 | * no IRQ context deadlocks to worry about either. Rejoice! | ||
3693 | */ | ||
3694 | if (!spin_trylock(&tp->tx_lock)) | ||
3695 | return NETDEV_TX_LOCKED; | ||
3696 | |||
3697 | if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) { | ||
3698 | if (!netif_queue_stopped(dev)) { | ||
3699 | netif_stop_queue(dev); | ||
3700 | |||
3701 | /* This is a hard error, log it. */ | ||
3702 | printk(KERN_ERR PFX "%s: BUG! Tx Ring full when " | ||
3703 | "queue awake!\n", dev->name); | ||
3704 | } | ||
3705 | spin_unlock(&tp->tx_lock); | ||
3706 | return NETDEV_TX_BUSY; | ||
3707 | } | ||
3708 | |||
3709 | entry = tp->tx_prod; | ||
3710 | base_flags = 0; | ||
3711 | #if TG3_TSO_SUPPORT != 0 | ||
3712 | mss = 0; | ||
3713 | if (skb->len > (tp->dev->mtu + ETH_HLEN) && | ||
3714 | (mss = skb_shinfo(skb)->tso_size) != 0) { | ||
3715 | int tcp_opt_len, ip_tcp_len; | ||
3716 | |||
3717 | if (skb_header_cloned(skb) && | ||
3718 | pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) { | ||
3719 | dev_kfree_skb(skb); | ||
3720 | goto out_unlock; | ||
3721 | } | ||
3722 | |||
3723 | tcp_opt_len = ((skb->h.th->doff - 5) * 4); | ||
3724 | ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr); | ||
3725 | |||
3726 | base_flags |= (TXD_FLAG_CPU_PRE_DMA | | ||
3727 | TXD_FLAG_CPU_POST_DMA); | ||
3728 | |||
3729 | skb->nh.iph->check = 0; | ||
3730 | skb->nh.iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len); | ||
3731 | |||
3732 | skb->h.th->check = 0; | ||
3733 | |||
3734 | mss |= (ip_tcp_len + tcp_opt_len) << 9; | ||
3735 | } | ||
3736 | else if (skb->ip_summed == CHECKSUM_HW) | ||
3737 | base_flags |= TXD_FLAG_TCPUDP_CSUM; | ||
3738 | #else | ||
3739 | mss = 0; | ||
3740 | if (skb->ip_summed == CHECKSUM_HW) | ||
3741 | base_flags |= TXD_FLAG_TCPUDP_CSUM; | ||
3742 | #endif | ||
3743 | #if TG3_VLAN_TAG_USED | ||
3744 | if (tp->vlgrp != NULL && vlan_tx_tag_present(skb)) | ||
3745 | base_flags |= (TXD_FLAG_VLAN | | ||
3746 | (vlan_tx_tag_get(skb) << 16)); | ||
3747 | #endif | ||
3748 | |||
3749 | /* Queue skb data, a.k.a. the main skb fragment. */ | ||
3750 | mapping = pci_map_single(tp->pdev, skb->data, len, PCI_DMA_TODEVICE); | ||
3751 | |||
3752 | tp->tx_buffers[entry].skb = skb; | ||
3753 | pci_unmap_addr_set(&tp->tx_buffers[entry], mapping, mapping); | ||
3754 | |||
3755 | tg3_set_txd(tp, entry, mapping, len, base_flags, | ||
3756 | (skb_shinfo(skb)->nr_frags == 0) | (mss << 1)); | ||
3757 | |||
3758 | entry = NEXT_TX(entry); | ||
3759 | |||
3760 | /* Now loop through additional data fragments, and queue them. */ | ||
3761 | if (skb_shinfo(skb)->nr_frags > 0) { | ||
3762 | unsigned int i, last; | ||
3763 | |||
3764 | last = skb_shinfo(skb)->nr_frags - 1; | ||
3765 | for (i = 0; i <= last; i++) { | ||
3766 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | ||
3767 | |||
3768 | len = frag->size; | ||
3769 | mapping = pci_map_page(tp->pdev, | ||
3770 | frag->page, | ||
3771 | frag->page_offset, | ||
3772 | len, PCI_DMA_TODEVICE); | ||
3773 | |||
3774 | tp->tx_buffers[entry].skb = NULL; | ||
3775 | pci_unmap_addr_set(&tp->tx_buffers[entry], mapping, mapping); | ||
3776 | |||
3777 | tg3_set_txd(tp, entry, mapping, len, | ||
3778 | base_flags, (i == last) | (mss << 1)); | ||
3779 | |||
3780 | entry = NEXT_TX(entry); | ||
3781 | } | ||
3782 | } | ||
3783 | |||
3784 | /* Packets are ready, update Tx producer idx local and on card. */ | ||
3785 | tw32_tx_mbox((MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW), entry); | ||
3786 | |||
3787 | tp->tx_prod = entry; | ||
3788 | if (TX_BUFFS_AVAIL(tp) <= (MAX_SKB_FRAGS + 1)) { | ||
3789 | netif_stop_queue(dev); | ||
3790 | if (TX_BUFFS_AVAIL(tp) > TG3_TX_WAKEUP_THRESH) | ||
3791 | netif_wake_queue(tp->dev); | ||
3792 | } | ||
3793 | |||
3794 | out_unlock: | ||
3795 | mmiowb(); | ||
3796 | spin_unlock(&tp->tx_lock); | ||
3797 | |||
3798 | dev->trans_start = jiffies; | ||
3799 | |||
3800 | return NETDEV_TX_OK; | ||
3801 | } | ||
3802 | |||
3803 | /* hard_start_xmit for devices that have the 4G bug and/or 40-bit bug and | ||
3804 | * support TG3_FLG2_HW_TSO_1 or firmware TSO only. | ||
3805 | */ | ||
3806 | static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev) | ||
3807 | { | ||
3808 | struct tg3 *tp = netdev_priv(dev); | ||
3809 | dma_addr_t mapping; | ||
3810 | u32 len, entry, base_flags, mss; | ||
3636 | int would_hit_hwbug; | 3811 | int would_hit_hwbug; |
3637 | 3812 | ||
3638 | len = skb_headlen(skb); | 3813 | len = skb_headlen(skb); |
@@ -4369,6 +4544,10 @@ static int tg3_chip_reset(struct tg3 *tp) | |||
4369 | tp->nvram_lock_cnt = 0; | 4544 | tp->nvram_lock_cnt = 0; |
4370 | } | 4545 | } |
4371 | 4546 | ||
4547 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || | ||
4548 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
4549 | tw32(GRC_FASTBOOT_PC, 0); | ||
4550 | |||
4372 | /* | 4551 | /* |
4373 | * We must avoid the readl() that normally takes place. | 4552 | * We must avoid the readl() that normally takes place. |
4374 | * It locks machines, causes machine checks, and other | 4553 | * It locks machines, causes machine checks, and other |
@@ -5518,6 +5697,9 @@ static int tg3_set_mac_addr(struct net_device *dev, void *p) | |||
5518 | 5697 | ||
5519 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); | 5698 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); |
5520 | 5699 | ||
5700 | if (!netif_running(dev)) | ||
5701 | return 0; | ||
5702 | |||
5521 | spin_lock_bh(&tp->lock); | 5703 | spin_lock_bh(&tp->lock); |
5522 | __tg3_set_mac_addr(tp); | 5704 | __tg3_set_mac_addr(tp); |
5523 | spin_unlock_bh(&tp->lock); | 5705 | spin_unlock_bh(&tp->lock); |
@@ -5585,6 +5767,9 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
5585 | tg3_abort_hw(tp, 1); | 5767 | tg3_abort_hw(tp, 1); |
5586 | } | 5768 | } |
5587 | 5769 | ||
5770 | if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) | ||
5771 | tg3_phy_reset(tp); | ||
5772 | |||
5588 | err = tg3_chip_reset(tp); | 5773 | err = tg3_chip_reset(tp); |
5589 | if (err) | 5774 | if (err) |
5590 | return err; | 5775 | return err; |
@@ -5993,6 +6178,10 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
5993 | } | 6178 | } |
5994 | } | 6179 | } |
5995 | 6180 | ||
6181 | /* Enable host coalescing bug fix */ | ||
6182 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
6183 | val |= (1 << 29); | ||
6184 | |||
5996 | tw32_f(WDMAC_MODE, val); | 6185 | tw32_f(WDMAC_MODE, val); |
5997 | udelay(40); | 6186 | udelay(40); |
5998 | 6187 | ||
@@ -6097,6 +6286,17 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
6097 | tp->tg3_flags2 |= TG3_FLG2_HW_AUTONEG; | 6286 | tp->tg3_flags2 |= TG3_FLG2_HW_AUTONEG; |
6098 | } | 6287 | } |
6099 | 6288 | ||
6289 | if ((tp->tg3_flags2 & TG3_FLG2_MII_SERDES) && | ||
6290 | (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714)) { | ||
6291 | u32 tmp; | ||
6292 | |||
6293 | tmp = tr32(SERDES_RX_CTRL); | ||
6294 | tw32(SERDES_RX_CTRL, tmp | SERDES_RX_SIG_DETECT); | ||
6295 | tp->grc_local_ctrl &= ~GRC_LCLCTRL_USE_EXT_SIG_DETECT; | ||
6296 | tp->grc_local_ctrl |= GRC_LCLCTRL_USE_SIG_DETECT; | ||
6297 | tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl); | ||
6298 | } | ||
6299 | |||
6100 | err = tg3_setup_phy(tp, 1); | 6300 | err = tg3_setup_phy(tp, 1); |
6101 | if (err) | 6301 | if (err) |
6102 | return err; | 6302 | return err; |
@@ -6175,7 +6375,7 @@ static int tg3_init_hw(struct tg3 *tp) | |||
6175 | int err; | 6375 | int err; |
6176 | 6376 | ||
6177 | /* Force the chip into D0. */ | 6377 | /* Force the chip into D0. */ |
6178 | err = tg3_set_power_state(tp, 0); | 6378 | err = tg3_set_power_state(tp, PCI_D0); |
6179 | if (err) | 6379 | if (err) |
6180 | goto out; | 6380 | goto out; |
6181 | 6381 | ||
@@ -6331,6 +6531,26 @@ static void tg3_timer(unsigned long __opaque) | |||
6331 | add_timer(&tp->timer); | 6531 | add_timer(&tp->timer); |
6332 | } | 6532 | } |
6333 | 6533 | ||
6534 | static int tg3_request_irq(struct tg3 *tp) | ||
6535 | { | ||
6536 | irqreturn_t (*fn)(int, void *, struct pt_regs *); | ||
6537 | unsigned long flags; | ||
6538 | struct net_device *dev = tp->dev; | ||
6539 | |||
6540 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { | ||
6541 | fn = tg3_msi; | ||
6542 | if (tp->tg3_flags2 & TG3_FLG2_1SHOT_MSI) | ||
6543 | fn = tg3_msi_1shot; | ||
6544 | flags = SA_SAMPLE_RANDOM; | ||
6545 | } else { | ||
6546 | fn = tg3_interrupt; | ||
6547 | if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) | ||
6548 | fn = tg3_interrupt_tagged; | ||
6549 | flags = SA_SHIRQ | SA_SAMPLE_RANDOM; | ||
6550 | } | ||
6551 | return (request_irq(tp->pdev->irq, fn, flags, dev->name, dev)); | ||
6552 | } | ||
6553 | |||
6334 | static int tg3_test_interrupt(struct tg3 *tp) | 6554 | static int tg3_test_interrupt(struct tg3 *tp) |
6335 | { | 6555 | { |
6336 | struct net_device *dev = tp->dev; | 6556 | struct net_device *dev = tp->dev; |
@@ -6367,16 +6587,7 @@ static int tg3_test_interrupt(struct tg3 *tp) | |||
6367 | 6587 | ||
6368 | free_irq(tp->pdev->irq, dev); | 6588 | free_irq(tp->pdev->irq, dev); |
6369 | 6589 | ||
6370 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) | 6590 | err = tg3_request_irq(tp); |
6371 | err = request_irq(tp->pdev->irq, tg3_msi, | ||
6372 | SA_SAMPLE_RANDOM, dev->name, dev); | ||
6373 | else { | ||
6374 | irqreturn_t (*fn)(int, void *, struct pt_regs *)=tg3_interrupt; | ||
6375 | if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) | ||
6376 | fn = tg3_interrupt_tagged; | ||
6377 | err = request_irq(tp->pdev->irq, fn, | ||
6378 | SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); | ||
6379 | } | ||
6380 | 6591 | ||
6381 | if (err) | 6592 | if (err) |
6382 | return err; | 6593 | return err; |
@@ -6428,14 +6639,7 @@ static int tg3_test_msi(struct tg3 *tp) | |||
6428 | 6639 | ||
6429 | tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; | 6640 | tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; |
6430 | 6641 | ||
6431 | { | 6642 | err = tg3_request_irq(tp); |
6432 | irqreturn_t (*fn)(int, void *, struct pt_regs *)=tg3_interrupt; | ||
6433 | if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) | ||
6434 | fn = tg3_interrupt_tagged; | ||
6435 | |||
6436 | err = request_irq(tp->pdev->irq, fn, | ||
6437 | SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); | ||
6438 | } | ||
6439 | if (err) | 6643 | if (err) |
6440 | return err; | 6644 | return err; |
6441 | 6645 | ||
@@ -6462,6 +6666,10 @@ static int tg3_open(struct net_device *dev) | |||
6462 | 6666 | ||
6463 | tg3_full_lock(tp, 0); | 6667 | tg3_full_lock(tp, 0); |
6464 | 6668 | ||
6669 | err = tg3_set_power_state(tp, PCI_D0); | ||
6670 | if (err) | ||
6671 | return err; | ||
6672 | |||
6465 | tg3_disable_ints(tp); | 6673 | tg3_disable_ints(tp); |
6466 | tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; | 6674 | tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; |
6467 | 6675 | ||
@@ -6476,7 +6684,9 @@ static int tg3_open(struct net_device *dev) | |||
6476 | 6684 | ||
6477 | if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && | 6685 | if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && |
6478 | (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_AX) && | 6686 | (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_AX) && |
6479 | (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_BX)) { | 6687 | (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_BX) && |
6688 | !((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) && | ||
6689 | (tp->pdev_peer == tp->pdev))) { | ||
6480 | /* All MSI supporting chips should support tagged | 6690 | /* All MSI supporting chips should support tagged |
6481 | * status. Assert that this is the case. | 6691 | * status. Assert that this is the case. |
6482 | */ | 6692 | */ |
@@ -6491,17 +6701,7 @@ static int tg3_open(struct net_device *dev) | |||
6491 | tp->tg3_flags2 |= TG3_FLG2_USING_MSI; | 6701 | tp->tg3_flags2 |= TG3_FLG2_USING_MSI; |
6492 | } | 6702 | } |
6493 | } | 6703 | } |
6494 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) | 6704 | err = tg3_request_irq(tp); |
6495 | err = request_irq(tp->pdev->irq, tg3_msi, | ||
6496 | SA_SAMPLE_RANDOM, dev->name, dev); | ||
6497 | else { | ||
6498 | irqreturn_t (*fn)(int, void *, struct pt_regs *)=tg3_interrupt; | ||
6499 | if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) | ||
6500 | fn = tg3_interrupt_tagged; | ||
6501 | |||
6502 | err = request_irq(tp->pdev->irq, fn, | ||
6503 | SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); | ||
6504 | } | ||
6505 | 6705 | ||
6506 | if (err) { | 6706 | if (err) { |
6507 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { | 6707 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { |
@@ -6566,6 +6766,14 @@ static int tg3_open(struct net_device *dev) | |||
6566 | 6766 | ||
6567 | return err; | 6767 | return err; |
6568 | } | 6768 | } |
6769 | |||
6770 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { | ||
6771 | if (tp->tg3_flags2 & TG3_FLG2_1SHOT_MSI) { | ||
6772 | u32 val = tr32(0x7c04); | ||
6773 | |||
6774 | tw32(0x7c04, val | (1 << 29)); | ||
6775 | } | ||
6776 | } | ||
6569 | } | 6777 | } |
6570 | 6778 | ||
6571 | tg3_full_lock(tp, 0); | 6779 | tg3_full_lock(tp, 0); |
@@ -6839,7 +7047,6 @@ static int tg3_close(struct net_device *dev) | |||
6839 | tp->tg3_flags &= | 7047 | tp->tg3_flags &= |
6840 | ~(TG3_FLAG_INIT_COMPLETE | | 7048 | ~(TG3_FLAG_INIT_COMPLETE | |
6841 | TG3_FLAG_GOT_SERDES_FLOWCTL); | 7049 | TG3_FLAG_GOT_SERDES_FLOWCTL); |
6842 | netif_carrier_off(tp->dev); | ||
6843 | 7050 | ||
6844 | tg3_full_unlock(tp); | 7051 | tg3_full_unlock(tp); |
6845 | 7052 | ||
@@ -6856,6 +7063,10 @@ static int tg3_close(struct net_device *dev) | |||
6856 | 7063 | ||
6857 | tg3_free_consistent(tp); | 7064 | tg3_free_consistent(tp); |
6858 | 7065 | ||
7066 | tg3_set_power_state(tp, PCI_D3hot); | ||
7067 | |||
7068 | netif_carrier_off(tp->dev); | ||
7069 | |||
6859 | return 0; | 7070 | return 0; |
6860 | } | 7071 | } |
6861 | 7072 | ||
@@ -7150,6 +7361,9 @@ static void tg3_set_rx_mode(struct net_device *dev) | |||
7150 | { | 7361 | { |
7151 | struct tg3 *tp = netdev_priv(dev); | 7362 | struct tg3 *tp = netdev_priv(dev); |
7152 | 7363 | ||
7364 | if (!netif_running(dev)) | ||
7365 | return; | ||
7366 | |||
7153 | tg3_full_lock(tp, 0); | 7367 | tg3_full_lock(tp, 0); |
7154 | __tg3_set_rx_mode(dev); | 7368 | __tg3_set_rx_mode(dev); |
7155 | tg3_full_unlock(tp); | 7369 | tg3_full_unlock(tp); |
@@ -7174,6 +7388,9 @@ static void tg3_get_regs(struct net_device *dev, | |||
7174 | 7388 | ||
7175 | memset(p, 0, TG3_REGDUMP_LEN); | 7389 | memset(p, 0, TG3_REGDUMP_LEN); |
7176 | 7390 | ||
7391 | if (tp->link_config.phy_is_low_power) | ||
7392 | return; | ||
7393 | |||
7177 | tg3_full_lock(tp, 0); | 7394 | tg3_full_lock(tp, 0); |
7178 | 7395 | ||
7179 | #define __GET_REG32(reg) (*(p)++ = tr32(reg)) | 7396 | #define __GET_REG32(reg) (*(p)++ = tr32(reg)) |
@@ -7240,6 +7457,7 @@ static int tg3_get_eeprom_len(struct net_device *dev) | |||
7240 | } | 7457 | } |
7241 | 7458 | ||
7242 | static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val); | 7459 | static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val); |
7460 | static int tg3_nvram_read_swab(struct tg3 *tp, u32 offset, u32 *val); | ||
7243 | 7461 | ||
7244 | static int tg3_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 *data) | 7462 | static int tg3_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 *data) |
7245 | { | 7463 | { |
@@ -7248,6 +7466,9 @@ static int tg3_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | |||
7248 | u8 *pd; | 7466 | u8 *pd; |
7249 | u32 i, offset, len, val, b_offset, b_count; | 7467 | u32 i, offset, len, val, b_offset, b_count; |
7250 | 7468 | ||
7469 | if (tp->link_config.phy_is_low_power) | ||
7470 | return -EAGAIN; | ||
7471 | |||
7251 | offset = eeprom->offset; | 7472 | offset = eeprom->offset; |
7252 | len = eeprom->len; | 7473 | len = eeprom->len; |
7253 | eeprom->len = 0; | 7474 | eeprom->len = 0; |
@@ -7309,6 +7530,9 @@ static int tg3_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | |||
7309 | u32 offset, len, b_offset, odd_len, start, end; | 7530 | u32 offset, len, b_offset, odd_len, start, end; |
7310 | u8 *buf; | 7531 | u8 *buf; |
7311 | 7532 | ||
7533 | if (tp->link_config.phy_is_low_power) | ||
7534 | return -EAGAIN; | ||
7535 | |||
7312 | if (eeprom->magic != TG3_EEPROM_MAGIC) | 7536 | if (eeprom->magic != TG3_EEPROM_MAGIC) |
7313 | return -EINVAL; | 7537 | return -EINVAL; |
7314 | 7538 | ||
@@ -7442,6 +7666,7 @@ static void tg3_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info | |||
7442 | 7666 | ||
7443 | strcpy(info->driver, DRV_MODULE_NAME); | 7667 | strcpy(info->driver, DRV_MODULE_NAME); |
7444 | strcpy(info->version, DRV_MODULE_VERSION); | 7668 | strcpy(info->version, DRV_MODULE_VERSION); |
7669 | strcpy(info->fw_version, tp->fw_ver); | ||
7445 | strcpy(info->bus_info, pci_name(tp->pdev)); | 7670 | strcpy(info->bus_info, pci_name(tp->pdev)); |
7446 | } | 7671 | } |
7447 | 7672 | ||
@@ -7536,11 +7761,20 @@ static void tg3_get_ringparam(struct net_device *dev, struct ethtool_ringparam * | |||
7536 | 7761 | ||
7537 | ering->rx_max_pending = TG3_RX_RING_SIZE - 1; | 7762 | ering->rx_max_pending = TG3_RX_RING_SIZE - 1; |
7538 | ering->rx_mini_max_pending = 0; | 7763 | ering->rx_mini_max_pending = 0; |
7539 | ering->rx_jumbo_max_pending = TG3_RX_JUMBO_RING_SIZE - 1; | 7764 | if (tp->tg3_flags & TG3_FLAG_JUMBO_RING_ENABLE) |
7765 | ering->rx_jumbo_max_pending = TG3_RX_JUMBO_RING_SIZE - 1; | ||
7766 | else | ||
7767 | ering->rx_jumbo_max_pending = 0; | ||
7768 | |||
7769 | ering->tx_max_pending = TG3_TX_RING_SIZE - 1; | ||
7540 | 7770 | ||
7541 | ering->rx_pending = tp->rx_pending; | 7771 | ering->rx_pending = tp->rx_pending; |
7542 | ering->rx_mini_pending = 0; | 7772 | ering->rx_mini_pending = 0; |
7543 | ering->rx_jumbo_pending = tp->rx_jumbo_pending; | 7773 | if (tp->tg3_flags & TG3_FLAG_JUMBO_RING_ENABLE) |
7774 | ering->rx_jumbo_pending = tp->rx_jumbo_pending; | ||
7775 | else | ||
7776 | ering->rx_jumbo_pending = 0; | ||
7777 | |||
7544 | ering->tx_pending = tp->tx_pending; | 7778 | ering->tx_pending = tp->tx_pending; |
7545 | } | 7779 | } |
7546 | 7780 | ||
@@ -7661,10 +7895,10 @@ static int tg3_set_tx_csum(struct net_device *dev, u32 data) | |||
7661 | return 0; | 7895 | return 0; |
7662 | } | 7896 | } |
7663 | 7897 | ||
7664 | if (data) | 7898 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) |
7665 | dev->features |= NETIF_F_IP_CSUM; | 7899 | ethtool_op_set_tx_hw_csum(dev, data); |
7666 | else | 7900 | else |
7667 | dev->features &= ~NETIF_F_IP_CSUM; | 7901 | ethtool_op_set_tx_csum(dev, data); |
7668 | 7902 | ||
7669 | return 0; | 7903 | return 0; |
7670 | } | 7904 | } |
@@ -7734,29 +7968,52 @@ static void tg3_get_ethtool_stats (struct net_device *dev, | |||
7734 | } | 7968 | } |
7735 | 7969 | ||
7736 | #define NVRAM_TEST_SIZE 0x100 | 7970 | #define NVRAM_TEST_SIZE 0x100 |
7971 | #define NVRAM_SELFBOOT_FORMAT1_SIZE 0x14 | ||
7737 | 7972 | ||
7738 | static int tg3_test_nvram(struct tg3 *tp) | 7973 | static int tg3_test_nvram(struct tg3 *tp) |
7739 | { | 7974 | { |
7740 | u32 *buf, csum; | 7975 | u32 *buf, csum, magic; |
7741 | int i, j, err = 0; | 7976 | int i, j, err = 0, size; |
7742 | 7977 | ||
7743 | buf = kmalloc(NVRAM_TEST_SIZE, GFP_KERNEL); | 7978 | if (tg3_nvram_read_swab(tp, 0, &magic) != 0) |
7979 | return -EIO; | ||
7980 | |||
7981 | if (magic == TG3_EEPROM_MAGIC) | ||
7982 | size = NVRAM_TEST_SIZE; | ||
7983 | else if ((magic & 0xff000000) == 0xa5000000) { | ||
7984 | if ((magic & 0xe00000) == 0x200000) | ||
7985 | size = NVRAM_SELFBOOT_FORMAT1_SIZE; | ||
7986 | else | ||
7987 | return 0; | ||
7988 | } else | ||
7989 | return -EIO; | ||
7990 | |||
7991 | buf = kmalloc(size, GFP_KERNEL); | ||
7744 | if (buf == NULL) | 7992 | if (buf == NULL) |
7745 | return -ENOMEM; | 7993 | return -ENOMEM; |
7746 | 7994 | ||
7747 | for (i = 0, j = 0; i < NVRAM_TEST_SIZE; i += 4, j++) { | 7995 | err = -EIO; |
7996 | for (i = 0, j = 0; i < size; i += 4, j++) { | ||
7748 | u32 val; | 7997 | u32 val; |
7749 | 7998 | ||
7750 | if ((err = tg3_nvram_read(tp, i, &val)) != 0) | 7999 | if ((err = tg3_nvram_read(tp, i, &val)) != 0) |
7751 | break; | 8000 | break; |
7752 | buf[j] = cpu_to_le32(val); | 8001 | buf[j] = cpu_to_le32(val); |
7753 | } | 8002 | } |
7754 | if (i < NVRAM_TEST_SIZE) | 8003 | if (i < size) |
7755 | goto out; | 8004 | goto out; |
7756 | 8005 | ||
7757 | err = -EIO; | 8006 | /* Selfboot format */ |
7758 | if (cpu_to_be32(buf[0]) != TG3_EEPROM_MAGIC) | 8007 | if (cpu_to_be32(buf[0]) != TG3_EEPROM_MAGIC) { |
7759 | goto out; | 8008 | u8 *buf8 = (u8 *) buf, csum8 = 0; |
8009 | |||
8010 | for (i = 0; i < size; i++) | ||
8011 | csum8 += buf8[i]; | ||
8012 | |||
8013 | if (csum8 == 0) | ||
8014 | return 0; | ||
8015 | return -EIO; | ||
8016 | } | ||
7760 | 8017 | ||
7761 | /* Bootstrap checksum at offset 0x10 */ | 8018 | /* Bootstrap checksum at offset 0x10 */ |
7762 | csum = calc_crc((unsigned char *) buf, 0x10); | 8019 | csum = calc_crc((unsigned char *) buf, 0x10); |
@@ -7802,7 +8059,7 @@ static int tg3_test_link(struct tg3 *tp) | |||
7802 | } | 8059 | } |
7803 | 8060 | ||
7804 | /* Only test the commonly used registers */ | 8061 | /* Only test the commonly used registers */ |
7805 | static const int tg3_test_registers(struct tg3 *tp) | 8062 | static int tg3_test_registers(struct tg3 *tp) |
7806 | { | 8063 | { |
7807 | int i, is_5705; | 8064 | int i, is_5705; |
7808 | u32 offset, read_mask, write_mask, val, save_val, read_val; | 8065 | u32 offset, read_mask, write_mask, val, save_val, read_val; |
@@ -8050,14 +8307,24 @@ static int tg3_test_memory(struct tg3 *tp) | |||
8050 | { 0x00008000, 0x02000}, | 8307 | { 0x00008000, 0x02000}, |
8051 | { 0x00010000, 0x0e000}, | 8308 | { 0x00010000, 0x0e000}, |
8052 | { 0xffffffff, 0x00000} | 8309 | { 0xffffffff, 0x00000} |
8310 | }, mem_tbl_5755[] = { | ||
8311 | { 0x00000200, 0x00008}, | ||
8312 | { 0x00004000, 0x00800}, | ||
8313 | { 0x00006000, 0x00800}, | ||
8314 | { 0x00008000, 0x02000}, | ||
8315 | { 0x00010000, 0x0c000}, | ||
8316 | { 0xffffffff, 0x00000} | ||
8053 | }; | 8317 | }; |
8054 | struct mem_entry *mem_tbl; | 8318 | struct mem_entry *mem_tbl; |
8055 | int err = 0; | 8319 | int err = 0; |
8056 | int i; | 8320 | int i; |
8057 | 8321 | ||
8058 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) | 8322 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { |
8059 | mem_tbl = mem_tbl_5705; | 8323 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) |
8060 | else | 8324 | mem_tbl = mem_tbl_5755; |
8325 | else | ||
8326 | mem_tbl = mem_tbl_5705; | ||
8327 | } else | ||
8061 | mem_tbl = mem_tbl_570x; | 8328 | mem_tbl = mem_tbl_570x; |
8062 | 8329 | ||
8063 | for (i = 0; mem_tbl[i].offset != 0xffffffff; i++) { | 8330 | for (i = 0; mem_tbl[i].offset != 0xffffffff; i++) { |
@@ -8229,6 +8496,9 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest, | |||
8229 | { | 8496 | { |
8230 | struct tg3 *tp = netdev_priv(dev); | 8497 | struct tg3 *tp = netdev_priv(dev); |
8231 | 8498 | ||
8499 | if (tp->link_config.phy_is_low_power) | ||
8500 | tg3_set_power_state(tp, PCI_D0); | ||
8501 | |||
8232 | memset(data, 0, sizeof(u64) * TG3_NUM_TEST); | 8502 | memset(data, 0, sizeof(u64) * TG3_NUM_TEST); |
8233 | 8503 | ||
8234 | if (tg3_test_nvram(tp) != 0) { | 8504 | if (tg3_test_nvram(tp) != 0) { |
@@ -8257,6 +8527,9 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest, | |||
8257 | if (!err) | 8527 | if (!err) |
8258 | tg3_nvram_unlock(tp); | 8528 | tg3_nvram_unlock(tp); |
8259 | 8529 | ||
8530 | if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) | ||
8531 | tg3_phy_reset(tp); | ||
8532 | |||
8260 | if (tg3_test_registers(tp) != 0) { | 8533 | if (tg3_test_registers(tp) != 0) { |
8261 | etest->flags |= ETH_TEST_FL_FAILED; | 8534 | etest->flags |= ETH_TEST_FL_FAILED; |
8262 | data[2] = 1; | 8535 | data[2] = 1; |
@@ -8286,6 +8559,9 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest, | |||
8286 | 8559 | ||
8287 | tg3_full_unlock(tp); | 8560 | tg3_full_unlock(tp); |
8288 | } | 8561 | } |
8562 | if (tp->link_config.phy_is_low_power) | ||
8563 | tg3_set_power_state(tp, PCI_D3hot); | ||
8564 | |||
8289 | } | 8565 | } |
8290 | 8566 | ||
8291 | static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | 8567 | static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
@@ -8305,6 +8581,9 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
8305 | if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) | 8581 | if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) |
8306 | break; /* We have no PHY */ | 8582 | break; /* We have no PHY */ |
8307 | 8583 | ||
8584 | if (tp->link_config.phy_is_low_power) | ||
8585 | return -EAGAIN; | ||
8586 | |||
8308 | spin_lock_bh(&tp->lock); | 8587 | spin_lock_bh(&tp->lock); |
8309 | err = tg3_readphy(tp, data->reg_num & 0x1f, &mii_regval); | 8588 | err = tg3_readphy(tp, data->reg_num & 0x1f, &mii_regval); |
8310 | spin_unlock_bh(&tp->lock); | 8589 | spin_unlock_bh(&tp->lock); |
@@ -8321,6 +8600,9 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
8321 | if (!capable(CAP_NET_ADMIN)) | 8600 | if (!capable(CAP_NET_ADMIN)) |
8322 | return -EPERM; | 8601 | return -EPERM; |
8323 | 8602 | ||
8603 | if (tp->link_config.phy_is_low_power) | ||
8604 | return -EAGAIN; | ||
8605 | |||
8324 | spin_lock_bh(&tp->lock); | 8606 | spin_lock_bh(&tp->lock); |
8325 | err = tg3_writephy(tp, data->reg_num & 0x1f, data->val_in); | 8607 | err = tg3_writephy(tp, data->reg_num & 0x1f, data->val_in); |
8326 | spin_unlock_bh(&tp->lock); | 8608 | spin_unlock_bh(&tp->lock); |
@@ -8464,14 +8746,14 @@ static struct ethtool_ops tg3_ethtool_ops = { | |||
8464 | 8746 | ||
8465 | static void __devinit tg3_get_eeprom_size(struct tg3 *tp) | 8747 | static void __devinit tg3_get_eeprom_size(struct tg3 *tp) |
8466 | { | 8748 | { |
8467 | u32 cursize, val; | 8749 | u32 cursize, val, magic; |
8468 | 8750 | ||
8469 | tp->nvram_size = EEPROM_CHIP_SIZE; | 8751 | tp->nvram_size = EEPROM_CHIP_SIZE; |
8470 | 8752 | ||
8471 | if (tg3_nvram_read(tp, 0, &val) != 0) | 8753 | if (tg3_nvram_read_swab(tp, 0, &magic) != 0) |
8472 | return; | 8754 | return; |
8473 | 8755 | ||
8474 | if (swab32(val) != TG3_EEPROM_MAGIC) | 8756 | if ((magic != TG3_EEPROM_MAGIC) && ((magic & 0xff000000) != 0xa5000000)) |
8475 | return; | 8757 | return; |
8476 | 8758 | ||
8477 | /* | 8759 | /* |
@@ -8479,13 +8761,13 @@ static void __devinit tg3_get_eeprom_size(struct tg3 *tp) | |||
8479 | * When we encounter our validation signature, we know the addressing | 8761 | * When we encounter our validation signature, we know the addressing |
8480 | * has wrapped around, and thus have our chip size. | 8762 | * has wrapped around, and thus have our chip size. |
8481 | */ | 8763 | */ |
8482 | cursize = 0x800; | 8764 | cursize = 0x10; |
8483 | 8765 | ||
8484 | while (cursize < tp->nvram_size) { | 8766 | while (cursize < tp->nvram_size) { |
8485 | if (tg3_nvram_read(tp, cursize, &val) != 0) | 8767 | if (tg3_nvram_read_swab(tp, cursize, &val) != 0) |
8486 | return; | 8768 | return; |
8487 | 8769 | ||
8488 | if (swab32(val) == TG3_EEPROM_MAGIC) | 8770 | if (val == magic) |
8489 | break; | 8771 | break; |
8490 | 8772 | ||
8491 | cursize <<= 1; | 8773 | cursize <<= 1; |
@@ -8498,6 +8780,15 @@ static void __devinit tg3_get_nvram_size(struct tg3 *tp) | |||
8498 | { | 8780 | { |
8499 | u32 val; | 8781 | u32 val; |
8500 | 8782 | ||
8783 | if (tg3_nvram_read_swab(tp, 0, &val) != 0) | ||
8784 | return; | ||
8785 | |||
8786 | /* Selfboot format */ | ||
8787 | if (val != TG3_EEPROM_MAGIC) { | ||
8788 | tg3_get_eeprom_size(tp); | ||
8789 | return; | ||
8790 | } | ||
8791 | |||
8501 | if (tg3_nvram_read(tp, 0xf0, &val) == 0) { | 8792 | if (tg3_nvram_read(tp, 0xf0, &val) == 0) { |
8502 | if (val != 0) { | 8793 | if (val != 0) { |
8503 | tp->nvram_size = (val >> 16) * 1024; | 8794 | tp->nvram_size = (val >> 16) * 1024; |
@@ -8621,6 +8912,44 @@ static void __devinit tg3_get_5752_nvram_info(struct tg3 *tp) | |||
8621 | } | 8912 | } |
8622 | } | 8913 | } |
8623 | 8914 | ||
8915 | static void __devinit tg3_get_5787_nvram_info(struct tg3 *tp) | ||
8916 | { | ||
8917 | u32 nvcfg1; | ||
8918 | |||
8919 | nvcfg1 = tr32(NVRAM_CFG1); | ||
8920 | |||
8921 | switch (nvcfg1 & NVRAM_CFG1_5752VENDOR_MASK) { | ||
8922 | case FLASH_5787VENDOR_ATMEL_EEPROM_64KHZ: | ||
8923 | case FLASH_5787VENDOR_ATMEL_EEPROM_376KHZ: | ||
8924 | case FLASH_5787VENDOR_MICRO_EEPROM_64KHZ: | ||
8925 | case FLASH_5787VENDOR_MICRO_EEPROM_376KHZ: | ||
8926 | tp->nvram_jedecnum = JEDEC_ATMEL; | ||
8927 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
8928 | tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE; | ||
8929 | |||
8930 | nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS; | ||
8931 | tw32(NVRAM_CFG1, nvcfg1); | ||
8932 | break; | ||
8933 | case FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED: | ||
8934 | case FLASH_5755VENDOR_ATMEL_FLASH_1: | ||
8935 | case FLASH_5755VENDOR_ATMEL_FLASH_2: | ||
8936 | case FLASH_5755VENDOR_ATMEL_FLASH_3: | ||
8937 | tp->nvram_jedecnum = JEDEC_ATMEL; | ||
8938 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
8939 | tp->tg3_flags2 |= TG3_FLG2_FLASH; | ||
8940 | tp->nvram_pagesize = 264; | ||
8941 | break; | ||
8942 | case FLASH_5752VENDOR_ST_M45PE10: | ||
8943 | case FLASH_5752VENDOR_ST_M45PE20: | ||
8944 | case FLASH_5752VENDOR_ST_M45PE40: | ||
8945 | tp->nvram_jedecnum = JEDEC_ST; | ||
8946 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
8947 | tp->tg3_flags2 |= TG3_FLG2_FLASH; | ||
8948 | tp->nvram_pagesize = 256; | ||
8949 | break; | ||
8950 | } | ||
8951 | } | ||
8952 | |||
8624 | /* Chips other than 5700/5701 use the NVRAM for fetching info. */ | 8953 | /* Chips other than 5700/5701 use the NVRAM for fetching info. */ |
8625 | static void __devinit tg3_nvram_init(struct tg3 *tp) | 8954 | static void __devinit tg3_nvram_init(struct tg3 *tp) |
8626 | { | 8955 | { |
@@ -8656,6 +8985,8 @@ static void __devinit tg3_nvram_init(struct tg3 *tp) | |||
8656 | 8985 | ||
8657 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) | 8986 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) |
8658 | tg3_get_5752_nvram_info(tp); | 8987 | tg3_get_5752_nvram_info(tp); |
8988 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
8989 | tg3_get_5787_nvram_info(tp); | ||
8659 | else | 8990 | else |
8660 | tg3_get_nvram_info(tp); | 8991 | tg3_get_nvram_info(tp); |
8661 | 8992 | ||
@@ -8725,6 +9056,34 @@ static int tg3_nvram_exec_cmd(struct tg3 *tp, u32 nvram_cmd) | |||
8725 | return 0; | 9056 | return 0; |
8726 | } | 9057 | } |
8727 | 9058 | ||
9059 | static u32 tg3_nvram_phys_addr(struct tg3 *tp, u32 addr) | ||
9060 | { | ||
9061 | if ((tp->tg3_flags & TG3_FLAG_NVRAM) && | ||
9062 | (tp->tg3_flags & TG3_FLAG_NVRAM_BUFFERED) && | ||
9063 | (tp->tg3_flags2 & TG3_FLG2_FLASH) && | ||
9064 | (tp->nvram_jedecnum == JEDEC_ATMEL)) | ||
9065 | |||
9066 | addr = ((addr / tp->nvram_pagesize) << | ||
9067 | ATMEL_AT45DB0X1B_PAGE_POS) + | ||
9068 | (addr % tp->nvram_pagesize); | ||
9069 | |||
9070 | return addr; | ||
9071 | } | ||
9072 | |||
9073 | static u32 tg3_nvram_logical_addr(struct tg3 *tp, u32 addr) | ||
9074 | { | ||
9075 | if ((tp->tg3_flags & TG3_FLAG_NVRAM) && | ||
9076 | (tp->tg3_flags & TG3_FLAG_NVRAM_BUFFERED) && | ||
9077 | (tp->tg3_flags2 & TG3_FLG2_FLASH) && | ||
9078 | (tp->nvram_jedecnum == JEDEC_ATMEL)) | ||
9079 | |||
9080 | addr = ((addr >> ATMEL_AT45DB0X1B_PAGE_POS) * | ||
9081 | tp->nvram_pagesize) + | ||
9082 | (addr & ((1 << ATMEL_AT45DB0X1B_PAGE_POS) - 1)); | ||
9083 | |||
9084 | return addr; | ||
9085 | } | ||
9086 | |||
8728 | static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val) | 9087 | static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val) |
8729 | { | 9088 | { |
8730 | int ret; | 9089 | int ret; |
@@ -8737,14 +9096,7 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val) | |||
8737 | if (!(tp->tg3_flags & TG3_FLAG_NVRAM)) | 9096 | if (!(tp->tg3_flags & TG3_FLAG_NVRAM)) |
8738 | return tg3_nvram_read_using_eeprom(tp, offset, val); | 9097 | return tg3_nvram_read_using_eeprom(tp, offset, val); |
8739 | 9098 | ||
8740 | if ((tp->tg3_flags & TG3_FLAG_NVRAM_BUFFERED) && | 9099 | offset = tg3_nvram_phys_addr(tp, offset); |
8741 | (tp->tg3_flags2 & TG3_FLG2_FLASH) && | ||
8742 | (tp->nvram_jedecnum == JEDEC_ATMEL)) { | ||
8743 | |||
8744 | offset = ((offset / tp->nvram_pagesize) << | ||
8745 | ATMEL_AT45DB0X1B_PAGE_POS) + | ||
8746 | (offset % tp->nvram_pagesize); | ||
8747 | } | ||
8748 | 9100 | ||
8749 | if (offset > NVRAM_ADDR_MSK) | 9101 | if (offset > NVRAM_ADDR_MSK) |
8750 | return -EINVAL; | 9102 | return -EINVAL; |
@@ -8769,6 +9121,16 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val) | |||
8769 | return ret; | 9121 | return ret; |
8770 | } | 9122 | } |
8771 | 9123 | ||
9124 | static int tg3_nvram_read_swab(struct tg3 *tp, u32 offset, u32 *val) | ||
9125 | { | ||
9126 | int err; | ||
9127 | u32 tmp; | ||
9128 | |||
9129 | err = tg3_nvram_read(tp, offset, &tmp); | ||
9130 | *val = swab32(tmp); | ||
9131 | return err; | ||
9132 | } | ||
9133 | |||
8772 | static int tg3_nvram_write_block_using_eeprom(struct tg3 *tp, | 9134 | static int tg3_nvram_write_block_using_eeprom(struct tg3 *tp, |
8773 | u32 offset, u32 len, u8 *buf) | 9135 | u32 offset, u32 len, u8 *buf) |
8774 | { | 9136 | { |
@@ -8921,15 +9283,7 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len, | |||
8921 | 9283 | ||
8922 | page_off = offset % tp->nvram_pagesize; | 9284 | page_off = offset % tp->nvram_pagesize; |
8923 | 9285 | ||
8924 | if ((tp->tg3_flags2 & TG3_FLG2_FLASH) && | 9286 | phy_addr = tg3_nvram_phys_addr(tp, offset); |
8925 | (tp->nvram_jedecnum == JEDEC_ATMEL)) { | ||
8926 | |||
8927 | phy_addr = ((offset / tp->nvram_pagesize) << | ||
8928 | ATMEL_AT45DB0X1B_PAGE_POS) + page_off; | ||
8929 | } | ||
8930 | else { | ||
8931 | phy_addr = offset; | ||
8932 | } | ||
8933 | 9287 | ||
8934 | tw32(NVRAM_ADDR, phy_addr); | 9288 | tw32(NVRAM_ADDR, phy_addr); |
8935 | 9289 | ||
@@ -8944,6 +9298,7 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len, | |||
8944 | nvram_cmd |= NVRAM_CMD_LAST; | 9298 | nvram_cmd |= NVRAM_CMD_LAST; |
8945 | 9299 | ||
8946 | if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752) && | 9300 | if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752) && |
9301 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) && | ||
8947 | (tp->nvram_jedecnum == JEDEC_ST) && | 9302 | (tp->nvram_jedecnum == JEDEC_ST) && |
8948 | (nvram_cmd & NVRAM_CMD_FIRST)) { | 9303 | (nvram_cmd & NVRAM_CMD_FIRST)) { |
8949 | 9304 | ||
@@ -9347,6 +9702,7 @@ static void __devinit tg3_read_partno(struct tg3 *tp) | |||
9347 | { | 9702 | { |
9348 | unsigned char vpd_data[256]; | 9703 | unsigned char vpd_data[256]; |
9349 | int i; | 9704 | int i; |
9705 | u32 magic; | ||
9350 | 9706 | ||
9351 | if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) { | 9707 | if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) { |
9352 | /* Sun decided not to put the necessary bits in the | 9708 | /* Sun decided not to put the necessary bits in the |
@@ -9356,16 +9712,43 @@ static void __devinit tg3_read_partno(struct tg3 *tp) | |||
9356 | return; | 9712 | return; |
9357 | } | 9713 | } |
9358 | 9714 | ||
9359 | for (i = 0; i < 256; i += 4) { | 9715 | if (tg3_nvram_read_swab(tp, 0x0, &magic)) |
9360 | u32 tmp; | 9716 | return; |
9361 | 9717 | ||
9362 | if (tg3_nvram_read(tp, 0x100 + i, &tmp)) | 9718 | if (magic == TG3_EEPROM_MAGIC) { |
9363 | goto out_not_found; | 9719 | for (i = 0; i < 256; i += 4) { |
9720 | u32 tmp; | ||
9721 | |||
9722 | if (tg3_nvram_read(tp, 0x100 + i, &tmp)) | ||
9723 | goto out_not_found; | ||
9364 | 9724 | ||
9365 | vpd_data[i + 0] = ((tmp >> 0) & 0xff); | 9725 | vpd_data[i + 0] = ((tmp >> 0) & 0xff); |
9366 | vpd_data[i + 1] = ((tmp >> 8) & 0xff); | 9726 | vpd_data[i + 1] = ((tmp >> 8) & 0xff); |
9367 | vpd_data[i + 2] = ((tmp >> 16) & 0xff); | 9727 | vpd_data[i + 2] = ((tmp >> 16) & 0xff); |
9368 | vpd_data[i + 3] = ((tmp >> 24) & 0xff); | 9728 | vpd_data[i + 3] = ((tmp >> 24) & 0xff); |
9729 | } | ||
9730 | } else { | ||
9731 | int vpd_cap; | ||
9732 | |||
9733 | vpd_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_VPD); | ||
9734 | for (i = 0; i < 256; i += 4) { | ||
9735 | u32 tmp, j = 0; | ||
9736 | u16 tmp16; | ||
9737 | |||
9738 | pci_write_config_word(tp->pdev, vpd_cap + PCI_VPD_ADDR, | ||
9739 | i); | ||
9740 | while (j++ < 100) { | ||
9741 | pci_read_config_word(tp->pdev, vpd_cap + | ||
9742 | PCI_VPD_ADDR, &tmp16); | ||
9743 | if (tmp16 & 0x8000) | ||
9744 | break; | ||
9745 | msleep(1); | ||
9746 | } | ||
9747 | pci_read_config_dword(tp->pdev, vpd_cap + PCI_VPD_DATA, | ||
9748 | &tmp); | ||
9749 | tmp = cpu_to_le32(tmp); | ||
9750 | memcpy(&vpd_data[i], &tmp, 4); | ||
9751 | } | ||
9369 | } | 9752 | } |
9370 | 9753 | ||
9371 | /* Now parse and find the part number. */ | 9754 | /* Now parse and find the part number. */ |
@@ -9412,6 +9795,46 @@ out_not_found: | |||
9412 | strcpy(tp->board_part_number, "none"); | 9795 | strcpy(tp->board_part_number, "none"); |
9413 | } | 9796 | } |
9414 | 9797 | ||
9798 | static void __devinit tg3_read_fw_ver(struct tg3 *tp) | ||
9799 | { | ||
9800 | u32 val, offset, start; | ||
9801 | |||
9802 | if (tg3_nvram_read_swab(tp, 0, &val)) | ||
9803 | return; | ||
9804 | |||
9805 | if (val != TG3_EEPROM_MAGIC) | ||
9806 | return; | ||
9807 | |||
9808 | if (tg3_nvram_read_swab(tp, 0xc, &offset) || | ||
9809 | tg3_nvram_read_swab(tp, 0x4, &start)) | ||
9810 | return; | ||
9811 | |||
9812 | offset = tg3_nvram_logical_addr(tp, offset); | ||
9813 | if (tg3_nvram_read_swab(tp, offset, &val)) | ||
9814 | return; | ||
9815 | |||
9816 | if ((val & 0xfc000000) == 0x0c000000) { | ||
9817 | u32 ver_offset, addr; | ||
9818 | int i; | ||
9819 | |||
9820 | if (tg3_nvram_read_swab(tp, offset + 4, &val) || | ||
9821 | tg3_nvram_read_swab(tp, offset + 8, &ver_offset)) | ||
9822 | return; | ||
9823 | |||
9824 | if (val != 0) | ||
9825 | return; | ||
9826 | |||
9827 | addr = offset + ver_offset - start; | ||
9828 | for (i = 0; i < 16; i += 4) { | ||
9829 | if (tg3_nvram_read(tp, addr + i, &val)) | ||
9830 | return; | ||
9831 | |||
9832 | val = cpu_to_le32(val); | ||
9833 | memcpy(tp->fw_ver + i, &val, 4); | ||
9834 | } | ||
9835 | } | ||
9836 | } | ||
9837 | |||
9415 | #ifdef CONFIG_SPARC64 | 9838 | #ifdef CONFIG_SPARC64 |
9416 | static int __devinit tg3_is_sun_570X(struct tg3 *tp) | 9839 | static int __devinit tg3_is_sun_570X(struct tg3 *tp) |
9417 | { | 9840 | { |
@@ -9603,6 +10026,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
9603 | 10026 | ||
9604 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 || | 10027 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 || |
9605 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || | 10028 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || |
10029 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 || | ||
9606 | (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) | 10030 | (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) |
9607 | tp->tg3_flags2 |= TG3_FLG2_5750_PLUS; | 10031 | tp->tg3_flags2 |= TG3_FLG2_5750_PLUS; |
9608 | 10032 | ||
@@ -9610,12 +10034,18 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
9610 | (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)) | 10034 | (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)) |
9611 | tp->tg3_flags2 |= TG3_FLG2_5705_PLUS; | 10035 | tp->tg3_flags2 |= TG3_FLG2_5705_PLUS; |
9612 | 10036 | ||
9613 | if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) | 10037 | if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) { |
9614 | tp->tg3_flags2 |= TG3_FLG2_HW_TSO; | 10038 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) { |
10039 | tp->tg3_flags2 |= TG3_FLG2_HW_TSO_2; | ||
10040 | tp->tg3_flags2 |= TG3_FLG2_1SHOT_MSI; | ||
10041 | } else | ||
10042 | tp->tg3_flags2 |= TG3_FLG2_HW_TSO_1; | ||
10043 | } | ||
9615 | 10044 | ||
9616 | if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && | 10045 | if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && |
9617 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750 && | 10046 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750 && |
9618 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752) | 10047 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752 && |
10048 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) | ||
9619 | tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE; | 10049 | tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE; |
9620 | 10050 | ||
9621 | if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0) | 10051 | if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0) |
@@ -9772,7 +10202,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
9772 | tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3; | 10202 | tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3; |
9773 | 10203 | ||
9774 | /* Force the chip into D0. */ | 10204 | /* Force the chip into D0. */ |
9775 | err = tg3_set_power_state(tp, 0); | 10205 | err = tg3_set_power_state(tp, PCI_D0); |
9776 | if (err) { | 10206 | if (err) { |
9777 | printk(KERN_ERR PFX "(%s) transition to D0 failed\n", | 10207 | printk(KERN_ERR PFX "(%s) transition to D0 failed\n", |
9778 | pci_name(tp->pdev)); | 10208 | pci_name(tp->pdev)); |
@@ -9825,7 +10255,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
9825 | if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0) | 10255 | if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0) |
9826 | tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG; | 10256 | tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG; |
9827 | 10257 | ||
9828 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) | 10258 | if ((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) && |
10259 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787)) | ||
9829 | tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; | 10260 | tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; |
9830 | 10261 | ||
9831 | tp->coalesce_mode = 0; | 10262 | tp->coalesce_mode = 0; |
@@ -9925,6 +10356,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
9925 | } | 10356 | } |
9926 | 10357 | ||
9927 | tg3_read_partno(tp); | 10358 | tg3_read_partno(tp); |
10359 | tg3_read_fw_ver(tp); | ||
9928 | 10360 | ||
9929 | if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) { | 10361 | if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) { |
9930 | tp->tg3_flags &= ~TG3_FLAG_USE_MI_INTERRUPT; | 10362 | tp->tg3_flags &= ~TG3_FLAG_USE_MI_INTERRUPT; |
@@ -9960,10 +10392,13 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
9960 | else | 10392 | else |
9961 | tp->tg3_flags &= ~TG3_FLAG_POLL_SERDES; | 10393 | tp->tg3_flags &= ~TG3_FLAG_POLL_SERDES; |
9962 | 10394 | ||
9963 | /* It seems all chips can get confused if TX buffers | 10395 | /* All chips before 5787 can get confused if TX buffers |
9964 | * straddle the 4GB address boundary in some cases. | 10396 | * straddle the 4GB address boundary in some cases. |
9965 | */ | 10397 | */ |
9966 | tp->dev->hard_start_xmit = tg3_start_xmit; | 10398 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) |
10399 | tp->dev->hard_start_xmit = tg3_start_xmit; | ||
10400 | else | ||
10401 | tp->dev->hard_start_xmit = tg3_start_xmit_dma_bug; | ||
9967 | 10402 | ||
9968 | tp->rx_offset = 2; | 10403 | tp->rx_offset = 2; |
9969 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 && | 10404 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 && |
@@ -10491,7 +10926,6 @@ static void __devinit tg3_init_link_config(struct tg3 *tp) | |||
10491 | tp->link_config.speed = SPEED_INVALID; | 10926 | tp->link_config.speed = SPEED_INVALID; |
10492 | tp->link_config.duplex = DUPLEX_INVALID; | 10927 | tp->link_config.duplex = DUPLEX_INVALID; |
10493 | tp->link_config.autoneg = AUTONEG_ENABLE; | 10928 | tp->link_config.autoneg = AUTONEG_ENABLE; |
10494 | netif_carrier_off(tp->dev); | ||
10495 | tp->link_config.active_speed = SPEED_INVALID; | 10929 | tp->link_config.active_speed = SPEED_INVALID; |
10496 | tp->link_config.active_duplex = DUPLEX_INVALID; | 10930 | tp->link_config.active_duplex = DUPLEX_INVALID; |
10497 | tp->link_config.phy_is_low_power = 0; | 10931 | tp->link_config.phy_is_low_power = 0; |
@@ -10550,6 +10984,7 @@ static char * __devinit tg3_phy_string(struct tg3 *tp) | |||
10550 | case PHY_ID_BCM5752: return "5752"; | 10984 | case PHY_ID_BCM5752: return "5752"; |
10551 | case PHY_ID_BCM5714: return "5714"; | 10985 | case PHY_ID_BCM5714: return "5714"; |
10552 | case PHY_ID_BCM5780: return "5780"; | 10986 | case PHY_ID_BCM5780: return "5780"; |
10987 | case PHY_ID_BCM5787: return "5787"; | ||
10553 | case PHY_ID_BCM8002: return "8002/serdes"; | 10988 | case PHY_ID_BCM8002: return "8002/serdes"; |
10554 | case 0: return "serdes"; | 10989 | case 0: return "serdes"; |
10555 | default: return "unknown"; | 10990 | default: return "unknown"; |
@@ -10848,11 +11283,12 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
10848 | tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE; | 11283 | tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE; |
10849 | } | 11284 | } |
10850 | 11285 | ||
10851 | /* TSO is off by default, user can enable using ethtool. */ | 11286 | /* TSO is on by default on chips that support hardware TSO. |
10852 | #if 0 | 11287 | * Firmware TSO on older chips gives lower performance, so it |
10853 | if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) | 11288 | * is off by default, but can be enabled using ethtool. |
11289 | */ | ||
11290 | if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) | ||
10854 | dev->features |= NETIF_F_TSO; | 11291 | dev->features |= NETIF_F_TSO; |
10855 | #endif | ||
10856 | 11292 | ||
10857 | #endif | 11293 | #endif |
10858 | 11294 | ||
@@ -10896,7 +11332,11 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
10896 | * checksumming. | 11332 | * checksumming. |
10897 | */ | 11333 | */ |
10898 | if ((tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) == 0) { | 11334 | if ((tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) == 0) { |
10899 | dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; | 11335 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) |
11336 | dev->features |= NETIF_F_HW_CSUM; | ||
11337 | else | ||
11338 | dev->features |= NETIF_F_IP_CSUM; | ||
11339 | dev->features |= NETIF_F_SG; | ||
10900 | tp->tg3_flags |= TG3_FLAG_RX_CHECKSUMS; | 11340 | tp->tg3_flags |= TG3_FLAG_RX_CHECKSUMS; |
10901 | } else | 11341 | } else |
10902 | tp->tg3_flags &= ~TG3_FLAG_RX_CHECKSUMS; | 11342 | tp->tg3_flags &= ~TG3_FLAG_RX_CHECKSUMS; |
@@ -10949,6 +11389,8 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
10949 | (pdev->dma_mask == DMA_32BIT_MASK) ? 32 : | 11389 | (pdev->dma_mask == DMA_32BIT_MASK) ? 32 : |
10950 | (((u64) pdev->dma_mask == DMA_40BIT_MASK) ? 40 : 64)); | 11390 | (((u64) pdev->dma_mask == DMA_40BIT_MASK) ? 40 : 64)); |
10951 | 11391 | ||
11392 | netif_carrier_off(tp->dev); | ||
11393 | |||
10952 | return 0; | 11394 | return 0; |
10953 | 11395 | ||
10954 | err_out_iounmap: | 11396 | err_out_iounmap: |
@@ -11044,7 +11486,7 @@ static int tg3_resume(struct pci_dev *pdev) | |||
11044 | 11486 | ||
11045 | pci_restore_state(tp->pdev); | 11487 | pci_restore_state(tp->pdev); |
11046 | 11488 | ||
11047 | err = tg3_set_power_state(tp, 0); | 11489 | err = tg3_set_power_state(tp, PCI_D0); |
11048 | if (err) | 11490 | if (err) |
11049 | return err; | 11491 | return err; |
11050 | 11492 | ||