Lines Matching full:nic
536 struct nic { struct
541 u16 (*mdio_ctrl)(struct nic *nic, u32 addr, u32 dir, u32 reg, u16 data); argument
605 static inline void e100_write_flush(struct nic *nic) in e100_write_flush() argument
609 (void)ioread8(&nic->csr->scb.status); in e100_write_flush()
612 static void e100_enable_irq(struct nic *nic) in e100_enable_irq() argument
616 spin_lock_irqsave(&nic->cmd_lock, flags); in e100_enable_irq()
617 iowrite8(irq_mask_none, &nic->csr->scb.cmd_hi); in e100_enable_irq()
618 e100_write_flush(nic); in e100_enable_irq()
619 spin_unlock_irqrestore(&nic->cmd_lock, flags); in e100_enable_irq()
622 static void e100_disable_irq(struct nic *nic) in e100_disable_irq() argument
626 spin_lock_irqsave(&nic->cmd_lock, flags); in e100_disable_irq()
627 iowrite8(irq_mask_all, &nic->csr->scb.cmd_hi); in e100_disable_irq()
628 e100_write_flush(nic); in e100_disable_irq()
629 spin_unlock_irqrestore(&nic->cmd_lock, flags); in e100_disable_irq()
632 static void e100_hw_reset(struct nic *nic) in e100_hw_reset() argument
636 iowrite32(selective_reset, &nic->csr->port); in e100_hw_reset()
637 e100_write_flush(nic); udelay(20); in e100_hw_reset()
640 iowrite32(software_reset, &nic->csr->port); in e100_hw_reset()
641 e100_write_flush(nic); udelay(20); in e100_hw_reset()
644 e100_disable_irq(nic); in e100_hw_reset()
647 static int e100_self_test(struct nic *nic) in e100_self_test() argument
649 u32 dma_addr = nic->dma_addr + offsetof(struct mem, selftest); in e100_self_test()
654 nic->mem->selftest.signature = 0; in e100_self_test()
655 nic->mem->selftest.result = 0xFFFFFFFF; in e100_self_test()
657 iowrite32(selftest | dma_addr, &nic->csr->port); in e100_self_test()
658 e100_write_flush(nic); in e100_self_test()
663 e100_disable_irq(nic); in e100_self_test()
666 if (nic->mem->selftest.result != 0) { in e100_self_test()
667 netif_err(nic, hw, nic->netdev, in e100_self_test()
669 nic->mem->selftest.result); in e100_self_test()
672 if (nic->mem->selftest.signature == 0) { in e100_self_test()
673 netif_err(nic, hw, nic->netdev, "Self-test failed: timed out\n"); in e100_self_test()
680 static void e100_eeprom_write(struct nic *nic, u16 addr_len, u16 addr, __le16 data) in e100_eeprom_write() argument
696 iowrite8(eecs | eesk, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_write()
697 e100_write_flush(nic); udelay(4); in e100_eeprom_write()
702 iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_write()
703 e100_write_flush(nic); udelay(4); in e100_eeprom_write()
705 iowrite8(ctrl | eesk, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_write()
706 e100_write_flush(nic); udelay(4); in e100_eeprom_write()
712 iowrite8(0, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_write()
713 e100_write_flush(nic); udelay(4); in e100_eeprom_write()
718 static __le16 e100_eeprom_read(struct nic *nic, u16 *addr_len, u16 addr) in e100_eeprom_read() argument
728 iowrite8(eecs | eesk, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_read()
729 e100_write_flush(nic); udelay(4); in e100_eeprom_read()
734 iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_read()
735 e100_write_flush(nic); udelay(4); in e100_eeprom_read()
737 iowrite8(ctrl | eesk, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_read()
738 e100_write_flush(nic); udelay(4); in e100_eeprom_read()
742 ctrl = ioread8(&nic->csr->eeprom_ctrl_lo); in e100_eeprom_read()
752 iowrite8(0, &nic->csr->eeprom_ctrl_lo); in e100_eeprom_read()
753 e100_write_flush(nic); udelay(4); in e100_eeprom_read()
759 static int e100_eeprom_load(struct nic *nic) in e100_eeprom_load() argument
764 e100_eeprom_read(nic, &addr_len, 0); in e100_eeprom_load()
765 nic->eeprom_wc = 1 << addr_len; in e100_eeprom_load()
767 for (addr = 0; addr < nic->eeprom_wc; addr++) { in e100_eeprom_load()
768 nic->eeprom[addr] = e100_eeprom_read(nic, &addr_len, addr); in e100_eeprom_load()
769 if (addr < nic->eeprom_wc - 1) in e100_eeprom_load()
770 checksum += le16_to_cpu(nic->eeprom[addr]); in e100_eeprom_load()
775 if (cpu_to_le16(0xBABA - checksum) != nic->eeprom[nic->eeprom_wc - 1]) { in e100_eeprom_load()
776 netif_err(nic, probe, nic->netdev, "EEPROM corrupted\n"); in e100_eeprom_load()
785 static int e100_eeprom_save(struct nic *nic, u16 start, u16 count) in e100_eeprom_save() argument
790 e100_eeprom_read(nic, &addr_len, 0); in e100_eeprom_save()
791 nic->eeprom_wc = 1 << addr_len; in e100_eeprom_save()
793 if (start + count >= nic->eeprom_wc) in e100_eeprom_save()
797 e100_eeprom_write(nic, addr_len, addr, nic->eeprom[addr]); in e100_eeprom_save()
801 for (addr = 0; addr < nic->eeprom_wc - 1; addr++) in e100_eeprom_save()
802 checksum += le16_to_cpu(nic->eeprom[addr]); in e100_eeprom_save()
803 nic->eeprom[nic->eeprom_wc - 1] = cpu_to_le16(0xBABA - checksum); in e100_eeprom_save()
804 e100_eeprom_write(nic, addr_len, nic->eeprom_wc - 1, in e100_eeprom_save()
805 nic->eeprom[nic->eeprom_wc - 1]); in e100_eeprom_save()
812 static int e100_exec_cmd(struct nic *nic, u8 cmd, dma_addr_t dma_addr) in e100_exec_cmd() argument
818 spin_lock_irqsave(&nic->cmd_lock, flags); in e100_exec_cmd()
822 if (likely(!ioread8(&nic->csr->scb.cmd_lo))) in e100_exec_cmd()
834 iowrite32(dma_addr, &nic->csr->scb.gen_ptr); in e100_exec_cmd()
835 iowrite8(cmd, &nic->csr->scb.cmd_lo); in e100_exec_cmd()
838 spin_unlock_irqrestore(&nic->cmd_lock, flags); in e100_exec_cmd()
843 static int e100_exec_cb(struct nic *nic, struct sk_buff *skb, in e100_exec_cb() argument
844 int (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *)) in e100_exec_cb() argument
850 spin_lock_irqsave(&nic->cb_lock, flags); in e100_exec_cb()
852 if (unlikely(!nic->cbs_avail)) { in e100_exec_cb()
857 cb = nic->cb_to_use; in e100_exec_cb()
858 nic->cb_to_use = cb->next; in e100_exec_cb()
859 nic->cbs_avail--; in e100_exec_cb()
862 err = cb_prepare(nic, cb, skb); in e100_exec_cb()
866 if (unlikely(!nic->cbs_avail)) in e100_exec_cb()
876 while (nic->cb_to_send != nic->cb_to_use) { in e100_exec_cb()
877 if (unlikely(e100_exec_cmd(nic, nic->cuc_cmd, in e100_exec_cb()
878 nic->cb_to_send->dma_addr))) { in e100_exec_cb()
886 schedule_work(&nic->tx_timeout_task); in e100_exec_cb()
890 nic->cuc_cmd = cuc_resume; in e100_exec_cb()
891 nic->cb_to_send = nic->cb_to_send->next; in e100_exec_cb()
896 spin_unlock_irqrestore(&nic->cb_lock, flags); in e100_exec_cb()
903 struct nic *nic = netdev_priv(netdev); in mdio_read() local
904 return nic->mdio_ctrl(nic, addr, mdi_read, reg, 0); in mdio_read()
909 struct nic *nic = netdev_priv(netdev); in mdio_write() local
911 nic->mdio_ctrl(nic, addr, mdi_write, reg, data); in mdio_write()
915 static u16 mdio_ctrl_hw(struct nic *nic, u32 addr, u32 dir, u32 reg, u16 data) in mdio_ctrl_hw() argument
928 spin_lock_irqsave(&nic->mdio_lock, flags); in mdio_ctrl_hw()
930 if (ioread32(&nic->csr->mdi_ctrl) & mdi_ready) in mdio_ctrl_hw()
935 netdev_err(nic->netdev, "e100.mdio_ctrl won't go Ready\n"); in mdio_ctrl_hw()
936 spin_unlock_irqrestore(&nic->mdio_lock, flags); in mdio_ctrl_hw()
939 iowrite32((reg << 16) | (addr << 21) | dir | data, &nic->csr->mdi_ctrl); in mdio_ctrl_hw()
943 if ((data_out = ioread32(&nic->csr->mdi_ctrl)) & mdi_ready) in mdio_ctrl_hw()
946 spin_unlock_irqrestore(&nic->mdio_lock, flags); in mdio_ctrl_hw()
947 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, in mdio_ctrl_hw()
955 static u16 mdio_ctrl_phy_82552_v(struct nic *nic, in mdio_ctrl_phy_82552_v() argument
963 u16 advert = mdio_read(nic->netdev, nic->mii.phy_id, in mdio_ctrl_phy_82552_v()
976 return mdio_ctrl_hw(nic, addr, dir, reg, data); in mdio_ctrl_phy_82552_v()
985 static u16 mdio_ctrl_phy_mii_emulated(struct nic *nic, in mdio_ctrl_phy_mii_emulated() argument
1010 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, in mdio_ctrl_phy_mii_emulated()
1019 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, in mdio_ctrl_phy_mii_emulated()
1027 static inline int e100_phy_supports_mii(struct nic *nic) in e100_phy_supports_mii() argument
1032 return (nic->mdio_ctrl != mdio_ctrl_phy_mii_emulated); in e100_phy_supports_mii()
1035 static void e100_get_defaults(struct nic *nic) in e100_get_defaults() argument
1041 nic->mac = (nic->flags & ich) ? mac_82559_D101M : nic->pdev->revision; in e100_get_defaults()
1042 if (nic->mac == mac_unknown) in e100_get_defaults()
1043 nic->mac = mac_82557_D100_A; in e100_get_defaults()
1045 nic->params.rfds = rfds; in e100_get_defaults()
1046 nic->params.cbs = cbs; in e100_get_defaults()
1049 nic->tx_threshold = 0xE0; in e100_get_defaults()
1052 nic->tx_command = cpu_to_le16(cb_tx | cb_tx_sf | in e100_get_defaults()
1053 ((nic->mac >= mac_82558_D101_A4) ? cb_cid : cb_i)); in e100_get_defaults()
1056 nic->blank_rfd.command = 0; in e100_get_defaults()
1057 nic->blank_rfd.rbd = cpu_to_le32(0xFFFFFFFF); in e100_get_defaults()
1058 nic->blank_rfd.size = cpu_to_le16(VLAN_ETH_FRAME_LEN + ETH_FCS_LEN); in e100_get_defaults()
1061 nic->mii.phy_id_mask = 0x1F; in e100_get_defaults()
1062 nic->mii.reg_num_mask = 0x1F; in e100_get_defaults()
1063 nic->mii.dev = nic->netdev; in e100_get_defaults()
1064 nic->mii.mdio_read = mdio_read; in e100_get_defaults()
1065 nic->mii.mdio_write = mdio_write; in e100_get_defaults()
1068 static int e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb) in e100_configure() argument
1072 struct net_device *netdev = nic->netdev; in e100_configure()
1085 if (e100_phy_supports_mii(nic)) in e100_configure()
1104 config->adaptive_ifs = nic->adaptive_ifs; in e100_configure()
1105 config->loopback = nic->loopback; in e100_configure()
1107 if (nic->mii.force_media && nic->mii.full_duplex) in e100_configure()
1110 if (nic->flags & promiscuous || nic->loopback) { in e100_configure()
1119 if (nic->flags & multicast_all) in e100_configure()
1123 if (netif_running(nic->netdev) || !(nic->flags & wol_magic)) in e100_configure()
1126 if (nic->mac >= mac_82558_D101_A4) { in e100_configure()
1131 if (nic->mac >= mac_82559_D101M) { in e100_configure()
1134 if (nic->mac >= mac_82551_10) { in e100_configure()
1149 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, "[00-07]=%8ph\n", in e100_configure()
1151 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, "[08-15]=%8ph\n", in e100_configure()
1153 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, "[16-23]=%8ph\n", in e100_configure()
1218 static const struct firmware *e100_request_firmware(struct nic *nic) in e100_request_firmware() argument
1221 const struct firmware *fw = nic->fw; in e100_request_firmware()
1227 if (nic->flags & ich) in e100_request_firmware()
1243 if (nic->mac == mac_82559_D101M) { in e100_request_firmware()
1245 } else if (nic->mac == mac_82559_D101S) { in e100_request_firmware()
1247 } else if (nic->mac == mac_82551_F || nic->mac == mac_82551_10) { in e100_request_firmware()
1260 err = request_firmware(&fw, fw_name, &nic->pdev->dev); in e100_request_firmware()
1264 netif_err(nic, probe, nic->netdev, in e100_request_firmware()
1269 netif_info(nic, probe, nic->netdev, in e100_request_firmware()
1279 netif_err(nic, probe, nic->netdev, in e100_request_firmware()
1293 netif_err(nic, probe, nic->netdev, in e100_request_firmware()
1301 * to it in the nic */ in e100_request_firmware()
1302 nic->fw = fw; in e100_request_firmware()
1306 static int e100_setup_ucode(struct nic *nic, struct cb *cb, in e100_setup_ucode() argument
1336 static inline int e100_load_ucode_wait(struct nic *nic) in e100_load_ucode_wait() argument
1340 struct cb *cb = nic->cb_to_clean; in e100_load_ucode_wait()
1342 fw = e100_request_firmware(nic); in e100_load_ucode_wait()
1347 if ((err = e100_exec_cb(nic, (void *)fw, e100_setup_ucode))) in e100_load_ucode_wait()
1348 netif_err(nic, probe, nic->netdev, in e100_load_ucode_wait()
1352 nic->cuc_cmd = cuc_start; in e100_load_ucode_wait()
1355 e100_write_flush(nic); in e100_load_ucode_wait()
1365 iowrite8(~0, &nic->csr->scb.stat_ack); in e100_load_ucode_wait()
1369 netif_err(nic, probe, nic->netdev, "ucode load failed\n"); in e100_load_ucode_wait()
1376 static int e100_setup_iaaddr(struct nic *nic, struct cb *cb, in e100_setup_iaaddr() argument
1380 memcpy(cb->u.iaaddr, nic->netdev->dev_addr, ETH_ALEN); in e100_setup_iaaddr()
1384 static int e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb) in e100_dump() argument
1387 cb->u.dump_buffer_addr = cpu_to_le32(nic->dma_addr + in e100_dump()
1392 static int e100_phy_check_without_mii(struct nic *nic) in e100_phy_check_without_mii() argument
1397 phy_type = (le16_to_cpu(nic->eeprom[eeprom_phy_iface]) >> 8) & 0x0f; in e100_phy_check_without_mii()
1409 netif_info(nic, probe, nic->netdev, in e100_phy_check_without_mii()
1412 nic->mdio_ctrl = mdio_ctrl_phy_mii_emulated; in e100_phy_check_without_mii()
1413 nic->mii.phy_id = 0; /* is this ok for an MII-less PHY? */ in e100_phy_check_without_mii()
1416 * nic->flags |= ich; in e100_phy_check_without_mii()
1417 * nic->flags |= ich_10h_workaround; */ in e100_phy_check_without_mii()
1432 static int e100_phy_init(struct nic *nic) in e100_phy_init() argument
1434 struct net_device *netdev = nic->netdev; in e100_phy_init()
1440 nic->mii.phy_id = (addr == 0) ? 1 : (addr == 1) ? 0 : addr; in e100_phy_init()
1441 bmcr = mdio_read(netdev, nic->mii.phy_id, MII_BMCR); in e100_phy_init()
1442 stat = mdio_read(netdev, nic->mii.phy_id, MII_BMSR); in e100_phy_init()
1443 stat = mdio_read(netdev, nic->mii.phy_id, MII_BMSR); in e100_phy_init()
1452 if (e100_phy_check_without_mii(nic)) in e100_phy_init()
1456 netif_err(nic, hw, nic->netdev, in e100_phy_init()
1461 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, in e100_phy_init()
1462 "phy_addr = %d\n", nic->mii.phy_id); in e100_phy_init()
1465 id_lo = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID1); in e100_phy_init()
1466 id_hi = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID2); in e100_phy_init()
1467 nic->phy = (u32)id_hi << 16 | (u32)id_lo; in e100_phy_init()
1468 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, in e100_phy_init()
1469 "phy ID = 0x%08X\n", nic->phy); in e100_phy_init()
1473 if (addr != nic->mii.phy_id) { in e100_phy_init()
1475 } else if (nic->phy != phy_82552_v) { in e100_phy_init()
1486 if (nic->phy == phy_82552_v) in e100_phy_init()
1487 mdio_write(netdev, nic->mii.phy_id, MII_BMCR, in e100_phy_init()
1492 if ((nic->phy & NCS_PHY_MODEL_MASK) == phy_nsc_tx) { in e100_phy_init()
1494 cong = mdio_read(netdev, nic->mii.phy_id, MII_NSC_CONG); in e100_phy_init()
1497 mdio_write(netdev, nic->mii.phy_id, MII_NSC_CONG, cong); in e100_phy_init()
1500 if (nic->phy == phy_82552_v) { in e100_phy_init()
1501 u16 advert = mdio_read(netdev, nic->mii.phy_id, MII_ADVERTISE); in e100_phy_init()
1504 nic->mdio_ctrl = mdio_ctrl_phy_82552_v; in e100_phy_init()
1508 mdio_write(netdev, nic->mii.phy_id, MII_ADVERTISE, advert); in e100_phy_init()
1511 bmcr = mdio_read(netdev, nic->mii.phy_id, MII_BMCR); in e100_phy_init()
1513 mdio_write(netdev, nic->mii.phy_id, MII_BMCR, bmcr); in e100_phy_init()
1514 } else if ((nic->mac >= mac_82550_D102) || ((nic->flags & ich) && in e100_phy_init()
1515 (mdio_read(netdev, nic->mii.phy_id, MII_TPISTATUS) & 0x8000) && in e100_phy_init()
1516 (le16_to_cpu(nic->eeprom[eeprom_cnfg_mdix]) & eeprom_mdix_enabled))) { in e100_phy_init()
1518 mdio_write(netdev, nic->mii.phy_id, MII_NCONFIG, in e100_phy_init()
1519 nic->mii.force_media ? 0 : NCONFIG_AUTO_SWITCH); in e100_phy_init()
1525 static int e100_hw_init(struct nic *nic) in e100_hw_init() argument
1529 e100_hw_reset(nic); in e100_hw_init()
1531 netif_err(nic, hw, nic->netdev, "e100_hw_init\n"); in e100_hw_init()
1532 if ((err = e100_self_test(nic))) in e100_hw_init()
1535 if ((err = e100_phy_init(nic))) in e100_hw_init()
1537 if ((err = e100_exec_cmd(nic, cuc_load_base, 0))) in e100_hw_init()
1539 if ((err = e100_exec_cmd(nic, ruc_load_base, 0))) in e100_hw_init()
1541 if ((err = e100_load_ucode_wait(nic))) in e100_hw_init()
1543 if ((err = e100_exec_cb(nic, NULL, e100_configure))) in e100_hw_init()
1545 if ((err = e100_exec_cb(nic, NULL, e100_setup_iaaddr))) in e100_hw_init()
1547 if ((err = e100_exec_cmd(nic, cuc_dump_addr, in e100_hw_init()
1548 nic->dma_addr + offsetof(struct mem, stats)))) in e100_hw_init()
1550 if ((err = e100_exec_cmd(nic, cuc_dump_reset, 0))) in e100_hw_init()
1553 e100_disable_irq(nic); in e100_hw_init()
1558 static int e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb) in e100_multi() argument
1560 struct net_device *netdev = nic->netdev; in e100_multi()
1578 struct nic *nic = netdev_priv(netdev); in e100_set_multicast_list() local
1580 netif_printk(nic, hw, KERN_DEBUG, nic->netdev, in e100_set_multicast_list()
1585 nic->flags |= promiscuous; in e100_set_multicast_list()
1587 nic->flags &= ~promiscuous; in e100_set_multicast_list()
1591 nic->flags |= multicast_all; in e100_set_multicast_list()
1593 nic->flags &= ~multicast_all; in e100_set_multicast_list()
1595 e100_exec_cb(nic, NULL, e100_configure); in e100_set_multicast_list()
1596 e100_exec_cb(nic, NULL, e100_multi); in e100_set_multicast_list()
1599 static void e100_update_stats(struct nic *nic) in e100_update_stats() argument
1601 struct net_device *dev = nic->netdev; in e100_update_stats()
1603 struct stats *s = &nic->mem->stats; in e100_update_stats()
1604 __le32 *complete = (nic->mac < mac_82558_D101_A4) ? &s->fc_xmt_pause : in e100_update_stats()
1605 (nic->mac < mac_82559_D101M) ? (__le32 *)&s->xmt_tco_frames : in e100_update_stats()
1614 nic->tx_frames = le32_to_cpu(s->tx_good_frames); in e100_update_stats()
1615 nic->tx_collisions = le32_to_cpu(s->tx_total_collisions); in e100_update_stats()
1620 ns->collisions += nic->tx_collisions; in e100_update_stats()
1623 nic->rx_short_frame_errors += in e100_update_stats()
1625 ns->rx_length_errors = nic->rx_short_frame_errors + in e100_update_stats()
1626 nic->rx_over_length_errors; in e100_update_stats()
1636 nic->tx_deferred += le32_to_cpu(s->tx_deferred); in e100_update_stats()
1637 nic->tx_single_collisions += in e100_update_stats()
1639 nic->tx_multiple_collisions += in e100_update_stats()
1641 if (nic->mac >= mac_82558_D101_A4) { in e100_update_stats()
1642 nic->tx_fc_pause += le32_to_cpu(s->fc_xmt_pause); in e100_update_stats()
1643 nic->rx_fc_pause += le32_to_cpu(s->fc_rcv_pause); in e100_update_stats()
1644 nic->rx_fc_unsupported += in e100_update_stats()
1646 if (nic->mac >= mac_82559_D101M) { in e100_update_stats()
1647 nic->tx_tco_frames += in e100_update_stats()
1649 nic->rx_tco_frames += in e100_update_stats()
1656 if (e100_exec_cmd(nic, cuc_dump_reset, 0)) in e100_update_stats()
1657 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev, in e100_update_stats()
1661 static void e100_adjust_adaptive_ifs(struct nic *nic, int speed, int duplex) in e100_adjust_adaptive_ifs() argument
1667 u32 prev = nic->adaptive_ifs; in e100_adjust_adaptive_ifs()
1670 if ((nic->tx_frames / 32 < nic->tx_collisions) && in e100_adjust_adaptive_ifs()
1671 (nic->tx_frames > min_frames)) { in e100_adjust_adaptive_ifs()
1672 if (nic->adaptive_ifs < 60) in e100_adjust_adaptive_ifs()
1673 nic->adaptive_ifs += 5; in e100_adjust_adaptive_ifs()
1674 } else if (nic->tx_frames < min_frames) { in e100_adjust_adaptive_ifs()
1675 if (nic->adaptive_ifs >= 5) in e100_adjust_adaptive_ifs()
1676 nic->adaptive_ifs -= 5; in e100_adjust_adaptive_ifs()
1678 if (nic->adaptive_ifs != prev) in e100_adjust_adaptive_ifs()
1679 e100_exec_cb(nic, NULL, e100_configure); in e100_adjust_adaptive_ifs()
1685 struct nic *nic = from_timer(nic, t, watchdog); in e100_watchdog() local
1689 netif_printk(nic, timer, KERN_DEBUG, nic->netdev, in e100_watchdog()
1694 mii_ethtool_gset(&nic->mii, &cmd); in e100_watchdog()
1697 if (mii_link_ok(&nic->mii) && !netif_carrier_ok(nic->netdev)) { in e100_watchdog()
1698 netdev_info(nic->netdev, "NIC Link is Up %u Mbps %s Duplex\n", in e100_watchdog()
1701 } else if (!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) { in e100_watchdog()
1702 netdev_info(nic->netdev, "NIC Link is Down\n"); in e100_watchdog()
1705 mii_check_link(&nic->mii); in e100_watchdog()
1712 spin_lock_irq(&nic->cmd_lock); in e100_watchdog()
1713 iowrite8(ioread8(&nic->csr->scb.cmd_hi) | irq_sw_gen,&nic->csr->scb.cmd_hi); in e100_watchdog()
1714 e100_write_flush(nic); in e100_watchdog()
1715 spin_unlock_irq(&nic->cmd_lock); in e100_watchdog()
1717 e100_update_stats(nic); in e100_watchdog()
1718 e100_adjust_adaptive_ifs(nic, speed, cmd.duplex); in e100_watchdog()
1720 if (nic->mac <= mac_82557_D100_C) in e100_watchdog()
1722 e100_set_multicast_list(nic->netdev); in e100_watchdog()
1724 if (nic->flags & ich && speed == SPEED_10 && cmd.duplex == DUPLEX_HALF) in e100_watchdog()
1726 nic->flags |= ich_10h_workaround; in e100_watchdog()
1728 nic->flags &= ~ich_10h_workaround; in e100_watchdog()
1730 mod_timer(&nic->watchdog, in e100_watchdog()
1734 static int e100_xmit_prepare(struct nic *nic, struct cb *cb, in e100_xmit_prepare() argument
1738 cb->command = nic->tx_command; in e100_xmit_prepare()
1740 dma_addr = dma_map_single(&nic->pdev->dev, skb->data, skb->len, in e100_xmit_prepare()
1743 if (dma_mapping_error(&nic->pdev->dev, dma_addr)) in e100_xmit_prepare()
1756 if ((nic->cbs_avail & ~15) == nic->cbs_avail) in e100_xmit_prepare()
1760 cb->u.tcb.threshold = nic->tx_threshold; in e100_xmit_prepare()
1771 struct nic *nic = netdev_priv(netdev); in e100_xmit_frame() local
1774 if (nic->flags & ich_10h_workaround) { in e100_xmit_frame()
1778 if (e100_exec_cmd(nic, cuc_nop, 0)) in e100_xmit_frame()
1779 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev, in e100_xmit_frame()
1784 err = e100_exec_cb(nic, skb, e100_xmit_prepare); in e100_xmit_frame()
1789 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev, in e100_xmit_frame()
1795 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev, in e100_xmit_frame()
1804 static int e100_tx_clean(struct nic *nic) in e100_tx_clean() argument
1806 struct net_device *dev = nic->netdev; in e100_tx_clean()
1810 spin_lock(&nic->cb_lock); in e100_tx_clean()
1813 for (cb = nic->cb_to_clean; in e100_tx_clean()
1815 cb = nic->cb_to_clean = cb->next) { in e100_tx_clean()
1817 netif_printk(nic, tx_done, KERN_DEBUG, nic->netdev, in e100_tx_clean()
1819 (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)), in e100_tx_clean()
1826 dma_unmap_single(&nic->pdev->dev, in e100_tx_clean()
1835 nic->cbs_avail++; in e100_tx_clean()
1838 spin_unlock(&nic->cb_lock); in e100_tx_clean()
1841 if (unlikely(tx_cleaned && netif_queue_stopped(nic->netdev))) in e100_tx_clean()
1842 netif_wake_queue(nic->netdev); in e100_tx_clean()
1847 static void e100_clean_cbs(struct nic *nic) in e100_clean_cbs() argument
1849 if (nic->cbs) { in e100_clean_cbs()
1850 while (nic->cbs_avail != nic->params.cbs.count) { in e100_clean_cbs()
1851 struct cb *cb = nic->cb_to_clean; in e100_clean_cbs()
1853 dma_unmap_single(&nic->pdev->dev, in e100_clean_cbs()
1859 nic->cb_to_clean = nic->cb_to_clean->next; in e100_clean_cbs()
1860 nic->cbs_avail++; in e100_clean_cbs()
1862 dma_pool_free(nic->cbs_pool, nic->cbs, nic->cbs_dma_addr); in e100_clean_cbs()
1863 nic->cbs = NULL; in e100_clean_cbs()
1864 nic->cbs_avail = 0; in e100_clean_cbs()
1866 nic->cuc_cmd = cuc_start; in e100_clean_cbs()
1867 nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = in e100_clean_cbs()
1868 nic->cbs; in e100_clean_cbs()
1871 static int e100_alloc_cbs(struct nic *nic) in e100_alloc_cbs() argument
1874 unsigned int i, count = nic->params.cbs.count; in e100_alloc_cbs()
1876 nic->cuc_cmd = cuc_start; in e100_alloc_cbs()
1877 nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = NULL; in e100_alloc_cbs()
1878 nic->cbs_avail = 0; in e100_alloc_cbs()
1880 nic->cbs = dma_pool_zalloc(nic->cbs_pool, GFP_KERNEL, in e100_alloc_cbs()
1881 &nic->cbs_dma_addr); in e100_alloc_cbs()
1882 if (!nic->cbs) in e100_alloc_cbs()
1885 for (cb = nic->cbs, i = 0; i < count; cb++, i++) { in e100_alloc_cbs()
1886 cb->next = (i + 1 < count) ? cb + 1 : nic->cbs; in e100_alloc_cbs()
1887 cb->prev = (i == 0) ? nic->cbs + count - 1 : cb - 1; in e100_alloc_cbs()
1889 cb->dma_addr = nic->cbs_dma_addr + i * sizeof(struct cb); in e100_alloc_cbs()
1890 cb->link = cpu_to_le32(nic->cbs_dma_addr + in e100_alloc_cbs()
1894 nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = nic->cbs; in e100_alloc_cbs()
1895 nic->cbs_avail = count; in e100_alloc_cbs()
1900 static inline void e100_start_receiver(struct nic *nic, struct rx *rx) in e100_start_receiver() argument
1902 if (!nic->rxs) return; in e100_start_receiver()
1903 if (RU_SUSPENDED != nic->ru_running) return; in e100_start_receiver()
1906 if (!rx) rx = nic->rxs; in e100_start_receiver()
1910 e100_exec_cmd(nic, ruc_start, rx->dma_addr); in e100_start_receiver()
1911 nic->ru_running = RU_RUNNING; in e100_start_receiver()
1916 static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx) in e100_rx_alloc_skb() argument
1918 if (!(rx->skb = netdev_alloc_skb_ip_align(nic->netdev, RFD_BUF_LEN))) in e100_rx_alloc_skb()
1922 skb_copy_to_linear_data(rx->skb, &nic->blank_rfd, sizeof(struct rfd)); in e100_rx_alloc_skb()
1923 rx->dma_addr = dma_map_single(&nic->pdev->dev, rx->skb->data, in e100_rx_alloc_skb()
1926 if (dma_mapping_error(&nic->pdev->dev, rx->dma_addr)) { in e100_rx_alloc_skb()
1939 dma_sync_single_for_device(&nic->pdev->dev, in e100_rx_alloc_skb()
1948 static int e100_rx_indicate(struct nic *nic, struct rx *rx, in e100_rx_indicate() argument
1951 struct net_device *dev = nic->netdev; in e100_rx_indicate()
1961 dma_sync_single_for_cpu(&nic->pdev->dev, rx->dma_addr, in e100_rx_indicate()
1965 netif_printk(nic, rx_status, KERN_DEBUG, nic->netdev, in e100_rx_indicate()
1977 (RU_RUNNING == nic->ru_running)) in e100_rx_indicate()
1979 if (ioread8(&nic->csr->scb.status) & rus_no_res) in e100_rx_indicate()
1980 nic->ru_running = RU_SUSPENDED; in e100_rx_indicate()
1981 dma_sync_single_for_device(&nic->pdev->dev, rx->dma_addr, in e100_rx_indicate()
1995 dma_unmap_single(&nic->pdev->dev, rx->dma_addr, RFD_BUF_LEN, in e100_rx_indicate()
2005 (RU_RUNNING == nic->ru_running)) { in e100_rx_indicate()
2007 if (ioread8(&nic->csr->scb.status) & rus_no_res) in e100_rx_indicate()
2008 nic->ru_running = RU_SUSPENDED; in e100_rx_indicate()
2014 skb->protocol = eth_type_trans(skb, nic->netdev); in e100_rx_indicate()
2022 nic->rx_over_length_errors++; in e100_rx_indicate()
2031 nic->rx_over_length_errors++; in e100_rx_indicate()
2047 static void e100_rx_clean(struct nic *nic, unsigned int *work_done, in e100_rx_clean() argument
2056 for (rx = nic->rx_to_clean; rx->skb; rx = nic->rx_to_clean = rx->next) { in e100_rx_clean()
2057 err = e100_rx_indicate(nic, rx, work_done, work_to_do); in e100_rx_clean()
2070 if (-EAGAIN != err && RU_SUSPENDED == nic->ru_running) in e100_rx_clean()
2073 old_before_last_rx = nic->rx_to_use->prev->prev; in e100_rx_clean()
2077 for (rx = nic->rx_to_use; !rx->skb; rx = nic->rx_to_use = rx->next) { in e100_rx_clean()
2078 if (unlikely(e100_rx_alloc_skb(nic, rx))) in e100_rx_clean()
2082 new_before_last_rx = nic->rx_to_use->prev->prev; in e100_rx_clean()
2097 dma_sync_single_for_device(&nic->pdev->dev, in e100_rx_clean()
2106 dma_sync_single_for_device(&nic->pdev->dev, in e100_rx_clean()
2112 dma_sync_single_for_device(&nic->pdev->dev, in e100_rx_clean()
2120 iowrite8(stat_ack_rnr, &nic->csr->scb.stat_ack); in e100_rx_clean()
2121 e100_start_receiver(nic, nic->rx_to_clean); in e100_rx_clean()
2127 static void e100_rx_clean_list(struct nic *nic) in e100_rx_clean_list() argument
2130 unsigned int i, count = nic->params.rfds.count; in e100_rx_clean_list()
2132 nic->ru_running = RU_UNINITIALIZED; in e100_rx_clean_list()
2134 if (nic->rxs) { in e100_rx_clean_list()
2135 for (rx = nic->rxs, i = 0; i < count; rx++, i++) { in e100_rx_clean_list()
2137 dma_unmap_single(&nic->pdev->dev, in e100_rx_clean_list()
2143 kfree(nic->rxs); in e100_rx_clean_list()
2144 nic->rxs = NULL; in e100_rx_clean_list()
2147 nic->rx_to_use = nic->rx_to_clean = NULL; in e100_rx_clean_list()
2150 static int e100_rx_alloc_list(struct nic *nic) in e100_rx_alloc_list() argument
2153 unsigned int i, count = nic->params.rfds.count; in e100_rx_alloc_list()
2156 nic->rx_to_use = nic->rx_to_clean = NULL; in e100_rx_alloc_list()
2157 nic->ru_running = RU_UNINITIALIZED; in e100_rx_alloc_list()
2159 if (!(nic->rxs = kcalloc(count, sizeof(struct rx), GFP_KERNEL))) in e100_rx_alloc_list()
2162 for (rx = nic->rxs, i = 0; i < count; rx++, i++) { in e100_rx_alloc_list()
2163 rx->next = (i + 1 < count) ? rx + 1 : nic->rxs; in e100_rx_alloc_list()
2164 rx->prev = (i == 0) ? nic->rxs + count - 1 : rx - 1; in e100_rx_alloc_list()
2165 if (e100_rx_alloc_skb(nic, rx)) { in e100_rx_alloc_list()
2166 e100_rx_clean_list(nic); in e100_rx_alloc_list()
2177 rx = nic->rxs->prev->prev; in e100_rx_alloc_list()
2181 dma_sync_single_for_device(&nic->pdev->dev, rx->dma_addr, in e100_rx_alloc_list()
2184 nic->rx_to_use = nic->rx_to_clean = nic->rxs; in e100_rx_alloc_list()
2185 nic->ru_running = RU_SUSPENDED; in e100_rx_alloc_list()
2193 struct nic *nic = netdev_priv(netdev); in e100_intr() local
2194 u8 stat_ack = ioread8(&nic->csr->scb.stat_ack); in e100_intr()
2196 netif_printk(nic, intr, KERN_DEBUG, nic->netdev, in e100_intr()
2204 iowrite8(stat_ack, &nic->csr->scb.stat_ack); in e100_intr()
2208 nic->ru_running = RU_SUSPENDED; in e100_intr()
2210 if (likely(napi_schedule_prep(&nic->napi))) { in e100_intr()
2211 e100_disable_irq(nic); in e100_intr()
2212 __napi_schedule(&nic->napi); in e100_intr()
2220 struct nic *nic = container_of(napi, struct nic, napi); in e100_poll() local
2223 e100_rx_clean(nic, &work_done, budget); in e100_poll()
2224 e100_tx_clean(nic); in e100_poll()
2232 e100_enable_irq(nic); in e100_poll()
2240 struct nic *nic = netdev_priv(netdev); in e100_netpoll() local
2242 e100_disable_irq(nic); in e100_netpoll()
2243 e100_intr(nic->pdev->irq, netdev); in e100_netpoll()
2244 e100_tx_clean(nic); in e100_netpoll()
2245 e100_enable_irq(nic); in e100_netpoll()
2251 struct nic *nic = netdev_priv(netdev); in e100_set_mac_address() local
2258 e100_exec_cb(nic, NULL, e100_setup_iaaddr); in e100_set_mac_address()
2263 static int e100_asf(struct nic *nic) in e100_asf() argument
2266 return (nic->pdev->device >= 0x1050) && (nic->pdev->device <= 0x1057) && in e100_asf()
2267 (le16_to_cpu(nic->eeprom[eeprom_config_asf]) & eeprom_asf) && in e100_asf()
2268 !(le16_to_cpu(nic->eeprom[eeprom_config_asf]) & eeprom_gcl) && in e100_asf()
2269 ((le16_to_cpu(nic->eeprom[eeprom_smbus_addr]) & 0xFF) != 0xFE); in e100_asf()
2272 static int e100_up(struct nic *nic) in e100_up() argument
2276 if ((err = e100_rx_alloc_list(nic))) in e100_up()
2278 if ((err = e100_alloc_cbs(nic))) in e100_up()
2280 if ((err = e100_hw_init(nic))) in e100_up()
2282 e100_set_multicast_list(nic->netdev); in e100_up()
2283 e100_start_receiver(nic, NULL); in e100_up()
2284 mod_timer(&nic->watchdog, jiffies); in e100_up()
2285 if ((err = request_irq(nic->pdev->irq, e100_intr, IRQF_SHARED, in e100_up()
2286 nic->netdev->name, nic->netdev))) in e100_up()
2288 netif_wake_queue(nic->netdev); in e100_up()
2289 napi_enable(&nic->napi); in e100_up()
2292 e100_enable_irq(nic); in e100_up()
2296 del_timer_sync(&nic->watchdog); in e100_up()
2298 e100_clean_cbs(nic); in e100_up()
2300 e100_rx_clean_list(nic); in e100_up()
2304 static void e100_down(struct nic *nic) in e100_down() argument
2307 napi_disable(&nic->napi); in e100_down()
2308 netif_stop_queue(nic->netdev); in e100_down()
2309 e100_hw_reset(nic); in e100_down()
2310 free_irq(nic->pdev->irq, nic->netdev); in e100_down()
2311 del_timer_sync(&nic->watchdog); in e100_down()
2312 netif_carrier_off(nic->netdev); in e100_down()
2313 e100_clean_cbs(nic); in e100_down()
2314 e100_rx_clean_list(nic); in e100_down()
2319 struct nic *nic = netdev_priv(netdev); in e100_tx_timeout() local
2323 schedule_work(&nic->tx_timeout_task); in e100_tx_timeout()
2328 struct nic *nic = container_of(work, struct nic, tx_timeout_task); in e100_tx_timeout_task() local
2329 struct net_device *netdev = nic->netdev; in e100_tx_timeout_task()
2331 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev, in e100_tx_timeout_task()
2332 "scb.status=0x%02X\n", ioread8(&nic->csr->scb.status)); in e100_tx_timeout_task()
2342 static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode) in e100_loopback_test() argument
2352 if ((err = e100_rx_alloc_list(nic))) in e100_loopback_test()
2354 if ((err = e100_alloc_cbs(nic))) in e100_loopback_test()
2358 if (nic->flags & ich && loopback_mode == lb_phy) in e100_loopback_test()
2361 nic->loopback = loopback_mode; in e100_loopback_test()
2362 if ((err = e100_hw_init(nic))) in e100_loopback_test()
2366 mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, in e100_loopback_test()
2369 e100_start_receiver(nic, NULL); in e100_loopback_test()
2371 if (!(skb = netdev_alloc_skb(nic->netdev, ETH_DATA_LEN))) { in e100_loopback_test()
2377 e100_xmit_frame(skb, nic->netdev); in e100_loopback_test()
2381 dma_sync_single_for_cpu(&nic->pdev->dev, nic->rx_to_clean->dma_addr, in e100_loopback_test()
2384 if (memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd), in e100_loopback_test()
2389 mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, 0); in e100_loopback_test()
2390 nic->loopback = lb_none; in e100_loopback_test()
2391 e100_clean_cbs(nic); in e100_loopback_test()
2392 e100_hw_reset(nic); in e100_loopback_test()
2394 e100_rx_clean_list(nic); in e100_loopback_test()
2406 struct nic *nic = netdev_priv(netdev); in e100_get_link_ksettings() local
2408 mii_ethtool_get_link_ksettings(&nic->mii, cmd); in e100_get_link_ksettings()
2416 struct nic *nic = netdev_priv(netdev); in e100_set_link_ksettings() local
2419 mdio_write(netdev, nic->mii.phy_id, MII_BMCR, BMCR_RESET); in e100_set_link_ksettings()
2420 err = mii_ethtool_set_link_ksettings(&nic->mii, cmd); in e100_set_link_ksettings()
2421 e100_exec_cb(nic, NULL, e100_configure); in e100_set_link_ksettings()
2429 struct nic *nic = netdev_priv(netdev); in e100_get_drvinfo() local
2431 strscpy(info->bus_info, pci_name(nic->pdev), in e100_get_drvinfo()
2438 struct nic *nic = netdev_priv(netdev); in e100_get_regs_len() local
2443 return (1 + E100_PHY_REGS) * sizeof(u32) + sizeof(nic->mem->dump_buf); in e100_get_regs_len()
2449 struct nic *nic = netdev_priv(netdev); in e100_get_regs() local
2453 regs->version = (1 << 24) | nic->pdev->revision; in e100_get_regs()
2454 buff[0] = ioread8(&nic->csr->scb.cmd_hi) << 24 | in e100_get_regs()
2455 ioread8(&nic->csr->scb.cmd_lo) << 16 | in e100_get_regs()
2456 ioread16(&nic->csr->scb.status); in e100_get_regs()
2462 buff[1 + i] = mdio_read(netdev, nic->mii.phy_id, in e100_get_regs()
2464 memset(nic->mem->dump_buf, 0, sizeof(nic->mem->dump_buf)); in e100_get_regs()
2465 e100_exec_cb(nic, NULL, e100_dump); in e100_get_regs()
2467 memcpy(&buff[1 + E100_PHY_REGS], nic->mem->dump_buf, in e100_get_regs()
2468 sizeof(nic->mem->dump_buf)); in e100_get_regs()
2473 struct nic *nic = netdev_priv(netdev); in e100_get_wol() local
2474 wol->supported = (nic->mac >= mac_82558_D101_A4) ? WAKE_MAGIC : 0; in e100_get_wol()
2475 wol->wolopts = (nic->flags & wol_magic) ? WAKE_MAGIC : 0; in e100_get_wol()
2480 struct nic *nic = netdev_priv(netdev); in e100_set_wol() local
2483 !device_can_wakeup(&nic->pdev->dev)) in e100_set_wol()
2487 nic->flags |= wol_magic; in e100_set_wol()
2489 nic->flags &= ~wol_magic; in e100_set_wol()
2491 device_set_wakeup_enable(&nic->pdev->dev, wol->wolopts); in e100_set_wol()
2493 e100_exec_cb(nic, NULL, e100_configure); in e100_set_wol()
2500 struct nic *nic = netdev_priv(netdev); in e100_get_msglevel() local
2501 return nic->msg_enable; in e100_get_msglevel()
2506 struct nic *nic = netdev_priv(netdev); in e100_set_msglevel() local
2507 nic->msg_enable = value; in e100_set_msglevel()
2512 struct nic *nic = netdev_priv(netdev); in e100_nway_reset() local
2513 return mii_nway_restart(&nic->mii); in e100_nway_reset()
2518 struct nic *nic = netdev_priv(netdev); in e100_get_link() local
2519 return mii_link_ok(&nic->mii); in e100_get_link()
2524 struct nic *nic = netdev_priv(netdev); in e100_get_eeprom_len() local
2525 return nic->eeprom_wc << 1; in e100_get_eeprom_len()
2532 struct nic *nic = netdev_priv(netdev); in e100_get_eeprom() local
2535 memcpy(bytes, &((u8 *)nic->eeprom)[eeprom->offset], eeprom->len); in e100_get_eeprom()
2543 struct nic *nic = netdev_priv(netdev); in e100_set_eeprom() local
2548 memcpy(&((u8 *)nic->eeprom)[eeprom->offset], bytes, eeprom->len); in e100_set_eeprom()
2550 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()
2574 struct nic *nic = netdev_priv(netdev); in e100_set_ringparam() local
2575 struct param_range *rfds = &nic->params.rfds; in e100_set_ringparam()
2576 struct param_range *cbs = &nic->params.cbs; in e100_set_ringparam()
2582 e100_down(nic); in e100_set_ringparam()
2587 netif_info(nic, drv, nic->netdev, "Ring Param settings: rx: %d, tx %d\n", in e100_set_ringparam()
2590 e100_up(nic); in e100_set_ringparam()
2608 struct nic *nic = netdev_priv(netdev); in e100_diag_test() local
2612 data[0] = !mii_link_ok(&nic->mii); in e100_diag_test()
2613 data[1] = e100_eeprom_load(nic); in e100_diag_test()
2617 mii_ethtool_gset(&nic->mii, &cmd); in e100_diag_test()
2620 e100_down(nic); in e100_diag_test()
2621 data[2] = e100_self_test(nic); in e100_diag_test()
2622 data[3] = e100_loopback_test(nic, lb_mac); in e100_diag_test()
2623 data[4] = e100_loopback_test(nic, lb_phy); in e100_diag_test()
2626 mii_ethtool_sset(&nic->mii, &cmd); in e100_diag_test()
2629 e100_up(nic); in e100_diag_test()
2640 struct nic *nic = netdev_priv(netdev); in e100_set_phys_id() local
2647 u16 led_reg = (nic->phy == phy_82552_v) ? E100_82552_LED_OVERRIDE : in e100_set_phys_id()
2656 leds = (nic->phy == phy_82552_v) ? E100_82552_LED_ON : in e100_set_phys_id()
2657 (nic->mac < mac_82559_D101M) ? led_on_557 : led_on_559; in e100_set_phys_id()
2661 leds = (nic->phy == phy_82552_v) ? E100_82552_LED_OFF : led_off; in e100_set_phys_id()
2668 mdio_write(netdev, nic->mii.phy_id, led_reg, leds); in e100_set_phys_id()
2703 struct nic *nic = netdev_priv(netdev); in e100_get_ethtool_stats() local
2709 data[i++] = nic->tx_deferred; in e100_get_ethtool_stats()
2710 data[i++] = nic->tx_single_collisions; in e100_get_ethtool_stats()
2711 data[i++] = nic->tx_multiple_collisions; in e100_get_ethtool_stats()
2712 data[i++] = nic->tx_fc_pause; in e100_get_ethtool_stats()
2713 data[i++] = nic->rx_fc_pause; in e100_get_ethtool_stats()
2714 data[i++] = nic->rx_fc_unsupported; in e100_get_ethtool_stats()
2715 data[i++] = nic->tx_tco_frames; in e100_get_ethtool_stats()
2716 data[i++] = nic->rx_tco_frames; in e100_get_ethtool_stats()
2717 data[i++] = nic->rx_short_frame_errors; in e100_get_ethtool_stats()
2718 data[i++] = nic->rx_over_length_errors; in e100_get_ethtool_stats()
2760 struct nic *nic = netdev_priv(netdev); in e100_do_ioctl() local
2762 return generic_mii_ioctl(&nic->mii, if_mii(ifr), cmd, NULL); in e100_do_ioctl()
2765 static int e100_alloc(struct nic *nic) in e100_alloc() argument
2767 nic->mem = dma_alloc_coherent(&nic->pdev->dev, sizeof(struct mem), in e100_alloc()
2768 &nic->dma_addr, GFP_KERNEL); in e100_alloc()
2769 return nic->mem ? 0 : -ENOMEM; in e100_alloc()
2772 static void e100_free(struct nic *nic) in e100_free() argument
2774 if (nic->mem) { in e100_free()
2775 dma_free_coherent(&nic->pdev->dev, sizeof(struct mem), in e100_free()
2776 nic->mem, nic->dma_addr); in e100_free()
2777 nic->mem = NULL; in e100_free()
2783 struct nic *nic = netdev_priv(netdev); in e100_open() local
2787 if ((err = e100_up(nic))) in e100_open()
2788 netif_err(nic, ifup, nic->netdev, "Cannot open interface, aborting\n"); in e100_open()
2801 struct nic *nic = netdev_priv(netdev); in e100_set_features() local
2808 e100_exec_cb(nic, NULL, e100_configure); in e100_set_features()
2830 struct nic *nic; in e100_probe() local
2833 if (!(netdev = alloc_etherdev(sizeof(struct nic)))) in e100_probe()
2845 nic = netdev_priv(netdev); in e100_probe()
2846 netif_napi_add_weight(netdev, &nic->napi, e100_poll, E100_NAPI_WEIGHT); in e100_probe()
2847 nic->netdev = netdev; in e100_probe()
2848 nic->pdev = pdev; in e100_probe()
2849 nic->msg_enable = (1 << debug) - 1; in e100_probe()
2850 nic->mdio_ctrl = mdio_ctrl_hw; in e100_probe()
2854 netif_err(nic, probe, nic->netdev, "Cannot enable PCI device, aborting\n"); in e100_probe()
2859 netif_err(nic, probe, nic->netdev, "Cannot find proper PCI device base address, aborting\n"); in e100_probe()
2865 netif_err(nic, probe, nic->netdev, "Cannot obtain PCI resources, aborting\n"); in e100_probe()
2870 netif_err(nic, probe, nic->netdev, "No usable DMA configuration, aborting\n"); in e100_probe()
2877 netif_info(nic, probe, nic->netdev, "using i/o access mode\n"); in e100_probe()
2879 nic->csr = pci_iomap(pdev, (use_io ? 1 : 0), sizeof(struct csr)); in e100_probe()
2880 if (!nic->csr) { in e100_probe()
2881 netif_err(nic, probe, nic->netdev, "Cannot map device registers, aborting\n"); in e100_probe()
2887 nic->flags |= ich; in e100_probe()
2889 nic->flags &= ~ich; in e100_probe()
2891 e100_get_defaults(nic); in e100_probe()
2894 if (nic->mac < mac_82558_D101_A4) in e100_probe()
2898 spin_lock_init(&nic->cb_lock); in e100_probe()
2899 spin_lock_init(&nic->cmd_lock); in e100_probe()
2900 spin_lock_init(&nic->mdio_lock); in e100_probe()
2905 e100_hw_reset(nic); in e100_probe()
2909 timer_setup(&nic->watchdog, e100_watchdog, 0); in e100_probe()
2911 INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task); in e100_probe()
2913 if ((err = e100_alloc(nic))) { in e100_probe()
2914 netif_err(nic, probe, nic->netdev, "Cannot alloc driver memory, aborting\n"); in e100_probe()
2918 if ((err = e100_eeprom_load(nic))) in e100_probe()
2921 e100_phy_init(nic); in e100_probe()
2923 eth_hw_addr_set(netdev, (u8 *)nic->eeprom); in e100_probe()
2926 netif_err(nic, probe, nic->netdev, "Invalid MAC address from EEPROM, aborting\n"); in e100_probe()
2930 netif_err(nic, probe, nic->netdev, "Invalid MAC address from EEPROM, you MUST configure one.\n"); in e100_probe()
2935 if ((nic->mac >= mac_82558_D101_A4) && in e100_probe()
2936 (le16_to_cpu(nic->eeprom[eeprom_id]) & eeprom_id_wol)) { in e100_probe()
2937 nic->flags |= wol_magic; in e100_probe()
2946 netif_err(nic, probe, nic->netdev, "Cannot register net device, aborting\n"); in e100_probe()
2949 nic->cbs_pool = dma_pool_create(netdev->name, in e100_probe()
2950 &nic->pdev->dev, in e100_probe()
2951 nic->params.cbs.max * sizeof(struct cb), in e100_probe()
2954 if (!nic->cbs_pool) { in e100_probe()
2955 netif_err(nic, probe, nic->netdev, "Cannot create DMA pool, aborting\n"); in e100_probe()
2959 netif_info(nic, probe, nic->netdev, in e100_probe()
2969 e100_free(nic); in e100_probe()
2971 pci_iounmap(pdev, nic->csr); in e100_probe()
2986 struct nic *nic = netdev_priv(netdev); in e100_remove() local
2988 e100_free(nic); in e100_remove()
2989 pci_iounmap(pdev, nic->csr); in e100_remove()
2990 dma_pool_destroy(nic->cbs_pool); in e100_remove()
3003 struct nic *nic = netdev_priv(netdev); in __e100_shutdown() local
3008 e100_down(nic); in __e100_shutdown()
3010 if ((nic->flags & wol_magic) | e100_asf(nic)) { in __e100_shutdown()
3012 if (nic->phy == phy_82552_v) { in __e100_shutdown()
3013 u16 smartspeed = mdio_read(netdev, nic->mii.phy_id, in __e100_shutdown()
3016 mdio_write(netdev, nic->mii.phy_id, in __e100_shutdown()
3051 struct nic *nic = netdev_priv(netdev); in e100_resume() local
3062 if (nic->phy == phy_82552_v) { in e100_resume()
3063 u16 smartspeed = mdio_read(netdev, nic->mii.phy_id, in e100_resume()
3066 mdio_write(netdev, nic->mii.phy_id, in e100_resume()
3072 e100_up(nic); in e100_resume()
3096 struct nic *nic = netdev_priv(netdev); in e100_io_error_detected() local
3104 e100_down(nic); in e100_io_error_detected()
3120 struct nic *nic = netdev_priv(netdev); in e100_io_slot_reset() local
3131 e100_hw_reset(nic); in e100_io_slot_reset()
3132 e100_phy_init(nic); in e100_io_slot_reset()
3147 struct nic *nic = netdev_priv(netdev); in e100_io_resume() local
3155 mod_timer(&nic->watchdog, jiffies); in e100_io_resume()