dcdbas: use memory_read_from_buffer()
[linux-2.6] / drivers / net / sun3_82586.c
1 /*
2  * Sun3 i82586 Ethernet driver
3  *
4  * Cloned from ni52.c for the Sun3 by Sam Creasey (sammy@sammy.net)
5  *
6  * Original copyright follows:
7  * --------------------------
8  *
9  * net-3-driver for the NI5210 card (i82586 Ethernet chip)
10  *
11  * This is an extension to the Linux operating system, and is covered by the
12  * same Gnu Public License that covers that work.
13  *
14  * Alphacode 0.82 (96/09/29) for Linux 2.0.0 (or later)
15  * Copyrights (c) 1994,1995,1996 by M.Hipp (hippm@informatik.uni-tuebingen.de)
16  * --------------------------
17  *
18  * Consult ni52.c for further notes from the original driver.
19  *
20  * This incarnation currently supports the OBIO version of the i82586 chip
21  * used in certain sun3 models.  It should be fairly doable to expand this
22  * to support VME if I should every acquire such a board.
23  *
24  */
25
26 static int debuglevel = 0; /* debug-printk 0: off 1: a few 2: more */
27 static int automatic_resume = 0; /* experimental .. better should be zero */
28 static int rfdadd = 0; /* rfdadd=1 may be better for 8K MEM cards */
29 static int fifo=0x8;    /* don't change */
30
31 #include <linux/module.h>
32 #include <linux/kernel.h>
33 #include <linux/string.h>
34 #include <linux/errno.h>
35 #include <linux/ioport.h>
36 #include <linux/slab.h>
37 #include <linux/interrupt.h>
38 #include <linux/delay.h>
39 #include <linux/init.h>
40 #include <linux/bitops.h>
41 #include <asm/io.h>
42 #include <asm/idprom.h>
43 #include <asm/machines.h>
44 #include <asm/sun3mmu.h>
45 #include <asm/dvma.h>
46 #include <asm/byteorder.h>
47
48 #include <linux/netdevice.h>
49 #include <linux/etherdevice.h>
50 #include <linux/skbuff.h>
51
52 #include "sun3_82586.h"
53
54 #define DRV_NAME "sun3_82586"
55
56 #define DEBUG       /* debug on */
57 #define SYSBUSVAL 0 /* 16 Bit */
58 #define SUN3_82586_TOTAL_SIZE   PAGE_SIZE
59
60 #define sun3_attn586()  {*(volatile unsigned char *)(dev->base_addr) |= IEOB_ATTEN; *(volatile unsigned char *)(dev->base_addr) &= ~IEOB_ATTEN;}
61 #define sun3_reset586() {*(volatile unsigned char *)(dev->base_addr) = 0; udelay(100); *(volatile unsigned char *)(dev->base_addr) = IEOB_NORSET;}
62 #define sun3_disint()   {*(volatile unsigned char *)(dev->base_addr) &= ~IEOB_IENAB;}
63 #define sun3_enaint()   {*(volatile unsigned char *)(dev->base_addr) |= IEOB_IENAB;}
64 #define sun3_active()   {*(volatile unsigned char *)(dev->base_addr) |= (IEOB_IENAB|IEOB_ONAIR|IEOB_NORSET);}
65
66 #define make32(ptr16) (p->memtop + (swab16((unsigned short) (ptr16))) )
67 #define make24(ptr32) (char *)swab32(( ((unsigned long) (ptr32)) - p->base))
68 #define make16(ptr32) (swab16((unsigned short) ((unsigned long)(ptr32) - (unsigned long) p->memtop )))
69
70 /******************* how to calculate the buffers *****************************
71
72   * IMPORTANT NOTE: if you configure only one NUM_XMIT_BUFFS, the driver works
73   * --------------- in a different (more stable?) mode. Only in this mode it's
74   *                 possible to configure the driver with 'NO_NOPCOMMANDS'
75
76 sizeof(scp)=12; sizeof(scb)=16; sizeof(iscp)=8;
77 sizeof(scp)+sizeof(iscp)+sizeof(scb) = 36 = INIT
78 sizeof(rfd) = 24; sizeof(rbd) = 12;
79 sizeof(tbd) = 8; sizeof(transmit_cmd) = 16;
80 sizeof(nop_cmd) = 8;
81
82   * if you don't know the driver, better do not change these values: */
83
84 #define RECV_BUFF_SIZE 1536 /* slightly oversized */
85 #define XMIT_BUFF_SIZE 1536 /* slightly oversized */
86 #define NUM_XMIT_BUFFS 1    /* config for 32K shmem */
87 #define NUM_RECV_BUFFS_8 4 /* config for 32K shared mem */
88 #define NUM_RECV_BUFFS_16 9 /* config for 32K shared mem */
89 #define NUM_RECV_BUFFS_32 16 /* config for 32K shared mem */
90 #define NO_NOPCOMMANDS      /* only possible with NUM_XMIT_BUFFS=1 */
91
92 /**************************************************************************/
93
94 /* different DELAYs */
95 #define DELAY(x) mdelay(32 * x);
96 #define DELAY_16(); { udelay(16); }
97 #define DELAY_18(); { udelay(4); }
98
99 /* wait for command with timeout: */
100 #define WAIT_4_SCB_CMD() \
101 { int i; \
102   for(i=0;i<16384;i++) { \
103     if(!p->scb->cmd_cuc) break; \
104     DELAY_18(); \
105     if(i == 16383) { \
106       printk("%s: scb_cmd timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_cuc,p->scb->cus); \
107        if(!p->reseted) { p->reseted = 1; sun3_reset586(); } } } }
108
109 #define WAIT_4_SCB_CMD_RUC() { int i; \
110   for(i=0;i<16384;i++) { \
111     if(!p->scb->cmd_ruc) break; \
112     DELAY_18(); \
113     if(i == 16383) { \
114       printk("%s: scb_cmd (ruc) timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_ruc,p->scb->rus); \
115        if(!p->reseted) { p->reseted = 1; sun3_reset586(); } } } }
116
117 #define WAIT_4_STAT_COMPL(addr) { int i; \
118    for(i=0;i<32767;i++) { \
119      if(swab16((addr)->cmd_status) & STAT_COMPL) break; \
120      DELAY_16(); DELAY_16(); } }
121
122 static int     sun3_82586_probe1(struct net_device *dev,int ioaddr);
123 static irqreturn_t sun3_82586_interrupt(int irq,void *dev_id);
124 static int     sun3_82586_open(struct net_device *dev);
125 static int     sun3_82586_close(struct net_device *dev);
126 static int     sun3_82586_send_packet(struct sk_buff *,struct net_device *);
127 static struct  net_device_stats *sun3_82586_get_stats(struct net_device *dev);
128 static void    set_multicast_list(struct net_device *dev);
129 static void    sun3_82586_timeout(struct net_device *dev);
130 #if 0
131 static void    sun3_82586_dump(struct net_device *,void *);
132 #endif
133
134 /* helper-functions */
135 static int     init586(struct net_device *dev);
136 static int     check586(struct net_device *dev,char *where,unsigned size);
137 static void    alloc586(struct net_device *dev);
138 static void    startrecv586(struct net_device *dev);
139 static void   *alloc_rfa(struct net_device *dev,void *ptr);
140 static void    sun3_82586_rcv_int(struct net_device *dev);
141 static void    sun3_82586_xmt_int(struct net_device *dev);
142 static void    sun3_82586_rnr_int(struct net_device *dev);
143
144 struct priv
145 {
146         struct net_device_stats stats;
147         unsigned long base;
148         char *memtop;
149         long int lock;
150         int reseted;
151         volatile struct rfd_struct      *rfd_last,*rfd_top,*rfd_first;
152         volatile struct scp_struct      *scp;   /* volatile is important */
153         volatile struct iscp_struct     *iscp;  /* volatile is important */
154         volatile struct scb_struct      *scb;   /* volatile is important */
155         volatile struct tbd_struct      *xmit_buffs[NUM_XMIT_BUFFS];
156         volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];
157 #if (NUM_XMIT_BUFFS == 1)
158         volatile struct nop_cmd_struct *nop_cmds[2];
159 #else
160         volatile struct nop_cmd_struct *nop_cmds[NUM_XMIT_BUFFS];
161 #endif
162         volatile int            nop_point,num_recv_buffs;
163         volatile char           *xmit_cbuffs[NUM_XMIT_BUFFS];
164         volatile int            xmit_count,xmit_last;
165 };
166
167 /**********************************************
168  * close device
169  */
170 static int sun3_82586_close(struct net_device *dev)
171 {
172         free_irq(dev->irq, dev);
173
174         sun3_reset586(); /* the hard way to stop the receiver */
175
176         netif_stop_queue(dev);
177
178         return 0;
179 }
180
181 /**********************************************
182  * open device
183  */
184 static int sun3_82586_open(struct net_device *dev)
185 {
186         int ret;
187
188         sun3_disint();
189         alloc586(dev);
190         init586(dev);
191         startrecv586(dev);
192         sun3_enaint();
193
194         ret = request_irq(dev->irq, &sun3_82586_interrupt,0,dev->name,dev);
195         if (ret)
196         {
197                 sun3_reset586();
198                 return ret;
199         }
200
201         netif_start_queue(dev);
202
203         return 0; /* most done by init */
204 }
205
206 /**********************************************
207  * Check to see if there's an 82586 out there.
208  */
209 static int check586(struct net_device *dev,char *where,unsigned size)
210 {
211         struct priv pb;
212         struct priv *p = /* (struct priv *) dev->priv*/ &pb;
213         char *iscp_addr;
214         int i;
215
216         p->base = (unsigned long) dvma_btov(0);
217         p->memtop = (char *)dvma_btov((unsigned long)where);
218         p->scp = (struct scp_struct *)(p->base + SCP_DEFAULT_ADDRESS);
219         memset((char *)p->scp,0, sizeof(struct scp_struct));
220         for(i=0;i<sizeof(struct scp_struct);i++) /* memory was writeable? */
221                 if(((char *)p->scp)[i])
222                         return 0;
223         p->scp->sysbus = SYSBUSVAL;                             /* 1 = 8Bit-Bus, 0 = 16 Bit */
224         if(p->scp->sysbus != SYSBUSVAL)
225                 return 0;
226
227         iscp_addr = (char *)dvma_btov((unsigned long)where);
228
229         p->iscp = (struct iscp_struct *) iscp_addr;
230         memset((char *)p->iscp,0, sizeof(struct iscp_struct));
231
232         p->scp->iscp = make24(p->iscp);
233         p->iscp->busy = 1;
234
235         sun3_reset586();
236         sun3_attn586();
237         DELAY(1);       /* wait a while... */
238
239         if(p->iscp->busy) /* i82586 clears 'busy' after successful init */
240                 return 0;
241
242         return 1;
243 }
244
245 /******************************************************************
246  * set iscp at the right place, called by sun3_82586_probe1 and open586.
247  */
248 static void alloc586(struct net_device *dev)
249 {
250         struct priv *p =        (struct priv *) dev->priv;
251
252         sun3_reset586();
253         DELAY(1);
254
255         p->scp  = (struct scp_struct *) (p->base + SCP_DEFAULT_ADDRESS);
256         p->iscp = (struct iscp_struct *) dvma_btov(dev->mem_start);
257         p->scb  = (struct scb_struct *)  ((char *)p->iscp + sizeof(struct iscp_struct));
258
259         memset((char *) p->iscp,0,sizeof(struct iscp_struct));
260         memset((char *) p->scp ,0,sizeof(struct scp_struct));
261
262         p->scp->iscp = make24(p->iscp);
263         p->scp->sysbus = SYSBUSVAL;
264         p->iscp->scb_offset = make16(p->scb);
265         p->iscp->scb_base = make24(dvma_btov(dev->mem_start));
266
267         p->iscp->busy = 1;
268         sun3_reset586();
269         sun3_attn586();
270
271         DELAY(1);
272
273         if(p->iscp->busy)
274                 printk("%s: Init-Problems (alloc).\n",dev->name);
275
276         p->reseted = 0;
277
278         memset((char *)p->scb,0,sizeof(struct scb_struct));
279 }
280
281 struct net_device * __init sun3_82586_probe(int unit)
282 {
283         struct net_device *dev;
284         unsigned long ioaddr;
285         static int found = 0;
286         int err = -ENOMEM;
287
288         /* check that this machine has an onboard 82586 */
289         switch(idprom->id_machtype) {
290         case SM_SUN3|SM_3_160:
291         case SM_SUN3|SM_3_260:
292                 /* these machines have 82586 */
293                 break;
294
295         default:
296                 return ERR_PTR(-ENODEV);
297         }
298
299         if (found)
300                 return ERR_PTR(-ENODEV);
301
302         ioaddr = (unsigned long)ioremap(IE_OBIO, SUN3_82586_TOTAL_SIZE);
303         if (!ioaddr)
304                 return ERR_PTR(-ENOMEM);
305         found = 1;
306
307         dev = alloc_etherdev(sizeof(struct priv));
308         if (!dev)
309                 goto out;
310         if (unit >= 0) {
311                 sprintf(dev->name, "eth%d", unit);
312                 netdev_boot_setup_check(dev);
313         }
314
315         dev->irq = IE_IRQ;
316         dev->base_addr = ioaddr;
317         err = sun3_82586_probe1(dev, ioaddr);
318         if (err)
319                 goto out1;
320         err = register_netdev(dev);
321         if (err)
322                 goto out2;
323         return dev;
324
325 out2:
326         release_region(ioaddr, SUN3_82586_TOTAL_SIZE);
327 out1:
328         free_netdev(dev);
329 out:
330         iounmap((void __iomem *)ioaddr);
331         return ERR_PTR(err);
332 }
333
334 static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr)
335 {
336         int i, size, retval;
337
338         if (!request_region(ioaddr, SUN3_82586_TOTAL_SIZE, DRV_NAME))
339                 return -EBUSY;
340
341         /* copy in the ethernet address from the prom */
342         for(i = 0; i < 6 ; i++)
343              dev->dev_addr[i] = idprom->id_ethaddr[i];
344
345         printk("%s: SUN3 Intel 82586 found at %lx, ",dev->name,dev->base_addr);
346
347         /*
348          * check (or search) IO-Memory, 32K
349          */
350         size = 0x8000;
351
352         dev->mem_start = (unsigned long)dvma_malloc_align(0x8000, 0x1000);
353         dev->mem_end = dev->mem_start + size;
354
355         if(size != 0x2000 && size != 0x4000 && size != 0x8000) {
356                 printk("\n%s: Illegal memory size %d. Allowed is 0x2000 or 0x4000 or 0x8000 bytes.\n",dev->name,size);
357                 retval = -ENODEV;
358                 goto out;
359         }
360         if(!check586(dev,(char *) dev->mem_start,size)) {
361                 printk("?memcheck, Can't find memory at 0x%lx with size %d!\n",dev->mem_start,size);
362                 retval = -ENODEV;
363                 goto out;
364         }
365
366         ((struct priv *) (dev->priv))->memtop = (char *)dvma_btov(dev->mem_start);
367         ((struct priv *) (dev->priv))->base = (unsigned long) dvma_btov(0);
368         alloc586(dev);
369
370         /* set number of receive-buffs according to memsize */
371         if(size == 0x2000)
372                 ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_8;
373         else if(size == 0x4000)
374                 ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_16;
375         else
376                 ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_32;
377
378         printk("Memaddr: 0x%lx, Memsize: %d, IRQ %d\n",dev->mem_start,size, dev->irq);
379
380         dev->open               = sun3_82586_open;
381         dev->stop               = sun3_82586_close;
382         dev->get_stats          = sun3_82586_get_stats;
383         dev->tx_timeout         = sun3_82586_timeout;
384         dev->watchdog_timeo     = HZ/20;
385         dev->hard_start_xmit    = sun3_82586_send_packet;
386         dev->set_multicast_list = set_multicast_list;
387
388         dev->if_port            = 0;
389         return 0;
390 out:
391         release_region(ioaddr, SUN3_82586_TOTAL_SIZE);
392         return retval;
393 }
394
395
396 static int init586(struct net_device *dev)
397 {
398         void *ptr;
399         int i,result=0;
400         struct priv *p = (struct priv *) dev->priv;
401         volatile struct configure_cmd_struct    *cfg_cmd;
402         volatile struct iasetup_cmd_struct *ias_cmd;
403         volatile struct tdr_cmd_struct *tdr_cmd;
404         volatile struct mcsetup_cmd_struct *mc_cmd;
405         struct dev_mc_list *dmi=dev->mc_list;
406         int num_addrs=dev->mc_count;
407
408         ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct));
409
410         cfg_cmd = (struct configure_cmd_struct *)ptr; /* configure-command */
411         cfg_cmd->cmd_status     = 0;
412         cfg_cmd->cmd_cmd        = swab16(CMD_CONFIGURE | CMD_LAST);
413         cfg_cmd->cmd_link       = 0xffff;
414
415         cfg_cmd->byte_cnt       = 0x0a; /* number of cfg bytes */
416         cfg_cmd->fifo           = fifo; /* fifo-limit (8=tx:32/rx:64) */
417         cfg_cmd->sav_bf         = 0x40; /* hold or discard bad recv frames (bit 7) */
418         cfg_cmd->adr_len        = 0x2e; /* addr_len |!src_insert |pre-len |loopback */
419         cfg_cmd->priority       = 0x00;
420         cfg_cmd->ifs            = 0x60;
421         cfg_cmd->time_low       = 0x00;
422         cfg_cmd->time_high      = 0xf2;
423         cfg_cmd->promisc        = 0;
424         if(dev->flags & IFF_ALLMULTI) {
425                 int len = ((char *) p->iscp - (char *) ptr - 8) / 6;
426                 if(num_addrs > len)     {
427                         printk("%s: switching to promisc. mode\n",dev->name);
428                         dev->flags|=IFF_PROMISC;
429                 }
430         }
431         if(dev->flags&IFF_PROMISC)
432         {
433                          cfg_cmd->promisc=1;
434                          dev->flags|=IFF_PROMISC;
435         }
436         cfg_cmd->carr_coll      = 0x00;
437
438         p->scb->cbl_offset      = make16(cfg_cmd);
439         p->scb->cmd_ruc         = 0;
440
441         p->scb->cmd_cuc         = CUC_START; /* cmd.-unit start */
442         sun3_attn586();
443
444         WAIT_4_STAT_COMPL(cfg_cmd);
445
446         if((swab16(cfg_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_COMPL|STAT_OK))
447         {
448                 printk("%s: configure command failed: %x\n",dev->name,swab16(cfg_cmd->cmd_status));
449                 return 1;
450         }
451
452         /*
453          * individual address setup
454          */
455
456         ias_cmd = (struct iasetup_cmd_struct *)ptr;
457
458         ias_cmd->cmd_status     = 0;
459         ias_cmd->cmd_cmd        = swab16(CMD_IASETUP | CMD_LAST);
460         ias_cmd->cmd_link       = 0xffff;
461
462         memcpy((char *)&ias_cmd->iaddr,(char *) dev->dev_addr,ETH_ALEN);
463
464         p->scb->cbl_offset = make16(ias_cmd);
465
466         p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
467         sun3_attn586();
468
469         WAIT_4_STAT_COMPL(ias_cmd);
470
471         if((swab16(ias_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_OK|STAT_COMPL)) {
472                 printk("%s (82586): individual address setup command failed: %04x\n",dev->name,swab16(ias_cmd->cmd_status));
473                 return 1;
474         }
475
476         /*
477          * TDR, wire check .. e.g. no resistor e.t.c
478          */
479
480         tdr_cmd = (struct tdr_cmd_struct *)ptr;
481
482         tdr_cmd->cmd_status     = 0;
483         tdr_cmd->cmd_cmd        = swab16(CMD_TDR | CMD_LAST);
484         tdr_cmd->cmd_link       = 0xffff;
485         tdr_cmd->status         = 0;
486
487         p->scb->cbl_offset = make16(tdr_cmd);
488         p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
489         sun3_attn586();
490
491         WAIT_4_STAT_COMPL(tdr_cmd);
492
493         if(!(swab16(tdr_cmd->cmd_status) & STAT_COMPL))
494         {
495                 printk("%s: Problems while running the TDR.\n",dev->name);
496         }
497         else
498         {
499                 DELAY_16(); /* wait for result */
500                 result = swab16(tdr_cmd->status);
501
502                 p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
503                 sun3_attn586(); /* ack the interrupts */
504
505                 if(result & TDR_LNK_OK)
506                         ;
507                 else if(result & TDR_XCVR_PRB)
508                         printk("%s: TDR: Transceiver problem. Check the cable(s)!\n",dev->name);
509                 else if(result & TDR_ET_OPN)
510                         printk("%s: TDR: No correct termination %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
511                 else if(result & TDR_ET_SRT)
512                 {
513                         if (result & TDR_TIMEMASK) /* time == 0 -> strange :-) */
514                                 printk("%s: TDR: Detected a short circuit %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
515                 }
516                 else
517                         printk("%s: TDR: Unknown status %04x\n",dev->name,result);
518         }
519
520         /*
521          * Multicast setup
522          */
523         if(num_addrs && !(dev->flags & IFF_PROMISC) )
524         {
525                 mc_cmd = (struct mcsetup_cmd_struct *) ptr;
526                 mc_cmd->cmd_status = 0;
527                 mc_cmd->cmd_cmd = swab16(CMD_MCSETUP | CMD_LAST);
528                 mc_cmd->cmd_link = 0xffff;
529                 mc_cmd->mc_cnt = swab16(num_addrs * 6);
530
531                 for(i=0;i<num_addrs;i++,dmi=dmi->next)
532                         memcpy((char *) mc_cmd->mc_list[i], dmi->dmi_addr,6);
533
534                 p->scb->cbl_offset = make16(mc_cmd);
535                 p->scb->cmd_cuc = CUC_START;
536                 sun3_attn586();
537
538                 WAIT_4_STAT_COMPL(mc_cmd);
539
540                 if( (swab16(mc_cmd->cmd_status) & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
541                         printk("%s: Can't apply multicast-address-list.\n",dev->name);
542         }
543
544         /*
545          * alloc nop/xmit-cmds
546          */
547 #if (NUM_XMIT_BUFFS == 1)
548         for(i=0;i<2;i++)
549         {
550                 p->nop_cmds[i]                  = (struct nop_cmd_struct *)ptr;
551                 p->nop_cmds[i]->cmd_cmd         = swab16(CMD_NOP);
552                 p->nop_cmds[i]->cmd_status      = 0;
553                 p->nop_cmds[i]->cmd_link        = make16((p->nop_cmds[i]));
554                 ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
555         }
556 #else
557         for(i=0;i<NUM_XMIT_BUFFS;i++)
558         {
559                 p->nop_cmds[i]                  = (struct nop_cmd_struct *)ptr;
560                 p->nop_cmds[i]->cmd_cmd         = swab16(CMD_NOP);
561                 p->nop_cmds[i]->cmd_status      = 0;
562                 p->nop_cmds[i]->cmd_link        = make16((p->nop_cmds[i]));
563                 ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
564         }
565 #endif
566
567         ptr = alloc_rfa(dev,(void *)ptr); /* init receive-frame-area */
568
569         /*
570          * alloc xmit-buffs / init xmit_cmds
571          */
572         for(i=0;i<NUM_XMIT_BUFFS;i++)
573         {
574                 p->xmit_cmds[i] = (struct transmit_cmd_struct *)ptr; /*transmit cmd/buff 0*/
575                 ptr = (char *) ptr + sizeof(struct transmit_cmd_struct);
576                 p->xmit_cbuffs[i] = (char *)ptr; /* char-buffs */
577                 ptr = (char *) ptr + XMIT_BUFF_SIZE;
578                 p->xmit_buffs[i] = (struct tbd_struct *)ptr; /* TBD */
579                 ptr = (char *) ptr + sizeof(struct tbd_struct);
580                 if((void *)ptr > (void *)dev->mem_end)
581                 {
582                         printk("%s: not enough shared-mem for your configuration!\n",dev->name);
583                         return 1;
584                 }
585                 memset((char *)(p->xmit_cmds[i]) ,0, sizeof(struct transmit_cmd_struct));
586                 memset((char *)(p->xmit_buffs[i]),0, sizeof(struct tbd_struct));
587                 p->xmit_cmds[i]->cmd_link = make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]);
588                 p->xmit_cmds[i]->cmd_status = swab16(STAT_COMPL);
589                 p->xmit_cmds[i]->cmd_cmd = swab16(CMD_XMIT | CMD_INT);
590                 p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i]));
591                 p->xmit_buffs[i]->next = 0xffff;
592                 p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i]));
593         }
594
595         p->xmit_count = 0;
596         p->xmit_last    = 0;
597 #ifndef NO_NOPCOMMANDS
598         p->nop_point    = 0;
599 #endif
600
601          /*
602                 * 'start transmitter'
603                 */
604 #ifndef NO_NOPCOMMANDS
605         p->scb->cbl_offset = make16(p->nop_cmds[0]);
606         p->scb->cmd_cuc = CUC_START;
607         sun3_attn586();
608         WAIT_4_SCB_CMD();
609 #else
610         p->xmit_cmds[0]->cmd_link = make16(p->xmit_cmds[0]);
611         p->xmit_cmds[0]->cmd_cmd        = swab16(CMD_XMIT | CMD_SUSPEND | CMD_INT);
612 #endif
613
614         /*
615          * ack. interrupts
616          */
617         p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
618         sun3_attn586();
619         DELAY_16();
620
621         sun3_enaint();
622         sun3_active();
623
624         return 0;
625 }
626
627 /******************************************************
628  * This is a helper routine for sun3_82586_rnr_int() and init586().
629  * It sets up the Receive Frame Area (RFA).
630  */
631
632 static void *alloc_rfa(struct net_device *dev,void *ptr)
633 {
634         volatile struct rfd_struct *rfd = (struct rfd_struct *)ptr;
635         volatile struct rbd_struct *rbd;
636         int i;
637         struct priv *p = (struct priv *) dev->priv;
638
639         memset((char *) rfd,0,sizeof(struct rfd_struct)*(p->num_recv_buffs+rfdadd));
640         p->rfd_first = rfd;
641
642         for(i = 0; i < (p->num_recv_buffs+rfdadd); i++) {
643                 rfd[i].next = make16(rfd + (i+1) % (p->num_recv_buffs+rfdadd) );
644                 rfd[i].rbd_offset = 0xffff;
645         }
646         rfd[p->num_recv_buffs-1+rfdadd].last = RFD_SUSP;         /* RU suspend */
647
648         ptr = (void *) (rfd + (p->num_recv_buffs + rfdadd) );
649
650         rbd = (struct rbd_struct *) ptr;
651         ptr = (void *) (rbd + p->num_recv_buffs);
652
653          /* clr descriptors */
654         memset((char *) rbd,0,sizeof(struct rbd_struct)*(p->num_recv_buffs));
655
656         for(i=0;i<p->num_recv_buffs;i++)
657         {
658                 rbd[i].next = make16((rbd + (i+1) % p->num_recv_buffs));
659                 rbd[i].size = swab16(RECV_BUFF_SIZE);
660                 rbd[i].buffer = make24(ptr);
661                 ptr = (char *) ptr + RECV_BUFF_SIZE;
662         }
663
664         p->rfd_top      = p->rfd_first;
665         p->rfd_last = p->rfd_first + (p->num_recv_buffs - 1 + rfdadd);
666
667         p->scb->rfa_offset              = make16(p->rfd_first);
668         p->rfd_first->rbd_offset        = make16(rbd);
669
670         return ptr;
671 }
672
673
674 /**************************************************
675  * Interrupt Handler ...
676  */
677
678 static irqreturn_t sun3_82586_interrupt(int irq,void *dev_id)
679 {
680         struct net_device *dev = dev_id;
681         unsigned short stat;
682         int cnt=0;
683         struct priv *p;
684
685         if (!dev) {
686                 printk ("sun3_82586-interrupt: irq %d for unknown device.\n",irq);
687                 return IRQ_NONE;
688         }
689         p = (struct priv *) dev->priv;
690
691         if(debuglevel > 1)
692                 printk("I");
693
694         WAIT_4_SCB_CMD(); /* wait for last command      */
695
696         while((stat=p->scb->cus & STAT_MASK))
697         {
698                 p->scb->cmd_cuc = stat;
699                 sun3_attn586();
700
701                 if(stat & STAT_FR)       /* received a frame */
702                         sun3_82586_rcv_int(dev);
703
704                 if(stat & STAT_RNR) /* RU went 'not ready' */
705                 {
706                         printk("(R)");
707                         if(p->scb->rus & RU_SUSPEND) /* special case: RU_SUSPEND */
708                         {
709                                 WAIT_4_SCB_CMD();
710                                 p->scb->cmd_ruc = RUC_RESUME;
711                                 sun3_attn586();
712                                 WAIT_4_SCB_CMD_RUC();
713                         }
714                         else
715                         {
716                                 printk("%s: Receiver-Unit went 'NOT READY': %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->rus);
717                                 sun3_82586_rnr_int(dev);
718                         }
719                 }
720
721                 if(stat & STAT_CX)              /* command with I-bit set complete */
722                          sun3_82586_xmt_int(dev);
723
724 #ifndef NO_NOPCOMMANDS
725                 if(stat & STAT_CNA)     /* CU went 'not ready' */
726                 {
727                         if(netif_running(dev))
728                                 printk("%s: oops! CU has left active state. stat: %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->cus);
729                 }
730 #endif
731
732                 if(debuglevel > 1)
733                         printk("%d",cnt++);
734
735                 WAIT_4_SCB_CMD(); /* wait for ack. (sun3_82586_xmt_int can be faster than ack!!) */
736                 if(p->scb->cmd_cuc)      /* timed out? */
737                 {
738                         printk("%s: Acknowledge timed out.\n",dev->name);
739                         sun3_disint();
740                         break;
741                 }
742         }
743
744         if(debuglevel > 1)
745                 printk("i");
746         return IRQ_HANDLED;
747 }
748
749 /*******************************************************
750  * receive-interrupt
751  */
752
753 static void sun3_82586_rcv_int(struct net_device *dev)
754 {
755         int status,cnt=0;
756         unsigned short totlen;
757         struct sk_buff *skb;
758         struct rbd_struct *rbd;
759         struct priv *p = (struct priv *) dev->priv;
760
761         if(debuglevel > 0)
762                 printk("R");
763
764         for(;(status = p->rfd_top->stat_high) & RFD_COMPL;)
765         {
766                         rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset);
767
768                         if(status & RFD_OK) /* frame received without error? */
769                         {
770                                 if( (totlen = swab16(rbd->status)) & RBD_LAST) /* the first and the last buffer? */
771                                 {
772                                         totlen &= RBD_MASK; /* length of this frame */
773                                         rbd->status = 0;
774                                         skb = (struct sk_buff *) dev_alloc_skb(totlen+2);
775                                         if(skb != NULL)
776                                         {
777                                                 skb_reserve(skb,2);
778                                                 skb_put(skb,totlen);
779                                                 skb_copy_to_linear_data(skb,(char *) p->base+swab32((unsigned long) rbd->buffer),totlen);
780                                                 skb->protocol=eth_type_trans(skb,dev);
781                                                 netif_rx(skb);
782                                                 p->stats.rx_packets++;
783                                         }
784                                         else
785                                                 p->stats.rx_dropped++;
786                                 }
787                                 else
788                                 {
789                                         int rstat;
790                                                  /* free all RBD's until RBD_LAST is set */
791                                         totlen = 0;
792                                         while(!((rstat=swab16(rbd->status)) & RBD_LAST))
793                                         {
794                                                 totlen += rstat & RBD_MASK;
795                                                 if(!rstat)
796                                                 {
797                                                         printk("%s: Whoops .. no end mark in RBD list\n",dev->name);
798                                                         break;
799                                                 }
800                                                 rbd->status = 0;
801                                                 rbd = (struct rbd_struct *) make32(rbd->next);
802                                         }
803                                         totlen += rstat & RBD_MASK;
804                                         rbd->status = 0;
805                                         printk("%s: received oversized frame! length: %d\n",dev->name,totlen);
806                                         p->stats.rx_dropped++;
807                          }
808                 }
809                 else /* frame !(ok), only with 'save-bad-frames' */
810                 {
811                         printk("%s: oops! rfd-error-status: %04x\n",dev->name,status);
812                         p->stats.rx_errors++;
813                 }
814                 p->rfd_top->stat_high = 0;
815                 p->rfd_top->last = RFD_SUSP; /* maybe exchange by RFD_LAST */
816                 p->rfd_top->rbd_offset = 0xffff;
817                 p->rfd_last->last = 0;                          /* delete RFD_SUSP      */
818                 p->rfd_last = p->rfd_top;
819                 p->rfd_top = (struct rfd_struct *) make32(p->rfd_top->next); /* step to next RFD */
820                 p->scb->rfa_offset = make16(p->rfd_top);
821
822                 if(debuglevel > 0)
823                         printk("%d",cnt++);
824         }
825
826         if(automatic_resume)
827         {
828                 WAIT_4_SCB_CMD();
829                 p->scb->cmd_ruc = RUC_RESUME;
830                 sun3_attn586();
831                 WAIT_4_SCB_CMD_RUC();
832         }
833
834 #ifdef WAIT_4_BUSY
835         {
836                 int i;
837                 for(i=0;i<1024;i++)
838                 {
839                         if(p->rfd_top->status)
840                                 break;
841                         DELAY_16();
842                         if(i == 1023)
843                                 printk("%s: RU hasn't fetched next RFD (not busy/complete)\n",dev->name);
844                 }
845         }
846 #endif
847
848 #if 0
849         if(!at_least_one)
850         {
851                 int i;
852                 volatile struct rfd_struct *rfds=p->rfd_top;
853                 volatile struct rbd_struct *rbds;
854                 printk("%s: received a FC intr. without having a frame: %04x %d\n",dev->name,status,old_at_least);
855                 for(i=0;i< (p->num_recv_buffs+4);i++)
856                 {
857                         rbds = (struct rbd_struct *) make32(rfds->rbd_offset);
858                         printk("%04x:%04x ",rfds->status,rbds->status);
859                         rfds = (struct rfd_struct *) make32(rfds->next);
860                 }
861                 printk("\nerrs: %04x %04x stat: %04x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->status);
862                 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);
863         }
864         old_at_least = at_least_one;
865 #endif
866
867         if(debuglevel > 0)
868                 printk("r");
869 }
870
871 /**********************************************************
872  * handle 'Receiver went not ready'.
873  */
874
875 static void sun3_82586_rnr_int(struct net_device *dev)
876 {
877         struct priv *p = (struct priv *) dev->priv;
878
879         p->stats.rx_errors++;
880
881         WAIT_4_SCB_CMD();               /* wait for the last cmd, WAIT_4_FULLSTAT?? */
882         p->scb->cmd_ruc = RUC_ABORT; /* usually the RU is in the 'no resource'-state .. abort it now. */
883         sun3_attn586();
884         WAIT_4_SCB_CMD_RUC();           /* wait for accept cmd. */
885
886         alloc_rfa(dev,(char *)p->rfd_first);
887 /* maybe add a check here, before restarting the RU */
888         startrecv586(dev); /* restart RU */
889
890         printk("%s: Receive-Unit restarted. Status: %04x\n",dev->name,p->scb->rus);
891
892 }
893
894 /**********************************************************
895  * handle xmit - interrupt
896  */
897
898 static void sun3_82586_xmt_int(struct net_device *dev)
899 {
900         int status;
901         struct priv *p = (struct priv *) dev->priv;
902
903         if(debuglevel > 0)
904                 printk("X");
905
906         status = swab16(p->xmit_cmds[p->xmit_last]->cmd_status);
907         if(!(status & STAT_COMPL))
908                 printk("%s: strange .. xmit-int without a 'COMPLETE'\n",dev->name);
909
910         if(status & STAT_OK)
911         {
912                 p->stats.tx_packets++;
913                 p->stats.collisions += (status & TCMD_MAXCOLLMASK);
914         }
915         else
916         {
917                 p->stats.tx_errors++;
918                 if(status & TCMD_LATECOLL) {
919                         printk("%s: late collision detected.\n",dev->name);
920                         p->stats.collisions++;
921                 }
922                 else if(status & TCMD_NOCARRIER) {
923                         p->stats.tx_carrier_errors++;
924                         printk("%s: no carrier detected.\n",dev->name);
925                 }
926                 else if(status & TCMD_LOSTCTS)
927                         printk("%s: loss of CTS detected.\n",dev->name);
928                 else if(status & TCMD_UNDERRUN) {
929                         p->stats.tx_fifo_errors++;
930                         printk("%s: DMA underrun detected.\n",dev->name);
931                 }
932                 else if(status & TCMD_MAXCOLL) {
933                         printk("%s: Max. collisions exceeded.\n",dev->name);
934                         p->stats.collisions += 16;
935                 }
936         }
937
938 #if (NUM_XMIT_BUFFS > 1)
939         if( (++p->xmit_last) == NUM_XMIT_BUFFS)
940                 p->xmit_last = 0;
941 #endif
942         netif_wake_queue(dev);
943 }
944
945 /***********************************************************
946  * (re)start the receiver
947  */
948
949 static void startrecv586(struct net_device *dev)
950 {
951         struct priv *p = (struct priv *) dev->priv;
952
953         WAIT_4_SCB_CMD();
954         WAIT_4_SCB_CMD_RUC();
955         p->scb->rfa_offset = make16(p->rfd_first);
956         p->scb->cmd_ruc = RUC_START;
957         sun3_attn586();         /* start cmd. */
958         WAIT_4_SCB_CMD_RUC();   /* wait for accept cmd. (no timeout!!) */
959 }
960
961 static void sun3_82586_timeout(struct net_device *dev)
962 {
963         struct priv *p = (struct priv *) dev->priv;
964 #ifndef NO_NOPCOMMANDS
965         if(p->scb->cus & CU_ACTIVE) /* COMMAND-UNIT active? */
966         {
967                 netif_wake_queue(dev);
968 #ifdef DEBUG
969                 printk("%s: strange ... timeout with CU active?!?\n",dev->name);
970                 printk("%s: X0: %04x N0: %04x N1: %04x %d\n",dev->name,(int)swab16(p->xmit_cmds[0]->cmd_status),(int)swab16(p->nop_cmds[0]->cmd_status),(int)swab16(p->nop_cmds[1]->cmd_status),(int)p->nop_point);
971 #endif
972                 p->scb->cmd_cuc = CUC_ABORT;
973                 sun3_attn586();
974                 WAIT_4_SCB_CMD();
975                 p->scb->cbl_offset = make16(p->nop_cmds[p->nop_point]);
976                 p->scb->cmd_cuc = CUC_START;
977                 sun3_attn586();
978                 WAIT_4_SCB_CMD();
979                 dev->trans_start = jiffies;
980                 return 0;
981         }
982 #endif
983         {
984 #ifdef DEBUG
985                 printk("%s: xmitter timed out, try to restart! stat: %02x\n",dev->name,p->scb->cus);
986                 printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
987                 printk("%s: check, whether you set the right interrupt number!\n",dev->name);
988 #endif
989                 sun3_82586_close(dev);
990                 sun3_82586_open(dev);
991         }
992         dev->trans_start = jiffies;
993 }
994
995 /******************************************************
996  * send frame
997  */
998
999 static int sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
1000 {
1001         int len,i;
1002 #ifndef NO_NOPCOMMANDS
1003         int next_nop;
1004 #endif
1005         struct priv *p = (struct priv *) dev->priv;
1006
1007         if(skb->len > XMIT_BUFF_SIZE)
1008         {
1009                 printk("%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n",dev->name,XMIT_BUFF_SIZE,skb->len);
1010                 return 0;
1011         }
1012
1013         netif_stop_queue(dev);
1014
1015 #if(NUM_XMIT_BUFFS > 1)
1016         if(test_and_set_bit(0,(void *) &p->lock)) {
1017                 printk("%s: Queue was locked\n",dev->name);
1018                 return 1;
1019         }
1020         else
1021 #endif
1022         {
1023                 len = skb->len;
1024                 if (len < ETH_ZLEN) {
1025                         memset((void *)p->xmit_cbuffs[p->xmit_count], 0,
1026                                ETH_ZLEN);
1027                         len = ETH_ZLEN;
1028                 }
1029                 skb_copy_from_linear_data(skb, (void *)p->xmit_cbuffs[p->xmit_count], skb->len);
1030
1031 #if (NUM_XMIT_BUFFS == 1)
1032 #       ifdef NO_NOPCOMMANDS
1033
1034 #ifdef DEBUG
1035                 if(p->scb->cus & CU_ACTIVE)
1036                 {
1037                         printk("%s: Hmmm .. CU is still running and we wanna send a new packet.\n",dev->name);
1038                         printk("%s: stat: %04x %04x\n",dev->name,p->scb->cus,swab16(p->xmit_cmds[0]->cmd_status));
1039                 }
1040 #endif
1041
1042                 p->xmit_buffs[0]->size = swab16(TBD_LAST | len);
1043                 for(i=0;i<16;i++)
1044                 {
1045                         p->xmit_cmds[0]->cmd_status = 0;
1046                         WAIT_4_SCB_CMD();
1047                         if( (p->scb->cus & CU_STATUS) == CU_SUSPEND)
1048                                 p->scb->cmd_cuc = CUC_RESUME;
1049                         else
1050                         {
1051                                 p->scb->cbl_offset = make16(p->xmit_cmds[0]);
1052                                 p->scb->cmd_cuc = CUC_START;
1053                         }
1054
1055                         sun3_attn586();
1056                         dev->trans_start = jiffies;
1057                         if(!i)
1058                                 dev_kfree_skb(skb);
1059                         WAIT_4_SCB_CMD();
1060                         if( (p->scb->cus & CU_ACTIVE)) /* test it, because CU sometimes doesn't start immediately */
1061                                 break;
1062                         if(p->xmit_cmds[0]->cmd_status)
1063                                 break;
1064                         if(i==15)
1065                                 printk("%s: Can't start transmit-command.\n",dev->name);
1066                 }
1067 #       else
1068                 next_nop = (p->nop_point + 1) & 0x1;
1069                 p->xmit_buffs[0]->size = swab16(TBD_LAST | len);
1070
1071                 p->xmit_cmds[0]->cmd_link        = p->nop_cmds[next_nop]->cmd_link
1072                         = make16((p->nop_cmds[next_nop]));
1073                 p->xmit_cmds[0]->cmd_status = p->nop_cmds[next_nop]->cmd_status = 0;
1074
1075                 p->nop_cmds[p->nop_point]->cmd_link = make16((p->xmit_cmds[0]));
1076                 dev->trans_start = jiffies;
1077                 p->nop_point = next_nop;
1078                 dev_kfree_skb(skb);
1079 #       endif
1080 #else
1081                 p->xmit_buffs[p->xmit_count]->size = swab16(TBD_LAST | len);
1082                 if( (next_nop = p->xmit_count + 1) == NUM_XMIT_BUFFS )
1083                         next_nop = 0;
1084
1085                 p->xmit_cmds[p->xmit_count]->cmd_status = 0;
1086                 /* linkpointer of xmit-command already points to next nop cmd */
1087                 p->nop_cmds[next_nop]->cmd_link = make16((p->nop_cmds[next_nop]));
1088                 p->nop_cmds[next_nop]->cmd_status = 0;
1089
1090                 p->nop_cmds[p->xmit_count]->cmd_link = make16((p->xmit_cmds[p->xmit_count]));
1091                 dev->trans_start = jiffies;
1092                 p->xmit_count = next_nop;
1093
1094                 {
1095                         unsigned long flags;
1096                         local_irq_save(flags);
1097                         if(p->xmit_count != p->xmit_last)
1098                                 netif_wake_queue(dev);
1099                         p->lock = 0;
1100                         local_irq_restore(flags);
1101                 }
1102                 dev_kfree_skb(skb);
1103 #endif
1104         }
1105         return 0;
1106 }
1107
1108 /*******************************************
1109  * Someone wanna have the statistics
1110  */
1111
1112 static struct net_device_stats *sun3_82586_get_stats(struct net_device *dev)
1113 {
1114         struct priv *p = (struct priv *) dev->priv;
1115         unsigned short crc,aln,rsc,ovrn;
1116
1117         crc = swab16(p->scb->crc_errs); /* get error-statistic from the ni82586 */
1118         p->scb->crc_errs = 0;
1119         aln = swab16(p->scb->aln_errs);
1120         p->scb->aln_errs = 0;
1121         rsc = swab16(p->scb->rsc_errs);
1122         p->scb->rsc_errs = 0;
1123         ovrn = swab16(p->scb->ovrn_errs);
1124         p->scb->ovrn_errs = 0;
1125
1126         p->stats.rx_crc_errors += crc;
1127         p->stats.rx_fifo_errors += ovrn;
1128         p->stats.rx_frame_errors += aln;
1129         p->stats.rx_dropped += rsc;
1130
1131         return &p->stats;
1132 }
1133
1134 /********************************************************
1135  * Set MC list ..
1136  */
1137
1138 static void set_multicast_list(struct net_device *dev)
1139 {
1140         netif_stop_queue(dev);
1141         sun3_disint();
1142         alloc586(dev);
1143         init586(dev);
1144         startrecv586(dev);
1145         sun3_enaint();
1146         netif_wake_queue(dev);
1147 }
1148
1149 #ifdef MODULE
1150 #error This code is not currently supported as a module
1151 static struct net_device *dev_sun3_82586;
1152
1153 int init_module(void)
1154 {
1155         dev_sun3_82586 = sun3_82586_probe(-1);
1156         if (IS_ERR(dev_sun3_82586))
1157                 return PTR_ERR(dev_sun3_82586);
1158         return 0;
1159 }
1160
1161 void cleanup_module(void)
1162 {
1163         unsigned long ioaddr = dev_sun3_82586->base_addr;
1164         unregister_netdev(dev_sun3_82586);
1165         release_region(ioaddr, SUN3_82586_TOTAL_SIZE);
1166         iounmap((void *)ioaddr);
1167         free_netdev(dev_sun3_82586);
1168 }
1169 #endif /* MODULE */
1170
1171 #if 0
1172 /*
1173  * DUMP .. we expect a not running CMD unit and enough space
1174  */
1175 void sun3_82586_dump(struct net_device *dev,void *ptr)
1176 {
1177         struct priv *p = (struct priv *) dev->priv;
1178         struct dump_cmd_struct *dump_cmd = (struct dump_cmd_struct *) ptr;
1179         int i;
1180
1181         p->scb->cmd_cuc = CUC_ABORT;
1182         sun3_attn586();
1183         WAIT_4_SCB_CMD();
1184         WAIT_4_SCB_CMD_RUC();
1185
1186         dump_cmd->cmd_status = 0;
1187         dump_cmd->cmd_cmd = CMD_DUMP | CMD_LAST;
1188         dump_cmd->dump_offset = make16((dump_cmd + 1));
1189         dump_cmd->cmd_link = 0xffff;
1190
1191         p->scb->cbl_offset = make16(dump_cmd);
1192         p->scb->cmd_cuc = CUC_START;
1193         sun3_attn586();
1194         WAIT_4_STAT_COMPL(dump_cmd);
1195
1196         if( (dump_cmd->cmd_status & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
1197                                 printk("%s: Can't get dump information.\n",dev->name);
1198
1199         for(i=0;i<170;i++) {
1200                 printk("%02x ",(int) ((unsigned char *) (dump_cmd + 1))[i]);
1201                 if(i % 24 == 23)
1202                         printk("\n");
1203         }
1204         printk("\n");
1205 }
1206 #endif
1207
1208 MODULE_LICENSE("GPL");