17 #include <linux/errno.h>
18 #include <linux/netdevice.h>
21 #include <linux/module.h>
22 #include <linux/kernel.h>
23 #include <linux/types.h>
24 #include <linux/fcntl.h>
29 #include <linux/string.h>
33 #include <linux/socket.h>
34 #include <linux/bitops.h>
38 #include <asm/pgtable.h>
45 #define WRITERAP(lp,x) out_be16(lp->base + LANCE_RAP, (x))
46 #define WRITERDP(lp,x) out_be16(lp->base + LANCE_RDP, (x))
47 #define READRDP(lp) in_be16(lp->base + LANCE_RDP)
49 #if defined(CONFIG_HPLANCE) || defined(CONFIG_HPLANCE_MODULE)
56 #if defined(CONFIG_MVME147_NET) || defined(CONFIG_MVME147_NET_MODULE)
59 #define WRITERAP(lp,x) (lp->writerap(lp,x))
60 #define WRITERDP(lp,x) (lp->writerdp(lp,x))
61 #define READRDP(lp) (lp->readrdp(lp))
95 #define PRINT_RINGS() \
98 for (t=0; t < RX_RING_SIZE; t++) { \
99 printk("R%d: @(%02X %04X) len %04X, mblen %04X, bits %02X\n",\
100 t, ib->brx_ring[t].rmd1_hadr, ib->brx_ring[t].rmd0,\
101 ib->brx_ring[t].length,\
102 ib->brx_ring[t].mblength, ib->brx_ring[t].rmd1_bits);\
104 for (t=0; t < TX_RING_SIZE; t++) { \
105 printk("T%d: @(%02X %04X) len %04X, misc %04X, bits %02X\n",\
106 t, ib->btx_ring[t].tmd1_hadr, ib->btx_ring[t].tmd0,\
107 ib->btx_ring[t].length,\
108 ib->btx_ring[t].misc, ib->btx_ring[t].tmd1_bits);\
112 #define PRINT_RINGS()
135 #define DEBUG_IRING 0
182 ib->
btx_ring [
i].tmd1_hadr = leptr >> 16;
187 printk (
"%d: 0x%8.8x\n", i, leptr);
197 ib->
brx_ring [
i].rmd1_hadr = leptr >> 16;
203 printk (
"%d: 0x%8.8x\n", i, leptr);
213 printk (
"RX ptr: %8.8x\n", leptr);
220 printk (
"TX ptr: %8.8x\n", leptr);
242 printk (
"LANCE unopened after %d ticks, csr0=%4.4x.\n", i,
READRDP(lp));
263 lance_init_ring (dev);
265 status = init_restart_lance (lp);
267 printk (
"Lance restart=%d\n", status);
295 blinken_leds(0x40, 0);
304 dev->
stats.rx_over_errors++;
305 dev->
stats.rx_errors++;
318 struct sk_buff *
skb = netdev_alloc_skb(dev, len + 2);
321 printk (
"%s: Memory squeeze, deferring packet.\n",
323 dev->
stats.rx_dropped++;
330 skb_reserve (skb, 2);
332 skb_copy_to_linear_data(skb,
337 dev->
stats.rx_packets++;
358 blinken_leds(0x80, 0);
365 for (i = j; i != lp->
tx_new; i =
j) {
375 dev->
stats.tx_errors++;
380 dev->
stats.tx_carrier_errors++;
383 printk(
"%s: Carrier Lost, trying %s\n",
384 dev->
name, lp->
tpe?
"TPE":
"AUI");
388 lance_init_ring (dev);
390 init_restart_lance (lp);
398 dev->
stats.tx_fifo_errors++;
400 printk (
"%s: Tx: ERR_BUF|ERR_UFL, restarting\n",
405 lance_init_ring (dev);
407 init_restart_lance (lp);
418 dev->
stats.collisions++;
422 dev->
stats.collisions += 2;
424 dev->
stats.tx_packets++;
435 lance_interrupt (
int irq,
void *
dev_id)
469 dev->
stats.tx_errors++;
471 dev->
stats.rx_errors++;
473 printk(
"%s: Bus master arbitration failure, status %4.4x.\n",
481 netif_wake_queue (dev);
500 res = lance_reset(dev);
502 netif_start_queue (dev);
512 netif_stop_queue (dev);
526 printk(
"lance_tx_timeout\n");
529 netif_wake_queue (dev);
537 int entry, skblen, len;
544 netif_stop_queue (dev);
553 for (i = 0; i < 64; i++) {
567 skb_copy_from_linear_data(skb, (
void *)&ib->
tx_buf[entry][0], skblen);
580 netif_start_queue (dev);
583 spin_unlock_irqrestore (&lp->
devlock, flags);
590 static void lance_load_multicast (
struct net_device *dev)
600 ib->
filter [0] = 0xffffffff;
601 ib->
filter [1] = 0xffffffff;
612 mcast_table [
crc >> 4] |= 1 << (
crc & 0xf);
623 stopped = netif_queue_stopped(dev);
625 netif_stop_queue (dev);
632 lance_init_ring (dev);
638 lance_load_multicast (dev);
641 init_restart_lance (lp);
644 netif_start_queue (dev);
648 #ifdef CONFIG_NET_POLL_CONTROLLER
657 lance_interrupt(dev->
irq, dev);