Lines Matching refs:dev

164 static void tc589_reset(struct net_device *dev);
166 static int el3_config(struct net_device *dev, struct ifmap *map);
167 static int el3_open(struct net_device *dev);
169 struct net_device *dev);
171 static void update_stats(struct net_device *dev);
172 static struct net_device_stats *el3_get_stats(struct net_device *dev);
173 static int el3_rx(struct net_device *dev);
174 static int el3_close(struct net_device *dev);
175 static void el3_tx_timeout(struct net_device *dev, unsigned int txqueue);
176 static void set_rx_mode(struct net_device *dev);
177 static void set_multicast_list(struct net_device *dev);
197 struct net_device *dev; in tc589_probe() local
200 dev_dbg(&link->dev, "3c589_attach()\n"); in tc589_probe()
203 dev = alloc_etherdev(sizeof(struct el3_private)); in tc589_probe()
204 if (!dev) in tc589_probe()
206 lp = netdev_priv(dev); in tc589_probe()
207 link->priv = dev; in tc589_probe()
217 dev->netdev_ops = &el3_netdev_ops; in tc589_probe()
218 dev->watchdog_timeo = TX_TIMEOUT; in tc589_probe()
220 dev->ethtool_ops = &netdev_ethtool_ops; in tc589_probe()
229 free_netdev(dev); in tc589_probe()
235 struct net_device *dev = link->priv; in tc589_detach() local
237 dev_dbg(&link->dev, "3c589_detach\n"); in tc589_detach()
239 unregister_netdev(dev); in tc589_detach()
243 free_netdev(dev); in tc589_detach()
248 struct net_device *dev = link->priv; in tc589_config() local
256 dev_dbg(&link->dev, "3c589_config\n"); in tc589_config()
260 dev_info(&link->dev, "hmmm, is this really a 3Com card??\n"); in tc589_config()
285 dev->irq = link->irq; in tc589_config()
286 dev->base_addr = link->resource[0]->start; in tc589_config()
287 ioaddr = dev->base_addr; in tc589_config()
303 dev_err(&link->dev, "IO port conflict at 0x%03lx-0x%03lx\n", in tc589_config()
304 dev->base_addr, dev->base_addr+15); in tc589_config()
308 eth_hw_addr_set(dev, (u8 *)addr); in tc589_config()
319 dev->if_port = if_port; in tc589_config()
321 dev_err(&link->dev, "invalid if_port requested\n"); in tc589_config()
323 SET_NETDEV_DEV(dev, &link->dev); in tc589_config()
325 if (register_netdev(dev) != 0) { in tc589_config()
326 dev_err(&link->dev, "register_netdev() failed\n"); in tc589_config()
330 netdev_info(dev, "3Com 3c%s, io %#3lx, irq %d, hw_addr %pM\n", in tc589_config()
331 (multi ? "562" : "589"), dev->base_addr, dev->irq, in tc589_config()
332 dev->dev_addr); in tc589_config()
333 netdev_info(dev, " %dK FIFO split %s Rx:Tx, %s xcvr\n", in tc589_config()
335 if_names[dev->if_port]); in tc589_config()
350 struct net_device *dev = link->priv; in tc589_suspend() local
353 netif_device_detach(dev); in tc589_suspend()
360 struct net_device *dev = link->priv; in tc589_resume() local
363 tc589_reset(dev); in tc589_resume()
364 netif_device_attach(dev); in tc589_resume()
374 static void tc589_wait_for_completion(struct net_device *dev, int cmd) in tc589_wait_for_completion() argument
377 outw(cmd, dev->base_addr + EL3_CMD); in tc589_wait_for_completion()
379 if (!(inw(dev->base_addr + EL3_STATUS) & 0x1000)) in tc589_wait_for_completion()
382 netdev_warn(dev, "command 0x%04x did not complete!\n", cmd); in tc589_wait_for_completion()
404 static void tc589_set_xcvr(struct net_device *dev, int if_port) in tc589_set_xcvr() argument
406 struct el3_private *lp = netdev_priv(dev); in tc589_set_xcvr()
407 unsigned int ioaddr = dev->base_addr; in tc589_set_xcvr()
429 lp->media_status = ((dev->if_port == 0) ? 0x8000 : 0x4000); in tc589_set_xcvr()
431 lp->media_status = ((dev->if_port == 0) ? 0x4010 : 0x8800); in tc589_set_xcvr()
434 static void dump_status(struct net_device *dev) in dump_status() argument
436 unsigned int ioaddr = dev->base_addr; in dump_status()
438 netdev_info(dev, " irq status %04x, rx status %04x, tx status %02x tx free %04x\n", in dump_status()
442 netdev_info(dev, " diagnostics: fifo %04x net %04x ethernet %04x media %04x\n", in dump_status()
449 static void tc589_reset(struct net_device *dev) in tc589_reset() argument
451 unsigned int ioaddr = dev->base_addr; in tc589_reset()
461 outb(dev->dev_addr[i], ioaddr + i); in tc589_reset()
463 tc589_set_xcvr(dev, dev->if_port); in tc589_reset()
476 set_rx_mode(dev); in tc589_reset()
489 static void netdev_get_drvinfo(struct net_device *dev, in netdev_get_drvinfo() argument
494 "PCMCIA 0x%lx", dev->base_addr); in netdev_get_drvinfo()
501 static int el3_config(struct net_device *dev, struct ifmap *map) in el3_config() argument
503 if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) { in el3_config()
505 dev->if_port = map->port; in el3_config()
506 netdev_info(dev, "switched to %s port\n", if_names[dev->if_port]); in el3_config()
507 tc589_set_xcvr(dev, dev->if_port); in el3_config()
515 static int el3_open(struct net_device *dev) in el3_open() argument
517 struct el3_private *lp = netdev_priv(dev); in el3_open()
524 netif_start_queue(dev); in el3_open()
526 tc589_reset(dev); in el3_open()
530 dev_dbg(&link->dev, "%s: opened, status %4.4x.\n", in el3_open()
531 dev->name, inw(dev->base_addr + EL3_STATUS)); in el3_open()
536 static void el3_tx_timeout(struct net_device *dev, unsigned int txqueue) in el3_tx_timeout() argument
538 unsigned int ioaddr = dev->base_addr; in el3_tx_timeout()
540 netdev_warn(dev, "Transmit timed out!\n"); in el3_tx_timeout()
541 dump_status(dev); in el3_tx_timeout()
542 dev->stats.tx_errors++; in el3_tx_timeout()
543 netif_trans_update(dev); /* prevent tx timeout */ in el3_tx_timeout()
545 tc589_wait_for_completion(dev, TxReset); in el3_tx_timeout()
547 netif_wake_queue(dev); in el3_tx_timeout()
550 static void pop_tx_status(struct net_device *dev) in pop_tx_status() argument
552 unsigned int ioaddr = dev->base_addr; in pop_tx_status()
562 tc589_wait_for_completion(dev, TxReset); in pop_tx_status()
564 netdev_dbg(dev, "transmit error: status 0x%02x\n", tx_status); in pop_tx_status()
566 dev->stats.tx_aborted_errors++; in pop_tx_status()
573 struct net_device *dev) in el3_start_xmit() argument
575 unsigned int ioaddr = dev->base_addr; in el3_start_xmit()
576 struct el3_private *priv = netdev_priv(dev); in el3_start_xmit()
579 netdev_dbg(dev, "el3_start_xmit(length = %ld) called, status %4.4x.\n", in el3_start_xmit()
584 dev->stats.tx_bytes += skb->len; in el3_start_xmit()
593 netif_stop_queue(dev); in el3_start_xmit()
598 pop_tx_status(dev); in el3_start_xmit()
608 struct net_device *dev = (struct net_device *) dev_id; in el3_interrupt() local
609 struct el3_private *lp = netdev_priv(dev); in el3_interrupt()
614 if (!netif_device_present(dev)) in el3_interrupt()
617 ioaddr = dev->base_addr; in el3_interrupt()
619 netdev_dbg(dev, "interrupt, status %4.4x.\n", inw(ioaddr + EL3_STATUS)); in el3_interrupt()
625 netdev_dbg(dev, "interrupt from dead card\n"); in el3_interrupt()
630 el3_rx(dev); in el3_interrupt()
632 netdev_dbg(dev, " TX room bit was handled.\n"); in el3_interrupt()
635 netif_wake_queue(dev); in el3_interrupt()
638 pop_tx_status(dev); in el3_interrupt()
642 update_stats(dev); in el3_interrupt()
645 el3_rx(dev); in el3_interrupt()
653 netdev_warn(dev, "adapter failure, FIFO diagnostic register %04x.\n", in el3_interrupt()
657 tc589_wait_for_completion(dev, TxReset); in el3_interrupt()
662 tc589_wait_for_completion(dev, RxReset); in el3_interrupt()
663 set_rx_mode(dev); in el3_interrupt()
670 netdev_err(dev, "infinite loop in interrupt, status %4.4x.\n", in el3_interrupt()
681 netdev_dbg(dev, "exiting interrupt, status %4.4x.\n", in el3_interrupt()
689 struct net_device *dev = lp->p_dev->priv; in media_check() local
690 unsigned int ioaddr = dev->base_addr; in media_check()
694 if (!netif_device_present(dev)) in media_check()
703 netdev_warn(dev, "interrupt(s) dropped!\n"); in media_check()
706 el3_interrupt(dev->irq, dev); in media_check()
735 dev->stats.tx_carrier_errors += errs; in media_check()
743 netdev_info(dev, "%s link beat\n", in media_check()
747 netdev_info(dev, "coax cable %s\n", in media_check()
749 if (dev->if_port == 0) { in media_check()
752 netdev_info(dev, "flipped to 10baseT\n"); in media_check()
754 tc589_set_xcvr(dev, 2); in media_check()
757 tc589_set_xcvr(dev, 1); in media_check()
759 netdev_info(dev, "flipped to 10base2\n"); in media_check()
773 static struct net_device_stats *el3_get_stats(struct net_device *dev) in el3_get_stats() argument
775 struct el3_private *lp = netdev_priv(dev); in el3_get_stats()
781 update_stats(dev); in el3_get_stats()
784 return &dev->stats; in el3_get_stats()
795 static void update_stats(struct net_device *dev) in update_stats() argument
797 unsigned int ioaddr = dev->base_addr; in update_stats()
799 netdev_dbg(dev, "updating the statistics.\n"); in update_stats()
804 dev->stats.tx_carrier_errors += inb(ioaddr + 0); in update_stats()
805 dev->stats.tx_heartbeat_errors += inb(ioaddr + 1); in update_stats()
808 dev->stats.collisions += inb(ioaddr + 3); in update_stats()
809 dev->stats.tx_window_errors += inb(ioaddr + 4); in update_stats()
810 dev->stats.rx_fifo_errors += inb(ioaddr + 5); in update_stats()
811 dev->stats.tx_packets += inb(ioaddr + 6); in update_stats()
826 static int el3_rx(struct net_device *dev) in el3_rx() argument
828 unsigned int ioaddr = dev->base_addr; in el3_rx()
832 netdev_dbg(dev, "in rx_packet(), status %4.4x, rx_status %4.4x.\n", in el3_rx()
839 dev->stats.rx_errors++; in el3_rx()
842 dev->stats.rx_over_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_length_errors++; in el3_rx()
854 dev->stats.rx_frame_errors++; in el3_rx()
857 dev->stats.rx_crc_errors++; in el3_rx()
864 skb = netdev_alloc_skb(dev, pkt_len + 5); in el3_rx()
866 netdev_dbg(dev, " Receiving packet size %d status %4.4x.\n", in el3_rx()
872 skb->protocol = eth_type_trans(skb, dev); in el3_rx()
874 dev->stats.rx_packets++; in el3_rx()
875 dev->stats.rx_bytes += pkt_len; in el3_rx()
877 netdev_dbg(dev, "couldn't allocate a sk_buff of size %d.\n", in el3_rx()
879 dev->stats.rx_dropped++; in el3_rx()
883 tc589_wait_for_completion(dev, RxDiscard); in el3_rx()
886 netdev_warn(dev, "too much work in el3_rx!\n"); in el3_rx()
890 static void set_rx_mode(struct net_device *dev) in set_rx_mode() argument
892 unsigned int ioaddr = dev->base_addr; in set_rx_mode()
895 if (dev->flags & IFF_PROMISC) in set_rx_mode()
897 else if (!netdev_mc_empty(dev) || (dev->flags & IFF_ALLMULTI)) in set_rx_mode()
902 static void set_multicast_list(struct net_device *dev) in set_multicast_list() argument
904 struct el3_private *priv = netdev_priv(dev); in set_multicast_list()
908 set_rx_mode(dev); in set_multicast_list()
912 static int el3_close(struct net_device *dev) in el3_close() argument
914 struct el3_private *lp = netdev_priv(dev); in el3_close()
916 unsigned int ioaddr = dev->base_addr; in el3_close()
918 dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name); in el3_close()
928 if (dev->if_port == 2) in el3_close()
931 else if (dev->if_port == 1) { in el3_close()
944 update_stats(dev); in el3_close()
948 netif_stop_queue(dev); in el3_close()