Lines Matching +full:pull +full:- +full:down +full:- +full:adv
7 * Copyright (C) 2005-2016 Broadcom Corporation.
8 * Copyright (C) 2016-2017 Broadcom Limited.
14 * Copyright (C) 2000-2016 Broadcom Corporation.
15 * Copyright (C) 2016-2017 Broadcom Ltd.
52 #include <linux/dma-mapping.h>
56 #include <linux/hwmon-sysfs.h>
93 _tg3_flag(TG3_FLAG_##flag, (tp)->tg3_flags)
95 _tg3_flag_set(TG3_FLAG_##flag, (tp)->tg3_flags)
97 _tg3_flag_clear(TG3_FLAG_##flag, (tp)->tg3_flags)
123 * and dev->tx_timeout() should be called to fix the problem
146 /* Do not place this n-ring entries value into the tp struct itself,
150 * replace things like '% foo' with '& (foo - 1)'.
154 #define TG3_DEF_TX_RING_PENDING (TG3_TX_RING_SIZE - 1)
161 (sizeof(struct tg3_rx_buffer_desc) * (tp->rx_ret_ring_mask + 1))
164 #define NEXT_TX(N) (((N) + 1) & (TG3_TX_RING_SIZE - 1))
197 #define TG3_RX_COPY_THRESH(tp) ((tp)->rx_copy_thresh)
201 #define TG3_RX_OFFSET(tp) ((tp)->rx_offset)
207 #define TG3_TX_WAKEUP_THRESH(tnapi) ((tnapi)->tx_pending / 4)
232 static int tg3_debug = -1; /* -1 == use TG3_DEF_MSG_ENABLE as value */
354 {PCI_DEVICE(0x10cf, 0x11a2)}, /* Fujitsu 1000base-SX with BCM5703SKHB */
472 writel(val, tp->regs + off); in tg3_write32()
477 return readl(tp->regs + off); in tg3_read32()
482 writel(val, tp->aperegs + off); in tg3_ape_write32()
487 return readl(tp->aperegs + off); in tg3_ape_read32()
494 spin_lock_irqsave(&tp->indirect_lock, flags); in tg3_write_indirect_reg32()
495 pci_write_config_dword(tp->pdev, TG3PCI_REG_BASE_ADDR, off); in tg3_write_indirect_reg32()
496 pci_write_config_dword(tp->pdev, TG3PCI_REG_DATA, val); in tg3_write_indirect_reg32()
497 spin_unlock_irqrestore(&tp->indirect_lock, flags); in tg3_write_indirect_reg32()
502 writel(val, tp->regs + off); in tg3_write_flush_reg32()
503 readl(tp->regs + off); in tg3_write_flush_reg32()
511 spin_lock_irqsave(&tp->indirect_lock, flags); in tg3_read_indirect_reg32()
512 pci_write_config_dword(tp->pdev, TG3PCI_REG_BASE_ADDR, off); in tg3_read_indirect_reg32()
513 pci_read_config_dword(tp->pdev, TG3PCI_REG_DATA, &val); in tg3_read_indirect_reg32()
514 spin_unlock_irqrestore(&tp->indirect_lock, flags); in tg3_read_indirect_reg32()
523 pci_write_config_dword(tp->pdev, TG3PCI_RCV_RET_RING_CON_IDX + in tg3_write_indirect_mbox()
528 pci_write_config_dword(tp->pdev, TG3PCI_STD_RING_PROD_IDX + in tg3_write_indirect_mbox()
533 spin_lock_irqsave(&tp->indirect_lock, flags); in tg3_write_indirect_mbox()
534 pci_write_config_dword(tp->pdev, TG3PCI_REG_BASE_ADDR, off + 0x5600); in tg3_write_indirect_mbox()
535 pci_write_config_dword(tp->pdev, TG3PCI_REG_DATA, val); in tg3_write_indirect_mbox()
536 spin_unlock_irqrestore(&tp->indirect_lock, flags); in tg3_write_indirect_mbox()
543 pci_write_config_dword(tp->pdev, TG3PCI_MISC_LOCAL_CTRL, in tg3_write_indirect_mbox()
544 tp->grc_local_ctrl|GRC_LCLCTRL_CLEARINT); in tg3_write_indirect_mbox()
553 spin_lock_irqsave(&tp->indirect_lock, flags); in tg3_read_indirect_mbox()
554 pci_write_config_dword(tp->pdev, TG3PCI_REG_BASE_ADDR, off + 0x5600); in tg3_read_indirect_mbox()
555 pci_read_config_dword(tp->pdev, TG3PCI_REG_DATA, &val); in tg3_read_indirect_mbox()
556 spin_unlock_irqrestore(&tp->indirect_lock, flags); in tg3_read_indirect_mbox()
568 /* Non-posted methods */ in _tw32_flush()
569 tp->write32(tp, off, val); in _tw32_flush()
575 tp->read32(tp, off); in _tw32_flush()
586 tp->write32_mbox(tp, off, val); in tw32_mailbox_flush()
590 tp->read32_mbox(tp, off); in tw32_mailbox_flush()
595 void __iomem *mbox = tp->regs + off; in tg3_write32_tx_mbox()
606 return readl(tp->regs + off + GRCMBOX_BASE); in tg3_read32_mbox_5906()
611 writel(val, tp->regs + off + GRCMBOX_BASE); in tg3_write32_mbox_5906()
614 #define tw32_mailbox(reg, val) tp->write32_mbox(tp, reg, val)
616 #define tw32_rx_mbox(reg, val) tp->write32_rx_mbox(tp, reg, val)
617 #define tw32_tx_mbox(reg, val) tp->write32_tx_mbox(tp, reg, val)
618 #define tr32_mailbox(reg) tp->read32_mbox(tp, reg)
620 #define tw32(reg, val) tp->write32(tp, reg, val)
623 #define tr32(reg) tp->read32(tp, reg)
633 spin_lock_irqsave(&tp->indirect_lock, flags); in tg3_write_mem()
635 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, off); in tg3_write_mem()
636 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_DATA, val); in tg3_write_mem()
639 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0); in tg3_write_mem()
647 spin_unlock_irqrestore(&tp->indirect_lock, flags); in tg3_write_mem()
660 spin_lock_irqsave(&tp->indirect_lock, flags); in tg3_read_mem()
662 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, off); in tg3_read_mem()
663 pci_read_config_dword(tp->pdev, TG3PCI_MEM_WIN_DATA, val); in tg3_read_mem()
666 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0); in tg3_read_mem()
674 spin_unlock_irqrestore(&tp->indirect_lock, flags); in tg3_read_mem()
697 if (!tp->pci_fn) in tg3_ape_lock_init()
700 bit = 1 << tp->pci_fn; in tg3_ape_lock_init()
723 if (!tp->pci_fn) in tg3_ape_lock()
726 bit = 1 << tp->pci_fn; in tg3_ape_lock()
735 return -EINVAL; in tg3_ape_lock()
755 if (pci_channel_offline(tp->pdev)) in tg3_ape_lock()
764 ret = -EBUSY; in tg3_ape_lock()
784 if (!tp->pci_fn) in tg3_ape_unlock()
787 bit = 1 << tp->pci_fn; in tg3_ape_unlock()
813 return -EBUSY; in tg3_ape_event_lock()
822 timeout_us -= (timeout_us > 10) ? 10 : timeout_us; in tg3_ape_event_lock()
825 return timeout_us ? 0 : -EBUSY; in tg3_ape_event_lock()
856 return -ENODEV; in tg3_ape_scratchpad_read()
860 return -EAGAIN; in tg3_ape_scratchpad_read()
872 len -= length; in tg3_ape_scratchpad_read()
876 return -EAGAIN; in tg3_ape_scratchpad_read()
897 return -EAGAIN; in tg3_ape_scratchpad_read()
899 for (i = 0; length; i += 4, length -= 4) { in tg3_ape_scratchpad_read()
917 return -EAGAIN; in tg3_ape_send_event()
921 return -EAGAIN; in tg3_ape_send_event()
947 tg3_ape_write32(tp, TG3_APE_HOST_HEARTBEAT_COUNT, tp->ape_hb++); in tg3_ape_driver_state_change()
964 if (device_may_wakeup(&tp->pdev->dev) && in tg3_ape_driver_state_change()
990 time_before(jiffies, tp->ape_hb_jiffies + interval)) in tg3_send_ape_heartbeat()
993 tg3_ape_write32(tp, TG3_APE_HOST_HEARTBEAT_COUNT, tp->ape_hb++); in tg3_send_ape_heartbeat()
994 tp->ape_hb_jiffies = jiffies; in tg3_send_ape_heartbeat()
1002 (tp->misc_host_ctrl | MISC_HOST_CTRL_MASK_PCI_INT)); in tg3_disable_ints()
1003 for (i = 0; i < tp->irq_max; i++) in tg3_disable_ints()
1004 tw32_mailbox_f(tp->napi[i].int_mbox, 0x00000001); in tg3_disable_ints()
1011 tp->irq_sync = 0; in tg3_enable_ints()
1015 (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT)); in tg3_enable_ints()
1017 tp->coal_now = tp->coalesce_mode | HOSTCC_MODE_ENABLE; in tg3_enable_ints()
1018 for (i = 0; i < tp->irq_cnt; i++) { in tg3_enable_ints()
1019 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_enable_ints()
1021 tw32_mailbox_f(tnapi->int_mbox, tnapi->last_tag << 24); in tg3_enable_ints()
1023 tw32_mailbox_f(tnapi->int_mbox, tnapi->last_tag << 24); in tg3_enable_ints()
1025 tp->coal_now |= tnapi->coal_now; in tg3_enable_ints()
1030 (tp->napi[0].hw_status->status & SD_STATUS_UPDATED)) in tg3_enable_ints()
1031 tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl | GRC_LCLCTRL_SETINT); in tg3_enable_ints()
1033 tw32(HOSTCC_MODE, tp->coal_now); in tg3_enable_ints()
1035 tp->coal_now &= ~(tp->napi[0].coal_now | tp->napi[1].coal_now); in tg3_enable_ints()
1040 struct tg3 *tp = tnapi->tp; in tg3_has_work()
1041 struct tg3_hw_status *sblk = tnapi->hw_status; in tg3_has_work()
1046 if (sblk->status & SD_STATUS_LINK_CHG) in tg3_has_work()
1051 if (sblk->idx[0].tx_consumer != tnapi->tx_cons) in tg3_has_work()
1055 if (tnapi->rx_rcb_prod_idx && in tg3_has_work()
1056 *(tnapi->rx_rcb_prod_idx) != tnapi->rx_rcb_ptr) in tg3_has_work()
1069 struct tg3 *tp = tnapi->tp; in tg3_int_reenable()
1071 tw32_mailbox(tnapi->int_mbox, tnapi->last_tag << 24); in tg3_int_reenable()
1078 tw32(HOSTCC_MODE, tp->coalesce_mode | in tg3_int_reenable()
1079 HOSTCC_MODE_ENABLE | tnapi->coal_now); in tg3_int_reenable()
1096 tp->pci_clock_ctrl = clock_ctrl; in tg3_switch_clocks()
1124 if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) { in __tg3_readphy()
1126 (tp->mi_mode & ~MAC_MI_MODE_AUTO_POLL)); in __tg3_readphy()
1130 tg3_ape_lock(tp, tp->phy_ape_lock); in __tg3_readphy()
1152 loops -= 1; in __tg3_readphy()
1155 ret = -EBUSY; in __tg3_readphy()
1161 if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) { in __tg3_readphy()
1162 tw32_f(MAC_MI_MODE, tp->mi_mode); in __tg3_readphy()
1166 tg3_ape_unlock(tp, tp->phy_ape_lock); in __tg3_readphy()
1173 return __tg3_readphy(tp, tp->phy_addr, reg, val); in tg3_readphy()
1183 if ((tp->phy_flags & TG3_PHYFLG_IS_FET) && in __tg3_writephy()
1187 if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) { in __tg3_writephy()
1189 (tp->mi_mode & ~MAC_MI_MODE_AUTO_POLL)); in __tg3_writephy()
1193 tg3_ape_lock(tp, tp->phy_ape_lock); in __tg3_writephy()
1213 loops -= 1; in __tg3_writephy()
1216 ret = -EBUSY; in __tg3_writephy()
1220 if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) { in __tg3_writephy()
1221 tw32_f(MAC_MI_MODE, tp->mi_mode); in __tg3_writephy()
1225 tg3_ape_unlock(tp, tp->phy_ape_lock); in __tg3_writephy()
1232 return __tg3_writephy(tp, tp->phy_addr, reg, val); in tg3_writephy()
1362 return -EBUSY; in tg3_bmcr_reset()
1365 while (limit--) { in tg3_bmcr_reset()
1368 return -EBUSY; in tg3_bmcr_reset()
1377 return -EBUSY; in tg3_bmcr_reset()
1384 struct tg3 *tp = bp->priv; in tg3_mdio_read()
1387 spin_lock_bh(&tp->lock); in tg3_mdio_read()
1390 val = -EIO; in tg3_mdio_read()
1392 spin_unlock_bh(&tp->lock); in tg3_mdio_read()
1399 struct tg3 *tp = bp->priv; in tg3_mdio_write()
1402 spin_lock_bh(&tp->lock); in tg3_mdio_write()
1405 ret = -EIO; in tg3_mdio_write()
1407 spin_unlock_bh(&tp->lock); in tg3_mdio_write()
1417 phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); in tg3_mdio_config_5785()
1418 switch (phydev->drv->phy_id & phydev->drv->phy_id_mask) { in tg3_mdio_config_5785()
1436 if (phydev->interface != PHY_INTERFACE_MODE_RGMII) { in tg3_mdio_config_5785()
1495 tp->mi_mode &= ~MAC_MI_MODE_AUTO_POLL; in tg3_mdio_start()
1496 tw32_f(MAC_MI_MODE, tp->mi_mode); in tg3_mdio_start()
1513 tp->phy_addr = tp->pci_fn + 1; in tg3_mdio_init()
1521 tp->phy_addr += 7; in tg3_mdio_init()
1525 addr = ssb_gige_get_phyaddr(tp->pdev); in tg3_mdio_init()
1528 tp->phy_addr = addr; in tg3_mdio_init()
1530 tp->phy_addr = TG3_PHY_MII_ADDR; in tg3_mdio_init()
1537 tp->mdio_bus = mdiobus_alloc(); in tg3_mdio_init()
1538 if (tp->mdio_bus == NULL) in tg3_mdio_init()
1539 return -ENOMEM; in tg3_mdio_init()
1541 tp->mdio_bus->name = "tg3 mdio bus"; in tg3_mdio_init()
1542 snprintf(tp->mdio_bus->id, MII_BUS_ID_SIZE, "%x", pci_dev_id(tp->pdev)); in tg3_mdio_init()
1543 tp->mdio_bus->priv = tp; in tg3_mdio_init()
1544 tp->mdio_bus->parent = &tp->pdev->dev; in tg3_mdio_init()
1545 tp->mdio_bus->read = &tg3_mdio_read; in tg3_mdio_init()
1546 tp->mdio_bus->write = &tg3_mdio_write; in tg3_mdio_init()
1547 tp->mdio_bus->phy_mask = ~(1 << tp->phy_addr); in tg3_mdio_init()
1557 i = mdiobus_register(tp->mdio_bus); in tg3_mdio_init()
1559 dev_warn(&tp->pdev->dev, "mdiobus_reg failed (0x%x)\n", i); in tg3_mdio_init()
1560 mdiobus_free(tp->mdio_bus); in tg3_mdio_init()
1564 phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); in tg3_mdio_init()
1566 if (!phydev || !phydev->drv) { in tg3_mdio_init()
1567 dev_warn(&tp->pdev->dev, "No PHY devices\n"); in tg3_mdio_init()
1568 mdiobus_unregister(tp->mdio_bus); in tg3_mdio_init()
1569 mdiobus_free(tp->mdio_bus); in tg3_mdio_init()
1570 return -ENODEV; in tg3_mdio_init()
1573 switch (phydev->drv->phy_id & phydev->drv->phy_id_mask) { in tg3_mdio_init()
1575 phydev->interface = PHY_INTERFACE_MODE_GMII; in tg3_mdio_init()
1576 phydev->dev_flags |= PHY_BRCM_AUTO_PWRDWN_ENABLE; in tg3_mdio_init()
1580 phydev->dev_flags |= PHY_BRCM_CLEAR_RGMII_MODE | in tg3_mdio_init()
1586 phydev->interface = PHY_INTERFACE_MODE_RGMII; in tg3_mdio_init()
1590 phydev->interface = PHY_INTERFACE_MODE_MII; in tg3_mdio_init()
1591 phydev->dev_flags |= PHY_BRCM_AUTO_PWRDWN_ENABLE; in tg3_mdio_init()
1592 tp->phy_flags |= TG3_PHYFLG_IS_FET; in tg3_mdio_init()
1608 mdiobus_unregister(tp->mdio_bus); in tg3_mdio_fini()
1609 mdiobus_free(tp->mdio_bus); in tg3_mdio_fini()
1613 /* tp->lock is held. */
1622 tp->last_event_jiffies = jiffies; in tg3_generate_fw_event()
1627 /* tp->lock is held. */
1635 time_remain = (long)(tp->last_event_jiffies + 1 + in tg3_wait_for_event_ack()
1636 usecs_to_jiffies(TG3_FW_EVENT_TIMEOUT_USEC)) - in tg3_wait_for_event_ack()
1650 if (pci_channel_offline(tp->pdev)) in tg3_wait_for_event_ack()
1657 /* tp->lock is held. */
1677 if (!(tp->phy_flags & TG3_PHYFLG_MII_SERDES)) { in tg3_phy_gather_ump_data()
1692 /* tp->lock is held. */
1714 /* tp->lock is held. */
1730 /* tp->lock is held. */
1759 /* tp->lock is held. */
1780 /* tp->lock is held. */
1824 if (pci_channel_offline(tp->pdev)) in tg3_poll_fw()
1825 return -ENODEV; in tg3_poll_fw()
1829 return -ENODEV; in tg3_poll_fw()
1837 if (pci_channel_offline(tp->pdev)) { in tg3_poll_fw()
1840 netdev_info(tp->dev, "No firmware running\n"); in tg3_poll_fw()
1857 netdev_info(tp->dev, "No firmware running\n"); in tg3_poll_fw()
1872 if (!netif_carrier_ok(tp->dev)) { in tg3_link_report()
1873 netif_info(tp, link, tp->dev, "Link is down\n"); in tg3_link_report()
1876 netdev_info(tp->dev, "Link is up at %d Mbps, %s duplex\n", in tg3_link_report()
1877 (tp->link_config.active_speed == SPEED_1000 ? in tg3_link_report()
1879 (tp->link_config.active_speed == SPEED_100 ? in tg3_link_report()
1881 (tp->link_config.active_duplex == DUPLEX_FULL ? in tg3_link_report()
1884 netdev_info(tp->dev, "Flow control is %s for TX and %s for RX\n", in tg3_link_report()
1885 (tp->link_config.active_flowctrl & FLOW_CTRL_TX) ? in tg3_link_report()
1887 (tp->link_config.active_flowctrl & FLOW_CTRL_RX) ? in tg3_link_report()
1890 if (tp->phy_flags & TG3_PHYFLG_EEE_CAP) in tg3_link_report()
1891 netdev_info(tp->dev, "EEE is %s\n", in tg3_link_report()
1892 tp->setlpicnt ? "enabled" : "disabled"); in tg3_link_report()
1897 tp->link_up = netif_carrier_ok(tp->dev); in tg3_link_report()
1900 static u32 tg3_decode_flowctrl_1000T(u32 adv) in tg3_decode_flowctrl_1000T() argument
1904 if (adv & ADVERTISE_PAUSE_CAP) { in tg3_decode_flowctrl_1000T()
1906 if (!(adv & ADVERTISE_PAUSE_ASYM)) in tg3_decode_flowctrl_1000T()
1908 } else if (adv & ADVERTISE_PAUSE_ASYM) in tg3_decode_flowctrl_1000T()
1930 static u32 tg3_decode_flowctrl_1000X(u32 adv) in tg3_decode_flowctrl_1000X() argument
1934 if (adv & ADVERTISE_1000XPAUSE) { in tg3_decode_flowctrl_1000X()
1936 if (!(adv & ADVERTISE_1000XPSE_ASYM)) in tg3_decode_flowctrl_1000X()
1938 } else if (adv & ADVERTISE_1000XPSE_ASYM) in tg3_decode_flowctrl_1000X()
1964 u32 old_rx_mode = tp->rx_mode; in tg3_setup_flow_control()
1965 u32 old_tx_mode = tp->tx_mode; in tg3_setup_flow_control()
1968 autoneg = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr)->autoneg; in tg3_setup_flow_control()
1970 autoneg = tp->link_config.autoneg; in tg3_setup_flow_control()
1973 if (tp->phy_flags & TG3_PHYFLG_ANY_SERDES) in tg3_setup_flow_control()
1978 flowctrl = tp->link_config.flowctrl; in tg3_setup_flow_control()
1980 tp->link_config.active_flowctrl = flowctrl; in tg3_setup_flow_control()
1983 tp->rx_mode |= RX_MODE_FLOW_CTRL_ENABLE; in tg3_setup_flow_control()
1985 tp->rx_mode &= ~RX_MODE_FLOW_CTRL_ENABLE; in tg3_setup_flow_control()
1987 if (old_rx_mode != tp->rx_mode) in tg3_setup_flow_control()
1988 tw32_f(MAC_RX_MODE, tp->rx_mode); in tg3_setup_flow_control()
1991 tp->tx_mode |= TX_MODE_FLOW_CTRL_ENABLE; in tg3_setup_flow_control()
1993 tp->tx_mode &= ~TX_MODE_FLOW_CTRL_ENABLE; in tg3_setup_flow_control()
1995 if (old_tx_mode != tp->tx_mode) in tg3_setup_flow_control()
1996 tw32_f(MAC_TX_MODE, tp->tx_mode); in tg3_setup_flow_control()
2004 struct phy_device *phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); in tg3_adjust_link()
2006 spin_lock_bh(&tp->lock); in tg3_adjust_link()
2008 mac_mode = tp->mac_mode & ~(MAC_MODE_PORT_MODE_MASK | in tg3_adjust_link()
2011 oldflowctrl = tp->link_config.active_flowctrl; in tg3_adjust_link()
2013 if (phydev->link) { in tg3_adjust_link()
2017 if (phydev->speed == SPEED_100 || phydev->speed == SPEED_10) in tg3_adjust_link()
2019 else if (phydev->speed == SPEED_1000 || in tg3_adjust_link()
2025 if (phydev->duplex == DUPLEX_HALF) in tg3_adjust_link()
2029 tp->link_config.flowctrl); in tg3_adjust_link()
2031 if (phydev->pause) in tg3_adjust_link()
2033 if (phydev->asym_pause) in tg3_adjust_link()
2041 if (mac_mode != tp->mac_mode) { in tg3_adjust_link()
2042 tp->mac_mode = mac_mode; in tg3_adjust_link()
2043 tw32_f(MAC_MODE, tp->mac_mode); in tg3_adjust_link()
2048 if (phydev->speed == SPEED_10) in tg3_adjust_link()
2056 if (phydev->speed == SPEED_1000 && phydev->duplex == DUPLEX_HALF) in tg3_adjust_link()
2067 if (phydev->link != tp->old_link || in tg3_adjust_link()
2068 phydev->speed != tp->link_config.active_speed || in tg3_adjust_link()
2069 phydev->duplex != tp->link_config.active_duplex || in tg3_adjust_link()
2070 oldflowctrl != tp->link_config.active_flowctrl) in tg3_adjust_link()
2073 tp->old_link = phydev->link; in tg3_adjust_link()
2074 tp->link_config.active_speed = phydev->speed; in tg3_adjust_link()
2075 tp->link_config.active_duplex = phydev->duplex; in tg3_adjust_link()
2077 spin_unlock_bh(&tp->lock); in tg3_adjust_link()
2087 if (tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) in tg3_phy_init()
2093 phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); in tg3_phy_init()
2096 phydev = phy_connect(tp->dev, phydev_name(phydev), in tg3_phy_init()
2097 tg3_adjust_link, phydev->interface); in tg3_phy_init()
2099 dev_err(&tp->pdev->dev, "Could not attach to PHY\n"); in tg3_phy_init()
2104 switch (phydev->interface) { in tg3_phy_init()
2107 if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) { in tg3_phy_init()
2118 phy_disconnect(mdiobus_get_phy(tp->mdio_bus, tp->phy_addr)); in tg3_phy_init()
2119 return -EINVAL; in tg3_phy_init()
2122 tp->phy_flags |= TG3_PHYFLG_IS_CONNECTED; in tg3_phy_init()
2133 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) in tg3_phy_start()
2136 phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); in tg3_phy_start()
2138 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) { in tg3_phy_start()
2139 tp->phy_flags &= ~TG3_PHYFLG_IS_LOW_POWER; in tg3_phy_start()
2140 phydev->speed = tp->link_config.speed; in tg3_phy_start()
2141 phydev->duplex = tp->link_config.duplex; in tg3_phy_start()
2142 phydev->autoneg = tp->link_config.autoneg; in tg3_phy_start()
2144 phydev->advertising, tp->link_config.advertising); in tg3_phy_start()
2154 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) in tg3_phy_stop()
2157 phy_stop(mdiobus_get_phy(tp->mdio_bus, tp->phy_addr)); in tg3_phy_stop()
2162 if (tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) { in tg3_phy_fini()
2163 phy_disconnect(mdiobus_get_phy(tp->mdio_bus, tp->phy_addr)); in tg3_phy_fini()
2164 tp->phy_flags &= ~TG3_PHYFLG_IS_CONNECTED; in tg3_phy_fini()
2173 if (tp->phy_flags & TG3_PHYFLG_IS_FET) in tg3_phy_set_extloopbk()
2176 if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5401) { in tg3_phy_set_extloopbk()
2177 /* Cannot do read-modify-write on 5401 */ in tg3_phy_set_extloopbk()
2224 (tp->phy_flags & TG3_PHYFLG_MII_SERDES))) in tg3_phy_toggle_apd()
2227 if (tp->phy_flags & TG3_PHYFLG_IS_FET) { in tg3_phy_toggle_apd()
2254 (tp->phy_flags & TG3_PHYFLG_ANY_SERDES)) in tg3_phy_toggle_automdix()
2257 if (tp->phy_flags & TG3_PHYFLG_IS_FET) { in tg3_phy_toggle_automdix()
2295 if (tp->phy_flags & TG3_PHYFLG_NO_ETH_WIRE_SPEED) in tg3_phy_set_wirespeed()
2308 if (!tp->phy_otp) in tg3_phy_apply_otp()
2311 otp = tp->phy_otp; in tg3_phy_apply_otp()
2344 struct ethtool_eee *dest = &tp->eee; in tg3_eee_pull_config()
2346 if (!(tp->phy_flags & TG3_PHYFLG_EEE_CAP)) in tg3_eee_pull_config()
2355 /* Pull eee_active */ in tg3_eee_pull_config()
2358 dest->eee_active = 1; in tg3_eee_pull_config()
2360 dest->eee_active = 0; in tg3_eee_pull_config()
2362 /* Pull lp advertised settings */ in tg3_eee_pull_config()
2365 dest->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(val); in tg3_eee_pull_config()
2367 /* Pull advertised and eee_enabled settings */ in tg3_eee_pull_config()
2370 dest->eee_enabled = !!val; in tg3_eee_pull_config()
2371 dest->advertised = mmd_eee_adv_to_ethtool_adv_t(val); in tg3_eee_pull_config()
2373 /* Pull tx_lpi_enabled */ in tg3_eee_pull_config()
2375 dest->tx_lpi_enabled = !!(val & TG3_CPMU_EEEMD_LPI_IN_TX); in tg3_eee_pull_config()
2377 /* Pull lpi timer value */ in tg3_eee_pull_config()
2378 dest->tx_lpi_timer = tr32(TG3_CPMU_EEE_DBTMR1) & 0xffff; in tg3_eee_pull_config()
2385 if (!(tp->phy_flags & TG3_PHYFLG_EEE_CAP)) in tg3_phy_eee_adjust()
2388 tp->setlpicnt = 0; in tg3_phy_eee_adjust()
2390 if (tp->link_config.autoneg == AUTONEG_ENABLE && in tg3_phy_eee_adjust()
2392 tp->link_config.active_duplex == DUPLEX_FULL && in tg3_phy_eee_adjust()
2393 (tp->link_config.active_speed == SPEED_100 || in tg3_phy_eee_adjust()
2394 tp->link_config.active_speed == SPEED_1000)) { in tg3_phy_eee_adjust()
2397 if (tp->link_config.active_speed == SPEED_1000) in tg3_phy_eee_adjust()
2405 if (tp->eee.eee_active) in tg3_phy_eee_adjust()
2406 tp->setlpicnt = 2; in tg3_phy_eee_adjust()
2409 if (!tp->setlpicnt) { in tg3_phy_eee_adjust()
2425 if (tp->link_config.active_speed == SPEED_1000 && in tg3_phy_eee_enable()
2444 while (limit--) { in tg3_wait_macro_done()
2453 return -EBUSY; in tg3_wait_macro_done()
2482 return -EBUSY; in tg3_phy_write_and_check_testpat()
2490 return -EBUSY; in tg3_phy_write_and_check_testpat()
2496 return -EBUSY; in tg3_phy_write_and_check_testpat()
2506 return -EBUSY; in tg3_phy_write_and_check_testpat()
2516 return -EBUSY; in tg3_phy_write_and_check_testpat()
2538 return -EBUSY; in tg3_phy_reset_chanpat()
2566 /* Set full-duplex, 1000 mbps. */ in tg3_phy_reset_5703_4_5()
2587 } while (--retries); in tg3_phy_reset_5703_4_5()
2614 netif_carrier_off(tp->dev); in tg3_carrier_off()
2615 tp->link_up = false; in tg3_carrier_off()
2621 netdev_warn(tp->dev, in tg3_warn_mgmt_link_flap()
2622 "Management side-band traffic will be interrupted during phy settings change\n"); in tg3_warn_mgmt_link_flap()
2626 * link unless the FORCE argument is non-zero.
2641 return -EBUSY; in tg3_phy_reset()
2643 if (netif_running(tp->dev) && tp->link_up) { in tg3_phy_reset()
2644 netif_carrier_off(tp->dev); in tg3_phy_reset()
2689 (tp->phy_flags & TG3_PHYFLG_MII_SERDES)) in tg3_phy_reset()
2694 if (tp->phy_flags & TG3_PHYFLG_ENABLE_APD) in tg3_phy_reset()
2700 if ((tp->phy_flags & TG3_PHYFLG_ADC_BUG) && in tg3_phy_reset()
2707 if (tp->phy_flags & TG3_PHYFLG_5704_A0_BUG) { in tg3_phy_reset()
2712 if (tp->phy_flags & TG3_PHYFLG_BER_BUG) { in tg3_phy_reset()
2719 } else if (tp->phy_flags & TG3_PHYFLG_JITTER_BUG) { in tg3_phy_reset()
2722 if (tp->phy_flags & TG3_PHYFLG_ADJUST_TRIM) { in tg3_phy_reset()
2735 if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5401) { in tg3_phy_reset()
2736 /* Cannot do read-modify-write on 5401 */ in tg3_phy_reset()
2739 /* Set bit 14 with read-modify-write to preserve other bits */ in tg3_phy_reset()
2795 shift = TG3_APE_GPIO_MSG_SHIFT + 4 * tp->pci_fn; in tg3_set_function_status()
2817 return -EIO; in tg3_pwrsrc_switch_to_vmain()
2821 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, in tg3_pwrsrc_switch_to_vmain()
2826 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, in tg3_pwrsrc_switch_to_vmain()
2842 grc_local_ctrl = tp->grc_local_ctrl | GRC_LCLCTRL_GPIO_OE1; in tg3_pwrsrc_die_with_vmain()
2864 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | in tg3_pwrsrc_switch_to_vaux()
2871 } else if (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5761 || in tg3_pwrsrc_switch_to_vaux()
2872 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5761S) { in tg3_pwrsrc_switch_to_vaux()
2873 /* The 5761 non-e device swaps GPIO 0 and GPIO 2. */ in tg3_pwrsrc_switch_to_vaux()
2879 tp->grc_local_ctrl; in tg3_pwrsrc_switch_to_vaux()
2897 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | in tg3_pwrsrc_switch_to_vaux()
2903 no_gpio2 = tp->nic_sram_data_cfg & in tg3_pwrsrc_switch_to_vaux()
2916 tp->grc_local_ctrl | grc_local_ctrl, in tg3_pwrsrc_switch_to_vaux()
2922 tp->grc_local_ctrl | grc_local_ctrl, in tg3_pwrsrc_switch_to_vaux()
2928 tp->grc_local_ctrl | grc_local_ctrl, in tg3_pwrsrc_switch_to_vaux()
2975 if (tp->pdev_peer && tp->pdev_peer != tp->pdev) { in tg3_frob_aux_power()
2978 dev_peer = pci_get_drvdata(tp->pdev_peer); in tg3_frob_aux_power()
3005 if (tp->led_ctrl == LED_CTRL_MODE_PHY_2) in tg3_5700_link_polarity()
3007 else if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5411) { in tg3_5700_link_polarity()
3023 if (tp->phy_flags & TG3_PHYFLG_MII_SERDES) in tg3_phy_power_bug()
3027 if (!tp->pci_fn) in tg3_phy_power_bug()
3032 if ((tp->phy_flags & TG3_PHYFLG_PHY_SERDES) && in tg3_phy_power_bug()
3033 !tp->pci_fn) in tg3_phy_power_bug()
3046 if ((tp->phy_flags & TG3_PHYFLG_MII_SERDES) && in tg3_phy_led_bug()
3047 !tp->pci_fn) in tg3_phy_led_bug()
3059 if (tp->phy_flags & TG3_PHYFLG_KEEP_LINK_ON_PWRDN) in tg3_power_down_phy()
3062 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) { in tg3_power_down_phy()
3081 } else if (tp->phy_flags & TG3_PHYFLG_IS_FET) { in tg3_power_down_phy()
3112 /* The PHY should not be powered down on some chips because in tg3_power_down_phy()
3129 /* tp->lock is held. */
3135 if (tp->nvram_lock_cnt == 0) { in tg3_nvram_lock()
3144 return -ENODEV; in tg3_nvram_lock()
3147 tp->nvram_lock_cnt++; in tg3_nvram_lock()
3152 /* tp->lock is held. */
3156 if (tp->nvram_lock_cnt > 0) in tg3_nvram_unlock()
3157 tp->nvram_lock_cnt--; in tg3_nvram_unlock()
3158 if (tp->nvram_lock_cnt == 0) in tg3_nvram_unlock()
3163 /* tp->lock is held. */
3173 /* tp->lock is held. */
3190 return -EINVAL; in tg3_nvram_read_using_eeprom()
3210 return -EBUSY; in tg3_nvram_read_using_eeprom()
3239 return -EBUSY; in tg3_nvram_exec_cmd()
3250 (tp->nvram_jedecnum == JEDEC_ATMEL)) in tg3_nvram_phys_addr()
3252 addr = ((addr / tp->nvram_pagesize) << in tg3_nvram_phys_addr()
3254 (addr % tp->nvram_pagesize); in tg3_nvram_phys_addr()
3265 (tp->nvram_jedecnum == JEDEC_ATMEL)) in tg3_nvram_logical_addr()
3268 tp->nvram_pagesize) + in tg3_nvram_logical_addr()
3269 (addr & ((1 << ATMEL_AT45DB0X1B_PAGE_POS) - 1)); in tg3_nvram_logical_addr()
3278 * machine, the 32-bit value will be byteswapped.
3290 return -EINVAL; in tg3_nvram_read()
3363 rc = -EBUSY; in tg3_nvram_write_block_using_eeprom()
3376 u32 pagesize = tp->nvram_pagesize; in tg3_nvram_write_block_unbuffered()
3377 u32 pagemask = pagesize - 1; in tg3_nvram_write_block_unbuffered()
3383 return -ENOMEM; in tg3_nvram_write_block_unbuffered()
3405 len -= size; in tg3_nvram_write_block_unbuffered()
3409 offset = offset + (pagesize - page_off); in tg3_nvram_write_block_unbuffered()
3451 else if (j == (pagesize - 4)) in tg3_nvram_write_block_unbuffered()
3483 page_off = offset % tp->nvram_pagesize; in tg3_nvram_write_block_buffered()
3491 if (page_off == (tp->nvram_pagesize - 4)) in tg3_nvram_write_block_buffered()
3494 if (i == (len - 4)) in tg3_nvram_write_block_buffered()
3504 (tp->nvram_jedecnum == JEDEC_ST) && in tg3_nvram_write_block_buffered()
3531 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl & in tg3_nvram_write_block()
3568 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); in tg3_nvram_write_block()
3580 /* tp->lock is held. */
3591 if (pci_channel_offline(tp->pdev)) in tg3_pause_cpu()
3592 return -EBUSY; in tg3_pause_cpu()
3595 return (i == iters) ? -EBUSY : 0; in tg3_pause_cpu()
3598 /* tp->lock is held. */
3610 /* tp->lock is held. */
3616 /* tp->lock is held. */
3623 /* tp->lock is held. */
3629 /* tp->lock is held. */
3656 netdev_err(tp->dev, "%s timed out, %s CPU\n", in tg3_halt_cpu()
3658 return -ENODEV; in tg3_halt_cpu()
3676 * tp->fw->size minus headers. in tg3_fw_data_len()
3686 if (tp->fw_len == 0xffffffff) in tg3_fw_data_len()
3687 fw_len = be32_to_cpu(fw_hdr->len); in tg3_fw_data_len()
3689 fw_len = tp->fw->size; in tg3_fw_data_len()
3691 return (fw_len - TG3_FW_HDR_LEN) / sizeof(u32); in tg3_fw_data_len()
3694 /* tp->lock is held. */
3701 int total_len = tp->fw->size; in tg3_load_firmware_cpu()
3704 netdev_err(tp->dev, in tg3_load_firmware_cpu()
3707 return -EINVAL; in tg3_load_firmware_cpu()
3735 total_len -= TG3_FW_HDR_LEN; in tg3_load_firmware_cpu()
3743 (be32_to_cpu(fw_hdr->base_addr) & 0xffff) + in tg3_load_firmware_cpu()
3747 total_len -= be32_to_cpu(fw_hdr->len); in tg3_load_firmware_cpu()
3751 ((void *)fw_hdr + be32_to_cpu(fw_hdr->len)); in tg3_load_firmware_cpu()
3760 /* tp->lock is held. */
3778 return (i == iters) ? -EBUSY : 0; in tg3_pause_cpu_and_set_pc()
3781 /* tp->lock is held. */
3787 fw_hdr = (struct tg3_firmware_hdr *)tp->fw->data; in tg3_load_5701_a0_firmware_fix()
3791 length = end_address_of_bss - start_address_of_text. in tg3_load_5701_a0_firmware_fix()
3809 be32_to_cpu(fw_hdr->base_addr)); in tg3_load_5701_a0_firmware_fix()
3811 netdev_err(tp->dev, "%s fails to set RX CPU PC, is %08x " in tg3_load_5701_a0_firmware_fix()
3814 be32_to_cpu(fw_hdr->base_addr)); in tg3_load_5701_a0_firmware_fix()
3815 return -ENODEV; in tg3_load_5701_a0_firmware_fix()
3840 netdev_err(tp->dev, "Boot code not ready for service patches\n"); in tg3_validate_rxcpu_state()
3841 return -EBUSY; in tg3_validate_rxcpu_state()
3846 netdev_warn(tp->dev, in tg3_validate_rxcpu_state()
3848 return -EEXIST; in tg3_validate_rxcpu_state()
3854 /* tp->lock is held. */
3865 if (!tp->fw) in tg3_load_57766_firmware()
3870 * data to be written to non-contiguous locations. in tg3_load_57766_firmware()
3882 fw_hdr = (struct tg3_firmware_hdr *)tp->fw->data; in tg3_load_57766_firmware()
3883 if (be32_to_cpu(fw_hdr->base_addr) != TG3_57766_FW_BASE_ADDR) in tg3_load_57766_firmware()
3895 /* tp->lock is held. */
3905 fw_hdr = (struct tg3_firmware_hdr *)tp->fw->data; in tg3_load_tso_firmware()
3909 length = end_address_of_bss - start_address_of_text. in tg3_load_tso_firmware()
3913 cpu_scratch_size = tp->fw_len; in tg3_load_tso_firmware()
3932 be32_to_cpu(fw_hdr->base_addr)); in tg3_load_tso_firmware()
3934 netdev_err(tp->dev, in tg3_load_tso_firmware()
3937 be32_to_cpu(fw_hdr->base_addr)); in tg3_load_tso_firmware()
3938 return -ENODEV; in tg3_load_tso_firmware()
3945 /* tp->lock is held. */
3959 index -= 4; in __tg3_set_one_mac_addr()
3965 /* tp->lock is held. */
3974 __tg3_set_one_mac_addr(tp, tp->dev->dev_addr, i); in __tg3_set_mac_addr()
3980 __tg3_set_one_mac_addr(tp, tp->dev->dev_addr, i); in __tg3_set_mac_addr()
3983 addr_high = (tp->dev->dev_addr[0] + in __tg3_set_mac_addr()
3984 tp->dev->dev_addr[1] + in __tg3_set_mac_addr()
3985 tp->dev->dev_addr[2] + in __tg3_set_mac_addr()
3986 tp->dev->dev_addr[3] + in __tg3_set_mac_addr()
3987 tp->dev->dev_addr[4] + in __tg3_set_mac_addr()
3988 tp->dev->dev_addr[5]) & in __tg3_set_mac_addr()
3999 pci_write_config_dword(tp->pdev, in tg3_enable_register_access()
4000 TG3PCI_MISC_HOST_CTRL, tp->misc_host_ctrl); in tg3_enable_register_access()
4009 err = pci_set_power_state(tp->pdev, PCI_D0); in tg3_power_up()
4014 netdev_err(tp->dev, "Transition to D0 failed\n"); in tg3_power_up()
4031 pcie_capability_set_word(tp->pdev, PCI_EXP_LNKCTL, in tg3_power_down_prepare()
4038 device_should_wake = device_may_wakeup(&tp->pdev->dev) && in tg3_power_down_prepare()
4043 if ((tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) && in tg3_power_down_prepare()
4044 !(tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)) { in tg3_power_down_prepare()
4049 phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); in tg3_power_down_prepare()
4051 tp->phy_flags |= TG3_PHYFLG_IS_LOW_POWER; in tg3_power_down_prepare()
4053 tp->link_config.speed = phydev->speed; in tg3_power_down_prepare()
4054 tp->link_config.duplex = phydev->duplex; in tg3_power_down_prepare()
4055 tp->link_config.autoneg = phydev->autoneg; in tg3_power_down_prepare()
4057 &tp->link_config.advertising, in tg3_power_down_prepare()
4058 phydev->advertising); in tg3_power_down_prepare()
4082 linkmode_copy(phydev->advertising, advertising); in tg3_power_down_prepare()
4085 phyid = phydev->drv->phy_id & phydev->drv->phy_id_mask; in tg3_power_down_prepare()
4097 if (!(tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)) in tg3_power_down_prepare()
4098 tp->phy_flags |= TG3_PHYFLG_IS_LOW_POWER; in tg3_power_down_prepare()
4100 if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES)) in tg3_power_down_prepare()
4129 if (!(tp->phy_flags & TG3_PHYFLG_PHY_SERDES)) { in tg3_power_down_prepare()
4131 !(tp->phy_flags & TG3_PHYFLG_IS_FET)) { in tg3_power_down_prepare()
4140 if (tp->phy_flags & TG3_PHYFLG_MII_SERDES) in tg3_power_down_prepare()
4142 else if (tp->phy_flags & in tg3_power_down_prepare()
4144 if (tp->link_config.active_speed == SPEED_1000) in tg3_power_down_prepare()
4151 mac_mode |= tp->mac_mode & MAC_MODE_LINK_POLARITY; in tg3_power_down_prepare()
4165 tw32(MAC_LED_CTRL, tp->led_ctrl); in tg3_power_down_prepare()
4189 base_val = tp->pci_clock_ctrl; in tg3_power_down_prepare()
4216 tw32_wait_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits1, in tg3_power_down_prepare()
4219 tw32_wait_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits2, in tg3_power_down_prepare()
4235 tp->pci_clock_ctrl | newbits3, 40); in tg3_power_down_prepare()
4271 pci_wake_from_d3(tp->pdev, tg3_flag(tp, WOL_ENABLE)); in tg3_power_down()
4272 pci_set_power_state(tp->pdev, PCI_D3hot); in tg3_power_down()
4309 if (tp->phy_flags & TG3_PHYFLG_IS_FET) { in tg3_aux_stat_to_speed_duplex()
4335 if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) { in tg3_phy_autoneg_cfg()
4347 if (!(tp->phy_flags & TG3_PHYFLG_EEE_CAP)) in tg3_phy_autoneg_cfg()
4358 /* Advertise 100-BaseTX EEE ability */ in tg3_phy_autoneg_cfg()
4361 /* Advertise 1000-BaseT EEE ability */ in tg3_phy_autoneg_cfg()
4365 if (!tp->eee.eee_enabled) { in tg3_phy_autoneg_cfg()
4367 tp->eee.advertised = 0; in tg3_phy_autoneg_cfg()
4369 tp->eee.advertised = advertise & in tg3_phy_autoneg_cfg()
4408 if (tp->link_config.autoneg == AUTONEG_ENABLE || in tg3_phy_copper_begin()
4409 (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)) { in tg3_phy_copper_begin()
4410 u32 adv, fc; in tg3_phy_copper_begin() local
4412 if ((tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) && in tg3_phy_copper_begin()
4413 !(tp->phy_flags & TG3_PHYFLG_KEEP_LINK_ON_PWRDN)) { in tg3_phy_copper_begin()
4414 adv = ADVERTISED_10baseT_Half | in tg3_phy_copper_begin()
4417 adv |= ADVERTISED_100baseT_Half | in tg3_phy_copper_begin()
4419 if (tp->phy_flags & TG3_PHYFLG_1G_ON_VAUX_OK) { in tg3_phy_copper_begin()
4420 if (!(tp->phy_flags & in tg3_phy_copper_begin()
4422 adv |= ADVERTISED_1000baseT_Half; in tg3_phy_copper_begin()
4423 adv |= ADVERTISED_1000baseT_Full; in tg3_phy_copper_begin()
4428 adv = tp->link_config.advertising; in tg3_phy_copper_begin()
4429 if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY) in tg3_phy_copper_begin()
4430 adv &= ~(ADVERTISED_1000baseT_Half | in tg3_phy_copper_begin()
4433 fc = tp->link_config.flowctrl; in tg3_phy_copper_begin()
4436 tg3_phy_autoneg_cfg(tp, adv, fc); in tg3_phy_copper_begin()
4438 if ((tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) && in tg3_phy_copper_begin()
4439 (tp->phy_flags & TG3_PHYFLG_KEEP_LINK_ON_PWRDN)) { in tg3_phy_copper_begin()
4440 /* Normally during power down we want to autonegotiate in tg3_phy_copper_begin()
4453 tp->link_config.active_speed = tp->link_config.speed; in tg3_phy_copper_begin()
4454 tp->link_config.active_duplex = tp->link_config.duplex; in tg3_phy_copper_begin()
4465 switch (tp->link_config.speed) { in tg3_phy_copper_begin()
4479 if (tp->link_config.duplex == DUPLEX_FULL) in tg3_phy_copper_begin()
4513 tp->link_config.autoneg = AUTONEG_DISABLE; in tg3_phy_pull_config()
4514 tp->link_config.advertising = 0; in tg3_phy_pull_config()
4517 err = -EIO; in tg3_phy_pull_config()
4521 if (tp->phy_flags & TG3_PHYFLG_ANY_SERDES) in tg3_phy_pull_config()
4524 tp->link_config.speed = SPEED_10; in tg3_phy_pull_config()
4527 if (tp->phy_flags & TG3_PHYFLG_ANY_SERDES) in tg3_phy_pull_config()
4530 tp->link_config.speed = SPEED_100; in tg3_phy_pull_config()
4533 if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) { in tg3_phy_pull_config()
4534 tp->link_config.speed = SPEED_1000; in tg3_phy_pull_config()
4543 tp->link_config.duplex = DUPLEX_FULL; in tg3_phy_pull_config()
4545 tp->link_config.duplex = DUPLEX_HALF; in tg3_phy_pull_config()
4547 tp->link_config.flowctrl = FLOW_CTRL_RX | FLOW_CTRL_TX; in tg3_phy_pull_config()
4553 tp->link_config.autoneg = AUTONEG_ENABLE; in tg3_phy_pull_config()
4554 tp->link_config.advertising = ADVERTISED_Autoneg; in tg3_phy_pull_config()
4557 if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES)) { in tg3_phy_pull_config()
4558 u32 adv; in tg3_phy_pull_config() local
4564 adv = mii_adv_to_ethtool_adv_t(val & ADVERTISE_ALL); in tg3_phy_pull_config()
4565 tp->link_config.advertising |= adv | ADVERTISED_TP; in tg3_phy_pull_config()
4567 tp->link_config.flowctrl = tg3_decode_flowctrl_1000T(val); in tg3_phy_pull_config()
4569 tp->link_config.advertising |= ADVERTISED_FIBRE; in tg3_phy_pull_config()
4572 if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) { in tg3_phy_pull_config()
4573 u32 adv; in tg3_phy_pull_config() local
4575 if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES)) { in tg3_phy_pull_config()
4580 adv = mii_ctrl1000_to_ethtool_adv_t(val); in tg3_phy_pull_config()
4586 adv = tg3_decode_flowctrl_1000X(val); in tg3_phy_pull_config()
4587 tp->link_config.flowctrl = adv; in tg3_phy_pull_config()
4590 adv = mii_adv_to_ethtool_adv_x(val); in tg3_phy_pull_config()
4593 tp->link_config.advertising |= adv; in tg3_phy_pull_config()
4623 if (!(tp->phy_flags & TG3_PHYFLG_EEE_CAP)) in tg3_phy_eee_config_ok()
4628 if (tp->eee.eee_enabled) { in tg3_phy_eee_config_ok()
4629 if (tp->eee.advertised != eee.advertised || in tg3_phy_eee_config_ok()
4630 tp->eee.tx_lpi_timer != eee.tx_lpi_timer || in tg3_phy_eee_config_ok()
4631 tp->eee.tx_lpi_enabled != eee.tx_lpi_enabled) in tg3_phy_eee_config_ok()
4646 advertising = tp->link_config.advertising; in tg3_phy_copper_an_config_ok()
4650 if (tp->link_config.active_duplex == DUPLEX_FULL) { in tg3_phy_copper_an_config_ok()
4651 tgtadv |= mii_advertise_flowctrl(tp->link_config.flowctrl); in tg3_phy_copper_an_config_ok()
4661 if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) { in tg3_phy_copper_an_config_ok()
4690 if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) { in tg3_phy_copper_fetch_rmtadv()
4703 tp->link_config.rmt_adv = lpeth; in tg3_phy_copper_fetch_rmtadv()
4710 if (curr_link_up != tp->link_up) { in tg3_test_and_report_link_chg()
4712 netif_carrier_on(tp->dev); in tg3_test_and_report_link_chg()
4714 netif_carrier_off(tp->dev); in tg3_test_and_report_link_chg()
4715 if (tp->phy_flags & TG3_PHYFLG_MII_SERDES) in tg3_test_and_report_link_chg()
4716 tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT; in tg3_test_and_report_link_chg()
4753 (tp->eee.tx_lpi_enabled ? TG3_CPMU_EEEMD_LPI_IN_TX : 0) | in tg3_setup_eee()
4763 tw32_f(TG3_CPMU_EEE_MODE, tp->eee.eee_enabled ? val : 0); in tg3_setup_eee()
4767 (tp->eee.tx_lpi_timer & 0xffff)); in tg3_setup_eee()
4785 if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) { in tg3_setup_copper_phy()
4787 (tp->mi_mode & ~MAC_MI_MODE_AUTO_POLL)); in tg3_setup_copper_phy()
4793 /* Some third-party PHYs need to be reset on link going in tg3_setup_copper_phy()
4794 * down. in tg3_setup_copper_phy()
4799 tp->link_up) { in tg3_setup_copper_phy()
4808 if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5401) { in tg3_setup_copper_phy()
4829 if ((tp->phy_id & TG3_PHY_ID_REV_MASK) == in tg3_setup_copper_phy()
4832 tp->link_config.active_speed == SPEED_1000) { in tg3_setup_copper_phy()
4853 if (tp->phy_flags & TG3_PHYFLG_USE_MI_INTERRUPT) in tg3_setup_copper_phy()
4855 else if (!(tp->phy_flags & TG3_PHYFLG_IS_FET)) in tg3_setup_copper_phy()
4860 if (tp->led_ctrl == LED_CTRL_MODE_PHY_1) in tg3_setup_copper_phy()
4870 tp->phy_flags &= ~TG3_PHYFLG_MDIX_STATE; in tg3_setup_copper_phy()
4871 tp->link_config.rmt_adv = 0; in tg3_setup_copper_phy()
4873 if (tp->phy_flags & TG3_PHYFLG_CAPACITIVE_COUPLING) { in tg3_setup_copper_phy()
4922 tp->link_config.active_speed = current_speed; in tg3_setup_copper_phy()
4923 tp->link_config.active_duplex = current_duplex; in tg3_setup_copper_phy()
4925 if (tp->link_config.autoneg == AUTONEG_ENABLE) { in tg3_setup_copper_phy()
4939 (tp->phy_flags & TG3_PHYFLG_KEEP_LINK_ON_PWRDN) && in tg3_setup_copper_phy()
4946 tp->link_config.speed == current_speed && in tg3_setup_copper_phy()
4947 tp->link_config.duplex == current_duplex) { in tg3_setup_copper_phy()
4953 tp->link_config.active_duplex == DUPLEX_FULL) { in tg3_setup_copper_phy()
4956 if (tp->phy_flags & TG3_PHYFLG_IS_FET) { in tg3_setup_copper_phy()
4965 tp->phy_flags |= TG3_PHYFLG_MDIX_STATE; in tg3_setup_copper_phy()
4972 if (!current_link_up || (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)) { in tg3_setup_copper_phy()
4980 tp->link_config.active_speed = current_speed; in tg3_setup_copper_phy()
4981 tp->link_config.active_duplex = current_duplex; in tg3_setup_copper_phy()
4986 (tp->mac_mode & MAC_MODE_PORT_INT_LPBACK)) in tg3_setup_copper_phy()
4990 tp->mac_mode &= ~MAC_MODE_PORT_MODE_MASK; in tg3_setup_copper_phy()
4992 if (tp->link_config.active_speed == SPEED_100 || in tg3_setup_copper_phy()
4993 tp->link_config.active_speed == SPEED_10) in tg3_setup_copper_phy()
4994 tp->mac_mode |= MAC_MODE_PORT_MODE_MII; in tg3_setup_copper_phy()
4996 tp->mac_mode |= MAC_MODE_PORT_MODE_GMII; in tg3_setup_copper_phy()
4997 } else if (tp->phy_flags & TG3_PHYFLG_IS_FET) in tg3_setup_copper_phy()
4998 tp->mac_mode |= MAC_MODE_PORT_MODE_MII; in tg3_setup_copper_phy()
5000 tp->mac_mode |= MAC_MODE_PORT_MODE_GMII; in tg3_setup_copper_phy()
5009 if (tp->link_config.active_speed == SPEED_10) in tg3_setup_copper_phy()
5011 else if (tp->link_config.active_speed == SPEED_100) in tg3_setup_copper_phy()
5014 else if (tp->link_config.active_speed == SPEED_1000) in tg3_setup_copper_phy()
5022 tp->mac_mode &= ~MAC_MODE_HALF_DUPLEX; in tg3_setup_copper_phy()
5023 if (tp->link_config.active_duplex == DUPLEX_HALF) in tg3_setup_copper_phy()
5024 tp->mac_mode |= MAC_MODE_HALF_DUPLEX; in tg3_setup_copper_phy()
5028 tg3_5700_link_polarity(tp, tp->link_config.active_speed)) in tg3_setup_copper_phy()
5029 tp->mac_mode |= MAC_MODE_LINK_POLARITY; in tg3_setup_copper_phy()
5031 tp->mac_mode &= ~MAC_MODE_LINK_POLARITY; in tg3_setup_copper_phy()
5037 if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5411 && in tg3_setup_copper_phy()
5039 tp->mi_mode |= MAC_MI_MODE_AUTO_POLL; in tg3_setup_copper_phy()
5040 tw32_f(MAC_MI_MODE, tp->mi_mode); in tg3_setup_copper_phy()
5044 tw32_f(MAC_MODE, tp->mac_mode); in tg3_setup_copper_phy()
5059 tp->link_config.active_speed == SPEED_1000 && in tg3_setup_copper_phy()
5073 if (tp->link_config.active_speed == SPEED_100 || in tg3_setup_copper_phy()
5074 tp->link_config.active_speed == SPEED_10) in tg3_setup_copper_phy()
5075 pcie_capability_clear_word(tp->pdev, PCI_EXP_LNKCTL, in tg3_setup_copper_phy()
5078 pcie_capability_set_word(tp->pdev, PCI_EXP_LNKCTL, in tg3_setup_copper_phy()
5147 #define ANEG_FAILED -1
5159 if (ap->state == ANEG_STATE_UNKNOWN) { in tg3_fiber_aneg_smachine()
5160 ap->rxconfig = 0; in tg3_fiber_aneg_smachine()
5161 ap->link_time = 0; in tg3_fiber_aneg_smachine()
5162 ap->cur_time = 0; in tg3_fiber_aneg_smachine()
5163 ap->ability_match_cfg = 0; in tg3_fiber_aneg_smachine()
5164 ap->ability_match_count = 0; in tg3_fiber_aneg_smachine()
5165 ap->ability_match = 0; in tg3_fiber_aneg_smachine()
5166 ap->idle_match = 0; in tg3_fiber_aneg_smachine()
5167 ap->ack_match = 0; in tg3_fiber_aneg_smachine()
5169 ap->cur_time++; in tg3_fiber_aneg_smachine()
5174 if (rx_cfg_reg != ap->ability_match_cfg) { in tg3_fiber_aneg_smachine()
5175 ap->ability_match_cfg = rx_cfg_reg; in tg3_fiber_aneg_smachine()
5176 ap->ability_match = 0; in tg3_fiber_aneg_smachine()
5177 ap->ability_match_count = 0; in tg3_fiber_aneg_smachine()
5179 if (++ap->ability_match_count > 1) { in tg3_fiber_aneg_smachine()
5180 ap->ability_match = 1; in tg3_fiber_aneg_smachine()
5181 ap->ability_match_cfg = rx_cfg_reg; in tg3_fiber_aneg_smachine()
5185 ap->ack_match = 1; in tg3_fiber_aneg_smachine()
5187 ap->ack_match = 0; in tg3_fiber_aneg_smachine()
5189 ap->idle_match = 0; in tg3_fiber_aneg_smachine()
5191 ap->idle_match = 1; in tg3_fiber_aneg_smachine()
5192 ap->ability_match_cfg = 0; in tg3_fiber_aneg_smachine()
5193 ap->ability_match_count = 0; in tg3_fiber_aneg_smachine()
5194 ap->ability_match = 0; in tg3_fiber_aneg_smachine()
5195 ap->ack_match = 0; in tg3_fiber_aneg_smachine()
5200 ap->rxconfig = rx_cfg_reg; in tg3_fiber_aneg_smachine()
5203 switch (ap->state) { in tg3_fiber_aneg_smachine()
5205 if (ap->flags & (MR_AN_ENABLE | MR_RESTART_AN)) in tg3_fiber_aneg_smachine()
5206 ap->state = ANEG_STATE_AN_ENABLE; in tg3_fiber_aneg_smachine()
5210 ap->flags &= ~(MR_AN_COMPLETE | MR_PAGE_RX); in tg3_fiber_aneg_smachine()
5211 if (ap->flags & MR_AN_ENABLE) { in tg3_fiber_aneg_smachine()
5212 ap->link_time = 0; in tg3_fiber_aneg_smachine()
5213 ap->cur_time = 0; in tg3_fiber_aneg_smachine()
5214 ap->ability_match_cfg = 0; in tg3_fiber_aneg_smachine()
5215 ap->ability_match_count = 0; in tg3_fiber_aneg_smachine()
5216 ap->ability_match = 0; in tg3_fiber_aneg_smachine()
5217 ap->idle_match = 0; in tg3_fiber_aneg_smachine()
5218 ap->ack_match = 0; in tg3_fiber_aneg_smachine()
5220 ap->state = ANEG_STATE_RESTART_INIT; in tg3_fiber_aneg_smachine()
5222 ap->state = ANEG_STATE_DISABLE_LINK_OK; in tg3_fiber_aneg_smachine()
5227 ap->link_time = ap->cur_time; in tg3_fiber_aneg_smachine()
5228 ap->flags &= ~(MR_NP_LOADED); in tg3_fiber_aneg_smachine()
5229 ap->txconfig = 0; in tg3_fiber_aneg_smachine()
5231 tp->mac_mode |= MAC_MODE_SEND_CONFIGS; in tg3_fiber_aneg_smachine()
5232 tw32_f(MAC_MODE, tp->mac_mode); in tg3_fiber_aneg_smachine()
5236 ap->state = ANEG_STATE_RESTART; in tg3_fiber_aneg_smachine()
5240 delta = ap->cur_time - ap->link_time; in tg3_fiber_aneg_smachine()
5242 ap->state = ANEG_STATE_ABILITY_DETECT_INIT; in tg3_fiber_aneg_smachine()
5252 ap->flags &= ~(MR_TOGGLE_TX); in tg3_fiber_aneg_smachine()
5253 ap->txconfig = ANEG_CFG_FD; in tg3_fiber_aneg_smachine()
5254 flowctrl = tg3_advert_flowctrl_1000X(tp->link_config.flowctrl); in tg3_fiber_aneg_smachine()
5256 ap->txconfig |= ANEG_CFG_PS1; in tg3_fiber_aneg_smachine()
5258 ap->txconfig |= ANEG_CFG_PS2; in tg3_fiber_aneg_smachine()
5259 tw32(MAC_TX_AUTO_NEG, ap->txconfig); in tg3_fiber_aneg_smachine()
5260 tp->mac_mode |= MAC_MODE_SEND_CONFIGS; in tg3_fiber_aneg_smachine()
5261 tw32_f(MAC_MODE, tp->mac_mode); in tg3_fiber_aneg_smachine()
5264 ap->state = ANEG_STATE_ABILITY_DETECT; in tg3_fiber_aneg_smachine()
5268 if (ap->ability_match != 0 && ap->rxconfig != 0) in tg3_fiber_aneg_smachine()
5269 ap->state = ANEG_STATE_ACK_DETECT_INIT; in tg3_fiber_aneg_smachine()
5273 ap->txconfig |= ANEG_CFG_ACK; in tg3_fiber_aneg_smachine()
5274 tw32(MAC_TX_AUTO_NEG, ap->txconfig); in tg3_fiber_aneg_smachine()
5275 tp->mac_mode |= MAC_MODE_SEND_CONFIGS; in tg3_fiber_aneg_smachine()
5276 tw32_f(MAC_MODE, tp->mac_mode); in tg3_fiber_aneg_smachine()
5279 ap->state = ANEG_STATE_ACK_DETECT; in tg3_fiber_aneg_smachine()
5283 if (ap->ack_match != 0) { in tg3_fiber_aneg_smachine()
5284 if ((ap->rxconfig & ~ANEG_CFG_ACK) == in tg3_fiber_aneg_smachine()
5285 (ap->ability_match_cfg & ~ANEG_CFG_ACK)) { in tg3_fiber_aneg_smachine()
5286 ap->state = ANEG_STATE_COMPLETE_ACK_INIT; in tg3_fiber_aneg_smachine()
5288 ap->state = ANEG_STATE_AN_ENABLE; in tg3_fiber_aneg_smachine()
5290 } else if (ap->ability_match != 0 && in tg3_fiber_aneg_smachine()
5291 ap->rxconfig == 0) { in tg3_fiber_aneg_smachine()
5292 ap->state = ANEG_STATE_AN_ENABLE; in tg3_fiber_aneg_smachine()
5297 if (ap->rxconfig & ANEG_CFG_INVAL) { in tg3_fiber_aneg_smachine()
5301 ap->flags &= ~(MR_LP_ADV_FULL_DUPLEX | in tg3_fiber_aneg_smachine()
5310 if (ap->rxconfig & ANEG_CFG_FD) in tg3_fiber_aneg_smachine()
5311 ap->flags |= MR_LP_ADV_FULL_DUPLEX; in tg3_fiber_aneg_smachine()
5312 if (ap->rxconfig & ANEG_CFG_HD) in tg3_fiber_aneg_smachine()
5313 ap->flags |= MR_LP_ADV_HALF_DUPLEX; in tg3_fiber_aneg_smachine()
5314 if (ap->rxconfig & ANEG_CFG_PS1) in tg3_fiber_aneg_smachine()
5315 ap->flags |= MR_LP_ADV_SYM_PAUSE; in tg3_fiber_aneg_smachine()
5316 if (ap->rxconfig & ANEG_CFG_PS2) in tg3_fiber_aneg_smachine()
5317 ap->flags |= MR_LP_ADV_ASYM_PAUSE; in tg3_fiber_aneg_smachine()
5318 if (ap->rxconfig & ANEG_CFG_RF1) in tg3_fiber_aneg_smachine()
5319 ap->flags |= MR_LP_ADV_REMOTE_FAULT1; in tg3_fiber_aneg_smachine()
5320 if (ap->rxconfig & ANEG_CFG_RF2) in tg3_fiber_aneg_smachine()
5321 ap->flags |= MR_LP_ADV_REMOTE_FAULT2; in tg3_fiber_aneg_smachine()
5322 if (ap->rxconfig & ANEG_CFG_NP) in tg3_fiber_aneg_smachine()
5323 ap->flags |= MR_LP_ADV_NEXT_PAGE; in tg3_fiber_aneg_smachine()
5325 ap->link_time = ap->cur_time; in tg3_fiber_aneg_smachine()
5327 ap->flags ^= (MR_TOGGLE_TX); in tg3_fiber_aneg_smachine()
5328 if (ap->rxconfig & 0x0008) in tg3_fiber_aneg_smachine()
5329 ap->flags |= MR_TOGGLE_RX; in tg3_fiber_aneg_smachine()
5330 if (ap->rxconfig & ANEG_CFG_NP) in tg3_fiber_aneg_smachine()
5331 ap->flags |= MR_NP_RX; in tg3_fiber_aneg_smachine()
5332 ap->flags |= MR_PAGE_RX; in tg3_fiber_aneg_smachine()
5334 ap->state = ANEG_STATE_COMPLETE_ACK; in tg3_fiber_aneg_smachine()
5339 if (ap->ability_match != 0 && in tg3_fiber_aneg_smachine()
5340 ap->rxconfig == 0) { in tg3_fiber_aneg_smachine()
5341 ap->state = ANEG_STATE_AN_ENABLE; in tg3_fiber_aneg_smachine()
5344 delta = ap->cur_time - ap->link_time; in tg3_fiber_aneg_smachine()
5346 if (!(ap->flags & (MR_LP_ADV_NEXT_PAGE))) { in tg3_fiber_aneg_smachine()
5347 ap->state = ANEG_STATE_IDLE_DETECT_INIT; in tg3_fiber_aneg_smachine()
5349 if ((ap->txconfig & ANEG_CFG_NP) == 0 && in tg3_fiber_aneg_smachine()
5350 !(ap->flags & MR_NP_RX)) { in tg3_fiber_aneg_smachine()
5351 ap->state = ANEG_STATE_IDLE_DETECT_INIT; in tg3_fiber_aneg_smachine()
5360 ap->link_time = ap->cur_time; in tg3_fiber_aneg_smachine()
5361 tp->mac_mode &= ~MAC_MODE_SEND_CONFIGS; in tg3_fiber_aneg_smachine()
5362 tw32_f(MAC_MODE, tp->mac_mode); in tg3_fiber_aneg_smachine()
5365 ap->state = ANEG_STATE_IDLE_DETECT; in tg3_fiber_aneg_smachine()
5370 if (ap->ability_match != 0 && in tg3_fiber_aneg_smachine()
5371 ap->rxconfig == 0) { in tg3_fiber_aneg_smachine()
5372 ap->state = ANEG_STATE_AN_ENABLE; in tg3_fiber_aneg_smachine()
5375 delta = ap->cur_time - ap->link_time; in tg3_fiber_aneg_smachine()
5378 ap->state = ANEG_STATE_LINK_OK; in tg3_fiber_aneg_smachine()
5383 ap->flags |= (MR_AN_COMPLETE | MR_LINK_OK); in tg3_fiber_aneg_smachine()
5413 tmp = tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK; in fiber_autoneg()
5417 tw32_f(MAC_MODE, tp->mac_mode | MAC_MODE_SEND_CONFIGS); in fiber_autoneg()
5433 tp->mac_mode &= ~MAC_MODE_SEND_CONFIGS; in fiber_autoneg()
5434 tw32_f(MAC_MODE, tp->mac_mode); in fiber_autoneg()
5472 /* Enable auto-lock and comdet, select txclk for tx. */ in tg3_init_bcm8002()
5517 /* preserve bits 0-11,13,14 for signal pre-emphasis */ in tg3_setup_fiber_hw_autoneg()
5518 /* preserve bits 20-23 for voltage regulator */ in tg3_setup_fiber_hw_autoneg()
5524 if (tp->link_config.autoneg != AUTONEG_ENABLE) { in tg3_setup_fiber_hw_autoneg()
5545 /* Want auto-negotiation. */ in tg3_setup_fiber_hw_autoneg()
5548 flowctrl = tg3_advert_flowctrl_1000X(tp->link_config.flowctrl); in tg3_setup_fiber_hw_autoneg()
5555 if ((tp->phy_flags & TG3_PHYFLG_PARALLEL_DETECT) && in tg3_setup_fiber_hw_autoneg()
5556 tp->serdes_counter && in tg3_setup_fiber_hw_autoneg()
5560 tp->serdes_counter--; in tg3_setup_fiber_hw_autoneg()
5571 tp->serdes_counter = SERDES_AN_TIMEOUT_5704S; in tg3_setup_fiber_hw_autoneg()
5572 tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT; in tg3_setup_fiber_hw_autoneg()
5592 tp->link_config.rmt_adv = in tg3_setup_fiber_hw_autoneg()
5597 tp->serdes_counter = 0; in tg3_setup_fiber_hw_autoneg()
5598 tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT; in tg3_setup_fiber_hw_autoneg()
5600 if (tp->serdes_counter) in tg3_setup_fiber_hw_autoneg()
5601 tp->serdes_counter--; in tg3_setup_fiber_hw_autoneg()
5617 /* Link parallel detection - link is up */ in tg3_setup_fiber_hw_autoneg()
5625 tp->phy_flags |= in tg3_setup_fiber_hw_autoneg()
5627 tp->serdes_counter = in tg3_setup_fiber_hw_autoneg()
5634 tp->serdes_counter = SERDES_AN_TIMEOUT_5704S; in tg3_setup_fiber_hw_autoneg()
5635 tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT; in tg3_setup_fiber_hw_autoneg()
5649 if (tp->link_config.autoneg == AUTONEG_ENABLE) { in tg3_setup_fiber_by_hand()
5666 tp->link_config.rmt_adv = in tg3_setup_fiber_by_hand()
5696 tw32_f(MAC_MODE, (tp->mac_mode | MAC_MODE_SEND_CONFIGS)); in tg3_setup_fiber_by_hand()
5699 tw32_f(MAC_MODE, tp->mac_mode); in tg3_setup_fiber_by_hand()
5716 orig_pause_cfg = tp->link_config.active_flowctrl; in tg3_setup_fiber_phy()
5717 orig_active_speed = tp->link_config.active_speed; in tg3_setup_fiber_phy()
5718 orig_active_duplex = tp->link_config.active_duplex; in tg3_setup_fiber_phy()
5721 tp->link_up && in tg3_setup_fiber_phy()
5738 tp->mac_mode &= ~(MAC_MODE_PORT_MODE_MASK | MAC_MODE_HALF_DUPLEX); in tg3_setup_fiber_phy()
5739 tp->mac_mode |= MAC_MODE_PORT_MODE_TBI; in tg3_setup_fiber_phy()
5740 tw32_f(MAC_MODE, tp->mac_mode); in tg3_setup_fiber_phy()
5743 if (tp->phy_id == TG3_PHY_ID_BCM8002) in tg3_setup_fiber_phy()
5750 tp->link_config.rmt_adv = 0; in tg3_setup_fiber_phy()
5758 tp->napi[0].hw_status->status = in tg3_setup_fiber_phy()
5760 (tp->napi[0].hw_status->status & ~SD_STATUS_LINK_CHG)); in tg3_setup_fiber_phy()
5775 if (tp->link_config.autoneg == AUTONEG_ENABLE && in tg3_setup_fiber_phy()
5776 tp->serdes_counter == 0) { in tg3_setup_fiber_phy()
5777 tw32_f(MAC_MODE, (tp->mac_mode | in tg3_setup_fiber_phy()
5780 tw32_f(MAC_MODE, tp->mac_mode); in tg3_setup_fiber_phy()
5785 tp->link_config.active_speed = SPEED_1000; in tg3_setup_fiber_phy()
5786 tp->link_config.active_duplex = DUPLEX_FULL; in tg3_setup_fiber_phy()
5787 tw32(MAC_LED_CTRL, (tp->led_ctrl | in tg3_setup_fiber_phy()
5791 tp->link_config.active_speed = SPEED_UNKNOWN; in tg3_setup_fiber_phy()
5792 tp->link_config.active_duplex = DUPLEX_UNKNOWN; in tg3_setup_fiber_phy()
5793 tw32(MAC_LED_CTRL, (tp->led_ctrl | in tg3_setup_fiber_phy()
5799 u32 now_pause_cfg = tp->link_config.active_flowctrl; in tg3_setup_fiber_phy()
5801 orig_active_speed != tp->link_config.active_speed || in tg3_setup_fiber_phy()
5802 orig_active_duplex != tp->link_config.active_duplex) in tg3_setup_fiber_phy()
5826 tp->mac_mode &= ~MAC_MODE_PORT_MODE_MASK; in tg3_setup_fiber_mii_phy()
5829 tp->mac_mode |= MAC_MODE_PORT_MODE_GMII; in tg3_setup_fiber_mii_phy()
5834 tp->mac_mode |= MAC_MODE_PORT_MODE_GMII; in tg3_setup_fiber_mii_phy()
5837 tp->mac_mode |= MAC_MODE_PORT_MODE_MII; in tg3_setup_fiber_mii_phy()
5840 tp->mac_mode |= MAC_MODE_PORT_MODE_MII; in tg3_setup_fiber_mii_phy()
5849 tw32_f(MAC_MODE, tp->mac_mode); in tg3_setup_fiber_mii_phy()
5857 tp->mac_mode |= MAC_MODE_PORT_MODE_GMII; in tg3_setup_fiber_mii_phy()
5858 tw32_f(MAC_MODE, tp->mac_mode); in tg3_setup_fiber_mii_phy()
5866 tp->link_config.rmt_adv = 0; in tg3_setup_fiber_mii_phy()
5879 if ((tp->link_config.autoneg == AUTONEG_ENABLE) && !force_reset && in tg3_setup_fiber_mii_phy()
5880 (tp->phy_flags & TG3_PHYFLG_PARALLEL_DETECT)) { in tg3_setup_fiber_mii_phy()
5882 } else if (tp->link_config.autoneg == AUTONEG_ENABLE) { in tg3_setup_fiber_mii_phy()
5883 u32 adv, newadv; in tg3_setup_fiber_mii_phy() local
5885 err |= tg3_readphy(tp, MII_ADVERTISE, &adv); in tg3_setup_fiber_mii_phy()
5886 newadv = adv & ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF | in tg3_setup_fiber_mii_phy()
5891 newadv |= tg3_advert_flowctrl_1000X(tp->link_config.flowctrl); in tg3_setup_fiber_mii_phy()
5892 newadv |= ethtool_adv_to_mii_adv_x(tp->link_config.advertising); in tg3_setup_fiber_mii_phy()
5894 if ((newadv != adv) || !(bmcr & BMCR_ANENABLE)) { in tg3_setup_fiber_mii_phy()
5900 tp->serdes_counter = SERDES_AN_TIMEOUT_5714S; in tg3_setup_fiber_mii_phy()
5901 tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT; in tg3_setup_fiber_mii_phy()
5911 if (tp->link_config.duplex == DUPLEX_FULL) in tg3_setup_fiber_mii_phy()
5921 if (tp->link_up) { in tg3_setup_fiber_mii_phy()
5922 u32 adv; in tg3_setup_fiber_mii_phy() local
5924 err |= tg3_readphy(tp, MII_ADVERTISE, &adv); in tg3_setup_fiber_mii_phy()
5925 adv &= ~(ADVERTISE_1000XFULL | in tg3_setup_fiber_mii_phy()
5928 tg3_writephy(tp, MII_ADVERTISE, adv); in tg3_setup_fiber_mii_phy()
5945 tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT; in tg3_setup_fiber_mii_phy()
5973 tp->link_config.rmt_adv = in tg3_setup_fiber_mii_phy()
5987 tp->mac_mode &= ~MAC_MODE_HALF_DUPLEX; in tg3_setup_fiber_mii_phy()
5988 if (tp->link_config.active_duplex == DUPLEX_HALF) in tg3_setup_fiber_mii_phy()
5989 tp->mac_mode |= MAC_MODE_HALF_DUPLEX; in tg3_setup_fiber_mii_phy()
5991 tw32_f(MAC_MODE, tp->mac_mode); in tg3_setup_fiber_mii_phy()
5996 tp->link_config.active_speed = current_speed; in tg3_setup_fiber_mii_phy()
5997 tp->link_config.active_duplex = current_duplex; in tg3_setup_fiber_mii_phy()
6005 if (tp->serdes_counter) { in tg3_serdes_parallel_detect()
6007 tp->serdes_counter--; in tg3_serdes_parallel_detect()
6011 if (!tp->link_up && in tg3_serdes_parallel_detect()
6012 (tp->link_config.autoneg == AUTONEG_ENABLE)) { in tg3_serdes_parallel_detect()
6038 tp->phy_flags |= TG3_PHYFLG_PARALLEL_DETECT; in tg3_serdes_parallel_detect()
6041 } else if (tp->link_up && in tg3_serdes_parallel_detect()
6042 (tp->link_config.autoneg == AUTONEG_ENABLE) && in tg3_serdes_parallel_detect()
6043 (tp->phy_flags & TG3_PHYFLG_PARALLEL_DETECT)) { in tg3_serdes_parallel_detect()
6057 tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT; in tg3_serdes_parallel_detect()
6068 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) in tg3_setup_phy()
6070 else if (tp->phy_flags & TG3_PHYFLG_MII_SERDES) in tg3_setup_phy()
6099 if (tp->link_config.active_speed == SPEED_1000 && in tg3_setup_phy()
6100 tp->link_config.active_duplex == DUPLEX_HALF) in tg3_setup_phy()
6108 if (tp->link_up) { in tg3_setup_phy()
6110 tp->coal.stats_block_coalesce_usecs); in tg3_setup_phy()
6118 if (!tp->link_up) in tg3_setup_phy()
6120 tp->pwrmgmt_thresh; in tg3_setup_phy()
6129 /* tp->lock must be held */
6142 /* tp->lock must be held */
6159 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | in tg3_get_ts_info()
6164 info->so_timestamping |= SOF_TIMESTAMPING_TX_HARDWARE | in tg3_get_ts_info()
6169 if (tp->ptp_clock) in tg3_get_ts_info()
6170 info->phc_index = ptp_clock_index(tp->ptp_clock); in tg3_get_ts_info()
6172 info->phc_index = -1; in tg3_get_ts_info()
6174 info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON); in tg3_get_ts_info()
6176 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) | in tg3_get_ts_info()
6216 tp->ptp_adjust += delta; in tg3_ptp_adjtime()
6230 ns += tp->ptp_adjust; in tg3_ptp_gettimex()
6248 tp->ptp_adjust = 0; in tg3_ptp_settime()
6261 switch (rq->type) { in tg3_ptp_enable()
6264 if (rq->perout.flags) in tg3_ptp_enable()
6265 return -EOPNOTSUPP; in tg3_ptp_enable()
6267 if (rq->perout.index != 0) in tg3_ptp_enable()
6268 return -EINVAL; in tg3_ptp_enable()
6277 nsec = rq->perout.start.sec * 1000000000ULL + in tg3_ptp_enable()
6278 rq->perout.start.nsec; in tg3_ptp_enable()
6280 if (rq->perout.period.sec || rq->perout.period.nsec) { in tg3_ptp_enable()
6281 netdev_warn(tp->dev, in tg3_ptp_enable()
6282 "Device supports only a one-shot timesync output, period must be 0\n"); in tg3_ptp_enable()
6283 rval = -EINVAL; in tg3_ptp_enable()
6288 netdev_warn(tp->dev, in tg3_ptp_enable()
6290 rval = -EINVAL; in tg3_ptp_enable()
6314 return -EOPNOTSUPP; in tg3_ptp_enable()
6337 timestamp->hwtstamp = ns_to_ktime((hwclock & TG3_TSTAMP_MASK) + in tg3_hwclock_to_timestamp()
6338 tp->ptp_adjust); in tg3_hwclock_to_timestamp()
6341 /* tp->lock must be held */
6349 tp->ptp_adjust = 0; in tg3_ptp_init()
6350 tp->ptp_info = tg3_ptp_caps; in tg3_ptp_init()
6353 /* tp->lock must be held */
6359 tg3_refclk_write(tp, ktime_to_ns(ktime_get_real()) + tp->ptp_adjust); in tg3_ptp_resume()
6360 tp->ptp_adjust = 0; in tg3_ptp_resume()
6365 if (!tg3_flag(tp, PTP_CAPABLE) || !tp->ptp_clock) in tg3_ptp_fini()
6368 ptp_clock_unregister(tp->ptp_clock); in tg3_ptp_fini()
6369 tp->ptp_clock = NULL; in tg3_ptp_fini()
6370 tp->ptp_adjust = 0; in tg3_ptp_fini()
6375 return tp->irq_sync; in tg3_irq_sync()
6458 netdev_err(tp->dev, "0x%08x: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", in tg3_dump_state()
6465 for (i = 0; i < tp->irq_cnt; i++) { in tg3_dump_state()
6466 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_dump_state()
6469 netdev_err(tp->dev, in tg3_dump_state()
6472 tnapi->hw_status->status, in tg3_dump_state()
6473 tnapi->hw_status->status_tag, in tg3_dump_state()
6474 tnapi->hw_status->rx_jumbo_consumer, in tg3_dump_state()
6475 tnapi->hw_status->rx_consumer, in tg3_dump_state()
6476 tnapi->hw_status->rx_mini_consumer, in tg3_dump_state()
6477 tnapi->hw_status->idx[0].rx_producer, in tg3_dump_state()
6478 tnapi->hw_status->idx[0].tx_consumer); in tg3_dump_state()
6480 netdev_err(tp->dev, in tg3_dump_state()
6483 tnapi->last_tag, tnapi->last_irq_tag, in tg3_dump_state()
6484 tnapi->tx_prod, tnapi->tx_cons, tnapi->tx_pending, in tg3_dump_state()
6485 tnapi->rx_rcb_ptr, in tg3_dump_state()
6486 tnapi->prodring.rx_std_prod_idx, in tg3_dump_state()
6487 tnapi->prodring.rx_std_cons_idx, in tg3_dump_state()
6488 tnapi->prodring.rx_jmb_prod_idx, in tg3_dump_state()
6489 tnapi->prodring.rx_jmb_cons_idx); in tg3_dump_state()
6493 /* This is called whenever we suspect that the system chipset is re-
6502 tp->write32_tx_mbox == tg3_write_indirect_mbox); in tg3_tx_recover()
6504 netdev_warn(tp->dev, in tg3_tx_recover()
6505 "The system may be re-ordering memory-mapped I/O " in tg3_tx_recover()
6517 return tnapi->tx_pending - in tg3_tx_avail()
6518 ((tnapi->tx_prod - tnapi->tx_cons) & (TG3_TX_RING_SIZE - 1)); in tg3_tx_avail()
6527 struct tg3 *tp = tnapi->tp; in tg3_tx()
6528 u32 hw_idx = tnapi->hw_status->idx[0].tx_consumer; in tg3_tx()
6529 u32 sw_idx = tnapi->tx_cons; in tg3_tx()
6531 int index = tnapi - tp->napi; in tg3_tx()
6535 index--; in tg3_tx()
6537 txq = netdev_get_tx_queue(tp->dev, index); in tg3_tx()
6540 struct tg3_tx_ring_info *ri = &tnapi->tx_buffers[sw_idx]; in tg3_tx()
6541 struct sk_buff *skb = ri->skb; in tg3_tx()
6549 if (tnapi->tx_ring[sw_idx].len_flags & TXD_FLAG_HWTSTAMP) { in tg3_tx()
6559 dma_unmap_single(&tp->pdev->dev, dma_unmap_addr(ri, mapping), in tg3_tx()
6562 ri->skb = NULL; in tg3_tx()
6564 while (ri->fragmented) { in tg3_tx()
6565 ri->fragmented = false; in tg3_tx()
6567 ri = &tnapi->tx_buffers[sw_idx]; in tg3_tx()
6572 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { in tg3_tx()
6573 ri = &tnapi->tx_buffers[sw_idx]; in tg3_tx()
6574 if (unlikely(ri->skb != NULL || sw_idx == hw_idx)) in tg3_tx()
6577 dma_unmap_page(&tp->pdev->dev, in tg3_tx()
6579 skb_frag_size(&skb_shinfo(skb)->frags[i]), in tg3_tx()
6582 while (ri->fragmented) { in tg3_tx()
6583 ri->fragmented = false; in tg3_tx()
6585 ri = &tnapi->tx_buffers[sw_idx]; in tg3_tx()
6592 bytes_compl += skb->len; in tg3_tx()
6604 tnapi->tx_cons = sw_idx; in tg3_tx()
6636 if (!ri->data) in tg3_rx_data_free()
6639 dma_unmap_single(&tp->pdev->dev, dma_unmap_addr(ri, mapping), map_sz, in tg3_rx_data_free()
6641 tg3_frag_free(skb_size <= PAGE_SIZE, ri->data); in tg3_rx_data_free()
6642 ri->data = NULL; in tg3_rx_data_free()
6669 dest_idx = dest_idx_unmasked & tp->rx_std_ring_mask; in tg3_alloc_rx_data()
6670 desc = &tpr->rx_std[dest_idx]; in tg3_alloc_rx_data()
6671 map = &tpr->rx_std_buffers[dest_idx]; in tg3_alloc_rx_data()
6672 data_size = tp->rx_pkt_map_sz; in tg3_alloc_rx_data()
6676 dest_idx = dest_idx_unmasked & tp->rx_jmb_ring_mask; in tg3_alloc_rx_data()
6677 desc = &tpr->rx_jmb[dest_idx].std; in tg3_alloc_rx_data()
6678 map = &tpr->rx_jmb_buffers[dest_idx]; in tg3_alloc_rx_data()
6683 return -EINVAL; in tg3_alloc_rx_data()
6702 return -ENOMEM; in tg3_alloc_rx_data()
6704 mapping = dma_map_single(&tp->pdev->dev, data + TG3_RX_OFFSET(tp), in tg3_alloc_rx_data()
6706 if (unlikely(dma_mapping_error(&tp->pdev->dev, mapping))) { in tg3_alloc_rx_data()
6708 return -EIO; in tg3_alloc_rx_data()
6711 map->data = data; in tg3_alloc_rx_data()
6714 desc->addr_hi = ((u64)mapping >> 32); in tg3_alloc_rx_data()
6715 desc->addr_lo = ((u64)mapping & 0xffffffff); in tg3_alloc_rx_data()
6729 struct tg3 *tp = tnapi->tp; in tg3_recycle_rx()
6732 struct tg3_rx_prodring_set *spr = &tp->napi[0].prodring; in tg3_recycle_rx()
6737 dest_idx = dest_idx_unmasked & tp->rx_std_ring_mask; in tg3_recycle_rx()
6738 dest_desc = &dpr->rx_std[dest_idx]; in tg3_recycle_rx()
6739 dest_map = &dpr->rx_std_buffers[dest_idx]; in tg3_recycle_rx()
6740 src_desc = &spr->rx_std[src_idx]; in tg3_recycle_rx()
6741 src_map = &spr->rx_std_buffers[src_idx]; in tg3_recycle_rx()
6745 dest_idx = dest_idx_unmasked & tp->rx_jmb_ring_mask; in tg3_recycle_rx()
6746 dest_desc = &dpr->rx_jmb[dest_idx].std; in tg3_recycle_rx()
6747 dest_map = &dpr->rx_jmb_buffers[dest_idx]; in tg3_recycle_rx()
6748 src_desc = &spr->rx_jmb[src_idx].std; in tg3_recycle_rx()
6749 src_map = &spr->rx_jmb_buffers[src_idx]; in tg3_recycle_rx()
6756 dest_map->data = src_map->data; in tg3_recycle_rx()
6759 dest_desc->addr_hi = src_desc->addr_hi; in tg3_recycle_rx()
6760 dest_desc->addr_lo = src_desc->addr_lo; in tg3_recycle_rx()
6767 src_map->data = NULL; in tg3_recycle_rx()
6782 * it is first placed into the on-chip ram. When the packet's length
6783 * is known, it walks down the TG3_BDINFO entries to select the ring.
6790 * rings, then cache lines never move beyond shared-modified state.
6796 struct tg3 *tp = tnapi->tp; in tg3_rx()
6799 u32 sw_idx = tnapi->rx_rcb_ptr; in tg3_rx()
6802 struct tg3_rx_prodring_set *tpr = &tnapi->prodring; in tg3_rx()
6804 hw_idx = *(tnapi->rx_rcb_prod_idx); in tg3_rx()
6812 std_prod_idx = tpr->rx_std_prod_idx; in tg3_rx()
6813 jmb_prod_idx = tpr->rx_jmb_prod_idx; in tg3_rx()
6816 struct tg3_rx_buffer_desc *desc = &tnapi->rx_rcb[sw_idx]; in tg3_rx()
6824 desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK; in tg3_rx()
6825 opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK; in tg3_rx()
6827 ri = &tp->napi[0].prodring.rx_std_buffers[desc_idx]; in tg3_rx()
6829 data = ri->data; in tg3_rx()
6833 ri = &tp->napi[0].prodring.rx_jmb_buffers[desc_idx]; in tg3_rx()
6835 data = ri->data; in tg3_rx()
6842 if (desc->err_vlan & RXD_ERR_MASK) { in tg3_rx()
6848 tp->rx_dropped++; in tg3_rx()
6853 len = ((desc->idx_len & RXD_LEN_MASK) >> RXD_LEN_SHIFT) - in tg3_rx()
6856 if ((desc->type_flags & RXD_FLAG_PTPSTAT_MASK) == in tg3_rx()
6858 (desc->type_flags & RXD_FLAG_PTPSTAT_MASK) == in tg3_rx()
6873 dma_unmap_single(&tp->pdev->dev, dma_addr, skb_size, in tg3_rx()
6881 ri->data = NULL; in tg3_rx()
6896 skb = netdev_alloc_skb(tp->dev, in tg3_rx()
6902 dma_sync_single_for_cpu(&tp->pdev->dev, dma_addr, len, in tg3_rx()
6904 memcpy(skb->data, in tg3_rx()
6907 dma_sync_single_for_device(&tp->pdev->dev, dma_addr, in tg3_rx()
6916 if ((tp->dev->features & NETIF_F_RXCSUM) && in tg3_rx()
6917 (desc->type_flags & RXD_FLAG_TCPUDP_CSUM) && in tg3_rx()
6918 (((desc->ip_tcp_csum & RXD_TCPCSUM_MASK) in tg3_rx()
6920 skb->ip_summed = CHECKSUM_UNNECESSARY; in tg3_rx()
6924 skb->protocol = eth_type_trans(skb, tp->dev); in tg3_rx()
6926 if (len > (tp->dev->mtu + ETH_HLEN) && in tg3_rx()
6927 skb->protocol != htons(ETH_P_8021Q) && in tg3_rx()
6928 skb->protocol != htons(ETH_P_8021AD)) { in tg3_rx()
6933 if (desc->type_flags & RXD_FLAG_VLAN && in tg3_rx()
6934 !(tp->rx_mode & RX_MODE_KEEP_VLAN_TAG)) in tg3_rx()
6936 desc->err_vlan & RXD_VLAN_MASK); in tg3_rx()
6938 napi_gro_receive(&tnapi->napi, skb); in tg3_rx()
6941 budget--; in tg3_rx()
6946 if (unlikely(rx_std_posted >= tp->rx_std_max_post)) { in tg3_rx()
6947 tpr->rx_std_prod_idx = std_prod_idx & in tg3_rx()
6948 tp->rx_std_ring_mask; in tg3_rx()
6950 tpr->rx_std_prod_idx); in tg3_rx()
6956 sw_idx &= tp->rx_ret_ring_mask; in tg3_rx()
6960 hw_idx = *(tnapi->rx_rcb_prod_idx); in tg3_rx()
6966 tnapi->rx_rcb_ptr = sw_idx; in tg3_rx()
6967 tw32_rx_mbox(tnapi->consmbox, sw_idx); in tg3_rx()
6975 tpr->rx_std_prod_idx = std_prod_idx & in tg3_rx()
6976 tp->rx_std_ring_mask; in tg3_rx()
6978 tpr->rx_std_prod_idx); in tg3_rx()
6981 tpr->rx_jmb_prod_idx = jmb_prod_idx & in tg3_rx()
6982 tp->rx_jmb_ring_mask; in tg3_rx()
6984 tpr->rx_jmb_prod_idx); in tg3_rx()
6992 tpr->rx_std_prod_idx = std_prod_idx & tp->rx_std_ring_mask; in tg3_rx()
6993 tpr->rx_jmb_prod_idx = jmb_prod_idx & tp->rx_jmb_ring_mask; in tg3_rx()
6995 if (tnapi != &tp->napi[1]) { in tg3_rx()
6996 tp->rx_refill = true; in tg3_rx()
6997 napi_schedule(&tp->napi[1].napi); in tg3_rx()
7008 struct tg3_hw_status *sblk = tp->napi[0].hw_status; in tg3_poll_link()
7010 if (sblk->status & SD_STATUS_LINK_CHG) { in tg3_poll_link()
7011 sblk->status = SD_STATUS_UPDATED | in tg3_poll_link()
7012 (sblk->status & ~SD_STATUS_LINK_CHG); in tg3_poll_link()
7013 spin_lock(&tp->lock); in tg3_poll_link()
7023 spin_unlock(&tp->lock); in tg3_poll_link()
7036 src_prod_idx = spr->rx_std_prod_idx; in tg3_rx_prodring_xfer()
7043 if (spr->rx_std_cons_idx == src_prod_idx) in tg3_rx_prodring_xfer()
7046 if (spr->rx_std_cons_idx < src_prod_idx) in tg3_rx_prodring_xfer()
7047 cpycnt = src_prod_idx - spr->rx_std_cons_idx; in tg3_rx_prodring_xfer()
7049 cpycnt = tp->rx_std_ring_mask + 1 - in tg3_rx_prodring_xfer()
7050 spr->rx_std_cons_idx; in tg3_rx_prodring_xfer()
7053 tp->rx_std_ring_mask + 1 - dpr->rx_std_prod_idx); in tg3_rx_prodring_xfer()
7055 si = spr->rx_std_cons_idx; in tg3_rx_prodring_xfer()
7056 di = dpr->rx_std_prod_idx; in tg3_rx_prodring_xfer()
7059 if (dpr->rx_std_buffers[i].data) { in tg3_rx_prodring_xfer()
7060 cpycnt = i - di; in tg3_rx_prodring_xfer()
7061 err = -ENOSPC; in tg3_rx_prodring_xfer()
7075 memcpy(&dpr->rx_std_buffers[di], in tg3_rx_prodring_xfer()
7076 &spr->rx_std_buffers[si], in tg3_rx_prodring_xfer()
7081 sbd = &spr->rx_std[si]; in tg3_rx_prodring_xfer()
7082 dbd = &dpr->rx_std[di]; in tg3_rx_prodring_xfer()
7083 dbd->addr_hi = sbd->addr_hi; in tg3_rx_prodring_xfer()
7084 dbd->addr_lo = sbd->addr_lo; in tg3_rx_prodring_xfer()
7087 spr->rx_std_cons_idx = (spr->rx_std_cons_idx + cpycnt) & in tg3_rx_prodring_xfer()
7088 tp->rx_std_ring_mask; in tg3_rx_prodring_xfer()
7089 dpr->rx_std_prod_idx = (dpr->rx_std_prod_idx + cpycnt) & in tg3_rx_prodring_xfer()
7090 tp->rx_std_ring_mask; in tg3_rx_prodring_xfer()
7094 src_prod_idx = spr->rx_jmb_prod_idx; in tg3_rx_prodring_xfer()
7101 if (spr->rx_jmb_cons_idx == src_prod_idx) in tg3_rx_prodring_xfer()
7104 if (spr->rx_jmb_cons_idx < src_prod_idx) in tg3_rx_prodring_xfer()
7105 cpycnt = src_prod_idx - spr->rx_jmb_cons_idx; in tg3_rx_prodring_xfer()
7107 cpycnt = tp->rx_jmb_ring_mask + 1 - in tg3_rx_prodring_xfer()
7108 spr->rx_jmb_cons_idx; in tg3_rx_prodring_xfer()
7111 tp->rx_jmb_ring_mask + 1 - dpr->rx_jmb_prod_idx); in tg3_rx_prodring_xfer()
7113 si = spr->rx_jmb_cons_idx; in tg3_rx_prodring_xfer()
7114 di = dpr->rx_jmb_prod_idx; in tg3_rx_prodring_xfer()
7117 if (dpr->rx_jmb_buffers[i].data) { in tg3_rx_prodring_xfer()
7118 cpycnt = i - di; in tg3_rx_prodring_xfer()
7119 err = -ENOSPC; in tg3_rx_prodring_xfer()
7133 memcpy(&dpr->rx_jmb_buffers[di], in tg3_rx_prodring_xfer()
7134 &spr->rx_jmb_buffers[si], in tg3_rx_prodring_xfer()
7139 sbd = &spr->rx_jmb[si].std; in tg3_rx_prodring_xfer()
7140 dbd = &dpr->rx_jmb[di].std; in tg3_rx_prodring_xfer()
7141 dbd->addr_hi = sbd->addr_hi; in tg3_rx_prodring_xfer()
7142 dbd->addr_lo = sbd->addr_lo; in tg3_rx_prodring_xfer()
7145 spr->rx_jmb_cons_idx = (spr->rx_jmb_cons_idx + cpycnt) & in tg3_rx_prodring_xfer()
7146 tp->rx_jmb_ring_mask; in tg3_rx_prodring_xfer()
7147 dpr->rx_jmb_prod_idx = (dpr->rx_jmb_prod_idx + cpycnt) & in tg3_rx_prodring_xfer()
7148 tp->rx_jmb_ring_mask; in tg3_rx_prodring_xfer()
7156 struct tg3 *tp = tnapi->tp; in tg3_poll_work()
7159 if (tnapi->hw_status->idx[0].tx_consumer != tnapi->tx_cons) { in tg3_poll_work()
7165 if (!tnapi->rx_rcb_prod_idx) in tg3_poll_work()
7170 * code synchronizes with tg3->napi.poll() in tg3_poll_work()
7172 if (*(tnapi->rx_rcb_prod_idx) != tnapi->rx_rcb_ptr) in tg3_poll_work()
7173 work_done += tg3_rx(tnapi, budget - work_done); in tg3_poll_work()
7175 if (tg3_flag(tp, ENABLE_RSS) && tnapi == &tp->napi[1]) { in tg3_poll_work()
7176 struct tg3_rx_prodring_set *dpr = &tp->napi[0].prodring; in tg3_poll_work()
7178 u32 std_prod_idx = dpr->rx_std_prod_idx; in tg3_poll_work()
7179 u32 jmb_prod_idx = dpr->rx_jmb_prod_idx; in tg3_poll_work()
7181 tp->rx_refill = false; in tg3_poll_work()
7182 for (i = 1; i <= tp->rxq_cnt; i++) in tg3_poll_work()
7184 &tp->napi[i].prodring); in tg3_poll_work()
7188 if (std_prod_idx != dpr->rx_std_prod_idx) in tg3_poll_work()
7190 dpr->rx_std_prod_idx); in tg3_poll_work()
7192 if (jmb_prod_idx != dpr->rx_jmb_prod_idx) in tg3_poll_work()
7194 dpr->rx_jmb_prod_idx); in tg3_poll_work()
7197 tw32_f(HOSTCC_MODE, tp->coal_now); in tg3_poll_work()
7205 if (!test_and_set_bit(TG3_FLAG_RESET_TASK_PENDING, tp->tg3_flags)) in tg3_reset_task_schedule()
7206 schedule_work(&tp->reset_task); in tg3_reset_task_schedule()
7211 if (test_and_clear_bit(TG3_FLAG_RESET_TASK_PENDING, tp->tg3_flags)) in tg3_reset_task_cancel()
7212 cancel_work_sync(&tp->reset_task); in tg3_reset_task_cancel()
7219 struct tg3 *tp = tnapi->tp; in tg3_poll_msix()
7221 struct tg3_hw_status *sblk = tnapi->hw_status; in tg3_poll_msix()
7232 /* tp->last_tag is used in tg3_int_reenable() below in tg3_poll_msix()
7236 tnapi->last_tag = sblk->status_tag; in tg3_poll_msix()
7237 tnapi->last_irq_tag = tnapi->last_tag; in tg3_poll_msix()
7241 if (likely(sblk->idx[0].tx_consumer == tnapi->tx_cons && in tg3_poll_msix()
7242 *(tnapi->rx_rcb_prod_idx) == tnapi->rx_rcb_ptr)) { in tg3_poll_msix()
7247 if (tnapi == &tp->napi[1] && tp->rx_refill) in tg3_poll_msix()
7252 tw32_mailbox(tnapi->int_mbox, tnapi->last_tag << 24); in tg3_poll_msix()
7257 if (unlikely(tnapi == &tp->napi[1] && tp->rx_refill)) { in tg3_poll_msix()
7258 tw32(HOSTCC_MODE, tp->coalesce_mode | in tg3_poll_msix()
7260 tnapi->coal_now); in tg3_poll_msix()
7287 netdev_err(tp->dev, "FLOW Attention error. Resetting chip.\n"); in tg3_process_error()
7292 netdev_err(tp->dev, "MSI Status error. Resetting chip.\n"); in tg3_process_error()
7297 netdev_err(tp->dev, "DMA Status error. Resetting chip.\n"); in tg3_process_error()
7313 struct tg3 *tp = tnapi->tp; in tg3_poll()
7315 struct tg3_hw_status *sblk = tnapi->hw_status; in tg3_poll()
7318 if (sblk->status & SD_STATUS_ERROR) in tg3_poll()
7332 /* tp->last_tag is used in tg3_int_reenable() below in tg3_poll()
7336 tnapi->last_tag = sblk->status_tag; in tg3_poll()
7337 tnapi->last_irq_tag = tnapi->last_tag; in tg3_poll()
7340 sblk->status &= ~SD_STATUS_UPDATED; in tg3_poll()
7363 for (i = tp->irq_cnt - 1; i >= 0; i--) in tg3_napi_disable()
7364 napi_disable(&tp->napi[i].napi); in tg3_napi_disable()
7371 for (i = 0; i < tp->irq_cnt; i++) in tg3_napi_enable()
7372 napi_enable(&tp->napi[i].napi); in tg3_napi_enable()
7379 netif_napi_add(tp->dev, &tp->napi[0].napi, tg3_poll); in tg3_napi_init()
7380 for (i = 1; i < tp->irq_cnt; i++) in tg3_napi_init()
7381 netif_napi_add(tp->dev, &tp->napi[i].napi, tg3_poll_msix); in tg3_napi_init()
7388 for (i = 0; i < tp->irq_cnt; i++) in tg3_napi_fini()
7389 netif_napi_del(&tp->napi[i].napi); in tg3_napi_fini()
7394 netif_trans_update(tp->dev); /* prevent tx timeout */ in tg3_netif_stop()
7396 netif_carrier_off(tp->dev); in tg3_netif_stop()
7397 netif_tx_disable(tp->dev); in tg3_netif_stop()
7400 /* tp->lock must be held */
7409 netif_tx_wake_all_queues(tp->dev); in tg3_netif_start()
7411 if (tp->link_up) in tg3_netif_start()
7412 netif_carrier_on(tp->dev); in tg3_netif_start()
7415 tp->napi[0].hw_status->status |= SD_STATUS_UPDATED; in tg3_netif_start()
7420 __releases(tp->lock) in tg3_irq_quiesce()
7421 __acquires(tp->lock) in tg3_irq_quiesce()
7425 BUG_ON(tp->irq_sync); in tg3_irq_quiesce()
7427 tp->irq_sync = 1; in tg3_irq_quiesce()
7430 spin_unlock_bh(&tp->lock); in tg3_irq_quiesce()
7432 for (i = 0; i < tp->irq_cnt; i++) in tg3_irq_quiesce()
7433 synchronize_irq(tp->napi[i].irq_vec); in tg3_irq_quiesce()
7435 spin_lock_bh(&tp->lock); in tg3_irq_quiesce()
7439 * If irq_sync is non-zero, then the IRQ handler must be synchronized
7441 * shutting down the device.
7445 spin_lock_bh(&tp->lock); in tg3_full_lock()
7452 spin_unlock_bh(&tp->lock); in tg3_full_unlock()
7455 /* One-shot MSI handler - Chip automatically disables interrupt
7461 struct tg3 *tp = tnapi->tp; in tg3_msi_1shot()
7463 prefetch(tnapi->hw_status); in tg3_msi_1shot()
7464 if (tnapi->rx_rcb) in tg3_msi_1shot()
7465 prefetch(&tnapi->rx_rcb[tnapi->rx_rcb_ptr]); in tg3_msi_1shot()
7468 napi_schedule(&tnapi->napi); in tg3_msi_1shot()
7473 /* MSI ISR - No need to check for interrupt sharing and no need to
7480 struct tg3 *tp = tnapi->tp; in tg3_msi()
7482 prefetch(tnapi->hw_status); in tg3_msi()
7483 if (tnapi->rx_rcb) in tg3_msi()
7484 prefetch(&tnapi->rx_rcb[tnapi->rx_rcb_ptr]); in tg3_msi()
7486 * Writing any value to intr-mbox-0 clears PCI INTA# and in tg3_msi()
7487 * chip-internal interrupt pending events. in tg3_msi()
7488 * Writing non-zero to intr-mbox-0 additional tells the in tg3_msi()
7489 * NIC to stop sending us irqs, engaging "in-intr-handler" in tg3_msi()
7492 tw32_mailbox(tnapi->int_mbox, 0x00000001); in tg3_msi()
7494 napi_schedule(&tnapi->napi); in tg3_msi()
7502 struct tg3 *tp = tnapi->tp; in tg3_interrupt()
7503 struct tg3_hw_status *sblk = tnapi->hw_status; in tg3_interrupt()
7511 if (unlikely(!(sblk->status & SD_STATUS_UPDATED))) { in tg3_interrupt()
7520 * Writing any value to intr-mbox-0 clears PCI INTA# and in tg3_interrupt()
7521 * chip-internal interrupt pending events. in tg3_interrupt()
7522 * Writing non-zero to intr-mbox-0 additional tells the in tg3_interrupt()
7523 * NIC to stop sending us irqs, engaging "in-intr-handler" in tg3_interrupt()
7526 * Flush the mailbox to de-assert the IRQ immediately to prevent in tg3_interrupt()
7533 sblk->status &= ~SD_STATUS_UPDATED; in tg3_interrupt()
7535 prefetch(&tnapi->rx_rcb[tnapi->rx_rcb_ptr]); in tg3_interrupt()
7536 napi_schedule(&tnapi->napi); in tg3_interrupt()
7538 /* No work, shared interrupt perhaps? re-enable in tg3_interrupt()
7551 struct tg3 *tp = tnapi->tp; in tg3_interrupt_tagged()
7552 struct tg3_hw_status *sblk = tnapi->hw_status; in tg3_interrupt_tagged()
7560 if (unlikely(sblk->status_tag == tnapi->last_irq_tag)) { in tg3_interrupt_tagged()
7569 * writing any value to intr-mbox-0 clears PCI INTA# and in tg3_interrupt_tagged()
7570 * chip-internal interrupt pending events. in tg3_interrupt_tagged()
7571 * writing non-zero to intr-mbox-0 additional tells the in tg3_interrupt_tagged()
7572 * NIC to stop sending us irqs, engaging "in-intr-handler" in tg3_interrupt_tagged()
7575 * Flush the mailbox to de-assert the IRQ immediately to prevent in tg3_interrupt_tagged()
7587 tnapi->last_irq_tag = sblk->status_tag; in tg3_interrupt_tagged()
7592 prefetch(&tnapi->rx_rcb[tnapi->rx_rcb_ptr]); in tg3_interrupt_tagged()
7594 napi_schedule(&tnapi->napi); in tg3_interrupt_tagged()
7604 struct tg3 *tp = tnapi->tp; in tg3_test_isr()
7605 struct tg3_hw_status *sblk = tnapi->hw_status; in tg3_test_isr()
7607 if ((sblk->status & SD_STATUS_UPDATED) || in tg3_test_isr()
7624 for (i = 0; i < tp->irq_cnt; i++) in tg3_poll_controller()
7625 tg3_interrupt(tp->napi[i].irq_vec, &tp->napi[i]); in tg3_poll_controller()
7663 /* Test for DMA addresses > 40-bit */
7680 txbd->addr_hi = ((u64) mapping >> 32); in tg3_tx_set_bd()
7681 txbd->addr_lo = ((u64) mapping & 0xffffffff); in tg3_tx_set_bd()
7682 txbd->len_flags = (len << TXD_LEN_SHIFT) | (flags & 0x0000ffff); in tg3_tx_set_bd()
7683 txbd->vlan_tag = (mss << TXD_MSS_SHIFT) | (vlan << TXD_VLAN_TAG_SHIFT); in tg3_tx_set_bd()
7690 struct tg3 *tp = tnapi->tp; in tg3_tx_frag_set()
7705 if (tp->dma_limit) { in tg3_tx_frag_set()
7708 while (len > tp->dma_limit && *budget) { in tg3_tx_frag_set()
7709 u32 frag_len = tp->dma_limit; in tg3_tx_frag_set()
7710 len -= tp->dma_limit; in tg3_tx_frag_set()
7714 len += tp->dma_limit / 2; in tg3_tx_frag_set()
7715 frag_len = tp->dma_limit / 2; in tg3_tx_frag_set()
7718 tnapi->tx_buffers[*entry].fragmented = true; in tg3_tx_frag_set()
7720 tg3_tx_set_bd(&tnapi->tx_ring[*entry], map, in tg3_tx_frag_set()
7722 *budget -= 1; in tg3_tx_frag_set()
7731 tg3_tx_set_bd(&tnapi->tx_ring[*entry], map, in tg3_tx_frag_set()
7733 *budget -= 1; in tg3_tx_frag_set()
7737 tnapi->tx_buffers[prvidx].fragmented = false; in tg3_tx_frag_set()
7741 tg3_tx_set_bd(&tnapi->tx_ring[*entry], map, in tg3_tx_frag_set()
7753 struct tg3_tx_ring_info *txb = &tnapi->tx_buffers[entry]; in tg3_tx_skb_unmap()
7755 skb = txb->skb; in tg3_tx_skb_unmap()
7756 txb->skb = NULL; in tg3_tx_skb_unmap()
7758 dma_unmap_single(&tnapi->tp->pdev->dev, dma_unmap_addr(txb, mapping), in tg3_tx_skb_unmap()
7761 while (txb->fragmented) { in tg3_tx_skb_unmap()
7762 txb->fragmented = false; in tg3_tx_skb_unmap()
7764 txb = &tnapi->tx_buffers[entry]; in tg3_tx_skb_unmap()
7768 const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in tg3_tx_skb_unmap()
7771 txb = &tnapi->tx_buffers[entry]; in tg3_tx_skb_unmap()
7773 dma_unmap_page(&tnapi->tp->pdev->dev, in tg3_tx_skb_unmap()
7777 while (txb->fragmented) { in tg3_tx_skb_unmap()
7778 txb->fragmented = false; in tg3_tx_skb_unmap()
7780 txb = &tnapi->tx_buffers[entry]; in tg3_tx_skb_unmap()
7785 /* Workaround 4GB and 40-bit hardware DMA bugs. */
7791 struct tg3 *tp = tnapi->tp; in tigon3_dma_hwbug_workaround()
7799 int more_headroom = 4 - ((unsigned long)skb->data & 3); in tigon3_dma_hwbug_workaround()
7807 ret = -1; in tigon3_dma_hwbug_workaround()
7810 new_addr = dma_map_single(&tp->pdev->dev, new_skb->data, in tigon3_dma_hwbug_workaround()
7811 new_skb->len, DMA_TO_DEVICE); in tigon3_dma_hwbug_workaround()
7813 if (dma_mapping_error(&tp->pdev->dev, new_addr)) { in tigon3_dma_hwbug_workaround()
7815 ret = -1; in tigon3_dma_hwbug_workaround()
7821 tnapi->tx_buffers[*entry].skb = new_skb; in tigon3_dma_hwbug_workaround()
7822 dma_unmap_addr_set(&tnapi->tx_buffers[*entry], in tigon3_dma_hwbug_workaround()
7826 new_skb->len, base_flags, in tigon3_dma_hwbug_workaround()
7828 tg3_tx_skb_unmap(tnapi, save_entry, -1); in tigon3_dma_hwbug_workaround()
7830 ret = -1; in tigon3_dma_hwbug_workaround()
7845 return skb_shinfo(skb)->gso_segs < tnapi->tx_pending / 3; in tg3_tso_bug_gso_check()
7856 u32 frag_cnt_est = skb_shinfo(skb)->gso_segs * 3; in tg3_tso_bug()
7875 segs = skb_gso_segment(skb, tp->dev->features & in tg3_tso_bug()
7882 tg3_start_xmit(seg, tp->dev); in tg3_tso_bug()
7897 int i = -1, would_hit_hwbug; in tg3_start_xmit()
7908 tnapi = &tp->napi[skb_get_queue_mapping(skb)]; in tg3_start_xmit()
7915 * and TX reclaim runs via tp->napi.poll inside of a software in tg3_start_xmit()
7919 if (unlikely(budget <= (skb_shinfo(skb)->nr_frags + 1))) { in tg3_start_xmit()
7930 entry = tnapi->tx_prod; in tg3_start_xmit()
7933 mss = skb_shinfo(skb)->gso_size; in tg3_start_xmit()
7943 hdr_len = skb_tcp_all_headers(skb) - ETH_HLEN; in tg3_start_xmit()
7948 if (skb->protocol == htons(ETH_P_8021Q) || in tg3_start_xmit()
7949 skb->protocol == htons(ETH_P_8021AD)) { in tg3_start_xmit()
7962 ip_csum = iph->check; in tg3_start_xmit()
7963 ip_tot_len = iph->tot_len; in tg3_start_xmit()
7964 iph->check = 0; in tg3_start_xmit()
7965 iph->tot_len = htons(mss + hdr_len); in tg3_start_xmit()
7972 tcp_csum = tcph->check; in tg3_start_xmit()
7977 tcph->check = 0; in tg3_start_xmit()
7980 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, in tg3_start_xmit()
7993 if (tcp_opt_len || iph->ihl > 5) { in tg3_start_xmit()
7996 tsflags = (iph->ihl - 5) + (tcp_opt_len >> 2); in tg3_start_xmit()
8000 if (tcp_opt_len || iph->ihl > 5) { in tg3_start_xmit()
8003 tsflags = (iph->ihl - 5) + (tcp_opt_len >> 2); in tg3_start_xmit()
8007 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { in tg3_start_xmit()
8011 if (skb->protocol == htons(ETH_P_8021Q) || in tg3_start_xmit()
8012 skb->protocol == htons(ETH_P_8021AD)) { in tg3_start_xmit()
8021 !mss && skb->len > VLAN_ETH_FRAME_LEN) in tg3_start_xmit()
8029 if ((unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) && in tg3_start_xmit()
8031 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in tg3_start_xmit()
8037 mapping = dma_map_single(&tp->pdev->dev, skb->data, len, in tg3_start_xmit()
8039 if (dma_mapping_error(&tp->pdev->dev, mapping)) in tg3_start_xmit()
8043 tnapi->tx_buffers[entry].skb = skb; in tg3_start_xmit()
8044 dma_unmap_addr_set(&tnapi->tx_buffers[entry], mapping, mapping); in tg3_start_xmit()
8052 ((skb_shinfo(skb)->nr_frags == 0) ? TXD_FLAG_END : 0), in tg3_start_xmit()
8055 } else if (skb_shinfo(skb)->nr_frags > 0) { in tg3_start_xmit()
8066 last = skb_shinfo(skb)->nr_frags - 1; in tg3_start_xmit()
8068 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in tg3_start_xmit()
8071 mapping = skb_frag_dma_map(&tp->pdev->dev, frag, 0, in tg3_start_xmit()
8074 tnapi->tx_buffers[entry].skb = NULL; in tg3_start_xmit()
8075 dma_unmap_addr_set(&tnapi->tx_buffers[entry], mapping, in tg3_start_xmit()
8077 if (dma_mapping_error(&tp->pdev->dev, mapping)) in tg3_start_xmit()
8092 tg3_tx_skb_unmap(tnapi, tnapi->tx_prod, i); in tg3_start_xmit()
8099 iph->check = ip_csum; in tg3_start_xmit()
8100 iph->tot_len = ip_tot_len; in tg3_start_xmit()
8102 tcph->check = tcp_csum; in tg3_start_xmit()
8109 entry = tnapi->tx_prod; in tg3_start_xmit()
8117 netdev_tx_sent_queue(txq, skb->len); in tg3_start_xmit()
8122 tnapi->tx_prod = entry; in tg3_start_xmit()
8138 tw32_tx_mbox(tnapi->prodmbox, entry); in tg3_start_xmit()
8144 tg3_tx_skb_unmap(tnapi, tnapi->tx_prod, --i); in tg3_start_xmit()
8145 tnapi->tx_buffers[tnapi->tx_prod].skb = NULL; in tg3_start_xmit()
8149 tp->tx_dropped++; in tg3_start_xmit()
8156 tp->mac_mode &= ~(MAC_MODE_HALF_DUPLEX | in tg3_mac_loopback()
8159 tp->mac_mode |= MAC_MODE_PORT_INT_LPBACK; in tg3_mac_loopback()
8162 tp->mac_mode |= MAC_MODE_LINK_POLARITY; in tg3_mac_loopback()
8164 if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY) in tg3_mac_loopback()
8165 tp->mac_mode |= MAC_MODE_PORT_MODE_MII; in tg3_mac_loopback()
8167 tp->mac_mode |= MAC_MODE_PORT_MODE_GMII; in tg3_mac_loopback()
8169 tp->mac_mode &= ~MAC_MODE_PORT_INT_LPBACK; in tg3_mac_loopback()
8172 (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) || in tg3_mac_loopback()
8174 tp->mac_mode &= ~MAC_MODE_LINK_POLARITY; in tg3_mac_loopback()
8177 tw32(MAC_MODE, tp->mac_mode); in tg3_mac_loopback()
8189 return -EIO; in tg3_phy_lpbk_set()
8200 if (tp->phy_flags & TG3_PHYFLG_IS_FET) { in tg3_phy_lpbk_set()
8210 if (!(tp->phy_flags & TG3_PHYFLG_IS_FET)) { in tg3_phy_lpbk_set()
8226 if (tp->phy_flags & TG3_PHYFLG_IS_FET) in tg3_phy_lpbk_set()
8231 if ((tp->phy_flags & TG3_PHYFLG_IS_FET) && in tg3_phy_lpbk_set()
8242 if ((tp->phy_flags & TG3_PHYFLG_MII_SERDES) && in tg3_phy_lpbk_set()
8246 tw32_f(MAC_RX_MODE, tp->rx_mode); in tg3_phy_lpbk_set()
8249 mac_mode = tp->mac_mode & in tg3_phy_lpbk_set()
8257 u32 masked_phy_id = tp->phy_id & TG3_PHY_ID_MASK; in tg3_phy_lpbk_set()
8279 if (tp->mac_mode & MAC_MODE_PORT_INT_LPBACK) in tg3_set_loopback()
8282 spin_lock_bh(&tp->lock); in tg3_set_loopback()
8284 netif_carrier_on(tp->dev); in tg3_set_loopback()
8285 spin_unlock_bh(&tp->lock); in tg3_set_loopback()
8288 if (!(tp->mac_mode & MAC_MODE_PORT_INT_LPBACK)) in tg3_set_loopback()
8291 spin_lock_bh(&tp->lock); in tg3_set_loopback()
8295 spin_unlock_bh(&tp->lock); in tg3_set_loopback()
8305 if (dev->mtu > ETH_DATA_LEN && tg3_flag(tp, 5780_CLASS)) in tg3_fix_features()
8313 netdev_features_t changed = dev->features ^ features; in tg3_set_features()
8326 if (tpr != &tp->napi[0].prodring) { in tg3_rx_prodring_free()
8327 for (i = tpr->rx_std_cons_idx; i != tpr->rx_std_prod_idx; in tg3_rx_prodring_free()
8328 i = (i + 1) & tp->rx_std_ring_mask) in tg3_rx_prodring_free()
8329 tg3_rx_data_free(tp, &tpr->rx_std_buffers[i], in tg3_rx_prodring_free()
8330 tp->rx_pkt_map_sz); in tg3_rx_prodring_free()
8333 for (i = tpr->rx_jmb_cons_idx; in tg3_rx_prodring_free()
8334 i != tpr->rx_jmb_prod_idx; in tg3_rx_prodring_free()
8335 i = (i + 1) & tp->rx_jmb_ring_mask) { in tg3_rx_prodring_free()
8336 tg3_rx_data_free(tp, &tpr->rx_jmb_buffers[i], in tg3_rx_prodring_free()
8344 for (i = 0; i <= tp->rx_std_ring_mask; i++) in tg3_rx_prodring_free()
8345 tg3_rx_data_free(tp, &tpr->rx_std_buffers[i], in tg3_rx_prodring_free()
8346 tp->rx_pkt_map_sz); in tg3_rx_prodring_free()
8349 for (i = 0; i <= tp->rx_jmb_ring_mask; i++) in tg3_rx_prodring_free()
8350 tg3_rx_data_free(tp, &tpr->rx_jmb_buffers[i], in tg3_rx_prodring_free()
8357 * The chip has been shut down and the driver detached from
8359 * end up in the driver. tp->{tx,}lock are held and thus
8367 tpr->rx_std_cons_idx = 0; in tg3_rx_prodring_alloc()
8368 tpr->rx_std_prod_idx = 0; in tg3_rx_prodring_alloc()
8369 tpr->rx_jmb_cons_idx = 0; in tg3_rx_prodring_alloc()
8370 tpr->rx_jmb_prod_idx = 0; in tg3_rx_prodring_alloc()
8372 if (tpr != &tp->napi[0].prodring) { in tg3_rx_prodring_alloc()
8373 memset(&tpr->rx_std_buffers[0], 0, in tg3_rx_prodring_alloc()
8375 if (tpr->rx_jmb_buffers) in tg3_rx_prodring_alloc()
8376 memset(&tpr->rx_jmb_buffers[0], 0, in tg3_rx_prodring_alloc()
8382 memset(tpr->rx_std, 0, TG3_RX_STD_RING_BYTES(tp)); in tg3_rx_prodring_alloc()
8386 tp->dev->mtu > ETH_DATA_LEN) in tg3_rx_prodring_alloc()
8388 tp->rx_pkt_map_sz = TG3_RX_DMA_TO_MAP_SZ(rx_pkt_dma_sz); in tg3_rx_prodring_alloc()
8394 for (i = 0; i <= tp->rx_std_ring_mask; i++) { in tg3_rx_prodring_alloc()
8397 rxd = &tpr->rx_std[i]; in tg3_rx_prodring_alloc()
8398 rxd->idx_len = rx_pkt_dma_sz << RXD_LEN_SHIFT; in tg3_rx_prodring_alloc()
8399 rxd->type_flags = (RXD_FLAG_END << RXD_FLAGS_SHIFT); in tg3_rx_prodring_alloc()
8400 rxd->opaque = (RXD_OPAQUE_RING_STD | in tg3_rx_prodring_alloc()
8405 for (i = 0; i < tp->rx_pending; i++) { in tg3_rx_prodring_alloc()
8410 netdev_warn(tp->dev, in tg3_rx_prodring_alloc()
8413 "successfully\n", i, tp->rx_pending); in tg3_rx_prodring_alloc()
8416 tp->rx_pending = i; in tg3_rx_prodring_alloc()
8424 memset(tpr->rx_jmb, 0, TG3_RX_JMB_RING_BYTES(tp)); in tg3_rx_prodring_alloc()
8429 for (i = 0; i <= tp->rx_jmb_ring_mask; i++) { in tg3_rx_prodring_alloc()
8432 rxd = &tpr->rx_jmb[i].std; in tg3_rx_prodring_alloc()
8433 rxd->idx_len = TG3_RX_JMB_DMA_SZ << RXD_LEN_SHIFT; in tg3_rx_prodring_alloc()
8434 rxd->type_flags = (RXD_FLAG_END << RXD_FLAGS_SHIFT) | in tg3_rx_prodring_alloc()
8436 rxd->opaque = (RXD_OPAQUE_RING_JUMBO | in tg3_rx_prodring_alloc()
8440 for (i = 0; i < tp->rx_jumbo_pending; i++) { in tg3_rx_prodring_alloc()
8445 netdev_warn(tp->dev, in tg3_rx_prodring_alloc()
8448 "successfully\n", i, tp->rx_jumbo_pending); in tg3_rx_prodring_alloc()
8451 tp->rx_jumbo_pending = i; in tg3_rx_prodring_alloc()
8461 return -ENOMEM; in tg3_rx_prodring_alloc()
8467 kfree(tpr->rx_std_buffers); in tg3_rx_prodring_fini()
8468 tpr->rx_std_buffers = NULL; in tg3_rx_prodring_fini()
8469 kfree(tpr->rx_jmb_buffers); in tg3_rx_prodring_fini()
8470 tpr->rx_jmb_buffers = NULL; in tg3_rx_prodring_fini()
8471 if (tpr->rx_std) { in tg3_rx_prodring_fini()
8472 dma_free_coherent(&tp->pdev->dev, TG3_RX_STD_RING_BYTES(tp), in tg3_rx_prodring_fini()
8473 tpr->rx_std, tpr->rx_std_mapping); in tg3_rx_prodring_fini()
8474 tpr->rx_std = NULL; in tg3_rx_prodring_fini()
8476 if (tpr->rx_jmb) { in tg3_rx_prodring_fini()
8477 dma_free_coherent(&tp->pdev->dev, TG3_RX_JMB_RING_BYTES(tp), in tg3_rx_prodring_fini()
8478 tpr->rx_jmb, tpr->rx_jmb_mapping); in tg3_rx_prodring_fini()
8479 tpr->rx_jmb = NULL; in tg3_rx_prodring_fini()
8486 tpr->rx_std_buffers = kzalloc(TG3_RX_STD_BUFF_RING_SIZE(tp), in tg3_rx_prodring_init()
8488 if (!tpr->rx_std_buffers) in tg3_rx_prodring_init()
8489 return -ENOMEM; in tg3_rx_prodring_init()
8491 tpr->rx_std = dma_alloc_coherent(&tp->pdev->dev, in tg3_rx_prodring_init()
8493 &tpr->rx_std_mapping, in tg3_rx_prodring_init()
8495 if (!tpr->rx_std) in tg3_rx_prodring_init()
8499 tpr->rx_jmb_buffers = kzalloc(TG3_RX_JMB_BUFF_RING_SIZE(tp), in tg3_rx_prodring_init()
8501 if (!tpr->rx_jmb_buffers) in tg3_rx_prodring_init()
8504 tpr->rx_jmb = dma_alloc_coherent(&tp->pdev->dev, in tg3_rx_prodring_init()
8506 &tpr->rx_jmb_mapping, in tg3_rx_prodring_init()
8508 if (!tpr->rx_jmb) in tg3_rx_prodring_init()
8516 return -ENOMEM; in tg3_rx_prodring_init()
8521 * The chip has been shut down and the driver detached from
8523 * end up in the driver. tp->{tx,}lock is not held and we are not
8530 for (j = 0; j < tp->irq_cnt; j++) { in tg3_free_rings()
8531 struct tg3_napi *tnapi = &tp->napi[j]; in tg3_free_rings()
8533 tg3_rx_prodring_free(tp, &tnapi->prodring); in tg3_free_rings()
8535 if (!tnapi->tx_buffers) in tg3_free_rings()
8539 struct sk_buff *skb = tnapi->tx_buffers[i].skb; in tg3_free_rings()
8545 skb_shinfo(skb)->nr_frags - 1); in tg3_free_rings()
8549 netdev_tx_reset_queue(netdev_get_tx_queue(tp->dev, j)); in tg3_free_rings()
8555 * The chip has been shut down and the driver detached from
8557 * end up in the driver. tp->{tx,}lock are held and thus
8567 for (i = 0; i < tp->irq_cnt; i++) { in tg3_init_rings()
8568 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_init_rings()
8570 tnapi->last_tag = 0; in tg3_init_rings()
8571 tnapi->last_irq_tag = 0; in tg3_init_rings()
8572 tnapi->hw_status->status = 0; in tg3_init_rings()
8573 tnapi->hw_status->status_tag = 0; in tg3_init_rings()
8574 memset(tnapi->hw_status, 0, TG3_HW_STATUS_SIZE); in tg3_init_rings()
8576 tnapi->tx_prod = 0; in tg3_init_rings()
8577 tnapi->tx_cons = 0; in tg3_init_rings()
8578 if (tnapi->tx_ring) in tg3_init_rings()
8579 memset(tnapi->tx_ring, 0, TG3_TX_RING_BYTES); in tg3_init_rings()
8581 tnapi->rx_rcb_ptr = 0; in tg3_init_rings()
8582 if (tnapi->rx_rcb) in tg3_init_rings()
8583 memset(tnapi->rx_rcb, 0, TG3_RX_RCB_RING_BYTES(tp)); in tg3_init_rings()
8585 if (tnapi->prodring.rx_std && in tg3_init_rings()
8586 tg3_rx_prodring_alloc(tp, &tnapi->prodring)) { in tg3_init_rings()
8588 return -ENOMEM; in tg3_init_rings()
8599 for (i = 0; i < tp->irq_max; i++) { in tg3_mem_tx_release()
8600 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_mem_tx_release()
8602 if (tnapi->tx_ring) { in tg3_mem_tx_release()
8603 dma_free_coherent(&tp->pdev->dev, TG3_TX_RING_BYTES, in tg3_mem_tx_release()
8604 tnapi->tx_ring, tnapi->tx_desc_mapping); in tg3_mem_tx_release()
8605 tnapi->tx_ring = NULL; in tg3_mem_tx_release()
8608 kfree(tnapi->tx_buffers); in tg3_mem_tx_release()
8609 tnapi->tx_buffers = NULL; in tg3_mem_tx_release()
8616 struct tg3_napi *tnapi = &tp->napi[0]; in tg3_mem_tx_acquire()
8624 for (i = 0; i < tp->txq_cnt; i++, tnapi++) { in tg3_mem_tx_acquire()
8625 tnapi->tx_buffers = kcalloc(TG3_TX_RING_SIZE, in tg3_mem_tx_acquire()
8628 if (!tnapi->tx_buffers) in tg3_mem_tx_acquire()
8631 tnapi->tx_ring = dma_alloc_coherent(&tp->pdev->dev, in tg3_mem_tx_acquire()
8633 &tnapi->tx_desc_mapping, in tg3_mem_tx_acquire()
8635 if (!tnapi->tx_ring) in tg3_mem_tx_acquire()
8643 return -ENOMEM; in tg3_mem_tx_acquire()
8650 for (i = 0; i < tp->irq_max; i++) { in tg3_mem_rx_release()
8651 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_mem_rx_release()
8653 tg3_rx_prodring_fini(tp, &tnapi->prodring); in tg3_mem_rx_release()
8655 if (!tnapi->rx_rcb) in tg3_mem_rx_release()
8658 dma_free_coherent(&tp->pdev->dev, in tg3_mem_rx_release()
8660 tnapi->rx_rcb, in tg3_mem_rx_release()
8661 tnapi->rx_rcb_mapping); in tg3_mem_rx_release()
8662 tnapi->rx_rcb = NULL; in tg3_mem_rx_release()
8670 limit = tp->rxq_cnt; in tg3_mem_rx_acquire()
8679 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_mem_rx_acquire()
8681 if (tg3_rx_prodring_init(tp, &tnapi->prodring)) in tg3_mem_rx_acquire()
8691 tnapi->rx_rcb = dma_alloc_coherent(&tp->pdev->dev, in tg3_mem_rx_acquire()
8693 &tnapi->rx_rcb_mapping, in tg3_mem_rx_acquire()
8695 if (!tnapi->rx_rcb) in tg3_mem_rx_acquire()
8703 return -ENOMEM; in tg3_mem_rx_acquire()
8708 * the hardware shutdown down.
8714 for (i = 0; i < tp->irq_cnt; i++) { in tg3_free_consistent()
8715 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_free_consistent()
8717 if (tnapi->hw_status) { in tg3_free_consistent()
8718 dma_free_coherent(&tp->pdev->dev, TG3_HW_STATUS_SIZE, in tg3_free_consistent()
8719 tnapi->hw_status, in tg3_free_consistent()
8720 tnapi->status_mapping); in tg3_free_consistent()
8721 tnapi->hw_status = NULL; in tg3_free_consistent()
8728 /* tp->hw_stats can be referenced safely: in tg3_free_consistent()
8730 * 2. or under tp->lock if TG3_FLAG_INIT_COMPLETE is set. in tg3_free_consistent()
8732 if (tp->hw_stats) { in tg3_free_consistent()
8733 dma_free_coherent(&tp->pdev->dev, sizeof(struct tg3_hw_stats), in tg3_free_consistent()
8734 tp->hw_stats, tp->stats_mapping); in tg3_free_consistent()
8735 tp->hw_stats = NULL; in tg3_free_consistent()
8741 * the hardware shutdown down. Can sleep.
8747 tp->hw_stats = dma_alloc_coherent(&tp->pdev->dev, in tg3_alloc_consistent()
8749 &tp->stats_mapping, GFP_KERNEL); in tg3_alloc_consistent()
8750 if (!tp->hw_stats) in tg3_alloc_consistent()
8753 for (i = 0; i < tp->irq_cnt; i++) { in tg3_alloc_consistent()
8754 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_alloc_consistent()
8757 tnapi->hw_status = dma_alloc_coherent(&tp->pdev->dev, in tg3_alloc_consistent()
8759 &tnapi->status_mapping, in tg3_alloc_consistent()
8761 if (!tnapi->hw_status) in tg3_alloc_consistent()
8764 sblk = tnapi->hw_status; in tg3_alloc_consistent()
8777 prodptr = &sblk->idx[0].rx_producer; in tg3_alloc_consistent()
8780 prodptr = &sblk->rx_jumbo_consumer; in tg3_alloc_consistent()
8783 prodptr = &sblk->reserved; in tg3_alloc_consistent()
8786 prodptr = &sblk->rx_mini_consumer; in tg3_alloc_consistent()
8789 tnapi->rx_rcb_prod_idx = prodptr; in tg3_alloc_consistent()
8791 tnapi->rx_rcb_prod_idx = &sblk->idx[0].rx_producer; in tg3_alloc_consistent()
8802 return -ENOMEM; in tg3_alloc_consistent()
8808 * clears. tp->lock is held.
8837 if (pci_channel_offline(tp->pdev)) { in tg3_stop_block()
8838 dev_err(&tp->pdev->dev, in tg3_stop_block()
8842 return -ENODEV; in tg3_stop_block()
8852 dev_err(&tp->pdev->dev, in tg3_stop_block()
8855 return -ENODEV; in tg3_stop_block()
8861 /* tp->lock is held. */
8868 if (pci_channel_offline(tp->pdev)) { in tg3_abort_hw()
8869 tp->rx_mode &= ~(RX_MODE_ENABLE | TX_MODE_ENABLE); in tg3_abort_hw()
8870 tp->mac_mode &= ~MAC_MODE_TDE_ENABLE; in tg3_abort_hw()
8871 err = -ENODEV; in tg3_abort_hw()
8875 tp->rx_mode &= ~RX_MODE_ENABLE; in tg3_abort_hw()
8876 tw32_f(MAC_RX_MODE, tp->rx_mode); in tg3_abort_hw()
8894 tp->mac_mode &= ~MAC_MODE_TDE_ENABLE; in tg3_abort_hw()
8895 tw32_f(MAC_MODE, tp->mac_mode); in tg3_abort_hw()
8898 tp->tx_mode &= ~TX_MODE_ENABLE; in tg3_abort_hw()
8899 tw32_f(MAC_TX_MODE, tp->tx_mode); in tg3_abort_hw()
8907 dev_err(&tp->pdev->dev, in tg3_abort_hw()
8910 err |= -ENODEV; in tg3_abort_hw()
8924 for (i = 0; i < tp->irq_cnt; i++) { in tg3_abort_hw()
8925 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_abort_hw()
8926 if (tnapi->hw_status) in tg3_abort_hw()
8927 memset(tnapi->hw_status, 0, TG3_HW_STATUS_SIZE); in tg3_abort_hw()
8936 pci_read_config_word(tp->pdev, PCI_COMMAND, &tp->pci_cmd); in tg3_save_pci_state()
8944 /* Re-enable indirect register accesses. */ in tg3_restore_pci_state()
8945 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, in tg3_restore_pci_state()
8946 tp->misc_host_ctrl); in tg3_restore_pci_state()
8958 pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, val); in tg3_restore_pci_state()
8960 pci_write_config_word(tp->pdev, PCI_COMMAND, tp->pci_cmd); in tg3_restore_pci_state()
8963 pci_write_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE, in tg3_restore_pci_state()
8964 tp->pci_cacheline_sz); in tg3_restore_pci_state()
8965 pci_write_config_byte(tp->pdev, PCI_LATENCY_TIMER, in tg3_restore_pci_state()
8966 tp->pci_lat_timer); in tg3_restore_pci_state()
8969 /* Make sure PCI-X relaxed ordering bit is clear. */ in tg3_restore_pci_state()
8973 pci_read_config_word(tp->pdev, tp->pcix_cap + PCI_X_CMD, in tg3_restore_pci_state()
8976 pci_write_config_word(tp->pdev, tp->pcix_cap + PCI_X_CMD, in tg3_restore_pci_state()
8988 pci_read_config_word(tp->pdev, in tg3_restore_pci_state()
8989 tp->msi_cap + PCI_MSI_FLAGS, in tg3_restore_pci_state()
8991 pci_write_config_word(tp->pdev, in tg3_restore_pci_state()
8992 tp->msi_cap + PCI_MSI_FLAGS, in tg3_restore_pci_state()
9043 /* tp->lock is held. */
9045 __releases(tp->lock) in tg3_chip_reset()
9046 __acquires(tp->lock) in tg3_chip_reset()
9052 if (!pci_device_is_present(tp->pdev)) in tg3_chip_reset()
9053 return -ENODEV; in tg3_chip_reset()
9062 tp->nvram_lock_cnt = 0; in tg3_chip_reset()
9080 write_op = tp->write32; in tg3_chip_reset()
9082 tp->write32 = tg3_write32; in tg3_chip_reset()
9091 for (i = 0; i < tp->irq_cnt; i++) { in tg3_chip_reset()
9092 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_chip_reset()
9093 if (tnapi->hw_status) { in tg3_chip_reset()
9094 tnapi->hw_status->status = 0; in tg3_chip_reset()
9095 tnapi->hw_status->status_tag = 0; in tg3_chip_reset()
9097 tnapi->last_tag = 0; in tg3_chip_reset()
9098 tnapi->last_irq_tag = 0; in tg3_chip_reset()
9104 for (i = 0; i < tp->irq_cnt; i++) in tg3_chip_reset()
9105 synchronize_irq(tp->napi[i].irq_vec); in tg3_chip_reset()
9151 tp->write32 = write_op; in tg3_chip_reset()
9174 pci_read_config_dword(tp->pdev, PCI_COMMAND, &val); in tg3_chip_reset()
9178 if (tg3_flag(tp, PCI_EXPRESS) && pci_is_pcie(tp->pdev)) { in tg3_chip_reset()
9189 pci_read_config_dword(tp->pdev, 0xc4, &cfg_val); in tg3_chip_reset()
9190 pci_write_config_dword(tp->pdev, 0xc4, in tg3_chip_reset()
9202 pcie_capability_clear_word(tp->pdev, PCI_EXP_DEVCTL, val16); in tg3_chip_reset()
9205 pcie_capability_write_word(tp->pdev, PCI_EXP_DEVSTA, in tg3_chip_reset()
9241 tw32(GRC_MODE, tp->grc_mode); in tg3_chip_reset()
9249 if ((tp->nic_sram_data_cfg & NIC_SRAM_DATA_CFG_MINI_PCI) != 0 && in tg3_chip_reset()
9251 tp->pci_clock_ctrl |= CLOCK_CTRL_CLKRUN_OENABLE; in tg3_chip_reset()
9253 tp->pci_clock_ctrl |= CLOCK_CTRL_FORCE_CLKRUN; in tg3_chip_reset()
9254 tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl); in tg3_chip_reset()
9257 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) { in tg3_chip_reset()
9258 tp->mac_mode = MAC_MODE_PORT_MODE_TBI; in tg3_chip_reset()
9259 val = tp->mac_mode; in tg3_chip_reset()
9260 } else if (tp->phy_flags & TG3_PHYFLG_MII_SERDES) { in tg3_chip_reset()
9261 tp->mac_mode = MAC_MODE_PORT_MODE_GMII; in tg3_chip_reset()
9262 val = tp->mac_mode; in tg3_chip_reset()
9295 tp->phy_flags &= ~(TG3_PHYFLG_1G_ON_VAUX_OK | in tg3_chip_reset()
9306 tp->last_event_jiffies = jiffies; in tg3_chip_reset()
9312 tp->phy_flags |= TG3_PHYFLG_1G_ON_VAUX_OK; in tg3_chip_reset()
9314 tp->phy_flags |= TG3_PHYFLG_KEEP_LINK_ON_PWRDN; in tg3_chip_reset()
9325 /* tp->lock is held. */
9342 if (tp->hw_stats) { in tg3_halt()
9344 tg3_get_nstats(tp, &tp->net_stats_prev); in tg3_halt()
9345 tg3_get_estats(tp, &tp->estats_prev); in tg3_halt()
9348 memset(tp->hw_stats, 0, sizeof(struct tg3_hw_stats)); in tg3_halt()
9361 if (!is_valid_ether_addr(addr->sa_data)) in tg3_set_mac_addr()
9362 return -EADDRNOTAVAIL; in tg3_set_mac_addr()
9364 eth_hw_addr_set(dev, addr->sa_data); in tg3_set_mac_addr()
9382 spin_lock_bh(&tp->lock); in tg3_set_mac_addr()
9385 spin_unlock_bh(&tp->lock); in tg3_set_mac_addr()
9390 /* tp->lock is held. */
9417 tw32(HOSTCC_TXCOL_TICKS, ec->tx_coalesce_usecs); in tg3_coal_tx_init()
9418 tw32(HOSTCC_TXMAX_FRAMES, ec->tx_max_coalesced_frames); in tg3_coal_tx_init()
9419 tw32(HOSTCC_TXCOAL_MAXF_INT, ec->tx_max_coalesced_frames_irq); in tg3_coal_tx_init()
9425 for (; i < tp->txq_cnt; i++) { in tg3_coal_tx_init()
9429 tw32(reg, ec->tx_coalesce_usecs); in tg3_coal_tx_init()
9431 tw32(reg, ec->tx_max_coalesced_frames); in tg3_coal_tx_init()
9433 tw32(reg, ec->tx_max_coalesced_frames_irq); in tg3_coal_tx_init()
9437 for (; i < tp->irq_max - 1; i++) { in tg3_coal_tx_init()
9447 u32 limit = tp->rxq_cnt; in tg3_coal_rx_init()
9450 tw32(HOSTCC_RXCOL_TICKS, ec->rx_coalesce_usecs); in tg3_coal_rx_init()
9451 tw32(HOSTCC_RXMAX_FRAMES, ec->rx_max_coalesced_frames); in tg3_coal_rx_init()
9452 tw32(HOSTCC_RXCOAL_MAXF_INT, ec->rx_max_coalesced_frames_irq); in tg3_coal_rx_init()
9453 limit--; in tg3_coal_rx_init()
9464 tw32(reg, ec->rx_coalesce_usecs); in tg3_coal_rx_init()
9466 tw32(reg, ec->rx_max_coalesced_frames); in tg3_coal_rx_init()
9468 tw32(reg, ec->rx_max_coalesced_frames_irq); in tg3_coal_rx_init()
9471 for (; i < tp->irq_max - 1; i++) { in tg3_coal_rx_init()
9484 u32 val = ec->stats_block_coalesce_usecs; in __tg3_set_coalesce()
9486 tw32(HOSTCC_RXCOAL_TICK_INT, ec->rx_coalesce_usecs_irq); in __tg3_set_coalesce()
9487 tw32(HOSTCC_TXCOAL_TICK_INT, ec->tx_coalesce_usecs_irq); in __tg3_set_coalesce()
9489 if (!tp->link_up) in __tg3_set_coalesce()
9496 /* tp->lock is held. */
9518 /* tp->lock is held. */
9527 for (; i < tp->irq_max; i++, txrcb += TG3_BDINFO_SIZE) { in tg3_tx_rcbs_init()
9528 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_tx_rcbs_init()
9530 if (!tnapi->tx_ring) in tg3_tx_rcbs_init()
9533 tg3_set_bdinfo(tp, txrcb, tnapi->tx_desc_mapping, in tg3_tx_rcbs_init()
9539 /* tp->lock is held. */
9562 /* tp->lock is held. */
9571 for (; i < tp->irq_max; i++, rxrcb += TG3_BDINFO_SIZE) { in tg3_rx_ret_rcbs_init()
9572 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_rx_ret_rcbs_init()
9574 if (!tnapi->rx_rcb) in tg3_rx_ret_rcbs_init()
9577 tg3_set_bdinfo(tp, rxrcb, tnapi->rx_rcb_mapping, in tg3_rx_ret_rcbs_init()
9578 (tp->rx_ret_ring_mask + 1) << in tg3_rx_ret_rcbs_init()
9583 /* tp->lock is held. */
9588 struct tg3_napi *tnapi = &tp->napi[0]; in tg3_rings_reset()
9595 tw32_mailbox_f(tp->napi[0].int_mbox, 1); in tg3_rings_reset()
9596 tp->napi[0].chk_msi_cnt = 0; in tg3_rings_reset()
9597 tp->napi[0].last_rx_cons = 0; in tg3_rings_reset()
9598 tp->napi[0].last_tx_cons = 0; in tg3_rings_reset()
9602 for (i = 1; i < tp->irq_max; i++) { in tg3_rings_reset()
9603 tp->napi[i].tx_prod = 0; in tg3_rings_reset()
9604 tp->napi[i].tx_cons = 0; in tg3_rings_reset()
9606 tw32_mailbox(tp->napi[i].prodmbox, 0); in tg3_rings_reset()
9607 tw32_rx_mbox(tp->napi[i].consmbox, 0); in tg3_rings_reset()
9608 tw32_mailbox_f(tp->napi[i].int_mbox, 1); in tg3_rings_reset()
9609 tp->napi[i].chk_msi_cnt = 0; in tg3_rings_reset()
9610 tp->napi[i].last_rx_cons = 0; in tg3_rings_reset()
9611 tp->napi[i].last_tx_cons = 0; in tg3_rings_reset()
9614 tw32_mailbox(tp->napi[0].prodmbox, 0); in tg3_rings_reset()
9616 tp->napi[0].tx_prod = 0; in tg3_rings_reset()
9617 tp->napi[0].tx_cons = 0; in tg3_rings_reset()
9618 tw32_mailbox(tp->napi[0].prodmbox, 0); in tg3_rings_reset()
9619 tw32_rx_mbox(tp->napi[0].consmbox, 0); in tg3_rings_reset()
9622 /* Make sure the NIC-based send BD rings are disabled. */ in tg3_rings_reset()
9630 memset(tnapi->hw_status, 0, TG3_HW_STATUS_SIZE); in tg3_rings_reset()
9634 ((u64) tnapi->status_mapping >> 32)); in tg3_rings_reset()
9636 ((u64) tnapi->status_mapping & 0xffffffff)); in tg3_rings_reset()
9640 for (i = 1, tnapi++; i < tp->irq_cnt; i++, tnapi++) { in tg3_rings_reset()
9641 u64 mapping = (u64)tnapi->status_mapping; in tg3_rings_reset()
9647 memset(tnapi->hw_status, 0, TG3_HW_STATUS_SIZE); in tg3_rings_reset()
9670 nic_rep_thresh = min(bdcache_maxcnt / 2, tp->rx_std_max_post); in tg3_setup_rxbd_thresholds()
9671 host_rep_thresh = max_t(u32, tp->rx_pending / 8, 1); in tg3_setup_rxbd_thresholds()
9684 host_rep_thresh = max_t(u32, tp->rx_jumbo_pending / 8, 1); in tg3_setup_rxbd_thresholds()
9731 rx_mode = tp->rx_mode & ~(RX_MODE_PROMISC | in __tg3_set_rx_mode()
9742 if (dev->flags & IFF_PROMISC) { in __tg3_set_rx_mode()
9745 } else if (dev->flags & IFF_ALLMULTI) { in __tg3_set_rx_mode()
9760 crc = calc_crc(ha->addr, ETH_ALEN); in __tg3_set_rx_mode()
9775 } else if (!(dev->flags & IFF_PROMISC)) { in __tg3_set_rx_mode()
9781 __tg3_set_one_mac_addr(tp, ha->addr, in __tg3_set_rx_mode()
9787 if (rx_mode != tp->rx_mode) { in __tg3_set_rx_mode()
9788 tp->rx_mode = rx_mode; in __tg3_set_rx_mode()
9799 tp->rss_ind_tbl[i] = ethtool_rxfh_indir_default(i, qcnt); in tg3_rss_init_dflt_indir_tbl()
9809 if (tp->rxq_cnt == 1) { in tg3_rss_check_indir_tbl()
9810 memset(&tp->rss_ind_tbl[0], 0, sizeof(tp->rss_ind_tbl)); in tg3_rss_check_indir_tbl()
9816 if (tp->rss_ind_tbl[i] >= tp->rxq_cnt) in tg3_rss_check_indir_tbl()
9821 tg3_rss_init_dflt_indir_tbl(tp, tp->rxq_cnt); in tg3_rss_check_indir_tbl()
9830 u32 val = tp->rss_ind_tbl[i]; in tg3_rss_write_indir_tbl()
9834 val |= tp->rss_ind_tbl[i]; in tg3_rss_write_indir_tbl()
9849 /* tp->lock is held. */
9854 struct tg3_rx_prodring_set *tpr = &tp->napi[0].prodring; in tg3_reset_hw()
9865 if ((tp->phy_flags & TG3_PHYFLG_KEEP_LINK_ON_PWRDN) && in tg3_reset_hw()
9866 !(tp->phy_flags & TG3_PHYFLG_USER_CONFIGURED)) { in tg3_reset_hw()
9869 tp->phy_flags |= TG3_PHYFLG_USER_CONFIGURED; in tg3_reset_hw()
9873 if (tp->phy_flags & TG3_PHYFLG_EEE_CAP) in tg3_reset_hw()
9987 tp->pci_clock_ctrl |= CLOCK_CTRL_DELAY_PCI_GRANT; in tg3_reset_hw()
9988 tw32_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl); in tg3_reset_hw()
10034 tw32(TG3PCI_DMA_RW_CTRL, val | tp->dma_rwctrl); in tg3_reset_hw()
10040 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl); in tg3_reset_hw()
10043 tp->grc_mode &= ~(GRC_MODE_HOST_SENDBDS | in tg3_reset_hw()
10047 tp->grc_mode |= GRC_MODE_HOST_SENDBDS; in tg3_reset_hw()
10049 /* Pseudo-header checksum is done by hardware logic and not in tg3_reset_hw()
10050 * the offload processers, so make the chip do the pseudo- in tg3_reset_hw()
10052 * convenient to do the pseudo-header checksum in software in tg3_reset_hw()
10055 tp->grc_mode |= GRC_MODE_NO_TX_PHDR_CSUM; in tg3_reset_hw()
10058 if (tp->rxptpctl) in tg3_reset_hw()
10060 tp->rxptpctl | TG3_RX_PTP_CTL_HWTS_INTERLOCK); in tg3_reset_hw()
10065 tw32(GRC_MODE, tp->grc_mode | val); in tg3_reset_hw()
10071 if (tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL && in tg3_reset_hw()
10072 tp->pdev->subsystem_device == TG3PCI_SUBDEVICE_ID_DELL_5762) { in tg3_reset_hw()
10097 fw_len = tp->fw_len; in tg3_reset_hw()
10098 fw_len = (fw_len + (0x80 - 1)) & ~(0x80 - 1); in tg3_reset_hw()
10102 NIC_SRAM_MBUF_POOL_SIZE5705 - fw_len - 0xa00); in tg3_reset_hw()
10105 if (tp->dev->mtu <= ETH_DATA_LEN) { in tg3_reset_hw()
10107 tp->bufmgr_config.mbuf_read_dma_low_water); in tg3_reset_hw()
10109 tp->bufmgr_config.mbuf_mac_rx_low_water); in tg3_reset_hw()
10111 tp->bufmgr_config.mbuf_high_water); in tg3_reset_hw()
10114 tp->bufmgr_config.mbuf_read_dma_low_water_jumbo); in tg3_reset_hw()
10116 tp->bufmgr_config.mbuf_mac_rx_low_water_jumbo); in tg3_reset_hw()
10118 tp->bufmgr_config.mbuf_high_water_jumbo); in tg3_reset_hw()
10121 tp->bufmgr_config.dma_low_water); in tg3_reset_hw()
10123 tp->bufmgr_config.dma_high_water); in tg3_reset_hw()
10140 netdev_err(tp->dev, "%s cannot enable BUFMGR\n", __func__); in tg3_reset_hw()
10141 return -ENODEV; in tg3_reset_hw()
10167 ((u64) tpr->rx_std_mapping >> 32)); in tg3_reset_hw()
10169 ((u64) tpr->rx_std_mapping & 0xffffffff)); in tg3_reset_hw()
10187 ((u64) tpr->rx_jmb_mapping >> 32)); in tg3_reset_hw()
10189 ((u64) tpr->rx_jmb_mapping & 0xffffffff)); in tg3_reset_hw()
10215 tpr->rx_std_prod_idx = tp->rx_pending; in tg3_reset_hw()
10216 tw32_rx_mbox(TG3_RX_STD_PROD_IDX_REG, tpr->rx_std_prod_idx); in tg3_reset_hw()
10218 tpr->rx_jmb_prod_idx = in tg3_reset_hw()
10219 tg3_flag(tp, JUMBO_RING_ENABLE) ? tp->rx_jumbo_pending : 0; in tg3_reset_hw()
10220 tw32_rx_mbox(TG3_RX_JMB_PROD_IDX_REG, tpr->rx_jmb_prod_idx); in tg3_reset_hw()
10229 tp->dev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN); in tg3_reset_hw()
10283 tp->dma_limit = 0; in tg3_reset_hw()
10284 if (tp->dev->mtu <= ETH_DATA_LEN) { in tg3_reset_hw()
10286 tp->dma_limit = TG3_TX_BD_DMA_MAX_2K; in tg3_reset_hw()
10372 __tg3_set_coalesce(tp, &tp->coal); in tg3_reset_hw()
10380 ((u64) tp->stats_mapping >> 32)); in tg3_reset_hw()
10382 ((u64) tp->stats_mapping & 0xffffffff)); in tg3_reset_hw()
10396 tw32(HOSTCC_MODE, HOSTCC_MODE_ENABLE | tp->coalesce_mode); in tg3_reset_hw()
10403 if (tp->phy_flags & TG3_PHYFLG_MII_SERDES) { in tg3_reset_hw()
10404 tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT; in tg3_reset_hw()
10410 tp->mac_mode |= MAC_MODE_TXSTAT_ENABLE | MAC_MODE_RXSTAT_ENABLE | in tg3_reset_hw()
10414 tp->mac_mode |= MAC_MODE_APE_TX_EN | MAC_MODE_APE_RX_EN; in tg3_reset_hw()
10416 !(tp->phy_flags & TG3_PHYFLG_PHY_SERDES) && in tg3_reset_hw()
10418 tp->mac_mode |= MAC_MODE_LINK_POLARITY; in tg3_reset_hw()
10419 tw32_f(MAC_MODE, tp->mac_mode | MAC_MODE_RXSTAT_CLEAR | MAC_MODE_TXSTAT_CLEAR); in tg3_reset_hw()
10422 /* tp->grc_local_ctrl is partially set up during tg3_get_invariants(). in tg3_reset_hw()
10442 tp->grc_local_ctrl &= ~gpio_mask; in tg3_reset_hw()
10443 tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask; in tg3_reset_hw()
10447 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 | in tg3_reset_hw()
10450 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); in tg3_reset_hw()
10456 if (tp->irq_cnt > 1) in tg3_reset_hw()
10499 pci_read_config_word(tp->pdev, tp->pcix_cap + PCI_X_CMD, in tg3_reset_hw()
10508 pci_write_config_word(tp->pdev, tp->pcix_cap + PCI_X_CMD, in tg3_reset_hw()
10575 tp->tx_mode = TX_MODE_ENABLE; in tg3_reset_hw()
10579 tp->tx_mode |= TX_MODE_MBUF_LOCKUP_FIX; in tg3_reset_hw()
10584 tp->tx_mode &= ~val; in tg3_reset_hw()
10585 tp->tx_mode |= tr32(MAC_TX_MODE) & val; in tg3_reset_hw()
10588 tw32_f(MAC_TX_MODE, tp->tx_mode); in tg3_reset_hw()
10602 tp->rx_mode = RX_MODE_ENABLE; in tg3_reset_hw()
10604 tp->rx_mode |= RX_MODE_IPV6_CSUM_ENABLE; in tg3_reset_hw()
10607 tp->rx_mode |= RX_MODE_IPV4_FRAG_FIX; in tg3_reset_hw()
10610 tp->rx_mode |= RX_MODE_RSS_ENABLE | in tg3_reset_hw()
10617 tw32_f(MAC_RX_MODE, tp->rx_mode); in tg3_reset_hw()
10620 tw32(MAC_LED_CTRL, tp->led_ctrl); in tg3_reset_hw()
10623 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) { in tg3_reset_hw()
10627 tw32_f(MAC_RX_MODE, tp->rx_mode); in tg3_reset_hw()
10630 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) { in tg3_reset_hw()
10632 !(tp->phy_flags & TG3_PHYFLG_SERDES_PREEMPHASIS)) { in tg3_reset_hw()
10634 /* only if the signal pre-emphasis bit is not set */ in tg3_reset_hw()
10654 (tp->phy_flags & TG3_PHYFLG_PHY_SERDES)) { in tg3_reset_hw()
10655 /* Use hardware link auto-negotiation */ in tg3_reset_hw()
10659 if ((tp->phy_flags & TG3_PHYFLG_MII_SERDES) && in tg3_reset_hw()
10665 tp->grc_local_ctrl &= ~GRC_LCLCTRL_USE_EXT_SIG_DETECT; in tg3_reset_hw()
10666 tp->grc_local_ctrl |= GRC_LCLCTRL_USE_SIG_DETECT; in tg3_reset_hw()
10667 tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl); in tg3_reset_hw()
10671 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) in tg3_reset_hw()
10672 tp->phy_flags &= ~TG3_PHYFLG_IS_LOW_POWER; in tg3_reset_hw()
10678 if (!(tp->phy_flags & TG3_PHYFLG_PHY_SERDES) && in tg3_reset_hw()
10679 !(tp->phy_flags & TG3_PHYFLG_IS_FET)) { in tg3_reset_hw()
10691 __tg3_set_rx_mode(tp->dev); in tg3_reset_hw()
10704 limit -= 4; in tg3_reset_hw()
10764 * packet processing. Invoked with tp->lock held.
10791 if (ocir->signature != TG3_OCIR_SIG_MAGIC || in tg3_sd_scan_scratchpad()
10792 !(ocir->version_flags & TG3_OCIR_FLAG_ACTIVE)) in tg3_sd_scan_scratchpad()
10805 spin_lock_bh(&tp->lock); in tg3_show_temp()
10806 tg3_ape_scratchpad_read(tp, &temperature, attr->index, in tg3_show_temp()
10808 spin_unlock_bh(&tp->lock); in tg3_show_temp()
10830 if (tp->hwmon_dev) { in tg3_hwmon_close()
10831 hwmon_device_unregister(tp->hwmon_dev); in tg3_hwmon_close()
10832 tp->hwmon_dev = NULL; in tg3_hwmon_close()
10840 struct pci_dev *pdev = tp->pdev; in tg3_hwmon_open()
10856 tp->hwmon_dev = hwmon_device_register_with_groups(&pdev->dev, "tg3", in tg3_hwmon_open()
10858 if (IS_ERR(tp->hwmon_dev)) { in tg3_hwmon_open()
10859 tp->hwmon_dev = NULL; in tg3_hwmon_open()
10860 dev_err(&pdev->dev, "Cannot register hwmon device, aborting\n"); in tg3_hwmon_open()
10871 (PSTAT)->low += __val; \
10872 if ((PSTAT)->low < __val) \
10873 (PSTAT)->high += 1; \
10878 struct tg3_hw_stats *sp = tp->hw_stats; in tg3_periodic_fetch_stats()
10880 if (!tp->link_up) in tg3_periodic_fetch_stats()
10883 TG3_STAT_ADD32(&sp->tx_octets, MAC_TX_STATS_OCTETS); in tg3_periodic_fetch_stats()
10884 TG3_STAT_ADD32(&sp->tx_collisions, MAC_TX_STATS_COLLISIONS); in tg3_periodic_fetch_stats()
10885 TG3_STAT_ADD32(&sp->tx_xon_sent, MAC_TX_STATS_XON_SENT); in tg3_periodic_fetch_stats()
10886 TG3_STAT_ADD32(&sp->tx_xoff_sent, MAC_TX_STATS_XOFF_SENT); in tg3_periodic_fetch_stats()
10887 TG3_STAT_ADD32(&sp->tx_mac_errors, MAC_TX_STATS_MAC_ERRORS); in tg3_periodic_fetch_stats()
10888 TG3_STAT_ADD32(&sp->tx_single_collisions, MAC_TX_STATS_SINGLE_COLLISIONS); in tg3_periodic_fetch_stats()
10889 TG3_STAT_ADD32(&sp->tx_mult_collisions, MAC_TX_STATS_MULT_COLLISIONS); in tg3_periodic_fetch_stats()
10890 TG3_STAT_ADD32(&sp->tx_deferred, MAC_TX_STATS_DEFERRED); in tg3_periodic_fetch_stats()
10891 TG3_STAT_ADD32(&sp->tx_excessive_collisions, MAC_TX_STATS_EXCESSIVE_COL); in tg3_periodic_fetch_stats()
10892 TG3_STAT_ADD32(&sp->tx_late_collisions, MAC_TX_STATS_LATE_COL); in tg3_periodic_fetch_stats()
10893 TG3_STAT_ADD32(&sp->tx_ucast_packets, MAC_TX_STATS_UCAST); in tg3_periodic_fetch_stats()
10894 TG3_STAT_ADD32(&sp->tx_mcast_packets, MAC_TX_STATS_MCAST); in tg3_periodic_fetch_stats()
10895 TG3_STAT_ADD32(&sp->tx_bcast_packets, MAC_TX_STATS_BCAST); in tg3_periodic_fetch_stats()
10897 (sp->tx_ucast_packets.low + sp->tx_mcast_packets.low + in tg3_periodic_fetch_stats()
10898 sp->tx_bcast_packets.low) > TG3_NUM_RDMA_CHANNELS)) { in tg3_periodic_fetch_stats()
10907 TG3_STAT_ADD32(&sp->rx_octets, MAC_RX_STATS_OCTETS); in tg3_periodic_fetch_stats()
10908 TG3_STAT_ADD32(&sp->rx_fragments, MAC_RX_STATS_FRAGMENTS); in tg3_periodic_fetch_stats()
10909 TG3_STAT_ADD32(&sp->rx_ucast_packets, MAC_RX_STATS_UCAST); in tg3_periodic_fetch_stats()
10910 TG3_STAT_ADD32(&sp->rx_mcast_packets, MAC_RX_STATS_MCAST); in tg3_periodic_fetch_stats()
10911 TG3_STAT_ADD32(&sp->rx_bcast_packets, MAC_RX_STATS_BCAST); in tg3_periodic_fetch_stats()
10912 TG3_STAT_ADD32(&sp->rx_fcs_errors, MAC_RX_STATS_FCS_ERRORS); in tg3_periodic_fetch_stats()
10913 TG3_STAT_ADD32(&sp->rx_align_errors, MAC_RX_STATS_ALIGN_ERRORS); in tg3_periodic_fetch_stats()
10914 TG3_STAT_ADD32(&sp->rx_xon_pause_rcvd, MAC_RX_STATS_XON_PAUSE_RECVD); in tg3_periodic_fetch_stats()
10915 TG3_STAT_ADD32(&sp->rx_xoff_pause_rcvd, MAC_RX_STATS_XOFF_PAUSE_RECVD); in tg3_periodic_fetch_stats()
10916 TG3_STAT_ADD32(&sp->rx_mac_ctrl_rcvd, MAC_RX_STATS_MAC_CTRL_RECVD); in tg3_periodic_fetch_stats()
10917 TG3_STAT_ADD32(&sp->rx_xoff_entered, MAC_RX_STATS_XOFF_ENTERED); in tg3_periodic_fetch_stats()
10918 TG3_STAT_ADD32(&sp->rx_frame_too_long_errors, MAC_RX_STATS_FRAME_TOO_LONG); in tg3_periodic_fetch_stats()
10919 TG3_STAT_ADD32(&sp->rx_jabbers, MAC_RX_STATS_JABBERS); in tg3_periodic_fetch_stats()
10920 TG3_STAT_ADD32(&sp->rx_undersize_packets, MAC_RX_STATS_UNDERSIZE); in tg3_periodic_fetch_stats()
10922 TG3_STAT_ADD32(&sp->rxbds_empty, RCVLPC_NO_RCV_BD_CNT); in tg3_periodic_fetch_stats()
10927 TG3_STAT_ADD32(&sp->rx_discards, RCVLPC_IN_DISCARDS_CNT); in tg3_periodic_fetch_stats()
10933 sp->rx_discards.low += val; in tg3_periodic_fetch_stats()
10934 if (sp->rx_discards.low < val) in tg3_periodic_fetch_stats()
10935 sp->rx_discards.high += 1; in tg3_periodic_fetch_stats()
10937 sp->mbuf_lwm_thresh_hit = sp->rx_discards; in tg3_periodic_fetch_stats()
10939 TG3_STAT_ADD32(&sp->rx_errors, RCVLPC_IN_ERRORS_CNT); in tg3_periodic_fetch_stats()
10946 for (i = 0; i < tp->irq_cnt; i++) { in tg3_chk_missed_msi()
10947 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_chk_missed_msi()
10950 if (tnapi->last_rx_cons == tnapi->rx_rcb_ptr && in tg3_chk_missed_msi()
10951 tnapi->last_tx_cons == tnapi->tx_cons) { in tg3_chk_missed_msi()
10952 if (tnapi->chk_msi_cnt < 1) { in tg3_chk_missed_msi()
10953 tnapi->chk_msi_cnt++; in tg3_chk_missed_msi()
10959 tnapi->chk_msi_cnt = 0; in tg3_chk_missed_msi()
10960 tnapi->last_rx_cons = tnapi->rx_rcb_ptr; in tg3_chk_missed_msi()
10961 tnapi->last_tx_cons = tnapi->tx_cons; in tg3_chk_missed_msi()
10969 spin_lock(&tp->lock); in tg3_timer()
10971 if (tp->irq_sync || tg3_flag(tp, RESET_TASK_PENDING)) { in tg3_timer()
10972 spin_unlock(&tp->lock); in tg3_timer()
10986 /* All of this garbage is because when using non-tagged in tg3_timer()
10990 if (tp->napi[0].hw_status->status & SD_STATUS_UPDATED) { in tg3_timer()
10992 tp->grc_local_ctrl | GRC_LCLCTRL_SETINT); in tg3_timer()
10994 tw32(HOSTCC_MODE, tp->coalesce_mode | in tg3_timer()
10999 spin_unlock(&tp->lock); in tg3_timer()
11006 if (!--tp->timer_counter) { in tg3_timer()
11010 if (tp->setlpicnt && !--tp->setlpicnt) in tg3_timer()
11020 if (tp->phy_flags & TG3_PHYFLG_USE_MI_INTERRUPT) { in tg3_timer()
11032 if (tp->link_up && in tg3_timer()
11036 if (!tp->link_up && in tg3_timer()
11042 if (!tp->serdes_counter) { in tg3_timer()
11044 (tp->mac_mode & in tg3_timer()
11047 tw32_f(MAC_MODE, tp->mac_mode); in tg3_timer()
11052 } else if ((tp->phy_flags & TG3_PHYFLG_MII_SERDES) && in tg3_timer()
11060 if (link_up != tp->link_up) in tg3_timer()
11064 tp->timer_counter = tp->timer_multiplier; in tg3_timer()
11084 if (!--tp->asf_counter) { in tg3_timer()
11096 tp->asf_counter = tp->asf_multiplier; in tg3_timer()
11102 spin_unlock(&tp->lock); in tg3_timer()
11105 tp->timer.expires = jiffies + tp->timer_offset; in tg3_timer()
11106 add_timer(&tp->timer); in tg3_timer()
11114 tp->timer_offset = HZ; in tg3_timer_init()
11116 tp->timer_offset = HZ / 10; in tg3_timer_init()
11118 BUG_ON(tp->timer_offset > HZ); in tg3_timer_init()
11120 tp->timer_multiplier = (HZ / tp->timer_offset); in tg3_timer_init()
11121 tp->asf_multiplier = (HZ / tp->timer_offset) * in tg3_timer_init()
11124 timer_setup(&tp->timer, tg3_timer, 0); in tg3_timer_init()
11129 tp->asf_counter = tp->asf_multiplier; in tg3_timer_start()
11130 tp->timer_counter = tp->timer_multiplier; in tg3_timer_start()
11132 tp->timer.expires = jiffies + tp->timer_offset; in tg3_timer_start()
11133 add_timer(&tp->timer); in tg3_timer_start()
11138 del_timer_sync(&tp->timer); in tg3_timer_stop()
11141 /* Restart hardware after configuration changes, self-test, etc.
11142 * Invoked with tp->lock held.
11145 __releases(tp->lock) in tg3_restart_hw()
11146 __acquires(tp->lock) in tg3_restart_hw()
11152 netdev_err(tp->dev, in tg3_restart_hw()
11153 "Failed to re-initialize device, aborting\n"); in tg3_restart_hw()
11157 tp->irq_sync = 0; in tg3_restart_hw()
11159 dev_close(tp->dev); in tg3_restart_hw()
11173 if (tp->pcierr_recovery || !netif_running(tp->dev)) { in tg3_reset_task()
11189 tp->write32_tx_mbox = tg3_write32_tx_mbox; in tg3_reset_task()
11190 tp->write32_rx_mbox = tg3_write_flush_reg32; in tg3_reset_task()
11199 tp->irq_sync = 0; in tg3_reset_task()
11205 dev_close(tp->dev); in tg3_reset_task()
11222 struct tg3_napi *tnapi = &tp->napi[irq_num]; in tg3_request_irq()
11224 if (tp->irq_cnt == 1) in tg3_request_irq()
11225 name = tp->dev->name; in tg3_request_irq()
11227 name = &tnapi->irq_lbl[0]; in tg3_request_irq()
11228 if (tnapi->tx_buffers && tnapi->rx_rcb) in tg3_request_irq()
11230 "%s-txrx-%d", tp->dev->name, irq_num); in tg3_request_irq()
11231 else if (tnapi->tx_buffers) in tg3_request_irq()
11233 "%s-tx-%d", tp->dev->name, irq_num); in tg3_request_irq()
11234 else if (tnapi->rx_rcb) in tg3_request_irq()
11236 "%s-rx-%d", tp->dev->name, irq_num); in tg3_request_irq()
11239 "%s-%d", tp->dev->name, irq_num); in tg3_request_irq()
11240 name[IFNAMSIZ-1] = 0; in tg3_request_irq()
11255 return request_irq(tnapi->irq_vec, fn, flags, name, tnapi); in tg3_request_irq()
11260 struct tg3_napi *tnapi = &tp->napi[0]; in tg3_test_interrupt()
11261 struct net_device *dev = tp->dev; in tg3_test_interrupt()
11266 return -ENODEV; in tg3_test_interrupt()
11270 free_irq(tnapi->irq_vec, tnapi); in tg3_test_interrupt()
11281 err = request_irq(tnapi->irq_vec, tg3_test_isr, in tg3_test_interrupt()
11282 IRQF_SHARED, dev->name, tnapi); in tg3_test_interrupt()
11286 tnapi->hw_status->status &= ~SD_STATUS_UPDATED; in tg3_test_interrupt()
11289 tw32_f(HOSTCC_MODE, tp->coalesce_mode | HOSTCC_MODE_ENABLE | in tg3_test_interrupt()
11290 tnapi->coal_now); in tg3_test_interrupt()
11295 int_mbox = tr32_mailbox(tnapi->int_mbox); in tg3_test_interrupt()
11305 tnapi->hw_status->status_tag != tnapi->last_tag) in tg3_test_interrupt()
11306 tw32_mailbox_f(tnapi->int_mbox, tnapi->last_tag << 24); in tg3_test_interrupt()
11313 free_irq(tnapi->irq_vec, tnapi); in tg3_test_interrupt()
11329 return -EIO; in tg3_test_interrupt()
11346 pci_read_config_word(tp->pdev, PCI_COMMAND, &pci_cmd); in tg3_test_msi()
11347 pci_write_config_word(tp->pdev, PCI_COMMAND, in tg3_test_msi()
11352 pci_write_config_word(tp->pdev, PCI_COMMAND, pci_cmd); in tg3_test_msi()
11358 if (err != -EIO) in tg3_test_msi()
11362 netdev_warn(tp->dev, "No interrupt was generated using MSI. Switching " in tg3_test_msi()
11366 free_irq(tp->napi[0].irq_vec, &tp->napi[0]); in tg3_test_msi()
11368 pci_disable_msi(tp->pdev); in tg3_test_msi()
11371 tp->napi[0].irq_vec = tp->pdev->irq; in tg3_test_msi()
11388 free_irq(tp->napi[0].irq_vec, &tp->napi[0]); in tg3_test_msi()
11397 if (request_firmware(&tp->fw, tp->fw_needed, &tp->pdev->dev)) { in tg3_request_firmware()
11398 netdev_err(tp->dev, "Failed to load firmware \"%s\"\n", in tg3_request_firmware()
11399 tp->fw_needed); in tg3_request_firmware()
11400 return -ENOENT; in tg3_request_firmware()
11403 fw_hdr = (struct tg3_firmware_hdr *)tp->fw->data; in tg3_request_firmware()
11410 tp->fw_len = be32_to_cpu(fw_hdr->len); /* includes bss */ in tg3_request_firmware()
11411 if (tp->fw_len < (tp->fw->size - TG3_FW_HDR_LEN)) { in tg3_request_firmware()
11412 netdev_err(tp->dev, "bogus length %d in \"%s\"\n", in tg3_request_firmware()
11413 tp->fw_len, tp->fw_needed); in tg3_request_firmware()
11414 release_firmware(tp->fw); in tg3_request_firmware()
11415 tp->fw = NULL; in tg3_request_firmware()
11416 return -EINVAL; in tg3_request_firmware()
11420 tp->fw_needed = NULL; in tg3_request_firmware()
11426 u32 irq_cnt = max(tp->rxq_cnt, tp->txq_cnt); in tg3_irq_count()
11430 * In multiqueue MSI-X mode, the first MSI-X vector in tg3_irq_count()
11434 irq_cnt = min_t(unsigned, irq_cnt + 1, tp->irq_max); in tg3_irq_count()
11445 tp->txq_cnt = tp->txq_req; in tg3_enable_msix()
11446 tp->rxq_cnt = tp->rxq_req; in tg3_enable_msix()
11447 if (!tp->rxq_cnt) in tg3_enable_msix()
11448 tp->rxq_cnt = netif_get_num_default_rss_queues(); in tg3_enable_msix()
11449 if (tp->rxq_cnt > tp->rxq_max) in tg3_enable_msix()
11450 tp->rxq_cnt = tp->rxq_max; in tg3_enable_msix()
11452 /* Disable multiple TX rings by default. Simple round-robin hardware in tg3_enable_msix()
11456 if (!tp->txq_req) in tg3_enable_msix()
11457 tp->txq_cnt = 1; in tg3_enable_msix()
11459 tp->irq_cnt = tg3_irq_count(tp); in tg3_enable_msix()
11461 for (i = 0; i < tp->irq_max; i++) { in tg3_enable_msix()
11466 rc = pci_enable_msix_range(tp->pdev, msix_ent, 1, tp->irq_cnt); in tg3_enable_msix()
11469 } else if (rc < tp->irq_cnt) { in tg3_enable_msix()
11470 netdev_notice(tp->dev, "Requested %d MSI-X vectors, received %d\n", in tg3_enable_msix()
11471 tp->irq_cnt, rc); in tg3_enable_msix()
11472 tp->irq_cnt = rc; in tg3_enable_msix()
11473 tp->rxq_cnt = max(rc - 1, 1); in tg3_enable_msix()
11474 if (tp->txq_cnt) in tg3_enable_msix()
11475 tp->txq_cnt = min(tp->rxq_cnt, tp->txq_max); in tg3_enable_msix()
11478 for (i = 0; i < tp->irq_max; i++) in tg3_enable_msix()
11479 tp->napi[i].irq_vec = msix_ent[i].vector; in tg3_enable_msix()
11481 if (netif_set_real_num_rx_queues(tp->dev, tp->rxq_cnt)) { in tg3_enable_msix()
11482 pci_disable_msix(tp->pdev); in tg3_enable_msix()
11486 if (tp->irq_cnt == 1) in tg3_enable_msix()
11491 if (tp->txq_cnt > 1) in tg3_enable_msix()
11494 netif_set_real_num_tx_queues(tp->dev, tp->txq_cnt); in tg3_enable_msix()
11506 netdev_warn(tp->dev, in tg3_ints_init()
11513 else if (tg3_flag(tp, SUPPORT_MSI) && pci_enable_msi(tp->pdev) == 0) in tg3_ints_init()
11518 if (tg3_flag(tp, USING_MSIX) && tp->irq_cnt > 1) in tg3_ints_init()
11526 tp->irq_cnt = 1; in tg3_ints_init()
11527 tp->napi[0].irq_vec = tp->pdev->irq; in tg3_ints_init()
11530 if (tp->irq_cnt == 1) { in tg3_ints_init()
11531 tp->txq_cnt = 1; in tg3_ints_init()
11532 tp->rxq_cnt = 1; in tg3_ints_init()
11533 netif_set_real_num_tx_queues(tp->dev, 1); in tg3_ints_init()
11534 netif_set_real_num_rx_queues(tp->dev, 1); in tg3_ints_init()
11541 pci_disable_msix(tp->pdev); in tg3_ints_fini()
11543 pci_disable_msi(tp->pdev); in tg3_ints_fini()
11553 struct net_device *dev = tp->dev; in tg3_start()
11575 for (i = 0; i < tp->irq_cnt; i++) { in tg3_start()
11578 for (i--; i >= 0; i--) { in tg3_start()
11579 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_start()
11581 free_irq(tnapi->irq_vec, tnapi); in tg3_start()
11640 * Reset loopback feature if it was turned on while the device was down in tg3_start()
11643 if (dev->features & NETIF_F_LOOPBACK) in tg3_start()
11644 tg3_set_loopback(dev, dev->features); in tg3_start()
11649 for (i = tp->irq_cnt - 1; i >= 0; i--) { in tg3_start()
11650 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_start()
11651 free_irq(tnapi->irq_vec, tnapi); in tg3_start()
11688 for (i = tp->irq_cnt - 1; i >= 0; i--) { in tg3_stop()
11689 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_stop()
11690 free_irq(tnapi->irq_vec, tnapi); in tg3_stop()
11705 if (tp->pcierr_recovery) { in tg3_open()
11708 return -EAGAIN; in tg3_open()
11711 if (tp->fw_needed) { in tg3_open()
11715 netdev_warn(tp->dev, "EEE capability disabled\n"); in tg3_open()
11716 tp->phy_flags &= ~TG3_PHYFLG_EEE_CAP; in tg3_open()
11717 } else if (!(tp->phy_flags & TG3_PHYFLG_EEE_CAP)) { in tg3_open()
11718 netdev_warn(tp->dev, "EEE capability restored\n"); in tg3_open()
11719 tp->phy_flags |= TG3_PHYFLG_EEE_CAP; in tg3_open()
11725 netdev_warn(tp->dev, "TSO capability disabled\n"); in tg3_open()
11728 netdev_notice(tp->dev, "TSO capability restored\n"); in tg3_open()
11747 !(tp->phy_flags & TG3_PHYFLG_KEEP_LINK_ON_PWRDN), in tg3_open()
11751 pci_set_power_state(tp->pdev, PCI_D3hot); in tg3_open()
11761 if (tp->pcierr_recovery) { in tg3_close()
11764 return -EAGAIN; in tg3_close()
11769 if (pci_device_is_present(tp->pdev)) { in tg3_close()
11779 return ((u64)val->high << 32) | ((u64)val->low); in get_stat64()
11784 struct tg3_hw_stats *hw_stats = tp->hw_stats; in tg3_calc_crc_errors()
11786 if (!(tp->phy_flags & TG3_PHYFLG_PHY_SERDES) && in tg3_calc_crc_errors()
11798 tp->phy_crc_errors += val; in tg3_calc_crc_errors()
11800 return tp->phy_crc_errors; in tg3_calc_crc_errors()
11803 return get_stat64(&hw_stats->rx_fcs_errors); in tg3_calc_crc_errors()
11807 estats->member = old_estats->member + \
11808 get_stat64(&hw_stats->member)
11812 struct tg3_ethtool_stats *old_estats = &tp->estats_prev; in tg3_get_estats()
11813 struct tg3_hw_stats *hw_stats = tp->hw_stats; in tg3_get_estats()
11896 struct rtnl_link_stats64 *old_stats = &tp->net_stats_prev; in tg3_get_nstats()
11897 struct tg3_hw_stats *hw_stats = tp->hw_stats; in tg3_get_nstats()
11899 stats->rx_packets = old_stats->rx_packets + in tg3_get_nstats()
11900 get_stat64(&hw_stats->rx_ucast_packets) + in tg3_get_nstats()
11901 get_stat64(&hw_stats->rx_mcast_packets) + in tg3_get_nstats()
11902 get_stat64(&hw_stats->rx_bcast_packets); in tg3_get_nstats()
11904 stats->tx_packets = old_stats->tx_packets + in tg3_get_nstats()
11905 get_stat64(&hw_stats->tx_ucast_packets) + in tg3_get_nstats()
11906 get_stat64(&hw_stats->tx_mcast_packets) + in tg3_get_nstats()
11907 get_stat64(&hw_stats->tx_bcast_packets); in tg3_get_nstats()
11909 stats->rx_bytes = old_stats->rx_bytes + in tg3_get_nstats()
11910 get_stat64(&hw_stats->rx_octets); in tg3_get_nstats()
11911 stats->tx_bytes = old_stats->tx_bytes + in tg3_get_nstats()
11912 get_stat64(&hw_stats->tx_octets); in tg3_get_nstats()
11914 stats->rx_errors = old_stats->rx_errors + in tg3_get_nstats()
11915 get_stat64(&hw_stats->rx_errors); in tg3_get_nstats()
11916 stats->tx_errors = old_stats->tx_errors + in tg3_get_nstats()
11917 get_stat64(&hw_stats->tx_errors) + in tg3_get_nstats()
11918 get_stat64(&hw_stats->tx_mac_errors) + in tg3_get_nstats()
11919 get_stat64(&hw_stats->tx_carrier_sense_errors) + in tg3_get_nstats()
11920 get_stat64(&hw_stats->tx_discards); in tg3_get_nstats()
11922 stats->multicast = old_stats->multicast + in tg3_get_nstats()
11923 get_stat64(&hw_stats->rx_mcast_packets); in tg3_get_nstats()
11924 stats->collisions = old_stats->collisions + in tg3_get_nstats()
11925 get_stat64(&hw_stats->tx_collisions); in tg3_get_nstats()
11927 stats->rx_length_errors = old_stats->rx_length_errors + in tg3_get_nstats()
11928 get_stat64(&hw_stats->rx_frame_too_long_errors) + in tg3_get_nstats()
11929 get_stat64(&hw_stats->rx_undersize_packets); in tg3_get_nstats()
11931 stats->rx_frame_errors = old_stats->rx_frame_errors + in tg3_get_nstats()
11932 get_stat64(&hw_stats->rx_align_errors); in tg3_get_nstats()
11933 stats->tx_aborted_errors = old_stats->tx_aborted_errors + in tg3_get_nstats()
11934 get_stat64(&hw_stats->tx_discards); in tg3_get_nstats()
11935 stats->tx_carrier_errors = old_stats->tx_carrier_errors + in tg3_get_nstats()
11936 get_stat64(&hw_stats->tx_carrier_sense_errors); in tg3_get_nstats()
11938 stats->rx_crc_errors = old_stats->rx_crc_errors + in tg3_get_nstats()
11941 stats->rx_missed_errors = old_stats->rx_missed_errors + in tg3_get_nstats()
11942 get_stat64(&hw_stats->rx_discards); in tg3_get_nstats()
11944 stats->rx_dropped = tp->rx_dropped; in tg3_get_nstats()
11945 stats->tx_dropped = tp->tx_dropped; in tg3_get_nstats()
11958 regs->version = 0; in tg3_get_regs()
11962 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) in tg3_get_regs()
11976 return tp->nvram_size; in tg3_get_eeprom_len()
11988 return -EINVAL; in tg3_get_eeprom()
11990 offset = eeprom->offset; in tg3_get_eeprom()
11991 len = eeprom->len; in tg3_get_eeprom()
11992 eeprom->len = 0; in tg3_get_eeprom()
11994 eeprom->magic = TG3_EEPROM_MAGIC; in tg3_get_eeprom()
12012 b_count = 4 - b_offset; in tg3_get_eeprom()
12017 ret = tg3_nvram_read_be32(tp, offset-b_offset, &val); in tg3_get_eeprom()
12021 len -= b_count; in tg3_get_eeprom()
12023 eeprom->len += b_count; in tg3_get_eeprom()
12027 pd = &data[eeprom->len]; in tg3_get_eeprom()
12028 for (i = 0; i < (len - (len & 3)); i += 4) { in tg3_get_eeprom()
12032 i -= 4; in tg3_get_eeprom()
12033 eeprom->len += i; in tg3_get_eeprom()
12039 eeprom->len += i; in tg3_get_eeprom()
12040 ret = -EINTR; in tg3_get_eeprom()
12046 eeprom->len += i; in tg3_get_eeprom()
12050 pd = &data[eeprom->len]; in tg3_get_eeprom()
12052 b_offset = offset + len - b_count; in tg3_get_eeprom()
12057 eeprom->len += b_count; in tg3_get_eeprom()
12079 eeprom->magic != TG3_EEPROM_MAGIC) in tg3_set_eeprom()
12080 return -EINVAL; in tg3_set_eeprom()
12082 offset = eeprom->offset; in tg3_set_eeprom()
12083 len = eeprom->len; in tg3_set_eeprom()
12087 ret = tg3_nvram_read_be32(tp, offset-b_offset, &start); in tg3_set_eeprom()
12101 ret = tg3_nvram_read_be32(tp, offset+len-4, &end); in tg3_set_eeprom()
12110 return -ENOMEM; in tg3_set_eeprom()
12114 memcpy(buf+len-4, &end, 4); in tg3_set_eeprom()
12115 memcpy(buf + b_offset, data, eeprom->len); in tg3_set_eeprom()
12134 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) in tg3_get_link_ksettings()
12135 return -EAGAIN; in tg3_get_link_ksettings()
12136 phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); in tg3_get_link_ksettings()
12144 if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) in tg3_get_link_ksettings()
12148 if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES)) { in tg3_get_link_ksettings()
12154 cmd->base.port = PORT_TP; in tg3_get_link_ksettings()
12157 cmd->base.port = PORT_FIBRE; in tg3_get_link_ksettings()
12159 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, in tg3_get_link_ksettings()
12162 advertising = tp->link_config.advertising; in tg3_get_link_ksettings()
12164 if (tp->link_config.flowctrl & FLOW_CTRL_RX) { in tg3_get_link_ksettings()
12165 if (tp->link_config.flowctrl & FLOW_CTRL_TX) { in tg3_get_link_ksettings()
12171 } else if (tp->link_config.flowctrl & FLOW_CTRL_TX) { in tg3_get_link_ksettings()
12175 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising, in tg3_get_link_ksettings()
12178 if (netif_running(dev) && tp->link_up) { in tg3_get_link_ksettings()
12179 cmd->base.speed = tp->link_config.active_speed; in tg3_get_link_ksettings()
12180 cmd->base.duplex = tp->link_config.active_duplex; in tg3_get_link_ksettings()
12182 cmd->link_modes.lp_advertising, in tg3_get_link_ksettings()
12183 tp->link_config.rmt_adv); in tg3_get_link_ksettings()
12185 if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES)) { in tg3_get_link_ksettings()
12186 if (tp->phy_flags & TG3_PHYFLG_MDIX_STATE) in tg3_get_link_ksettings()
12187 cmd->base.eth_tp_mdix = ETH_TP_MDI_X; in tg3_get_link_ksettings()
12189 cmd->base.eth_tp_mdix = ETH_TP_MDI; in tg3_get_link_ksettings()
12192 cmd->base.speed = SPEED_UNKNOWN; in tg3_get_link_ksettings()
12193 cmd->base.duplex = DUPLEX_UNKNOWN; in tg3_get_link_ksettings()
12194 cmd->base.eth_tp_mdix = ETH_TP_MDI_INVALID; in tg3_get_link_ksettings()
12196 cmd->base.phy_address = tp->phy_addr; in tg3_get_link_ksettings()
12197 cmd->base.autoneg = tp->link_config.autoneg; in tg3_get_link_ksettings()
12205 u32 speed = cmd->base.speed; in tg3_set_link_ksettings()
12210 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) in tg3_set_link_ksettings()
12211 return -EAGAIN; in tg3_set_link_ksettings()
12212 phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); in tg3_set_link_ksettings()
12216 if (cmd->base.autoneg != AUTONEG_ENABLE && in tg3_set_link_ksettings()
12217 cmd->base.autoneg != AUTONEG_DISABLE) in tg3_set_link_ksettings()
12218 return -EINVAL; in tg3_set_link_ksettings()
12220 if (cmd->base.autoneg == AUTONEG_DISABLE && in tg3_set_link_ksettings()
12221 cmd->base.duplex != DUPLEX_FULL && in tg3_set_link_ksettings()
12222 cmd->base.duplex != DUPLEX_HALF) in tg3_set_link_ksettings()
12223 return -EINVAL; in tg3_set_link_ksettings()
12226 cmd->link_modes.advertising); in tg3_set_link_ksettings()
12228 if (cmd->base.autoneg == AUTONEG_ENABLE) { in tg3_set_link_ksettings()
12233 if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) in tg3_set_link_ksettings()
12237 if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES)) in tg3_set_link_ksettings()
12247 return -EINVAL; in tg3_set_link_ksettings()
12258 if (tp->phy_flags & TG3_PHYFLG_ANY_SERDES) { in tg3_set_link_ksettings()
12260 return -EINVAL; in tg3_set_link_ksettings()
12262 if (cmd->base.duplex != DUPLEX_FULL) in tg3_set_link_ksettings()
12263 return -EINVAL; in tg3_set_link_ksettings()
12267 return -EINVAL; in tg3_set_link_ksettings()
12273 tp->link_config.autoneg = cmd->base.autoneg; in tg3_set_link_ksettings()
12274 if (cmd->base.autoneg == AUTONEG_ENABLE) { in tg3_set_link_ksettings()
12275 tp->link_config.advertising = (advertising | in tg3_set_link_ksettings()
12277 tp->link_config.speed = SPEED_UNKNOWN; in tg3_set_link_ksettings()
12278 tp->link_config.duplex = DUPLEX_UNKNOWN; in tg3_set_link_ksettings()
12280 tp->link_config.advertising = 0; in tg3_set_link_ksettings()
12281 tp->link_config.speed = speed; in tg3_set_link_ksettings()
12282 tp->link_config.duplex = cmd->base.duplex; in tg3_set_link_ksettings()
12285 tp->phy_flags |= TG3_PHYFLG_USER_CONFIGURED; in tg3_set_link_ksettings()
12301 strscpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); in tg3_get_drvinfo()
12302 strscpy(info->fw_version, tp->fw_ver, sizeof(info->fw_version)); in tg3_get_drvinfo()
12303 strscpy(info->bus_info, pci_name(tp->pdev), sizeof(info->bus_info)); in tg3_get_drvinfo()
12310 if (tg3_flag(tp, WOL_CAP) && device_can_wakeup(&tp->pdev->dev)) in tg3_get_wol()
12311 wol->supported = WAKE_MAGIC; in tg3_get_wol()
12313 wol->supported = 0; in tg3_get_wol()
12314 wol->wolopts = 0; in tg3_get_wol()
12315 if (tg3_flag(tp, WOL_ENABLE) && device_can_wakeup(&tp->pdev->dev)) in tg3_get_wol()
12316 wol->wolopts = WAKE_MAGIC; in tg3_get_wol()
12317 memset(&wol->sopass, 0, sizeof(wol->sopass)); in tg3_get_wol()
12323 struct device *dp = &tp->pdev->dev; in tg3_set_wol()
12325 if (wol->wolopts & ~WAKE_MAGIC) in tg3_set_wol()
12326 return -EINVAL; in tg3_set_wol()
12327 if ((wol->wolopts & WAKE_MAGIC) && in tg3_set_wol()
12329 return -EINVAL; in tg3_set_wol()
12331 device_set_wakeup_enable(dp, wol->wolopts & WAKE_MAGIC); in tg3_set_wol()
12344 return tp->msg_enable; in tg3_get_msglevel()
12350 tp->msg_enable = value; in tg3_set_msglevel()
12359 return -EAGAIN; in tg3_nway_reset()
12361 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) in tg3_nway_reset()
12362 return -EINVAL; in tg3_nway_reset()
12367 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) in tg3_nway_reset()
12368 return -EAGAIN; in tg3_nway_reset()
12369 r = phy_start_aneg(mdiobus_get_phy(tp->mdio_bus, tp->phy_addr)); in tg3_nway_reset()
12373 spin_lock_bh(&tp->lock); in tg3_nway_reset()
12374 r = -EINVAL; in tg3_nway_reset()
12378 (tp->phy_flags & TG3_PHYFLG_PARALLEL_DETECT))) { in tg3_nway_reset()
12383 spin_unlock_bh(&tp->lock); in tg3_nway_reset()
12396 ering->rx_max_pending = tp->rx_std_ring_mask; in tg3_get_ringparam()
12398 ering->rx_jumbo_max_pending = tp->rx_jmb_ring_mask; in tg3_get_ringparam()
12400 ering->rx_jumbo_max_pending = 0; in tg3_get_ringparam()
12402 ering->tx_max_pending = TG3_TX_RING_SIZE - 1; in tg3_get_ringparam()
12404 ering->rx_pending = tp->rx_pending; in tg3_get_ringparam()
12406 ering->rx_jumbo_pending = tp->rx_jumbo_pending; in tg3_get_ringparam()
12408 ering->rx_jumbo_pending = 0; in tg3_get_ringparam()
12410 ering->tx_pending = tp->napi[0].tx_pending; in tg3_get_ringparam()
12422 if ((ering->rx_pending > tp->rx_std_ring_mask) || in tg3_set_ringparam()
12423 (ering->rx_jumbo_pending > tp->rx_jmb_ring_mask) || in tg3_set_ringparam()
12424 (ering->tx_pending > TG3_TX_RING_SIZE - 1) || in tg3_set_ringparam()
12425 (ering->tx_pending <= MAX_SKB_FRAGS) || in tg3_set_ringparam()
12427 (ering->tx_pending <= (MAX_SKB_FRAGS * 3)))) in tg3_set_ringparam()
12428 return -EINVAL; in tg3_set_ringparam()
12438 tp->rx_pending = ering->rx_pending; in tg3_set_ringparam()
12441 tp->rx_pending > 63) in tg3_set_ringparam()
12442 tp->rx_pending = 63; in tg3_set_ringparam()
12445 tp->rx_jumbo_pending = ering->rx_jumbo_pending; in tg3_set_ringparam()
12447 for (i = 0; i < tp->irq_max; i++) in tg3_set_ringparam()
12448 tp->napi[i].tx_pending = ering->tx_pending; in tg3_set_ringparam()
12475 epause->autoneg = !!tg3_flag(tp, PAUSE_AUTONEG); in tg3_get_pauseparam()
12477 if (tp->link_config.flowctrl & FLOW_CTRL_RX) in tg3_get_pauseparam()
12478 epause->rx_pause = 1; in tg3_get_pauseparam()
12480 epause->rx_pause = 0; in tg3_get_pauseparam()
12482 if (tp->link_config.flowctrl & FLOW_CTRL_TX) in tg3_get_pauseparam()
12483 epause->tx_pause = 1; in tg3_get_pauseparam()
12485 epause->tx_pause = 0; in tg3_get_pauseparam()
12494 if (tp->link_config.autoneg == AUTONEG_ENABLE) in tg3_set_pauseparam()
12500 phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); in tg3_set_pauseparam()
12503 return -EINVAL; in tg3_set_pauseparam()
12505 tp->link_config.flowctrl = 0; in tg3_set_pauseparam()
12506 phy_set_asym_pause(phydev, epause->rx_pause, epause->tx_pause); in tg3_set_pauseparam()
12507 if (epause->rx_pause) { in tg3_set_pauseparam()
12508 tp->link_config.flowctrl |= FLOW_CTRL_RX; in tg3_set_pauseparam()
12510 if (epause->tx_pause) { in tg3_set_pauseparam()
12511 tp->link_config.flowctrl |= FLOW_CTRL_TX; in tg3_set_pauseparam()
12513 } else if (epause->tx_pause) { in tg3_set_pauseparam()
12514 tp->link_config.flowctrl |= FLOW_CTRL_TX; in tg3_set_pauseparam()
12517 if (epause->autoneg) in tg3_set_pauseparam()
12522 if (tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) { in tg3_set_pauseparam()
12523 if (phydev->autoneg) { in tg3_set_pauseparam()
12534 if (!epause->autoneg) in tg3_set_pauseparam()
12547 if (epause->autoneg) in tg3_set_pauseparam()
12551 if (epause->rx_pause) in tg3_set_pauseparam()
12552 tp->link_config.flowctrl |= FLOW_CTRL_RX; in tg3_set_pauseparam()
12554 tp->link_config.flowctrl &= ~FLOW_CTRL_RX; in tg3_set_pauseparam()
12555 if (epause->tx_pause) in tg3_set_pauseparam()
12556 tp->link_config.flowctrl |= FLOW_CTRL_TX; in tg3_set_pauseparam()
12558 tp->link_config.flowctrl &= ~FLOW_CTRL_TX; in tg3_set_pauseparam()
12576 tp->phy_flags |= TG3_PHYFLG_USER_CONFIGURED; in tg3_set_pauseparam()
12589 return -EOPNOTSUPP; in tg3_get_sset_count()
12599 return -EOPNOTSUPP; in tg3_get_rxnfc()
12601 switch (info->cmd) { in tg3_get_rxnfc()
12603 if (netif_running(tp->dev)) in tg3_get_rxnfc()
12604 info->data = tp->rxq_cnt; in tg3_get_rxnfc()
12606 info->data = num_online_cpus(); in tg3_get_rxnfc()
12607 if (info->data > TG3_RSS_MAX_NUM_QS) in tg3_get_rxnfc()
12608 info->data = TG3_RSS_MAX_NUM_QS; in tg3_get_rxnfc()
12614 return -EOPNOTSUPP; in tg3_get_rxnfc()
12640 indir[i] = tp->rss_ind_tbl[i]; in tg3_get_rxfh()
12656 return -EOPNOTSUPP; in tg3_set_rxfh()
12662 tp->rss_ind_tbl[i] = indir[i]; in tg3_set_rxfh()
12683 channel->max_rx = tp->rxq_max; in tg3_get_channels()
12684 channel->max_tx = tp->txq_max; in tg3_get_channels()
12687 channel->rx_count = tp->rxq_cnt; in tg3_get_channels()
12688 channel->tx_count = tp->txq_cnt; in tg3_get_channels()
12690 if (tp->rxq_req) in tg3_get_channels()
12691 channel->rx_count = tp->rxq_req; in tg3_get_channels()
12693 channel->rx_count = min(deflt_qs, tp->rxq_max); in tg3_get_channels()
12695 if (tp->txq_req) in tg3_get_channels()
12696 channel->tx_count = tp->txq_req; in tg3_get_channels()
12698 channel->tx_count = min(deflt_qs, tp->txq_max); in tg3_get_channels()
12708 return -EOPNOTSUPP; in tg3_set_channels()
12710 if (channel->rx_count > tp->rxq_max || in tg3_set_channels()
12711 channel->tx_count > tp->txq_max) in tg3_set_channels()
12712 return -EINVAL; in tg3_set_channels()
12714 tp->rxq_req = channel->rx_count; in tg3_set_channels()
12715 tp->txq_req = channel->tx_count; in tg3_set_channels()
12769 tw32(MAC_LED_CTRL, tp->led_ctrl); in tg3_set_phys_id()
12781 if (tp->hw_stats) in tg3_get_ethtool_stats()
12827 /* The data is in little-endian format in NVRAM. in tg3_vpd_readblock()
12828 * Use the big-endian read routines to preserve in tg3_vpd_readblock()
12836 buf = pci_vpd_alloc(tp->pdev, vpdlen); in tg3_vpd_readblock()
12869 return -EIO; in tg3_test_nvram()
12896 return -EIO; in tg3_test_nvram()
12903 return -EIO; in tg3_test_nvram()
12907 return -ENOMEM; in tg3_test_nvram()
12909 err = -EIO; in tg3_test_nvram()
12941 err = -EIO; in tg3_test_nvram()
12975 err = -EIO; in tg3_test_nvram()
12988 err = -EIO; in tg3_test_nvram()
13004 return -ENOMEM; in tg3_test_nvram()
13022 if (!netif_running(tp->dev)) in tg3_test_link()
13023 return -ENODEV; in tg3_test_link()
13025 if (tp->phy_flags & TG3_PHYFLG_ANY_SERDES) in tg3_test_link()
13031 if (tp->link_up) in tg3_test_link()
13038 return -EIO; in tg3_test_link()
13219 /* Determine the read-only value. */ in tg3_test_registers()
13222 /* Write zero to the register, then make sure the read-only bits in tg3_test_registers()
13229 /* Test the read-only and read/write bits. */ in tg3_test_registers()
13234 * make sure the read-only bits are not changed and the in tg3_test_registers()
13241 /* Test the read-only bits. */ in tg3_test_registers()
13256 netdev_err(tp->dev, in tg3_test_registers()
13259 return -EIO; in tg3_test_registers()
13275 return -EIO; in tg3_do_mem_test()
13385 struct tg3_rx_prodring_set *tpr = &tp->napi[0].prodring; in tg3_run_loopback()
13387 tnapi = &tp->napi[0]; in tg3_run_loopback()
13388 rnapi = &tp->napi[0]; in tg3_run_loopback()
13389 if (tp->irq_cnt > 1) { in tg3_run_loopback()
13391 rnapi = &tp->napi[1]; in tg3_run_loopback()
13393 tnapi = &tp->napi[1]; in tg3_run_loopback()
13395 coal_now = tnapi->coal_now | rnapi->coal_now; in tg3_run_loopback()
13397 err = -EIO; in tg3_run_loopback()
13400 skb = netdev_alloc_skb(tp->dev, tx_len); in tg3_run_loopback()
13402 return -ENOMEM; in tg3_run_loopback()
13405 memcpy(tx_data, tp->dev->dev_addr, ETH_ALEN); in tg3_run_loopback()
13420 val = tx_len - ETH_ALEN * 2 - sizeof(tg3_tso_header); in tg3_run_loopback()
13424 iph->tot_len = htons((u16)(mss + hdr_len)); in tg3_run_loopback()
13435 th->check = 0; in tg3_run_loopback()
13466 map = dma_map_single(&tp->pdev->dev, skb->data, tx_len, DMA_TO_DEVICE); in tg3_run_loopback()
13467 if (dma_mapping_error(&tp->pdev->dev, map)) { in tg3_run_loopback()
13469 return -EIO; in tg3_run_loopback()
13472 val = tnapi->tx_prod; in tg3_run_loopback()
13473 tnapi->tx_buffers[val].skb = skb; in tg3_run_loopback()
13474 dma_unmap_addr_set(&tnapi->tx_buffers[val], mapping, map); in tg3_run_loopback()
13476 tw32_f(HOSTCC_MODE, tp->coalesce_mode | HOSTCC_MODE_ENABLE | in tg3_run_loopback()
13477 rnapi->coal_now); in tg3_run_loopback()
13481 rx_start_idx = rnapi->hw_status->idx[0].rx_producer; in tg3_run_loopback()
13486 tnapi->tx_buffers[val].skb = NULL; in tg3_run_loopback()
13488 return -EIO; in tg3_run_loopback()
13491 tnapi->tx_prod++; in tg3_run_loopback()
13496 tw32_tx_mbox(tnapi->prodmbox, tnapi->tx_prod); in tg3_run_loopback()
13497 tr32_mailbox(tnapi->prodmbox); in tg3_run_loopback()
13503 tw32_f(HOSTCC_MODE, tp->coalesce_mode | HOSTCC_MODE_ENABLE | in tg3_run_loopback()
13508 tx_idx = tnapi->hw_status->idx[0].tx_consumer; in tg3_run_loopback()
13509 rx_idx = rnapi->hw_status->idx[0].rx_producer; in tg3_run_loopback()
13510 if ((tx_idx == tnapi->tx_prod) && in tg3_run_loopback()
13515 tg3_tx_skb_unmap(tnapi, tnapi->tx_prod - 1, -1); in tg3_run_loopback()
13518 if (tx_idx != tnapi->tx_prod) in tg3_run_loopback()
13526 desc = &rnapi->rx_rcb[rx_start_idx++]; in tg3_run_loopback()
13527 desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK; in tg3_run_loopback()
13528 opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK; in tg3_run_loopback()
13530 if ((desc->err_vlan & RXD_ERR_MASK) != 0 && in tg3_run_loopback()
13531 (desc->err_vlan != RXD_ERR_ODD_NIBBLE_RCVD_MII)) in tg3_run_loopback()
13534 rx_len = ((desc->idx_len & RXD_LEN_MASK) >> RXD_LEN_SHIFT) in tg3_run_loopback()
13535 - ETH_FCS_LEN; in tg3_run_loopback()
13541 if (pktsz <= TG3_RX_STD_DMA_SZ - ETH_FCS_LEN) { in tg3_run_loopback()
13548 } else if ((desc->type_flags & RXD_FLAG_TCPUDP_CSUM) && in tg3_run_loopback()
13549 (desc->ip_tcp_csum & RXD_TCPCSUM_MASK) in tg3_run_loopback()
13555 rx_data = tpr->rx_std_buffers[desc_idx].data; in tg3_run_loopback()
13556 map = dma_unmap_addr(&tpr->rx_std_buffers[desc_idx], in tg3_run_loopback()
13559 rx_data = tpr->rx_jmb_buffers[desc_idx].data; in tg3_run_loopback()
13560 map = dma_unmap_addr(&tpr->rx_jmb_buffers[desc_idx], in tg3_run_loopback()
13565 dma_sync_single_for_cpu(&tp->pdev->dev, map, rx_len, in tg3_run_loopback()
13592 int err = -EIO; in tg3_test_loopback()
13596 if (tp->dma_limit) in tg3_test_loopback()
13597 jmb_pkt_sz = tp->dma_limit - ETH_HLEN; in tg3_test_loopback()
13599 eee_cap = tp->phy_flags & TG3_PHYFLG_EEE_CAP; in tg3_test_loopback()
13600 tp->phy_flags &= ~TG3_PHYFLG_EEE_CAP; in tg3_test_loopback()
13602 if (!netif_running(tp->dev)) { in tg3_test_loopback()
13628 /* HW errata - mac loopback fails in some cases on 5780. in tg3_test_loopback()
13647 if (!(tp->phy_flags & TG3_PHYFLG_PHY_SERDES) && in tg3_test_loopback()
13691 /* Re-enable gphy autopowerdown. */ in tg3_test_loopback()
13692 if (tp->phy_flags & TG3_PHYFLG_ENABLE_APD) in tg3_test_loopback()
13697 data[TG3_EXT_LOOPB_TEST]) ? -EIO : 0; in tg3_test_loopback()
13700 tp->phy_flags |= eee_cap; in tg3_test_loopback()
13709 bool doextlpbk = etest->flags & ETH_TEST_FL_EXTERNAL_LB; in tg3_self_test()
13711 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) { in tg3_self_test()
13713 etest->flags |= ETH_TEST_FL_FAILED; in tg3_self_test()
13723 etest->flags |= ETH_TEST_FL_FAILED; in tg3_self_test()
13727 etest->flags |= ETH_TEST_FL_FAILED; in tg3_self_test()
13730 if (etest->flags & ETH_TEST_FL_OFFLINE) { in tg3_self_test()
13748 if (tp->phy_flags & TG3_PHYFLG_MII_SERDES) in tg3_self_test()
13752 etest->flags |= ETH_TEST_FL_FAILED; in tg3_self_test()
13757 etest->flags |= ETH_TEST_FL_FAILED; in tg3_self_test()
13762 etest->flags |= ETH_TEST_FL_EXTERNAL_LB_DONE; in tg3_self_test()
13765 etest->flags |= ETH_TEST_FL_FAILED; in tg3_self_test()
13770 etest->flags |= ETH_TEST_FL_FAILED; in tg3_self_test()
13789 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) in tg3_self_test()
13800 return -EOPNOTSUPP; in tg3_hwtstamp_set()
13802 if (copy_from_user(&stmpconf, ifr->ifr_data, sizeof(stmpconf))) in tg3_hwtstamp_set()
13803 return -EFAULT; in tg3_hwtstamp_set()
13807 return -ERANGE; in tg3_hwtstamp_set()
13811 tp->rxptpctl = 0; in tg3_hwtstamp_set()
13814 tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V1_EN | in tg3_hwtstamp_set()
13818 tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V1_EN | in tg3_hwtstamp_set()
13822 tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V1_EN | in tg3_hwtstamp_set()
13826 tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_EN | in tg3_hwtstamp_set()
13830 tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN | in tg3_hwtstamp_set()
13834 tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN | in tg3_hwtstamp_set()
13838 tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_EN | in tg3_hwtstamp_set()
13842 tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN | in tg3_hwtstamp_set()
13846 tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN | in tg3_hwtstamp_set()
13850 tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_EN | in tg3_hwtstamp_set()
13854 tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN | in tg3_hwtstamp_set()
13858 tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN | in tg3_hwtstamp_set()
13862 return -ERANGE; in tg3_hwtstamp_set()
13865 if (netif_running(dev) && tp->rxptpctl) in tg3_hwtstamp_set()
13867 tp->rxptpctl | TG3_RX_PTP_CTL_HWTS_INTERLOCK); in tg3_hwtstamp_set()
13874 return copy_to_user(ifr->ifr_data, &stmpconf, sizeof(stmpconf)) ? in tg3_hwtstamp_set()
13875 -EFAULT : 0; in tg3_hwtstamp_set()
13884 return -EOPNOTSUPP; in tg3_hwtstamp_get()
13890 switch (tp->rxptpctl) { in tg3_hwtstamp_get()
13932 return -ERANGE; in tg3_hwtstamp_get()
13935 return copy_to_user(ifr->ifr_data, &stmpconf, sizeof(stmpconf)) ? in tg3_hwtstamp_get()
13936 -EFAULT : 0; in tg3_hwtstamp_get()
13947 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) in tg3_ioctl()
13948 return -EAGAIN; in tg3_ioctl()
13949 phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); in tg3_ioctl()
13955 data->phy_id = tp->phy_addr; in tg3_ioctl()
13961 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) in tg3_ioctl()
13965 return -EAGAIN; in tg3_ioctl()
13967 spin_lock_bh(&tp->lock); in tg3_ioctl()
13968 err = __tg3_readphy(tp, data->phy_id & 0x1f, in tg3_ioctl()
13969 data->reg_num & 0x1f, &mii_regval); in tg3_ioctl()
13970 spin_unlock_bh(&tp->lock); in tg3_ioctl()
13972 data->val_out = mii_regval; in tg3_ioctl()
13978 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) in tg3_ioctl()
13982 return -EAGAIN; in tg3_ioctl()
13984 spin_lock_bh(&tp->lock); in tg3_ioctl()
13985 err = __tg3_writephy(tp, data->phy_id & 0x1f, in tg3_ioctl()
13986 data->reg_num & 0x1f, data->val_in); in tg3_ioctl()
13987 spin_unlock_bh(&tp->lock); in tg3_ioctl()
14001 return -EOPNOTSUPP; in tg3_ioctl()
14011 memcpy(ec, &tp->coal, sizeof(*ec)); in tg3_get_coalesce()
14031 if ((ec->rx_coalesce_usecs > MAX_RXCOL_TICKS) || in tg3_set_coalesce()
14032 (!ec->rx_coalesce_usecs) || in tg3_set_coalesce()
14033 (ec->tx_coalesce_usecs > MAX_TXCOL_TICKS) || in tg3_set_coalesce()
14034 (!ec->tx_coalesce_usecs) || in tg3_set_coalesce()
14035 (ec->rx_max_coalesced_frames > MAX_RXMAX_FRAMES) || in tg3_set_coalesce()
14036 (ec->tx_max_coalesced_frames > MAX_TXMAX_FRAMES) || in tg3_set_coalesce()
14037 (ec->rx_coalesce_usecs_irq > max_rxcoal_tick_int) || in tg3_set_coalesce()
14038 (ec->tx_coalesce_usecs_irq > max_txcoal_tick_int) || in tg3_set_coalesce()
14039 (ec->rx_max_coalesced_frames_irq > MAX_RXCOAL_MAXF_INT) || in tg3_set_coalesce()
14040 (ec->tx_max_coalesced_frames_irq > MAX_TXCOAL_MAXF_INT) || in tg3_set_coalesce()
14041 (ec->stats_block_coalesce_usecs > max_stat_coal_ticks) || in tg3_set_coalesce()
14042 (ec->stats_block_coalesce_usecs < min_stat_coal_ticks)) in tg3_set_coalesce()
14043 return -EINVAL; in tg3_set_coalesce()
14046 tp->coal.rx_coalesce_usecs = ec->rx_coalesce_usecs; in tg3_set_coalesce()
14047 tp->coal.tx_coalesce_usecs = ec->tx_coalesce_usecs; in tg3_set_coalesce()
14048 tp->coal.rx_max_coalesced_frames = ec->rx_max_coalesced_frames; in tg3_set_coalesce()
14049 tp->coal.tx_max_coalesced_frames = ec->tx_max_coalesced_frames; in tg3_set_coalesce()
14050 tp->coal.rx_coalesce_usecs_irq = ec->rx_coalesce_usecs_irq; in tg3_set_coalesce()
14051 tp->coal.tx_coalesce_usecs_irq = ec->tx_coalesce_usecs_irq; in tg3_set_coalesce()
14052 tp->coal.rx_max_coalesced_frames_irq = ec->rx_max_coalesced_frames_irq; in tg3_set_coalesce()
14053 tp->coal.tx_max_coalesced_frames_irq = ec->tx_max_coalesced_frames_irq; in tg3_set_coalesce()
14054 tp->coal.stats_block_coalesce_usecs = ec->stats_block_coalesce_usecs; in tg3_set_coalesce()
14058 __tg3_set_coalesce(tp, &tp->coal); in tg3_set_coalesce()
14068 if (!(tp->phy_flags & TG3_PHYFLG_EEE_CAP)) { in tg3_set_eee()
14069 netdev_warn(tp->dev, "Board does not support EEE!\n"); in tg3_set_eee()
14070 return -EOPNOTSUPP; in tg3_set_eee()
14073 if (edata->advertised != tp->eee.advertised) { in tg3_set_eee()
14074 netdev_warn(tp->dev, in tg3_set_eee()
14076 return -EINVAL; in tg3_set_eee()
14079 if (edata->tx_lpi_timer > TG3_CPMU_DBTMR1_LNKIDLE_MAX) { in tg3_set_eee()
14080 netdev_warn(tp->dev, in tg3_set_eee()
14083 return -EINVAL; in tg3_set_eee()
14086 tp->eee = *edata; in tg3_set_eee()
14088 tp->phy_flags |= TG3_PHYFLG_USER_CONFIGURED; in tg3_set_eee()
14091 if (netif_running(tp->dev)) { in tg3_set_eee()
14105 if (!(tp->phy_flags & TG3_PHYFLG_EEE_CAP)) { in tg3_get_eee()
14106 netdev_warn(tp->dev, in tg3_get_eee()
14108 return -EOPNOTSUPP; in tg3_get_eee()
14111 *edata = tp->eee; in tg3_get_eee()
14162 spin_lock_bh(&tp->lock); in tg3_get_stats64()
14163 if (!tp->hw_stats || !tg3_flag(tp, INIT_COMPLETE)) { in tg3_get_stats64()
14164 *stats = tp->net_stats_prev; in tg3_get_stats64()
14165 spin_unlock_bh(&tp->lock); in tg3_get_stats64()
14170 spin_unlock_bh(&tp->lock); in tg3_get_stats64()
14188 dev->mtu = new_mtu; in tg3_set_mtu()
14274 tp->nvram_size = EEPROM_CHIP_SIZE; in tg3_get_eeprom_size()
14291 while (cursize < tp->nvram_size) { in tg3_get_eeprom_size()
14301 tp->nvram_size = cursize; in tg3_get_eeprom_size()
14320 * 16-bit value at offset 0xf2. The tg3_nvram_read() in tg3_get_nvram_size()
14324 * want will always reside in the lower 16-bits. in tg3_get_nvram_size()
14327 * opposite the endianness of the CPU. The 16-bit in tg3_get_nvram_size()
14330 tp->nvram_size = swab16((u16)(val & 0x0000ffff)) * 1024; in tg3_get_nvram_size()
14334 tp->nvram_size = TG3_NVRAM_SIZE_512KB; in tg3_get_nvram_size()
14353 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_nvram_info()
14354 tp->nvram_pagesize = ATMEL_AT45DB0X1B_PAGE_SIZE; in tg3_get_nvram_info()
14358 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_nvram_info()
14359 tp->nvram_pagesize = ATMEL_AT25F512_PAGE_SIZE; in tg3_get_nvram_info()
14362 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_nvram_info()
14363 tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE; in tg3_get_nvram_info()
14367 tp->nvram_jedecnum = JEDEC_ST; in tg3_get_nvram_info()
14368 tp->nvram_pagesize = ST_M45PEX0_PAGE_SIZE; in tg3_get_nvram_info()
14372 tp->nvram_jedecnum = JEDEC_SAIFUN; in tg3_get_nvram_info()
14373 tp->nvram_pagesize = SAIFUN_SA25F0XX_PAGE_SIZE; in tg3_get_nvram_info()
14377 tp->nvram_jedecnum = JEDEC_SST; in tg3_get_nvram_info()
14378 tp->nvram_pagesize = SST_25VF0X0_PAGE_SIZE; in tg3_get_nvram_info()
14382 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_nvram_info()
14383 tp->nvram_pagesize = ATMEL_AT45DB0X1B_PAGE_SIZE; in tg3_get_nvram_info()
14392 tp->nvram_pagesize = 256; in tg3_nvram_get_pagesize()
14395 tp->nvram_pagesize = 512; in tg3_nvram_get_pagesize()
14398 tp->nvram_pagesize = 1024; in tg3_nvram_get_pagesize()
14401 tp->nvram_pagesize = 2048; in tg3_nvram_get_pagesize()
14404 tp->nvram_pagesize = 4096; in tg3_nvram_get_pagesize()
14407 tp->nvram_pagesize = 264; in tg3_nvram_get_pagesize()
14410 tp->nvram_pagesize = 528; in tg3_nvram_get_pagesize()
14428 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_5752_nvram_info()
14432 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_5752_nvram_info()
14439 tp->nvram_jedecnum = JEDEC_ST; in tg3_get_5752_nvram_info()
14449 tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE; in tg3_get_5752_nvram_info()
14474 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_5755_nvram_info()
14477 tp->nvram_pagesize = 264; in tg3_get_5755_nvram_info()
14480 tp->nvram_size = (protect ? 0x3e200 : in tg3_get_5755_nvram_info()
14483 tp->nvram_size = (protect ? 0x1f200 : in tg3_get_5755_nvram_info()
14486 tp->nvram_size = (protect ? 0x1f200 : in tg3_get_5755_nvram_info()
14492 tp->nvram_jedecnum = JEDEC_ST; in tg3_get_5755_nvram_info()
14495 tp->nvram_pagesize = 256; in tg3_get_5755_nvram_info()
14497 tp->nvram_size = (protect ? in tg3_get_5755_nvram_info()
14501 tp->nvram_size = (protect ? in tg3_get_5755_nvram_info()
14505 tp->nvram_size = (protect ? in tg3_get_5755_nvram_info()
14523 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_5787_nvram_info()
14525 tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE; in tg3_get_5787_nvram_info()
14534 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_5787_nvram_info()
14537 tp->nvram_pagesize = 264; in tg3_get_5787_nvram_info()
14542 tp->nvram_jedecnum = JEDEC_ST; in tg3_get_5787_nvram_info()
14545 tp->nvram_pagesize = 256; in tg3_get_5787_nvram_info()
14572 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_5761_nvram_info()
14576 tp->nvram_pagesize = 256; in tg3_get_5761_nvram_info()
14586 tp->nvram_jedecnum = JEDEC_ST; in tg3_get_5761_nvram_info()
14589 tp->nvram_pagesize = 256; in tg3_get_5761_nvram_info()
14594 tp->nvram_size = tr32(NVRAM_ADDR_LOCKOUT); in tg3_get_5761_nvram_info()
14601 tp->nvram_size = TG3_NVRAM_SIZE_2MB; in tg3_get_5761_nvram_info()
14607 tp->nvram_size = TG3_NVRAM_SIZE_1MB; in tg3_get_5761_nvram_info()
14613 tp->nvram_size = TG3_NVRAM_SIZE_512KB; in tg3_get_5761_nvram_info()
14619 tp->nvram_size = TG3_NVRAM_SIZE_256KB; in tg3_get_5761_nvram_info()
14627 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_5906_nvram_info()
14629 tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE; in tg3_get_5906_nvram_info()
14641 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_57780_nvram_info()
14643 tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE; in tg3_get_57780_nvram_info()
14655 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_57780_nvram_info()
14663 tp->nvram_size = TG3_NVRAM_SIZE_128KB; in tg3_get_57780_nvram_info()
14667 tp->nvram_size = TG3_NVRAM_SIZE_256KB; in tg3_get_57780_nvram_info()
14671 tp->nvram_size = TG3_NVRAM_SIZE_512KB; in tg3_get_57780_nvram_info()
14678 tp->nvram_jedecnum = JEDEC_ST; in tg3_get_57780_nvram_info()
14684 tp->nvram_size = TG3_NVRAM_SIZE_128KB; in tg3_get_57780_nvram_info()
14687 tp->nvram_size = TG3_NVRAM_SIZE_256KB; in tg3_get_57780_nvram_info()
14690 tp->nvram_size = TG3_NVRAM_SIZE_512KB; in tg3_get_57780_nvram_info()
14700 if (tp->nvram_pagesize != 264 && tp->nvram_pagesize != 528) in tg3_get_57780_nvram_info()
14714 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_5717_nvram_info()
14716 tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE; in tg3_get_5717_nvram_info()
14728 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_5717_nvram_info()
14738 tp->nvram_size = TG3_NVRAM_SIZE_256KB; in tg3_get_5717_nvram_info()
14741 tp->nvram_size = TG3_NVRAM_SIZE_128KB; in tg3_get_5717_nvram_info()
14755 tp->nvram_jedecnum = JEDEC_ST; in tg3_get_5717_nvram_info()
14766 tp->nvram_size = TG3_NVRAM_SIZE_256KB; in tg3_get_5717_nvram_info()
14769 tp->nvram_size = TG3_NVRAM_SIZE_128KB; in tg3_get_5717_nvram_info()
14779 if (tp->nvram_pagesize != 264 && tp->nvram_pagesize != 528) in tg3_get_5717_nvram_info()
14802 tp->nvram_pagesize = 4096; in tg3_get_5720_nvram_info()
14803 tp->nvram_jedecnum = JEDEC_MACRONIX; in tg3_get_5720_nvram_info()
14808 tp->nvram_size = in tg3_get_5720_nvram_info()
14832 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_5720_nvram_info()
14838 tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE; in tg3_get_5720_nvram_info()
14840 tp->nvram_pagesize = ATMEL_AT24C02_CHIP_SIZE; in tg3_get_5720_nvram_info()
14854 tp->nvram_jedecnum = JEDEC_ATMEL; in tg3_get_5720_nvram_info()
14862 tp->nvram_size = TG3_NVRAM_SIZE_256KB; in tg3_get_5720_nvram_info()
14867 tp->nvram_size = TG3_NVRAM_SIZE_512KB; in tg3_get_5720_nvram_info()
14871 tp->nvram_size = TG3_NVRAM_SIZE_1MB; in tg3_get_5720_nvram_info()
14875 tp->nvram_size = TG3_NVRAM_SIZE_128KB; in tg3_get_5720_nvram_info()
14897 tp->nvram_jedecnum = JEDEC_ST; in tg3_get_5720_nvram_info()
14906 tp->nvram_size = TG3_NVRAM_SIZE_256KB; in tg3_get_5720_nvram_info()
14912 tp->nvram_size = TG3_NVRAM_SIZE_512KB; in tg3_get_5720_nvram_info()
14918 tp->nvram_size = TG3_NVRAM_SIZE_1MB; in tg3_get_5720_nvram_info()
14922 tp->nvram_size = TG3_NVRAM_SIZE_128KB; in tg3_get_5720_nvram_info()
14932 if (tp->nvram_pagesize != 264 && tp->nvram_pagesize != 528) in tg3_get_5720_nvram_info()
14975 netdev_warn(tp->dev, in tg3_nvram_init()
14982 tp->nvram_size = 0; in tg3_nvram_init()
15008 if (tp->nvram_size == 0) in tg3_nvram_init()
15097 tp->pdev->subsystem_vendor) && in tg3_lookup_by_subsys()
15099 tp->pdev->subsystem_device)) in tg3_lookup_by_subsys()
15109 tp->phy_id = TG3_PHY_ID_INVALID; in tg3_get_eeprom_hw_cfg()
15110 tp->led_ctrl = LED_CTRL_MODE_PHY_1; in tg3_get_eeprom_hw_cfg()
15127 device_set_wakeup_enable(&tp->pdev->dev, true); in tg3_get_eeprom_hw_cfg()
15140 tp->nic_sram_data_cfg = nic_cfg; in tg3_get_eeprom_hw_cfg()
15173 tp->phy_id = eeprom_phy_id; in tg3_get_eeprom_hw_cfg()
15176 tp->phy_flags |= TG3_PHYFLG_PHY_SERDES; in tg3_get_eeprom_hw_cfg()
15178 tp->phy_flags |= TG3_PHYFLG_MII_SERDES; in tg3_get_eeprom_hw_cfg()
15190 tp->led_ctrl = LED_CTRL_MODE_PHY_1; in tg3_get_eeprom_hw_cfg()
15194 tp->led_ctrl = LED_CTRL_MODE_PHY_2; in tg3_get_eeprom_hw_cfg()
15198 tp->led_ctrl = LED_CTRL_MODE_MAC; in tg3_get_eeprom_hw_cfg()
15205 tp->led_ctrl = LED_CTRL_MODE_PHY_1; in tg3_get_eeprom_hw_cfg()
15210 tp->led_ctrl = LED_CTRL_MODE_SHARED; in tg3_get_eeprom_hw_cfg()
15213 tp->led_ctrl |= (LED_CTRL_MODE_PHY_1 | in tg3_get_eeprom_hw_cfg()
15218 tp->led_ctrl |= LED_CTRL_BLINK_RATE_OVERRIDE | in tg3_get_eeprom_hw_cfg()
15224 tp->led_ctrl = LED_CTRL_MODE_SHASTA_MAC; in tg3_get_eeprom_hw_cfg()
15228 tp->led_ctrl = LED_CTRL_MODE_COMBO; in tg3_get_eeprom_hw_cfg()
15230 tp->led_ctrl |= (LED_CTRL_MODE_PHY_1 | in tg3_get_eeprom_hw_cfg()
15238 tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL) in tg3_get_eeprom_hw_cfg()
15239 tp->led_ctrl = LED_CTRL_MODE_PHY_2; in tg3_get_eeprom_hw_cfg()
15242 tp->led_ctrl = LED_CTRL_MODE_PHY_1; in tg3_get_eeprom_hw_cfg()
15246 if ((tp->pdev->subsystem_vendor == in tg3_get_eeprom_hw_cfg()
15248 (tp->pdev->subsystem_device == 0x205a || in tg3_get_eeprom_hw_cfg()
15249 tp->pdev->subsystem_device == 0x2063)) in tg3_get_eeprom_hw_cfg()
15266 if (tp->phy_flags & TG3_PHYFLG_ANY_SERDES && in tg3_get_eeprom_hw_cfg()
15273 device_set_wakeup_enable(&tp->pdev->dev, true); in tg3_get_eeprom_hw_cfg()
15277 tp->phy_flags |= TG3_PHYFLG_CAPACITIVE_COUPLING; in tg3_get_eeprom_hw_cfg()
15279 /* serdes signal pre-emphasis in register 0x590 set by */ in tg3_get_eeprom_hw_cfg()
15282 tp->phy_flags |= TG3_PHYFLG_SERDES_PREEMPHASIS; in tg3_get_eeprom_hw_cfg()
15288 tp->phy_flags |= TG3_PHYFLG_ENABLE_APD; in tg3_get_eeprom_hw_cfg()
15299 tp->phy_flags |= TG3_PHYFLG_KEEP_LINK_ON_PWRDN; in tg3_get_eeprom_hw_cfg()
15301 tp->phy_flags |= TG3_PHYFLG_1G_ON_VAUX_OK; in tg3_get_eeprom_hw_cfg()
15312 tp->phy_flags |= TG3_PHYFLG_DISABLE_1G_HD_ADV; in tg3_get_eeprom_hw_cfg()
15316 device_set_wakeup_enable(&tp->pdev->dev, in tg3_get_eeprom_hw_cfg()
15319 device_set_wakeup_capable(&tp->pdev->dev, false); in tg3_get_eeprom_hw_cfg()
15352 return -EBUSY; in tg3_ape_otp_read()
15371 return (val & OTP_STATUS_CMD_DONE) ? 0 : -EBUSY; in tg3_issue_otp_command()
15375 * configuration is a 32-bit value that straddles the alignment boundary.
15376 * We do two 32-bit reads and then shift and merge the results.
15406 u32 adv = ADVERTISED_Autoneg; in tg3_phy_init_link_config() local
15408 if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) { in tg3_phy_init_link_config()
15409 if (!(tp->phy_flags & TG3_PHYFLG_DISABLE_1G_HD_ADV)) in tg3_phy_init_link_config()
15410 adv |= ADVERTISED_1000baseT_Half; in tg3_phy_init_link_config()
15411 adv |= ADVERTISED_1000baseT_Full; in tg3_phy_init_link_config()
15414 if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES)) in tg3_phy_init_link_config()
15415 adv |= ADVERTISED_100baseT_Half | in tg3_phy_init_link_config()
15421 adv |= ADVERTISED_FIBRE; in tg3_phy_init_link_config()
15423 tp->link_config.advertising = adv; in tg3_phy_init_link_config()
15424 tp->link_config.speed = SPEED_UNKNOWN; in tg3_phy_init_link_config()
15425 tp->link_config.duplex = DUPLEX_UNKNOWN; in tg3_phy_init_link_config()
15426 tp->link_config.autoneg = AUTONEG_ENABLE; in tg3_phy_init_link_config()
15427 tp->link_config.active_speed = SPEED_UNKNOWN; in tg3_phy_init_link_config()
15428 tp->link_config.active_duplex = DUPLEX_UNKNOWN; in tg3_phy_init_link_config()
15430 tp->old_link = -1; in tg3_phy_init_link_config()
15441 tp->link_config.flowctrl = FLOW_CTRL_TX | FLOW_CTRL_RX; in tg3_phy_probe()
15444 switch (tp->pci_fn) { in tg3_phy_probe()
15446 tp->phy_ape_lock = TG3_APE_LOCK_PHY0; in tg3_phy_probe()
15449 tp->phy_ape_lock = TG3_APE_LOCK_PHY1; in tg3_phy_probe()
15452 tp->phy_ape_lock = TG3_APE_LOCK_PHY2; in tg3_phy_probe()
15455 tp->phy_ape_lock = TG3_APE_LOCK_PHY3; in tg3_phy_probe()
15461 !(tp->phy_flags & TG3_PHYFLG_ANY_SERDES) && in tg3_phy_probe()
15462 !(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) in tg3_phy_probe()
15463 tp->phy_flags &= ~(TG3_PHYFLG_1G_ON_VAUX_OK | in tg3_phy_probe()
15478 * to either the hard-coded table based PHY_ID and failing in tg3_phy_probe()
15492 tp->phy_id = hw_phy_id; in tg3_phy_probe()
15494 tp->phy_flags |= TG3_PHYFLG_PHY_SERDES; in tg3_phy_probe()
15496 tp->phy_flags &= ~TG3_PHYFLG_PHY_SERDES; in tg3_phy_probe()
15498 if (tp->phy_id != TG3_PHY_ID_INVALID) { in tg3_phy_probe()
15510 tp->phy_id = p->phy_id; in tg3_phy_probe()
15519 return -ENODEV; in tg3_phy_probe()
15522 if (!tp->phy_id || in tg3_phy_probe()
15523 tp->phy_id == TG3_PHY_ID_BCM8002) in tg3_phy_probe()
15524 tp->phy_flags |= TG3_PHYFLG_PHY_SERDES; in tg3_phy_probe()
15528 if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES) && in tg3_phy_probe()
15537 tp->phy_flags |= TG3_PHYFLG_EEE_CAP; in tg3_phy_probe()
15539 tp->eee.supported = SUPPORTED_100baseT_Full | in tg3_phy_probe()
15541 tp->eee.advertised = ADVERTISED_100baseT_Full | in tg3_phy_probe()
15543 tp->eee.eee_enabled = 1; in tg3_phy_probe()
15544 tp->eee.tx_lpi_enabled = 1; in tg3_phy_probe()
15545 tp->eee.tx_lpi_timer = TG3_CPMU_DBTMR1_LNKIDLE_2047US; in tg3_phy_probe()
15550 if (!(tp->phy_flags & TG3_PHYFLG_KEEP_LINK_ON_PWRDN) && in tg3_phy_probe()
15551 !(tp->phy_flags & TG3_PHYFLG_ANY_SERDES) && in tg3_phy_probe()
15568 tg3_phy_autoneg_cfg(tp, tp->link_config.advertising, in tg3_phy_probe()
15569 tp->link_config.flowctrl); in tg3_phy_probe()
15577 if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5401) { in tg3_phy_probe()
15611 memset(tp->fw_ver, 0, sizeof(tp->fw_ver)); in tg3_read_vpd()
15612 snprintf(tp->fw_ver, sizeof(tp->fw_ver), "%.*s bc ", len, vpd_data + i); in tg3_read_vpd()
15623 memcpy(tp->board_part_number, &vpd_data[i], len); in tg3_read_vpd()
15627 if (tp->board_part_number[0]) in tg3_read_vpd()
15632 if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_5717 || in tg3_read_vpd()
15633 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5717_C) in tg3_read_vpd()
15634 strcpy(tp->board_part_number, "BCM5717"); in tg3_read_vpd()
15635 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718) in tg3_read_vpd()
15636 strcpy(tp->board_part_number, "BCM5718"); in tg3_read_vpd()
15640 if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57780) in tg3_read_vpd()
15641 strcpy(tp->board_part_number, "BCM57780"); in tg3_read_vpd()
15642 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57760) in tg3_read_vpd()
15643 strcpy(tp->board_part_number, "BCM57760"); in tg3_read_vpd()
15644 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57790) in tg3_read_vpd()
15645 strcpy(tp->board_part_number, "BCM57790"); in tg3_read_vpd()
15646 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57788) in tg3_read_vpd()
15647 strcpy(tp->board_part_number, "BCM57788"); in tg3_read_vpd()
15651 if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57761) in tg3_read_vpd()
15652 strcpy(tp->board_part_number, "BCM57761"); in tg3_read_vpd()
15653 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57765) in tg3_read_vpd()
15654 strcpy(tp->board_part_number, "BCM57765"); in tg3_read_vpd()
15655 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57781) in tg3_read_vpd()
15656 strcpy(tp->board_part_number, "BCM57781"); in tg3_read_vpd()
15657 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57785) in tg3_read_vpd()
15658 strcpy(tp->board_part_number, "BCM57785"); in tg3_read_vpd()
15659 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57791) in tg3_read_vpd()
15660 strcpy(tp->board_part_number, "BCM57791"); in tg3_read_vpd()
15661 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57795) in tg3_read_vpd()
15662 strcpy(tp->board_part_number, "BCM57795"); in tg3_read_vpd()
15666 if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57762) in tg3_read_vpd()
15667 strcpy(tp->board_part_number, "BCM57762"); in tg3_read_vpd()
15668 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57766) in tg3_read_vpd()
15669 strcpy(tp->board_part_number, "BCM57766"); in tg3_read_vpd()
15670 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57782) in tg3_read_vpd()
15671 strcpy(tp->board_part_number, "BCM57782"); in tg3_read_vpd()
15672 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57786) in tg3_read_vpd()
15673 strcpy(tp->board_part_number, "BCM57786"); in tg3_read_vpd()
15677 strcpy(tp->board_part_number, "BCM95906"); in tg3_read_vpd()
15680 strcpy(tp->board_part_number, "none"); in tg3_read_vpd()
15720 dst_off = strlen(tp->fw_ver); in tg3_read_bc_ver()
15723 if (TG3_VER_SIZE - dst_off < 16 || in tg3_read_bc_ver()
15727 offset = offset + ver_offset - start; in tg3_read_bc_ver()
15733 memcpy(tp->fw_ver + dst_off + i, &v, sizeof(v)); in tg3_read_bc_ver()
15744 snprintf(&tp->fw_ver[dst_off], TG3_VER_SIZE - dst_off, in tg3_read_bc_ver()
15762 snprintf(&tp->fw_ver[0], 32, "sb v%d.%02d", major, minor); in tg3_read_hwsb_ver()
15769 strncat(tp->fw_ver, "sb", TG3_VER_SIZE - strlen(tp->fw_ver) - 1); in tg3_read_sb_ver()
15809 offset = strlen(tp->fw_ver); in tg3_read_sb_ver()
15810 snprintf(&tp->fw_ver[offset], TG3_VER_SIZE - offset, in tg3_read_sb_ver()
15814 offset = strlen(tp->fw_ver); in tg3_read_sb_ver()
15815 if (offset < TG3_VER_SIZE - 1) in tg3_read_sb_ver()
15816 tp->fw_ver[offset] = 'a' + build - 1; in tg3_read_sb_ver()
15840 else if (tg3_nvram_read(tp, offset - 4, &start)) in tg3_read_mgmtfw_ver()
15848 offset += val - start; in tg3_read_mgmtfw_ver()
15850 vlen = strlen(tp->fw_ver); in tg3_read_mgmtfw_ver()
15852 tp->fw_ver[vlen++] = ','; in tg3_read_mgmtfw_ver()
15853 tp->fw_ver[vlen++] = ' '; in tg3_read_mgmtfw_ver()
15862 if (vlen > TG3_VER_SIZE - sizeof(v)) { in tg3_read_mgmtfw_ver()
15863 memcpy(&tp->fw_ver[vlen], &v, TG3_VER_SIZE - vlen); in tg3_read_mgmtfw_ver()
15867 memcpy(&tp->fw_ver[vlen], &v, sizeof(v)); in tg3_read_mgmtfw_ver()
15898 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_5725) in tg3_read_dash_ver()
15903 vlen = strlen(tp->fw_ver); in tg3_read_dash_ver()
15905 snprintf(&tp->fw_ver[vlen], TG3_VER_SIZE - vlen, " %s v%d.%d.%d.%d", in tg3_read_dash_ver()
15933 vlen = strlen(tp->fw_ver); in tg3_read_otp_ver()
15934 snprintf(&tp->fw_ver[vlen], TG3_VER_SIZE - vlen, " .%02d", ver); in tg3_read_otp_ver()
15943 if (tp->fw_ver[0] != 0) in tg3_read_fw_ver()
15947 strcat(tp->fw_ver, "sb"); in tg3_read_fw_ver()
15972 tp->fw_ver[TG3_VER_SIZE - 1] = 0; in tg3_read_fw_ver()
15995 unsigned int func, devnr = tp->pdev->devfn & ~7; in tg3_find_peer()
15998 peer = pci_get_slot(tp->pdev->bus, devnr | func); in tg3_find_peer()
15999 if (peer && peer != tp->pdev) in tg3_find_peer()
16003 /* 5704 can be configured in single-port mode, set peer to in tg3_find_peer()
16004 * tp->pdev in that case. in tg3_find_peer()
16007 peer = tp->pdev; in tg3_find_peer()
16022 tp->pci_chip_rev_id = misc_ctrl_reg >> MISC_HOST_CTRL_CHIPREV_SHIFT; in tg3_detect_asic_rev()
16031 if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_5717 || in tg3_detect_asic_rev()
16032 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5717_C || in tg3_detect_asic_rev()
16033 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718 || in tg3_detect_asic_rev()
16034 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5719 || in tg3_detect_asic_rev()
16035 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5720 || in tg3_detect_asic_rev()
16036 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57767 || in tg3_detect_asic_rev()
16037 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57764 || in tg3_detect_asic_rev()
16038 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5762 || in tg3_detect_asic_rev()
16039 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5725 || in tg3_detect_asic_rev()
16040 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5727 || in tg3_detect_asic_rev()
16041 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57787) in tg3_detect_asic_rev()
16043 else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57781 || in tg3_detect_asic_rev()
16044 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57785 || in tg3_detect_asic_rev()
16045 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57761 || in tg3_detect_asic_rev()
16046 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57765 || in tg3_detect_asic_rev()
16047 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57791 || in tg3_detect_asic_rev()
16048 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57795 || in tg3_detect_asic_rev()
16049 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57762 || in tg3_detect_asic_rev()
16050 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57766 || in tg3_detect_asic_rev()
16051 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57782 || in tg3_detect_asic_rev()
16052 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57786) in tg3_detect_asic_rev()
16057 pci_read_config_dword(tp->pdev, reg, &tp->pci_chip_rev_id); in tg3_detect_asic_rev()
16064 tp->pci_chip_rev_id = CHIPREV_ID_5752_A0; in tg3_detect_asic_rev()
16067 tp->pci_chip_rev_id = CHIPREV_ID_5720_A0; in tg3_detect_asic_rev()
16115 (tp->phy_flags & TG3_PHYFLG_IS_FET)) in tg3_10_100_only_device()
16118 if (ent->driver_data & TG3_DRV_DATA_FLAG_10_100_ONLY) { in tg3_10_100_only_device()
16120 if (ent->driver_data & TG3_DRV_DATA_FLAG_5705_10_100) in tg3_10_100_only_device()
16145 pci_read_config_word(tp->pdev, PCI_COMMAND, &pci_cmd); in tg3_get_invariants()
16147 pci_write_config_word(tp->pdev, PCI_COMMAND, pci_cmd); in tg3_get_invariants()
16149 /* Important! -- Make sure register accesses are byteswapped in tg3_get_invariants()
16154 pci_read_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, in tg3_get_invariants()
16156 tp->misc_host_ctrl |= (misc_ctrl_reg & in tg3_get_invariants()
16158 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, in tg3_get_invariants()
16159 tp->misc_host_ctrl); in tg3_get_invariants()
16169 * will drive special cycles with non-zero data during the in tg3_get_invariants()
16172 * non-zero address during special cycles. However, only in tg3_get_invariants()
16173 * these ICH bridges are known to drive non-zero addresses in tg3_get_invariants()
16200 while (pci_id->vendor != 0) { in tg3_get_invariants()
16201 bridge = pci_get_device(pci_id->vendor, pci_id->device, in tg3_get_invariants()
16207 if (pci_id->rev != PCI_ANY_ID) { in tg3_get_invariants()
16208 if (bridge->revision > pci_id->rev) in tg3_get_invariants()
16211 if (bridge->subordinate && in tg3_get_invariants()
16212 (bridge->subordinate->number == in tg3_get_invariants()
16213 tp->pdev->bus->number)) { in tg3_get_invariants()
16233 while (pci_id->vendor != 0) { in tg3_get_invariants()
16234 bridge = pci_get_device(pci_id->vendor, in tg3_get_invariants()
16235 pci_id->device, in tg3_get_invariants()
16241 if (bridge->subordinate && in tg3_get_invariants()
16242 (bridge->subordinate->number <= in tg3_get_invariants()
16243 tp->pdev->bus->number) && in tg3_get_invariants()
16244 (bridge->subordinate->busn_res.end >= in tg3_get_invariants()
16245 tp->pdev->bus->number)) { in tg3_get_invariants()
16254 * DMA addresses > 40-bit. This bridge may have other additional in tg3_get_invariants()
16255 * 57xx devices behind it in some 4-port NIC designs for example. in tg3_get_invariants()
16256 * Any tg3 device found behind the bridge will also need the 40-bit in tg3_get_invariants()
16261 tp->msi_cap = tp->pdev->msi_cap; in tg3_get_invariants()
16269 if (bridge && bridge->subordinate && in tg3_get_invariants()
16270 (bridge->subordinate->number <= in tg3_get_invariants()
16271 tp->pdev->bus->number) && in tg3_get_invariants()
16272 (bridge->subordinate->busn_res.end >= in tg3_get_invariants()
16273 tp->pdev->bus->number)) { in tg3_get_invariants()
16283 tp->pdev_peer = tg3_find_peer(tp); in tg3_get_invariants()
16305 tp->fw_needed = FIRMWARE_TG3TSO5; in tg3_get_invariants()
16307 tp->fw_needed = FIRMWARE_TG3TSO; in tg3_get_invariants()
16323 tp->fw_needed = NULL; in tg3_get_invariants()
16327 tp->fw_needed = FIRMWARE_TG3; in tg3_get_invariants()
16330 tp->fw_needed = FIRMWARE_TG357766; in tg3_get_invariants()
16332 tp->irq_max = 1; in tg3_get_invariants()
16340 tp->pdev_peer == tp->pdev)) in tg3_get_invariants()
16350 tp->irq_max = TG3_IRQ_MAX_VECS; in tg3_get_invariants()
16354 tp->txq_max = 1; in tg3_get_invariants()
16355 tp->rxq_max = 1; in tg3_get_invariants()
16356 if (tp->irq_max > 1) { in tg3_get_invariants()
16357 tp->rxq_max = TG3_RSS_MAX_NUM_QS; in tg3_get_invariants()
16362 tp->txq_max = tp->irq_max - 1; in tg3_get_invariants()
16370 tp->dma_limit = TG3_TX_BD_DMA_MAX_4K; in tg3_get_invariants()
16387 pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE, in tg3_get_invariants()
16390 if (pci_is_pcie(tp->pdev)) { in tg3_get_invariants()
16395 pcie_capability_read_word(tp->pdev, PCI_EXP_LNKCTL, &lnkctl); in tg3_get_invariants()
16417 tp->pcix_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_PCIX); in tg3_get_invariants()
16418 if (!tp->pcix_cap) { in tg3_get_invariants()
16419 dev_err(&tp->pdev->dev, in tg3_get_invariants()
16420 "Cannot find PCI-X capability, aborting\n"); in tg3_get_invariants()
16421 return -EIO; in tg3_get_invariants()
16438 pci_read_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE, in tg3_get_invariants()
16439 &tp->pci_cacheline_sz); in tg3_get_invariants()
16440 pci_read_config_byte(tp->pdev, PCI_LATENCY_TIMER, in tg3_get_invariants()
16441 &tp->pci_lat_timer); in tg3_get_invariants()
16443 tp->pci_lat_timer < 64) { in tg3_get_invariants()
16444 tp->pci_lat_timer = 64; in tg3_get_invariants()
16445 pci_write_config_byte(tp->pdev, PCI_LATENCY_TIMER, in tg3_get_invariants()
16446 tp->pci_lat_timer); in tg3_get_invariants()
16449 /* Important! -- It is critical that the PCI-X hw workaround in tg3_get_invariants()
16458 /* If we are in PCI-X mode, enable register write workaround. in tg3_get_invariants()
16472 pci_read_config_dword(tp->pdev, in tg3_get_invariants()
16473 tp->pdev->pm_cap + PCI_PM_CTRL, in tg3_get_invariants()
16477 pci_write_config_dword(tp->pdev, in tg3_get_invariants()
16478 tp->pdev->pm_cap + PCI_PM_CTRL, in tg3_get_invariants()
16482 pci_read_config_word(tp->pdev, PCI_COMMAND, &pci_cmd); in tg3_get_invariants()
16484 pci_write_config_word(tp->pdev, PCI_COMMAND, pci_cmd); in tg3_get_invariants()
16493 /* Chip-specific fixup from Broadcom driver */ in tg3_get_invariants()
16497 pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, pci_state_reg); in tg3_get_invariants()
16501 tp->read32 = tg3_read32; in tg3_get_invariants()
16502 tp->write32 = tg3_write32; in tg3_get_invariants()
16503 tp->read32_mbox = tg3_read32; in tg3_get_invariants()
16504 tp->write32_mbox = tg3_write32; in tg3_get_invariants()
16505 tp->write32_tx_mbox = tg3_write32; in tg3_get_invariants()
16506 tp->write32_rx_mbox = tg3_write32; in tg3_get_invariants()
16510 tp->write32 = tg3_write_indirect_reg32; in tg3_get_invariants()
16521 tp->write32 = tg3_write_flush_reg32; in tg3_get_invariants()
16525 tp->write32_tx_mbox = tg3_write32_tx_mbox; in tg3_get_invariants()
16527 tp->write32_rx_mbox = tg3_write_flush_reg32; in tg3_get_invariants()
16531 tp->read32 = tg3_read_indirect_reg32; in tg3_get_invariants()
16532 tp->write32 = tg3_write_indirect_reg32; in tg3_get_invariants()
16533 tp->read32_mbox = tg3_read_indirect_mbox; in tg3_get_invariants()
16534 tp->write32_mbox = tg3_write_indirect_mbox; in tg3_get_invariants()
16535 tp->write32_tx_mbox = tg3_write_indirect_mbox; in tg3_get_invariants()
16536 tp->write32_rx_mbox = tg3_write_indirect_mbox; in tg3_get_invariants()
16538 iounmap(tp->regs); in tg3_get_invariants()
16539 tp->regs = NULL; in tg3_get_invariants()
16541 pci_read_config_word(tp->pdev, PCI_COMMAND, &pci_cmd); in tg3_get_invariants()
16543 pci_write_config_word(tp->pdev, PCI_COMMAND, pci_cmd); in tg3_get_invariants()
16546 tp->read32_mbox = tg3_read32_mbox_5906; in tg3_get_invariants()
16547 tp->write32_mbox = tg3_write32_mbox_5906; in tg3_get_invariants()
16548 tp->write32_tx_mbox = tg3_write32_mbox_5906; in tg3_get_invariants()
16549 tp->write32_rx_mbox = tg3_write32_mbox_5906; in tg3_get_invariants()
16552 if (tp->write32 == tg3_write_indirect_reg32 || in tg3_get_invariants()
16566 tp->pci_fn = PCI_FUNC(tp->pdev->devfn) & 3; in tg3_get_invariants()
16570 pci_read_config_dword(tp->pdev, in tg3_get_invariants()
16571 tp->pcix_cap + PCI_X_STATUS, in tg3_get_invariants()
16573 tp->pci_fn = val & 0x7; in tg3_get_invariants()
16583 tp->pci_fn = (val & TG3_CPMU_STATUS_FMSK_5717) ? 1 : 0; in tg3_get_invariants()
16585 tp->pci_fn = (val & TG3_CPMU_STATUS_FMSK_5719) >> in tg3_get_invariants()
16590 tp->write32_tx_mbox = tg3_write_flush_reg32; in tg3_get_invariants()
16591 tp->write32_rx_mbox = tg3_write_flush_reg32; in tg3_get_invariants()
16607 tp->fw_needed = NULL; in tg3_get_invariants()
16617 pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, in tg3_get_invariants()
16621 tp->ape_hb_interval = in tg3_get_invariants()
16625 /* Set up tp->grc_local_ctrl before calling in tg3_get_invariants()
16630 tp->grc_local_ctrl = GRC_LCLCTRL_INT_ON_ATTN | GRC_LCLCTRL_AUTO_SEEPROM; in tg3_get_invariants()
16633 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 | in tg3_get_invariants()
16636 * are no pull-up resistors on unused GPIO pins. in tg3_get_invariants()
16639 tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3; in tg3_get_invariants()
16644 tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_UART_SEL; in tg3_get_invariants()
16646 if (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5761 || in tg3_get_invariants()
16647 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5761S) { in tg3_get_invariants()
16649 tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_UART_SEL; in tg3_get_invariants()
16652 tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE0 | in tg3_get_invariants()
16657 tp->grc_local_ctrl |= in tg3_get_invariants()
16666 if (tp->dev->mtu > ETH_DATA_LEN && !tg3_flag(tp, 5780_CLASS)) in tg3_get_invariants()
16680 tp->phy_flags |= TG3_PHYFLG_IS_FET; in tg3_get_invariants()
16687 (tp->phy_flags & TG3_PHYFLG_IS_FET) || in tg3_get_invariants()
16688 (tp->phy_flags & TG3_PHYFLG_ANY_SERDES)) in tg3_get_invariants()
16689 tp->phy_flags |= TG3_PHYFLG_NO_ETH_WIRE_SPEED; in tg3_get_invariants()
16693 tp->phy_flags |= TG3_PHYFLG_ADC_BUG; in tg3_get_invariants()
16695 tp->phy_flags |= TG3_PHYFLG_5704_A0_BUG; in tg3_get_invariants()
16698 !(tp->phy_flags & TG3_PHYFLG_IS_FET) && in tg3_get_invariants()
16706 if (tp->pdev->device != PCI_DEVICE_ID_TIGON3_5756 && in tg3_get_invariants()
16707 tp->pdev->device != PCI_DEVICE_ID_TIGON3_5722) in tg3_get_invariants()
16708 tp->phy_flags |= TG3_PHYFLG_JITTER_BUG; in tg3_get_invariants()
16709 if (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5755M) in tg3_get_invariants()
16710 tp->phy_flags |= TG3_PHYFLG_ADJUST_TRIM; in tg3_get_invariants()
16712 tp->phy_flags |= TG3_PHYFLG_BER_BUG; in tg3_get_invariants()
16717 tp->phy_otp = tg3_read_otp_phycfg(tp); in tg3_get_invariants()
16718 if (tp->phy_otp == 0) in tg3_get_invariants()
16719 tp->phy_otp = TG3_OTP_DEFAULT; in tg3_get_invariants()
16723 tp->mi_mode = MAC_MI_MODE_500KHZ_CONST; in tg3_get_invariants()
16725 tp->mi_mode = MAC_MI_MODE_BASE; in tg3_get_invariants()
16727 tp->coalesce_mode = 0; in tg3_get_invariants()
16730 tp->coalesce_mode |= HOSTCC_MODE_32BYTE; in tg3_get_invariants()
16737 tp->coalesce_mode |= HOSTCC_MODE_ATTN; in tg3_get_invariants()
16738 tp->grc_mode |= GRC_MODE_IRQ_ON_FLOW_ATTN; in tg3_get_invariants()
16761 tw32(GRC_MODE, val | tp->grc_mode); in tg3_get_invariants()
16771 pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE, in tg3_get_invariants()
16785 sram_base = tp->regs + NIC_SRAM_WIN_BASE + NIC_SRAM_STATS_BLK; in tg3_get_invariants()
16801 tp->fw_needed = NULL; in tg3_get_invariants()
16815 tp->coalesce_mode |= (HOSTCC_MODE_CLRTICK_RXBD | in tg3_get_invariants()
16818 tp->misc_host_ctrl |= MISC_HOST_CTRL_TAGGED_STATUS; in tg3_get_invariants()
16819 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, in tg3_get_invariants()
16820 tp->misc_host_ctrl); in tg3_get_invariants()
16825 tp->mac_mode = MAC_MODE_APE_TX_EN | MAC_MODE_APE_RX_EN; in tg3_get_invariants()
16827 tp->mac_mode = 0; in tg3_get_invariants()
16830 tp->phy_flags |= TG3_PHYFLG_10_100_ONLY; in tg3_get_invariants()
16834 dev_err(&tp->pdev->dev, "phy probe failed, err %d\n", err); in tg3_get_invariants()
16842 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) { in tg3_get_invariants()
16843 tp->phy_flags &= ~TG3_PHYFLG_USE_MI_INTERRUPT; in tg3_get_invariants()
16846 tp->phy_flags |= TG3_PHYFLG_USE_MI_INTERRUPT; in tg3_get_invariants()
16848 tp->phy_flags &= ~TG3_PHYFLG_USE_MI_INTERRUPT; in tg3_get_invariants()
16864 if (tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL && in tg3_get_invariants()
16866 !(tp->phy_flags & TG3_PHYFLG_PHY_SERDES)) { in tg3_get_invariants()
16867 tp->phy_flags |= TG3_PHYFLG_USE_MI_INTERRUPT; in tg3_get_invariants()
16872 if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) in tg3_get_invariants()
16880 tp->rx_offset = NET_SKB_PAD + NET_IP_ALIGN; in tg3_get_invariants()
16881 tp->rx_copy_thresh = TG3_RX_COPY_THRESHOLD; in tg3_get_invariants()
16884 tp->rx_offset = NET_SKB_PAD; in tg3_get_invariants()
16886 tp->rx_copy_thresh = ~(u16)0; in tg3_get_invariants()
16890 tp->rx_std_ring_mask = TG3_RX_STD_RING_SIZE(tp) - 1; in tg3_get_invariants()
16891 tp->rx_jmb_ring_mask = TG3_RX_JMB_RING_SIZE(tp) - 1; in tg3_get_invariants()
16892 tp->rx_ret_ring_mask = tg3_rx_ret_ring_size(tp) - 1; in tg3_get_invariants()
16894 tp->rx_std_max_post = tp->rx_std_ring_mask + 1; in tg3_get_invariants()
16902 tp->rx_std_max_post = 8; in tg3_get_invariants()
16905 tp->pwrmgmt_thresh = tr32(PCIE_PWR_MGMT_THRESH) & in tg3_get_invariants()
16917 if (!eth_platform_get_mac_address(&tp->pdev->dev, addr)) in tg3_get_device_address()
16921 err = ssb_gige_get_macaddr(tp->pdev, addr); in tg3_get_device_address()
16936 if (tp->pci_fn & 1) in tg3_get_device_address()
16938 if (tp->pci_fn > 1) in tg3_get_device_address()
16981 return -EINVAL; in tg3_get_device_address()
16994 pci_read_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE, &byte); in tg3_calc_dma_bndry()
17027 * when a device tries to burst across a cache-line boundary. in tg3_calc_dma_bndry()
17030 * Unfortunately, for PCI-E there are only limited in tg3_calc_dma_bndry()
17031 * write-side controls for this, and thus for reads in tg3_calc_dma_bndry()
17161 * Broadcom noted the GRC reset will also reset all sub-components. in tg3_do_test_dma()
17180 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, in tg3_do_test_dma()
17182 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_DATA, val); in tg3_do_test_dma()
17184 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0); in tg3_do_test_dma()
17191 ret = -ENODEV; in tg3_do_test_dma()
17223 buf = dma_alloc_coherent(&tp->pdev->dev, TEST_BUFFER_SIZE, in tg3_test_dma()
17226 ret = -ENOMEM; in tg3_test_dma()
17230 tp->dma_rwctrl = ((0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) | in tg3_test_dma()
17233 tp->dma_rwctrl = tg3_calc_dma_bndry(tp, tp->dma_rwctrl); in tg3_test_dma()
17240 tp->dma_rwctrl |= 0x00180000; in tg3_test_dma()
17244 tp->dma_rwctrl |= 0x003f0000; in tg3_test_dma()
17246 tp->dma_rwctrl |= 0x003f000f; in tg3_test_dma()
17259 tp->dma_rwctrl |= 0x8000; in tg3_test_dma()
17261 tp->dma_rwctrl |= DMA_RWCTRL_ONE_DMA; in tg3_test_dma()
17266 tp->dma_rwctrl |= in tg3_test_dma()
17272 tp->dma_rwctrl |= 0x00144000; in tg3_test_dma()
17275 tp->dma_rwctrl |= 0x00148000; in tg3_test_dma()
17277 tp->dma_rwctrl |= 0x001b000f; in tg3_test_dma()
17281 tp->dma_rwctrl |= DMA_RWCTRL_ONE_DMA; in tg3_test_dma()
17285 tp->dma_rwctrl &= 0xfffffff0; in tg3_test_dma()
17290 tp->dma_rwctrl |= DMA_RWCTRL_USE_MEM_READ_MULT; in tg3_test_dma()
17300 * on those chips to enable a PCI-X workaround. in tg3_test_dma()
17302 tp->dma_rwctrl |= DMA_RWCTRL_ASSERT_ALL_BE; in tg3_test_dma()
17305 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl); in tg3_test_dma()
17315 saved_dma_rwctrl = tp->dma_rwctrl; in tg3_test_dma()
17316 tp->dma_rwctrl &= ~DMA_RWCTRL_WRITE_BNDRY_MASK; in tg3_test_dma()
17317 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl); in tg3_test_dma()
17328 dev_err(&tp->pdev->dev, in tg3_test_dma()
17337 dev_err(&tp->pdev->dev, "%s: Buffer read failed. " in tg3_test_dma()
17347 if ((tp->dma_rwctrl & DMA_RWCTRL_WRITE_BNDRY_MASK) != in tg3_test_dma()
17349 tp->dma_rwctrl &= ~DMA_RWCTRL_WRITE_BNDRY_MASK; in tg3_test_dma()
17350 tp->dma_rwctrl |= DMA_RWCTRL_WRITE_BNDRY_16; in tg3_test_dma()
17351 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl); in tg3_test_dma()
17354 dev_err(&tp->pdev->dev, in tg3_test_dma()
17357 ret = -ENODEV; in tg3_test_dma()
17368 if ((tp->dma_rwctrl & DMA_RWCTRL_WRITE_BNDRY_MASK) != in tg3_test_dma()
17375 tp->dma_rwctrl &= ~DMA_RWCTRL_WRITE_BNDRY_MASK; in tg3_test_dma()
17376 tp->dma_rwctrl |= DMA_RWCTRL_WRITE_BNDRY_16; in tg3_test_dma()
17379 tp->dma_rwctrl = saved_dma_rwctrl; in tg3_test_dma()
17382 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl); in tg3_test_dma()
17386 dma_free_coherent(&tp->pdev->dev, TEST_BUFFER_SIZE, buf, buf_dma); in tg3_test_dma()
17394 tp->bufmgr_config.mbuf_read_dma_low_water = in tg3_init_bufmgr_config()
17396 tp->bufmgr_config.mbuf_mac_rx_low_water = in tg3_init_bufmgr_config()
17398 tp->bufmgr_config.mbuf_high_water = in tg3_init_bufmgr_config()
17401 tp->bufmgr_config.mbuf_read_dma_low_water_jumbo = in tg3_init_bufmgr_config()
17403 tp->bufmgr_config.mbuf_mac_rx_low_water_jumbo = in tg3_init_bufmgr_config()
17405 tp->bufmgr_config.mbuf_high_water_jumbo = in tg3_init_bufmgr_config()
17408 tp->bufmgr_config.mbuf_read_dma_low_water = in tg3_init_bufmgr_config()
17410 tp->bufmgr_config.mbuf_mac_rx_low_water = in tg3_init_bufmgr_config()
17412 tp->bufmgr_config.mbuf_high_water = in tg3_init_bufmgr_config()
17415 tp->bufmgr_config.mbuf_mac_rx_low_water = in tg3_init_bufmgr_config()
17417 tp->bufmgr_config.mbuf_high_water = in tg3_init_bufmgr_config()
17421 tp->bufmgr_config.mbuf_read_dma_low_water_jumbo = in tg3_init_bufmgr_config()
17423 tp->bufmgr_config.mbuf_mac_rx_low_water_jumbo = in tg3_init_bufmgr_config()
17425 tp->bufmgr_config.mbuf_high_water_jumbo = in tg3_init_bufmgr_config()
17428 tp->bufmgr_config.mbuf_read_dma_low_water = in tg3_init_bufmgr_config()
17430 tp->bufmgr_config.mbuf_mac_rx_low_water = in tg3_init_bufmgr_config()
17432 tp->bufmgr_config.mbuf_high_water = in tg3_init_bufmgr_config()
17435 tp->bufmgr_config.mbuf_read_dma_low_water_jumbo = in tg3_init_bufmgr_config()
17437 tp->bufmgr_config.mbuf_mac_rx_low_water_jumbo = in tg3_init_bufmgr_config()
17439 tp->bufmgr_config.mbuf_high_water_jumbo = in tg3_init_bufmgr_config()
17443 tp->bufmgr_config.dma_low_water = DEFAULT_DMA_LOW_WATER; in tg3_init_bufmgr_config()
17444 tp->bufmgr_config.dma_high_water = DEFAULT_DMA_HIGH_WATER; in tg3_init_bufmgr_config()
17449 switch (tp->phy_id & TG3_PHY_ID_MASK) { in tg3_phy_string()
17509 strcat(str, ":32-bit"); in tg3_bus_string()
17511 strcat(str, ":64-bit"); in tg3_bus_string()
17517 struct ethtool_coalesce *ec = &tp->coal; in tg3_init_coal()
17520 ec->cmd = ETHTOOL_GCOALESCE; in tg3_init_coal()
17521 ec->rx_coalesce_usecs = LOW_RXCOL_TICKS; in tg3_init_coal()
17522 ec->tx_coalesce_usecs = LOW_TXCOL_TICKS; in tg3_init_coal()
17523 ec->rx_max_coalesced_frames = LOW_RXMAX_FRAMES; in tg3_init_coal()
17524 ec->tx_max_coalesced_frames = LOW_TXMAX_FRAMES; in tg3_init_coal()
17525 ec->rx_coalesce_usecs_irq = DEFAULT_RXCOAL_TICK_INT; in tg3_init_coal()
17526 ec->tx_coalesce_usecs_irq = DEFAULT_TXCOAL_TICK_INT; in tg3_init_coal()
17527 ec->rx_max_coalesced_frames_irq = DEFAULT_RXCOAL_MAXF_INT; in tg3_init_coal()
17528 ec->tx_max_coalesced_frames_irq = DEFAULT_TXCOAL_MAXF_INT; in tg3_init_coal()
17529 ec->stats_block_coalesce_usecs = DEFAULT_STAT_COAL_TICKS; in tg3_init_coal()
17531 if (tp->coalesce_mode & (HOSTCC_MODE_CLRTICK_RXBD | in tg3_init_coal()
17533 ec->rx_coalesce_usecs = LOW_RXCOL_TICKS_CLRTCKS; in tg3_init_coal()
17534 ec->rx_coalesce_usecs_irq = DEFAULT_RXCOAL_TICK_INT_CLRTCKS; in tg3_init_coal()
17535 ec->tx_coalesce_usecs = LOW_TXCOL_TICKS_CLRTCKS; in tg3_init_coal()
17536 ec->tx_coalesce_usecs_irq = DEFAULT_TXCOAL_TICK_INT_CLRTCKS; in tg3_init_coal()
17540 ec->rx_coalesce_usecs_irq = 0; in tg3_init_coal()
17541 ec->tx_coalesce_usecs_irq = 0; in tg3_init_coal()
17542 ec->stats_block_coalesce_usecs = 0; in tg3_init_coal()
17560 dev_err(&pdev->dev, "Cannot enable PCI device, aborting\n"); in tg3_init_one()
17566 dev_err(&pdev->dev, "Cannot obtain PCI resources, aborting\n"); in tg3_init_one()
17574 err = -ENOMEM; in tg3_init_one()
17578 SET_NETDEV_DEV(dev, &pdev->dev); in tg3_init_one()
17581 tp->pdev = pdev; in tg3_init_one()
17582 tp->dev = dev; in tg3_init_one()
17583 tp->rx_mode = TG3_DEF_RX_MODE; in tg3_init_one()
17584 tp->tx_mode = TG3_DEF_TX_MODE; in tg3_init_one()
17585 tp->irq_sync = 1; in tg3_init_one()
17586 tp->pcierr_recovery = false; in tg3_init_one()
17589 tp->msg_enable = tg3_debug; in tg3_init_one()
17591 tp->msg_enable = TG3_DEF_MSG_ENABLE; in tg3_init_one()
17611 tp->misc_host_ctrl = in tg3_init_one()
17617 /* The NONFRM (non-frame) byte/word swap controls take effect in tg3_init_one()
17621 * are running in big-endian mode. in tg3_init_one()
17623 tp->grc_mode = (GRC_MODE_WSWAP_DATA | GRC_MODE_BSWAP_DATA | in tg3_init_one()
17626 tp->grc_mode |= GRC_MODE_BSWAP_NONFRM_DATA; in tg3_init_one()
17628 spin_lock_init(&tp->lock); in tg3_init_one()
17629 spin_lock_init(&tp->indirect_lock); in tg3_init_one()
17630 INIT_WORK(&tp->reset_task, tg3_reset_task); in tg3_init_one()
17632 tp->regs = pci_ioremap_bar(pdev, BAR_0); in tg3_init_one()
17633 if (!tp->regs) { in tg3_init_one()
17634 dev_err(&pdev->dev, "Cannot map device registers, aborting\n"); in tg3_init_one()
17635 err = -ENOMEM; in tg3_init_one()
17639 if (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5761 || in tg3_init_one()
17640 tp->pdev->device == PCI_DEVICE_ID_TIGON3_5761E || in tg3_init_one()
17641 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5761S || in tg3_init_one()
17642 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5761SE || in tg3_init_one()
17643 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5717 || in tg3_init_one()
17644 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5717_C || in tg3_init_one()
17645 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718 || in tg3_init_one()
17646 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5719 || in tg3_init_one()
17647 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5720 || in tg3_init_one()
17648 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57767 || in tg3_init_one()
17649 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57764 || in tg3_init_one()
17650 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5762 || in tg3_init_one()
17651 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5725 || in tg3_init_one()
17652 tp->pdev->device == TG3PCI_DEVICE_TIGON3_5727 || in tg3_init_one()
17653 tp->pdev->device == TG3PCI_DEVICE_TIGON3_57787) { in tg3_init_one()
17655 tp->aperegs = pci_ioremap_bar(pdev, BAR_2); in tg3_init_one()
17656 if (!tp->aperegs) { in tg3_init_one()
17657 dev_err(&pdev->dev, in tg3_init_one()
17659 err = -ENOMEM; in tg3_init_one()
17664 tp->rx_pending = TG3_DEF_RX_RING_PENDING; in tg3_init_one()
17665 tp->rx_jumbo_pending = TG3_DEF_RX_JUMBO_RING_PENDING; in tg3_init_one()
17667 dev->ethtool_ops = &tg3_ethtool_ops; in tg3_init_one()
17668 dev->watchdog_timeo = TG3_TX_TIMEOUT; in tg3_init_one()
17669 dev->netdev_ops = &tg3_netdev_ops; in tg3_init_one()
17670 dev->irq = pdev->irq; in tg3_init_one()
17674 dev_err(&pdev->dev, in tg3_init_one()
17680 * device behind the EPB cannot support DMA addresses > 40-bit. in tg3_init_one()
17681 * On 64-bit systems with IOMMU, use 40-bit dma_mask. in tg3_init_one()
17682 * On 64-bit systems without IOMMU, use 64-bit dma_mask and in tg3_init_one()
17697 err = dma_set_mask(&pdev->dev, dma_mask); in tg3_init_one()
17700 err = dma_set_coherent_mask(&pdev->dev, in tg3_init_one()
17703 dev_err(&pdev->dev, "Unable to obtain 64 bit " in tg3_init_one()
17710 err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); in tg3_init_one()
17712 dev_err(&pdev->dev, in tg3_init_one()
17751 dev->features |= features | NETIF_F_HW_VLAN_CTAG_TX | in tg3_init_one()
17753 dev->vlan_features |= features; in tg3_init_one()
17757 * MAC-LOOPBACK. Eventually this need to be enhanced to allow INT-PHY in tg3_init_one()
17765 dev->hw_features |= features; in tg3_init_one()
17766 dev->priv_flags |= IFF_UNICAST_FLT; in tg3_init_one()
17768 /* MTU range: 60 - 9000 or 1500, depending on hardware */ in tg3_init_one()
17769 dev->min_mtu = TG3_MIN_MTU; in tg3_init_one()
17770 dev->max_mtu = TG3_MAX_MTU(tp); in tg3_init_one()
17776 tp->rx_pending = 63; in tg3_init_one()
17781 dev_err(&pdev->dev, in tg3_init_one()
17790 for (i = 0; i < tp->irq_max; i++) { in tg3_init_one()
17791 struct tg3_napi *tnapi = &tp->napi[i]; in tg3_init_one()
17793 tnapi->tp = tp; in tg3_init_one()
17794 tnapi->tx_pending = TG3_DEF_TX_RING_PENDING; in tg3_init_one()
17796 tnapi->int_mbox = intmbx; in tg3_init_one()
17799 tnapi->consmbox = rcvmbx; in tg3_init_one()
17800 tnapi->prodmbox = sndmbx; in tg3_init_one()
17803 tnapi->coal_now = HOSTCC_MODE_COAL_VEC1_NOW << (i - 1); in tg3_init_one()
17805 tnapi->coal_now = HOSTCC_MODE_NOW; in tg3_init_one()
17823 sndmbx -= 0x4; in tg3_init_one()
17843 dev_err(&pdev->dev, "DMA engine test failed, aborting\n"); in tg3_init_one()
17862 dev_err(&pdev->dev, "Cannot register net device, aborting\n"); in tg3_init_one()
17868 tp->ptp_clock = ptp_clock_register(&tp->ptp_info, in tg3_init_one()
17869 &tp->pdev->dev); in tg3_init_one()
17870 if (IS_ERR(tp->ptp_clock)) in tg3_init_one()
17871 tp->ptp_clock = NULL; in tg3_init_one()
17875 tp->board_part_number, in tg3_init_one()
17878 dev->dev_addr); in tg3_init_one()
17880 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) { in tg3_init_one()
17883 if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY) in tg3_init_one()
17884 ethtype = "10/100Base-TX"; in tg3_init_one()
17885 else if (tp->phy_flags & TG3_PHYFLG_ANY_SERDES) in tg3_init_one()
17886 ethtype = "1000Base-SX"; in tg3_init_one()
17888 ethtype = "10/100/1000Base-T"; in tg3_init_one()
17893 (tp->phy_flags & TG3_PHYFLG_NO_ETH_WIRE_SPEED) == 0, in tg3_init_one()
17894 (tp->phy_flags & TG3_PHYFLG_EEE_CAP) != 0); in tg3_init_one()
17898 (dev->features & NETIF_F_RXCSUM) != 0, in tg3_init_one()
17900 (tp->phy_flags & TG3_PHYFLG_USE_MI_INTERRUPT) != 0, in tg3_init_one()
17903 netdev_info(dev, "dma_rwctrl[%08x] dma_mask[%d-bit]\n", in tg3_init_one()
17904 tp->dma_rwctrl, in tg3_init_one()
17905 pdev->dma_mask == DMA_BIT_MASK(32) ? 32 : in tg3_init_one()
17906 ((u64)pdev->dma_mask) == DMA_BIT_MASK(40) ? 40 : 64); in tg3_init_one()
17913 if (tp->aperegs) { in tg3_init_one()
17914 iounmap(tp->aperegs); in tg3_init_one()
17915 tp->aperegs = NULL; in tg3_init_one()
17919 if (tp->regs) { in tg3_init_one()
17920 iounmap(tp->regs); in tg3_init_one()
17921 tp->regs = NULL; in tg3_init_one()
17945 release_firmware(tp->fw); in tg3_remove_one()
17955 if (tp->aperegs) { in tg3_remove_one()
17956 iounmap(tp->aperegs); in tg3_remove_one()
17957 tp->aperegs = NULL; in tg3_remove_one()
17959 if (tp->regs) { in tg3_remove_one()
17960 iounmap(tp->regs); in tg3_remove_one()
17961 tp->regs = NULL; in tg3_remove_one()
18045 !(tp->phy_flags & TG3_PHYFLG_KEEP_LINK_ON_PWRDN)); in tg3_resume()
18089 * tg3_io_error_detected - called when PCI error is detected
18111 if (!netdev || tp->pcierr_recovery || !netif_running(netdev)) in tg3_io_error_detected()
18116 tp->pcierr_recovery = true; in tg3_io_error_detected()
18148 * tg3_io_slot_reset - called after the pci bus has been reset.
18151 * Restart the card from scratch, as if from a cold-boot.
18166 dev_err(&pdev->dev, in tg3_io_slot_reset()
18167 "Cannot re-enable PCI device after reset.\n"); in tg3_io_slot_reset()
18197 * tg3_io_resume - called when traffic can start flowing again.
18235 tp->pcierr_recovery = false; in tg3_io_resume()