Lines Matching refs:dev
165 static void tc589_reset(struct net_device *dev);
167 static int el3_config(struct net_device *dev, struct ifmap *map);
168 static int el3_open(struct net_device *dev);
170 struct net_device *dev);
172 static void update_stats(struct net_device *dev);
173 static struct net_device_stats *el3_get_stats(struct net_device *dev);
174 static int el3_rx(struct net_device *dev);
175 static int el3_close(struct net_device *dev);
176 static void el3_tx_timeout(struct net_device *dev);
177 static void set_rx_mode(struct net_device *dev);
178 static void set_multicast_list(struct net_device *dev);
199 struct net_device *dev; in tc589_probe() local
201 dev_dbg(&link->dev, "3c589_attach()\n"); in tc589_probe()
204 dev = alloc_etherdev(sizeof(struct el3_private)); in tc589_probe()
205 if (!dev) in tc589_probe()
207 lp = netdev_priv(dev); in tc589_probe()
208 link->priv = dev; in tc589_probe()
218 dev->netdev_ops = &el3_netdev_ops; in tc589_probe()
219 dev->watchdog_timeo = TX_TIMEOUT; in tc589_probe()
221 dev->ethtool_ops = &netdev_ethtool_ops; in tc589_probe()
228 struct net_device *dev = link->priv; in tc589_detach() local
230 dev_dbg(&link->dev, "3c589_detach\n"); in tc589_detach()
232 unregister_netdev(dev); in tc589_detach()
236 free_netdev(dev); in tc589_detach()
241 struct net_device *dev = link->priv; in tc589_config() local
249 dev_dbg(&link->dev, "3c589_config\n"); in tc589_config()
251 phys_addr = (__be16 *)dev->dev_addr; in tc589_config()
254 dev_info(&link->dev, "hmmm, is this really a 3Com card??\n"); in tc589_config()
279 dev->irq = link->irq; in tc589_config()
280 dev->base_addr = link->resource[0]->start; in tc589_config()
281 ioaddr = dev->base_addr; in tc589_config()
297 dev_err(&link->dev, "IO port conflict at 0x%03lx-0x%03lx\n", in tc589_config()
298 dev->base_addr, dev->base_addr+15); in tc589_config()
312 dev->if_port = if_port; in tc589_config()
314 dev_err(&link->dev, "invalid if_port requested\n"); in tc589_config()
316 SET_NETDEV_DEV(dev, &link->dev); in tc589_config()
318 if (register_netdev(dev) != 0) { in tc589_config()
319 dev_err(&link->dev, "register_netdev() failed\n"); in tc589_config()
323 netdev_info(dev, "3Com 3c%s, io %#3lx, irq %d, hw_addr %pM\n", in tc589_config()
324 (multi ? "562" : "589"), dev->base_addr, dev->irq, in tc589_config()
325 dev->dev_addr); in tc589_config()
326 netdev_info(dev, " %dK FIFO split %s Rx:Tx, %s xcvr\n", in tc589_config()
328 if_names[dev->if_port]); in tc589_config()
343 struct net_device *dev = link->priv; in tc589_suspend() local
346 netif_device_detach(dev); in tc589_suspend()
353 struct net_device *dev = link->priv; in tc589_resume() local
356 tc589_reset(dev); in tc589_resume()
357 netif_device_attach(dev); in tc589_resume()
367 static void tc589_wait_for_completion(struct net_device *dev, int cmd) in tc589_wait_for_completion() argument
370 outw(cmd, dev->base_addr + EL3_CMD); in tc589_wait_for_completion()
372 if (!(inw(dev->base_addr + EL3_STATUS) & 0x1000)) in tc589_wait_for_completion()
375 netdev_warn(dev, "command 0x%04x did not complete!\n", cmd); in tc589_wait_for_completion()
397 static void tc589_set_xcvr(struct net_device *dev, int if_port) in tc589_set_xcvr() argument
399 struct el3_private *lp = netdev_priv(dev); in tc589_set_xcvr()
400 unsigned int ioaddr = dev->base_addr; in tc589_set_xcvr()
422 lp->media_status = ((dev->if_port == 0) ? 0x8000 : 0x4000); in tc589_set_xcvr()
424 lp->media_status = ((dev->if_port == 0) ? 0x4010 : 0x8800); in tc589_set_xcvr()
427 static void dump_status(struct net_device *dev) in dump_status() argument
429 unsigned int ioaddr = dev->base_addr; in dump_status()
431 netdev_info(dev, " irq status %04x, rx status %04x, tx status %02x tx free %04x\n", in dump_status()
435 netdev_info(dev, " diagnostics: fifo %04x net %04x ethernet %04x media %04x\n", in dump_status()
442 static void tc589_reset(struct net_device *dev) in tc589_reset() argument
444 unsigned int ioaddr = dev->base_addr; in tc589_reset()
454 outb(dev->dev_addr[i], ioaddr + i); in tc589_reset()
456 tc589_set_xcvr(dev, dev->if_port); in tc589_reset()
469 set_rx_mode(dev); in tc589_reset()
482 static void netdev_get_drvinfo(struct net_device *dev, in netdev_get_drvinfo() argument
488 "PCMCIA 0x%lx", dev->base_addr); in netdev_get_drvinfo()
495 static int el3_config(struct net_device *dev, struct ifmap *map) in el3_config() argument
497 if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) { in el3_config()
499 dev->if_port = map->port; in el3_config()
500 netdev_info(dev, "switched to %s port\n", if_names[dev->if_port]); in el3_config()
501 tc589_set_xcvr(dev, dev->if_port); in el3_config()
509 static int el3_open(struct net_device *dev) in el3_open() argument
511 struct el3_private *lp = netdev_priv(dev); in el3_open()
518 netif_start_queue(dev); in el3_open()
520 tc589_reset(dev); in el3_open()
521 setup_timer(&lp->media, media_check, (unsigned long)dev); in el3_open()
524 dev_dbg(&link->dev, "%s: opened, status %4.4x.\n", in el3_open()
525 dev->name, inw(dev->base_addr + EL3_STATUS)); in el3_open()
530 static void el3_tx_timeout(struct net_device *dev) in el3_tx_timeout() argument
532 unsigned int ioaddr = dev->base_addr; in el3_tx_timeout()
534 netdev_warn(dev, "Transmit timed out!\n"); in el3_tx_timeout()
535 dump_status(dev); in el3_tx_timeout()
536 dev->stats.tx_errors++; in el3_tx_timeout()
537 dev->trans_start = jiffies; /* prevent tx timeout */ in el3_tx_timeout()
539 tc589_wait_for_completion(dev, TxReset); in el3_tx_timeout()
541 netif_wake_queue(dev); in el3_tx_timeout()
544 static void pop_tx_status(struct net_device *dev) in pop_tx_status() argument
546 unsigned int ioaddr = dev->base_addr; in pop_tx_status()
556 tc589_wait_for_completion(dev, TxReset); in pop_tx_status()
558 netdev_dbg(dev, "transmit error: status 0x%02x\n", tx_status); in pop_tx_status()
560 dev->stats.tx_aborted_errors++; in pop_tx_status()
567 struct net_device *dev) in el3_start_xmit() argument
569 unsigned int ioaddr = dev->base_addr; in el3_start_xmit()
570 struct el3_private *priv = netdev_priv(dev); in el3_start_xmit()
573 netdev_dbg(dev, "el3_start_xmit(length = %ld) called, status %4.4x.\n", in el3_start_xmit()
578 dev->stats.tx_bytes += skb->len; in el3_start_xmit()
587 netif_stop_queue(dev); in el3_start_xmit()
592 pop_tx_status(dev); in el3_start_xmit()
602 struct net_device *dev = (struct net_device *) dev_id; in el3_interrupt() local
603 struct el3_private *lp = netdev_priv(dev); in el3_interrupt()
608 if (!netif_device_present(dev)) in el3_interrupt()
611 ioaddr = dev->base_addr; in el3_interrupt()
613 netdev_dbg(dev, "interrupt, status %4.4x.\n", inw(ioaddr + EL3_STATUS)); in el3_interrupt()
619 netdev_dbg(dev, "interrupt from dead card\n"); in el3_interrupt()
624 el3_rx(dev); in el3_interrupt()
626 netdev_dbg(dev, " TX room bit was handled.\n"); in el3_interrupt()
629 netif_wake_queue(dev); in el3_interrupt()
632 pop_tx_status(dev); in el3_interrupt()
636 update_stats(dev); in el3_interrupt()
639 el3_rx(dev); in el3_interrupt()
647 netdev_warn(dev, "adapter failure, FIFO diagnostic register %04x.\n", in el3_interrupt()
651 tc589_wait_for_completion(dev, TxReset); in el3_interrupt()
656 tc589_wait_for_completion(dev, RxReset); in el3_interrupt()
657 set_rx_mode(dev); in el3_interrupt()
664 netdev_err(dev, "infinite loop in interrupt, status %4.4x.\n", in el3_interrupt()
675 netdev_dbg(dev, "exiting interrupt, status %4.4x.\n", in el3_interrupt()
682 struct net_device *dev = (struct net_device *)(arg); in media_check() local
683 struct el3_private *lp = netdev_priv(dev); in media_check()
684 unsigned int ioaddr = dev->base_addr; in media_check()
688 if (!netif_device_present(dev)) in media_check()
697 netdev_warn(dev, "interrupt(s) dropped!\n"); in media_check()
700 el3_interrupt(dev->irq, dev); in media_check()
729 dev->stats.tx_carrier_errors += errs; in media_check()
737 netdev_info(dev, "%s link beat\n", in media_check()
741 netdev_info(dev, "coax cable %s\n", in media_check()
743 if (dev->if_port == 0) { in media_check()
746 netdev_info(dev, "flipped to 10baseT\n"); in media_check()
748 tc589_set_xcvr(dev, 2); in media_check()
751 tc589_set_xcvr(dev, 1); in media_check()
753 netdev_info(dev, "flipped to 10base2\n"); in media_check()
767 static struct net_device_stats *el3_get_stats(struct net_device *dev) in el3_get_stats() argument
769 struct el3_private *lp = netdev_priv(dev); in el3_get_stats()
775 update_stats(dev); in el3_get_stats()
778 return &dev->stats; in el3_get_stats()
789 static void update_stats(struct net_device *dev) in update_stats() argument
791 unsigned int ioaddr = dev->base_addr; in update_stats()
793 netdev_dbg(dev, "updating the statistics.\n"); in update_stats()
798 dev->stats.tx_carrier_errors += inb(ioaddr + 0); in update_stats()
799 dev->stats.tx_heartbeat_errors += inb(ioaddr + 1); in update_stats()
802 dev->stats.collisions += inb(ioaddr + 3); in update_stats()
803 dev->stats.tx_window_errors += inb(ioaddr + 4); in update_stats()
804 dev->stats.rx_fifo_errors += inb(ioaddr + 5); in update_stats()
805 dev->stats.tx_packets += inb(ioaddr + 6); in update_stats()
820 static int el3_rx(struct net_device *dev) in el3_rx() argument
822 unsigned int ioaddr = dev->base_addr; in el3_rx()
826 netdev_dbg(dev, "in rx_packet(), status %4.4x, rx_status %4.4x.\n", in el3_rx()
833 dev->stats.rx_errors++; in el3_rx()
836 dev->stats.rx_over_errors++; in el3_rx()
839 dev->stats.rx_length_errors++; in el3_rx()
842 dev->stats.rx_frame_errors++; in el3_rx()
845 dev->stats.rx_length_errors++; in el3_rx()
848 dev->stats.rx_frame_errors++; in el3_rx()
851 dev->stats.rx_crc_errors++; in el3_rx()
858 skb = netdev_alloc_skb(dev, pkt_len + 5); in el3_rx()
860 netdev_dbg(dev, " Receiving packet size %d status %4.4x.\n", in el3_rx()
866 skb->protocol = eth_type_trans(skb, dev); in el3_rx()
868 dev->stats.rx_packets++; in el3_rx()
869 dev->stats.rx_bytes += pkt_len; in el3_rx()
871 netdev_dbg(dev, "couldn't allocate a sk_buff of size %d.\n", in el3_rx()
873 dev->stats.rx_dropped++; in el3_rx()
877 tc589_wait_for_completion(dev, RxDiscard); in el3_rx()
880 netdev_warn(dev, "too much work in el3_rx!\n"); in el3_rx()
884 static void set_rx_mode(struct net_device *dev) in set_rx_mode() argument
886 unsigned int ioaddr = dev->base_addr; in set_rx_mode()
889 if (dev->flags & IFF_PROMISC) in set_rx_mode()
891 else if (!netdev_mc_empty(dev) || (dev->flags & IFF_ALLMULTI)) in set_rx_mode()
896 static void set_multicast_list(struct net_device *dev) in set_multicast_list() argument
898 struct el3_private *priv = netdev_priv(dev); in set_multicast_list()
902 set_rx_mode(dev); in set_multicast_list()
906 static int el3_close(struct net_device *dev) in el3_close() argument
908 struct el3_private *lp = netdev_priv(dev); in el3_close()
910 unsigned int ioaddr = dev->base_addr; in el3_close()
912 dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name); in el3_close()
922 if (dev->if_port == 2) in el3_close()
925 else if (dev->if_port == 1) { in el3_close()
938 update_stats(dev); in el3_close()
942 netif_stop_queue(dev); in el3_close()