Ok. I didn't make 2.4.0 in 2000. Tough. I tried, but we had some
[davej-history.git] / drivers / net / ni52.c
blobe05e75484e248cfac9fd3a82816c45a7584313cb
1 /*
2 * net-3-driver for the NI5210 card (i82586 Ethernet chip)
4 * This is an extension to the Linux operating system, and is covered by the
5 * same Gnu Public License that covers that work.
7 * Alphacode 0.82 (96/09/29) for Linux 2.0.0 (or later)
8 * Copyrights (c) 1994,1995,1996 by M.Hipp (hippm@informatik.uni-tuebingen.de)
9 * [feel free to mail ....]
11 * when using as module: (no autoprobing!)
12 * compile with:
13 * gcc -O2 -fomit-frame-pointer -m486 -D__KERNEL__ -DMODULE -c ni52.c
14 * run with e.g:
15 * insmod ni52.o io=0x360 irq=9 memstart=0xd0000 memend=0xd4000
17 * CAN YOU PLEASE REPORT ME YOUR PERFORMANCE EXPERIENCES !!.
19 * If you find a bug, please report me:
20 * The kernel panic output and any kmsg from the ni52 driver
21 * the ni5210-driver-version and the linux-kernel version
22 * how many shared memory (memsize) on the netcard,
23 * bootprom: yes/no, base_addr, mem_start
24 * maybe the ni5210-card revision and the i82586 version
26 * autoprobe for: base_addr: 0x300,0x280,0x360,0x320,0x340
27 * mem_start: 0xd0000,0xd2000,0xc8000,0xca000,0xd4000,0xd6000,
28 * 0xd8000,0xcc000,0xce000,0xda000,0xdc000
30 * sources:
31 * skeleton.c from Donald Becker
33 * I have also done a look in the following sources: (mail me if you need them)
34 * crynwr-packet-driver by Russ Nelson
35 * Garret A. Wollman's (fourth) i82586-driver for BSD
36 * (before getting an i82596 (yes 596 not 586) manual, the existing drivers helped
37 * me a lot to understand this tricky chip.)
39 * Known Problems:
40 * The internal sysbus seems to be slow. So we often lose packets because of
41 * overruns while receiving from a fast remote host.
42 * This can slow down TCP connections. Maybe the newer ni5210 cards are better.
43 * my experience is, that if a machine sends with more then about 500-600K/s
44 * the fifo/sysbus overflows.
46 * IMPORTANT NOTE:
47 * On fast networks, it's a (very) good idea to have 16K shared memory. With
48 * 8K, we can store only 4 receive frames, so it can (easily) happen that a remote
49 * machine 'overruns' our system.
51 * Known i82586/card problems (I'm sure, there are many more!):
52 * Running the NOP-mode, the i82586 sometimes seems to forget to report
53 * every xmit-interrupt until we restart the CU.
54 * Another MAJOR bug is, that the RU sometimes seems to ignore the EL-Bit
55 * in the RBD-Struct which indicates an end of the RBD queue.
56 * Instead, the RU fetches another (randomly selected and
57 * usually used) RBD and begins to fill it. (Maybe, this happens only if
58 * the last buffer from the previous RFD fits exact into the queue and
59 * the next RFD can't fetch an initial RBD. Anyone knows more? )
61 * results from ftp performance tests with Linux 1.2.5
62 * send and receive about 350-400 KByte/s (peak up to 460 kbytes/s)
63 * sending in NOP-mode: peak performance up to 530K/s (but better don't run this mode)
67 * 29.Sept.96: virt_to_bus changes for new memory scheme
68 * 19.Feb.96: more Mcast changes, module support (MH)
70 * 18.Nov.95: Mcast changes (AC).
72 * 23.April.95: fixed(?) receiving problems by configuring a RFD more
73 * than the number of RBD's. Can maybe cause other problems.
74 * 18.April.95: Added MODULE support (MH)
75 * 17.April.95: MC related changes in init586() and set_multicast_list().
76 * removed use of 'jiffies' in init586() (MH)
78 * 19.Sep.94: Added Multicast support (not tested yet) (MH)
80 * 18.Sep.94: Workaround for 'EL-Bug'. Removed flexible RBD-handling.
81 * Now, every RFD has exact one RBD. (MH)
83 * 14.Sep.94: added promiscuous mode, a few cleanups (MH)
85 * 19.Aug.94: changed request_irq() parameter (MH)
87 * 20.July.94: removed cleanup bugs, removed a 16K-mem-probe-bug (MH)
89 * 19.July.94: lotsa cleanups .. (MH)
91 * 17.July.94: some patches ... verified to run with 1.1.29 (MH)
93 * 4.July.94: patches for Linux 1.1.24 (MH)
95 * 26.March.94: patches for Linux 1.0 and iomem-auto-probe (MH)
97 * 30.Sep.93: Added nop-chain .. driver now runs with only one Xmit-Buff, too (MH)
99 * < 30.Sep.93: first versions
102 static int debuglevel = 0; /* debug-printk 0: off 1: a few 2: more */
103 static int automatic_resume = 0; /* experimental .. better should be zero */
104 static int rfdadd = 0; /* rfdadd=1 may be better for 8K MEM cards */
105 static int fifo=0x8; /* don't change */
107 /* #define REALLY_SLOW_IO */
109 #include <linux/module.h>
110 #include <linux/kernel.h>
111 #include <linux/string.h>
112 #include <linux/errno.h>
113 #include <linux/ioport.h>
114 #include <linux/malloc.h>
115 #include <linux/interrupt.h>
116 #include <linux/delay.h>
117 #include <linux/init.h>
118 #include <asm/bitops.h>
119 #include <asm/io.h>
121 #include <linux/netdevice.h>
122 #include <linux/etherdevice.h>
123 #include <linux/skbuff.h>
125 #include "ni52.h"
127 #define DEBUG /* debug on */
128 #define SYSBUSVAL 1 /* 8 Bit */
130 #define ni_attn586() {outb(0,dev->base_addr+NI52_ATTENTION);}
131 #define ni_reset586() {outb(0,dev->base_addr+NI52_RESET);}
132 #define ni_disint() {outb(0,dev->base_addr+NI52_INTDIS);}
133 #define ni_enaint() {outb(0,dev->base_addr+NI52_INTENA);}
135 #define make32(ptr16) (p->memtop + (short) (ptr16) )
136 #define make24(ptr32) ( ((char *) (ptr32)) - p->base)
137 #define make16(ptr32) ((unsigned short) ((unsigned long)(ptr32) - (unsigned long) p->memtop ))
139 /******************* how to calculate the buffers *****************************
141 * IMPORTANT NOTE: if you configure only one NUM_XMIT_BUFFS, the driver works
142 * --------------- in a different (more stable?) mode. Only in this mode it's
143 * possible to configure the driver with 'NO_NOPCOMMANDS'
145 sizeof(scp)=12; sizeof(scb)=16; sizeof(iscp)=8;
146 sizeof(scp)+sizeof(iscp)+sizeof(scb) = 36 = INIT
147 sizeof(rfd) = 24; sizeof(rbd) = 12;
148 sizeof(tbd) = 8; sizeof(transmit_cmd) = 16;
149 sizeof(nop_cmd) = 8;
151 * if you don't know the driver, better do not change these values: */
153 #define RECV_BUFF_SIZE 1524 /* slightly oversized */
154 #define XMIT_BUFF_SIZE 1524 /* slightly oversized */
155 #define NUM_XMIT_BUFFS 1 /* config for both, 8K and 16K shmem */
156 #define NUM_RECV_BUFFS_8 4 /* config for 8K shared mem */
157 #define NUM_RECV_BUFFS_16 9 /* config for 16K shared mem */
158 #define NO_NOPCOMMANDS /* only possible with NUM_XMIT_BUFFS=1 */
160 /**************************************************************************/
162 /* different DELAYs */
163 #define DELAY(x) mdelay(32 * x);
164 #define DELAY_16(); { udelay(16); }
165 #define DELAY_18(); { udelay(4); }
167 /* wait for command with timeout: */
168 #define WAIT_4_SCB_CMD() \
169 { int i; \
170 for(i=0;i<16384;i++) { \
171 if(!p->scb->cmd_cuc) break; \
172 DELAY_18(); \
173 if(i == 16383) { \
174 printk("%s: scb_cmd timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_cuc,p->scb->cus); \
175 if(!p->reseted) { p->reseted = 1; ni_reset586(); } } } }
177 #define WAIT_4_SCB_CMD_RUC() { int i; \
178 for(i=0;i<16384;i++) { \
179 if(!p->scb->cmd_ruc) break; \
180 DELAY_18(); \
181 if(i == 16383) { \
182 printk("%s: scb_cmd (ruc) timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_ruc,p->scb->rus); \
183 if(!p->reseted) { p->reseted = 1; ni_reset586(); } } } }
185 #define WAIT_4_STAT_COMPL(addr) { int i; \
186 for(i=0;i<32767;i++) { \
187 if((addr)->cmd_status & STAT_COMPL) break; \
188 DELAY_16(); DELAY_16(); } }
190 #define NI52_TOTAL_SIZE 16
191 #define NI52_ADDR0 0x02
192 #define NI52_ADDR1 0x07
193 #define NI52_ADDR2 0x01
195 static int ni52_probe1(struct net_device *dev,int ioaddr);
196 static void ni52_interrupt(int irq,void *dev_id,struct pt_regs *reg_ptr);
197 static int ni52_open(struct net_device *dev);
198 static int ni52_close(struct net_device *dev);
199 static int ni52_send_packet(struct sk_buff *,struct net_device *);
200 static struct net_device_stats *ni52_get_stats(struct net_device *dev);
201 static void set_multicast_list(struct net_device *dev);
202 static void ni52_timeout(struct net_device *dev);
203 #if 0
204 static void ni52_dump(struct net_device *,void *);
205 #endif
207 /* helper-functions */
208 static int init586(struct net_device *dev);
209 static int check586(struct net_device *dev,char *where,unsigned size);
210 static void alloc586(struct net_device *dev);
211 static void startrecv586(struct net_device *dev);
212 static void *alloc_rfa(struct net_device *dev,void *ptr);
213 static void ni52_rcv_int(struct net_device *dev);
214 static void ni52_xmt_int(struct net_device *dev);
215 static void ni52_rnr_int(struct net_device *dev);
217 struct priv
219 struct net_device_stats stats;
220 unsigned long base;
221 char *memtop;
222 long int lock;
223 int reseted;
224 volatile struct rfd_struct *rfd_last,*rfd_top,*rfd_first;
225 volatile struct scp_struct *scp; /* volatile is important */
226 volatile struct iscp_struct *iscp; /* volatile is important */
227 volatile struct scb_struct *scb; /* volatile is important */
228 volatile struct tbd_struct *xmit_buffs[NUM_XMIT_BUFFS];
229 volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];
230 #if (NUM_XMIT_BUFFS == 1)
231 volatile struct nop_cmd_struct *nop_cmds[2];
232 #else
233 volatile struct nop_cmd_struct *nop_cmds[NUM_XMIT_BUFFS];
234 #endif
235 volatile int nop_point,num_recv_buffs;
236 volatile char *xmit_cbuffs[NUM_XMIT_BUFFS];
237 volatile int xmit_count,xmit_last;
240 /**********************************************
241 * close device
243 static int ni52_close(struct net_device *dev)
245 free_irq(dev->irq, dev);
247 ni_reset586(); /* the hard way to stop the receiver */
249 netif_stop_queue(dev);
251 return 0;
254 /**********************************************
255 * open device
257 static int ni52_open(struct net_device *dev)
259 int ret;
261 ni_disint();
262 alloc586(dev);
263 init586(dev);
264 startrecv586(dev);
265 ni_enaint();
267 ret = request_irq(dev->irq, &ni52_interrupt,0,dev->name,dev);
268 if (ret)
270 ni_reset586();
271 return ret;
274 netif_start_queue(dev);
276 return 0; /* most done by init */
279 /**********************************************
280 * Check to see if there's an 82586 out there.
282 static int check586(struct net_device *dev,char *where,unsigned size)
284 struct priv pb;
285 struct priv *p = /* (struct priv *) dev->priv*/ &pb;
286 char *iscp_addrs[2];
287 int i;
289 p->base = (unsigned long) bus_to_virt((unsigned long)where) + size - 0x01000000;
290 p->memtop = bus_to_virt((unsigned long)where) + size;
291 p->scp = (struct scp_struct *)(p->base + SCP_DEFAULT_ADDRESS);
292 memset((char *)p->scp,0, sizeof(struct scp_struct));
293 for(i=0;i<sizeof(struct scp_struct);i++) /* memory was writeable? */
294 if(((char *)p->scp)[i])
295 return 0;
296 p->scp->sysbus = SYSBUSVAL; /* 1 = 8Bit-Bus, 0 = 16 Bit */
297 if(p->scp->sysbus != SYSBUSVAL)
298 return 0;
300 iscp_addrs[0] = bus_to_virt((unsigned long)where);
301 iscp_addrs[1]= (char *) p->scp - sizeof(struct iscp_struct);
303 for(i=0;i<2;i++)
305 p->iscp = (struct iscp_struct *) iscp_addrs[i];
306 memset((char *)p->iscp,0, sizeof(struct iscp_struct));
308 p->scp->iscp = make24(p->iscp);
309 p->iscp->busy = 1;
311 ni_reset586();
312 ni_attn586();
313 DELAY(1); /* wait a while... */
315 if(p->iscp->busy) /* i82586 clears 'busy' after successful init */
316 return 0;
318 return 1;
321 /******************************************************************
322 * set iscp at the right place, called by ni52_probe1 and open586.
324 static void alloc586(struct net_device *dev)
326 struct priv *p = (struct priv *) dev->priv;
328 ni_reset586();
329 DELAY(1);
331 p->scp = (struct scp_struct *) (p->base + SCP_DEFAULT_ADDRESS);
332 p->scb = (struct scb_struct *) bus_to_virt(dev->mem_start);
333 p->iscp = (struct iscp_struct *) ((char *)p->scp - sizeof(struct iscp_struct));
335 memset((char *) p->iscp,0,sizeof(struct iscp_struct));
336 memset((char *) p->scp ,0,sizeof(struct scp_struct));
338 p->scp->iscp = make24(p->iscp);
339 p->scp->sysbus = SYSBUSVAL;
340 p->iscp->scb_offset = make16(p->scb);
342 p->iscp->busy = 1;
343 ni_reset586();
344 ni_attn586();
346 DELAY(1);
348 if(p->iscp->busy)
349 printk("%s: Init-Problems (alloc).\n",dev->name);
351 p->reseted = 0;
353 memset((char *)p->scb,0,sizeof(struct scb_struct));
356 /**********************************************
357 * probe the ni5210-card
359 int __init ni52_probe(struct net_device *dev)
361 #ifndef MODULE
362 int *port;
363 static int ports[] = {0x300, 0x280, 0x360 , 0x320 , 0x340, 0};
364 #endif
365 int base_addr = dev->base_addr;
367 SET_MODULE_OWNER(dev);
369 if (base_addr > 0x1ff) /* Check a single specified location. */
370 return ni52_probe1(dev, base_addr);
371 else if (base_addr > 0) /* Don't probe at all. */
372 return -ENXIO;
374 #ifdef MODULE
375 printk("%s: no autoprobing allowed for modules.\n",dev->name);
376 #else
377 for (port = ports; *port; port++) {
378 int ioaddr = *port;
379 dev->base_addr = ioaddr;
380 if (ni52_probe1(dev, ioaddr) == 0)
381 return 0;
384 #ifdef FULL_IO_PROBE
385 for(dev->base_addr=0x200; dev->base_addr<0x400; dev->base_addr+=8)
386 if (ni52_probe1(dev, dev->base_addr) == 0)
387 return 0;
388 #endif
390 #endif
392 dev->base_addr = base_addr;
393 return -ENODEV;
396 static int __init ni52_probe1(struct net_device *dev,int ioaddr)
398 int i, size, retval;
400 if (!request_region(ioaddr, NI52_TOTAL_SIZE, dev->name))
401 return -EBUSY;
403 if( !(inb(ioaddr+NI52_MAGIC1) == NI52_MAGICVAL1) ||
404 !(inb(ioaddr+NI52_MAGIC2) == NI52_MAGICVAL2)) {
405 retval = -ENODEV;
406 goto out;
409 for(i=0;i<ETH_ALEN;i++)
410 dev->dev_addr[i] = inb(dev->base_addr+i);
412 if(dev->dev_addr[0] != NI52_ADDR0 || dev->dev_addr[1] != NI52_ADDR1
413 || dev->dev_addr[2] != NI52_ADDR2) {
414 retval = -ENODEV;
415 goto out;
418 printk("%s: NI5210 found at %#3lx, ",dev->name,dev->base_addr);
421 * check (or search) IO-Memory, 8K and 16K
423 #ifdef MODULE
424 size = dev->mem_end - dev->mem_start;
425 if(size != 0x2000 && size != 0x4000) {
426 printk("\n%s: Illegal memory size %d. Allowed is 0x2000 or 0x4000 bytes.\n",dev->name,size);
427 retval = -ENODEV;
428 goto out;
430 if(!check586(dev,(char *) dev->mem_start,size)) {
431 printk("?memcheck, Can't find memory at 0x%lx with size %d!\n",dev->mem_start,size);
432 retval = -ENODEV;
433 goto out;
435 #else
436 if(dev->mem_start != 0) /* no auto-mem-probe */
438 size = 0x4000; /* check for 16K mem */
439 if(!check586(dev,(char *) dev->mem_start,size)) {
440 size = 0x2000; /* check for 8K mem */
441 if(!check586(dev,(char *) dev->mem_start,size)) {
442 printk("?memprobe, Can't find memory at 0x%lx!\n",dev->mem_start);
443 retval = -ENODEV;
444 goto out;
448 else
450 static long memaddrs[] = { 0xc8000,0xca000,0xcc000,0xce000,0xd0000,0xd2000,
451 0xd4000,0xd6000,0xd8000,0xda000,0xdc000, 0 };
452 for(i=0;;i++)
454 if(!memaddrs[i]) {
455 printk("?memprobe, Can't find io-memory!\n");
456 retval = -ENODEV;
457 goto out;
459 dev->mem_start = memaddrs[i];
460 size = 0x2000; /* check for 8K mem */
461 if(check586(dev,(char *)dev->mem_start,size)) /* 8K-check */
462 break;
463 size = 0x4000; /* check for 16K mem */
464 if(check586(dev,(char *)dev->mem_start,size)) /* 16K-check */
465 break;
468 dev->mem_end = dev->mem_start + size; /* set mem_end showed by 'ifconfig' */
469 #endif
471 dev->priv = (void *) kmalloc(sizeof(struct priv),GFP_KERNEL);
472 if(dev->priv == NULL) {
473 printk("%s: Ooops .. can't allocate private driver memory.\n",dev->name);
474 retval = -ENOMEM;
475 goto out;
477 /* warning: we don't free it on errors */
478 memset((char *) dev->priv,0,sizeof(struct priv));
480 ((struct priv *) (dev->priv))->memtop = bus_to_virt(dev->mem_start) + size;
481 ((struct priv *) (dev->priv))->base = (unsigned long) bus_to_virt(dev->mem_start) + size - 0x01000000;
482 alloc586(dev);
484 /* set number of receive-buffs according to memsize */
485 if(size == 0x2000)
486 ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_8;
487 else
488 ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_16;
490 printk("Memaddr: 0x%lx, Memsize: %d, ",dev->mem_start,size);
492 if(dev->irq < 2)
494 autoirq_setup(0);
495 ni_reset586();
496 ni_attn586();
497 if(!(dev->irq = autoirq_report(2)))
499 printk("?autoirq, Failed to detect IRQ line!\n");
500 kfree(dev->priv);
501 dev->priv = NULL;
502 retval = -EAGAIN;
503 goto out;
505 printk("IRQ %d (autodetected).\n",dev->irq);
507 else {
508 if(dev->irq == 2)
509 dev->irq = 9;
510 printk("IRQ %d (assigned and not checked!).\n",dev->irq);
513 dev->open = ni52_open;
514 dev->stop = ni52_close;
515 dev->get_stats = ni52_get_stats;
516 dev->tx_timeout = ni52_timeout;
517 dev->watchdog_timeo = HZ/20;
518 dev->hard_start_xmit = ni52_send_packet;
519 dev->set_multicast_list = set_multicast_list;
521 dev->if_port = 0;
523 ether_setup(dev);
525 return 0;
526 out:
527 release_region(ioaddr, NI52_TOTAL_SIZE);
528 return retval;
531 /**********************************************
532 * init the chip (ni52-interrupt should be disabled?!)
533 * needs a correct 'allocated' memory
536 static int init586(struct net_device *dev)
538 void *ptr;
539 int i,result=0;
540 struct priv *p = (struct priv *) dev->priv;
541 volatile struct configure_cmd_struct *cfg_cmd;
542 volatile struct iasetup_cmd_struct *ias_cmd;
543 volatile struct tdr_cmd_struct *tdr_cmd;
544 volatile struct mcsetup_cmd_struct *mc_cmd;
545 struct dev_mc_list *dmi=dev->mc_list;
546 int num_addrs=dev->mc_count;
548 ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct));
550 cfg_cmd = (struct configure_cmd_struct *)ptr; /* configure-command */
551 cfg_cmd->cmd_status = 0;
552 cfg_cmd->cmd_cmd = CMD_CONFIGURE | CMD_LAST;
553 cfg_cmd->cmd_link = 0xffff;
555 cfg_cmd->byte_cnt = 0x0a; /* number of cfg bytes */
556 cfg_cmd->fifo = fifo; /* fifo-limit (8=tx:32/rx:64) */
557 cfg_cmd->sav_bf = 0x40; /* hold or discard bad recv frames (bit 7) */
558 cfg_cmd->adr_len = 0x2e; /* addr_len |!src_insert |pre-len |loopback */
559 cfg_cmd->priority = 0x00;
560 cfg_cmd->ifs = 0x60;
561 cfg_cmd->time_low = 0x00;
562 cfg_cmd->time_high = 0xf2;
563 cfg_cmd->promisc = 0;
564 if(dev->flags & IFF_ALLMULTI) {
565 int len = ((char *) p->iscp - (char *) ptr - 8) / 6;
566 if(num_addrs > len) {
567 printk("%s: switching to promisc. mode\n",dev->name);
568 dev->flags|=IFF_PROMISC;
571 if(dev->flags&IFF_PROMISC)
573 cfg_cmd->promisc=1;
574 dev->flags|=IFF_PROMISC;
576 cfg_cmd->carr_coll = 0x00;
578 p->scb->cbl_offset = make16(cfg_cmd);
579 p->scb->cmd_ruc = 0;
581 p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
582 ni_attn586();
584 WAIT_4_STAT_COMPL(cfg_cmd);
586 if((cfg_cmd->cmd_status & (STAT_OK|STAT_COMPL)) != (STAT_COMPL|STAT_OK))
588 printk("%s: configure command failed: %x\n",dev->name,cfg_cmd->cmd_status);
589 return 1;
593 * individual address setup
596 ias_cmd = (struct iasetup_cmd_struct *)ptr;
598 ias_cmd->cmd_status = 0;
599 ias_cmd->cmd_cmd = CMD_IASETUP | CMD_LAST;
600 ias_cmd->cmd_link = 0xffff;
602 memcpy((char *)&ias_cmd->iaddr,(char *) dev->dev_addr,ETH_ALEN);
604 p->scb->cbl_offset = make16(ias_cmd);
606 p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
607 ni_attn586();
609 WAIT_4_STAT_COMPL(ias_cmd);
611 if((ias_cmd->cmd_status & (STAT_OK|STAT_COMPL)) != (STAT_OK|STAT_COMPL)) {
612 printk("%s (ni52): individual address setup command failed: %04x\n",dev->name,ias_cmd->cmd_status);
613 return 1;
617 * TDR, wire check .. e.g. no resistor e.t.c
620 tdr_cmd = (struct tdr_cmd_struct *)ptr;
622 tdr_cmd->cmd_status = 0;
623 tdr_cmd->cmd_cmd = CMD_TDR | CMD_LAST;
624 tdr_cmd->cmd_link = 0xffff;
625 tdr_cmd->status = 0;
627 p->scb->cbl_offset = make16(tdr_cmd);
628 p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
629 ni_attn586();
631 WAIT_4_STAT_COMPL(tdr_cmd);
633 if(!(tdr_cmd->cmd_status & STAT_COMPL))
635 printk("%s: Problems while running the TDR.\n",dev->name);
637 else
639 DELAY_16(); /* wait for result */
640 result = tdr_cmd->status;
642 p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
643 ni_attn586(); /* ack the interrupts */
645 if(result & TDR_LNK_OK)
647 else if(result & TDR_XCVR_PRB)
648 printk("%s: TDR: Transceiver problem. Check the cable(s)!\n",dev->name);
649 else if(result & TDR_ET_OPN)
650 printk("%s: TDR: No correct termination %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
651 else if(result & TDR_ET_SRT)
653 if (result & TDR_TIMEMASK) /* time == 0 -> strange :-) */
654 printk("%s: TDR: Detected a short circuit %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
656 else
657 printk("%s: TDR: Unknown status %04x\n",dev->name,result);
661 * Multicast setup
663 if(num_addrs && !(dev->flags & IFF_PROMISC) )
665 mc_cmd = (struct mcsetup_cmd_struct *) ptr;
666 mc_cmd->cmd_status = 0;
667 mc_cmd->cmd_cmd = CMD_MCSETUP | CMD_LAST;
668 mc_cmd->cmd_link = 0xffff;
669 mc_cmd->mc_cnt = num_addrs * 6;
671 for(i=0;i<num_addrs;i++,dmi=dmi->next)
672 memcpy((char *) mc_cmd->mc_list[i], dmi->dmi_addr,6);
674 p->scb->cbl_offset = make16(mc_cmd);
675 p->scb->cmd_cuc = CUC_START;
676 ni_attn586();
678 WAIT_4_STAT_COMPL(mc_cmd);
680 if( (mc_cmd->cmd_status & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
681 printk("%s: Can't apply multicast-address-list.\n",dev->name);
685 * alloc nop/xmit-cmds
687 #if (NUM_XMIT_BUFFS == 1)
688 for(i=0;i<2;i++)
690 p->nop_cmds[i] = (struct nop_cmd_struct *)ptr;
691 p->nop_cmds[i]->cmd_cmd = CMD_NOP;
692 p->nop_cmds[i]->cmd_status = 0;
693 p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i]));
694 ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
696 #else
697 for(i=0;i<NUM_XMIT_BUFFS;i++)
699 p->nop_cmds[i] = (struct nop_cmd_struct *)ptr;
700 p->nop_cmds[i]->cmd_cmd = CMD_NOP;
701 p->nop_cmds[i]->cmd_status = 0;
702 p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i]));
703 ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
705 #endif
707 ptr = alloc_rfa(dev,(void *)ptr); /* init receive-frame-area */
710 * alloc xmit-buffs / init xmit_cmds
712 for(i=0;i<NUM_XMIT_BUFFS;i++)
714 p->xmit_cmds[i] = (struct transmit_cmd_struct *)ptr; /*transmit cmd/buff 0*/
715 ptr = (char *) ptr + sizeof(struct transmit_cmd_struct);
716 p->xmit_cbuffs[i] = (char *)ptr; /* char-buffs */
717 ptr = (char *) ptr + XMIT_BUFF_SIZE;
718 p->xmit_buffs[i] = (struct tbd_struct *)ptr; /* TBD */
719 ptr = (char *) ptr + sizeof(struct tbd_struct);
720 if((void *)ptr > (void *)p->iscp)
722 printk("%s: not enough shared-mem for your configuration!\n",dev->name);
723 return 1;
725 memset((char *)(p->xmit_cmds[i]) ,0, sizeof(struct transmit_cmd_struct));
726 memset((char *)(p->xmit_buffs[i]),0, sizeof(struct tbd_struct));
727 p->xmit_cmds[i]->cmd_link = make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]);
728 p->xmit_cmds[i]->cmd_status = STAT_COMPL;
729 p->xmit_cmds[i]->cmd_cmd = CMD_XMIT | CMD_INT;
730 p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i]));
731 p->xmit_buffs[i]->next = 0xffff;
732 p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i]));
735 p->xmit_count = 0;
736 p->xmit_last = 0;
737 #ifndef NO_NOPCOMMANDS
738 p->nop_point = 0;
739 #endif
742 * 'start transmitter'
744 #ifndef NO_NOPCOMMANDS
745 p->scb->cbl_offset = make16(p->nop_cmds[0]);
746 p->scb->cmd_cuc = CUC_START;
747 ni_attn586();
748 WAIT_4_SCB_CMD();
749 #else
750 p->xmit_cmds[0]->cmd_link = make16(p->xmit_cmds[0]);
751 p->xmit_cmds[0]->cmd_cmd = CMD_XMIT | CMD_SUSPEND | CMD_INT;
752 #endif
755 * ack. interrupts
757 p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
758 ni_attn586();
759 DELAY_16();
761 ni_enaint();
763 return 0;
766 /******************************************************
767 * This is a helper routine for ni52_rnr_int() and init586().
768 * It sets up the Receive Frame Area (RFA).
771 static void *alloc_rfa(struct net_device *dev,void *ptr)
773 volatile struct rfd_struct *rfd = (struct rfd_struct *)ptr;
774 volatile struct rbd_struct *rbd;
775 int i;
776 struct priv *p = (struct priv *) dev->priv;
778 memset((char *) rfd,0,sizeof(struct rfd_struct)*(p->num_recv_buffs+rfdadd));
779 p->rfd_first = rfd;
781 for(i = 0; i < (p->num_recv_buffs+rfdadd); i++) {
782 rfd[i].next = make16(rfd + (i+1) % (p->num_recv_buffs+rfdadd) );
783 rfd[i].rbd_offset = 0xffff;
785 rfd[p->num_recv_buffs-1+rfdadd].last = RFD_SUSP; /* RU suspend */
787 ptr = (void *) (rfd + (p->num_recv_buffs + rfdadd) );
789 rbd = (struct rbd_struct *) ptr;
790 ptr = (void *) (rbd + p->num_recv_buffs);
792 /* clr descriptors */
793 memset((char *) rbd,0,sizeof(struct rbd_struct)*(p->num_recv_buffs));
795 for(i=0;i<p->num_recv_buffs;i++)
797 rbd[i].next = make16((rbd + (i+1) % p->num_recv_buffs));
798 rbd[i].size = RECV_BUFF_SIZE;
799 rbd[i].buffer = make24(ptr);
800 ptr = (char *) ptr + RECV_BUFF_SIZE;
803 p->rfd_top = p->rfd_first;
804 p->rfd_last = p->rfd_first + (p->num_recv_buffs - 1 + rfdadd);
806 p->scb->rfa_offset = make16(p->rfd_first);
807 p->rfd_first->rbd_offset = make16(rbd);
809 return ptr;
813 /**************************************************
814 * Interrupt Handler ...
817 static void ni52_interrupt(int irq,void *dev_id,struct pt_regs *reg_ptr)
819 struct net_device *dev = dev_id;
820 unsigned short stat;
821 int cnt=0;
822 struct priv *p;
824 if (!dev) {
825 printk ("ni5210-interrupt: irq %d for unknown device.\n",irq);
826 return;
828 p = (struct priv *) dev->priv;
830 if(debuglevel > 1)
831 printk("I");
833 WAIT_4_SCB_CMD(); /* wait for last command */
835 while((stat=p->scb->cus & STAT_MASK))
837 p->scb->cmd_cuc = stat;
838 ni_attn586();
840 if(stat & STAT_FR) /* received a frame */
841 ni52_rcv_int(dev);
843 if(stat & STAT_RNR) /* RU went 'not ready' */
845 printk("(R)");
846 if(p->scb->rus & RU_SUSPEND) /* special case: RU_SUSPEND */
848 WAIT_4_SCB_CMD();
849 p->scb->cmd_ruc = RUC_RESUME;
850 ni_attn586();
851 WAIT_4_SCB_CMD_RUC();
853 else
855 printk("%s: Receiver-Unit went 'NOT READY': %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->rus);
856 ni52_rnr_int(dev);
860 if(stat & STAT_CX) /* command with I-bit set complete */
861 ni52_xmt_int(dev);
863 #ifndef NO_NOPCOMMANDS
864 if(stat & STAT_CNA) /* CU went 'not ready' */
866 if(netif_running(dev))
867 printk("%s: oops! CU has left active state. stat: %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->cus);
869 #endif
871 if(debuglevel > 1)
872 printk("%d",cnt++);
874 WAIT_4_SCB_CMD(); /* wait for ack. (ni52_xmt_int can be faster than ack!!) */
875 if(p->scb->cmd_cuc) /* timed out? */
877 printk("%s: Acknowledge timed out.\n",dev->name);
878 ni_disint();
879 break;
883 if(debuglevel > 1)
884 printk("i");
887 /*******************************************************
888 * receive-interrupt
891 static void ni52_rcv_int(struct net_device *dev)
893 int status,cnt=0;
894 unsigned short totlen;
895 struct sk_buff *skb;
896 struct rbd_struct *rbd;
897 struct priv *p = (struct priv *) dev->priv;
899 if(debuglevel > 0)
900 printk("R");
902 for(;(status = p->rfd_top->stat_high) & RFD_COMPL;)
904 rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset);
906 if(status & RFD_OK) /* frame received without error? */
908 if( (totlen = rbd->status) & RBD_LAST) /* the first and the last buffer? */
910 totlen &= RBD_MASK; /* length of this frame */
911 rbd->status = 0;
912 skb = (struct sk_buff *) dev_alloc_skb(totlen+2);
913 if(skb != NULL)
915 skb->dev = dev;
916 skb_reserve(skb,2);
917 skb_put(skb,totlen);
918 eth_copy_and_sum(skb,(char *) p->base+(unsigned long) rbd->buffer,totlen,0);
919 skb->protocol=eth_type_trans(skb,dev);
920 netif_rx(skb);
921 p->stats.rx_packets++;
923 else
924 p->stats.rx_dropped++;
926 else
928 int rstat;
929 /* free all RBD's until RBD_LAST is set */
930 totlen = 0;
931 while(!((rstat=rbd->status) & RBD_LAST))
933 totlen += rstat & RBD_MASK;
934 if(!rstat)
936 printk("%s: Whoops .. no end mark in RBD list\n",dev->name);
937 break;
939 rbd->status = 0;
940 rbd = (struct rbd_struct *) make32(rbd->next);
942 totlen += rstat & RBD_MASK;
943 rbd->status = 0;
944 printk("%s: received oversized frame! length: %d\n",dev->name,totlen);
945 p->stats.rx_dropped++;
948 else /* frame !(ok), only with 'save-bad-frames' */
950 printk("%s: oops! rfd-error-status: %04x\n",dev->name,status);
951 p->stats.rx_errors++;
953 p->rfd_top->stat_high = 0;
954 p->rfd_top->last = RFD_SUSP; /* maybe exchange by RFD_LAST */
955 p->rfd_top->rbd_offset = 0xffff;
956 p->rfd_last->last = 0; /* delete RFD_SUSP */
957 p->rfd_last = p->rfd_top;
958 p->rfd_top = (struct rfd_struct *) make32(p->rfd_top->next); /* step to next RFD */
959 p->scb->rfa_offset = make16(p->rfd_top);
961 if(debuglevel > 0)
962 printk("%d",cnt++);
965 if(automatic_resume)
967 WAIT_4_SCB_CMD();
968 p->scb->cmd_ruc = RUC_RESUME;
969 ni_attn586();
970 WAIT_4_SCB_CMD_RUC();
973 #ifdef WAIT_4_BUSY
975 int i;
976 for(i=0;i<1024;i++)
978 if(p->rfd_top->status)
979 break;
980 DELAY_16();
981 if(i == 1023)
982 printk("%s: RU hasn't fetched next RFD (not busy/complete)\n",dev->name);
985 #endif
987 #if 0
988 if(!at_least_one)
990 int i;
991 volatile struct rfd_struct *rfds=p->rfd_top;
992 volatile struct rbd_struct *rbds;
993 printk("%s: received a FC intr. without having a frame: %04x %d\n",dev->name,status,old_at_least);
994 for(i=0;i< (p->num_recv_buffs+4);i++)
996 rbds = (struct rbd_struct *) make32(rfds->rbd_offset);
997 printk("%04x:%04x ",rfds->status,rbds->status);
998 rfds = (struct rfd_struct *) make32(rfds->next);
1000 printk("\nerrs: %04x %04x stat: %04x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->status);
1001 printk("\nerrs: %04x %04x rus: %02x, cus: %02x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->rus,(int)p->scb->cus);
1003 old_at_least = at_least_one;
1004 #endif
1006 if(debuglevel > 0)
1007 printk("r");
1010 /**********************************************************
1011 * handle 'Receiver went not ready'.
1014 static void ni52_rnr_int(struct net_device *dev)
1016 struct priv *p = (struct priv *) dev->priv;
1018 p->stats.rx_errors++;
1020 WAIT_4_SCB_CMD(); /* wait for the last cmd, WAIT_4_FULLSTAT?? */
1021 p->scb->cmd_ruc = RUC_ABORT; /* usually the RU is in the 'no resource'-state .. abort it now. */
1022 ni_attn586();
1023 WAIT_4_SCB_CMD_RUC(); /* wait for accept cmd. */
1025 alloc_rfa(dev,(char *)p->rfd_first);
1026 /* maybe add a check here, before restarting the RU */
1027 startrecv586(dev); /* restart RU */
1029 printk("%s: Receive-Unit restarted. Status: %04x\n",dev->name,p->scb->rus);
1033 /**********************************************************
1034 * handle xmit - interrupt
1037 static void ni52_xmt_int(struct net_device *dev)
1039 int status;
1040 struct priv *p = (struct priv *) dev->priv;
1042 if(debuglevel > 0)
1043 printk("X");
1045 status = p->xmit_cmds[p->xmit_last]->cmd_status;
1046 if(!(status & STAT_COMPL))
1047 printk("%s: strange .. xmit-int without a 'COMPLETE'\n",dev->name);
1049 if(status & STAT_OK)
1051 p->stats.tx_packets++;
1052 p->stats.collisions += (status & TCMD_MAXCOLLMASK);
1054 else
1056 p->stats.tx_errors++;
1057 if(status & TCMD_LATECOLL) {
1058 printk("%s: late collision detected.\n",dev->name);
1059 p->stats.collisions++;
1061 else if(status & TCMD_NOCARRIER) {
1062 p->stats.tx_carrier_errors++;
1063 printk("%s: no carrier detected.\n",dev->name);
1065 else if(status & TCMD_LOSTCTS)
1066 printk("%s: loss of CTS detected.\n",dev->name);
1067 else if(status & TCMD_UNDERRUN) {
1068 p->stats.tx_fifo_errors++;
1069 printk("%s: DMA underrun detected.\n",dev->name);
1071 else if(status & TCMD_MAXCOLL) {
1072 printk("%s: Max. collisions exceeded.\n",dev->name);
1073 p->stats.collisions += 16;
1077 #if (NUM_XMIT_BUFFS > 1)
1078 if( (++p->xmit_last) == NUM_XMIT_BUFFS)
1079 p->xmit_last = 0;
1080 #endif
1081 netif_wake_queue(dev);
1084 /***********************************************************
1085 * (re)start the receiver
1088 static void startrecv586(struct net_device *dev)
1090 struct priv *p = (struct priv *) dev->priv;
1092 WAIT_4_SCB_CMD();
1093 WAIT_4_SCB_CMD_RUC();
1094 p->scb->rfa_offset = make16(p->rfd_first);
1095 p->scb->cmd_ruc = RUC_START;
1096 ni_attn586(); /* start cmd. */
1097 WAIT_4_SCB_CMD_RUC(); /* wait for accept cmd. (no timeout!!) */
1100 static void ni52_timeout(struct net_device *dev)
1102 struct priv *p = (struct priv *) dev->priv;
1103 #ifndef NO_NOPCOMMANDS
1104 if(p->scb->cus & CU_ACTIVE) /* COMMAND-UNIT active? */
1106 netif_wake_queue(dev);
1107 #ifdef DEBUG
1108 printk("%s: strange ... timeout with CU active?!?\n",dev->name);
1109 printk("%s: X0: %04x N0: %04x N1: %04x %d\n",dev->name,(int)p->xmit_cmds[0]->cmd_status,(int)p->nop_cmds[0]->cmd_status,(int)p->nop_cmds[1]->cmd_status,(int)p->nop_point);
1110 #endif
1111 p->scb->cmd_cuc = CUC_ABORT;
1112 ni_attn586();
1113 WAIT_4_SCB_CMD();
1114 p->scb->cbl_offset = make16(p->nop_cmds[p->nop_point]);
1115 p->scb->cmd_cuc = CUC_START;
1116 ni_attn586();
1117 WAIT_4_SCB_CMD();
1118 dev->trans_start = jiffies;
1119 return 0;
1121 #endif
1123 #ifdef DEBUG
1124 printk("%s: xmitter timed out, try to restart! stat: %02x\n",dev->name,p->scb->cus);
1125 printk("%s: command-stats: %04x %04x\n",dev->name,p->xmit_cmds[0]->cmd_status,p->xmit_cmds[1]->cmd_status);
1126 printk("%s: check, whether you set the right interrupt number!\n",dev->name);
1127 #endif
1128 ni52_close(dev);
1129 ni52_open(dev);
1131 dev->trans_start = jiffies;
1134 /******************************************************
1135 * send frame
1138 static int ni52_send_packet(struct sk_buff *skb, struct net_device *dev)
1140 int len,i;
1141 #ifndef NO_NOPCOMMANDS
1142 int next_nop;
1143 #endif
1144 struct priv *p = (struct priv *) dev->priv;
1146 if(skb->len > XMIT_BUFF_SIZE)
1148 printk("%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n",dev->name,XMIT_BUFF_SIZE,skb->len);
1149 return 0;
1152 netif_stop_queue(dev);
1154 #if(NUM_XMIT_BUFFS > 1)
1155 if(test_and_set_bit(0,(void *) &p->lock)) {
1156 printk("%s: Queue was locked\n",dev->name);
1157 return 1;
1159 else
1160 #endif
1162 memcpy((char *)p->xmit_cbuffs[p->xmit_count],(char *)(skb->data),skb->len);
1163 len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
1165 #if (NUM_XMIT_BUFFS == 1)
1166 # ifdef NO_NOPCOMMANDS
1168 #ifdef DEBUG
1169 if(p->scb->cus & CU_ACTIVE)
1171 printk("%s: Hmmm .. CU is still running and we wanna send a new packet.\n",dev->name);
1172 printk("%s: stat: %04x %04x\n",dev->name,p->scb->cus,p->xmit_cmds[0]->cmd_status);
1174 #endif
1176 p->xmit_buffs[0]->size = TBD_LAST | len;
1177 for(i=0;i<16;i++)
1179 p->xmit_cmds[0]->cmd_status = 0;
1180 WAIT_4_SCB_CMD();
1181 if( (p->scb->cus & CU_STATUS) == CU_SUSPEND)
1182 p->scb->cmd_cuc = CUC_RESUME;
1183 else
1185 p->scb->cbl_offset = make16(p->xmit_cmds[0]);
1186 p->scb->cmd_cuc = CUC_START;
1189 ni_attn586();
1190 dev->trans_start = jiffies;
1191 if(!i)
1192 dev_kfree_skb(skb);
1193 WAIT_4_SCB_CMD();
1194 if( (p->scb->cus & CU_ACTIVE)) /* test it, because CU sometimes doesn't start immediately */
1195 break;
1196 if(p->xmit_cmds[0]->cmd_status)
1197 break;
1198 if(i==15)
1199 printk("%s: Can't start transmit-command.\n",dev->name);
1201 # else
1202 next_nop = (p->nop_point + 1) & 0x1;
1203 p->xmit_buffs[0]->size = TBD_LAST | len;
1205 p->xmit_cmds[0]->cmd_link = p->nop_cmds[next_nop]->cmd_link
1206 = make16((p->nop_cmds[next_nop]));
1207 p->xmit_cmds[0]->cmd_status = p->nop_cmds[next_nop]->cmd_status = 0;
1209 p->nop_cmds[p->nop_point]->cmd_link = make16((p->xmit_cmds[0]));
1210 dev->trans_start = jiffies;
1211 p->nop_point = next_nop;
1212 dev_kfree_skb(skb);
1213 # endif
1214 #else
1215 p->xmit_buffs[p->xmit_count]->size = TBD_LAST | len;
1216 if( (next_nop = p->xmit_count + 1) == NUM_XMIT_BUFFS )
1217 next_nop = 0;
1219 p->xmit_cmds[p->xmit_count]->cmd_status = 0;
1220 /* linkpointer of xmit-command already points to next nop cmd */
1221 p->nop_cmds[next_nop]->cmd_link = make16((p->nop_cmds[next_nop]));
1222 p->nop_cmds[next_nop]->cmd_status = 0;
1224 p->nop_cmds[p->xmit_count]->cmd_link = make16((p->xmit_cmds[p->xmit_count]));
1225 dev->trans_start = jiffies;
1226 p->xmit_count = next_nop;
1229 unsigned long flags;
1230 save_flags(flags);
1231 cli();
1232 if(p->xmit_count != p->xmit_last)
1233 netif_wake_queue(dev);
1234 p->lock = 0;
1235 restore_flags(flags);
1237 dev_kfree_skb(skb);
1238 #endif
1240 return 0;
1243 /*******************************************
1244 * Someone wanna have the statistics
1247 static struct net_device_stats *ni52_get_stats(struct net_device *dev)
1249 struct priv *p = (struct priv *) dev->priv;
1250 unsigned short crc,aln,rsc,ovrn;
1252 crc = p->scb->crc_errs; /* get error-statistic from the ni82586 */
1253 p->scb->crc_errs = 0;
1254 aln = p->scb->aln_errs;
1255 p->scb->aln_errs = 0;
1256 rsc = p->scb->rsc_errs;
1257 p->scb->rsc_errs = 0;
1258 ovrn = p->scb->ovrn_errs;
1259 p->scb->ovrn_errs = 0;
1261 p->stats.rx_crc_errors += crc;
1262 p->stats.rx_fifo_errors += ovrn;
1263 p->stats.rx_frame_errors += aln;
1264 p->stats.rx_dropped += rsc;
1266 return &p->stats;
1269 /********************************************************
1270 * Set MC list ..
1273 static void set_multicast_list(struct net_device *dev)
1275 netif_stop_queue(dev);
1276 ni_disint();
1277 alloc586(dev);
1278 init586(dev);
1279 startrecv586(dev);
1280 ni_enaint();
1281 netif_wake_queue(dev);
1284 #ifdef MODULE
1285 static struct net_device dev_ni52;
1287 /* set: io,irq,memstart,memend or set it when calling insmod */
1288 static int irq=9;
1289 static int io=0x300;
1290 static long memstart=0; /* e.g 0xd0000 */
1291 static long memend=0; /* e.g 0xd4000 */
1293 MODULE_PARM(io, "i");
1294 MODULE_PARM(irq, "i");
1295 MODULE_PARM(memstart, "l");
1296 MODULE_PARM(memend, "l");
1298 int init_module(void)
1300 if(io <= 0x0 || !memend || !memstart || irq < 2) {
1301 printk("ni52: Autoprobing not allowed for modules.\nni52: Set symbols 'io' 'irq' 'memstart' and 'memend'\n");
1302 return -ENODEV;
1304 dev_ni52.init = ni52_probe;
1305 dev_ni52.irq = irq;
1306 dev_ni52.base_addr = io;
1307 dev_ni52.mem_end = memend;
1308 dev_ni52.mem_start = memstart;
1309 if (register_netdev(&dev_ni52) != 0)
1310 return -EIO;
1311 return 0;
1314 void cleanup_module(void)
1316 release_region(dev_ni52.base_addr, NI52_TOTAL_SIZE);
1317 unregister_netdev(&dev_ni52);
1318 kfree(dev_ni52.priv);
1319 dev_ni52.priv = NULL;
1321 #endif /* MODULE */
1323 #if 0
1325 * DUMP .. we expect a not running CMD unit and enough space
1327 void ni52_dump(struct net_device *dev,void *ptr)
1329 struct priv *p = (struct priv *) dev->priv;
1330 struct dump_cmd_struct *dump_cmd = (struct dump_cmd_struct *) ptr;
1331 int i;
1333 p->scb->cmd_cuc = CUC_ABORT;
1334 ni_attn586();
1335 WAIT_4_SCB_CMD();
1336 WAIT_4_SCB_CMD_RUC();
1338 dump_cmd->cmd_status = 0;
1339 dump_cmd->cmd_cmd = CMD_DUMP | CMD_LAST;
1340 dump_cmd->dump_offset = make16((dump_cmd + 1));
1341 dump_cmd->cmd_link = 0xffff;
1343 p->scb->cbl_offset = make16(dump_cmd);
1344 p->scb->cmd_cuc = CUC_START;
1345 ni_attn586();
1346 WAIT_4_STAT_COMPL(dump_cmd);
1348 if( (dump_cmd->cmd_status & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
1349 printk("%s: Can't get dump information.\n",dev->name);
1351 for(i=0;i<170;i++) {
1352 printk("%02x ",(int) ((unsigned char *) (dump_cmd + 1))[i]);
1353 if(i % 24 == 23)
1354 printk("\n");
1356 printk("\n");
1358 #endif
1361 * END: linux/drivers/net/ni52.c