Lines Matching defs:dev
388 struct net_device *dev;
449 static struct sk_buff *alloc_rxbuf_skb(struct net_device *dev,
454 skb = netdev_alloc_skb(dev, RX_BUF_SIZE);
457 *dma_handle = dma_map_single(&hwdev->dev, skb->data, RX_BUF_SIZE,
459 if (dma_mapping_error(&hwdev->dev, *dma_handle)) {
469 dma_unmap_single(&hwdev->dev, dma_handle, RX_BUF_SIZE,
476 static int tc35815_open(struct net_device *dev);
478 struct net_device *dev);
480 static int tc35815_rx(struct net_device *dev, int limit);
482 static void tc35815_txdone(struct net_device *dev);
483 static int tc35815_close(struct net_device *dev);
484 static struct net_device_stats *tc35815_get_stats(struct net_device *dev);
485 static void tc35815_set_multicast_list(struct net_device *dev);
486 static void tc35815_tx_timeout(struct net_device *dev, unsigned int txqueue);
488 static void tc35815_poll_controller(struct net_device *dev);
493 static void tc35815_chip_reset(struct net_device *dev);
494 static void tc35815_chip_init(struct net_device *dev);
497 static void panic_queues(struct net_device *dev);
504 struct net_device *dev = bus->priv;
506 (struct tc35815_regs __iomem *)dev->base_addr;
521 struct net_device *dev = bus->priv;
523 (struct tc35815_regs __iomem *)dev->base_addr;
538 static void tc_handle_link_change(struct net_device *dev)
540 struct tc35815_local *lp = netdev_priv(dev);
541 struct phy_device *phydev = dev->phydev;
549 (struct tc35815_regs __iomem *)dev->base_addr;
585 if (dev->flags & IFF_PROMISC)
586 tc35815_set_multicast_list(dev);
600 dev->name,
607 static int tc_mii_probe(struct net_device *dev)
610 struct tc35815_local *lp = netdev_priv(dev);
615 printk(KERN_ERR "%s: no PHY found\n", dev->name);
620 phydev = phy_connect(dev, phydev_name(phydev),
624 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
656 static int tc_mii_init(struct net_device *dev)
658 struct tc35815_local *lp = netdev_priv(dev);
671 lp->mii_bus->priv = dev;
672 lp->mii_bus->parent = &lp->pci_dev->dev;
676 err = tc_mii_probe(dev);
695 static int tc35815_mac_match(struct device *dev, const void *data)
697 struct platform_device *plat_dev = to_platform_device(dev);
703 static int tc35815_read_plat_dev_addr(struct net_device *dev)
705 struct tc35815_local *lp = netdev_priv(dev);
710 eth_hw_addr_set(dev, pd->platform_data);
712 return is_valid_ether_addr(dev->dev_addr) ? 0 : -ENODEV;
717 static int tc35815_read_plat_dev_addr(struct net_device *dev)
723 static int tc35815_init_dev_addr(struct net_device *dev)
726 (struct tc35815_regs __iomem *)dev->base_addr;
741 eth_hw_addr_set(dev, addr);
742 if (!is_valid_ether_addr(dev->dev_addr))
743 return tc35815_read_plat_dev_addr(dev);
766 struct net_device *dev;
773 dev_printk(KERN_DEBUG, &pdev->dev,
779 dev_warn(&pdev->dev, "no IRQ assigned.\n");
783 /* dev zeroed in alloc_etherdev */
784 dev = alloc_etherdev(sizeof(*lp));
785 if (dev == NULL)
788 SET_NETDEV_DEV(dev, &pdev->dev);
789 lp = netdev_priv(dev);
790 lp->dev = dev;
803 dev->netdev_ops = &tc35815_netdev_ops;
804 dev->ethtool_ops = &tc35815_ethtool_ops;
805 dev->watchdog_timeo = TC35815_TX_TIMEOUT;
806 netif_napi_add_weight(dev, &lp->napi, tc35815_poll, NAPI_WEIGHT);
808 dev->irq = pdev->irq;
809 dev->base_addr = (unsigned long)ioaddr;
818 pci_set_drvdata(pdev, dev);
821 tc35815_chip_reset(dev);
824 if (tc35815_init_dev_addr(dev)) {
825 dev_warn(&pdev->dev, "not valid ether addr\n");
826 eth_hw_addr_random(dev);
829 rc = register_netdev(dev);
834 dev->name,
836 dev->base_addr,
837 dev->dev_addr,
838 dev->irq);
840 rc = tc_mii_init(dev);
847 unregister_netdev(dev);
849 free_netdev(dev);
856 struct net_device *dev = pci_get_drvdata(pdev);
857 struct tc35815_local *lp = netdev_priv(dev);
859 phy_disconnect(dev->phydev);
862 unregister_netdev(dev);
863 free_netdev(dev);
867 tc35815_init_queues(struct net_device *dev)
869 struct tc35815_local *lp = netdev_priv(dev);
880 lp->fd_buf = dma_alloc_coherent(&lp->pci_dev->dev,
887 alloc_rxbuf_skb(dev, lp->pci_dev,
896 dma_free_coherent(&lp->pci_dev->dev,
904 dev->name, lp->fd_buf);
969 dev->name, lp->tfd_base, lp->rfd_base, lp->fbl_ptr);
974 tc35815_clear_queues(struct net_device *dev)
976 struct tc35815_local *lp = netdev_priv(dev);
986 printk("%s: tx_skbs mismatch(%d).\n", dev->name, i);
987 panic_queues(dev);
993 dma_unmap_single(&lp->pci_dev->dev,
1003 tc35815_init_queues(dev);
1007 tc35815_free_queues(struct net_device *dev)
1009 struct tc35815_local *lp = netdev_priv(dev);
1020 printk("%s: tx_skbs mismatch(%d).\n", dev->name, i);
1021 panic_queues(dev);
1027 dma_unmap_single(&lp->pci_dev->dev,
1051 dma_free_coherent(&lp->pci_dev->dev, PAGE_SIZE * FD_PAGE_NUM,
1113 panic_queues(struct net_device *dev)
1115 struct tc35815_local *lp = netdev_priv(dev);
1130 panic("%s: Illegal queue state.", dev->name);
1141 static int tc35815_tx_full(struct net_device *dev)
1143 struct tc35815_local *lp = netdev_priv(dev);
1147 static void tc35815_restart(struct net_device *dev)
1149 struct tc35815_local *lp = netdev_priv(dev);
1152 if (dev->phydev) {
1153 ret = phy_init_hw(dev->phydev);
1155 printk(KERN_ERR "%s: PHY init failed.\n", dev->name);
1160 tc35815_chip_reset(dev);
1161 tc35815_clear_queues(dev);
1162 tc35815_chip_init(dev);
1164 tc35815_set_multicast_list(dev);
1168 netif_wake_queue(dev);
1175 struct net_device *dev = lp->dev;
1177 tc35815_restart(dev);
1180 static void tc35815_schedule_restart(struct net_device *dev)
1182 struct tc35815_local *lp = netdev_priv(dev);
1184 (struct tc35815_regs __iomem *)dev->base_addr;
1195 static void tc35815_tx_timeout(struct net_device *dev, unsigned int txqueue)
1198 (struct tc35815_regs __iomem *)dev->base_addr;
1201 dev->name, tc_readl(&tr->Tx_Stat));
1204 tc35815_schedule_restart(dev);
1205 dev->stats.tx_errors++;
1217 tc35815_open(struct net_device *dev)
1219 struct tc35815_local *lp = netdev_priv(dev);
1225 if (request_irq(dev->irq, tc35815_interrupt, IRQF_SHARED,
1226 dev->name, dev))
1229 tc35815_chip_reset(dev);
1231 if (tc35815_init_queues(dev) != 0) {
1232 free_irq(dev->irq, dev);
1240 tc35815_chip_init(dev);
1243 netif_carrier_off(dev);
1245 phy_start(dev->phydev);
1250 netif_start_queue(dev);
1261 tc35815_send_packet(struct sk_buff *skb, struct net_device *dev)
1263 struct tc35815_local *lp = netdev_priv(dev);
1286 tc35815_txdone(dev);
1292 printk("%s: tx_skbs conflict.\n", dev->name);
1293 panic_queues(dev);
1299 lp->tx_skbs[lp->tfd_start].skb_dma = dma_map_single(&lp->pci_dev->dev,
1313 (struct tc35815_regs __iomem *)dev->base_addr;
1318 printk("%s: starting TxFD.\n", dev->name);
1325 printk("%s: queueing TxFD.\n", dev->name);
1335 if (tc35815_tx_full(dev)) {
1337 printk(KERN_WARNING "%s: TxFD Exhausted.\n", dev->name);
1338 netif_stop_queue(dev);
1351 static void tc35815_fatal_error_interrupt(struct net_device *dev, u32 status)
1355 dev->name, status);
1364 panic("%s: Too many fatal errors.", dev->name);
1365 printk(KERN_WARNING "%s: Resetting ...\n", dev->name);
1367 tc35815_schedule_restart(dev);
1370 static int tc35815_do_interrupt(struct net_device *dev, u32 status, int limit)
1372 struct tc35815_local *lp = netdev_priv(dev);
1377 tc35815_fatal_error_interrupt(dev, status);
1383 dev_warn(&dev->dev,
1386 dev->stats.rx_dropped++;
1391 dev_warn(&dev->dev,
1394 dev->stats.rx_dropped++;
1399 dev_warn(&dev->dev,
1402 dev->stats.rx_length_errors++;
1409 ret = tc35815_rx(dev, limit);
1416 tc35815_txdone(dev);
1430 struct net_device *dev = dev_id;
1431 struct tc35815_local *lp = netdev_priv(dev);
1433 (struct tc35815_regs __iomem *)dev->base_addr;
1443 dev->name);
1453 static void tc35815_poll_controller(struct net_device *dev)
1455 disable_irq(dev->irq);
1456 tc35815_interrupt(dev->irq, dev);
1457 enable_irq(dev->irq);
1463 tc35815_rx(struct net_device *dev, int limit)
1465 struct tc35815_local *lp = netdev_priv(dev);
1495 printk("%s: invalid BDID.\n", dev->name);
1496 panic_queues(dev);
1501 printk("%s: NULL skb.\n", dev->name);
1502 panic_queues(dev);
1510 dma_unmap_single(&lp->pci_dev->dev,
1519 skb->protocol = eth_type_trans(skb, dev);
1522 dev->stats.rx_packets++;
1523 dev->stats.rx_bytes += pkt_len;
1525 dev->stats.rx_errors++;
1527 dev_info(&dev->dev, "Rx error (status %x)\n",
1535 dev->stats.rx_length_errors++;
1537 dev->stats.rx_fifo_errors++;
1539 dev->stats.rx_crc_errors++;
1541 dev->stats.rx_frame_errors++;
1551 printk("%s: invalid BDID.\n", dev->name);
1552 panic_queues(dev);
1568 dev->name);
1569 panic_queues(dev);
1575 alloc_rxbuf_skb(dev,
1595 printk("%s: RxFD FDNext invalid.\n", dev->name);
1596 panic_queues(dev);
1624 struct net_device *dev = lp->dev;
1626 (struct tc35815_regs __iomem *)dev->base_addr;
1640 handled = tc35815_do_interrupt(dev, status, budget - received);
1664 tc35815_check_tx_stat(struct net_device *dev, int status)
1666 struct tc35815_local *lp = netdev_priv(dev);
1671 dev->stats.collisions += 16;
1673 dev->stats.collisions += status & Tx_TxColl_MASK;
1684 dev->stats.tx_packets++;
1688 dev->stats.tx_errors++;
1690 dev->stats.tx_aborted_errors++;
1694 dev->stats.tx_fifo_errors++;
1700 (struct tc35815_regs __iomem *)dev->base_addr;
1707 dev->stats.tx_fifo_errors++;
1711 dev->stats.tx_carrier_errors++;
1715 dev->stats.tx_aborted_errors++;
1719 dev->stats.tx_fifo_errors++;
1723 dev->stats.tx_heartbeat_errors++;
1727 printk(KERN_WARNING "%s: %s (%#x)\n", dev->name, msg, status);
1734 tc35815_txdone(struct net_device *dev)
1736 struct tc35815_local *lp = netdev_priv(dev);
1749 printk("%s: complete TxFD.\n", dev->name);
1752 tc35815_check_tx_stat(dev, status);
1758 printk("%s: tx_skbs mismatch.\n", dev->name);
1759 panic_queues(dev);
1765 dev->stats.tx_bytes += skb->len;
1766 dma_unmap_single(&lp->pci_dev->dev,
1779 printk("%s: TxFD FDNext invalid.\n", dev->name);
1780 panic_queues(dev);
1787 (struct tc35815_regs __iomem *)dev->base_addr;
1795 printk("%s: TxFD FDCtl invalid.\n", dev->name);
1796 panic_queues(dev);
1809 dev->name);
1822 if (netif_queue_stopped(dev) && !tc35815_tx_full(dev))
1823 netif_wake_queue(dev);
1828 tc35815_close(struct net_device *dev)
1830 struct tc35815_local *lp = netdev_priv(dev);
1832 netif_stop_queue(dev);
1834 if (dev->phydev)
1835 phy_stop(dev->phydev);
1839 tc35815_chip_reset(dev);
1840 free_irq(dev->irq, dev);
1842 tc35815_free_queues(dev);
1852 static struct net_device_stats *tc35815_get_stats(struct net_device *dev)
1855 (struct tc35815_regs __iomem *)dev->base_addr;
1856 if (netif_running(dev))
1858 dev->stats.rx_missed_errors += tc_readl(&tr->Miss_Cnt);
1860 return &dev->stats;
1863 static void tc35815_set_cam_entry(struct net_device *dev, int index,
1866 struct tc35815_local *lp = netdev_priv(dev);
1868 (struct tc35815_regs __iomem *)dev->base_addr;
1877 dev->name, index, addr);
1912 tc35815_set_multicast_list(struct net_device *dev)
1915 (struct tc35815_regs __iomem *)dev->base_addr;
1917 if (dev->flags & IFF_PROMISC) {
1921 struct tc35815_local *lp = netdev_priv(dev);
1927 } else if ((dev->flags & IFF_ALLMULTI) ||
1928 netdev_mc_count(dev) > CAM_ENTRY_MAX - 3) {
1932 } else if (!netdev_mc_empty(dev)) {
1940 netdev_for_each_mc_addr(ha, dev) {
1942 tc35815_set_cam_entry(dev, i + 2, ha->addr);
1954 static void tc35815_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1956 struct tc35815_local *lp = netdev_priv(dev);
1963 static u32 tc35815_get_msglevel(struct net_device *dev)
1965 struct tc35815_local *lp = netdev_priv(dev);
1969 static void tc35815_set_msglevel(struct net_device *dev, u32 datum)
1971 struct tc35815_local *lp = netdev_priv(dev);
1975 static int tc35815_get_sset_count(struct net_device *dev, int sset)
1977 struct tc35815_local *lp = netdev_priv(dev);
1987 static void tc35815_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data)
1989 struct tc35815_local *lp = netdev_priv(dev);
2005 static void tc35815_get_strings(struct net_device *dev, u32 stringset, u8 *data)
2022 static void tc35815_chip_reset(struct net_device *dev)
2025 (struct tc35815_regs __iomem *)dev->base_addr;
2033 printk(KERN_ERR "%s: MAC reset failed.\n", dev->name);
2064 static void tc35815_chip_init(struct net_device *dev)
2066 struct tc35815_local *lp = netdev_priv(dev);
2068 (struct tc35815_regs __iomem *)dev->base_addr;
2072 tc35815_set_cam_entry(dev, CAM_ENTRY_SOURCE, dev->dev_addr);
2104 if (!dev->phydev || !lp->link || lp->duplex == DUPLEX_FULL)
2112 struct net_device *dev = pci_get_drvdata(pdev);
2113 struct tc35815_local *lp = netdev_priv(dev);
2117 if (!netif_running(dev))
2119 netif_device_detach(dev);
2120 if (dev->phydev)
2121 phy_stop(dev->phydev);
2123 tc35815_chip_reset(dev);
2131 struct net_device *dev = pci_get_drvdata(pdev);
2134 if (!netif_running(dev))
2137 tc35815_restart(dev);
2138 netif_carrier_off(dev);
2139 if (dev->phydev)
2140 phy_start(dev->phydev);
2141 netif_device_attach(dev);