1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#define DRV_NAME "3c507"
29#define DRV_VERSION "1.10a"
30#define DRV_RELDATE "11/17/2001"
31
32static const char version[] =
33 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Donald Becker (becker@scyld.com)\n";
34
35
36
37
38
39
40
41
42
43
44
45
46#include <linux/module.h>
47#include <linux/kernel.h>
48#include <linux/types.h>
49#include <linux/fcntl.h>
50#include <linux/interrupt.h>
51#include <linux/ioport.h>
52#include <linux/in.h>
53#include <linux/string.h>
54#include <linux/spinlock.h>
55#include <linux/ethtool.h>
56#include <linux/errno.h>
57#include <linux/netdevice.h>
58#include <linux/etherdevice.h>
59#include <linux/skbuff.h>
60#include <linux/slab.h>
61#include <linux/init.h>
62#include <linux/bitops.h>
63
64#include <asm/dma.h>
65#include <asm/io.h>
66#include <asm/system.h>
67#include <asm/uaccess.h>
68
69
70#ifndef NET_DEBUG
71#define NET_DEBUG 1
72#endif
73static unsigned int net_debug = NET_DEBUG;
74#define debug net_debug
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92#define CUC_START 0x0100
93#define CUC_RESUME 0x0200
94#define CUC_SUSPEND 0x0300
95#define RX_START 0x0010
96#define RX_RESUME 0x0020
97#define RX_SUSPEND 0x0030
98
99
100
101
102
103
104
105
106
107
108
109
110
111#define CMD_EOL 0x8000
112#define CMD_SUSP 0x4000
113#define CMD_INTR 0x2000
114
115enum commands {
116 CmdNOp = 0, CmdSASetup = 1, CmdConfigure = 2, CmdMulticastList = 3,
117 CmdTx = 4, CmdTDR = 5, CmdDump = 6, CmdDiagnose = 7};
118
119
120struct net_local {
121 int last_restart;
122 ushort rx_head;
123 ushort rx_tail;
124 ushort tx_head;
125 ushort tx_cmd_link;
126 ushort tx_reap;
127 ushort tx_pkts_in_ring;
128 spinlock_t lock;
129 void __iomem *base;
130};
131
132
133
134
135
136
137
138
139
140#define SA_DATA 0
141#define MISC_CTRL 6
142#define RESET_IRQ 10
143#define SIGNAL_CA 11
144#define ROM_CONFIG 13
145#define MEM_CONFIG 14
146#define IRQ_CONFIG 15
147#define EL16_IO_EXTENT 16
148
149
150#define ID_PORT 0x100
151
152
153#define iSCB_STATUS 0x8
154#define iSCB_CMD 0xA
155#define iSCB_CBL 0xC
156#define iSCB_RFA 0xE
157
158
159
160
161
162
163
164
165
166
167#define SCB_BASE ((unsigned)64*1024 - (dev->mem_end - dev->mem_start))
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185#define CONFIG_CMD 0x0018
186#define SET_SA_CMD 0x0024
187#define SA_OFFSET 0x002A
188#define IDLELOOP 0x30
189#define TDR_CMD 0x38
190#define TDR_TIME 0x3C
191#define DUMP_CMD 0x40
192#define DIAG_CMD 0x48
193#define SET_MC_CMD 0x4E
194#define DUMP_DATA 0x56
195
196#define TX_BUF_START 0x0100
197#define NUM_TX_BUFS 5
198#define TX_BUF_SIZE (1518+14+20+16)
199
200#define RX_BUF_START 0x2000
201#define RX_BUF_SIZE (1518+14+18)
202#define RX_BUF_END (dev->mem_end - dev->mem_start)
203
204#define TX_TIMEOUT 5
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239static unsigned short init_words[] = {
240
241 0x0000,
242 0,0,
243 0x0000,0x0000,
244
245
246 0x0001,
247 0x0008,0,0,
248
249
250 0,0xf000|RX_START|CUC_START,
251 CONFIG_CMD,
252 RX_BUF_START,
253 0,0,0,0,
254
255
256 0, CmdConfigure,
257 SET_SA_CMD,
258 0x0804,
259 0x2e40,
260 0,
261
262
263 0, CmdSASetup,
264 SET_MC_CMD,
265 0xaa00,0xb000,0x0bad,
266
267
268 0, CmdNOp, IDLELOOP, 0 ,
269
270
271 0, CmdTDR, IDLELOOP, 0,
272
273
274 0, CmdDump, IDLELOOP, DUMP_DATA,
275
276
277 0, CmdDiagnose, IDLELOOP,
278
279
280 0, CmdMulticastList, IDLELOOP, 0,
281};
282
283
284
285static int el16_probe1(struct net_device *dev, int ioaddr);
286static int el16_open(struct net_device *dev);
287static int el16_send_packet(struct sk_buff *skb, struct net_device *dev);
288static irqreturn_t el16_interrupt(int irq, void *dev_id);
289static void el16_rx(struct net_device *dev);
290static int el16_close(struct net_device *dev);
291static void el16_tx_timeout (struct net_device *dev);
292
293static void hardware_send_packet(struct net_device *dev, void *buf, short length, short pad);
294static void init_82586_mem(struct net_device *dev);
295static const struct ethtool_ops netdev_ethtool_ops;
296static void init_rx_bufs(struct net_device *);
297
298static int io = 0x300;
299static int irq;
300static int mem_start;
301
302
303
304
305
306
307
308
309
310struct net_device * __init el16_probe(int unit)
311{
312 struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
313 static unsigned ports[] = { 0x300, 0x320, 0x340, 0x280, 0};
314 unsigned *port;
315 int err = -ENODEV;
316
317 if (!dev)
318 return ERR_PTR(-ENODEV);
319
320 if (unit >= 0) {
321 sprintf(dev->name, "eth%d", unit);
322 netdev_boot_setup_check(dev);
323 io = dev->base_addr;
324 irq = dev->irq;
325 mem_start = dev->mem_start & 15;
326 }
327
328 if (io > 0x1ff)
329 err = el16_probe1(dev, io);
330 else if (io != 0)
331 err = -ENXIO;
332 else {
333 for (port = ports; *port; port++) {
334 err = el16_probe1(dev, *port);
335 if (!err)
336 break;
337 }
338 }
339
340 if (err)
341 goto out;
342 err = register_netdev(dev);
343 if (err)
344 goto out1;
345 return dev;
346out1:
347 free_irq(dev->irq, dev);
348 iounmap(((struct net_local *)netdev_priv(dev))->base);
349 release_region(dev->base_addr, EL16_IO_EXTENT);
350out:
351 free_netdev(dev);
352 return ERR_PTR(err);
353}
354
355static const struct net_device_ops netdev_ops = {
356 .ndo_open = el16_open,
357 .ndo_stop = el16_close,
358 .ndo_start_xmit = el16_send_packet,
359 .ndo_tx_timeout = el16_tx_timeout,
360 .ndo_change_mtu = eth_change_mtu,
361 .ndo_set_mac_address = eth_mac_addr,
362 .ndo_validate_addr = eth_validate_addr,
363};
364
365static int __init el16_probe1(struct net_device *dev, int ioaddr)
366{
367 static unsigned char init_ID_done;
368 int i, irq, irqval, retval;
369 struct net_local *lp;
370
371 if (init_ID_done == 0) {
372 ushort lrs_state = 0xff;
373
374 outb(0x00, ID_PORT);
375 for(i = 0; i < 255; i++) {
376 outb(lrs_state, ID_PORT);
377 lrs_state <<= 1;
378 if (lrs_state & 0x100)
379 lrs_state ^= 0xe7;
380 }
381 outb(0x00, ID_PORT);
382 init_ID_done = 1;
383 }
384
385 if (!request_region(ioaddr, EL16_IO_EXTENT, DRV_NAME))
386 return -ENODEV;
387
388 if ((inb(ioaddr) != '*') || (inb(ioaddr + 1) != '3') ||
389 (inb(ioaddr + 2) != 'C') || (inb(ioaddr + 3) != 'O')) {
390 retval = -ENODEV;
391 goto out;
392 }
393
394 pr_info("%s: 3c507 at %#x,", dev->name, ioaddr);
395
396
397
398
399 irq = inb(ioaddr + IRQ_CONFIG) & 0x0f;
400
401 irqval = request_irq(irq, &el16_interrupt, 0, DRV_NAME, dev);
402 if (irqval) {
403 pr_cont("\n");
404 pr_err("3c507: unable to get IRQ %d (irqval=%d).\n", irq, irqval);
405 retval = -EAGAIN;
406 goto out;
407 }
408
409
410 dev->base_addr = ioaddr;
411
412 outb(0x01, ioaddr + MISC_CTRL);
413 for (i = 0; i < 6; i++)
414 dev->dev_addr[i] = inb(ioaddr + i);
415 pr_cont(" %pM", dev->dev_addr);
416
417 if (mem_start)
418 net_debug = mem_start & 7;
419
420#ifdef MEM_BASE
421 dev->mem_start = MEM_BASE;
422 dev->mem_end = dev->mem_start + 0x10000;
423#else
424 {
425 int base;
426 int size;
427 char mem_config = inb(ioaddr + MEM_CONFIG);
428 if (mem_config & 0x20) {
429 size = 64*1024;
430 base = 0xf00000 + (mem_config & 0x08 ? 0x080000
431 : ((mem_config & 3) << 17));
432 } else {
433 size = ((mem_config & 3) + 1) << 14;
434 base = 0x0c0000 + ( (mem_config & 0x18) << 12);
435 }
436 dev->mem_start = base;
437 dev->mem_end = base + size;
438 }
439#endif
440
441 dev->if_port = (inb(ioaddr + ROM_CONFIG) & 0x80) ? 1 : 0;
442 dev->irq = inb(ioaddr + IRQ_CONFIG) & 0x0f;
443
444 pr_cont(", IRQ %d, %sternal xcvr, memory %#lx-%#lx.\n", dev->irq,
445 dev->if_port ? "ex" : "in", dev->mem_start, dev->mem_end-1);
446
447 if (net_debug)
448 pr_debug("%s", version);
449
450 lp = netdev_priv(dev);
451 memset(lp, 0, sizeof(*lp));
452 spin_lock_init(&lp->lock);
453 lp->base = ioremap(dev->mem_start, RX_BUF_END);
454 if (!lp->base) {
455 pr_err("3c507: unable to remap memory\n");
456 retval = -EAGAIN;
457 goto out1;
458 }
459
460 dev->netdev_ops = &netdev_ops;
461 dev->watchdog_timeo = TX_TIMEOUT;
462 dev->ethtool_ops = &netdev_ethtool_ops;
463 dev->flags &= ~IFF_MULTICAST;
464 return 0;
465out1:
466 free_irq(dev->irq, dev);
467out:
468 release_region(ioaddr, EL16_IO_EXTENT);
469 return retval;
470}
471
472static int el16_open(struct net_device *dev)
473{
474
475 init_82586_mem(dev);
476
477 netif_start_queue(dev);
478 return 0;
479}
480
481
482static void el16_tx_timeout (struct net_device *dev)
483{
484 struct net_local *lp = netdev_priv(dev);
485 int ioaddr = dev->base_addr;
486 void __iomem *shmem = lp->base;
487
488 if (net_debug > 1)
489 pr_debug("%s: transmit timed out, %s? ", dev->name,
490 readw(shmem + iSCB_STATUS) & 0x8000 ? "IRQ conflict" :
491 "network cable problem");
492
493 if (lp->last_restart == dev->stats.tx_packets) {
494 if (net_debug > 1)
495 pr_cont("Resetting board.\n");
496
497 init_82586_mem (dev);
498 lp->tx_pkts_in_ring = 0;
499 } else {
500
501 if (net_debug > 1)
502 pr_cont("Kicking board.\n");
503 writew(0xf000 | CUC_START | RX_START, shmem + iSCB_CMD);
504 outb (0, ioaddr + SIGNAL_CA);
505 lp->last_restart = dev->stats.tx_packets;
506 }
507 dev->trans_start = jiffies;
508 netif_wake_queue (dev);
509}
510
511
512static int el16_send_packet (struct sk_buff *skb, struct net_device *dev)
513{
514 struct net_local *lp = netdev_priv(dev);
515 int ioaddr = dev->base_addr;
516 unsigned long flags;
517 short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
518 unsigned char *buf = skb->data;
519
520 netif_stop_queue (dev);
521
522 spin_lock_irqsave (&lp->lock, flags);
523
524 dev->stats.tx_bytes += length;
525
526 outb (0x80, ioaddr + MISC_CTRL);
527
528 hardware_send_packet (dev, buf, skb->len, length - skb->len);
529
530 dev->trans_start = jiffies;
531
532 outb (0x84, ioaddr + MISC_CTRL);
533
534 spin_unlock_irqrestore (&lp->lock, flags);
535
536 dev_kfree_skb (skb);
537
538
539
540 return 0;
541}
542
543
544
545static irqreturn_t el16_interrupt(int irq, void *dev_id)
546{
547 struct net_device *dev = dev_id;
548 struct net_local *lp;
549 int ioaddr, status, boguscount = 0;
550 ushort ack_cmd = 0;
551 void __iomem *shmem;
552
553 if (dev == NULL) {
554 pr_err("%s: net_interrupt(): irq %d for unknown device.\n",
555 dev->name, irq);
556 return IRQ_NONE;
557 }
558
559 ioaddr = dev->base_addr;
560 lp = netdev_priv(dev);
561 shmem = lp->base;
562
563 spin_lock(&lp->lock);
564
565 status = readw(shmem+iSCB_STATUS);
566
567 if (net_debug > 4) {
568 pr_debug("%s: 3c507 interrupt, status %4.4x.\n", dev->name, status);
569 }
570
571
572 outb(0x80, ioaddr + MISC_CTRL);
573
574
575 while (lp->tx_pkts_in_ring) {
576 unsigned short tx_status = readw(shmem+lp->tx_reap);
577 if (!(tx_status & 0x8000)) {
578 if (net_debug > 5)
579 pr_debug("Tx command incomplete (%#x).\n", lp->tx_reap);
580 break;
581 }
582
583 if (!(tx_status & 0x2000) || (tx_status & 0x0f3f)) {
584 dev->stats.tx_errors++;
585 if (tx_status & 0x0600) dev->stats.tx_carrier_errors++;
586 if (tx_status & 0x0100) dev->stats.tx_fifo_errors++;
587 if (!(tx_status & 0x0040)) dev->stats.tx_heartbeat_errors++;
588 if (tx_status & 0x0020) dev->stats.tx_aborted_errors++;
589 dev->stats.collisions += tx_status & 0xf;
590 }
591 dev->stats.tx_packets++;
592 if (net_debug > 5)
593 pr_debug("Reaped %x, Tx status %04x.\n" , lp->tx_reap, tx_status);
594 lp->tx_reap += TX_BUF_SIZE;
595 if (lp->tx_reap > RX_BUF_START - TX_BUF_SIZE)
596 lp->tx_reap = TX_BUF_START;
597
598 lp->tx_pkts_in_ring--;
599
600 netif_wake_queue(dev);
601
602 if (++boguscount > 10)
603 break;
604 }
605
606 if (status & 0x4000) {
607 if (net_debug > 5)
608 pr_debug("Received packet, rx_head %04x.\n", lp->rx_head);
609 el16_rx(dev);
610 }
611
612
613 ack_cmd = status & 0xf000;
614
615 if ((status & 0x0700) != 0x0200 && netif_running(dev)) {
616 if (net_debug)
617 pr_debug("%s: Command unit stopped, status %04x, restarting.\n",
618 dev->name, status);
619
620
621
622 ack_cmd |= CUC_RESUME;
623 }
624
625 if ((status & 0x0070) != 0x0040 && netif_running(dev)) {
626
627
628 if (net_debug)
629 pr_debug("%s: Rx unit stopped, status %04x, restarting.\n",
630 dev->name, status);
631 init_rx_bufs(dev);
632 writew(RX_BUF_START,shmem+iSCB_RFA);
633 ack_cmd |= RX_START;
634 }
635
636 writew(ack_cmd,shmem+iSCB_CMD);
637 outb(0, ioaddr + SIGNAL_CA);
638
639
640 outb(0, ioaddr + RESET_IRQ);
641
642
643 outb(0x84, ioaddr + MISC_CTRL);
644 spin_unlock(&lp->lock);
645 return IRQ_HANDLED;
646}
647
648static int el16_close(struct net_device *dev)
649{
650 struct net_local *lp = netdev_priv(dev);
651 int ioaddr = dev->base_addr;
652 void __iomem *shmem = lp->base;
653
654 netif_stop_queue(dev);
655
656
657 writew(RX_SUSPEND | CUC_SUSPEND,shmem+iSCB_CMD);
658 outb(0, ioaddr + SIGNAL_CA);
659
660
661 outb(0x80, ioaddr + MISC_CTRL);
662
663
664
665
666
667 return 0;
668}
669
670
671static void init_rx_bufs(struct net_device *dev)
672{
673 struct net_local *lp = netdev_priv(dev);
674 void __iomem *write_ptr;
675 unsigned short SCB_base = SCB_BASE;
676
677 int cur_rxbuf = lp->rx_head = RX_BUF_START;
678
679
680 do {
681
682 write_ptr = lp->base + cur_rxbuf;
683
684 writew(0x0000,write_ptr);
685 writew(0x0000,write_ptr+=2);
686 writew(cur_rxbuf + RX_BUF_SIZE,write_ptr+=2);
687 writew(cur_rxbuf + 22,write_ptr+=2);
688 writew(0x0000,write_ptr+=2);
689 writew(0x0000,write_ptr+=2);
690 writew(0x0000,write_ptr+=2);
691 writew(0x0000,write_ptr+=2);
692 writew(0x0000,write_ptr+=2);
693 writew(0x0000,write_ptr+=2);
694 writew(0x0000,write_ptr+=2);
695
696 writew(0x0000,write_ptr+=2);
697 writew(-1,write_ptr+=2);
698 writew(cur_rxbuf + 0x20 + SCB_base,write_ptr+=2);
699 writew(0x0000,write_ptr+=2);
700
701 writew(0x8000 + RX_BUF_SIZE-0x20,write_ptr+=2);
702
703 lp->rx_tail = cur_rxbuf;
704 cur_rxbuf += RX_BUF_SIZE;
705 } while (cur_rxbuf <= RX_BUF_END - RX_BUF_SIZE);
706
707
708
709 write_ptr = lp->base + lp->rx_tail + 2;
710 writew(0xC000,write_ptr);
711 writew(lp->rx_head,write_ptr+2);
712}
713
714static void init_82586_mem(struct net_device *dev)
715{
716 struct net_local *lp = netdev_priv(dev);
717 short ioaddr = dev->base_addr;
718 void __iomem *shmem = lp->base;
719
720
721
722 outb(0x20, ioaddr + MISC_CTRL);
723
724
725 init_words[3] = SCB_BASE;
726 init_words[7] = SCB_BASE;
727
728
729 memcpy_toio(lp->base + RX_BUF_END - 10, init_words, 10);
730
731
732 memcpy_toio(lp->base, init_words + 5, sizeof(init_words) - 10);
733
734
735 memcpy_toio(lp->base+SA_OFFSET, dev->dev_addr,
736 sizeof(dev->dev_addr));
737
738
739 lp->tx_cmd_link = IDLELOOP + 4;
740 lp->tx_head = lp->tx_reap = TX_BUF_START;
741
742 init_rx_bufs(dev);
743
744
745 outb(0xA0, ioaddr + MISC_CTRL);
746
747
748
749 outb(0, ioaddr + SIGNAL_CA);
750
751 {
752 int boguscnt = 50;
753 while (readw(shmem+iSCB_STATUS) == 0)
754 if (--boguscnt == 0) {
755 pr_warning("%s: i82586 initialization timed out with status %04x, cmd %04x.\n",
756 dev->name, readw(shmem+iSCB_STATUS), readw(shmem+iSCB_CMD));
757 break;
758 }
759
760 outb(0, ioaddr + SIGNAL_CA);
761 }
762
763
764 outb(0x84, ioaddr + MISC_CTRL);
765 if (net_debug > 4)
766 pr_debug("%s: Initialized 82586, status %04x.\n", dev->name,
767 readw(shmem+iSCB_STATUS));
768 return;
769}
770
771static void hardware_send_packet(struct net_device *dev, void *buf, short length, short pad)
772{
773 struct net_local *lp = netdev_priv(dev);
774 short ioaddr = dev->base_addr;
775 ushort tx_block = lp->tx_head;
776 void __iomem *write_ptr = lp->base + tx_block;
777 static char padding[ETH_ZLEN];
778
779
780 writew(0x0000,write_ptr);
781 writew(CMD_INTR|CmdTx,write_ptr+=2);
782 writew(tx_block+16,write_ptr+=2);
783 writew(tx_block+8,write_ptr+=2);
784
785
786 writew((pad + length) | 0x8000,write_ptr+=2);
787 writew(-1,write_ptr+=2);
788 writew(tx_block+22+SCB_BASE,write_ptr+=2);
789 writew(0x0000,write_ptr+=2);
790
791
792 writew(0x0000,write_ptr+=2);
793 writew(CmdNOp,write_ptr+=2);
794 writew(tx_block+16,write_ptr+=2);
795
796
797 memcpy_toio(write_ptr+2, buf, length);
798 if (pad)
799 memcpy_toio(write_ptr+length+2, padding, pad);
800
801
802 writew(tx_block,lp->base + lp->tx_cmd_link);
803 lp->tx_cmd_link = tx_block + 20;
804
805
806 lp->tx_head = tx_block + TX_BUF_SIZE;
807 if (lp->tx_head > RX_BUF_START - TX_BUF_SIZE)
808 lp->tx_head = TX_BUF_START;
809
810 if (net_debug > 4) {
811 pr_debug("%s: 3c507 @%x send length = %d, tx_block %3x, next %3x.\n",
812 dev->name, ioaddr, length, tx_block, lp->tx_head);
813 }
814
815
816 if (++lp->tx_pkts_in_ring < NUM_TX_BUFS)
817 netif_wake_queue(dev);
818}
819
820static void el16_rx(struct net_device *dev)
821{
822 struct net_local *lp = netdev_priv(dev);
823 void __iomem *shmem = lp->base;
824 ushort rx_head = lp->rx_head;
825 ushort rx_tail = lp->rx_tail;
826 ushort boguscount = 10;
827 short frame_status;
828
829 while ((frame_status = readw(shmem+rx_head)) < 0) {
830 void __iomem *read_frame = lp->base + rx_head;
831 ushort rfd_cmd = readw(read_frame+2);
832 ushort next_rx_frame = readw(read_frame+4);
833 ushort data_buffer_addr = readw(read_frame+6);
834 void __iomem *data_frame = lp->base + data_buffer_addr;
835 ushort pkt_len = readw(data_frame);
836
837 if (rfd_cmd != 0 || data_buffer_addr != rx_head + 22
838 || (pkt_len & 0xC000) != 0xC000) {
839 pr_err("%s: Rx frame at %#x corrupted, "
840 "status %04x cmd %04x next %04x "
841 "data-buf @%04x %04x.\n",
842 dev->name, rx_head, frame_status, rfd_cmd,
843 next_rx_frame, data_buffer_addr, pkt_len);
844 } else if ((frame_status & 0x2000) == 0) {
845
846 dev->stats.rx_errors++;
847 if (frame_status & 0x0800) dev->stats.rx_crc_errors++;
848 if (frame_status & 0x0400) dev->stats.rx_frame_errors++;
849 if (frame_status & 0x0200) dev->stats.rx_fifo_errors++;
850 if (frame_status & 0x0100) dev->stats.rx_over_errors++;
851 if (frame_status & 0x0080) dev->stats.rx_length_errors++;
852 } else {
853
854 struct sk_buff *skb;
855
856 pkt_len &= 0x3fff;
857 skb = dev_alloc_skb(pkt_len+2);
858 if (skb == NULL) {
859 pr_err("%s: Memory squeeze, dropping packet.\n",
860 dev->name);
861 dev->stats.rx_dropped++;
862 break;
863 }
864
865 skb_reserve(skb,2);
866
867
868 memcpy_fromio(skb_put(skb,pkt_len), data_frame + 10, pkt_len);
869
870 skb->protocol=eth_type_trans(skb,dev);
871 netif_rx(skb);
872 dev->stats.rx_packets++;
873 dev->stats.rx_bytes += pkt_len;
874 }
875
876
877 writew(0,read_frame);
878 writew(0xC000,read_frame+2);
879
880 writew(0x0000,lp->base + rx_tail + 2);
881
882 rx_tail = rx_head;
883 rx_head = next_rx_frame;
884 if (--boguscount == 0)
885 break;
886 }
887
888 lp->rx_head = rx_head;
889 lp->rx_tail = rx_tail;
890}
891
892static void netdev_get_drvinfo(struct net_device *dev,
893 struct ethtool_drvinfo *info)
894{
895 strcpy(info->driver, DRV_NAME);
896 strcpy(info->version, DRV_VERSION);
897 sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
898}
899
900static u32 netdev_get_msglevel(struct net_device *dev)
901{
902 return debug;
903}
904
905static void netdev_set_msglevel(struct net_device *dev, u32 level)
906{
907 debug = level;
908}
909
910static const struct ethtool_ops netdev_ethtool_ops = {
911 .get_drvinfo = netdev_get_drvinfo,
912 .get_msglevel = netdev_get_msglevel,
913 .set_msglevel = netdev_set_msglevel,
914};
915
916#ifdef MODULE
917static struct net_device *dev_3c507;
918module_param(io, int, 0);
919module_param(irq, int, 0);
920MODULE_PARM_DESC(io, "EtherLink16 I/O base address");
921MODULE_PARM_DESC(irq, "(ignored)");
922
923int __init init_module(void)
924{
925 if (io == 0)
926 pr_notice("3c507: You should not use auto-probing with insmod!\n");
927 dev_3c507 = el16_probe(-1);
928 return IS_ERR(dev_3c507) ? PTR_ERR(dev_3c507) : 0;
929}
930
931void __exit
932cleanup_module(void)
933{
934 struct net_device *dev = dev_3c507;
935 unregister_netdev(dev);
936 free_irq(dev->irq, dev);
937 iounmap(((struct net_local *)netdev_priv(dev))->base);
938 release_region(dev->base_addr, EL16_IO_EXTENT);
939 free_netdev(dev);
940}
941#endif
942MODULE_LICENSE("GPL");
943