diff options
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 744 |
1 files changed, 636 insertions, 108 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 6c6c5498899f..b5473325bff4 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.54" |
73 | #define DRV_MODULE_RELDATE "Feb 2, 2006" | 73 | #define DRV_MODULE_RELDATE "Mar 23, 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,26 @@ 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_5755, | ||
229 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
230 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5755M, | ||
231 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
232 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787, | ||
233 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
234 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M, | ||
235 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
224 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714, | 236 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714, |
225 | 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_5714S, | ||
239 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
226 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5715, | 240 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5715, |
227 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | 241 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
242 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5715S, | ||
243 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
228 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5780, | 244 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5780, |
229 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | 245 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
230 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5780S, | 246 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5780S, |
@@ -534,6 +550,9 @@ static void tg3_enable_ints(struct tg3 *tp) | |||
534 | (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT)); | 550 | (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT)); |
535 | tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, | 551 | tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, |
536 | (tp->last_tag << 24)); | 552 | (tp->last_tag << 24)); |
553 | if (tp->tg3_flags2 & TG3_FLG2_1SHOT_MSI) | ||
554 | tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, | ||
555 | (tp->last_tag << 24)); | ||
537 | tg3_cond_int(tp); | 556 | tg3_cond_int(tp); |
538 | } | 557 | } |
539 | 558 | ||
@@ -1038,9 +1057,11 @@ static void tg3_frob_aux_power(struct tg3 *tp) | |||
1038 | struct net_device *dev_peer; | 1057 | struct net_device *dev_peer; |
1039 | 1058 | ||
1040 | dev_peer = pci_get_drvdata(tp->pdev_peer); | 1059 | dev_peer = pci_get_drvdata(tp->pdev_peer); |
1060 | /* remove_one() may have been run on the peer. */ | ||
1041 | if (!dev_peer) | 1061 | if (!dev_peer) |
1042 | BUG(); | 1062 | tp_peer = tp; |
1043 | tp_peer = netdev_priv(dev_peer); | 1063 | else |
1064 | tp_peer = netdev_priv(dev_peer); | ||
1044 | } | 1065 | } |
1045 | 1066 | ||
1046 | if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 || | 1067 | if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 || |
@@ -1131,7 +1152,20 @@ static int tg3_halt_cpu(struct tg3 *, u32); | |||
1131 | static int tg3_nvram_lock(struct tg3 *); | 1152 | static int tg3_nvram_lock(struct tg3 *); |
1132 | static void tg3_nvram_unlock(struct tg3 *); | 1153 | static void tg3_nvram_unlock(struct tg3 *); |
1133 | 1154 | ||
1134 | static int tg3_set_power_state(struct tg3 *tp, int state) | 1155 | static void tg3_power_down_phy(struct tg3 *tp) |
1156 | { | ||
1157 | /* The PHY should not be powered down on some chips because | ||
1158 | * of bugs. | ||
1159 | */ | ||
1160 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 || | ||
1161 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 || | ||
1162 | (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780 && | ||
1163 | (tp->tg3_flags2 & TG3_FLG2_MII_SERDES))) | ||
1164 | return; | ||
1165 | tg3_writephy(tp, MII_BMCR, BMCR_PDOWN); | ||
1166 | } | ||
1167 | |||
1168 | static int tg3_set_power_state(struct tg3 *tp, pci_power_t state) | ||
1135 | { | 1169 | { |
1136 | u32 misc_host_ctrl; | 1170 | u32 misc_host_ctrl; |
1137 | u16 power_control, power_caps; | 1171 | u16 power_control, power_caps; |
@@ -1150,7 +1184,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state) | |||
1150 | power_control |= PCI_PM_CTRL_PME_STATUS; | 1184 | power_control |= PCI_PM_CTRL_PME_STATUS; |
1151 | power_control &= ~(PCI_PM_CTRL_STATE_MASK); | 1185 | power_control &= ~(PCI_PM_CTRL_STATE_MASK); |
1152 | switch (state) { | 1186 | switch (state) { |
1153 | case 0: | 1187 | case PCI_D0: |
1154 | power_control |= 0; | 1188 | power_control |= 0; |
1155 | pci_write_config_word(tp->pdev, | 1189 | pci_write_config_word(tp->pdev, |
1156 | pm + PCI_PM_CTRL, | 1190 | pm + PCI_PM_CTRL, |
@@ -1163,15 +1197,15 @@ static int tg3_set_power_state(struct tg3 *tp, int state) | |||
1163 | 1197 | ||
1164 | return 0; | 1198 | return 0; |
1165 | 1199 | ||
1166 | case 1: | 1200 | case PCI_D1: |
1167 | power_control |= 1; | 1201 | power_control |= 1; |
1168 | break; | 1202 | break; |
1169 | 1203 | ||
1170 | case 2: | 1204 | case PCI_D2: |
1171 | power_control |= 2; | 1205 | power_control |= 2; |
1172 | break; | 1206 | break; |
1173 | 1207 | ||
1174 | case 3: | 1208 | case PCI_D3hot: |
1175 | power_control |= 3; | 1209 | power_control |= 3; |
1176 | break; | 1210 | break; |
1177 | 1211 | ||
@@ -1310,8 +1344,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state) | |||
1310 | tg3_writephy(tp, MII_TG3_EXT_CTRL, | 1344 | tg3_writephy(tp, MII_TG3_EXT_CTRL, |
1311 | MII_TG3_EXT_CTRL_FORCE_LED_OFF); | 1345 | MII_TG3_EXT_CTRL_FORCE_LED_OFF); |
1312 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x01b2); | 1346 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x01b2); |
1313 | if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700) | 1347 | tg3_power_down_phy(tp); |
1314 | tg3_writephy(tp, MII_BMCR, BMCR_PDOWN); | ||
1315 | } | 1348 | } |
1316 | } | 1349 | } |
1317 | 1350 | ||
@@ -2680,6 +2713,12 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset) | |||
2680 | 2713 | ||
2681 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); | 2714 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); |
2682 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); | 2715 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); |
2716 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) { | ||
2717 | if (tr32(MAC_TX_STATUS) & TX_STATUS_LINK_UP) | ||
2718 | bmsr |= BMSR_LSTATUS; | ||
2719 | else | ||
2720 | bmsr &= ~BMSR_LSTATUS; | ||
2721 | } | ||
2683 | 2722 | ||
2684 | err |= tg3_readphy(tp, MII_BMCR, &bmcr); | 2723 | err |= tg3_readphy(tp, MII_BMCR, &bmcr); |
2685 | 2724 | ||
@@ -2748,6 +2787,13 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset) | |||
2748 | bmcr = new_bmcr; | 2787 | bmcr = new_bmcr; |
2749 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); | 2788 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); |
2750 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); | 2789 | err |= tg3_readphy(tp, MII_BMSR, &bmsr); |
2790 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == | ||
2791 | ASIC_REV_5714) { | ||
2792 | if (tr32(MAC_TX_STATUS) & TX_STATUS_LINK_UP) | ||
2793 | bmsr |= BMSR_LSTATUS; | ||
2794 | else | ||
2795 | bmsr &= ~BMSR_LSTATUS; | ||
2796 | } | ||
2751 | tp->tg3_flags2 &= ~TG3_FLG2_PARALLEL_DETECT; | 2797 | tp->tg3_flags2 &= ~TG3_FLG2_PARALLEL_DETECT; |
2752 | } | 2798 | } |
2753 | } | 2799 | } |
@@ -3338,6 +3384,23 @@ static inline void tg3_full_unlock(struct tg3 *tp) | |||
3338 | spin_unlock_bh(&tp->lock); | 3384 | spin_unlock_bh(&tp->lock); |
3339 | } | 3385 | } |
3340 | 3386 | ||
3387 | /* One-shot MSI handler - Chip automatically disables interrupt | ||
3388 | * after sending MSI so driver doesn't have to do it. | ||
3389 | */ | ||
3390 | static irqreturn_t tg3_msi_1shot(int irq, void *dev_id, struct pt_regs *regs) | ||
3391 | { | ||
3392 | struct net_device *dev = dev_id; | ||
3393 | struct tg3 *tp = netdev_priv(dev); | ||
3394 | |||
3395 | prefetch(tp->hw_status); | ||
3396 | prefetch(&tp->rx_rcb[tp->rx_rcb_ptr]); | ||
3397 | |||
3398 | if (likely(!tg3_irq_sync(tp))) | ||
3399 | netif_rx_schedule(dev); /* schedule NAPI poll */ | ||
3400 | |||
3401 | return IRQ_HANDLED; | ||
3402 | } | ||
3403 | |||
3341 | /* MSI ISR - No need to check for interrupt sharing and no need to | 3404 | /* MSI ISR - No need to check for interrupt sharing and no need to |
3342 | * flush status block and interrupt mailbox. PCI ordering rules | 3405 | * flush status block and interrupt mailbox. PCI ordering rules |
3343 | * guarantee that MSI will arrive after the status block. | 3406 | * guarantee that MSI will arrive after the status block. |
@@ -3628,11 +3691,139 @@ static void tg3_set_txd(struct tg3 *tp, int entry, | |||
3628 | txd->vlan_tag = vlan_tag << TXD_VLAN_TAG_SHIFT; | 3691 | txd->vlan_tag = vlan_tag << TXD_VLAN_TAG_SHIFT; |
3629 | } | 3692 | } |
3630 | 3693 | ||
3694 | /* hard_start_xmit for devices that don't have any bugs and | ||
3695 | * support TG3_FLG2_HW_TSO_2 only. | ||
3696 | */ | ||
3631 | static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) | 3697 | static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) |
3632 | { | 3698 | { |
3633 | struct tg3 *tp = netdev_priv(dev); | 3699 | struct tg3 *tp = netdev_priv(dev); |
3634 | dma_addr_t mapping; | 3700 | dma_addr_t mapping; |
3635 | u32 len, entry, base_flags, mss; | 3701 | u32 len, entry, base_flags, mss; |
3702 | |||
3703 | len = skb_headlen(skb); | ||
3704 | |||
3705 | /* No BH disabling for tx_lock here. We are running in BH disabled | ||
3706 | * context and TX reclaim runs via tp->poll inside of a software | ||
3707 | * interrupt. Furthermore, IRQ processing runs lockless so we have | ||
3708 | * no IRQ context deadlocks to worry about either. Rejoice! | ||
3709 | */ | ||
3710 | if (!spin_trylock(&tp->tx_lock)) | ||
3711 | return NETDEV_TX_LOCKED; | ||
3712 | |||
3713 | if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) { | ||
3714 | if (!netif_queue_stopped(dev)) { | ||
3715 | netif_stop_queue(dev); | ||
3716 | |||
3717 | /* This is a hard error, log it. */ | ||
3718 | printk(KERN_ERR PFX "%s: BUG! Tx Ring full when " | ||
3719 | "queue awake!\n", dev->name); | ||
3720 | } | ||
3721 | spin_unlock(&tp->tx_lock); | ||
3722 | return NETDEV_TX_BUSY; | ||
3723 | } | ||
3724 | |||
3725 | entry = tp->tx_prod; | ||
3726 | base_flags = 0; | ||
3727 | #if TG3_TSO_SUPPORT != 0 | ||
3728 | mss = 0; | ||
3729 | if (skb->len > (tp->dev->mtu + ETH_HLEN) && | ||
3730 | (mss = skb_shinfo(skb)->tso_size) != 0) { | ||
3731 | int tcp_opt_len, ip_tcp_len; | ||
3732 | |||
3733 | if (skb_header_cloned(skb) && | ||
3734 | pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) { | ||
3735 | dev_kfree_skb(skb); | ||
3736 | goto out_unlock; | ||
3737 | } | ||
3738 | |||
3739 | tcp_opt_len = ((skb->h.th->doff - 5) * 4); | ||
3740 | ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr); | ||
3741 | |||
3742 | base_flags |= (TXD_FLAG_CPU_PRE_DMA | | ||
3743 | TXD_FLAG_CPU_POST_DMA); | ||
3744 | |||
3745 | skb->nh.iph->check = 0; | ||
3746 | skb->nh.iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len); | ||
3747 | |||
3748 | skb->h.th->check = 0; | ||
3749 | |||
3750 | mss |= (ip_tcp_len + tcp_opt_len) << 9; | ||
3751 | } | ||
3752 | else if (skb->ip_summed == CHECKSUM_HW) | ||
3753 | base_flags |= TXD_FLAG_TCPUDP_CSUM; | ||
3754 | #else | ||
3755 | mss = 0; | ||
3756 | if (skb->ip_summed == CHECKSUM_HW) | ||
3757 | base_flags |= TXD_FLAG_TCPUDP_CSUM; | ||
3758 | #endif | ||
3759 | #if TG3_VLAN_TAG_USED | ||
3760 | if (tp->vlgrp != NULL && vlan_tx_tag_present(skb)) | ||
3761 | base_flags |= (TXD_FLAG_VLAN | | ||
3762 | (vlan_tx_tag_get(skb) << 16)); | ||
3763 | #endif | ||
3764 | |||
3765 | /* Queue skb data, a.k.a. the main skb fragment. */ | ||
3766 | mapping = pci_map_single(tp->pdev, skb->data, len, PCI_DMA_TODEVICE); | ||
3767 | |||
3768 | tp->tx_buffers[entry].skb = skb; | ||
3769 | pci_unmap_addr_set(&tp->tx_buffers[entry], mapping, mapping); | ||
3770 | |||
3771 | tg3_set_txd(tp, entry, mapping, len, base_flags, | ||
3772 | (skb_shinfo(skb)->nr_frags == 0) | (mss << 1)); | ||
3773 | |||
3774 | entry = NEXT_TX(entry); | ||
3775 | |||
3776 | /* Now loop through additional data fragments, and queue them. */ | ||
3777 | if (skb_shinfo(skb)->nr_frags > 0) { | ||
3778 | unsigned int i, last; | ||
3779 | |||
3780 | last = skb_shinfo(skb)->nr_frags - 1; | ||
3781 | for (i = 0; i <= last; i++) { | ||
3782 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | ||
3783 | |||
3784 | len = frag->size; | ||
3785 | mapping = pci_map_page(tp->pdev, | ||
3786 | frag->page, | ||
3787 | frag->page_offset, | ||
3788 | len, PCI_DMA_TODEVICE); | ||
3789 | |||
3790 | tp->tx_buffers[entry].skb = NULL; | ||
3791 | pci_unmap_addr_set(&tp->tx_buffers[entry], mapping, mapping); | ||
3792 | |||
3793 | tg3_set_txd(tp, entry, mapping, len, | ||
3794 | base_flags, (i == last) | (mss << 1)); | ||
3795 | |||
3796 | entry = NEXT_TX(entry); | ||
3797 | } | ||
3798 | } | ||
3799 | |||
3800 | /* Packets are ready, update Tx producer idx local and on card. */ | ||
3801 | tw32_tx_mbox((MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW), entry); | ||
3802 | |||
3803 | tp->tx_prod = entry; | ||
3804 | if (TX_BUFFS_AVAIL(tp) <= (MAX_SKB_FRAGS + 1)) { | ||
3805 | netif_stop_queue(dev); | ||
3806 | if (TX_BUFFS_AVAIL(tp) > TG3_TX_WAKEUP_THRESH) | ||
3807 | netif_wake_queue(tp->dev); | ||
3808 | } | ||
3809 | |||
3810 | out_unlock: | ||
3811 | mmiowb(); | ||
3812 | spin_unlock(&tp->tx_lock); | ||
3813 | |||
3814 | dev->trans_start = jiffies; | ||
3815 | |||
3816 | return NETDEV_TX_OK; | ||
3817 | } | ||
3818 | |||
3819 | /* hard_start_xmit for devices that have the 4G bug and/or 40-bit bug and | ||
3820 | * support TG3_FLG2_HW_TSO_1 or firmware TSO only. | ||
3821 | */ | ||
3822 | static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev) | ||
3823 | { | ||
3824 | struct tg3 *tp = netdev_priv(dev); | ||
3825 | dma_addr_t mapping; | ||
3826 | u32 len, entry, base_flags, mss; | ||
3636 | int would_hit_hwbug; | 3827 | int would_hit_hwbug; |
3637 | 3828 | ||
3638 | len = skb_headlen(skb); | 3829 | len = skb_headlen(skb); |
@@ -4369,6 +4560,11 @@ static int tg3_chip_reset(struct tg3 *tp) | |||
4369 | tp->nvram_lock_cnt = 0; | 4560 | tp->nvram_lock_cnt = 0; |
4370 | } | 4561 | } |
4371 | 4562 | ||
4563 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || | ||
4564 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || | ||
4565 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
4566 | tw32(GRC_FASTBOOT_PC, 0); | ||
4567 | |||
4372 | /* | 4568 | /* |
4373 | * We must avoid the readl() that normally takes place. | 4569 | * We must avoid the readl() that normally takes place. |
4374 | * It locks machines, causes machine checks, and other | 4570 | * It locks machines, causes machine checks, and other |
@@ -5518,6 +5714,9 @@ static int tg3_set_mac_addr(struct net_device *dev, void *p) | |||
5518 | 5714 | ||
5519 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); | 5715 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); |
5520 | 5716 | ||
5717 | if (!netif_running(dev)) | ||
5718 | return 0; | ||
5719 | |||
5521 | spin_lock_bh(&tp->lock); | 5720 | spin_lock_bh(&tp->lock); |
5522 | __tg3_set_mac_addr(tp); | 5721 | __tg3_set_mac_addr(tp); |
5523 | spin_unlock_bh(&tp->lock); | 5722 | spin_unlock_bh(&tp->lock); |
@@ -5585,6 +5784,9 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
5585 | tg3_abort_hw(tp, 1); | 5784 | tg3_abort_hw(tp, 1); |
5586 | } | 5785 | } |
5587 | 5786 | ||
5787 | if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) | ||
5788 | tg3_phy_reset(tp); | ||
5789 | |||
5588 | err = tg3_chip_reset(tp); | 5790 | err = tg3_chip_reset(tp); |
5589 | if (err) | 5791 | if (err) |
5590 | return err; | 5792 | return err; |
@@ -5955,6 +6157,9 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
5955 | gpio_mask |= GRC_LCLCTRL_GPIO_OE3 | | 6157 | gpio_mask |= GRC_LCLCTRL_GPIO_OE3 | |
5956 | GRC_LCLCTRL_GPIO_OUTPUT3; | 6158 | GRC_LCLCTRL_GPIO_OUTPUT3; |
5957 | 6159 | ||
6160 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) | ||
6161 | gpio_mask |= GRC_LCLCTRL_GPIO_UART_SEL; | ||
6162 | |||
5958 | tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask; | 6163 | tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask; |
5959 | 6164 | ||
5960 | /* GPIO1 must be driven high for eeprom write protect */ | 6165 | /* GPIO1 must be driven high for eeprom write protect */ |
@@ -5993,6 +6198,11 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
5993 | } | 6198 | } |
5994 | } | 6199 | } |
5995 | 6200 | ||
6201 | /* Enable host coalescing bug fix */ | ||
6202 | if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) || | ||
6203 | (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)) | ||
6204 | val |= (1 << 29); | ||
6205 | |||
5996 | tw32_f(WDMAC_MODE, val); | 6206 | tw32_f(WDMAC_MODE, val); |
5997 | udelay(40); | 6207 | udelay(40); |
5998 | 6208 | ||
@@ -6048,6 +6258,9 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
6048 | udelay(100); | 6258 | udelay(100); |
6049 | 6259 | ||
6050 | tp->rx_mode = RX_MODE_ENABLE; | 6260 | tp->rx_mode = RX_MODE_ENABLE; |
6261 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) | ||
6262 | tp->rx_mode |= RX_MODE_IPV6_CSUM_ENABLE; | ||
6263 | |||
6051 | tw32_f(MAC_RX_MODE, tp->rx_mode); | 6264 | tw32_f(MAC_RX_MODE, tp->rx_mode); |
6052 | udelay(10); | 6265 | udelay(10); |
6053 | 6266 | ||
@@ -6097,6 +6310,17 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
6097 | tp->tg3_flags2 |= TG3_FLG2_HW_AUTONEG; | 6310 | tp->tg3_flags2 |= TG3_FLG2_HW_AUTONEG; |
6098 | } | 6311 | } |
6099 | 6312 | ||
6313 | if ((tp->tg3_flags2 & TG3_FLG2_MII_SERDES) && | ||
6314 | (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714)) { | ||
6315 | u32 tmp; | ||
6316 | |||
6317 | tmp = tr32(SERDES_RX_CTRL); | ||
6318 | tw32(SERDES_RX_CTRL, tmp | SERDES_RX_SIG_DETECT); | ||
6319 | tp->grc_local_ctrl &= ~GRC_LCLCTRL_USE_EXT_SIG_DETECT; | ||
6320 | tp->grc_local_ctrl |= GRC_LCLCTRL_USE_SIG_DETECT; | ||
6321 | tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl); | ||
6322 | } | ||
6323 | |||
6100 | err = tg3_setup_phy(tp, 1); | 6324 | err = tg3_setup_phy(tp, 1); |
6101 | if (err) | 6325 | if (err) |
6102 | return err; | 6326 | return err; |
@@ -6175,7 +6399,7 @@ static int tg3_init_hw(struct tg3 *tp) | |||
6175 | int err; | 6399 | int err; |
6176 | 6400 | ||
6177 | /* Force the chip into D0. */ | 6401 | /* Force the chip into D0. */ |
6178 | err = tg3_set_power_state(tp, 0); | 6402 | err = tg3_set_power_state(tp, PCI_D0); |
6179 | if (err) | 6403 | if (err) |
6180 | goto out; | 6404 | goto out; |
6181 | 6405 | ||
@@ -6331,6 +6555,26 @@ static void tg3_timer(unsigned long __opaque) | |||
6331 | add_timer(&tp->timer); | 6555 | add_timer(&tp->timer); |
6332 | } | 6556 | } |
6333 | 6557 | ||
6558 | static int tg3_request_irq(struct tg3 *tp) | ||
6559 | { | ||
6560 | irqreturn_t (*fn)(int, void *, struct pt_regs *); | ||
6561 | unsigned long flags; | ||
6562 | struct net_device *dev = tp->dev; | ||
6563 | |||
6564 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { | ||
6565 | fn = tg3_msi; | ||
6566 | if (tp->tg3_flags2 & TG3_FLG2_1SHOT_MSI) | ||
6567 | fn = tg3_msi_1shot; | ||
6568 | flags = SA_SAMPLE_RANDOM; | ||
6569 | } else { | ||
6570 | fn = tg3_interrupt; | ||
6571 | if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) | ||
6572 | fn = tg3_interrupt_tagged; | ||
6573 | flags = SA_SHIRQ | SA_SAMPLE_RANDOM; | ||
6574 | } | ||
6575 | return (request_irq(tp->pdev->irq, fn, flags, dev->name, dev)); | ||
6576 | } | ||
6577 | |||
6334 | static int tg3_test_interrupt(struct tg3 *tp) | 6578 | static int tg3_test_interrupt(struct tg3 *tp) |
6335 | { | 6579 | { |
6336 | struct net_device *dev = tp->dev; | 6580 | struct net_device *dev = tp->dev; |
@@ -6367,16 +6611,7 @@ static int tg3_test_interrupt(struct tg3 *tp) | |||
6367 | 6611 | ||
6368 | free_irq(tp->pdev->irq, dev); | 6612 | free_irq(tp->pdev->irq, dev); |
6369 | 6613 | ||
6370 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) | 6614 | 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 | 6615 | ||
6381 | if (err) | 6616 | if (err) |
6382 | return err; | 6617 | return err; |
@@ -6428,14 +6663,7 @@ static int tg3_test_msi(struct tg3 *tp) | |||
6428 | 6663 | ||
6429 | tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; | 6664 | tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; |
6430 | 6665 | ||
6431 | { | 6666 | 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) | 6667 | if (err) |
6440 | return err; | 6668 | return err; |
6441 | 6669 | ||
@@ -6462,6 +6690,10 @@ static int tg3_open(struct net_device *dev) | |||
6462 | 6690 | ||
6463 | tg3_full_lock(tp, 0); | 6691 | tg3_full_lock(tp, 0); |
6464 | 6692 | ||
6693 | err = tg3_set_power_state(tp, PCI_D0); | ||
6694 | if (err) | ||
6695 | return err; | ||
6696 | |||
6465 | tg3_disable_ints(tp); | 6697 | tg3_disable_ints(tp); |
6466 | tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; | 6698 | tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; |
6467 | 6699 | ||
@@ -6476,7 +6708,9 @@ static int tg3_open(struct net_device *dev) | |||
6476 | 6708 | ||
6477 | if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && | 6709 | if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && |
6478 | (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_AX) && | 6710 | (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_AX) && |
6479 | (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_BX)) { | 6711 | (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_BX) && |
6712 | !((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) && | ||
6713 | (tp->pdev_peer == tp->pdev))) { | ||
6480 | /* All MSI supporting chips should support tagged | 6714 | /* All MSI supporting chips should support tagged |
6481 | * status. Assert that this is the case. | 6715 | * status. Assert that this is the case. |
6482 | */ | 6716 | */ |
@@ -6491,17 +6725,7 @@ static int tg3_open(struct net_device *dev) | |||
6491 | tp->tg3_flags2 |= TG3_FLG2_USING_MSI; | 6725 | tp->tg3_flags2 |= TG3_FLG2_USING_MSI; |
6492 | } | 6726 | } |
6493 | } | 6727 | } |
6494 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) | 6728 | 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 | 6729 | ||
6506 | if (err) { | 6730 | if (err) { |
6507 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { | 6731 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { |
@@ -6566,6 +6790,14 @@ static int tg3_open(struct net_device *dev) | |||
6566 | 6790 | ||
6567 | return err; | 6791 | return err; |
6568 | } | 6792 | } |
6793 | |||
6794 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { | ||
6795 | if (tp->tg3_flags2 & TG3_FLG2_1SHOT_MSI) { | ||
6796 | u32 val = tr32(0x7c04); | ||
6797 | |||
6798 | tw32(0x7c04, val | (1 << 29)); | ||
6799 | } | ||
6800 | } | ||
6569 | } | 6801 | } |
6570 | 6802 | ||
6571 | tg3_full_lock(tp, 0); | 6803 | tg3_full_lock(tp, 0); |
@@ -6839,7 +7071,6 @@ static int tg3_close(struct net_device *dev) | |||
6839 | tp->tg3_flags &= | 7071 | tp->tg3_flags &= |
6840 | ~(TG3_FLAG_INIT_COMPLETE | | 7072 | ~(TG3_FLAG_INIT_COMPLETE | |
6841 | TG3_FLAG_GOT_SERDES_FLOWCTL); | 7073 | TG3_FLAG_GOT_SERDES_FLOWCTL); |
6842 | netif_carrier_off(tp->dev); | ||
6843 | 7074 | ||
6844 | tg3_full_unlock(tp); | 7075 | tg3_full_unlock(tp); |
6845 | 7076 | ||
@@ -6856,6 +7087,10 @@ static int tg3_close(struct net_device *dev) | |||
6856 | 7087 | ||
6857 | tg3_free_consistent(tp); | 7088 | tg3_free_consistent(tp); |
6858 | 7089 | ||
7090 | tg3_set_power_state(tp, PCI_D3hot); | ||
7091 | |||
7092 | netif_carrier_off(tp->dev); | ||
7093 | |||
6859 | return 0; | 7094 | return 0; |
6860 | } | 7095 | } |
6861 | 7096 | ||
@@ -7150,6 +7385,9 @@ static void tg3_set_rx_mode(struct net_device *dev) | |||
7150 | { | 7385 | { |
7151 | struct tg3 *tp = netdev_priv(dev); | 7386 | struct tg3 *tp = netdev_priv(dev); |
7152 | 7387 | ||
7388 | if (!netif_running(dev)) | ||
7389 | return; | ||
7390 | |||
7153 | tg3_full_lock(tp, 0); | 7391 | tg3_full_lock(tp, 0); |
7154 | __tg3_set_rx_mode(dev); | 7392 | __tg3_set_rx_mode(dev); |
7155 | tg3_full_unlock(tp); | 7393 | tg3_full_unlock(tp); |
@@ -7174,6 +7412,9 @@ static void tg3_get_regs(struct net_device *dev, | |||
7174 | 7412 | ||
7175 | memset(p, 0, TG3_REGDUMP_LEN); | 7413 | memset(p, 0, TG3_REGDUMP_LEN); |
7176 | 7414 | ||
7415 | if (tp->link_config.phy_is_low_power) | ||
7416 | return; | ||
7417 | |||
7177 | tg3_full_lock(tp, 0); | 7418 | tg3_full_lock(tp, 0); |
7178 | 7419 | ||
7179 | #define __GET_REG32(reg) (*(p)++ = tr32(reg)) | 7420 | #define __GET_REG32(reg) (*(p)++ = tr32(reg)) |
@@ -7240,6 +7481,7 @@ static int tg3_get_eeprom_len(struct net_device *dev) | |||
7240 | } | 7481 | } |
7241 | 7482 | ||
7242 | static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val); | 7483 | static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val); |
7484 | static int tg3_nvram_read_swab(struct tg3 *tp, u32 offset, u32 *val); | ||
7243 | 7485 | ||
7244 | static int tg3_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 *data) | 7486 | static int tg3_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 *data) |
7245 | { | 7487 | { |
@@ -7248,6 +7490,9 @@ static int tg3_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | |||
7248 | u8 *pd; | 7490 | u8 *pd; |
7249 | u32 i, offset, len, val, b_offset, b_count; | 7491 | u32 i, offset, len, val, b_offset, b_count; |
7250 | 7492 | ||
7493 | if (tp->link_config.phy_is_low_power) | ||
7494 | return -EAGAIN; | ||
7495 | |||
7251 | offset = eeprom->offset; | 7496 | offset = eeprom->offset; |
7252 | len = eeprom->len; | 7497 | len = eeprom->len; |
7253 | eeprom->len = 0; | 7498 | eeprom->len = 0; |
@@ -7309,6 +7554,9 @@ static int tg3_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | |||
7309 | u32 offset, len, b_offset, odd_len, start, end; | 7554 | u32 offset, len, b_offset, odd_len, start, end; |
7310 | u8 *buf; | 7555 | u8 *buf; |
7311 | 7556 | ||
7557 | if (tp->link_config.phy_is_low_power) | ||
7558 | return -EAGAIN; | ||
7559 | |||
7312 | if (eeprom->magic != TG3_EEPROM_MAGIC) | 7560 | if (eeprom->magic != TG3_EEPROM_MAGIC) |
7313 | return -EINVAL; | 7561 | return -EINVAL; |
7314 | 7562 | ||
@@ -7442,6 +7690,7 @@ static void tg3_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info | |||
7442 | 7690 | ||
7443 | strcpy(info->driver, DRV_MODULE_NAME); | 7691 | strcpy(info->driver, DRV_MODULE_NAME); |
7444 | strcpy(info->version, DRV_MODULE_VERSION); | 7692 | strcpy(info->version, DRV_MODULE_VERSION); |
7693 | strcpy(info->fw_version, tp->fw_ver); | ||
7445 | strcpy(info->bus_info, pci_name(tp->pdev)); | 7694 | strcpy(info->bus_info, pci_name(tp->pdev)); |
7446 | } | 7695 | } |
7447 | 7696 | ||
@@ -7536,11 +7785,20 @@ static void tg3_get_ringparam(struct net_device *dev, struct ethtool_ringparam * | |||
7536 | 7785 | ||
7537 | ering->rx_max_pending = TG3_RX_RING_SIZE - 1; | 7786 | ering->rx_max_pending = TG3_RX_RING_SIZE - 1; |
7538 | ering->rx_mini_max_pending = 0; | 7787 | ering->rx_mini_max_pending = 0; |
7539 | ering->rx_jumbo_max_pending = TG3_RX_JUMBO_RING_SIZE - 1; | 7788 | if (tp->tg3_flags & TG3_FLAG_JUMBO_RING_ENABLE) |
7789 | ering->rx_jumbo_max_pending = TG3_RX_JUMBO_RING_SIZE - 1; | ||
7790 | else | ||
7791 | ering->rx_jumbo_max_pending = 0; | ||
7792 | |||
7793 | ering->tx_max_pending = TG3_TX_RING_SIZE - 1; | ||
7540 | 7794 | ||
7541 | ering->rx_pending = tp->rx_pending; | 7795 | ering->rx_pending = tp->rx_pending; |
7542 | ering->rx_mini_pending = 0; | 7796 | ering->rx_mini_pending = 0; |
7543 | ering->rx_jumbo_pending = tp->rx_jumbo_pending; | 7797 | if (tp->tg3_flags & TG3_FLAG_JUMBO_RING_ENABLE) |
7798 | ering->rx_jumbo_pending = tp->rx_jumbo_pending; | ||
7799 | else | ||
7800 | ering->rx_jumbo_pending = 0; | ||
7801 | |||
7544 | ering->tx_pending = tp->tx_pending; | 7802 | ering->tx_pending = tp->tx_pending; |
7545 | } | 7803 | } |
7546 | 7804 | ||
@@ -7661,10 +7919,11 @@ static int tg3_set_tx_csum(struct net_device *dev, u32 data) | |||
7661 | return 0; | 7919 | return 0; |
7662 | } | 7920 | } |
7663 | 7921 | ||
7664 | if (data) | 7922 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
7665 | dev->features |= NETIF_F_IP_CSUM; | 7923 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) |
7924 | ethtool_op_set_tx_hw_csum(dev, data); | ||
7666 | else | 7925 | else |
7667 | dev->features &= ~NETIF_F_IP_CSUM; | 7926 | ethtool_op_set_tx_csum(dev, data); |
7668 | 7927 | ||
7669 | return 0; | 7928 | return 0; |
7670 | } | 7929 | } |
@@ -7734,29 +7993,52 @@ static void tg3_get_ethtool_stats (struct net_device *dev, | |||
7734 | } | 7993 | } |
7735 | 7994 | ||
7736 | #define NVRAM_TEST_SIZE 0x100 | 7995 | #define NVRAM_TEST_SIZE 0x100 |
7996 | #define NVRAM_SELFBOOT_FORMAT1_SIZE 0x14 | ||
7737 | 7997 | ||
7738 | static int tg3_test_nvram(struct tg3 *tp) | 7998 | static int tg3_test_nvram(struct tg3 *tp) |
7739 | { | 7999 | { |
7740 | u32 *buf, csum; | 8000 | u32 *buf, csum, magic; |
7741 | int i, j, err = 0; | 8001 | int i, j, err = 0, size; |
8002 | |||
8003 | if (tg3_nvram_read_swab(tp, 0, &magic) != 0) | ||
8004 | return -EIO; | ||
8005 | |||
8006 | if (magic == TG3_EEPROM_MAGIC) | ||
8007 | size = NVRAM_TEST_SIZE; | ||
8008 | else if ((magic & 0xff000000) == 0xa5000000) { | ||
8009 | if ((magic & 0xe00000) == 0x200000) | ||
8010 | size = NVRAM_SELFBOOT_FORMAT1_SIZE; | ||
8011 | else | ||
8012 | return 0; | ||
8013 | } else | ||
8014 | return -EIO; | ||
7742 | 8015 | ||
7743 | buf = kmalloc(NVRAM_TEST_SIZE, GFP_KERNEL); | 8016 | buf = kmalloc(size, GFP_KERNEL); |
7744 | if (buf == NULL) | 8017 | if (buf == NULL) |
7745 | return -ENOMEM; | 8018 | return -ENOMEM; |
7746 | 8019 | ||
7747 | for (i = 0, j = 0; i < NVRAM_TEST_SIZE; i += 4, j++) { | 8020 | err = -EIO; |
8021 | for (i = 0, j = 0; i < size; i += 4, j++) { | ||
7748 | u32 val; | 8022 | u32 val; |
7749 | 8023 | ||
7750 | if ((err = tg3_nvram_read(tp, i, &val)) != 0) | 8024 | if ((err = tg3_nvram_read(tp, i, &val)) != 0) |
7751 | break; | 8025 | break; |
7752 | buf[j] = cpu_to_le32(val); | 8026 | buf[j] = cpu_to_le32(val); |
7753 | } | 8027 | } |
7754 | if (i < NVRAM_TEST_SIZE) | 8028 | if (i < size) |
7755 | goto out; | 8029 | goto out; |
7756 | 8030 | ||
7757 | err = -EIO; | 8031 | /* Selfboot format */ |
7758 | if (cpu_to_be32(buf[0]) != TG3_EEPROM_MAGIC) | 8032 | if (cpu_to_be32(buf[0]) != TG3_EEPROM_MAGIC) { |
7759 | goto out; | 8033 | u8 *buf8 = (u8 *) buf, csum8 = 0; |
8034 | |||
8035 | for (i = 0; i < size; i++) | ||
8036 | csum8 += buf8[i]; | ||
8037 | |||
8038 | if (csum8 == 0) | ||
8039 | return 0; | ||
8040 | return -EIO; | ||
8041 | } | ||
7760 | 8042 | ||
7761 | /* Bootstrap checksum at offset 0x10 */ | 8043 | /* Bootstrap checksum at offset 0x10 */ |
7762 | csum = calc_crc((unsigned char *) buf, 0x10); | 8044 | csum = calc_crc((unsigned char *) buf, 0x10); |
@@ -7802,7 +8084,7 @@ static int tg3_test_link(struct tg3 *tp) | |||
7802 | } | 8084 | } |
7803 | 8085 | ||
7804 | /* Only test the commonly used registers */ | 8086 | /* Only test the commonly used registers */ |
7805 | static const int tg3_test_registers(struct tg3 *tp) | 8087 | static int tg3_test_registers(struct tg3 *tp) |
7806 | { | 8088 | { |
7807 | int i, is_5705; | 8089 | int i, is_5705; |
7808 | u32 offset, read_mask, write_mask, val, save_val, read_val; | 8090 | u32 offset, read_mask, write_mask, val, save_val, read_val; |
@@ -8050,14 +8332,25 @@ static int tg3_test_memory(struct tg3 *tp) | |||
8050 | { 0x00008000, 0x02000}, | 8332 | { 0x00008000, 0x02000}, |
8051 | { 0x00010000, 0x0e000}, | 8333 | { 0x00010000, 0x0e000}, |
8052 | { 0xffffffff, 0x00000} | 8334 | { 0xffffffff, 0x00000} |
8335 | }, mem_tbl_5755[] = { | ||
8336 | { 0x00000200, 0x00008}, | ||
8337 | { 0x00004000, 0x00800}, | ||
8338 | { 0x00006000, 0x00800}, | ||
8339 | { 0x00008000, 0x02000}, | ||
8340 | { 0x00010000, 0x0c000}, | ||
8341 | { 0xffffffff, 0x00000} | ||
8053 | }; | 8342 | }; |
8054 | struct mem_entry *mem_tbl; | 8343 | struct mem_entry *mem_tbl; |
8055 | int err = 0; | 8344 | int err = 0; |
8056 | int i; | 8345 | int i; |
8057 | 8346 | ||
8058 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) | 8347 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { |
8059 | mem_tbl = mem_tbl_5705; | 8348 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
8060 | else | 8349 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) |
8350 | mem_tbl = mem_tbl_5755; | ||
8351 | else | ||
8352 | mem_tbl = mem_tbl_5705; | ||
8353 | } else | ||
8061 | mem_tbl = mem_tbl_570x; | 8354 | mem_tbl = mem_tbl_570x; |
8062 | 8355 | ||
8063 | for (i = 0; mem_tbl[i].offset != 0xffffffff; i++) { | 8356 | for (i = 0; mem_tbl[i].offset != 0xffffffff; i++) { |
@@ -8229,6 +8522,9 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest, | |||
8229 | { | 8522 | { |
8230 | struct tg3 *tp = netdev_priv(dev); | 8523 | struct tg3 *tp = netdev_priv(dev); |
8231 | 8524 | ||
8525 | if (tp->link_config.phy_is_low_power) | ||
8526 | tg3_set_power_state(tp, PCI_D0); | ||
8527 | |||
8232 | memset(data, 0, sizeof(u64) * TG3_NUM_TEST); | 8528 | memset(data, 0, sizeof(u64) * TG3_NUM_TEST); |
8233 | 8529 | ||
8234 | if (tg3_test_nvram(tp) != 0) { | 8530 | if (tg3_test_nvram(tp) != 0) { |
@@ -8257,6 +8553,9 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest, | |||
8257 | if (!err) | 8553 | if (!err) |
8258 | tg3_nvram_unlock(tp); | 8554 | tg3_nvram_unlock(tp); |
8259 | 8555 | ||
8556 | if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) | ||
8557 | tg3_phy_reset(tp); | ||
8558 | |||
8260 | if (tg3_test_registers(tp) != 0) { | 8559 | if (tg3_test_registers(tp) != 0) { |
8261 | etest->flags |= ETH_TEST_FL_FAILED; | 8560 | etest->flags |= ETH_TEST_FL_FAILED; |
8262 | data[2] = 1; | 8561 | data[2] = 1; |
@@ -8286,6 +8585,9 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest, | |||
8286 | 8585 | ||
8287 | tg3_full_unlock(tp); | 8586 | tg3_full_unlock(tp); |
8288 | } | 8587 | } |
8588 | if (tp->link_config.phy_is_low_power) | ||
8589 | tg3_set_power_state(tp, PCI_D3hot); | ||
8590 | |||
8289 | } | 8591 | } |
8290 | 8592 | ||
8291 | static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | 8593 | static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
@@ -8305,6 +8607,9 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
8305 | if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) | 8607 | if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) |
8306 | break; /* We have no PHY */ | 8608 | break; /* We have no PHY */ |
8307 | 8609 | ||
8610 | if (tp->link_config.phy_is_low_power) | ||
8611 | return -EAGAIN; | ||
8612 | |||
8308 | spin_lock_bh(&tp->lock); | 8613 | spin_lock_bh(&tp->lock); |
8309 | err = tg3_readphy(tp, data->reg_num & 0x1f, &mii_regval); | 8614 | err = tg3_readphy(tp, data->reg_num & 0x1f, &mii_regval); |
8310 | spin_unlock_bh(&tp->lock); | 8615 | spin_unlock_bh(&tp->lock); |
@@ -8321,6 +8626,9 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
8321 | if (!capable(CAP_NET_ADMIN)) | 8626 | if (!capable(CAP_NET_ADMIN)) |
8322 | return -EPERM; | 8627 | return -EPERM; |
8323 | 8628 | ||
8629 | if (tp->link_config.phy_is_low_power) | ||
8630 | return -EAGAIN; | ||
8631 | |||
8324 | spin_lock_bh(&tp->lock); | 8632 | spin_lock_bh(&tp->lock); |
8325 | err = tg3_writephy(tp, data->reg_num & 0x1f, data->val_in); | 8633 | err = tg3_writephy(tp, data->reg_num & 0x1f, data->val_in); |
8326 | spin_unlock_bh(&tp->lock); | 8634 | spin_unlock_bh(&tp->lock); |
@@ -8464,14 +8772,14 @@ static struct ethtool_ops tg3_ethtool_ops = { | |||
8464 | 8772 | ||
8465 | static void __devinit tg3_get_eeprom_size(struct tg3 *tp) | 8773 | static void __devinit tg3_get_eeprom_size(struct tg3 *tp) |
8466 | { | 8774 | { |
8467 | u32 cursize, val; | 8775 | u32 cursize, val, magic; |
8468 | 8776 | ||
8469 | tp->nvram_size = EEPROM_CHIP_SIZE; | 8777 | tp->nvram_size = EEPROM_CHIP_SIZE; |
8470 | 8778 | ||
8471 | if (tg3_nvram_read(tp, 0, &val) != 0) | 8779 | if (tg3_nvram_read_swab(tp, 0, &magic) != 0) |
8472 | return; | 8780 | return; |
8473 | 8781 | ||
8474 | if (swab32(val) != TG3_EEPROM_MAGIC) | 8782 | if ((magic != TG3_EEPROM_MAGIC) && ((magic & 0xff000000) != 0xa5000000)) |
8475 | return; | 8783 | return; |
8476 | 8784 | ||
8477 | /* | 8785 | /* |
@@ -8479,13 +8787,13 @@ static void __devinit tg3_get_eeprom_size(struct tg3 *tp) | |||
8479 | * When we encounter our validation signature, we know the addressing | 8787 | * When we encounter our validation signature, we know the addressing |
8480 | * has wrapped around, and thus have our chip size. | 8788 | * has wrapped around, and thus have our chip size. |
8481 | */ | 8789 | */ |
8482 | cursize = 0x800; | 8790 | cursize = 0x10; |
8483 | 8791 | ||
8484 | while (cursize < tp->nvram_size) { | 8792 | while (cursize < tp->nvram_size) { |
8485 | if (tg3_nvram_read(tp, cursize, &val) != 0) | 8793 | if (tg3_nvram_read_swab(tp, cursize, &val) != 0) |
8486 | return; | 8794 | return; |
8487 | 8795 | ||
8488 | if (swab32(val) == TG3_EEPROM_MAGIC) | 8796 | if (val == magic) |
8489 | break; | 8797 | break; |
8490 | 8798 | ||
8491 | cursize <<= 1; | 8799 | cursize <<= 1; |
@@ -8498,6 +8806,15 @@ static void __devinit tg3_get_nvram_size(struct tg3 *tp) | |||
8498 | { | 8806 | { |
8499 | u32 val; | 8807 | u32 val; |
8500 | 8808 | ||
8809 | if (tg3_nvram_read_swab(tp, 0, &val) != 0) | ||
8810 | return; | ||
8811 | |||
8812 | /* Selfboot format */ | ||
8813 | if (val != TG3_EEPROM_MAGIC) { | ||
8814 | tg3_get_eeprom_size(tp); | ||
8815 | return; | ||
8816 | } | ||
8817 | |||
8501 | if (tg3_nvram_read(tp, 0xf0, &val) == 0) { | 8818 | if (tg3_nvram_read(tp, 0xf0, &val) == 0) { |
8502 | if (val != 0) { | 8819 | if (val != 0) { |
8503 | tp->nvram_size = (val >> 16) * 1024; | 8820 | tp->nvram_size = (val >> 16) * 1024; |
@@ -8621,6 +8938,85 @@ static void __devinit tg3_get_5752_nvram_info(struct tg3 *tp) | |||
8621 | } | 8938 | } |
8622 | } | 8939 | } |
8623 | 8940 | ||
8941 | static void __devinit tg3_get_5755_nvram_info(struct tg3 *tp) | ||
8942 | { | ||
8943 | u32 nvcfg1; | ||
8944 | |||
8945 | nvcfg1 = tr32(NVRAM_CFG1); | ||
8946 | |||
8947 | /* NVRAM protection for TPM */ | ||
8948 | if (nvcfg1 & (1 << 27)) | ||
8949 | tp->tg3_flags2 |= TG3_FLG2_PROTECTED_NVRAM; | ||
8950 | |||
8951 | switch (nvcfg1 & NVRAM_CFG1_5752VENDOR_MASK) { | ||
8952 | case FLASH_5755VENDOR_ATMEL_EEPROM_64KHZ: | ||
8953 | case FLASH_5755VENDOR_ATMEL_EEPROM_376KHZ: | ||
8954 | tp->nvram_jedecnum = JEDEC_ATMEL; | ||
8955 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
8956 | tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE; | ||
8957 | |||
8958 | nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS; | ||
8959 | tw32(NVRAM_CFG1, nvcfg1); | ||
8960 | break; | ||
8961 | case FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED: | ||
8962 | case FLASH_5755VENDOR_ATMEL_FLASH_1: | ||
8963 | case FLASH_5755VENDOR_ATMEL_FLASH_2: | ||
8964 | case FLASH_5755VENDOR_ATMEL_FLASH_3: | ||
8965 | case FLASH_5755VENDOR_ATMEL_FLASH_4: | ||
8966 | tp->nvram_jedecnum = JEDEC_ATMEL; | ||
8967 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
8968 | tp->tg3_flags2 |= TG3_FLG2_FLASH; | ||
8969 | tp->nvram_pagesize = 264; | ||
8970 | break; | ||
8971 | case FLASH_5752VENDOR_ST_M45PE10: | ||
8972 | case FLASH_5752VENDOR_ST_M45PE20: | ||
8973 | case FLASH_5752VENDOR_ST_M45PE40: | ||
8974 | tp->nvram_jedecnum = JEDEC_ST; | ||
8975 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
8976 | tp->tg3_flags2 |= TG3_FLG2_FLASH; | ||
8977 | tp->nvram_pagesize = 256; | ||
8978 | break; | ||
8979 | } | ||
8980 | } | ||
8981 | |||
8982 | static void __devinit tg3_get_5787_nvram_info(struct tg3 *tp) | ||
8983 | { | ||
8984 | u32 nvcfg1; | ||
8985 | |||
8986 | nvcfg1 = tr32(NVRAM_CFG1); | ||
8987 | |||
8988 | switch (nvcfg1 & NVRAM_CFG1_5752VENDOR_MASK) { | ||
8989 | case FLASH_5787VENDOR_ATMEL_EEPROM_64KHZ: | ||
8990 | case FLASH_5787VENDOR_ATMEL_EEPROM_376KHZ: | ||
8991 | case FLASH_5787VENDOR_MICRO_EEPROM_64KHZ: | ||
8992 | case FLASH_5787VENDOR_MICRO_EEPROM_376KHZ: | ||
8993 | tp->nvram_jedecnum = JEDEC_ATMEL; | ||
8994 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
8995 | tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE; | ||
8996 | |||
8997 | nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS; | ||
8998 | tw32(NVRAM_CFG1, nvcfg1); | ||
8999 | break; | ||
9000 | case FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED: | ||
9001 | case FLASH_5755VENDOR_ATMEL_FLASH_1: | ||
9002 | case FLASH_5755VENDOR_ATMEL_FLASH_2: | ||
9003 | case FLASH_5755VENDOR_ATMEL_FLASH_3: | ||
9004 | tp->nvram_jedecnum = JEDEC_ATMEL; | ||
9005 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
9006 | tp->tg3_flags2 |= TG3_FLG2_FLASH; | ||
9007 | tp->nvram_pagesize = 264; | ||
9008 | break; | ||
9009 | case FLASH_5752VENDOR_ST_M45PE10: | ||
9010 | case FLASH_5752VENDOR_ST_M45PE20: | ||
9011 | case FLASH_5752VENDOR_ST_M45PE40: | ||
9012 | tp->nvram_jedecnum = JEDEC_ST; | ||
9013 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
9014 | tp->tg3_flags2 |= TG3_FLG2_FLASH; | ||
9015 | tp->nvram_pagesize = 256; | ||
9016 | break; | ||
9017 | } | ||
9018 | } | ||
9019 | |||
8624 | /* Chips other than 5700/5701 use the NVRAM for fetching info. */ | 9020 | /* Chips other than 5700/5701 use the NVRAM for fetching info. */ |
8625 | static void __devinit tg3_nvram_init(struct tg3 *tp) | 9021 | static void __devinit tg3_nvram_init(struct tg3 *tp) |
8626 | { | 9022 | { |
@@ -8656,6 +9052,10 @@ static void __devinit tg3_nvram_init(struct tg3 *tp) | |||
8656 | 9052 | ||
8657 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) | 9053 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) |
8658 | tg3_get_5752_nvram_info(tp); | 9054 | tg3_get_5752_nvram_info(tp); |
9055 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) | ||
9056 | tg3_get_5755_nvram_info(tp); | ||
9057 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
9058 | tg3_get_5787_nvram_info(tp); | ||
8659 | else | 9059 | else |
8660 | tg3_get_nvram_info(tp); | 9060 | tg3_get_nvram_info(tp); |
8661 | 9061 | ||
@@ -8725,6 +9125,34 @@ static int tg3_nvram_exec_cmd(struct tg3 *tp, u32 nvram_cmd) | |||
8725 | return 0; | 9125 | return 0; |
8726 | } | 9126 | } |
8727 | 9127 | ||
9128 | static u32 tg3_nvram_phys_addr(struct tg3 *tp, u32 addr) | ||
9129 | { | ||
9130 | if ((tp->tg3_flags & TG3_FLAG_NVRAM) && | ||
9131 | (tp->tg3_flags & TG3_FLAG_NVRAM_BUFFERED) && | ||
9132 | (tp->tg3_flags2 & TG3_FLG2_FLASH) && | ||
9133 | (tp->nvram_jedecnum == JEDEC_ATMEL)) | ||
9134 | |||
9135 | addr = ((addr / tp->nvram_pagesize) << | ||
9136 | ATMEL_AT45DB0X1B_PAGE_POS) + | ||
9137 | (addr % tp->nvram_pagesize); | ||
9138 | |||
9139 | return addr; | ||
9140 | } | ||
9141 | |||
9142 | static u32 tg3_nvram_logical_addr(struct tg3 *tp, u32 addr) | ||
9143 | { | ||
9144 | if ((tp->tg3_flags & TG3_FLAG_NVRAM) && | ||
9145 | (tp->tg3_flags & TG3_FLAG_NVRAM_BUFFERED) && | ||
9146 | (tp->tg3_flags2 & TG3_FLG2_FLASH) && | ||
9147 | (tp->nvram_jedecnum == JEDEC_ATMEL)) | ||
9148 | |||
9149 | addr = ((addr >> ATMEL_AT45DB0X1B_PAGE_POS) * | ||
9150 | tp->nvram_pagesize) + | ||
9151 | (addr & ((1 << ATMEL_AT45DB0X1B_PAGE_POS) - 1)); | ||
9152 | |||
9153 | return addr; | ||
9154 | } | ||
9155 | |||
8728 | static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val) | 9156 | static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val) |
8729 | { | 9157 | { |
8730 | int ret; | 9158 | int ret; |
@@ -8737,14 +9165,7 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val) | |||
8737 | if (!(tp->tg3_flags & TG3_FLAG_NVRAM)) | 9165 | if (!(tp->tg3_flags & TG3_FLAG_NVRAM)) |
8738 | return tg3_nvram_read_using_eeprom(tp, offset, val); | 9166 | return tg3_nvram_read_using_eeprom(tp, offset, val); |
8739 | 9167 | ||
8740 | if ((tp->tg3_flags & TG3_FLAG_NVRAM_BUFFERED) && | 9168 | 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 | 9169 | ||
8749 | if (offset > NVRAM_ADDR_MSK) | 9170 | if (offset > NVRAM_ADDR_MSK) |
8750 | return -EINVAL; | 9171 | return -EINVAL; |
@@ -8769,6 +9190,16 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val) | |||
8769 | return ret; | 9190 | return ret; |
8770 | } | 9191 | } |
8771 | 9192 | ||
9193 | static int tg3_nvram_read_swab(struct tg3 *tp, u32 offset, u32 *val) | ||
9194 | { | ||
9195 | int err; | ||
9196 | u32 tmp; | ||
9197 | |||
9198 | err = tg3_nvram_read(tp, offset, &tmp); | ||
9199 | *val = swab32(tmp); | ||
9200 | return err; | ||
9201 | } | ||
9202 | |||
8772 | static int tg3_nvram_write_block_using_eeprom(struct tg3 *tp, | 9203 | static int tg3_nvram_write_block_using_eeprom(struct tg3 *tp, |
8773 | u32 offset, u32 len, u8 *buf) | 9204 | u32 offset, u32 len, u8 *buf) |
8774 | { | 9205 | { |
@@ -8921,15 +9352,7 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len, | |||
8921 | 9352 | ||
8922 | page_off = offset % tp->nvram_pagesize; | 9353 | page_off = offset % tp->nvram_pagesize; |
8923 | 9354 | ||
8924 | if ((tp->tg3_flags2 & TG3_FLG2_FLASH) && | 9355 | 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 | 9356 | ||
8934 | tw32(NVRAM_ADDR, phy_addr); | 9357 | tw32(NVRAM_ADDR, phy_addr); |
8935 | 9358 | ||
@@ -8944,6 +9367,8 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len, | |||
8944 | nvram_cmd |= NVRAM_CMD_LAST; | 9367 | nvram_cmd |= NVRAM_CMD_LAST; |
8945 | 9368 | ||
8946 | if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752) && | 9369 | if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752) && |
9370 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755) && | ||
9371 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) && | ||
8947 | (tp->nvram_jedecnum == JEDEC_ST) && | 9372 | (tp->nvram_jedecnum == JEDEC_ST) && |
8948 | (nvram_cmd & NVRAM_CMD_FIRST)) { | 9373 | (nvram_cmd & NVRAM_CMD_FIRST)) { |
8949 | 9374 | ||
@@ -9081,12 +9506,18 @@ static inline struct subsys_tbl_ent *lookup_by_subsys(struct tg3 *tp) | |||
9081 | return NULL; | 9506 | return NULL; |
9082 | } | 9507 | } |
9083 | 9508 | ||
9084 | /* Since this function may be called in D3-hot power state during | ||
9085 | * tg3_init_one(), only config cycles are allowed. | ||
9086 | */ | ||
9087 | static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) | 9509 | static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) |
9088 | { | 9510 | { |
9089 | u32 val; | 9511 | u32 val; |
9512 | u16 pmcsr; | ||
9513 | |||
9514 | /* On some early chips the SRAM cannot be accessed in D3hot state, | ||
9515 | * so need make sure we're in D0. | ||
9516 | */ | ||
9517 | pci_read_config_word(tp->pdev, tp->pm_cap + PCI_PM_CTRL, &pmcsr); | ||
9518 | pmcsr &= ~PCI_PM_CTRL_STATE_MASK; | ||
9519 | pci_write_config_word(tp->pdev, tp->pm_cap + PCI_PM_CTRL, pmcsr); | ||
9520 | msleep(1); | ||
9090 | 9521 | ||
9091 | /* Make sure register accesses (indirect or otherwise) | 9522 | /* Make sure register accesses (indirect or otherwise) |
9092 | * will function correctly. | 9523 | * will function correctly. |
@@ -9347,6 +9778,7 @@ static void __devinit tg3_read_partno(struct tg3 *tp) | |||
9347 | { | 9778 | { |
9348 | unsigned char vpd_data[256]; | 9779 | unsigned char vpd_data[256]; |
9349 | int i; | 9780 | int i; |
9781 | u32 magic; | ||
9350 | 9782 | ||
9351 | if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) { | 9783 | if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) { |
9352 | /* Sun decided not to put the necessary bits in the | 9784 | /* Sun decided not to put the necessary bits in the |
@@ -9356,16 +9788,43 @@ static void __devinit tg3_read_partno(struct tg3 *tp) | |||
9356 | return; | 9788 | return; |
9357 | } | 9789 | } |
9358 | 9790 | ||
9359 | for (i = 0; i < 256; i += 4) { | 9791 | if (tg3_nvram_read_swab(tp, 0x0, &magic)) |
9360 | u32 tmp; | 9792 | return; |
9361 | 9793 | ||
9362 | if (tg3_nvram_read(tp, 0x100 + i, &tmp)) | 9794 | if (magic == TG3_EEPROM_MAGIC) { |
9363 | goto out_not_found; | 9795 | for (i = 0; i < 256; i += 4) { |
9796 | u32 tmp; | ||
9797 | |||
9798 | if (tg3_nvram_read(tp, 0x100 + i, &tmp)) | ||
9799 | goto out_not_found; | ||
9364 | 9800 | ||
9365 | vpd_data[i + 0] = ((tmp >> 0) & 0xff); | 9801 | vpd_data[i + 0] = ((tmp >> 0) & 0xff); |
9366 | vpd_data[i + 1] = ((tmp >> 8) & 0xff); | 9802 | vpd_data[i + 1] = ((tmp >> 8) & 0xff); |
9367 | vpd_data[i + 2] = ((tmp >> 16) & 0xff); | 9803 | vpd_data[i + 2] = ((tmp >> 16) & 0xff); |
9368 | vpd_data[i + 3] = ((tmp >> 24) & 0xff); | 9804 | vpd_data[i + 3] = ((tmp >> 24) & 0xff); |
9805 | } | ||
9806 | } else { | ||
9807 | int vpd_cap; | ||
9808 | |||
9809 | vpd_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_VPD); | ||
9810 | for (i = 0; i < 256; i += 4) { | ||
9811 | u32 tmp, j = 0; | ||
9812 | u16 tmp16; | ||
9813 | |||
9814 | pci_write_config_word(tp->pdev, vpd_cap + PCI_VPD_ADDR, | ||
9815 | i); | ||
9816 | while (j++ < 100) { | ||
9817 | pci_read_config_word(tp->pdev, vpd_cap + | ||
9818 | PCI_VPD_ADDR, &tmp16); | ||
9819 | if (tmp16 & 0x8000) | ||
9820 | break; | ||
9821 | msleep(1); | ||
9822 | } | ||
9823 | pci_read_config_dword(tp->pdev, vpd_cap + PCI_VPD_DATA, | ||
9824 | &tmp); | ||
9825 | tmp = cpu_to_le32(tmp); | ||
9826 | memcpy(&vpd_data[i], &tmp, 4); | ||
9827 | } | ||
9369 | } | 9828 | } |
9370 | 9829 | ||
9371 | /* Now parse and find the part number. */ | 9830 | /* Now parse and find the part number. */ |
@@ -9412,6 +9871,46 @@ out_not_found: | |||
9412 | strcpy(tp->board_part_number, "none"); | 9871 | strcpy(tp->board_part_number, "none"); |
9413 | } | 9872 | } |
9414 | 9873 | ||
9874 | static void __devinit tg3_read_fw_ver(struct tg3 *tp) | ||
9875 | { | ||
9876 | u32 val, offset, start; | ||
9877 | |||
9878 | if (tg3_nvram_read_swab(tp, 0, &val)) | ||
9879 | return; | ||
9880 | |||
9881 | if (val != TG3_EEPROM_MAGIC) | ||
9882 | return; | ||
9883 | |||
9884 | if (tg3_nvram_read_swab(tp, 0xc, &offset) || | ||
9885 | tg3_nvram_read_swab(tp, 0x4, &start)) | ||
9886 | return; | ||
9887 | |||
9888 | offset = tg3_nvram_logical_addr(tp, offset); | ||
9889 | if (tg3_nvram_read_swab(tp, offset, &val)) | ||
9890 | return; | ||
9891 | |||
9892 | if ((val & 0xfc000000) == 0x0c000000) { | ||
9893 | u32 ver_offset, addr; | ||
9894 | int i; | ||
9895 | |||
9896 | if (tg3_nvram_read_swab(tp, offset + 4, &val) || | ||
9897 | tg3_nvram_read_swab(tp, offset + 8, &ver_offset)) | ||
9898 | return; | ||
9899 | |||
9900 | if (val != 0) | ||
9901 | return; | ||
9902 | |||
9903 | addr = offset + ver_offset - start; | ||
9904 | for (i = 0; i < 16; i += 4) { | ||
9905 | if (tg3_nvram_read(tp, addr + i, &val)) | ||
9906 | return; | ||
9907 | |||
9908 | val = cpu_to_le32(val); | ||
9909 | memcpy(tp->fw_ver + i, &val, 4); | ||
9910 | } | ||
9911 | } | ||
9912 | } | ||
9913 | |||
9415 | #ifdef CONFIG_SPARC64 | 9914 | #ifdef CONFIG_SPARC64 |
9416 | static int __devinit tg3_is_sun_570X(struct tg3 *tp) | 9915 | static int __devinit tg3_is_sun_570X(struct tg3 *tp) |
9417 | { | 9916 | { |
@@ -9603,6 +10102,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
9603 | 10102 | ||
9604 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 || | 10103 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 || |
9605 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || | 10104 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || |
10105 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || | ||
10106 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 || | ||
9606 | (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) | 10107 | (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) |
9607 | tp->tg3_flags2 |= TG3_FLG2_5750_PLUS; | 10108 | tp->tg3_flags2 |= TG3_FLG2_5750_PLUS; |
9608 | 10109 | ||
@@ -9610,12 +10111,20 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
9610 | (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)) | 10111 | (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)) |
9611 | tp->tg3_flags2 |= TG3_FLG2_5705_PLUS; | 10112 | tp->tg3_flags2 |= TG3_FLG2_5705_PLUS; |
9612 | 10113 | ||
9613 | if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) | 10114 | if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) { |
9614 | tp->tg3_flags2 |= TG3_FLG2_HW_TSO; | 10115 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
10116 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) { | ||
10117 | tp->tg3_flags2 |= TG3_FLG2_HW_TSO_2; | ||
10118 | tp->tg3_flags2 |= TG3_FLG2_1SHOT_MSI; | ||
10119 | } else | ||
10120 | tp->tg3_flags2 |= TG3_FLG2_HW_TSO_1; | ||
10121 | } | ||
9615 | 10122 | ||
9616 | if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && | 10123 | if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && |
9617 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750 && | 10124 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750 && |
9618 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752) | 10125 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752 && |
10126 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755 && | ||
10127 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) | ||
9619 | tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE; | 10128 | tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE; |
9620 | 10129 | ||
9621 | if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0) | 10130 | if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0) |
@@ -9771,8 +10280,11 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
9771 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) | 10280 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) |
9772 | tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3; | 10281 | tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3; |
9773 | 10282 | ||
10283 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) | ||
10284 | tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_UART_SEL; | ||
10285 | |||
9774 | /* Force the chip into D0. */ | 10286 | /* Force the chip into D0. */ |
9775 | err = tg3_set_power_state(tp, 0); | 10287 | err = tg3_set_power_state(tp, PCI_D0); |
9776 | if (err) { | 10288 | if (err) { |
9777 | printk(KERN_ERR PFX "(%s) transition to D0 failed\n", | 10289 | printk(KERN_ERR PFX "(%s) transition to D0 failed\n", |
9778 | pci_name(tp->pdev)); | 10290 | pci_name(tp->pdev)); |
@@ -9825,7 +10337,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
9825 | if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0) | 10337 | if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0) |
9826 | tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG; | 10338 | tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG; |
9827 | 10339 | ||
9828 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) | 10340 | if ((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) && |
10341 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755) && | ||
10342 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787)) | ||
9829 | tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; | 10343 | tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; |
9830 | 10344 | ||
9831 | tp->coalesce_mode = 0; | 10345 | tp->coalesce_mode = 0; |
@@ -9925,6 +10439,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
9925 | } | 10439 | } |
9926 | 10440 | ||
9927 | tg3_read_partno(tp); | 10441 | tg3_read_partno(tp); |
10442 | tg3_read_fw_ver(tp); | ||
9928 | 10443 | ||
9929 | if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) { | 10444 | if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) { |
9930 | tp->tg3_flags &= ~TG3_FLAG_USE_MI_INTERRUPT; | 10445 | tp->tg3_flags &= ~TG3_FLAG_USE_MI_INTERRUPT; |
@@ -9960,10 +10475,14 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
9960 | else | 10475 | else |
9961 | tp->tg3_flags &= ~TG3_FLAG_POLL_SERDES; | 10476 | tp->tg3_flags &= ~TG3_FLAG_POLL_SERDES; |
9962 | 10477 | ||
9963 | /* It seems all chips can get confused if TX buffers | 10478 | /* All chips before 5787 can get confused if TX buffers |
9964 | * straddle the 4GB address boundary in some cases. | 10479 | * straddle the 4GB address boundary in some cases. |
9965 | */ | 10480 | */ |
9966 | tp->dev->hard_start_xmit = tg3_start_xmit; | 10481 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
10482 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
10483 | tp->dev->hard_start_xmit = tg3_start_xmit; | ||
10484 | else | ||
10485 | tp->dev->hard_start_xmit = tg3_start_xmit_dma_bug; | ||
9967 | 10486 | ||
9968 | tp->rx_offset = 2; | 10487 | tp->rx_offset = 2; |
9969 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 && | 10488 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 && |
@@ -10491,7 +11010,6 @@ static void __devinit tg3_init_link_config(struct tg3 *tp) | |||
10491 | tp->link_config.speed = SPEED_INVALID; | 11010 | tp->link_config.speed = SPEED_INVALID; |
10492 | tp->link_config.duplex = DUPLEX_INVALID; | 11011 | tp->link_config.duplex = DUPLEX_INVALID; |
10493 | tp->link_config.autoneg = AUTONEG_ENABLE; | 11012 | tp->link_config.autoneg = AUTONEG_ENABLE; |
10494 | netif_carrier_off(tp->dev); | ||
10495 | tp->link_config.active_speed = SPEED_INVALID; | 11013 | tp->link_config.active_speed = SPEED_INVALID; |
10496 | tp->link_config.active_duplex = DUPLEX_INVALID; | 11014 | tp->link_config.active_duplex = DUPLEX_INVALID; |
10497 | tp->link_config.phy_is_low_power = 0; | 11015 | tp->link_config.phy_is_low_power = 0; |
@@ -10550,6 +11068,8 @@ static char * __devinit tg3_phy_string(struct tg3 *tp) | |||
10550 | case PHY_ID_BCM5752: return "5752"; | 11068 | case PHY_ID_BCM5752: return "5752"; |
10551 | case PHY_ID_BCM5714: return "5714"; | 11069 | case PHY_ID_BCM5714: return "5714"; |
10552 | case PHY_ID_BCM5780: return "5780"; | 11070 | case PHY_ID_BCM5780: return "5780"; |
11071 | case PHY_ID_BCM5755: return "5755"; | ||
11072 | case PHY_ID_BCM5787: return "5787"; | ||
10553 | case PHY_ID_BCM8002: return "8002/serdes"; | 11073 | case PHY_ID_BCM8002: return "8002/serdes"; |
10554 | case 0: return "serdes"; | 11074 | case 0: return "serdes"; |
10555 | default: return "unknown"; | 11075 | default: return "unknown"; |
@@ -10848,11 +11368,12 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
10848 | tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE; | 11368 | tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE; |
10849 | } | 11369 | } |
10850 | 11370 | ||
10851 | /* TSO is off by default, user can enable using ethtool. */ | 11371 | /* TSO is on by default on chips that support hardware TSO. |
10852 | #if 0 | 11372 | * Firmware TSO on older chips gives lower performance, so it |
10853 | if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) | 11373 | * is off by default, but can be enabled using ethtool. |
11374 | */ | ||
11375 | if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) | ||
10854 | dev->features |= NETIF_F_TSO; | 11376 | dev->features |= NETIF_F_TSO; |
10855 | #endif | ||
10856 | 11377 | ||
10857 | #endif | 11378 | #endif |
10858 | 11379 | ||
@@ -10896,7 +11417,12 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
10896 | * checksumming. | 11417 | * checksumming. |
10897 | */ | 11418 | */ |
10898 | if ((tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) == 0) { | 11419 | if ((tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) == 0) { |
10899 | dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; | 11420 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
11421 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
11422 | dev->features |= NETIF_F_HW_CSUM; | ||
11423 | else | ||
11424 | dev->features |= NETIF_F_IP_CSUM; | ||
11425 | dev->features |= NETIF_F_SG; | ||
10900 | tp->tg3_flags |= TG3_FLAG_RX_CHECKSUMS; | 11426 | tp->tg3_flags |= TG3_FLAG_RX_CHECKSUMS; |
10901 | } else | 11427 | } else |
10902 | tp->tg3_flags &= ~TG3_FLAG_RX_CHECKSUMS; | 11428 | tp->tg3_flags &= ~TG3_FLAG_RX_CHECKSUMS; |
@@ -10949,6 +11475,8 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
10949 | (pdev->dma_mask == DMA_32BIT_MASK) ? 32 : | 11475 | (pdev->dma_mask == DMA_32BIT_MASK) ? 32 : |
10950 | (((u64) pdev->dma_mask == DMA_40BIT_MASK) ? 40 : 64)); | 11476 | (((u64) pdev->dma_mask == DMA_40BIT_MASK) ? 40 : 64)); |
10951 | 11477 | ||
11478 | netif_carrier_off(tp->dev); | ||
11479 | |||
10952 | return 0; | 11480 | return 0; |
10953 | 11481 | ||
10954 | err_out_iounmap: | 11482 | err_out_iounmap: |
@@ -11044,7 +11572,7 @@ static int tg3_resume(struct pci_dev *pdev) | |||
11044 | 11572 | ||
11045 | pci_restore_state(tp->pdev); | 11573 | pci_restore_state(tp->pdev); |
11046 | 11574 | ||
11047 | err = tg3_set_power_state(tp, 0); | 11575 | err = tg3_set_power_state(tp, PCI_D0); |
11048 | if (err) | 11576 | if (err) |
11049 | return err; | 11577 | return err; |
11050 | 11578 | ||