• Home
  • Raw
  • Download

Lines Matching full:nic

537 struct nic {  struct
542 u16 (*mdio_ctrl)(struct nic *nic, u32 addr, u32 dir, u32 reg, u16 data); argument
606 static inline void e100_write_flush(struct nic *nic) in e100_write_flush() argument
610 (void)ioread8(&nic->csr->scb.status); in e100_write_flush()
613 static void e100_enable_irq(struct nic *nic) in e100_enable_irq() argument
617 spin_lock_irqsave(&nic->cmd_lock, flags); in e100_enable_irq()
618 iowrite8(irq_mask_none, &nic->csr->scb.cmd_hi); in e100_enable_irq()
619 e100_write_flush(nic); in e100_enable_irq()
620 spin_unlock_irqrestore(&nic->cmd_lock, flags); in e100_enable_irq()
623 static void e100_disable_irq(struct nic *nic) in e100_disable_irq() argument
627 spin_lock_irqsave(&nic->cmd_lock, flags); in e100_disable_irq()
628 iowrite8(irq_mask_all, &nic->csr->scb.cmd_hi); in e100_disable_irq()
629 e100_write_flush(nic); in e100_disable_irq()
630 spin_unlock_irqrestore(&nic->cmd_lock, flags); in e100_disable_irq()
633 static void e100_hw_reset(struct nic *nic) in e100_hw_reset() argument
637 iowrite32(selective_reset, &nic->csr->port); in e100_hw_reset()
638 e100_write_flush(nic); udelay(20); in e100_hw_reset()
641 iowrite32(software_reset, &nic->csr->port); in e100_hw_reset()
642 e100_write_flush(nic); udelay(20); in e100_hw_reset()
645 e100_disable_irq(nic); in e100_hw_reset()
648 static int e100_self_test(struct nic *nic) in e100_self_test() argument
650 u32 dma_addr = nic->dma_addr + offsetof(struct mem, selftest); in e100_self_test()
655 nic->mem->selftest.signature = 0; in e100_self_test()
656 nic->mem->selftest.result = 0xFFFFFFFF; in e100_self_test()
658 iowrite32(selftest | dma_addr, &nic->csr->port); in e100_self_test()
659 e100_write_flush(nic); in e100_self_test()
664 e100_disable_irq(nic); in e100_self_test()
667 if (nic->mem->selftest.result != 0) { in e100_self_test()
668 netif_err(nic, hw, nic->netdev, in e100_self_test()
670 nic->mem->selftest.result); in e100_self_test()
673 if (nic->mem->selftest.signature == 0) { in e100_self_test()
674 netif_err(nic, hw, nic->netdev, "Self-test failed: timed out\n"); in e100_self_test()
681 static void e100_eeprom_write(struct nic *nic, u16 addr_len, u16 addr, __le16 data) in e100_eeprom_write() argument
697 iowrite8(eecs | eesk, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_write()
698 e100_write_flush(nic); udelay(4); in e100_eeprom_write()
703 iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_write()
704 e100_write_flush(nic); udelay(4); in e100_eeprom_write()
706 iowrite8(ctrl | eesk, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_write()
707 e100_write_flush(nic); udelay(4); in e100_eeprom_write()
713 iowrite8(0, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_write()
714 e100_write_flush(nic); udelay(4); in e100_eeprom_write()
719 static __le16 e100_eeprom_read(struct nic *nic, u16 *addr_len, u16 addr) in e100_eeprom_read() argument
729 iowrite8(eecs | eesk, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_read()
730 e100_write_flush(nic); udelay(4); in e100_eeprom_read()
735 iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_read()
736 e100_write_flush(nic); udelay(4); in e100_eeprom_read()
738 iowrite8(ctrl | eesk, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_read()
739 e100_write_flush(nic); udelay(4); in e100_eeprom_read()
743 ctrl = ioread8(&nic->csr->eeprom_ctrl_lo); in e100_eeprom_read()
753 iowrite8(0, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_read()
754 e100_write_flush(nic); udelay(4); in e100_eeprom_read()
760 static int e100_eeprom_load(struct nic *nic) in e100_eeprom_load() argument
765 e100_eeprom_read(nic, &addr_len, 0); in e100_eeprom_load()
766 nic->eeprom_wc = 1 << addr_len; in e100_eeprom_load()
768 for (addr = 0; addr < nic->eeprom_wc; addr++) { in e100_eeprom_load()
769 nic->eeprom[addr] = e100_eeprom_read(nic, &addr_len, addr); in e100_eeprom_load()
770 if (addr < nic->eeprom_wc - 1) in e100_eeprom_load()
771 checksum += le16_to_cpu(nic->eeprom[addr]); in e100_eeprom_load()
776 if (cpu_to_le16(0xBABA - checksum) != nic->eeprom[nic->eeprom_wc - 1]) { in e100_eeprom_load()
777 netif_err(nic, probe, nic->netdev, "EEPROM corrupted\n"); in e100_eeprom_load()
786 static int e100_eeprom_save(struct nic *nic, u16 start, u16 count) in e100_eeprom_save() argument
791 e100_eeprom_read(nic, &addr_len, 0); in e100_eeprom_save()
792 nic->eeprom_wc = 1 << addr_len; in e100_eeprom_save()
794 if (start + count >= nic->eeprom_wc) in e100_eeprom_save()
798 e100_eeprom_write(nic, addr_len, addr, nic->eeprom[addr]); in e100_eeprom_save()
802 for (addr = 0; addr < nic->eeprom_wc - 1; addr++) in e100_eeprom_save()
803 checksum += le16_to_cpu(nic->eeprom[addr]); in e100_eeprom_save()
804 nic->eeprom[nic->eeprom_wc - 1] = cpu_to_le16(0xBABA - checksum); in e100_eeprom_save()
805 e100_eeprom_write(nic, addr_len, nic->eeprom_wc - 1, in e100_eeprom_save()
806 nic->eeprom[nic->eeprom_wc - 1]); in e100_eeprom_save()
813 static int e100_exec_cmd(struct nic *nic, u8 cmd, dma_addr_t dma_addr) in e100_exec_cmd() argument
819 spin_lock_irqsave(&nic->cmd_lock, flags); in e100_exec_cmd()
823 if (likely(!ioread8(&nic->csr->scb.cmd_lo))) in e100_exec_cmd()
835 iowrite32(dma_addr, &nic->csr->scb.gen_ptr); in e100_exec_cmd()
836 iowrite8(cmd, &nic->csr->scb.cmd_lo); in e100_exec_cmd()
839 spin_unlock_irqrestore(&nic->cmd_lock, flags); in e100_exec_cmd()
844 static int e100_exec_cb(struct nic *nic, struct sk_buff *skb, in e100_exec_cb() argument
845 int (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *)) in e100_exec_cb() argument
851 spin_lock_irqsave(&nic->cb_lock, flags); in e100_exec_cb()
853 if (unlikely(!nic->cbs_avail)) { in e100_exec_cb()
858 cb = nic->cb_to_use; in e100_exec_cb()
859 nic->cb_to_use = cb->next; in e100_exec_cb()
860 nic->cbs_avail--; in e100_exec_cb()
863 err = cb_prepare(nic, cb, skb); in e100_exec_cb()
867 if (unlikely(!nic->cbs_avail)) in e100_exec_cb()
877 while (nic->cb_to_send != nic->cb_to_use) { in e100_exec_cb()
878 if (unlikely(e100_exec_cmd(nic, nic->cuc_cmd, in e100_exec_cb()
879 nic->cb_to_send->dma_addr))) { in e100_exec_cb()
887 schedule_work(&nic->tx_timeout_task); in e100_exec_cb()
891 nic->cuc_cmd = cuc_resume; in e100_exec_cb()
892 nic->cb_to_send = nic->cb_to_send->next; in e100_exec_cb()
897 spin_unlock_irqrestore(&nic->cb_lock, flags); in e100_exec_cb()
904 struct nic *nic = netdev_priv(netdev); in mdio_read() local
905 return nic->mdio_ctrl(nic, addr, mdi_read, reg, 0); in mdio_read()
910 struct nic *nic = netdev_priv(netdev); in mdio_write() local
912 nic->mdio_ctrl(nic, addr, mdi_write, reg, data); in mdio_write()
916 static u16 mdio_ctrl_hw(struct nic *nic, u32 addr, u32 dir, u32 reg, u16 data) in mdio_ctrl_hw() argument
929 spin_lock_irqsave(&nic->mdio_lock, flags); in mdio_ctrl_hw()
931 if (ioread32(&nic->csr->mdi_ctrl) & mdi_ready) in mdio_ctrl_hw()
936 netdev_err(nic->netdev, "e100.mdio_ctrl won't go Ready\n"); in mdio_ctrl_hw()
937 spin_unlock_irqrestore(&nic->mdio_lock, flags); in mdio_ctrl_hw()
940 iowrite32((reg << 16) | (addr << 21) | dir | data, &nic->csr->mdi_ctrl); in mdio_ctrl_hw()
944 if ((data_out = ioread32(&nic->csr->mdi_ctrl)) & mdi_ready) in mdio_ctrl_hw()
947 spin_unlock_irqrestore(&nic->mdio_lock, flags); in mdio_ctrl_hw()
948 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, in mdio_ctrl_hw()
956 static u16 mdio_ctrl_phy_82552_v(struct nic *nic, in mdio_ctrl_phy_82552_v() argument
964 u16 advert = mdio_read(nic->netdev, nic->mii.phy_id, in mdio_ctrl_phy_82552_v()
977 return mdio_ctrl_hw(nic, addr, dir, reg, data); in mdio_ctrl_phy_82552_v()
986 static u16 mdio_ctrl_phy_mii_emulated(struct nic *nic, in mdio_ctrl_phy_mii_emulated() argument
1011 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, in mdio_ctrl_phy_mii_emulated()
1020 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, in mdio_ctrl_phy_mii_emulated()
1028 static inline int e100_phy_supports_mii(struct nic *nic) in e100_phy_supports_mii() argument
1033 return (nic->mdio_ctrl != mdio_ctrl_phy_mii_emulated); in e100_phy_supports_mii()
1036 static void e100_get_defaults(struct nic *nic) in e100_get_defaults() argument
1042 nic->mac = (nic->flags & ich) ? mac_82559_D101M : nic->pdev->revision; in e100_get_defaults()
1043 if (nic->mac == mac_unknown) in e100_get_defaults()
1044 nic->mac = mac_82557_D100_A; in e100_get_defaults()
1046 nic->params.rfds = rfds; in e100_get_defaults()
1047 nic->params.cbs = cbs; in e100_get_defaults()
1050 nic->tx_threshold = 0xE0; in e100_get_defaults()
1053 nic->tx_command = cpu_to_le16(cb_tx | cb_tx_sf | in e100_get_defaults()
1054 ((nic->mac >= mac_82558_D101_A4) ? cb_cid : cb_i)); in e100_get_defaults()
1057 nic->blank_rfd.command = 0; in e100_get_defaults()
1058 nic->blank_rfd.rbd = cpu_to_le32(0xFFFFFFFF); in e100_get_defaults()
1059 nic->blank_rfd.size = cpu_to_le16(VLAN_ETH_FRAME_LEN + ETH_FCS_LEN); in e100_get_defaults()
1062 nic->mii.phy_id_mask = 0x1F; in e100_get_defaults()
1063 nic->mii.reg_num_mask = 0x1F; in e100_get_defaults()
1064 nic->mii.dev = nic->netdev; in e100_get_defaults()
1065 nic->mii.mdio_read = mdio_read; in e100_get_defaults()
1066 nic->mii.mdio_write = mdio_write; in e100_get_defaults()
1069 static int e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb) in e100_configure() argument
1073 struct net_device *netdev = nic->netdev; in e100_configure()
1086 if (e100_phy_supports_mii(nic)) in e100_configure()
1105 config->adaptive_ifs = nic->adaptive_ifs; in e100_configure()
1106 config->loopback = nic->loopback; in e100_configure()
1108 if (nic->mii.force_media && nic->mii.full_duplex) in e100_configure()
1111 if (nic->flags & promiscuous || nic->loopback) { in e100_configure()
1120 if (nic->flags & multicast_all) in e100_configure()
1124 if (netif_running(nic->netdev) || !(nic->flags & wol_magic)) in e100_configure()
1127 if (nic->mac >= mac_82558_D101_A4) { in e100_configure()
1132 if (nic->mac >= mac_82559_D101M) { in e100_configure()
1135 if (nic->mac >= mac_82551_10) { in e100_configure()
1150 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, "[00-07]=%8ph\n", in e100_configure()
1152 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, "[08-15]=%8ph\n", in e100_configure()
1154 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, "[16-23]=%8ph\n", in e100_configure()
1219 static const struct firmware *e100_request_firmware(struct nic *nic) in e100_request_firmware() argument
1222 const struct firmware *fw = nic->fw; in e100_request_firmware()
1228 if (nic->flags & ich) in e100_request_firmware()
1244 if (nic->mac == mac_82559_D101M) { in e100_request_firmware()
1246 } else if (nic->mac == mac_82559_D101S) { in e100_request_firmware()
1248 } else if (nic->mac == mac_82551_F || nic->mac == mac_82551_10) { in e100_request_firmware()
1261 err = request_firmware(&fw, fw_name, &nic->pdev->dev); in e100_request_firmware()
1265 netif_err(nic, probe, nic->netdev, in e100_request_firmware()
1270 netif_info(nic, probe, nic->netdev, in e100_request_firmware()
1280 netif_err(nic, probe, nic->netdev, in e100_request_firmware()
1294 netif_err(nic, probe, nic->netdev, in e100_request_firmware()
1302 * to it in the nic */ in e100_request_firmware()
1303 nic->fw = fw; in e100_request_firmware()
1307 static int e100_setup_ucode(struct nic *nic, struct cb *cb, in e100_setup_ucode() argument
1337 static inline int e100_load_ucode_wait(struct nic *nic) in e100_load_ucode_wait() argument
1341 struct cb *cb = nic->cb_to_clean; in e100_load_ucode_wait()
1343 fw = e100_request_firmware(nic); in e100_load_ucode_wait()
1348 if ((err = e100_exec_cb(nic, (void *)fw, e100_setup_ucode))) in e100_load_ucode_wait()
1349 netif_err(nic, probe, nic->netdev, in e100_load_ucode_wait()
1353 nic->cuc_cmd = cuc_start; in e100_load_ucode_wait()
1356 e100_write_flush(nic); in e100_load_ucode_wait()
1366 iowrite8(~0, &nic->csr->scb.stat_ack); in e100_load_ucode_wait()
1370 netif_err(nic, probe, nic->netdev, "ucode load failed\n"); in e100_load_ucode_wait()
1377 static int e100_setup_iaaddr(struct nic *nic, struct cb *cb, in e100_setup_iaaddr() argument
1381 memcpy(cb->u.iaaddr, nic->netdev->dev_addr, ETH_ALEN); in e100_setup_iaaddr()
1385 static int e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb) in e100_dump() argument
1388 cb->u.dump_buffer_addr = cpu_to_le32(nic->dma_addr + in e100_dump()
1393 static int e100_phy_check_without_mii(struct nic *nic) in e100_phy_check_without_mii() argument
1398 phy_type = (le16_to_cpu(nic->eeprom[eeprom_phy_iface]) >> 8) & 0x0f; in e100_phy_check_without_mii()
1410 netif_info(nic, probe, nic->netdev, in e100_phy_check_without_mii()
1413 nic->mdio_ctrl = mdio_ctrl_phy_mii_emulated; in e100_phy_check_without_mii()
1414 nic->mii.phy_id = 0; /* is this ok for an MII-less PHY? */ in e100_phy_check_without_mii()
1417 * nic->flags |= ich; in e100_phy_check_without_mii()
1418 * nic->flags |= ich_10h_workaround; */ in e100_phy_check_without_mii()
1434 static int e100_phy_init(struct nic *nic) in e100_phy_init() argument
1436 struct net_device *netdev = nic->netdev; in e100_phy_init()
1442 nic->mii.phy_id = (addr == 0) ? 1 : (addr == 1) ? 0 : addr; in e100_phy_init()
1443 bmcr = mdio_read(netdev, nic->mii.phy_id, MII_BMCR); in e100_phy_init()
1444 stat = mdio_read(netdev, nic->mii.phy_id, MII_BMSR); in e100_phy_init()
1445 stat = mdio_read(netdev, nic->mii.phy_id, MII_BMSR); in e100_phy_init()
1454 if (e100_phy_check_without_mii(nic)) in e100_phy_init()
1458 netif_err(nic, hw, nic->netdev, in e100_phy_init()
1463 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, in e100_phy_init()
1464 "phy_addr = %d\n", nic->mii.phy_id); in e100_phy_init()
1467 id_lo = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID1); in e100_phy_init()
1468 id_hi = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID2); in e100_phy_init()
1469 nic->phy = (u32)id_hi << 16 | (u32)id_lo; in e100_phy_init()
1470 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, in e100_phy_init()
1471 "phy ID = 0x%08X\n", nic->phy); in e100_phy_init()
1475 if (addr != nic->mii.phy_id) { in e100_phy_init()
1477 } else if (nic->phy != phy_82552_v) { in e100_phy_init()
1488 if (nic->phy == phy_82552_v) in e100_phy_init()
1489 mdio_write(netdev, nic->mii.phy_id, MII_BMCR, in e100_phy_init()
1494 if ((nic->phy & NCS_PHY_MODEL_MASK) == phy_nsc_tx) { in e100_phy_init()
1496 cong = mdio_read(netdev, nic->mii.phy_id, MII_NSC_CONG); in e100_phy_init()
1499 mdio_write(netdev, nic->mii.phy_id, MII_NSC_CONG, cong); in e100_phy_init()
1502 if (nic->phy == phy_82552_v) { in e100_phy_init()
1503 u16 advert = mdio_read(netdev, nic->mii.phy_id, MII_ADVERTISE); in e100_phy_init()
1506 nic->mdio_ctrl = mdio_ctrl_phy_82552_v; in e100_phy_init()
1510 mdio_write(netdev, nic->mii.phy_id, MII_ADVERTISE, advert); in e100_phy_init()
1513 bmcr = mdio_read(netdev, nic->mii.phy_id, MII_BMCR); in e100_phy_init()
1515 mdio_write(netdev, nic->mii.phy_id, MII_BMCR, bmcr); in e100_phy_init()
1516 } else if ((nic->mac >= mac_82550_D102) || ((nic->flags & ich) && in e100_phy_init()
1517 (mdio_read(netdev, nic->mii.phy_id, MII_TPISTATUS) & 0x8000) && in e100_phy_init()
1518 (le16_to_cpu(nic->eeprom[eeprom_cnfg_mdix]) & eeprom_mdix_enabled))) { in e100_phy_init()
1520 mdio_write(netdev, nic->mii.phy_id, MII_NCONFIG, in e100_phy_init()
1521 nic->mii.force_media ? 0 : NCONFIG_AUTO_SWITCH); in e100_phy_init()
1527 static int e100_hw_init(struct nic *nic) in e100_hw_init() argument
1531 e100_hw_reset(nic); in e100_hw_init()
1533 netif_err(nic, hw, nic->netdev, "e100_hw_init\n"); in e100_hw_init()
1534 if ((err = e100_self_test(nic))) in e100_hw_init()
1537 if ((err = e100_phy_init(nic))) in e100_hw_init()
1539 if ((err = e100_exec_cmd(nic, cuc_load_base, 0))) in e100_hw_init()
1541 if ((err = e100_exec_cmd(nic, ruc_load_base, 0))) in e100_hw_init()
1543 if ((err = e100_load_ucode_wait(nic))) in e100_hw_init()
1545 if ((err = e100_exec_cb(nic, NULL, e100_configure))) in e100_hw_init()
1547 if ((err = e100_exec_cb(nic, NULL, e100_setup_iaaddr))) in e100_hw_init()
1549 if ((err = e100_exec_cmd(nic, cuc_dump_addr, in e100_hw_init()
1550 nic->dma_addr + offsetof(struct mem, stats)))) in e100_hw_init()
1552 if ((err = e100_exec_cmd(nic, cuc_dump_reset, 0))) in e100_hw_init()
1555 e100_disable_irq(nic); in e100_hw_init()
1560 static int e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb) in e100_multi() argument
1562 struct net_device *netdev = nic->netdev; in e100_multi()
1580 struct nic *nic = netdev_priv(netdev); in e100_set_multicast_list() local
1582 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, in e100_set_multicast_list()
1587 nic->flags |= promiscuous; in e100_set_multicast_list()
1589 nic->flags &= ~promiscuous; in e100_set_multicast_list()
1593 nic->flags |= multicast_all; in e100_set_multicast_list()
1595 nic->flags &= ~multicast_all; in e100_set_multicast_list()
1597 e100_exec_cb(nic, NULL, e100_configure); in e100_set_multicast_list()
1598 e100_exec_cb(nic, NULL, e100_multi); in e100_set_multicast_list()
1601 static void e100_update_stats(struct nic *nic) in e100_update_stats() argument
1603 struct net_device *dev = nic->netdev; in e100_update_stats()
1605 struct stats *s = &nic->mem->stats; in e100_update_stats()
1606 __le32 *complete = (nic->mac < mac_82558_D101_A4) ? &s->fc_xmt_pause : in e100_update_stats()
1607 (nic->mac < mac_82559_D101M) ? (__le32 *)&s->xmt_tco_frames : in e100_update_stats()
1616 nic->tx_frames = le32_to_cpu(s->tx_good_frames); in e100_update_stats()
1617 nic->tx_collisions = le32_to_cpu(s->tx_total_collisions); in e100_update_stats()
1622 ns->collisions += nic->tx_collisions; in e100_update_stats()
1625 nic->rx_short_frame_errors += in e100_update_stats()
1627 ns->rx_length_errors = nic->rx_short_frame_errors + in e100_update_stats()
1628 nic->rx_over_length_errors; in e100_update_stats()
1638 nic->tx_deferred += le32_to_cpu(s->tx_deferred); in e100_update_stats()
1639 nic->tx_single_collisions += in e100_update_stats()
1641 nic->tx_multiple_collisions += in e100_update_stats()
1643 if (nic->mac >= mac_82558_D101_A4) { in e100_update_stats()
1644 nic->tx_fc_pause += le32_to_cpu(s->fc_xmt_pause); in e100_update_stats()
1645 nic->rx_fc_pause += le32_to_cpu(s->fc_rcv_pause); in e100_update_stats()
1646 nic->rx_fc_unsupported += in e100_update_stats()
1648 if (nic->mac >= mac_82559_D101M) { in e100_update_stats()
1649 nic->tx_tco_frames += in e100_update_stats()
1651 nic->rx_tco_frames += in e100_update_stats()
1658 if (e100_exec_cmd(nic, cuc_dump_reset, 0)) in e100_update_stats()
1659 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev, in e100_update_stats()
1663 static void e100_adjust_adaptive_ifs(struct nic *nic, int speed, int duplex) in e100_adjust_adaptive_ifs() argument
1669 u32 prev = nic->adaptive_ifs; in e100_adjust_adaptive_ifs()
1672 if ((nic->tx_frames / 32 < nic->tx_collisions) && in e100_adjust_adaptive_ifs()
1673 (nic->tx_frames > min_frames)) { in e100_adjust_adaptive_ifs()
1674 if (nic->adaptive_ifs < 60) in e100_adjust_adaptive_ifs()
1675 nic->adaptive_ifs += 5; in e100_adjust_adaptive_ifs()
1676 } else if (nic->tx_frames < min_frames) { in e100_adjust_adaptive_ifs()
1677 if (nic->adaptive_ifs >= 5) in e100_adjust_adaptive_ifs()
1678 nic->adaptive_ifs -= 5; in e100_adjust_adaptive_ifs()
1680 if (nic->adaptive_ifs != prev) in e100_adjust_adaptive_ifs()
1681 e100_exec_cb(nic, NULL, e100_configure); in e100_adjust_adaptive_ifs()
1687 struct nic *nic = from_timer(nic, t, watchdog); in e100_watchdog() local
1691 netif_printk(nic, timer, KERN_DEBUG, nic->netdev, in e100_watchdog()
1696 mii_ethtool_gset(&nic->mii, &cmd); in e100_watchdog()
1699 if (mii_link_ok(&nic->mii) && !netif_carrier_ok(nic->netdev)) { in e100_watchdog()
1700 netdev_info(nic->netdev, "NIC Link is Up %u Mbps %s Duplex\n", in e100_watchdog()
1703 } else if (!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) { in e100_watchdog()
1704 netdev_info(nic->netdev, "NIC Link is Down\n"); in e100_watchdog()
1707 mii_check_link(&nic->mii); in e100_watchdog()
1714 spin_lock_irq(&nic->cmd_lock); in e100_watchdog()
1715 iowrite8(ioread8(&nic->csr->scb.cmd_hi) | irq_sw_gen,&nic->csr->scb.cmd_hi); in e100_watchdog()
1716 e100_write_flush(nic); in e100_watchdog()
1717 spin_unlock_irq(&nic->cmd_lock); in e100_watchdog()
1719 e100_update_stats(nic); in e100_watchdog()
1720 e100_adjust_adaptive_ifs(nic, speed, cmd.duplex); in e100_watchdog()
1722 if (nic->mac <= mac_82557_D100_C) in e100_watchdog()
1724 e100_set_multicast_list(nic->netdev); in e100_watchdog()
1726 if (nic->flags & ich && speed == SPEED_10 && cmd.duplex == DUPLEX_HALF) in e100_watchdog()
1728 nic->flags |= ich_10h_workaround; in e100_watchdog()
1730 nic->flags &= ~ich_10h_workaround; in e100_watchdog()
1732 mod_timer(&nic->watchdog, in e100_watchdog()
1736 static int e100_xmit_prepare(struct nic *nic, struct cb *cb, in e100_xmit_prepare() argument
1740 cb->command = nic->tx_command; in e100_xmit_prepare()
1742 dma_addr = dma_map_single(&nic->pdev->dev, skb->data, skb->len, in e100_xmit_prepare()
1745 if (dma_mapping_error(&nic->pdev->dev, dma_addr)) in e100_xmit_prepare()
1758 if ((nic->cbs_avail & ~15) == nic->cbs_avail) in e100_xmit_prepare()
1762 cb->u.tcb.threshold = nic->tx_threshold; in e100_xmit_prepare()
1773 struct nic *nic = netdev_priv(netdev); in e100_xmit_frame() local
1776 if (nic->flags & ich_10h_workaround) { in e100_xmit_frame()
1780 if (e100_exec_cmd(nic, cuc_nop, 0)) in e100_xmit_frame()
1781 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev, in e100_xmit_frame()
1786 err = e100_exec_cb(nic, skb, e100_xmit_prepare); in e100_xmit_frame()
1791 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev, in e100_xmit_frame()
1797 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev, in e100_xmit_frame()
1806 static int e100_tx_clean(struct nic *nic) in e100_tx_clean() argument
1808 struct net_device *dev = nic->netdev; in e100_tx_clean()
1812 spin_lock(&nic->cb_lock); in e100_tx_clean()
1815 for (cb = nic->cb_to_clean; in e100_tx_clean()
1817 cb = nic->cb_to_clean = cb->next) { in e100_tx_clean()
1819 netif_printk(nic, tx_done, KERN_DEBUG, nic->netdev, in e100_tx_clean()
1821 (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)), in e100_tx_clean()
1828 dma_unmap_single(&nic->pdev->dev, in e100_tx_clean()
1837 nic->cbs_avail++; in e100_tx_clean()
1840 spin_unlock(&nic->cb_lock); in e100_tx_clean()
1843 if (unlikely(tx_cleaned && netif_queue_stopped(nic->netdev))) in e100_tx_clean()
1844 netif_wake_queue(nic->netdev); in e100_tx_clean()
1849 static void e100_clean_cbs(struct nic *nic) in e100_clean_cbs() argument
1851 if (nic->cbs) { in e100_clean_cbs()
1852 while (nic->cbs_avail != nic->params.cbs.count) { in e100_clean_cbs()
1853 struct cb *cb = nic->cb_to_clean; in e100_clean_cbs()
1855 dma_unmap_single(&nic->pdev->dev, in e100_clean_cbs()
1861 nic->cb_to_clean = nic->cb_to_clean->next; in e100_clean_cbs()
1862 nic->cbs_avail++; in e100_clean_cbs()
1864 dma_pool_free(nic->cbs_pool, nic->cbs, nic->cbs_dma_addr); in e100_clean_cbs()
1865 nic->cbs = NULL; in e100_clean_cbs()
1866 nic->cbs_avail = 0; in e100_clean_cbs()
1868 nic->cuc_cmd = cuc_start; in e100_clean_cbs()
1869 nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = in e100_clean_cbs()
1870 nic->cbs; in e100_clean_cbs()
1873 static int e100_alloc_cbs(struct nic *nic) in e100_alloc_cbs() argument
1876 unsigned int i, count = nic->params.cbs.count; in e100_alloc_cbs()
1878 nic->cuc_cmd = cuc_start; in e100_alloc_cbs()
1879 nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = NULL; in e100_alloc_cbs()
1880 nic->cbs_avail = 0; in e100_alloc_cbs()
1882 nic->cbs = dma_pool_zalloc(nic->cbs_pool, GFP_KERNEL, in e100_alloc_cbs()
1883 &nic->cbs_dma_addr); in e100_alloc_cbs()
1884 if (!nic->cbs) in e100_alloc_cbs()
1887 for (cb = nic->cbs, i = 0; i < count; cb++, i++) { in e100_alloc_cbs()
1888 cb->next = (i + 1 < count) ? cb + 1 : nic->cbs; in e100_alloc_cbs()
1889 cb->prev = (i == 0) ? nic->cbs + count - 1 : cb - 1; in e100_alloc_cbs()
1891 cb->dma_addr = nic->cbs_dma_addr + i * sizeof(struct cb); in e100_alloc_cbs()
1892 cb->link = cpu_to_le32(nic->cbs_dma_addr + in e100_alloc_cbs()
1896 nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = nic->cbs; in e100_alloc_cbs()
1897 nic->cbs_avail = count; in e100_alloc_cbs()
1902 static inline void e100_start_receiver(struct nic *nic, struct rx *rx) in e100_start_receiver() argument
1904 if (!nic->rxs) return; in e100_start_receiver()
1905 if (RU_SUSPENDED != nic->ru_running) return; in e100_start_receiver()
1908 if (!rx) rx = nic->rxs; in e100_start_receiver()
1912 e100_exec_cmd(nic, ruc_start, rx->dma_addr); in e100_start_receiver()
1913 nic->ru_running = RU_RUNNING; in e100_start_receiver()
1918 static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx) in e100_rx_alloc_skb() argument
1920 if (!(rx->skb = netdev_alloc_skb_ip_align(nic->netdev, RFD_BUF_LEN))) in e100_rx_alloc_skb()
1924 skb_copy_to_linear_data(rx->skb, &nic->blank_rfd, sizeof(struct rfd)); in e100_rx_alloc_skb()
1925 rx->dma_addr = dma_map_single(&nic->pdev->dev, rx->skb->data, in e100_rx_alloc_skb()
1928 if (dma_mapping_error(&nic->pdev->dev, rx->dma_addr)) { in e100_rx_alloc_skb()
1941 dma_sync_single_for_device(&nic->pdev->dev, in e100_rx_alloc_skb()
1950 static int e100_rx_indicate(struct nic *nic, struct rx *rx, in e100_rx_indicate() argument
1953 struct net_device *dev = nic->netdev; in e100_rx_indicate()
1963 dma_sync_single_for_cpu(&nic->pdev->dev, rx->dma_addr, in e100_rx_indicate()
1967 netif_printk(nic, rx_status, KERN_DEBUG, nic->netdev, in e100_rx_indicate()
1979 (RU_RUNNING == nic->ru_running)) in e100_rx_indicate()
1981 if (ioread8(&nic->csr->scb.status) & rus_no_res) in e100_rx_indicate()
1982 nic->ru_running = RU_SUSPENDED; in e100_rx_indicate()
1983 dma_sync_single_for_device(&nic->pdev->dev, rx->dma_addr, in e100_rx_indicate()
1997 dma_unmap_single(&nic->pdev->dev, rx->dma_addr, RFD_BUF_LEN, in e100_rx_indicate()
2007 (RU_RUNNING == nic->ru_running)) { in e100_rx_indicate()
2009 if (ioread8(&nic->csr->scb.status) & rus_no_res) in e100_rx_indicate()
2010 nic->ru_running = RU_SUSPENDED; in e100_rx_indicate()
2016 skb->protocol = eth_type_trans(skb, nic->netdev); in e100_rx_indicate()
2024 nic->rx_over_length_errors++; in e100_rx_indicate()
2033 nic->rx_over_length_errors++; in e100_rx_indicate()
2049 static void e100_rx_clean(struct nic *nic, unsigned int *work_done, in e100_rx_clean() argument
2058 for (rx = nic->rx_to_clean; rx->skb; rx = nic->rx_to_clean = rx->next) { in e100_rx_clean()
2059 err = e100_rx_indicate(nic, rx, work_done, work_to_do); in e100_rx_clean()
2072 if (-EAGAIN != err && RU_SUSPENDED == nic->ru_running) in e100_rx_clean()
2075 old_before_last_rx = nic->rx_to_use->prev->prev; in e100_rx_clean()
2079 for (rx = nic->rx_to_use; !rx->skb; rx = nic->rx_to_use = rx->next) { in e100_rx_clean()
2080 if (unlikely(e100_rx_alloc_skb(nic, rx))) in e100_rx_clean()
2084 new_before_last_rx = nic->rx_to_use->prev->prev; in e100_rx_clean()
2099 dma_sync_single_for_device(&nic->pdev->dev, in e100_rx_clean()
2108 dma_sync_single_for_device(&nic->pdev->dev, in e100_rx_clean()
2114 dma_sync_single_for_device(&nic->pdev->dev, in e100_rx_clean()
2122 iowrite8(stat_ack_rnr, &nic->csr->scb.stat_ack); in e100_rx_clean()
2123 e100_start_receiver(nic, nic->rx_to_clean); in e100_rx_clean()
2129 static void e100_rx_clean_list(struct nic *nic) in e100_rx_clean_list() argument
2132 unsigned int i, count = nic->params.rfds.count; in e100_rx_clean_list()
2134 nic->ru_running = RU_UNINITIALIZED; in e100_rx_clean_list()
2136 if (nic->rxs) { in e100_rx_clean_list()
2137 for (rx = nic->rxs, i = 0; i < count; rx++, i++) { in e100_rx_clean_list()
2139 dma_unmap_single(&nic->pdev->dev, in e100_rx_clean_list()
2145 kfree(nic->rxs); in e100_rx_clean_list()
2146 nic->rxs = NULL; in e100_rx_clean_list()
2149 nic->rx_to_use = nic->rx_to_clean = NULL; in e100_rx_clean_list()
2152 static int e100_rx_alloc_list(struct nic *nic) in e100_rx_alloc_list() argument
2155 unsigned int i, count = nic->params.rfds.count; in e100_rx_alloc_list()
2158 nic->rx_to_use = nic->rx_to_clean = NULL; in e100_rx_alloc_list()
2159 nic->ru_running = RU_UNINITIALIZED; in e100_rx_alloc_list()
2161 if (!(nic->rxs = kcalloc(count, sizeof(struct rx), GFP_KERNEL))) in e100_rx_alloc_list()
2164 for (rx = nic->rxs, i = 0; i < count; rx++, i++) { in e100_rx_alloc_list()
2165 rx->next = (i + 1 < count) ? rx + 1 : nic->rxs; in e100_rx_alloc_list()
2166 rx->prev = (i == 0) ? nic->rxs + count - 1 : rx - 1; in e100_rx_alloc_list()
2167 if (e100_rx_alloc_skb(nic, rx)) { in e100_rx_alloc_list()
2168 e100_rx_clean_list(nic); in e100_rx_alloc_list()
2179 rx = nic->rxs->prev->prev; in e100_rx_alloc_list()
2183 dma_sync_single_for_device(&nic->pdev->dev, rx->dma_addr, in e100_rx_alloc_list()
2186 nic->rx_to_use = nic->rx_to_clean = nic->rxs; in e100_rx_alloc_list()
2187 nic->ru_running = RU_SUSPENDED; in e100_rx_alloc_list()
2195 struct nic *nic = netdev_priv(netdev); in e100_intr() local
2196 u8 stat_ack = ioread8(&nic->csr->scb.stat_ack); in e100_intr()
2198 netif_printk(nic, intr, KERN_DEBUG, nic->netdev, in e100_intr()
2206 iowrite8(stat_ack, &nic->csr->scb.stat_ack); in e100_intr()
2210 nic->ru_running = RU_SUSPENDED; in e100_intr()
2212 if (likely(napi_schedule_prep(&nic->napi))) { in e100_intr()
2213 e100_disable_irq(nic); in e100_intr()
2214 __napi_schedule(&nic->napi); in e100_intr()
2222 struct nic *nic = container_of(napi, struct nic, napi); in e100_poll() local
2225 e100_rx_clean(nic, &work_done, budget); in e100_poll()
2226 e100_tx_clean(nic); in e100_poll()
2234 e100_enable_irq(nic); in e100_poll()
2242 struct nic *nic = netdev_priv(netdev); in e100_netpoll() local
2244 e100_disable_irq(nic); in e100_netpoll()
2245 e100_intr(nic->pdev->irq, netdev); in e100_netpoll()
2246 e100_tx_clean(nic); in e100_netpoll()
2247 e100_enable_irq(nic); in e100_netpoll()
2253 struct nic *nic = netdev_priv(netdev); in e100_set_mac_address() local
2260 e100_exec_cb(nic, NULL, e100_setup_iaaddr); in e100_set_mac_address()
2265 static int e100_asf(struct nic *nic) in e100_asf() argument
2268 return (nic->pdev->device >= 0x1050) && (nic->pdev->device <= 0x1057) && in e100_asf()
2269 (le16_to_cpu(nic->eeprom[eeprom_config_asf]) & eeprom_asf) && in e100_asf()
2270 !(le16_to_cpu(nic->eeprom[eeprom_config_asf]) & eeprom_gcl) && in e100_asf()
2271 ((le16_to_cpu(nic->eeprom[eeprom_smbus_addr]) & 0xFF) != 0xFE); in e100_asf()
2274 static int e100_up(struct nic *nic) in e100_up() argument
2278 if ((err = e100_rx_alloc_list(nic))) in e100_up()
2280 if ((err = e100_alloc_cbs(nic))) in e100_up()
2282 if ((err = e100_hw_init(nic))) in e100_up()
2284 e100_set_multicast_list(nic->netdev); in e100_up()
2285 e100_start_receiver(nic, NULL); in e100_up()
2286 mod_timer(&nic->watchdog, jiffies); in e100_up()
2287 if ((err = request_irq(nic->pdev->irq, e100_intr, IRQF_SHARED, in e100_up()
2288 nic->netdev->name, nic->netdev))) in e100_up()
2290 netif_wake_queue(nic->netdev); in e100_up()
2291 napi_enable(&nic->napi); in e100_up()
2294 e100_enable_irq(nic); in e100_up()
2298 del_timer_sync(&nic->watchdog); in e100_up()
2300 e100_clean_cbs(nic); in e100_up()
2302 e100_rx_clean_list(nic); in e100_up()
2306 static void e100_down(struct nic *nic) in e100_down() argument
2309 napi_disable(&nic->napi); in e100_down()
2310 netif_stop_queue(nic->netdev); in e100_down()
2311 e100_hw_reset(nic); in e100_down()
2312 free_irq(nic->pdev->irq, nic->netdev); in e100_down()
2313 del_timer_sync(&nic->watchdog); in e100_down()
2314 netif_carrier_off(nic->netdev); in e100_down()
2315 e100_clean_cbs(nic); in e100_down()
2316 e100_rx_clean_list(nic); in e100_down()
2321 struct nic *nic = netdev_priv(netdev); in e100_tx_timeout() local
2325 schedule_work(&nic->tx_timeout_task); in e100_tx_timeout()
2330 struct nic *nic = container_of(work, struct nic, tx_timeout_task); in e100_tx_timeout_task() local
2331 struct net_device *netdev = nic->netdev; in e100_tx_timeout_task()
2333 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev, in e100_tx_timeout_task()
2334 "scb.status=0x%02X\n", ioread8(&nic->csr->scb.status)); in e100_tx_timeout_task()
2344 static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode) in e100_loopback_test() argument
2354 if ((err = e100_rx_alloc_list(nic))) in e100_loopback_test()
2356 if ((err = e100_alloc_cbs(nic))) in e100_loopback_test()
2360 if (nic->flags & ich && loopback_mode == lb_phy) in e100_loopback_test()
2363 nic->loopback = loopback_mode; in e100_loopback_test()
2364 if ((err = e100_hw_init(nic))) in e100_loopback_test()
2368 mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, in e100_loopback_test()
2371 e100_start_receiver(nic, NULL); in e100_loopback_test()
2373 if (!(skb = netdev_alloc_skb(nic->netdev, ETH_DATA_LEN))) { in e100_loopback_test()
2379 e100_xmit_frame(skb, nic->netdev); in e100_loopback_test()
2383 dma_sync_single_for_cpu(&nic->pdev->dev, nic->rx_to_clean->dma_addr, in e100_loopback_test()
2386 if (memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd), in e100_loopback_test()
2391 mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, 0); in e100_loopback_test()
2392 nic->loopback = lb_none; in e100_loopback_test()
2393 e100_clean_cbs(nic); in e100_loopback_test()
2394 e100_hw_reset(nic); in e100_loopback_test()
2396 e100_rx_clean_list(nic); in e100_loopback_test()
2408 struct nic *nic = netdev_priv(netdev); in e100_get_link_ksettings() local
2410 mii_ethtool_get_link_ksettings(&nic->mii, cmd); in e100_get_link_ksettings()
2418 struct nic *nic = netdev_priv(netdev); in e100_set_link_ksettings() local
2421 mdio_write(netdev, nic->mii.phy_id, MII_BMCR, BMCR_RESET); in e100_set_link_ksettings()
2422 err = mii_ethtool_set_link_ksettings(&nic->mii, cmd); in e100_set_link_ksettings()
2423 e100_exec_cb(nic, NULL, e100_configure); in e100_set_link_ksettings()
2431 struct nic *nic = netdev_priv(netdev); in e100_get_drvinfo() local
2433 strlcpy(info->bus_info, pci_name(nic->pdev), in e100_get_drvinfo()
2440 struct nic *nic = netdev_priv(netdev); in e100_get_regs_len() local
2445 return (1 + E100_PHY_REGS) * sizeof(u32) + sizeof(nic->mem->dump_buf); in e100_get_regs_len()
2451 struct nic *nic = netdev_priv(netdev); in e100_get_regs() local
2455 regs->version = (1 << 24) | nic->pdev->revision; in e100_get_regs()
2456 buff[0] = ioread8(&nic->csr->scb.cmd_hi) << 24 | in e100_get_regs()
2457 ioread8(&nic->csr->scb.cmd_lo) << 16 | in e100_get_regs()
2458 ioread16(&nic->csr->scb.status); in e100_get_regs()
2464 buff[1 + i] = mdio_read(netdev, nic->mii.phy_id, in e100_get_regs()
2466 memset(nic->mem->dump_buf, 0, sizeof(nic->mem->dump_buf)); in e100_get_regs()
2467 e100_exec_cb(nic, NULL, e100_dump); in e100_get_regs()
2469 memcpy(&buff[1 + E100_PHY_REGS], nic->mem->dump_buf, in e100_get_regs()
2470 sizeof(nic->mem->dump_buf)); in e100_get_regs()
2475 struct nic *nic = netdev_priv(netdev); in e100_get_wol() local
2476 wol->supported = (nic->mac >= mac_82558_D101_A4) ? WAKE_MAGIC : 0; in e100_get_wol()
2477 wol->wolopts = (nic->flags & wol_magic) ? WAKE_MAGIC : 0; in e100_get_wol()
2482 struct nic *nic = netdev_priv(netdev); in e100_set_wol() local
2485 !device_can_wakeup(&nic->pdev->dev)) in e100_set_wol()
2489 nic->flags |= wol_magic; in e100_set_wol()
2491 nic->flags &= ~wol_magic; in e100_set_wol()
2493 device_set_wakeup_enable(&nic->pdev->dev, wol->wolopts); in e100_set_wol()
2495 e100_exec_cb(nic, NULL, e100_configure); in e100_set_wol()
2502 struct nic *nic = netdev_priv(netdev); in e100_get_msglevel() local
2503 return nic->msg_enable; in e100_get_msglevel()
2508 struct nic *nic = netdev_priv(netdev); in e100_set_msglevel() local
2509 nic->msg_enable = value; in e100_set_msglevel()
2514 struct nic *nic = netdev_priv(netdev); in e100_nway_reset() local
2515 return mii_nway_restart(&nic->mii); in e100_nway_reset()
2520 struct nic *nic = netdev_priv(netdev); in e100_get_link() local
2521 return mii_link_ok(&nic->mii); in e100_get_link()
2526 struct nic *nic = netdev_priv(netdev); in e100_get_eeprom_len() local
2527 return nic->eeprom_wc << 1; in e100_get_eeprom_len()
2534 struct nic *nic = netdev_priv(netdev); in e100_get_eeprom() local
2537 memcpy(bytes, &((u8 *)nic->eeprom)[eeprom->offset], eeprom->len); in e100_get_eeprom()
2545 struct nic *nic = netdev_priv(netdev); in e100_set_eeprom() local
2550 memcpy(&((u8 *)nic->eeprom)[eeprom->offset], bytes, eeprom->len); in e100_set_eeprom()
2552 return e100_eeprom_save(nic, eeprom->offset >> 1, in e100_set_eeprom()
2559 struct nic *nic = netdev_priv(netdev); in e100_get_ringparam() local
2560 struct param_range *rfds = &nic->params.rfds; in e100_get_ringparam()
2561 struct param_range *cbs = &nic->params.cbs; in e100_get_ringparam()
2572 struct nic *nic = netdev_priv(netdev); in e100_set_ringparam() local
2573 struct param_range *rfds = &nic->params.rfds; in e100_set_ringparam()
2574 struct param_range *cbs = &nic->params.cbs; in e100_set_ringparam()
2580 e100_down(nic); in e100_set_ringparam()
2585 netif_info(nic, drv, nic->netdev, "Ring Param settings: rx: %d, tx %d\n", in e100_set_ringparam()
2588 e100_up(nic); in e100_set_ringparam()
2606 struct nic *nic = netdev_priv(netdev); in e100_diag_test() local
2610 data[0] = !mii_link_ok(&nic->mii); in e100_diag_test()
2611 data[1] = e100_eeprom_load(nic); in e100_diag_test()
2615 mii_ethtool_gset(&nic->mii, &cmd); in e100_diag_test()
2618 e100_down(nic); in e100_diag_test()
2619 data[2] = e100_self_test(nic); in e100_diag_test()
2620 data[3] = e100_loopback_test(nic, lb_mac); in e100_diag_test()
2621 data[4] = e100_loopback_test(nic, lb_phy); in e100_diag_test()
2624 mii_ethtool_sset(&nic->mii, &cmd); in e100_diag_test()
2627 e100_up(nic); in e100_diag_test()
2638 struct nic *nic = netdev_priv(netdev); in e100_set_phys_id() local
2645 u16 led_reg = (nic->phy == phy_82552_v) ? E100_82552_LED_OVERRIDE : in e100_set_phys_id()
2654 leds = (nic->phy == phy_82552_v) ? E100_82552_LED_ON : in e100_set_phys_id()
2655 (nic->mac < mac_82559_D101M) ? led_on_557 : led_on_559; in e100_set_phys_id()
2659 leds = (nic->phy == phy_82552_v) ? E100_82552_LED_OFF : led_off; in e100_set_phys_id()
2666 mdio_write(netdev, nic->mii.phy_id, led_reg, leds); in e100_set_phys_id()
2701 struct nic *nic = netdev_priv(netdev); in e100_get_ethtool_stats() local
2707 data[i++] = nic->tx_deferred; in e100_get_ethtool_stats()
2708 data[i++] = nic->tx_single_collisions; in e100_get_ethtool_stats()
2709 data[i++] = nic->tx_multiple_collisions; in e100_get_ethtool_stats()
2710 data[i++] = nic->tx_fc_pause; in e100_get_ethtool_stats()
2711 data[i++] = nic->rx_fc_pause; in e100_get_ethtool_stats()
2712 data[i++] = nic->rx_fc_unsupported; in e100_get_ethtool_stats()
2713 data[i++] = nic->tx_tco_frames; in e100_get_ethtool_stats()
2714 data[i++] = nic->rx_tco_frames; in e100_get_ethtool_stats()
2715 data[i++] = nic->rx_short_frame_errors; in e100_get_ethtool_stats()
2716 data[i++] = nic->rx_over_length_errors; in e100_get_ethtool_stats()
2758 struct nic *nic = netdev_priv(netdev); in e100_do_ioctl() local
2760 return generic_mii_ioctl(&nic->mii, if_mii(ifr), cmd, NULL); in e100_do_ioctl()
2763 static int e100_alloc(struct nic *nic) in e100_alloc() argument
2765 nic->mem = dma_alloc_coherent(&nic->pdev->dev, sizeof(struct mem), in e100_alloc()
2766 &nic->dma_addr, GFP_KERNEL); in e100_alloc()
2767 return nic->mem ? 0 : -ENOMEM; in e100_alloc()
2770 static void e100_free(struct nic *nic) in e100_free() argument
2772 if (nic->mem) { in e100_free()
2773 dma_free_coherent(&nic->pdev->dev, sizeof(struct mem), in e100_free()
2774 nic->mem, nic->dma_addr); in e100_free()
2775 nic->mem = NULL; in e100_free()
2781 struct nic *nic = netdev_priv(netdev); in e100_open() local
2785 if ((err = e100_up(nic))) in e100_open()
2786 netif_err(nic, ifup, nic->netdev, "Cannot open interface, aborting\n"); in e100_open()
2799 struct nic *nic = netdev_priv(netdev); in e100_set_features() local
2806 e100_exec_cb(nic, NULL, e100_configure); in e100_set_features()
2828 struct nic *nic; in e100_probe() local
2831 if (!(netdev = alloc_etherdev(sizeof(struct nic)))) in e100_probe()
2843 nic = netdev_priv(netdev); in e100_probe()
2844 netif_napi_add(netdev, &nic->napi, e100_poll, E100_NAPI_WEIGHT); in e100_probe()
2845 nic->netdev = netdev; in e100_probe()
2846 nic->pdev = pdev; in e100_probe()
2847 nic->msg_enable = (1 << debug) - 1; in e100_probe()
2848 nic->mdio_ctrl = mdio_ctrl_hw; in e100_probe()
2852 netif_err(nic, probe, nic->netdev, "Cannot enable PCI device, aborting\n"); in e100_probe()
2857 netif_err(nic, probe, nic->netdev, "Cannot find proper PCI device base address, aborting\n"); in e100_probe()
2863 netif_err(nic, probe, nic->netdev, "Cannot obtain PCI resources, aborting\n"); in e100_probe()
2868 netif_err(nic, probe, nic->netdev, "No usable DMA configuration, aborting\n"); in e100_probe()
2875 netif_info(nic, probe, nic->netdev, "using i/o access mode\n"); in e100_probe()
2877 nic->csr = pci_iomap(pdev, (use_io ? 1 : 0), sizeof(struct csr)); in e100_probe()
2878 if (!nic->csr) { in e100_probe()
2879 netif_err(nic, probe, nic->netdev, "Cannot map device registers, aborting\n"); in e100_probe()
2885 nic->flags |= ich; in e100_probe()
2887 nic->flags &= ~ich; in e100_probe()
2889 e100_get_defaults(nic); in e100_probe()
2892 if (nic->mac < mac_82558_D101_A4) in e100_probe()
2896 spin_lock_init(&nic->cb_lock); in e100_probe()
2897 spin_lock_init(&nic->cmd_lock); in e100_probe()
2898 spin_lock_init(&nic->mdio_lock); in e100_probe()
2903 e100_hw_reset(nic); in e100_probe()
2907 timer_setup(&nic->watchdog, e100_watchdog, 0); in e100_probe()
2909 INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task); in e100_probe()
2911 if ((err = e100_alloc(nic))) { in e100_probe()
2912 netif_err(nic, probe, nic->netdev, "Cannot alloc driver memory, aborting\n"); in e100_probe()
2916 if ((err = e100_eeprom_load(nic))) in e100_probe()
2919 e100_phy_init(nic); in e100_probe()
2921 memcpy(netdev->dev_addr, nic->eeprom, ETH_ALEN); in e100_probe()
2924 netif_err(nic, probe, nic->netdev, "Invalid MAC address from EEPROM, aborting\n"); in e100_probe()
2928 netif_err(nic, probe, nic->netdev, "Invalid MAC address from EEPROM, you MUST configure one.\n"); in e100_probe()
2933 if ((nic->mac >= mac_82558_D101_A4) && in e100_probe()
2934 (le16_to_cpu(nic->eeprom[eeprom_id]) & eeprom_id_wol)) { in e100_probe()
2935 nic->flags |= wol_magic; in e100_probe()
2944 netif_err(nic, probe, nic->netdev, "Cannot register net device, aborting\n"); in e100_probe()
2947 nic->cbs_pool = dma_pool_create(netdev->name, in e100_probe()
2948 &nic->pdev->dev, in e100_probe()
2949 nic->params.cbs.max * sizeof(struct cb), in e100_probe()
2952 if (!nic->cbs_pool) { in e100_probe()
2953 netif_err(nic, probe, nic->netdev, "Cannot create DMA pool, aborting\n"); in e100_probe()
2957 netif_info(nic, probe, nic->netdev, in e100_probe()
2967 e100_free(nic); in e100_probe()
2969 pci_iounmap(pdev, nic->csr); in e100_probe()
2984 struct nic *nic = netdev_priv(netdev); in e100_remove() local
2986 e100_free(nic); in e100_remove()
2987 pci_iounmap(pdev, nic->csr); in e100_remove()
2988 dma_pool_destroy(nic->cbs_pool); in e100_remove()
3001 struct nic *nic = netdev_priv(netdev); in __e100_shutdown() local
3006 e100_down(nic); in __e100_shutdown()
3008 if ((nic->flags & wol_magic) | e100_asf(nic)) { in __e100_shutdown()
3010 if (nic->phy == phy_82552_v) { in __e100_shutdown()
3011 u16 smartspeed = mdio_read(netdev, nic->mii.phy_id, in __e100_shutdown()
3014 mdio_write(netdev, nic->mii.phy_id, in __e100_shutdown()
3049 struct nic *nic = netdev_priv(netdev); in e100_resume() local
3060 if (nic->phy == phy_82552_v) { in e100_resume()
3061 u16 smartspeed = mdio_read(netdev, nic->mii.phy_id, in e100_resume()
3064 mdio_write(netdev, nic->mii.phy_id, in e100_resume()
3070 e100_up(nic); in e100_resume()
3094 struct nic *nic = netdev_priv(netdev); in e100_io_error_detected() local
3102 e100_down(nic); in e100_io_error_detected()
3118 struct nic *nic = netdev_priv(netdev); in e100_io_slot_reset() local
3129 e100_hw_reset(nic); in e100_io_slot_reset()
3130 e100_phy_init(nic); in e100_io_slot_reset()
3145 struct nic *nic = netdev_priv(netdev); in e100_io_resume() local
3153 mod_timer(&nic->watchdog, jiffies); in e100_io_resume()