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