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.c157
1 files changed, 130 insertions, 27 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index b2ddd4522a87..f645921aff8b 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -15,7 +15,6 @@
15 * notice is accompanying it. 15 * notice is accompanying it.
16 */ 16 */
17 17
18#include <linux/config.h>
19 18
20#include <linux/module.h> 19#include <linux/module.h>
21#include <linux/moduleparam.h> 20#include <linux/moduleparam.h>
@@ -69,8 +68,8 @@
69 68
70#define DRV_MODULE_NAME "tg3" 69#define DRV_MODULE_NAME "tg3"
71#define PFX DRV_MODULE_NAME ": " 70#define PFX DRV_MODULE_NAME ": "
72#define DRV_MODULE_VERSION "3.60" 71#define DRV_MODULE_VERSION "3.62"
73#define DRV_MODULE_RELDATE "June 17, 2006" 72#define DRV_MODULE_RELDATE "June 30, 2006"
74 73
75#define TG3_DEF_MAC_MODE 0 74#define TG3_DEF_MAC_MODE 0
76#define TG3_DEF_RX_MODE 0 75#define TG3_DEF_RX_MODE 0
@@ -3195,7 +3194,7 @@ static int tg3_vlan_rx(struct tg3 *tp, struct sk_buff *skb, u16 vlan_tag)
3195 */ 3194 */
3196static int tg3_rx(struct tg3 *tp, int budget) 3195static int tg3_rx(struct tg3 *tp, int budget)
3197{ 3196{
3198 u32 work_mask; 3197 u32 work_mask, rx_std_posted = 0;
3199 u32 sw_idx = tp->rx_rcb_ptr; 3198 u32 sw_idx = tp->rx_rcb_ptr;
3200 u16 hw_idx; 3199 u16 hw_idx;
3201 int received; 3200 int received;
@@ -3222,6 +3221,7 @@ static int tg3_rx(struct tg3 *tp, int budget)
3222 mapping); 3221 mapping);
3223 skb = tp->rx_std_buffers[desc_idx].skb; 3222 skb = tp->rx_std_buffers[desc_idx].skb;
3224 post_ptr = &tp->rx_std_ptr; 3223 post_ptr = &tp->rx_std_ptr;
3224 rx_std_posted++;
3225 } else if (opaque_key == RXD_OPAQUE_RING_JUMBO) { 3225 } else if (opaque_key == RXD_OPAQUE_RING_JUMBO) {
3226 dma_addr = pci_unmap_addr(&tp->rx_jumbo_buffers[desc_idx], 3226 dma_addr = pci_unmap_addr(&tp->rx_jumbo_buffers[desc_idx],
3227 mapping); 3227 mapping);
@@ -3309,6 +3309,15 @@ static int tg3_rx(struct tg3 *tp, int budget)
3309 3309
3310next_pkt: 3310next_pkt:
3311 (*post_ptr)++; 3311 (*post_ptr)++;
3312
3313 if (unlikely(rx_std_posted >= tp->rx_std_max_post)) {
3314 u32 idx = *post_ptr % TG3_RX_RING_SIZE;
3315
3316 tw32_rx_mbox(MAILBOX_RCV_STD_PROD_IDX +
3317 TG3_64BIT_REG_LOW, idx);
3318 work_mask &= ~RXD_OPAQUE_RING_STD;
3319 rx_std_posted = 0;
3320 }
3312next_pkt_nopost: 3321next_pkt_nopost:
3313 sw_idx++; 3322 sw_idx++;
3314 sw_idx %= TG3_RX_RCB_RING_SIZE(tp); 3323 sw_idx %= TG3_RX_RCB_RING_SIZE(tp);
@@ -3780,7 +3789,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3780#if TG3_TSO_SUPPORT != 0 3789#if TG3_TSO_SUPPORT != 0
3781 mss = 0; 3790 mss = 0;
3782 if (skb->len > (tp->dev->mtu + ETH_HLEN) && 3791 if (skb->len > (tp->dev->mtu + ETH_HLEN) &&
3783 (mss = skb_shinfo(skb)->tso_size) != 0) { 3792 (mss = skb_shinfo(skb)->gso_size) != 0) {
3784 int tcp_opt_len, ip_tcp_len; 3793 int tcp_opt_len, ip_tcp_len;
3785 3794
3786 if (skb_header_cloned(skb) && 3795 if (skb_header_cloned(skb) &&
@@ -3789,18 +3798,24 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3789 goto out_unlock; 3798 goto out_unlock;
3790 } 3799 }
3791 3800
3792 tcp_opt_len = ((skb->h.th->doff - 5) * 4); 3801 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
3793 ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr); 3802 mss |= (skb_headlen(skb) - ETH_HLEN) << 9;
3803 else {
3804 tcp_opt_len = ((skb->h.th->doff - 5) * 4);
3805 ip_tcp_len = (skb->nh.iph->ihl * 4) +
3806 sizeof(struct tcphdr);
3807
3808 skb->nh.iph->check = 0;
3809 skb->nh.iph->tot_len = htons(mss + ip_tcp_len +
3810 tcp_opt_len);
3811 mss |= (ip_tcp_len + tcp_opt_len) << 9;
3812 }
3794 3813
3795 base_flags |= (TXD_FLAG_CPU_PRE_DMA | 3814 base_flags |= (TXD_FLAG_CPU_PRE_DMA |
3796 TXD_FLAG_CPU_POST_DMA); 3815 TXD_FLAG_CPU_POST_DMA);
3797 3816
3798 skb->nh.iph->check = 0;
3799 skb->nh.iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
3800
3801 skb->h.th->check = 0; 3817 skb->h.th->check = 0;
3802 3818
3803 mss |= (ip_tcp_len + tcp_opt_len) << 9;
3804 } 3819 }
3805 else if (skb->ip_summed == CHECKSUM_HW) 3820 else if (skb->ip_summed == CHECKSUM_HW)
3806 base_flags |= TXD_FLAG_TCPUDP_CSUM; 3821 base_flags |= TXD_FLAG_TCPUDP_CSUM;
@@ -3870,6 +3885,40 @@ out_unlock:
3870 return NETDEV_TX_OK; 3885 return NETDEV_TX_OK;
3871} 3886}
3872 3887
3888#if TG3_TSO_SUPPORT != 0
3889static int tg3_start_xmit_dma_bug(struct sk_buff *, struct net_device *);
3890
3891/* Use GSO to workaround a rare TSO bug that may be triggered when the
3892 * TSO header is greater than 80 bytes.
3893 */
3894static int tg3_tso_bug(struct tg3 *tp, struct sk_buff *skb)
3895{
3896 struct sk_buff *segs, *nskb;
3897
3898 /* Estimate the number of fragments in the worst case */
3899 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->gso_segs * 3))) {
3900 netif_stop_queue(tp->dev);
3901 return NETDEV_TX_BUSY;
3902 }
3903
3904 segs = skb_gso_segment(skb, tp->dev->features & ~NETIF_F_TSO);
3905 if (unlikely(IS_ERR(segs)))
3906 goto tg3_tso_bug_end;
3907
3908 do {
3909 nskb = segs;
3910 segs = segs->next;
3911 nskb->next = NULL;
3912 tg3_start_xmit_dma_bug(nskb, tp->dev);
3913 } while (segs);
3914
3915tg3_tso_bug_end:
3916 dev_kfree_skb(skb);
3917
3918 return NETDEV_TX_OK;
3919}
3920#endif
3921
3873/* hard_start_xmit for devices that have the 4G bug and/or 40-bit bug and 3922/* hard_start_xmit for devices that have the 4G bug and/or 40-bit bug and
3874 * support TG3_FLG2_HW_TSO_1 or firmware TSO only. 3923 * support TG3_FLG2_HW_TSO_1 or firmware TSO only.
3875 */ 3924 */
@@ -3905,8 +3954,8 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
3905#if TG3_TSO_SUPPORT != 0 3954#if TG3_TSO_SUPPORT != 0
3906 mss = 0; 3955 mss = 0;
3907 if (skb->len > (tp->dev->mtu + ETH_HLEN) && 3956 if (skb->len > (tp->dev->mtu + ETH_HLEN) &&
3908 (mss = skb_shinfo(skb)->tso_size) != 0) { 3957 (mss = skb_shinfo(skb)->gso_size) != 0) {
3909 int tcp_opt_len, ip_tcp_len; 3958 int tcp_opt_len, ip_tcp_len, hdr_len;
3910 3959
3911 if (skb_header_cloned(skb) && 3960 if (skb_header_cloned(skb) &&
3912 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) { 3961 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
@@ -3917,11 +3966,16 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
3917 tcp_opt_len = ((skb->h.th->doff - 5) * 4); 3966 tcp_opt_len = ((skb->h.th->doff - 5) * 4);
3918 ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr); 3967 ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr);
3919 3968
3969 hdr_len = ip_tcp_len + tcp_opt_len;
3970 if (unlikely((ETH_HLEN + hdr_len) > 80) &&
3971 (tp->tg3_flags2 & TG3_FLG2_HW_TSO_1_BUG))
3972 return (tg3_tso_bug(tp, skb));
3973
3920 base_flags |= (TXD_FLAG_CPU_PRE_DMA | 3974 base_flags |= (TXD_FLAG_CPU_PRE_DMA |
3921 TXD_FLAG_CPU_POST_DMA); 3975 TXD_FLAG_CPU_POST_DMA);
3922 3976
3923 skb->nh.iph->check = 0; 3977 skb->nh.iph->check = 0;
3924 skb->nh.iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len); 3978 skb->nh.iph->tot_len = htons(mss + hdr_len);
3925 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) { 3979 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) {
3926 skb->h.th->check = 0; 3980 skb->h.th->check = 0;
3927 base_flags &= ~TXD_FLAG_TCPUDP_CSUM; 3981 base_flags &= ~TXD_FLAG_TCPUDP_CSUM;
@@ -5981,7 +6035,13 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
5981 } 6035 }
5982 6036
5983 /* Setup replenish threshold. */ 6037 /* Setup replenish threshold. */
5984 tw32(RCVBDI_STD_THRESH, tp->rx_pending / 8); 6038 val = tp->rx_pending / 8;
6039 if (val == 0)
6040 val = 1;
6041 else if (val > tp->rx_std_max_post)
6042 val = tp->rx_std_max_post;
6043
6044 tw32(RCVBDI_STD_THRESH, val);
5985 6045
5986 /* Initialize TG3_BDINFO's at: 6046 /* Initialize TG3_BDINFO's at:
5987 * RCVDBDI_STD_BD: standard eth size rx ring 6047 * RCVDBDI_STD_BD: standard eth size rx ring
@@ -6141,8 +6201,12 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6141#endif 6201#endif
6142 6202
6143 /* Receive/send statistics. */ 6203 /* Receive/send statistics. */
6144 if ((rdmac_mode & RDMAC_MODE_FIFO_SIZE_128) && 6204 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) {
6145 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE)) { 6205 val = tr32(RCVLPC_STATS_ENABLE);
6206 val &= ~RCVLPC_STATSENAB_DACK_FIX;
6207 tw32(RCVLPC_STATS_ENABLE, val);
6208 } else if ((rdmac_mode & RDMAC_MODE_FIFO_SIZE_128) &&
6209 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE)) {
6146 val = tr32(RCVLPC_STATS_ENABLE); 6210 val = tr32(RCVLPC_STATS_ENABLE);
6147 val &= ~RCVLPC_STATSENAB_LNGBRST_RFIX; 6211 val &= ~RCVLPC_STATSENAB_LNGBRST_RFIX;
6148 tw32(RCVLPC_STATS_ENABLE, val); 6212 tw32(RCVLPC_STATS_ENABLE, val);
@@ -6644,12 +6708,12 @@ static int tg3_request_irq(struct tg3 *tp)
6644 fn = tg3_msi; 6708 fn = tg3_msi;
6645 if (tp->tg3_flags2 & TG3_FLG2_1SHOT_MSI) 6709 if (tp->tg3_flags2 & TG3_FLG2_1SHOT_MSI)
6646 fn = tg3_msi_1shot; 6710 fn = tg3_msi_1shot;
6647 flags = SA_SAMPLE_RANDOM; 6711 flags = IRQF_SAMPLE_RANDOM;
6648 } else { 6712 } else {
6649 fn = tg3_interrupt; 6713 fn = tg3_interrupt;
6650 if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) 6714 if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)
6651 fn = tg3_interrupt_tagged; 6715 fn = tg3_interrupt_tagged;
6652 flags = SA_SHIRQ | SA_SAMPLE_RANDOM; 6716 flags = IRQF_SHARED | IRQF_SAMPLE_RANDOM;
6653 } 6717 }
6654 return (request_irq(tp->pdev->irq, fn, flags, dev->name, dev)); 6718 return (request_irq(tp->pdev->irq, fn, flags, dev->name, dev));
6655} 6719}
@@ -6668,7 +6732,7 @@ static int tg3_test_interrupt(struct tg3 *tp)
6668 free_irq(tp->pdev->irq, dev); 6732 free_irq(tp->pdev->irq, dev);
6669 6733
6670 err = request_irq(tp->pdev->irq, tg3_test_isr, 6734 err = request_irq(tp->pdev->irq, tg3_test_isr,
6671 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); 6735 IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
6672 if (err) 6736 if (err)
6673 return err; 6737 return err;
6674 6738
@@ -7829,6 +7893,12 @@ static int tg3_set_tso(struct net_device *dev, u32 value)
7829 return -EINVAL; 7893 return -EINVAL;
7830 return 0; 7894 return 0;
7831 } 7895 }
7896 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO_2) {
7897 if (value)
7898 dev->features |= NETIF_F_TSO6;
7899 else
7900 dev->features &= ~NETIF_F_TSO6;
7901 }
7832 return ethtool_op_set_tso(dev, value); 7902 return ethtool_op_set_tso(dev, value);
7833} 7903}
7834#endif 7904#endif
@@ -8738,6 +8808,9 @@ static void tg3_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
8738{ 8808{
8739 struct tg3 *tp = netdev_priv(dev); 8809 struct tg3 *tp = netdev_priv(dev);
8740 8810
8811 if (netif_running(dev))
8812 tg3_netif_stop(tp);
8813
8741 tg3_full_lock(tp, 0); 8814 tg3_full_lock(tp, 0);
8742 8815
8743 tp->vlgrp = grp; 8816 tp->vlgrp = grp;
@@ -8746,16 +8819,25 @@ static void tg3_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
8746 __tg3_set_rx_mode(dev); 8819 __tg3_set_rx_mode(dev);
8747 8820
8748 tg3_full_unlock(tp); 8821 tg3_full_unlock(tp);
8822
8823 if (netif_running(dev))
8824 tg3_netif_start(tp);
8749} 8825}
8750 8826
8751static void tg3_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) 8827static void tg3_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
8752{ 8828{
8753 struct tg3 *tp = netdev_priv(dev); 8829 struct tg3 *tp = netdev_priv(dev);
8754 8830
8831 if (netif_running(dev))
8832 tg3_netif_stop(tp);
8833
8755 tg3_full_lock(tp, 0); 8834 tg3_full_lock(tp, 0);
8756 if (tp->vlgrp) 8835 if (tp->vlgrp)
8757 tp->vlgrp->vlan_devices[vid] = NULL; 8836 tp->vlgrp->vlan_devices[vid] = NULL;
8758 tg3_full_unlock(tp); 8837 tg3_full_unlock(tp);
8838
8839 if (netif_running(dev))
8840 tg3_netif_start(tp);
8759} 8841}
8760#endif 8842#endif
8761 8843
@@ -10160,8 +10242,14 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10160 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) { 10242 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) {
10161 tp->tg3_flags2 |= TG3_FLG2_HW_TSO_2; 10243 tp->tg3_flags2 |= TG3_FLG2_HW_TSO_2;
10162 tp->tg3_flags2 |= TG3_FLG2_1SHOT_MSI; 10244 tp->tg3_flags2 |= TG3_FLG2_1SHOT_MSI;
10163 } else 10245 } else {
10164 tp->tg3_flags2 |= TG3_FLG2_HW_TSO_1; 10246 tp->tg3_flags2 |= TG3_FLG2_HW_TSO_1 |
10247 TG3_FLG2_HW_TSO_1_BUG;
10248 if (GET_ASIC_REV(tp->pci_chip_rev_id) ==
10249 ASIC_REV_5750 &&
10250 tp->pci_chip_rev_id >= CHIPREV_ID_5750_C2)
10251 tp->tg3_flags2 &= ~TG3_FLG2_HW_TSO_1_BUG;
10252 }
10165 } 10253 }
10166 10254
10167 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && 10255 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
@@ -10533,6 +10621,16 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10533 (tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) 10621 (tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0)
10534 tp->rx_offset = 0; 10622 tp->rx_offset = 0;
10535 10623
10624 tp->rx_std_max_post = TG3_RX_RING_SIZE;
10625
10626 /* Increment the rx prod index on the rx std ring by at most
10627 * 8 for these chips to workaround hw errata.
10628 */
10629 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 ||
10630 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 ||
10631 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
10632 tp->rx_std_max_post = 8;
10633
10536 /* By default, disable wake-on-lan. User can change this 10634 /* By default, disable wake-on-lan. User can change this
10537 * using ETHTOOL_SWOL. 10635 * using ETHTOOL_SWOL.
10538 */ 10636 */
@@ -10549,11 +10647,13 @@ static int __devinit tg3_get_macaddr_sparc(struct tg3 *tp)
10549 struct pcidev_cookie *pcp = pdev->sysdata; 10647 struct pcidev_cookie *pcp = pdev->sysdata;
10550 10648
10551 if (pcp != NULL) { 10649 if (pcp != NULL) {
10552 int node = pcp->prom_node; 10650 unsigned char *addr;
10651 int len;
10553 10652
10554 if (prom_getproplen(node, "local-mac-address") == 6) { 10653 addr = of_get_property(pcp->prom_node, "local-mac-address",
10555 prom_getproperty(node, "local-mac-address", 10654 &len);
10556 dev->dev_addr, 6); 10655 if (addr && len == 6) {
10656 memcpy(dev->dev_addr, addr, 6);
10557 memcpy(dev->perm_addr, dev->dev_addr, 6); 10657 memcpy(dev->perm_addr, dev->dev_addr, 6);
10558 return 0; 10658 return 0;
10559 } 10659 }
@@ -11419,8 +11519,11 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11419 * Firmware TSO on older chips gives lower performance, so it 11519 * Firmware TSO on older chips gives lower performance, so it
11420 * is off by default, but can be enabled using ethtool. 11520 * is off by default, but can be enabled using ethtool.
11421 */ 11521 */
11422 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) 11522 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) {
11423 dev->features |= NETIF_F_TSO; 11523 dev->features |= NETIF_F_TSO;
11524 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO_2)
11525 dev->features |= NETIF_F_TSO6;
11526 }
11424 11527
11425#endif 11528#endif
11426 11529