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.c264
1 files changed, 110 insertions, 154 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 7841a8f69998..6be418591df9 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 2001, 2002, 2003, 2004 David S. Miller (davem@redhat.com) 4 * Copyright (C) 2001, 2002, 2003, 2004 David S. Miller (davem@redhat.com)
5 * Copyright (C) 2001, 2002, 2003 Jeff Garzik (jgarzik@pobox.com) 5 * Copyright (C) 2001, 2002, 2003 Jeff Garzik (jgarzik@pobox.com)
6 * Copyright (C) 2004 Sun Microsystems Inc. 6 * Copyright (C) 2004 Sun Microsystems Inc.
7 * Copyright (C) 2005-2010 Broadcom Corporation. 7 * Copyright (C) 2005-2011 Broadcom Corporation.
8 * 8 *
9 * Firmware is: 9 * Firmware is:
10 * Derived from proprietary unpublished source code, 10 * Derived from proprietary unpublished source code,
@@ -60,20 +60,14 @@
60#define BAR_0 0 60#define BAR_0 0
61#define BAR_2 2 61#define BAR_2 2
62 62
63#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
64#define TG3_VLAN_TAG_USED 1
65#else
66#define TG3_VLAN_TAG_USED 0
67#endif
68
69#include "tg3.h" 63#include "tg3.h"
70 64
71#define DRV_MODULE_NAME "tg3" 65#define DRV_MODULE_NAME "tg3"
72#define TG3_MAJ_NUM 3 66#define TG3_MAJ_NUM 3
73#define TG3_MIN_NUM 116 67#define TG3_MIN_NUM 117
74#define DRV_MODULE_VERSION \ 68#define DRV_MODULE_VERSION \
75 __stringify(TG3_MAJ_NUM) "." __stringify(TG3_MIN_NUM) 69 __stringify(TG3_MAJ_NUM) "." __stringify(TG3_MIN_NUM)
76#define DRV_MODULE_RELDATE "December 3, 2010" 70#define DRV_MODULE_RELDATE "January 25, 2011"
77 71
78#define TG3_DEF_MAC_MODE 0 72#define TG3_DEF_MAC_MODE 0
79#define TG3_DEF_RX_MODE 0 73#define TG3_DEF_RX_MODE 0
@@ -134,9 +128,6 @@
134 TG3_TX_RING_SIZE) 128 TG3_TX_RING_SIZE)
135#define NEXT_TX(N) (((N) + 1) & (TG3_TX_RING_SIZE - 1)) 129#define NEXT_TX(N) (((N) + 1) & (TG3_TX_RING_SIZE - 1))
136 130
137#define TG3_RX_DMA_ALIGN 16
138#define TG3_RX_HEADROOM ALIGN(VLAN_HLEN, TG3_RX_DMA_ALIGN)
139
140#define TG3_DMA_BYTE_ENAB 64 131#define TG3_DMA_BYTE_ENAB 64
141 132
142#define TG3_RX_STD_DMA_SZ 1536 133#define TG3_RX_STD_DMA_SZ 1536
@@ -1785,9 +1776,29 @@ static void tg3_phy_eee_adjust(struct tg3 *tp, u32 current_link_up)
1785 tg3_phy_cl45_read(tp, MDIO_MMD_AN, 1776 tg3_phy_cl45_read(tp, MDIO_MMD_AN,
1786 TG3_CL45_D7_EEERES_STAT, &val); 1777 TG3_CL45_D7_EEERES_STAT, &val);
1787 1778
1788 if (val == TG3_CL45_D7_EEERES_STAT_LP_1000T || 1779 switch (val) {
1789 val == TG3_CL45_D7_EEERES_STAT_LP_100TX) 1780 case TG3_CL45_D7_EEERES_STAT_LP_1000T:
1781 switch (GET_ASIC_REV(tp->pci_chip_rev_id)) {
1782 case ASIC_REV_5717:
1783 case ASIC_REV_5719:
1784 case ASIC_REV_57765:
1785 /* Enable SM_DSP clock and tx 6dB coding. */
1786 val = MII_TG3_AUXCTL_SHDWSEL_AUXCTL |
1787 MII_TG3_AUXCTL_ACTL_SMDSP_ENA |
1788 MII_TG3_AUXCTL_ACTL_TX_6DB;
1789 tg3_writephy(tp, MII_TG3_AUX_CTRL, val);
1790
1791 tg3_phydsp_write(tp, MII_TG3_DSP_TAP26, 0x0000);
1792
1793 /* Turn off SM_DSP clock. */
1794 val = MII_TG3_AUXCTL_SHDWSEL_AUXCTL |
1795 MII_TG3_AUXCTL_ACTL_TX_6DB;
1796 tg3_writephy(tp, MII_TG3_AUX_CTRL, val);
1797 }
1798 /* Fallthrough */
1799 case TG3_CL45_D7_EEERES_STAT_LP_100TX:
1790 tp->setlpicnt = 2; 1800 tp->setlpicnt = 2;
1801 }
1791 } 1802 }
1792 1803
1793 if (!tp->setlpicnt) { 1804 if (!tp->setlpicnt) {
@@ -2977,11 +2988,19 @@ static void tg3_phy_copper_begin(struct tg3 *tp)
2977 MII_TG3_AUXCTL_ACTL_TX_6DB; 2988 MII_TG3_AUXCTL_ACTL_TX_6DB;
2978 tg3_writephy(tp, MII_TG3_AUX_CTRL, val); 2989 tg3_writephy(tp, MII_TG3_AUX_CTRL, val);
2979 2990
2980 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || 2991 switch (GET_ASIC_REV(tp->pci_chip_rev_id)) {
2981 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765) && 2992 case ASIC_REV_5717:
2982 !tg3_phydsp_read(tp, MII_TG3_DSP_CH34TP2, &val)) 2993 case ASIC_REV_57765:
2983 tg3_phydsp_write(tp, MII_TG3_DSP_CH34TP2, 2994 if (!tg3_phydsp_read(tp, MII_TG3_DSP_CH34TP2, &val))
2984 val | MII_TG3_DSP_CH34TP2_HIBW01); 2995 tg3_phydsp_write(tp, MII_TG3_DSP_CH34TP2, val |
2996 MII_TG3_DSP_CH34TP2_HIBW01);
2997 /* Fall through */
2998 case ASIC_REV_5719:
2999 val = MII_TG3_DSP_TAP26_ALNOKO |
3000 MII_TG3_DSP_TAP26_RMRXSTO |
3001 MII_TG3_DSP_TAP26_OPCSINPT;
3002 tg3_phydsp_write(tp, MII_TG3_DSP_TAP26, val);
3003 }
2985 3004
2986 val = 0; 3005 val = 0;
2987 if (tp->link_config.autoneg == AUTONEG_ENABLE) { 3006 if (tp->link_config.autoneg == AUTONEG_ENABLE) {
@@ -4722,8 +4741,6 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
4722 struct sk_buff *skb; 4741 struct sk_buff *skb;
4723 dma_addr_t dma_addr; 4742 dma_addr_t dma_addr;
4724 u32 opaque_key, desc_idx, *post_ptr; 4743 u32 opaque_key, desc_idx, *post_ptr;
4725 bool hw_vlan __maybe_unused = false;
4726 u16 vtag __maybe_unused = 0;
4727 4744
4728 desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK; 4745 desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK;
4729 opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK; 4746 opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK;
@@ -4782,12 +4799,12 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
4782 tg3_recycle_rx(tnapi, tpr, opaque_key, 4799 tg3_recycle_rx(tnapi, tpr, opaque_key,
4783 desc_idx, *post_ptr); 4800 desc_idx, *post_ptr);
4784 4801
4785 copy_skb = netdev_alloc_skb(tp->dev, len + VLAN_HLEN + 4802 copy_skb = netdev_alloc_skb(tp->dev, len +
4786 TG3_RAW_IP_ALIGN); 4803 TG3_RAW_IP_ALIGN);
4787 if (copy_skb == NULL) 4804 if (copy_skb == NULL)
4788 goto drop_it_no_recycle; 4805 goto drop_it_no_recycle;
4789 4806
4790 skb_reserve(copy_skb, TG3_RAW_IP_ALIGN + VLAN_HLEN); 4807 skb_reserve(copy_skb, TG3_RAW_IP_ALIGN);
4791 skb_put(copy_skb, len); 4808 skb_put(copy_skb, len);
4792 pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE); 4809 pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE);
4793 skb_copy_from_linear_data(skb, copy_skb->data, len); 4810 skb_copy_from_linear_data(skb, copy_skb->data, len);
@@ -4814,30 +4831,11 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
4814 } 4831 }
4815 4832
4816 if (desc->type_flags & RXD_FLAG_VLAN && 4833 if (desc->type_flags & RXD_FLAG_VLAN &&
4817 !(tp->rx_mode & RX_MODE_KEEP_VLAN_TAG)) { 4834 !(tp->rx_mode & RX_MODE_KEEP_VLAN_TAG))
4818 vtag = desc->err_vlan & RXD_VLAN_MASK; 4835 __vlan_hwaccel_put_tag(skb,
4819#if TG3_VLAN_TAG_USED 4836 desc->err_vlan & RXD_VLAN_MASK);
4820 if (tp->vlgrp)
4821 hw_vlan = true;
4822 else
4823#endif
4824 {
4825 struct vlan_ethhdr *ve = (struct vlan_ethhdr *)
4826 __skb_push(skb, VLAN_HLEN);
4827
4828 memmove(ve, skb->data + VLAN_HLEN,
4829 ETH_ALEN * 2);
4830 ve->h_vlan_proto = htons(ETH_P_8021Q);
4831 ve->h_vlan_TCI = htons(vtag);
4832 }
4833 }
4834 4837
4835#if TG3_VLAN_TAG_USED 4838 napi_gro_receive(&tnapi->napi, skb);
4836 if (hw_vlan)
4837 vlan_gro_receive(&tnapi->napi, tp->vlgrp, vtag, skb);
4838 else
4839#endif
4840 napi_gro_receive(&tnapi->napi, skb);
4841 4839
4842 received++; 4840 received++;
4843 budget--; 4841 budget--;
@@ -5740,11 +5738,9 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb,
5740 base_flags |= TXD_FLAG_TCPUDP_CSUM; 5738 base_flags |= TXD_FLAG_TCPUDP_CSUM;
5741 } 5739 }
5742 5740
5743#if TG3_VLAN_TAG_USED
5744 if (vlan_tx_tag_present(skb)) 5741 if (vlan_tx_tag_present(skb))
5745 base_flags |= (TXD_FLAG_VLAN | 5742 base_flags |= (TXD_FLAG_VLAN |
5746 (vlan_tx_tag_get(skb) << 16)); 5743 (vlan_tx_tag_get(skb) << 16));
5747#endif
5748 5744
5749 len = skb_headlen(skb); 5745 len = skb_headlen(skb);
5750 5746
@@ -5986,11 +5982,10 @@ static netdev_tx_t tg3_start_xmit_dma_bug(struct sk_buff *skb,
5986 } 5982 }
5987 } 5983 }
5988 } 5984 }
5989#if TG3_VLAN_TAG_USED 5985
5990 if (vlan_tx_tag_present(skb)) 5986 if (vlan_tx_tag_present(skb))
5991 base_flags |= (TXD_FLAG_VLAN | 5987 base_flags |= (TXD_FLAG_VLAN |
5992 (vlan_tx_tag_get(skb) << 16)); 5988 (vlan_tx_tag_get(skb) << 16));
5993#endif
5994 5989
5995 if ((tp->tg3_flags3 & TG3_FLG3_USE_JUMBO_BDFLAG) && 5990 if ((tp->tg3_flags3 & TG3_FLG3_USE_JUMBO_BDFLAG) &&
5996 !mss && skb->len > VLAN_ETH_FRAME_LEN) 5991 !mss && skb->len > VLAN_ETH_FRAME_LEN)
@@ -7834,7 +7829,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
7834 TG3_CPMU_DBTMR1_LNKIDLE_2047US); 7829 TG3_CPMU_DBTMR1_LNKIDLE_2047US);
7835 7830
7836 tw32_f(TG3_CPMU_EEE_DBTMR2, 7831 tw32_f(TG3_CPMU_EEE_DBTMR2,
7837 TG3_CPMU_DBTMR1_APE_TX_2047US | 7832 TG3_CPMU_DBTMR2_APE_TX_2047US |
7838 TG3_CPMU_DBTMR2_TXIDXEQ_2047US); 7833 TG3_CPMU_DBTMR2_TXIDXEQ_2047US);
7839 } 7834 }
7840 7835
@@ -8108,8 +8103,9 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
8108 /* Program the jumbo buffer descriptor ring control 8103 /* Program the jumbo buffer descriptor ring control
8109 * blocks on those devices that have them. 8104 * blocks on those devices that have them.
8110 */ 8105 */
8111 if ((tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) && 8106 if (tp->pci_chip_rev_id == CHIPREV_ID_5719_A0 ||
8112 !(tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) { 8107 ((tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) &&
8108 !(tp->tg3_flags2 & TG3_FLG2_5780_CLASS))) {
8113 /* Setup replenish threshold. */ 8109 /* Setup replenish threshold. */
8114 tw32(RCVBDI_JUMBO_THRESH, tp->rx_jumbo_pending / 8); 8110 tw32(RCVBDI_JUMBO_THRESH, tp->rx_jumbo_pending / 8);
8115 8111
@@ -8227,8 +8223,12 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
8227 (tp->tg3_flags3 & TG3_FLG3_5717_PLUS)) { 8223 (tp->tg3_flags3 & TG3_FLG3_5717_PLUS)) {
8228 val = tr32(TG3_RDMA_RSRVCTRL_REG); 8224 val = tr32(TG3_RDMA_RSRVCTRL_REG);
8229 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719) { 8225 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719) {
8230 val &= ~TG3_RDMA_RSRVCTRL_TXMRGN_MASK; 8226 val &= ~(TG3_RDMA_RSRVCTRL_TXMRGN_MASK |
8231 val |= TG3_RDMA_RSRVCTRL_TXMRGN_320B; 8227 TG3_RDMA_RSRVCTRL_FIFO_LWM_MASK |
8228 TG3_RDMA_RSRVCTRL_FIFO_HWM_MASK);
8229 val |= TG3_RDMA_RSRVCTRL_TXMRGN_320B |
8230 TG3_RDMA_RSRVCTRL_FIFO_LWM_1_5K |
8231 TG3_RDMA_RSRVCTRL_FIFO_HWM_1_5K;
8232 } 8232 }
8233 tw32(TG3_RDMA_RSRVCTRL_REG, 8233 tw32(TG3_RDMA_RSRVCTRL_REG,
8234 val | TG3_RDMA_RSRVCTRL_FIFO_OFLW_FIX); 8234 val | TG3_RDMA_RSRVCTRL_FIFO_OFLW_FIX);
@@ -8350,7 +8350,8 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
8350 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 8350 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
8351 udelay(100); 8351 udelay(100);
8352 8352
8353 if (tp->tg3_flags2 & TG3_FLG2_USING_MSIX) { 8353 if ((tp->tg3_flags2 & TG3_FLG2_USING_MSIX) &&
8354 tp->irq_cnt > 1) {
8354 val = tr32(MSGINT_MODE); 8355 val = tr32(MSGINT_MODE);
8355 val |= MSGINT_MODE_MULTIVEC_EN | MSGINT_MODE_ENABLE; 8356 val |= MSGINT_MODE_MULTIVEC_EN | MSGINT_MODE_ENABLE;
8356 tw32(MSGINT_MODE, val); 8357 tw32(MSGINT_MODE, val);
@@ -9090,7 +9091,8 @@ static void tg3_ints_init(struct tg3 *tp)
9090 9091
9091 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI_OR_MSIX) { 9092 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI_OR_MSIX) {
9092 u32 msi_mode = tr32(MSGINT_MODE); 9093 u32 msi_mode = tr32(MSGINT_MODE);
9093 if (tp->tg3_flags2 & TG3_FLG2_USING_MSIX) 9094 if ((tp->tg3_flags2 & TG3_FLG2_USING_MSIX) &&
9095 tp->irq_cnt > 1)
9094 msi_mode |= MSGINT_MODE_MULTIVEC_EN; 9096 msi_mode |= MSGINT_MODE_MULTIVEC_EN;
9095 tw32(MSGINT_MODE, msi_mode | MSGINT_MODE_ENABLE); 9097 tw32(MSGINT_MODE, msi_mode | MSGINT_MODE_ENABLE);
9096 } 9098 }
@@ -9532,17 +9534,10 @@ static void __tg3_set_rx_mode(struct net_device *dev)
9532 rx_mode = tp->rx_mode & ~(RX_MODE_PROMISC | 9534 rx_mode = tp->rx_mode & ~(RX_MODE_PROMISC |
9533 RX_MODE_KEEP_VLAN_TAG); 9535 RX_MODE_KEEP_VLAN_TAG);
9534 9536
9537#if !defined(CONFIG_VLAN_8021Q) && !defined(CONFIG_VLAN_8021Q_MODULE)
9535 /* When ASF is in use, we always keep the RX_MODE_KEEP_VLAN_TAG 9538 /* When ASF is in use, we always keep the RX_MODE_KEEP_VLAN_TAG
9536 * flag clear. 9539 * flag clear.
9537 */ 9540 */
9538#if TG3_VLAN_TAG_USED
9539 if (!tp->vlgrp &&
9540 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF))
9541 rx_mode |= RX_MODE_KEEP_VLAN_TAG;
9542#else
9543 /* By definition, VLAN is disabled always in this
9544 * case.
9545 */
9546 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) 9541 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF))
9547 rx_mode |= RX_MODE_KEEP_VLAN_TAG; 9542 rx_mode |= RX_MODE_KEEP_VLAN_TAG;
9548#endif 9543#endif
@@ -10873,13 +10868,16 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
10873 if (loopback_mode == TG3_MAC_LOOPBACK) { 10868 if (loopback_mode == TG3_MAC_LOOPBACK) {
10874 /* HW errata - mac loopback fails in some cases on 5780. 10869 /* HW errata - mac loopback fails in some cases on 5780.
10875 * Normal traffic and PHY loopback are not affected by 10870 * Normal traffic and PHY loopback are not affected by
10876 * errata. 10871 * errata. Also, the MAC loopback test is deprecated for
10872 * all newer ASIC revisions.
10877 */ 10873 */
10878 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780) 10874 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780 ||
10875 (tp->tg3_flags & TG3_FLAG_CPMU_PRESENT))
10879 return 0; 10876 return 0;
10880 10877
10881 mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) | 10878 mac_mode = tp->mac_mode &
10882 MAC_MODE_PORT_INT_LPBACK; 10879 ~(MAC_MODE_PORT_MODE_MASK | MAC_MODE_HALF_DUPLEX);
10880 mac_mode |= MAC_MODE_PORT_INT_LPBACK;
10883 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) 10881 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS))
10884 mac_mode |= MAC_MODE_LINK_POLARITY; 10882 mac_mode |= MAC_MODE_LINK_POLARITY;
10885 if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY) 10883 if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY)
@@ -10901,7 +10899,8 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
10901 tg3_writephy(tp, MII_BMCR, val); 10899 tg3_writephy(tp, MII_BMCR, val);
10902 udelay(40); 10900 udelay(40);
10903 10901
10904 mac_mode = tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK; 10902 mac_mode = tp->mac_mode &
10903 ~(MAC_MODE_PORT_MODE_MASK | MAC_MODE_HALF_DUPLEX);
10905 if (tp->phy_flags & TG3_PHYFLG_IS_FET) { 10904 if (tp->phy_flags & TG3_PHYFLG_IS_FET) {
10906 tg3_writephy(tp, MII_TG3_FET_PTEST, 10905 tg3_writephy(tp, MII_TG3_FET_PTEST,
10907 MII_TG3_FET_PTEST_FRC_TX_LINK | 10906 MII_TG3_FET_PTEST_FRC_TX_LINK |
@@ -10929,6 +10928,13 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
10929 MII_TG3_EXT_CTRL_LNK3_LED_MODE); 10928 MII_TG3_EXT_CTRL_LNK3_LED_MODE);
10930 } 10929 }
10931 tw32(MAC_MODE, mac_mode); 10930 tw32(MAC_MODE, mac_mode);
10931
10932 /* Wait for link */
10933 for (i = 0; i < 100; i++) {
10934 if (tr32(MAC_TX_STATUS) & TX_STATUS_LINK_UP)
10935 break;
10936 mdelay(1);
10937 }
10932 } else { 10938 } else {
10933 return -EINVAL; 10939 return -EINVAL;
10934 } 10940 }
@@ -11035,14 +11041,19 @@ out:
11035static int tg3_test_loopback(struct tg3 *tp) 11041static int tg3_test_loopback(struct tg3 *tp)
11036{ 11042{
11037 int err = 0; 11043 int err = 0;
11038 u32 cpmuctrl = 0; 11044 u32 eee_cap, cpmuctrl = 0;
11039 11045
11040 if (!netif_running(tp->dev)) 11046 if (!netif_running(tp->dev))
11041 return TG3_LOOPBACK_FAILED; 11047 return TG3_LOOPBACK_FAILED;
11042 11048
11049 eee_cap = tp->phy_flags & TG3_PHYFLG_EEE_CAP;
11050 tp->phy_flags &= ~TG3_PHYFLG_EEE_CAP;
11051
11043 err = tg3_reset_hw(tp, 1); 11052 err = tg3_reset_hw(tp, 1);
11044 if (err) 11053 if (err) {
11045 return TG3_LOOPBACK_FAILED; 11054 err = TG3_LOOPBACK_FAILED;
11055 goto done;
11056 }
11046 11057
11047 /* Turn off gphy autopowerdown. */ 11058 /* Turn off gphy autopowerdown. */
11048 if (tp->phy_flags & TG3_PHYFLG_ENABLE_APD) 11059 if (tp->phy_flags & TG3_PHYFLG_ENABLE_APD)
@@ -11062,8 +11073,10 @@ static int tg3_test_loopback(struct tg3 *tp)
11062 udelay(10); 11073 udelay(10);
11063 } 11074 }
11064 11075
11065 if (status != CPMU_MUTEX_GNT_DRIVER) 11076 if (status != CPMU_MUTEX_GNT_DRIVER) {
11066 return TG3_LOOPBACK_FAILED; 11077 err = TG3_LOOPBACK_FAILED;
11078 goto done;
11079 }
11067 11080
11068 /* Turn off link-based power management. */ 11081 /* Turn off link-based power management. */
11069 cpmuctrl = tr32(TG3_CPMU_CTRL); 11082 cpmuctrl = tr32(TG3_CPMU_CTRL);
@@ -11092,6 +11105,9 @@ static int tg3_test_loopback(struct tg3 *tp)
11092 if (tp->phy_flags & TG3_PHYFLG_ENABLE_APD) 11105 if (tp->phy_flags & TG3_PHYFLG_ENABLE_APD)
11093 tg3_phy_toggle_apd(tp, true); 11106 tg3_phy_toggle_apd(tp, true);
11094 11107
11108done:
11109 tp->phy_flags |= eee_cap;
11110
11095 return err; 11111 return err;
11096} 11112}
11097 11113
@@ -11198,7 +11214,9 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
11198 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) 11214 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES)
11199 break; /* We have no PHY */ 11215 break; /* We have no PHY */
11200 11216
11201 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) 11217 if ((tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) ||
11218 ((tp->tg3_flags & TG3_FLAG_ENABLE_ASF) &&
11219 !netif_running(dev)))
11202 return -EAGAIN; 11220 return -EAGAIN;
11203 11221
11204 spin_lock_bh(&tp->lock); 11222 spin_lock_bh(&tp->lock);
@@ -11214,7 +11232,9 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
11214 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) 11232 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES)
11215 break; /* We have no PHY */ 11233 break; /* We have no PHY */
11216 11234
11217 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) 11235 if ((tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) ||
11236 ((tp->tg3_flags & TG3_FLAG_ENABLE_ASF) &&
11237 !netif_running(dev)))
11218 return -EAGAIN; 11238 return -EAGAIN;
11219 11239
11220 spin_lock_bh(&tp->lock); 11240 spin_lock_bh(&tp->lock);
@@ -11230,31 +11250,6 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
11230 return -EOPNOTSUPP; 11250 return -EOPNOTSUPP;
11231} 11251}
11232 11252
11233#if TG3_VLAN_TAG_USED
11234static void tg3_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
11235{
11236 struct tg3 *tp = netdev_priv(dev);
11237
11238 if (!netif_running(dev)) {
11239 tp->vlgrp = grp;
11240 return;
11241 }
11242
11243 tg3_netif_stop(tp);
11244
11245 tg3_full_lock(tp, 0);
11246
11247 tp->vlgrp = grp;
11248
11249 /* Update RX_MODE_KEEP_VLAN_TAG bit in RX_MODE register. */
11250 __tg3_set_rx_mode(dev);
11251
11252 tg3_netif_start(tp);
11253
11254 tg3_full_unlock(tp);
11255}
11256#endif
11257
11258static int tg3_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) 11253static int tg3_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
11259{ 11254{
11260 struct tg3 *tp = netdev_priv(dev); 11255 struct tg3 *tp = netdev_priv(dev);
@@ -12468,9 +12463,11 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
12468 tp->tg3_flags3 |= TG3_FLG3_RGMII_EXT_IBND_TX_EN; 12463 tp->tg3_flags3 |= TG3_FLG3_RGMII_EXT_IBND_TX_EN;
12469 } 12464 }
12470done: 12465done:
12471 device_init_wakeup(&tp->pdev->dev, tp->tg3_flags & TG3_FLAG_WOL_CAP); 12466 if (tp->tg3_flags & TG3_FLAG_WOL_CAP)
12472 device_set_wakeup_enable(&tp->pdev->dev, 12467 device_set_wakeup_enable(&tp->pdev->dev,
12473 tp->tg3_flags & TG3_FLAG_WOL_ENABLE); 12468 tp->tg3_flags & TG3_FLAG_WOL_ENABLE);
12469 else
12470 device_set_wakeup_capable(&tp->pdev->dev, false);
12474} 12471}
12475 12472
12476static int __devinit tg3_issue_otp_command(struct tg3 *tp, u32 cmd) 12473static int __devinit tg3_issue_otp_command(struct tg3 *tp, u32 cmd)
@@ -13066,9 +13063,7 @@ static struct pci_dev * __devinit tg3_find_peer(struct tg3 *);
13066 13063
13067static void inline vlan_features_add(struct net_device *dev, unsigned long flags) 13064static void inline vlan_features_add(struct net_device *dev, unsigned long flags)
13068{ 13065{
13069#if TG3_VLAN_TAG_USED
13070 dev->vlan_features |= flags; 13066 dev->vlan_features |= flags;
13071#endif
13072} 13067}
13073 13068
13074static inline u32 tg3_rx_ret_ring_size(struct tg3 *tp) 13069static inline u32 tg3_rx_ret_ring_size(struct tg3 *tp)
@@ -13325,7 +13320,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13325 } 13320 }
13326 13321
13327 /* Determine TSO capabilities */ 13322 /* Determine TSO capabilities */
13328 if (tp->tg3_flags3 & TG3_FLG3_5717_PLUS) 13323 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719)
13324 ; /* Do nothing. HW bug. */
13325 else if (tp->tg3_flags3 & TG3_FLG3_5717_PLUS)
13329 tp->tg3_flags2 |= TG3_FLG2_HW_TSO_3; 13326 tp->tg3_flags2 |= TG3_FLG2_HW_TSO_3;
13330 else if ((tp->tg3_flags3 & TG3_FLG3_5755_PLUS) || 13327 else if ((tp->tg3_flags3 & TG3_FLG3_5755_PLUS) ||
13331 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) 13328 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906)
@@ -13376,7 +13373,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13376 tp->tg3_flags3 |= TG3_FLG3_40BIT_DMA_LIMIT_BUG; 13373 tp->tg3_flags3 |= TG3_FLG3_40BIT_DMA_LIMIT_BUG;
13377 } 13374 }
13378 13375
13379 if (tp->tg3_flags3 & TG3_FLG3_5717_PLUS) 13376 if ((tp->tg3_flags3 & TG3_FLG3_5717_PLUS) &&
13377 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5719)
13380 tp->tg3_flags3 |= TG3_FLG3_USE_JUMBO_BDFLAG; 13378 tp->tg3_flags3 |= TG3_FLG3_USE_JUMBO_BDFLAG;
13381 13379
13382 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS) || 13380 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS) ||
@@ -13394,42 +13392,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13394 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS; 13392 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS;
13395 13393
13396 tp->pcie_readrq = 4096; 13394 tp->pcie_readrq = 4096;
13397 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719) { 13395 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719)
13398 u16 word; 13396 tp->pcie_readrq = 2048;
13399
13400 pci_read_config_word(tp->pdev,
13401 tp->pcie_cap + PCI_EXP_LNKSTA,
13402 &word);
13403 switch (word & PCI_EXP_LNKSTA_CLS) {
13404 case PCI_EXP_LNKSTA_CLS_2_5GB:
13405 word &= PCI_EXP_LNKSTA_NLW;
13406 word >>= PCI_EXP_LNKSTA_NLW_SHIFT;
13407 switch (word) {
13408 case 2:
13409 tp->pcie_readrq = 2048;
13410 break;
13411 case 4:
13412 tp->pcie_readrq = 1024;
13413 break;
13414 }
13415 break;
13416
13417 case PCI_EXP_LNKSTA_CLS_5_0GB:
13418 word &= PCI_EXP_LNKSTA_NLW;
13419 word >>= PCI_EXP_LNKSTA_NLW_SHIFT;
13420 switch (word) {
13421 case 1:
13422 tp->pcie_readrq = 2048;
13423 break;
13424 case 2:
13425 tp->pcie_readrq = 1024;
13426 break;
13427 case 4:
13428 tp->pcie_readrq = 512;
13429 break;
13430 }
13431 }
13432 }
13433 13397
13434 pcie_set_readrq(tp->pdev, tp->pcie_readrq); 13398 pcie_set_readrq(tp->pdev, tp->pcie_readrq);
13435 13399
@@ -13861,11 +13825,11 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13861 else 13825 else
13862 tp->tg3_flags &= ~TG3_FLAG_POLL_SERDES; 13826 tp->tg3_flags &= ~TG3_FLAG_POLL_SERDES;
13863 13827
13864 tp->rx_offset = NET_IP_ALIGN + TG3_RX_HEADROOM; 13828 tp->rx_offset = NET_IP_ALIGN;
13865 tp->rx_copy_thresh = TG3_RX_COPY_THRESHOLD; 13829 tp->rx_copy_thresh = TG3_RX_COPY_THRESHOLD;
13866 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 && 13830 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 &&
13867 (tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) { 13831 (tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) {
13868 tp->rx_offset -= NET_IP_ALIGN; 13832 tp->rx_offset = 0;
13869#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 13833#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
13870 tp->rx_copy_thresh = ~(u16)0; 13834 tp->rx_copy_thresh = ~(u16)0;
13871#endif 13835#endif
@@ -14629,9 +14593,6 @@ static const struct net_device_ops tg3_netdev_ops = {
14629 .ndo_do_ioctl = tg3_ioctl, 14593 .ndo_do_ioctl = tg3_ioctl,
14630 .ndo_tx_timeout = tg3_tx_timeout, 14594 .ndo_tx_timeout = tg3_tx_timeout,
14631 .ndo_change_mtu = tg3_change_mtu, 14595 .ndo_change_mtu = tg3_change_mtu,
14632#if TG3_VLAN_TAG_USED
14633 .ndo_vlan_rx_register = tg3_vlan_rx_register,
14634#endif
14635#ifdef CONFIG_NET_POLL_CONTROLLER 14596#ifdef CONFIG_NET_POLL_CONTROLLER
14636 .ndo_poll_controller = tg3_poll_controller, 14597 .ndo_poll_controller = tg3_poll_controller,
14637#endif 14598#endif
@@ -14648,9 +14609,6 @@ static const struct net_device_ops tg3_netdev_ops_dma_bug = {
14648 .ndo_do_ioctl = tg3_ioctl, 14609 .ndo_do_ioctl = tg3_ioctl,
14649 .ndo_tx_timeout = tg3_tx_timeout, 14610 .ndo_tx_timeout = tg3_tx_timeout,
14650 .ndo_change_mtu = tg3_change_mtu, 14611 .ndo_change_mtu = tg3_change_mtu,
14651#if TG3_VLAN_TAG_USED
14652 .ndo_vlan_rx_register = tg3_vlan_rx_register,
14653#endif
14654#ifdef CONFIG_NET_POLL_CONTROLLER 14612#ifdef CONFIG_NET_POLL_CONTROLLER
14655 .ndo_poll_controller = tg3_poll_controller, 14613 .ndo_poll_controller = tg3_poll_controller,
14656#endif 14614#endif
@@ -14700,9 +14658,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
14700 14658
14701 SET_NETDEV_DEV(dev, &pdev->dev); 14659 SET_NETDEV_DEV(dev, &pdev->dev);
14702 14660
14703#if TG3_VLAN_TAG_USED
14704 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; 14661 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
14705#endif
14706 14662
14707 tp = netdev_priv(dev); 14663 tp = netdev_priv(dev);
14708 tp->pdev = pdev; 14664 tp->pdev = pdev;