Lines Matching refs:dev
186 /* max supported ethernet frame size -- must be at least (dev->mtu+18+4).*/
192 /* Size of the Tx bounce buffers -- must be at least (dev->mtu+18+4). */
585 struct net_device *dev;
606 unsigned int default_port : 4; /* Last dev->if_port value. */
640 static int rtl8139_open (struct net_device *dev);
641 static int mdio_read (struct net_device *dev, int phy_id, int location);
642 static void mdio_write (struct net_device *dev, int phy_id, int location,
645 static void rtl8139_tx_timeout (struct net_device *dev, unsigned int txqueue);
646 static void rtl8139_init_ring (struct net_device *dev);
648 struct net_device *dev);
650 static void rtl8139_poll_controller(struct net_device *dev);
652 static int rtl8139_set_mac_address(struct net_device *dev, void *p);
655 static int rtl8139_close (struct net_device *dev);
656 static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
657 static void rtl8139_get_stats64(struct net_device *dev,
659 static void rtl8139_set_rx_mode (struct net_device *dev);
660 static void __set_rx_mode (struct net_device *dev);
661 static void rtl8139_hw_start (struct net_device *dev);
718 static void __rtl8139_cleanup_dev (struct net_device *dev)
720 struct rtl8139_private *tp = netdev_priv(dev);
723 assert (dev != NULL);
733 free_netdev(dev);
756 struct device *d = &pdev->dev;
758 struct net_device *dev;
775 /* dev and priv zeroed in alloc_etherdev */
776 dev = alloc_etherdev (sizeof (*tp));
777 if (dev == NULL)
780 SET_NETDEV_DEV(dev, &pdev->dev);
782 tp = netdev_priv(dev);
839 dev_err(&pdev->dev, "Chip not responding, ignoring board\n");
854 dev_dbg(&pdev->dev, "unknown chip version, assuming RTL-8139\n");
855 dev_dbg(&pdev->dev, "TxConfig = 0x%x\n", RTL_R32 (TxConfig));
891 return dev;
894 __rtl8139_cleanup_dev (dev);
900 static int rtl8139_set_features(struct net_device *dev, netdev_features_t features)
902 struct rtl8139_private *tp = netdev_priv(dev);
904 netdev_features_t changed = features ^ dev->features;
946 struct net_device *dev = NULL;
970 dev_info(&pdev->dev,
984 dev = rtl8139_init_board (pdev);
985 if (IS_ERR(dev))
986 return PTR_ERR(dev);
988 assert (dev != NULL);
989 tp = netdev_priv(dev);
990 tp->dev = dev;
997 ((__le16 *) (dev->dev_addr))[i] =
1001 dev->netdev_ops = &rtl8139_netdev_ops;
1002 dev->ethtool_ops = &rtl8139_ethtool_ops;
1003 dev->watchdog_timeo = TX_TIMEOUT;
1004 netif_napi_add(dev, &tp->napi, rtl8139_poll, 64);
1010 dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HIGHDMA;
1011 dev->vlan_features = dev->features;
1013 dev->hw_features |= NETIF_F_RXALL;
1014 dev->hw_features |= NETIF_F_RXFCS;
1017 dev->min_mtu = ETH_MIN_MTU;
1018 dev->max_mtu = MAX_ETH_DATA_SIZE;
1021 tp = netdev_priv(dev);
1031 tp->mii.dev = dev;
1037 /* dev is fully set up and ready to use now */
1039 dev->name, dev);
1040 i = register_netdev (dev);
1043 pci_set_drvdata (pdev, dev);
1045 netdev_info(dev, "%s at 0x%p, %pM, IRQ %d\n",
1047 ioaddr, dev->dev_addr, pdev->irq);
1049 netdev_dbg(dev, "Identified 8139 chip type '%s'\n",
1059 int mii_status = mdio_read(dev, phy, 1);
1061 u16 advertising = mdio_read(dev, phy, 4);
1063 netdev_info(dev, "MII transceiver %d status 0x%04x advertising %04x\n",
1068 netdev_info(dev, "No MII transceivers found! Assuming SYM transceiver\n");
1087 netdev_info(dev, "Media type forced to Full Duplex\n");
1093 netdev_info(dev, " Forcing %dMbps %s-duplex operation\n",
1096 mdio_write(dev, tp->phys[0], 0,
1108 __rtl8139_cleanup_dev (dev);
1116 struct net_device *dev = pci_get_drvdata (pdev);
1117 struct rtl8139_private *tp = netdev_priv(dev);
1119 assert (dev != NULL);
1123 unregister_netdev (dev);
1125 __rtl8139_cleanup_dev (dev);
1233 static int mdio_read (struct net_device *dev, int phy_id, int location)
1235 struct rtl8139_private *tp = netdev_priv(dev);
1275 static void mdio_write (struct net_device *dev, int phy_id, int location,
1278 struct rtl8139_private *tp = netdev_priv(dev);
1319 static int rtl8139_open (struct net_device *dev)
1321 struct rtl8139_private *tp = netdev_priv(dev);
1326 retval = request_irq(irq, rtl8139_interrupt, IRQF_SHARED, dev->name, dev);
1330 tp->tx_bufs = dma_alloc_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN,
1332 tp->rx_ring = dma_alloc_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN,
1335 free_irq(irq, dev);
1338 dma_free_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN,
1341 dma_free_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN,
1353 rtl8139_init_ring (dev);
1354 rtl8139_hw_start (dev);
1355 netif_start_queue (dev);
1357 netif_dbg(tp, ifup, dev,
1370 static void rtl_check_media (struct net_device *dev, unsigned int init_media)
1372 struct rtl8139_private *tp = netdev_priv(dev);
1380 static void rtl8139_hw_start (struct net_device *dev)
1382 struct rtl8139_private *tp = netdev_priv(dev);
1396 RTL_W32_F (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0)));
1397 RTL_W32_F (MAC0 + 4, le16_to_cpu (*(__le16 *) (dev->dev_addr + 4)));
1411 rtl_check_media (dev, 1);
1420 netdev_dbg(dev, "init buffer addresses\n");
1431 rtl8139_set_rx_mode (dev);
1446 /* Initialize the Rx and Tx rings, along with various 'dev' bits. */
1447 static void rtl8139_init_ring (struct net_device *dev)
1449 struct rtl8139_private *tp = netdev_priv(dev);
1465 static inline void rtl8139_tune_twister (struct net_device *dev,
1481 static void rtl8139_tune_twister (struct net_device *dev,
1567 static inline void rtl8139_thread_iter (struct net_device *dev,
1573 mii_lpa = mdio_read (dev, tp->phys[0], MII_LPA);
1582 netdev_info(dev, "Setting %s-duplex based on MII #%d link partner ability of %04x\n",
1586 netdev_info(dev, "media is unconnected, link down, or incompatible connection\n");
1598 rtl8139_tune_twister (dev, tp);
1600 netdev_dbg(dev, "Media selection tick, Link partner %04x\n",
1602 netdev_dbg(dev, "Other registers are IntMask %04x IntStatus %04x\n",
1604 netdev_dbg(dev, "Chip config %02x %02x\n",
1612 struct net_device *dev = tp->mii.dev;
1617 if (!netif_running(dev))
1624 rtl8139_thread_iter(dev, tp, tp->mmio_addr);
1658 struct net_device *dev = tp->mii.dev;
1664 netif_stop_queue(dev);
1667 netdev_dbg(dev, "Transmit timeout, status %02x %04x %04x media %02x\n",
1671 netdev_dbg(dev, "Tx queue start entry %ld dirty entry %ld\n",
1674 netdev_dbg(dev, "Tx descriptor %d is %08x%s\n",
1697 rtl8139_hw_start(dev);
1698 netif_wake_queue(dev);
1703 static void rtl8139_tx_timeout(struct net_device *dev, unsigned int txqueue)
1705 struct rtl8139_private *tp = netdev_priv(dev);
1715 struct net_device *dev)
1717 struct rtl8139_private *tp = netdev_priv(dev);
1734 dev->stats.tx_dropped++;
1751 netif_stop_queue (dev);
1754 netif_dbg(tp, tx_queued, dev, "Queued Tx packet size %u to slot %d\n",
1761 static void rtl8139_tx_interrupt (struct net_device *dev,
1767 assert (dev != NULL);
1784 netif_dbg(tp, tx_err, dev, "Transmit error, Tx status %08x\n",
1786 dev->stats.tx_errors++;
1788 dev->stats.tx_aborted_errors++;
1794 dev->stats.tx_carrier_errors++;
1796 dev->stats.tx_window_errors++;
1802 dev->stats.tx_fifo_errors++;
1804 dev->stats.collisions += (txstatus >> 24) & 15;
1817 netdev_err(dev, "Out-of-sync dirty pointer, %ld vs. %ld\n",
1827 netif_wake_queue (dev);
1833 static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
1841 netif_dbg(tp, rx_err, dev, "Ethernet frame had errors, status %08x\n",
1843 dev->stats.rx_errors++;
1846 netdev_dbg(dev, "Oversized Ethernet frame, status %04x!\n",
1851 dev->stats.rx_frame_errors++;
1853 dev->stats.rx_length_errors++;
1855 dev->stats.rx_crc_errors++;
1879 netdev_warn(dev, "rx stop wait too long\n");
1890 netdev_warn(dev, "tx/rx enable wait too long\n");
1901 netdev_dbg(dev, "init buffer addresses\n");
1910 __set_rx_mode (dev);
1938 tp->dev->stats.rx_errors++;
1940 tp->dev->stats.rx_fifo_errors++;
1946 static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
1955 netdev_dbg(dev, "In %s(), current %04x BufAddr %04x, free to %04x, Cmd %02x\n",
1959 while (netif_running(dev) && received < budget &&
1971 if (likely(!(dev->features & NETIF_F_RXFCS)))
1976 netif_dbg(tp, rx_status, dev, "%s() status %04x, size %04x, cur %04x\n",
1992 netdev_dbg(dev, "hung FIFO. Reset\n");
1996 netif_dbg(tp, intr, dev, "fifo copy in progress\n");
2012 if ((dev->features & NETIF_F_RXALL) &&
2020 dev->stats.rx_errors++;
2022 dev->stats.rx_crc_errors++;
2026 dev->stats.rx_length_errors++;
2030 rtl8139_rx_err (rx_status, dev, tp, ioaddr);
2048 skb->protocol = eth_type_trans (skb, dev);
2057 dev->stats.rx_dropped++;
2070 netdev_dbg(dev, "Done %s(), current %04x BufAddr %04x, free to %04x, Cmd %02x\n",
2088 static void rtl8139_weird_interrupt (struct net_device *dev,
2093 netdev_dbg(dev, "Abnormal interrupt, status %08x\n", status);
2095 assert (dev != NULL);
2100 dev->stats.rx_missed_errors += RTL_R32 (RxMissed);
2105 rtl_check_media(dev, 0);
2110 dev->stats.rx_errors++;
2113 dev->stats.rx_length_errors++;
2115 dev->stats.rx_fifo_errors++;
2121 netdev_err(dev, "PCI Bus error %04x\n", pci_cmd_status);
2128 struct net_device *dev = tp->dev;
2135 work_done += rtl8139_rx(dev, tp, budget);
2154 struct net_device *dev = (struct net_device *) dev_instance;
2155 struct rtl8139_private *tp = netdev_priv(dev);
2175 if (unlikely(!netif_running(dev))) {
2200 rtl8139_weird_interrupt (dev, tp, ioaddr,
2204 rtl8139_tx_interrupt (dev, tp, ioaddr);
2211 netdev_dbg(dev, "exiting interrupt, intr_status=%#4.4x\n",
2221 static void rtl8139_poll_controller(struct net_device *dev)
2223 struct rtl8139_private *tp = netdev_priv(dev);
2227 rtl8139_interrupt(irq, dev);
2232 static int rtl8139_set_mac_address(struct net_device *dev, void *p)
2234 struct rtl8139_private *tp = netdev_priv(dev);
2241 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
2246 RTL_W32_F(MAC0 + 0, cpu_to_le32 (*(u32 *) (dev->dev_addr + 0)));
2247 RTL_W32_F(MAC0 + 4, cpu_to_le32 (*(u32 *) (dev->dev_addr + 4)));
2255 static int rtl8139_close (struct net_device *dev)
2257 struct rtl8139_private *tp = netdev_priv(dev);
2261 netif_stop_queue(dev);
2264 netif_dbg(tp, ifdown, dev, "Shutting down ethercard, status was 0x%04x\n",
2276 dev->stats.rx_missed_errors += RTL_R32 (RxMissed);
2281 free_irq(tp->pci_dev->irq, dev);
2285 dma_free_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN,
2287 dma_free_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN,
2305 static void rtl8139_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2307 struct rtl8139_private *tp = netdev_priv(dev);
2339 static int rtl8139_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2341 struct rtl8139_private *tp = netdev_priv(dev);
2379 static void rtl8139_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
2381 struct rtl8139_private *tp = netdev_priv(dev);
2387 static int rtl8139_get_link_ksettings(struct net_device *dev,
2390 struct rtl8139_private *tp = netdev_priv(dev);
2397 static int rtl8139_set_link_ksettings(struct net_device *dev,
2400 struct rtl8139_private *tp = netdev_priv(dev);
2408 static int rtl8139_nway_reset(struct net_device *dev)
2410 struct rtl8139_private *tp = netdev_priv(dev);
2414 static u32 rtl8139_get_link(struct net_device *dev)
2416 struct rtl8139_private *tp = netdev_priv(dev);
2420 static u32 rtl8139_get_msglevel(struct net_device *dev)
2422 struct rtl8139_private *tp = netdev_priv(dev);
2426 static void rtl8139_set_msglevel(struct net_device *dev, u32 datum)
2428 struct rtl8139_private *tp = netdev_priv(dev);
2432 static int rtl8139_get_regs_len(struct net_device *dev)
2438 tp = netdev_priv(dev);
2442 static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf)
2449 tp = netdev_priv(dev);
2458 static int rtl8139_get_sset_count(struct net_device *dev, int sset)
2468 static void rtl8139_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data)
2470 struct rtl8139_private *tp = netdev_priv(dev);
2478 static void rtl8139_get_strings(struct net_device *dev, u32 stringset, u8 *data)
2500 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2502 struct rtl8139_private *tp = netdev_priv(dev);
2505 if (!netif_running(dev))
2517 rtl8139_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
2519 struct rtl8139_private *tp = netdev_priv(dev);
2524 if (netif_running(dev)) {
2526 dev->stats.rx_missed_errors += RTL_R32 (RxMissed);
2531 netdev_stats_to_stats64(stats, &dev->stats);
2549 static void __set_rx_mode (struct net_device *dev)
2551 struct rtl8139_private *tp = netdev_priv(dev);
2557 netdev_dbg(dev, "rtl8139_set_rx_mode(%04x) done -- Rx config %08x\n",
2558 dev->flags, RTL_R32(RxConfig));
2561 if (dev->flags & IFF_PROMISC) {
2566 } else if ((netdev_mc_count(dev) > multicast_filter_limit) ||
2567 (dev->flags & IFF_ALLMULTI)) {
2575 netdev_for_each_mc_addr(ha, dev) {
2583 if (dev->features & NETIF_F_RXALL)
2596 static void rtl8139_set_rx_mode (struct net_device *dev)
2599 struct rtl8139_private *tp = netdev_priv(dev);
2602 __set_rx_mode(dev);
2608 struct net_device *dev = dev_get_drvdata(device);
2609 struct rtl8139_private *tp = netdev_priv(dev);
2613 if (!netif_running (dev))
2616 netif_device_detach (dev);
2625 dev->stats.rx_missed_errors += RTL_R32 (RxMissed);
2635 struct net_device *dev = dev_get_drvdata(device);
2637 if (!netif_running (dev))
2640 rtl8139_init_ring (dev);
2641 rtl8139_hw_start (dev);
2642 netif_device_attach (dev);