40 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
45 #include <linux/errno.h>
46 #include <linux/netdevice.h>
48 #include <linux/module.h>
49 #include <linux/stddef.h>
50 #include <linux/kernel.h>
54 #include <linux/string.h>
58 #include <linux/bitops.h>
68 #define LANCE_LOG_TX_BUFFERS (2)
69 #define LANCE_LOG_RX_BUFFERS (4)
71 #define TX_RING_SIZE (1 << LANCE_LOG_TX_BUFFERS)
72 #define RX_RING_SIZE (1 << LANCE_LOG_RX_BUFFERS)
74 #define TX_RING_MOD_MASK (TX_RING_SIZE - 1)
75 #define RX_RING_MOD_MASK (RX_RING_SIZE - 1)
77 #define PKT_BUF_SIZE (1544)
78 #define RX_BUFF_SIZE PKT_BUF_SIZE
79 #define TX_BUFF_SIZE PKT_BUF_SIZE
120 #ifdef CONFIG_SUNLANCE
127 #define LANCE_ADDR(x) ((int)(x) & ~0xff000000)
137 ll->
rdp = (leptr & 0xFFFF);
139 ll->
rdp = leptr >> 16;
158 netif_stop_queue(dev);
232 pr_err(
"unopened after %d ticks, csr0=%04x\n", i, ll->
rdp);
258 buf[
i] = r1_own ?
'_' :
'X';
260 buf[
i] = r1_own ?
'.' :
'1';
264 pr_debug(
"RxRing TestHits: [%s]\n", buf);
274 dev->
stats.rx_over_errors++;
275 dev->
stats.rx_errors++;
282 dev->
stats.rx_fifo_errors++;
284 dev->
stats.rx_crc_errors++;
286 dev->
stats.rx_over_errors++;
288 dev->
stats.rx_frame_errors++;
290 dev->
stats.rx_errors++;
293 struct sk_buff *
skb = netdev_alloc_skb(dev, len + 2);
296 netdev_warn(dev,
"Memory squeeze, deferring packet\n");
297 dev->
stats.rx_dropped++;
306 skb_copy_to_linear_data(skb,
311 dev->
stats.rx_packets++;
337 for (i = j; i != lp->
tx_new; i =
j) {
347 dev->
stats.tx_errors++;
349 dev->
stats.tx_aborted_errors++;
351 dev->
stats.tx_window_errors++;
354 dev->
stats.tx_carrier_errors++;
357 netdev_err(dev,
"Carrier Lost, trying %s\n",
358 lp->
tpe ?
"TPE" :
"AUI");
362 lance_init_ring(dev);
364 init_restart_lance(lp);
373 dev->
stats.tx_fifo_errors++;
375 netdev_err(dev,
"Tx: ERR_BUF|ERR_UFL, restarting\n");
379 lance_init_ring(dev);
381 init_restart_lance(lp);
390 dev->
stats.collisions++;
394 dev->
stats.collisions += 2;
396 dev->
stats.tx_packets++;
443 dev->
stats.tx_errors++;
445 dev->
stats.rx_errors++;
447 netdev_err(dev,
"Bus master arbitration failure, status %04x\n",
453 if (netif_queue_stopped(dev) && lance_tx_buffs_avail(lp) > 0)
454 netif_wake_queue(dev);
457 ll->
rdp = (LE_C0_BABL |
LE_C0_CERR | LE_C0_MISS | LE_C0_MERR |
479 lance_init_ring(dev);
481 netif_start_queue(dev);
483 return init_restart_lance(lp);
491 netif_stop_queue(dev);
502 static inline int lance_reset(
struct net_device *dev)
514 lance_init_ring(dev);
516 netif_start_queue(dev);
518 status = init_restart_lance(lp);
519 netdev_dbg(dev,
"Lance restart=%d\n", status);
529 netdev_err(dev,
"transmit timed out, status %04x, reset\n", ll->
rdp);
531 netif_wake_queue(dev);
550 if (!lance_tx_buffs_avail(lp)) {
558 16, 1, skb->
data, 64,
true);
564 skb_copy_from_linear_data(skb, (
void *)&ib->
tx_buf[entry][0], skblen);
569 dev->
stats.tx_bytes += skblen;
571 if (lance_tx_buffs_avail(lp) <= 0)
572 netif_stop_queue(dev);
584 static void lance_load_multicast(
struct net_device *dev)
594 ib->
filter[0] = 0xffffffff;
595 ib->
filter[1] = 0xffffffff;
606 mcast_table[
crc >> 4] |= 1 << (
crc & 0xf);
616 if (!netif_running(dev))
621 netif_wake_queue(dev);
625 netif_stop_queue(dev);
629 lance_init_ring(dev);
635 lance_load_multicast(dev);
638 init_restart_lance(lp);
639 netif_wake_queue(dev);
642 static int __devinit a2065_init_one(
struct zorro_dev *z,
644 static void __devexit a2065_remove_one(
struct zorro_dev *z);
655 static struct zorro_driver a2065_driver = {
657 .id_table = a2065_zorro_tbl,
658 .probe = a2065_init_one,
673 static int __devinit a2065_init_one(
struct zorro_dev *z,
678 unsigned long board = z->resource.start;
701 priv = netdev_priv(dev);
714 dev->
dev_addr[3] = (z->rom.er_SerialNumber >> 16) & 0xff;
715 dev->
dev_addr[4] = (z->rom.er_SerialNumber >> 8) & 0xff;
716 dev->
dev_addr[5] = z->rom.er_SerialNumber & 0xff;
748 zorro_set_drvdata(z, dev);
750 netdev_info(dev,
"A2065 at 0x%08lx, Ethernet Address %pM\n",
757 static void __devexit a2065_remove_one(
struct zorro_dev *z)
759 struct net_device *dev = zorro_get_drvdata(z);
768 static int __init a2065_init_module(
void)
773 static void __exit a2065_cleanup_module(
void)