Lines Matching refs:dev

79 static int axnet_open(struct net_device *dev);
80 static int axnet_close(struct net_device *dev);
81 static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
83 struct net_device *dev);
84 static struct net_device_stats *get_stats(struct net_device *dev);
85 static void set_multicast_list(struct net_device *dev);
86 static void axnet_tx_timeout(struct net_device *dev, unsigned int txqueue);
89 static void axnet_reset_8390(struct net_device *dev);
96 static void block_input(struct net_device *dev, int count,
98 static void block_output(struct net_device *dev, int count,
103 static void AX88190_init(struct net_device *dev, int startp);
104 static int ax_open(struct net_device *dev);
105 static int ax_close(struct net_device *dev);
122 static inline struct axnet_dev *PRIV(struct net_device *dev) in PRIV() argument
124 void *p = (char *)netdev_priv(dev) + sizeof(struct ei_device); in PRIV()
143 struct net_device *dev; in axnet_probe() local
146 dev_dbg(&link->dev, "axnet_attach()\n"); in axnet_probe()
148 dev = alloc_etherdev(sizeof(struct ei_device) + sizeof(struct axnet_dev)); in axnet_probe()
149 if (!dev) in axnet_probe()
152 ei_local = netdev_priv(dev); in axnet_probe()
155 info = PRIV(dev); in axnet_probe()
157 link->priv = dev; in axnet_probe()
160 dev->netdev_ops = &axnet_netdev_ops; in axnet_probe()
162 dev->watchdog_timeo = TX_TIMEOUT; in axnet_probe()
169 struct net_device *dev = link->priv; in axnet_detach() local
171 dev_dbg(&link->dev, "axnet_detach(0x%p)\n", link); in axnet_detach()
173 unregister_netdev(dev); in axnet_detach()
177 free_netdev(dev); in axnet_detach()
188 struct net_device *dev = link->priv; in get_prom() local
189 unsigned int ioaddr = dev->base_addr; in get_prom()
216 axnet_reset_8390(dev); in get_prom()
227 eth_hw_addr_set(dev, addr); in get_prom()
276 struct net_device *dev = link->priv; in axnet_config() local
277 struct axnet_dev *info = PRIV(dev); in axnet_config()
280 dev_dbg(&link->dev, "axnet_config(0x%p)\n", link); in axnet_config()
299 dev->irq = link->irq; in axnet_config()
300 dev->base_addr = link->resource[0]->start; in axnet_config()
318 if (inb(dev->base_addr + AXNET_TEST) != 0) in axnet_config()
324 outb(0x10, dev->base_addr + AXNET_GPIO); /* select Internal PHY */ in axnet_config()
329 j = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 1); in axnet_config()
330 j2 = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 2); in axnet_config()
340 j = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 1); in axnet_config()
341 j2 = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 2); in axnet_config()
351 SET_NETDEV_DEV(dev, &link->dev); in axnet_config()
353 if (register_netdev(dev) != 0) { in axnet_config()
358 netdev_info(dev, "Asix AX88%d90: io %#3lx, irq %d, hw_addr %pM\n", in axnet_config()
360 dev->base_addr, dev->irq, dev->dev_addr); in axnet_config()
362 netdev_dbg(dev, " MII transceiver at index %d, status %x\n", in axnet_config()
365 netdev_notice(dev, " No MII transceivers found!\n"); in axnet_config()
381 struct net_device *dev = link->priv; in axnet_suspend() local
384 netif_device_detach(dev); in axnet_suspend()
391 struct net_device *dev = link->priv; in axnet_resume() local
392 struct axnet_dev *info = PRIV(dev); in axnet_resume()
398 axnet_reset_8390(dev); in axnet_resume()
399 AX88190_init(dev, 1); in axnet_resume()
400 netif_device_attach(dev); in axnet_resume()
467 static int axnet_open(struct net_device *dev) in axnet_open() argument
470 struct axnet_dev *info = PRIV(dev); in axnet_open()
472 unsigned int nic_base = dev->base_addr; in axnet_open()
474 dev_dbg(&link->dev, "axnet_open('%s')\n", dev->name); in axnet_open()
480 ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, "axnet_cs", dev); in axnet_open()
490 return ax_open(dev); in axnet_open()
495 static int axnet_close(struct net_device *dev) in axnet_close() argument
497 struct axnet_dev *info = PRIV(dev); in axnet_close()
500 dev_dbg(&link->dev, "axnet_close('%s')\n", dev->name); in axnet_close()
502 ax_close(dev); in axnet_close()
503 free_irq(dev->irq, dev); in axnet_close()
506 netif_stop_queue(dev); in axnet_close()
519 static void axnet_reset_8390(struct net_device *dev) in axnet_reset_8390() argument
521 unsigned int nic_base = dev->base_addr; in axnet_reset_8390()
538 netdev_err(dev, "axnet_reset_8390() did not complete\n"); in axnet_reset_8390()
546 struct net_device *dev = dev_id; in ei_irq_wrapper() local
547 PRIV(dev)->stale = 0; in ei_irq_wrapper()
554 struct net_device *dev = info->p_dev->priv; in ei_watchdog() local
555 unsigned int nic_base = dev->base_addr; in ei_watchdog()
559 if (!netif_device_present(dev)) goto reschedule; in ei_watchdog()
565 netdev_info(dev, "interrupt(s) dropped!\n"); in ei_watchdog()
566 ei_irq_wrapper(dev->irq, dev); in ei_watchdog()
580 netdev_info(dev, "MII is missing!\n"); in ei_watchdog()
588 netdev_info(dev, "%s link beat\n", link ? "found" : "lost"); in ei_watchdog()
592 netdev_info(dev, "autonegotiation complete: %dbaseT-%cD selected\n", in ei_watchdog()
595 netdev_info(dev, "link partner did not autonegotiate\n"); in ei_watchdog()
596 AX88190_init(dev, 1); in ei_watchdog()
608 static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) in axnet_ioctl() argument
610 struct axnet_dev *info = PRIV(dev); in axnet_ioctl()
612 unsigned int mii_addr = dev->base_addr + AXNET_MII_EEP; in axnet_ioctl()
629 static void get_8390_hdr(struct net_device *dev, in get_8390_hdr() argument
633 unsigned int nic_base = dev->base_addr; in get_8390_hdr()
648 static void block_input(struct net_device *dev, int count, in block_input() argument
651 unsigned int nic_base = dev->base_addr; in block_input()
652 struct ei_device *ei_local = netdev_priv(dev); in block_input()
656 netdev_dbg(dev, "[bi=%d]\n", count+4); in block_input()
669 static void block_output(struct net_device *dev, int count, in block_output() argument
672 unsigned int nic_base = dev->base_addr; in block_output()
674 pr_debug("%s: [bo=%d]\n", dev->name, count); in block_output()
813 static void ei_tx_intr(struct net_device *dev);
814 static void ei_tx_err(struct net_device *dev);
815 static void ei_receive(struct net_device *dev);
816 static void ei_rx_overrun(struct net_device *dev);
819 static void NS8390_trigger_send(struct net_device *dev, unsigned int length,
821 static void do_set_multicast_list(struct net_device *dev);
857 static int ax_open(struct net_device *dev) in ax_open() argument
860 struct ei_device *ei_local = netdev_priv(dev); in ax_open()
868 AX88190_init(dev, 1); in ax_open()
871 netif_start_queue(dev); in ax_open()
877 #define dev_lock(dev) (((struct ei_device *)netdev_priv(dev))->page_lock) argument
885 static int ax_close(struct net_device *dev) in ax_close() argument
893 spin_lock_irqsave(&dev_lock(dev), flags); in ax_close()
894 AX88190_init(dev, 0); in ax_close()
895 spin_unlock_irqrestore(&dev_lock(dev), flags); in ax_close()
896 netif_stop_queue(dev); in ax_close()
909 static void axnet_tx_timeout(struct net_device *dev, unsigned int txqueue) in axnet_tx_timeout() argument
911 long e8390_base = dev->base_addr; in axnet_tx_timeout()
912 struct ei_device *ei_local = netdev_priv(dev); in axnet_tx_timeout()
913 int txsr, isr, tickssofar = jiffies - dev_trans_start(dev); in axnet_tx_timeout()
916 dev->stats.tx_errors++; in axnet_tx_timeout()
923 netdev_dbg(dev, "Tx timed out, %s TSR=%#2x, ISR=%#2x, t=%d.\n", in axnet_tx_timeout()
928 if (!isr && !dev->stats.tx_packets) in axnet_tx_timeout()
939 ei_reset_8390(dev); in axnet_tx_timeout()
940 AX88190_init(dev, 1); in axnet_tx_timeout()
943 netif_wake_queue(dev); in axnet_tx_timeout()
955 struct net_device *dev) in axnet_start_xmit() argument
957 long e8390_base = dev->base_addr; in axnet_start_xmit()
958 struct ei_device *ei_local = netdev_priv(dev); in axnet_start_xmit()
963 netif_stop_queue(dev); in axnet_start_xmit()
997 netdev_dbg(dev, in axnet_start_xmit()
1008 netdev_dbg(dev, in axnet_start_xmit()
1015 netif_dbg(ei_local, tx_err, dev, in axnet_start_xmit()
1020 netif_stop_queue(dev); in axnet_start_xmit()
1023 dev->stats.tx_errors++; in axnet_start_xmit()
1034 ei_block_output(dev, length, skb->data, output_page); in axnet_start_xmit()
1038 ei_block_output(dev, length, packet, output_page); in axnet_start_xmit()
1044 NS8390_trigger_send(dev, send_length, output_page); in axnet_start_xmit()
1045 netif_trans_update(dev); in axnet_start_xmit()
1060 netif_stop_queue(dev); in axnet_start_xmit()
1062 netif_start_queue(dev); in axnet_start_xmit()
1071 dev->stats.tx_bytes += send_length; in axnet_start_xmit()
1090 struct net_device *dev = dev_id; in ax_interrupt() local
1097 e8390_base = dev->base_addr; in ax_interrupt()
1098 ei_local = netdev_priv(dev); in ax_interrupt()
1114 netdev_info(dev, "%s, isr=%#2x imr=%#2x\n", in ax_interrupt()
1123 netif_dbg(ei_local, intr, dev, "interrupt(isr=%#2.2x)\n", in ax_interrupt()
1133 if (!netif_running(dev) || (interrupts == 0xff)) { in ax_interrupt()
1134 netif_warn(ei_local, intr, dev, in ax_interrupt()
1151 ei_rx_overrun(dev); in ax_interrupt()
1155 ei_receive(dev); in ax_interrupt()
1159 ei_tx_intr(dev); in ax_interrupt()
1161 ei_tx_err(dev); in ax_interrupt()
1165 dev->stats.rx_frame_errors += inb_p(e8390_base + EN0_COUNTER0); in ax_interrupt()
1166 dev->stats.rx_crc_errors += inb_p(e8390_base + EN0_COUNTER1); in ax_interrupt()
1167 dev->stats.rx_missed_errors+= inb_p(e8390_base + EN0_COUNTER2); in ax_interrupt()
1178 netdev_warn(dev, in ax_interrupt()
1183 netdev_warn(dev, "unknown interrupt %#2x\n", in ax_interrupt()
1211 static void ei_tx_err(struct net_device *dev) in ei_tx_err() argument
1213 long e8390_base = dev->base_addr; in ei_tx_err()
1218 netdev_dbg(dev, "transmitter error (%#2x):", txsr); in ei_tx_err()
1233 ei_tx_intr(dev); in ei_tx_err()
1236 dev->stats.tx_errors++; in ei_tx_err()
1237 if (txsr & ENTSR_CRS) dev->stats.tx_carrier_errors++; in ei_tx_err()
1238 if (txsr & ENTSR_CDH) dev->stats.tx_heartbeat_errors++; in ei_tx_err()
1239 if (txsr & ENTSR_OWC) dev->stats.tx_window_errors++; in ei_tx_err()
1251 static void ei_tx_intr(struct net_device *dev) in ei_tx_intr() argument
1253 long e8390_base = dev->base_addr; in ei_tx_intr()
1254 struct ei_device *ei_local = netdev_priv(dev); in ei_tx_intr()
1266 netdev_err(dev, "%s: bogus last_tx_buffer %d, tx1=%d\n", in ei_tx_intr()
1273 NS8390_trigger_send(dev, ei_local->tx2, ei_local->tx_start_page + 6); in ei_tx_intr()
1274 netif_trans_update(dev); in ei_tx_intr()
1285 netdev_err(dev, "%s: bogus last_tx_buffer %d, tx2=%d\n", in ei_tx_intr()
1292 NS8390_trigger_send(dev, ei_local->tx1, ei_local->tx_start_page); in ei_tx_intr()
1293 netif_trans_update(dev); in ei_tx_intr()
1307 dev->stats.collisions++; in ei_tx_intr()
1309 dev->stats.tx_packets++; in ei_tx_intr()
1312 dev->stats.tx_errors++; in ei_tx_intr()
1315 dev->stats.tx_aborted_errors++; in ei_tx_intr()
1316 dev->stats.collisions += 16; in ei_tx_intr()
1319 dev->stats.tx_carrier_errors++; in ei_tx_intr()
1321 dev->stats.tx_fifo_errors++; in ei_tx_intr()
1323 dev->stats.tx_heartbeat_errors++; in ei_tx_intr()
1325 dev->stats.tx_window_errors++; in ei_tx_intr()
1327 netif_wake_queue(dev); in ei_tx_intr()
1338 static void ei_receive(struct net_device *dev) in ei_receive() argument
1340 long e8390_base = dev->base_addr; in ei_receive()
1341 struct ei_device *ei_local = netdev_priv(dev); in ei_receive()
1368 netdev_err(dev, "mismatched read page pointers %2x vs %2x\n", in ei_receive()
1375 ei_get_8390_hdr(dev, &rx_frame, this_frame); in ei_receive()
1384 netif_err(ei_local, rx_err, dev, in ei_receive()
1388 dev->stats.rx_errors++; in ei_receive()
1389 dev->stats.rx_length_errors++; in ei_receive()
1395 skb = netdev_alloc_skb(dev, pkt_len + 2); in ei_receive()
1398 netif_err(ei_local, rx_err, dev, in ei_receive()
1401 dev->stats.rx_dropped++; in ei_receive()
1408 ei_block_input(dev, pkt_len, skb, current_offset + sizeof(rx_frame)); in ei_receive()
1409 skb->protocol=eth_type_trans(skb,dev); in ei_receive()
1411 dev->stats.rx_packets++; in ei_receive()
1412 dev->stats.rx_bytes += pkt_len; in ei_receive()
1414 dev->stats.multicast++; in ei_receive()
1419 netif_err(ei_local, rx_err, dev, in ei_receive()
1423 dev->stats.rx_errors++; in ei_receive()
1426 dev->stats.rx_fifo_errors++; in ei_receive()
1432 netdev_info(dev, "next frame inconsistency, %#2x\n", in ei_receive()
1454 static void ei_rx_overrun(struct net_device *dev) in ei_rx_overrun() argument
1456 struct axnet_dev *info = PRIV(dev); in ei_rx_overrun()
1457 long e8390_base = dev->base_addr; in ei_rx_overrun()
1459 struct ei_device *ei_local = netdev_priv(dev); in ei_rx_overrun()
1468 netif_dbg(ei_local, rx_err, dev, "Receiver overrun\n"); in ei_rx_overrun()
1469 dev->stats.rx_over_errors++; in ei_rx_overrun()
1506 ei_receive(dev); in ei_rx_overrun()
1520 static struct net_device_stats *get_stats(struct net_device *dev) in get_stats() argument
1522 long ioaddr = dev->base_addr; in get_stats()
1523 struct ei_device *ei_local = netdev_priv(dev); in get_stats()
1527 if (!netif_running(dev)) in get_stats()
1528 return &dev->stats; in get_stats()
1532 dev->stats.rx_frame_errors += inb_p(ioaddr + EN0_COUNTER0); in get_stats()
1533 dev->stats.rx_crc_errors += inb_p(ioaddr + EN0_COUNTER1); in get_stats()
1534 dev->stats.rx_missed_errors+= inb_p(ioaddr + EN0_COUNTER2); in get_stats()
1537 return &dev->stats; in get_stats()
1545 static inline void make_mc_bits(u8 *bits, struct net_device *dev) in make_mc_bits() argument
1550 netdev_for_each_mc_addr(ha, dev) { in make_mc_bits()
1568 static void do_set_multicast_list(struct net_device *dev) in do_set_multicast_list() argument
1570 long e8390_base = dev->base_addr; in do_set_multicast_list()
1572 struct ei_device *ei_local = netdev_priv(dev); in do_set_multicast_list()
1574 if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI))) { in do_set_multicast_list()
1576 if (!netdev_mc_empty(dev)) in do_set_multicast_list()
1577 make_mc_bits(ei_local->mcfilter, dev); in do_set_multicast_list()
1590 if(dev->flags&IFF_PROMISC) in do_set_multicast_list()
1592 else if (dev->flags & IFF_ALLMULTI || !netdev_mc_empty(dev)) in do_set_multicast_list()
1606 static void set_multicast_list(struct net_device *dev) in set_multicast_list() argument
1610 spin_lock_irqsave(&dev_lock(dev), flags); in set_multicast_list()
1611 do_set_multicast_list(dev); in set_multicast_list()
1612 spin_unlock_irqrestore(&dev_lock(dev), flags); in set_multicast_list()
1626 static void AX88190_init(struct net_device *dev, int startp) in AX88190_init() argument
1628 struct axnet_dev *info = PRIV(dev); in AX88190_init()
1629 long e8390_base = dev->base_addr; in AX88190_init()
1630 struct ei_device *ei_local = netdev_priv(dev); in AX88190_init()
1661 outb_p(dev->dev_addr[i], e8390_base + EN1_PHYS_SHIFT(i)); in AX88190_init()
1662 if(inb_p(e8390_base + EN1_PHYS_SHIFT(i))!=dev->dev_addr[i]) in AX88190_init()
1663 netdev_err(dev, "Hw. address read/write mismap %d\n", i); in AX88190_init()
1669 netif_start_queue(dev); in AX88190_init()
1685 do_set_multicast_list(dev); /* (re)load the mcast table */ in AX88190_init()
1692 static void NS8390_trigger_send(struct net_device *dev, unsigned int length, in NS8390_trigger_send() argument
1695 long e8390_base = dev->base_addr; in NS8390_trigger_send()
1696 struct ei_device *ei_local __attribute((unused)) = netdev_priv(dev); in NS8390_trigger_send()
1700 netdev_warn(dev, "trigger_send() called with the transmitter busy\n"); in NS8390_trigger_send()