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