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.c156
1 files changed, 57 insertions, 99 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 2bd9592b75cd..862c226dbbe2 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.57" 72#define DRV_MODULE_VERSION "3.59"
73#define DRV_MODULE_RELDATE "Apr 28, 2006" 73#define DRV_MODULE_RELDATE "June 8, 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
@@ -4485,9 +4485,8 @@ static void tg3_disable_nvram_access(struct tg3 *tp)
4485/* tp->lock is held. */ 4485/* tp->lock is held. */
4486static void tg3_write_sig_pre_reset(struct tg3 *tp, int kind) 4486static void tg3_write_sig_pre_reset(struct tg3 *tp, int kind)
4487{ 4487{
4488 if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X)) 4488 tg3_write_mem(tp, NIC_SRAM_FIRMWARE_MBOX,
4489 tg3_write_mem(tp, NIC_SRAM_FIRMWARE_MBOX, 4489 NIC_SRAM_FIRMWARE_MBOX_MAGIC1);
4490 NIC_SRAM_FIRMWARE_MBOX_MAGIC1);
4491 4490
4492 if (tp->tg3_flags2 & TG3_FLG2_ASF_NEW_HANDSHAKE) { 4491 if (tp->tg3_flags2 & TG3_FLG2_ASF_NEW_HANDSHAKE) {
4493 switch (kind) { 4492 switch (kind) {
@@ -4568,13 +4567,12 @@ static int tg3_chip_reset(struct tg3 *tp)
4568 void (*write_op)(struct tg3 *, u32, u32); 4567 void (*write_op)(struct tg3 *, u32, u32);
4569 int i; 4568 int i;
4570 4569
4571 if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X)) { 4570 tg3_nvram_lock(tp);
4572 tg3_nvram_lock(tp); 4571
4573 /* No matching tg3_nvram_unlock() after this because 4572 /* No matching tg3_nvram_unlock() after this because
4574 * chip reset below will undo the nvram lock. 4573 * chip reset below will undo the nvram lock.
4575 */ 4574 */
4576 tp->nvram_lock_cnt = 0; 4575 tp->nvram_lock_cnt = 0;
4577 }
4578 4576
4579 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || 4577 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 ||
4580 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || 4578 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
@@ -4727,20 +4725,25 @@ static int tg3_chip_reset(struct tg3 *tp)
4727 tw32_f(MAC_MODE, 0); 4725 tw32_f(MAC_MODE, 0);
4728 udelay(40); 4726 udelay(40);
4729 4727
4730 if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X)) { 4728 /* Wait for firmware initialization to complete. */
4731 /* Wait for firmware initialization to complete. */ 4729 for (i = 0; i < 100000; i++) {
4732 for (i = 0; i < 100000; i++) { 4730 tg3_read_mem(tp, NIC_SRAM_FIRMWARE_MBOX, &val);
4733 tg3_read_mem(tp, NIC_SRAM_FIRMWARE_MBOX, &val); 4731 if (val == ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1)
4734 if (val == ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1) 4732 break;
4735 break; 4733 udelay(10);
4736 udelay(10); 4734 }
4737 } 4735
4738 if (i >= 100000) { 4736 /* Chip might not be fitted with firmare. Some Sun onboard
4739 printk(KERN_ERR PFX "tg3_reset_hw timed out for %s, " 4737 * parts are configured like that. So don't signal the timeout
4740 "firmware will not restart magic=%08x\n", 4738 * of the above loop as an error, but do report the lack of
4741 tp->dev->name, val); 4739 * running firmware once.
4742 return -ENODEV; 4740 */
4743 } 4741 if (i >= 100000 &&
4742 !(tp->tg3_flags2 & TG3_FLG2_NO_FWARE_REPORTED)) {
4743 tp->tg3_flags2 |= TG3_FLG2_NO_FWARE_REPORTED;
4744
4745 printk(KERN_INFO PFX "%s: No firmware running.\n",
4746 tp->dev->name);
4744 } 4747 }
4745 4748
4746 if ((tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) && 4749 if ((tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) &&
@@ -6488,6 +6491,10 @@ static void tg3_periodic_fetch_stats(struct tg3 *tp)
6488 TG3_STAT_ADD32(&sp->rx_frame_too_long_errors, MAC_RX_STATS_FRAME_TOO_LONG); 6491 TG3_STAT_ADD32(&sp->rx_frame_too_long_errors, MAC_RX_STATS_FRAME_TOO_LONG);
6489 TG3_STAT_ADD32(&sp->rx_jabbers, MAC_RX_STATS_JABBERS); 6492 TG3_STAT_ADD32(&sp->rx_jabbers, MAC_RX_STATS_JABBERS);
6490 TG3_STAT_ADD32(&sp->rx_undersize_packets, MAC_RX_STATS_UNDERSIZE); 6493 TG3_STAT_ADD32(&sp->rx_undersize_packets, MAC_RX_STATS_UNDERSIZE);
6494
6495 TG3_STAT_ADD32(&sp->rxbds_empty, RCVLPC_NO_RCV_BD_CNT);
6496 TG3_STAT_ADD32(&sp->rx_discards, RCVLPC_IN_DISCARDS_CNT);
6497 TG3_STAT_ADD32(&sp->rx_errors, RCVLPC_IN_ERRORS_CNT);
6491} 6498}
6492 6499
6493static void tg3_timer(unsigned long __opaque) 6500static void tg3_timer(unsigned long __opaque)
@@ -7653,21 +7660,23 @@ static int tg3_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
7653 cmd->supported |= (SUPPORTED_1000baseT_Half | 7660 cmd->supported |= (SUPPORTED_1000baseT_Half |
7654 SUPPORTED_1000baseT_Full); 7661 SUPPORTED_1000baseT_Full);
7655 7662
7656 if (!(tp->tg3_flags2 & TG3_FLG2_ANY_SERDES)) 7663 if (!(tp->tg3_flags2 & TG3_FLG2_ANY_SERDES)) {
7657 cmd->supported |= (SUPPORTED_100baseT_Half | 7664 cmd->supported |= (SUPPORTED_100baseT_Half |
7658 SUPPORTED_100baseT_Full | 7665 SUPPORTED_100baseT_Full |
7659 SUPPORTED_10baseT_Half | 7666 SUPPORTED_10baseT_Half |
7660 SUPPORTED_10baseT_Full | 7667 SUPPORTED_10baseT_Full |
7661 SUPPORTED_MII); 7668 SUPPORTED_MII);
7662 else 7669 cmd->port = PORT_TP;
7670 } else {
7663 cmd->supported |= SUPPORTED_FIBRE; 7671 cmd->supported |= SUPPORTED_FIBRE;
7672 cmd->port = PORT_FIBRE;
7673 }
7664 7674
7665 cmd->advertising = tp->link_config.advertising; 7675 cmd->advertising = tp->link_config.advertising;
7666 if (netif_running(dev)) { 7676 if (netif_running(dev)) {
7667 cmd->speed = tp->link_config.active_speed; 7677 cmd->speed = tp->link_config.active_speed;
7668 cmd->duplex = tp->link_config.active_duplex; 7678 cmd->duplex = tp->link_config.active_duplex;
7669 } 7679 }
7670 cmd->port = 0;
7671 cmd->phy_address = PHY_ADDR; 7680 cmd->phy_address = PHY_ADDR;
7672 cmd->transceiver = 0; 7681 cmd->transceiver = 0;
7673 cmd->autoneg = tp->link_config.autoneg; 7682 cmd->autoneg = tp->link_config.autoneg;
@@ -9069,9 +9078,6 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
9069{ 9078{
9070 int j; 9079 int j;
9071 9080
9072 if (tp->tg3_flags2 & TG3_FLG2_SUN_570X)
9073 return;
9074
9075 tw32_f(GRC_EEPROM_ADDR, 9081 tw32_f(GRC_EEPROM_ADDR,
9076 (EEPROM_ADDR_FSM_RESET | 9082 (EEPROM_ADDR_FSM_RESET |
9077 (EEPROM_DEFAULT_CLOCK_PERIOD << 9083 (EEPROM_DEFAULT_CLOCK_PERIOD <<
@@ -9204,11 +9210,6 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val)
9204{ 9210{
9205 int ret; 9211 int ret;
9206 9212
9207 if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
9208 printk(KERN_ERR PFX "Attempt to do nvram_read on Sun 570X\n");
9209 return -EINVAL;
9210 }
9211
9212 if (!(tp->tg3_flags & TG3_FLAG_NVRAM)) 9213 if (!(tp->tg3_flags & TG3_FLAG_NVRAM))
9213 return tg3_nvram_read_using_eeprom(tp, offset, val); 9214 return tg3_nvram_read_using_eeprom(tp, offset, val);
9214 9215
@@ -9441,11 +9442,6 @@ static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf)
9441{ 9442{
9442 int ret; 9443 int ret;
9443 9444
9444 if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
9445 printk(KERN_ERR PFX "Attempt to do nvram_write on Sun 570X\n");
9446 return -EINVAL;
9447 }
9448
9449 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) { 9445 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
9450 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl & 9446 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl &
9451 ~GRC_LCLCTRL_GPIO_OUTPUT1); 9447 ~GRC_LCLCTRL_GPIO_OUTPUT1);
@@ -9572,15 +9568,19 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
9572 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, 9568 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
9573 tp->misc_host_ctrl); 9569 tp->misc_host_ctrl);
9574 9570
9571 /* The memory arbiter has to be enabled in order for SRAM accesses
9572 * to succeed. Normally on powerup the tg3 chip firmware will make
9573 * sure it is enabled, but other entities such as system netboot
9574 * code might disable it.
9575 */
9576 val = tr32(MEMARB_MODE);
9577 tw32(MEMARB_MODE, val | MEMARB_MODE_ENABLE);
9578
9575 tp->phy_id = PHY_ID_INVALID; 9579 tp->phy_id = PHY_ID_INVALID;
9576 tp->led_ctrl = LED_CTRL_MODE_PHY_1; 9580 tp->led_ctrl = LED_CTRL_MODE_PHY_1;
9577 9581
9578 /* Do not even try poking around in here on Sun parts. */ 9582 /* Assume an onboard device by default. */
9579 if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) { 9583 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
9580 /* All SUN chips are built-in LOMs. */
9581 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
9582 return;
9583 }
9584 9584
9585 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val); 9585 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val);
9586 if (val == NIC_SRAM_DATA_SIG_MAGIC) { 9586 if (val == NIC_SRAM_DATA_SIG_MAGIC) {
@@ -9680,6 +9680,8 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
9680 9680
9681 if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) 9681 if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP)
9682 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT; 9682 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
9683 else
9684 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT;
9683 9685
9684 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) { 9686 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) {
9685 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF; 9687 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF;
@@ -9828,16 +9830,8 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
9828 int i; 9830 int i;
9829 u32 magic; 9831 u32 magic;
9830 9832
9831 if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
9832 /* Sun decided not to put the necessary bits in the
9833 * NVRAM of their onboard tg3 parts :(
9834 */
9835 strcpy(tp->board_part_number, "Sun 570X");
9836 return;
9837 }
9838
9839 if (tg3_nvram_read_swab(tp, 0x0, &magic)) 9833 if (tg3_nvram_read_swab(tp, 0x0, &magic))
9840 return; 9834 goto out_not_found;
9841 9835
9842 if (magic == TG3_EEPROM_MAGIC) { 9836 if (magic == TG3_EEPROM_MAGIC) {
9843 for (i = 0; i < 256; i += 4) { 9837 for (i = 0; i < 256; i += 4) {
@@ -9868,6 +9862,9 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
9868 break; 9862 break;
9869 msleep(1); 9863 msleep(1);
9870 } 9864 }
9865 if (!(tmp16 & 0x8000))
9866 goto out_not_found;
9867
9871 pci_read_config_dword(tp->pdev, vpd_cap + PCI_VPD_DATA, 9868 pci_read_config_dword(tp->pdev, vpd_cap + PCI_VPD_DATA,
9872 &tmp); 9869 &tmp);
9873 tmp = cpu_to_le32(tmp); 9870 tmp = cpu_to_le32(tmp);
@@ -9959,37 +9956,6 @@ static void __devinit tg3_read_fw_ver(struct tg3 *tp)
9959 } 9956 }
9960} 9957}
9961 9958
9962#ifdef CONFIG_SPARC64
9963static int __devinit tg3_is_sun_570X(struct tg3 *tp)
9964{
9965 struct pci_dev *pdev = tp->pdev;
9966 struct pcidev_cookie *pcp = pdev->sysdata;
9967
9968 if (pcp != NULL) {
9969 int node = pcp->prom_node;
9970 u32 venid;
9971 int err;
9972
9973 err = prom_getproperty(node, "subsystem-vendor-id",
9974 (char *) &venid, sizeof(venid));
9975 if (err == 0 || err == -1)
9976 return 0;
9977 if (venid == PCI_VENDOR_ID_SUN)
9978 return 1;
9979
9980 /* TG3 chips onboard the SunBlade-2500 don't have the
9981 * subsystem-vendor-id set to PCI_VENDOR_ID_SUN but they
9982 * are distinguishable from non-Sun variants by being
9983 * named "network" by the firmware. Non-Sun cards will
9984 * show up as being named "ethernet".
9985 */
9986 if (!strcmp(pcp->prom_name, "network"))
9987 return 1;
9988 }
9989 return 0;
9990}
9991#endif
9992
9993static int __devinit tg3_get_invariants(struct tg3 *tp) 9959static int __devinit tg3_get_invariants(struct tg3 *tp)
9994{ 9960{
9995 static struct pci_device_id write_reorder_chipsets[] = { 9961 static struct pci_device_id write_reorder_chipsets[] = {
@@ -10006,11 +9972,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10006 u16 pci_cmd; 9972 u16 pci_cmd;
10007 int err; 9973 int err;
10008 9974
10009#ifdef CONFIG_SPARC64
10010 if (tg3_is_sun_570X(tp))
10011 tp->tg3_flags2 |= TG3_FLG2_SUN_570X;
10012#endif
10013
10014 /* Force memory write invalidate off. If we leave it on, 9975 /* Force memory write invalidate off. If we leave it on,
10015 * then on 5700_BX chips we have to enable a workaround. 9976 * then on 5700_BX chips we have to enable a workaround.
10016 * The workaround is to set the TG3PCI_DMA_RW_CTRL boundary 9977 * The workaround is to set the TG3PCI_DMA_RW_CTRL boundary
@@ -10306,8 +10267,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10306 if (tp->write32 == tg3_write_indirect_reg32 || 10267 if (tp->write32 == tg3_write_indirect_reg32 ||
10307 ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) && 10268 ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) &&
10308 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 || 10269 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
10309 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)) || 10270 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)))
10310 (tp->tg3_flags2 & TG3_FLG2_SUN_570X))
10311 tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG; 10271 tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG;
10312 10272
10313 /* Get eeprom hw config before calling tg3_set_power_state(). 10273 /* Get eeprom hw config before calling tg3_set_power_state().
@@ -10588,8 +10548,7 @@ static int __devinit tg3_get_device_address(struct tg3 *tp)
10588#endif 10548#endif
10589 10549
10590 mac_offset = 0x7c; 10550 mac_offset = 0x7c;
10591 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 && 10551 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
10592 !(tp->tg3_flags & TG3_FLG2_SUN_570X)) ||
10593 (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) { 10552 (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) {
10594 if (tr32(TG3PCI_DUAL_MAC_CTRL) & DUAL_MAC_CTRL_ID) 10553 if (tr32(TG3PCI_DUAL_MAC_CTRL) & DUAL_MAC_CTRL_ID)
10595 mac_offset = 0xcc; 10554 mac_offset = 0xcc;
@@ -10616,8 +10575,7 @@ static int __devinit tg3_get_device_address(struct tg3 *tp)
10616 } 10575 }
10617 if (!addr_ok) { 10576 if (!addr_ok) {
10618 /* Next, try NVRAM. */ 10577 /* Next, try NVRAM. */
10619 if (!(tp->tg3_flags & TG3_FLG2_SUN_570X) && 10578 if (!tg3_nvram_read(tp, mac_offset + 0, &hi) &&
10620 !tg3_nvram_read(tp, mac_offset + 0, &hi) &&
10621 !tg3_nvram_read(tp, mac_offset + 4, &lo)) { 10579 !tg3_nvram_read(tp, mac_offset + 4, &lo)) {
10622 dev->dev_addr[0] = ((hi >> 16) & 0xff); 10580 dev->dev_addr[0] = ((hi >> 16) & 0xff);
10623 dev->dev_addr[1] = ((hi >> 24) & 0xff); 10581 dev->dev_addr[1] = ((hi >> 24) & 0xff);