aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tg3.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r--drivers/net/tg3.c140
1 files changed, 106 insertions, 34 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index e7dc653d5bd6..caf4102b54ce 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -3532,9 +3532,23 @@ static inline int tg3_4g_overflow_test(dma_addr_t mapping, int len)
3532 (base + len + 8 < base)); 3532 (base + len + 8 < base));
3533} 3533}
3534 3534
3535/* Test for DMA addresses > 40-bit */
3536static inline int tg3_40bit_overflow_test(struct tg3 *tp, dma_addr_t mapping,
3537 int len)
3538{
3539#if defined(CONFIG_HIGHMEM) && (BITS_PER_LONG == 64)
3540 if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)
3541 return (((u64) mapping + len) > DMA_40BIT_MASK);
3542 return 0;
3543#else
3544 return 0;
3545#endif
3546}
3547
3535static void tg3_set_txd(struct tg3 *, int, dma_addr_t, int, u32, u32); 3548static void tg3_set_txd(struct tg3 *, int, dma_addr_t, int, u32, u32);
3536 3549
3537static int tigon3_4gb_hwbug_workaround(struct tg3 *tp, struct sk_buff *skb, 3550/* Workaround 4GB and 40-bit hardware DMA bugs. */
3551static int tigon3_dma_hwbug_workaround(struct tg3 *tp, struct sk_buff *skb,
3538 u32 last_plus_one, u32 *start, 3552 u32 last_plus_one, u32 *start,
3539 u32 base_flags, u32 mss) 3553 u32 base_flags, u32 mss)
3540{ 3554{
@@ -3742,6 +3756,9 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3742 if (tg3_4g_overflow_test(mapping, len)) 3756 if (tg3_4g_overflow_test(mapping, len))
3743 would_hit_hwbug = 1; 3757 would_hit_hwbug = 1;
3744 3758
3759 if (tg3_40bit_overflow_test(tp, mapping, len))
3760 would_hit_hwbug = 1;
3761
3745 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) 3762 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO)
3746 tg3_set_txd(tp, entry, mapping, len, 3763 tg3_set_txd(tp, entry, mapping, len,
3747 base_flags, (i == last)|(mss << 1)); 3764 base_flags, (i == last)|(mss << 1));
@@ -3763,7 +3780,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3763 /* If the workaround fails due to memory/mapping 3780 /* If the workaround fails due to memory/mapping
3764 * failure, silently drop this packet. 3781 * failure, silently drop this packet.
3765 */ 3782 */
3766 if (tigon3_4gb_hwbug_workaround(tp, skb, last_plus_one, 3783 if (tigon3_dma_hwbug_workaround(tp, skb, last_plus_one,
3767 &start, base_flags, mss)) 3784 &start, base_flags, mss))
3768 goto out_unlock; 3785 goto out_unlock;
3769 3786
@@ -9408,6 +9425,15 @@ static int __devinit tg3_is_sun_570X(struct tg3 *tp)
9408 return 0; 9425 return 0;
9409 if (venid == PCI_VENDOR_ID_SUN) 9426 if (venid == PCI_VENDOR_ID_SUN)
9410 return 1; 9427 return 1;
9428
9429 /* TG3 chips onboard the SunBlade-2500 don't have the
9430 * subsystem-vendor-id set to PCI_VENDOR_ID_SUN but they
9431 * are distinguishable from non-Sun variants by being
9432 * named "network" by the firmware. Non-Sun cards will
9433 * show up as being named "ethernet".
9434 */
9435 if (!strcmp(pcp->prom_name, "network"))
9436 return 1;
9411 } 9437 }
9412 return 0; 9438 return 0;
9413} 9439}
@@ -9526,12 +9552,36 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
9526 } 9552 }
9527 } 9553 }
9528 9554
9529 /* Find msi capability. */ 9555 /* The EPB bridge inside 5714, 5715, and 5780 cannot support
9556 * DMA addresses > 40-bit. This bridge may have other additional
9557 * 57xx devices behind it in some 4-port NIC designs for example.
9558 * Any tg3 device found behind the bridge will also need the 40-bit
9559 * DMA workaround.
9560 */
9530 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780 || 9561 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780 ||
9531 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) { 9562 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) {
9532 tp->tg3_flags2 |= TG3_FLG2_5780_CLASS; 9563 tp->tg3_flags2 |= TG3_FLG2_5780_CLASS;
9564 tp->tg3_flags |= TG3_FLAG_40BIT_DMA_BUG;
9533 tp->msi_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_MSI); 9565 tp->msi_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_MSI);
9534 } 9566 }
9567 else {
9568 struct pci_dev *bridge = NULL;
9569
9570 do {
9571 bridge = pci_get_device(PCI_VENDOR_ID_SERVERWORKS,
9572 PCI_DEVICE_ID_SERVERWORKS_EPB,
9573 bridge);
9574 if (bridge && bridge->subordinate &&
9575 (bridge->subordinate->number <=
9576 tp->pdev->bus->number) &&
9577 (bridge->subordinate->subordinate >=
9578 tp->pdev->bus->number)) {
9579 tp->tg3_flags |= TG3_FLAG_40BIT_DMA_BUG;
9580 pci_dev_put(bridge);
9581 break;
9582 }
9583 } while (bridge);
9584 }
9535 9585
9536 /* Initialize misc host control in PCI block. */ 9586 /* Initialize misc host control in PCI block. */
9537 tp->misc_host_ctrl |= (misc_ctrl_reg & 9587 tp->misc_host_ctrl |= (misc_ctrl_reg &
@@ -10277,7 +10327,14 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
10277 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { 10327 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
10278 u32 ccval = (tr32(TG3PCI_CLOCK_CTRL) & 0x1f); 10328 u32 ccval = (tr32(TG3PCI_CLOCK_CTRL) & 0x1f);
10279 10329
10280 if (ccval == 0x6 || ccval == 0x7) 10330 /* If the 5704 is behind the EPB bridge, we can
10331 * do the less restrictive ONE_DMA workaround for
10332 * better performance.
10333 */
10334 if ((tp->tg3_flags & TG3_FLAG_40BIT_DMA_BUG) &&
10335 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
10336 tp->dma_rwctrl |= 0x8000;
10337 else if (ccval == 0x6 || ccval == 0x7)
10281 tp->dma_rwctrl |= DMA_RWCTRL_ONE_DMA; 10338 tp->dma_rwctrl |= DMA_RWCTRL_ONE_DMA;
10282 10339
10283 /* Set bit 23 to enable PCIX hw bug fix */ 10340 /* Set bit 23 to enable PCIX hw bug fix */
@@ -10517,8 +10574,6 @@ static char * __devinit tg3_bus_string(struct tg3 *tp, char *str)
10517 strcat(str, "66MHz"); 10574 strcat(str, "66MHz");
10518 else if (clock_ctrl == 6) 10575 else if (clock_ctrl == 6)
10519 strcat(str, "100MHz"); 10576 strcat(str, "100MHz");
10520 else if (clock_ctrl == 7)
10521 strcat(str, "133MHz");
10522 } else { 10577 } else {
10523 strcpy(str, "PCI:"); 10578 strcpy(str, "PCI:");
10524 if (tp->tg3_flags & TG3_FLAG_PCI_HIGH_SPEED) 10579 if (tp->tg3_flags & TG3_FLAG_PCI_HIGH_SPEED)
@@ -10599,8 +10654,9 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10599 unsigned long tg3reg_base, tg3reg_len; 10654 unsigned long tg3reg_base, tg3reg_len;
10600 struct net_device *dev; 10655 struct net_device *dev;
10601 struct tg3 *tp; 10656 struct tg3 *tp;
10602 int i, err, pci_using_dac, pm_cap; 10657 int i, err, pm_cap;
10603 char str[40]; 10658 char str[40];
10659 u64 dma_mask, persist_dma_mask;
10604 10660
10605 if (tg3_version_printed++ == 0) 10661 if (tg3_version_printed++ == 0)
10606 printk(KERN_INFO "%s", version); 10662 printk(KERN_INFO "%s", version);
@@ -10637,26 +10693,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10637 goto err_out_free_res; 10693 goto err_out_free_res;
10638 } 10694 }
10639 10695
10640 /* Configure DMA attributes. */
10641 err = pci_set_dma_mask(pdev, DMA_64BIT_MASK);
10642 if (!err) {
10643 pci_using_dac = 1;
10644 err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
10645 if (err < 0) {
10646 printk(KERN_ERR PFX "Unable to obtain 64 bit DMA "
10647 "for consistent allocations\n");
10648 goto err_out_free_res;
10649 }
10650 } else {
10651 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
10652 if (err) {
10653 printk(KERN_ERR PFX "No usable DMA configuration, "
10654 "aborting.\n");
10655 goto err_out_free_res;
10656 }
10657 pci_using_dac = 0;
10658 }
10659
10660 tg3reg_base = pci_resource_start(pdev, 0); 10696 tg3reg_base = pci_resource_start(pdev, 0);
10661 tg3reg_len = pci_resource_len(pdev, 0); 10697 tg3reg_len = pci_resource_len(pdev, 0);
10662 10698
@@ -10670,8 +10706,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10670 SET_MODULE_OWNER(dev); 10706 SET_MODULE_OWNER(dev);
10671 SET_NETDEV_DEV(dev, &pdev->dev); 10707 SET_NETDEV_DEV(dev, &pdev->dev);
10672 10708
10673 if (pci_using_dac)
10674 dev->features |= NETIF_F_HIGHDMA;
10675 dev->features |= NETIF_F_LLTX; 10709 dev->features |= NETIF_F_LLTX;
10676#if TG3_VLAN_TAG_USED 10710#if TG3_VLAN_TAG_USED
10677 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; 10711 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
@@ -10756,6 +10790,45 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10756 goto err_out_iounmap; 10790 goto err_out_iounmap;
10757 } 10791 }
10758 10792
10793 /* The EPB bridge inside 5714, 5715, and 5780 and any
10794 * device behind the EPB cannot support DMA addresses > 40-bit.
10795 * On 64-bit systems with IOMMU, use 40-bit dma_mask.
10796 * On 64-bit systems without IOMMU, use 64-bit dma_mask and
10797 * do DMA address check in tg3_start_xmit().
10798 */
10799 if (tp->tg3_flags2 & TG3_FLG2_IS_5788)
10800 persist_dma_mask = dma_mask = DMA_32BIT_MASK;
10801 else if (tp->tg3_flags & TG3_FLAG_40BIT_DMA_BUG) {
10802 persist_dma_mask = dma_mask = DMA_40BIT_MASK;
10803#ifdef CONFIG_HIGHMEM
10804 dma_mask = DMA_64BIT_MASK;
10805#endif
10806 } else
10807 persist_dma_mask = dma_mask = DMA_64BIT_MASK;
10808
10809 /* Configure DMA attributes. */
10810 if (dma_mask > DMA_32BIT_MASK) {
10811 err = pci_set_dma_mask(pdev, dma_mask);
10812 if (!err) {
10813 dev->features |= NETIF_F_HIGHDMA;
10814 err = pci_set_consistent_dma_mask(pdev,
10815 persist_dma_mask);
10816 if (err < 0) {
10817 printk(KERN_ERR PFX "Unable to obtain 64 bit "
10818 "DMA for consistent allocations\n");
10819 goto err_out_iounmap;
10820 }
10821 }
10822 }
10823 if (err || dma_mask == DMA_32BIT_MASK) {
10824 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
10825 if (err) {
10826 printk(KERN_ERR PFX "No usable DMA configuration, "
10827 "aborting.\n");
10828 goto err_out_iounmap;
10829 }
10830 }
10831
10759 tg3_init_bufmgr_config(tp); 10832 tg3_init_bufmgr_config(tp);
10760 10833
10761#if TG3_TSO_SUPPORT != 0 10834#if TG3_TSO_SUPPORT != 0
@@ -10824,9 +10897,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10824 } else 10897 } else
10825 tp->tg3_flags &= ~TG3_FLAG_RX_CHECKSUMS; 10898 tp->tg3_flags &= ~TG3_FLAG_RX_CHECKSUMS;
10826 10899
10827 if (tp->tg3_flags2 & TG3_FLG2_IS_5788)
10828 dev->features &= ~NETIF_F_HIGHDMA;
10829
10830 /* flow control autonegotiation is default behavior */ 10900 /* flow control autonegotiation is default behavior */
10831 tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG; 10901 tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG;
10832 10902
@@ -10870,8 +10940,10 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10870 (tp->tg3_flags & TG3_FLAG_SPLIT_MODE) != 0, 10940 (tp->tg3_flags & TG3_FLAG_SPLIT_MODE) != 0,
10871 (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED) == 0, 10941 (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED) == 0,
10872 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) != 0); 10942 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) != 0);
10873 printk(KERN_INFO "%s: dma_rwctrl[%08x]\n", 10943 printk(KERN_INFO "%s: dma_rwctrl[%08x] dma_mask[%d-bit]\n",
10874 dev->name, tp->dma_rwctrl); 10944 dev->name, tp->dma_rwctrl,
10945 (pdev->dma_mask == DMA_32BIT_MASK) ? 32 :
10946 (((u64) pdev->dma_mask == DMA_40BIT_MASK) ? 40 : 64));
10875 10947
10876 return 0; 10948 return 0;
10877 10949