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