2f6a760e5f21b5f5c68594ec4007d39fae0b81a0
[linux-2.6.git] / 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 = &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 = netdev_priv(dev);
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 const struct net_device_ops sun3_82586_netdev_ops = {
335         .ndo_open               = sun3_82586_open,
336         .ndo_stop               = sun3_82586_close,
337         .ndo_start_xmit         = sun3_82586_send_packet,
338         .ndo_set_multicast_list = set_multicast_list,
339         .ndo_tx_timeout         = sun3_82586_timeout,
340         .ndo_get_stats          = sun3_82586_get_stats,
341         .ndo_validate_addr      = eth_validate_addr,
342         .ndo_set_mac_address    = eth_mac_addr,
343         .ndo_change_mtu         = eth_change_mtu,
344 };
345
346 static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr)
347 {
348         int i, size, retval;
349
350         if (!request_region(ioaddr, SUN3_82586_TOTAL_SIZE, DRV_NAME))
351                 return -EBUSY;
352
353         /* copy in the ethernet address from the prom */
354         for(i = 0; i < 6 ; i++)
355              dev->dev_addr[i] = idprom->id_ethaddr[i];
356
357         printk("%s: SUN3 Intel 82586 found at %lx, ",dev->name,dev->base_addr);
358
359         /*
360          * check (or search) IO-Memory, 32K
361          */
362         size = 0x8000;
363
364         dev->mem_start = (unsigned long)dvma_malloc_align(0x8000, 0x1000);
365         dev->mem_end = dev->mem_start + size;
366
367         if(size != 0x2000 && size != 0x4000 && size != 0x8000) {
368                 printk("\n%s: Illegal memory size %d. Allowed is 0x2000 or 0x4000 or 0x8000 bytes.\n",dev->name,size);
369                 retval = -ENODEV;
370                 goto out;
371         }
372         if(!check586(dev,(char *) dev->mem_start,size)) {
373                 printk("?memcheck, Can't find memory at 0x%lx with size %d!\n",dev->mem_start,size);
374                 retval = -ENODEV;
375                 goto out;
376         }
377
378         ((struct priv *)netdev_priv(dev))->memtop =
379                                         (char *)dvma_btov(dev->mem_start);
380         ((struct priv *)netdev_priv(dev))->base = (unsigned long) dvma_btov(0);
381         alloc586(dev);
382
383         /* set number of receive-buffs according to memsize */
384         if(size == 0x2000)
385                 ((struct priv *)netdev_priv(dev))->num_recv_buffs =
386                                                         NUM_RECV_BUFFS_8;
387         else if(size == 0x4000)
388                 ((struct priv *)netdev_priv(dev))->num_recv_buffs =
389                                                         NUM_RECV_BUFFS_16;
390         else
391                 ((struct priv *)netdev_priv(dev))->num_recv_buffs =
392                                                         NUM_RECV_BUFFS_32;
393
394         printk("Memaddr: 0x%lx, Memsize: %d, IRQ %d\n",dev->mem_start,size, dev->irq);
395
396         dev->netdev_ops         = &sun3_82586_netdev_ops;
397         dev->watchdog_timeo     = HZ/20;
398
399         dev->if_port            = 0;
400         return 0;
401 out:
402         release_region(ioaddr, SUN3_82586_TOTAL_SIZE);
403         return retval;
404 }
405
406
407 static int init586(struct net_device *dev)
408 {
409         void *ptr;
410         int i,result=0;
411         struct priv *p = netdev_priv(dev);
412         volatile struct configure_cmd_struct    *cfg_cmd;
413         volatile struct iasetup_cmd_struct *ias_cmd;
414         volatile struct tdr_cmd_struct *tdr_cmd;
415         volatile struct mcsetup_cmd_struct *mc_cmd;
416         struct dev_mc_list *dmi;
417         int num_addrs=netdev_mc_count(dev);
418
419         ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct));
420
421         cfg_cmd = (struct configure_cmd_struct *)ptr; /* configure-command */
422         cfg_cmd->cmd_status     = 0;
423         cfg_cmd->cmd_cmd        = swab16(CMD_CONFIGURE | CMD_LAST);
424         cfg_cmd->cmd_link       = 0xffff;
425
426         cfg_cmd->byte_cnt       = 0x0a; /* number of cfg bytes */
427         cfg_cmd->fifo           = fifo; /* fifo-limit (8=tx:32/rx:64) */
428         cfg_cmd->sav_bf         = 0x40; /* hold or discard bad recv frames (bit 7) */
429         cfg_cmd->adr_len        = 0x2e; /* addr_len |!src_insert |pre-len |loopback */
430         cfg_cmd->priority       = 0x00;
431         cfg_cmd->ifs            = 0x60;
432         cfg_cmd->time_low       = 0x00;
433         cfg_cmd->time_high      = 0xf2;
434         cfg_cmd->promisc        = 0;
435         if(dev->flags & IFF_ALLMULTI) {
436                 int len = ((char *) p->iscp - (char *) ptr - 8) / 6;
437                 if(num_addrs > len)     {
438                         printk("%s: switching to promisc. mode\n",dev->name);
439                         cfg_cmd->promisc = 1;
440                 }
441         }
442         if(dev->flags&IFF_PROMISC)
443                 cfg_cmd->promisc = 1;
444         cfg_cmd->carr_coll      = 0x00;
445
446         p->scb->cbl_offset      = make16(cfg_cmd);
447         p->scb->cmd_ruc         = 0;
448
449         p->scb->cmd_cuc         = CUC_START; /* cmd.-unit start */
450         sun3_attn586();
451
452         WAIT_4_STAT_COMPL(cfg_cmd);
453
454         if((swab16(cfg_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_COMPL|STAT_OK))
455         {
456                 printk("%s: configure command failed: %x\n",dev->name,swab16(cfg_cmd->cmd_status));
457                 return 1;
458         }
459
460         /*
461          * individual address setup
462          */
463
464         ias_cmd = (struct iasetup_cmd_struct *)ptr;
465
466         ias_cmd->cmd_status     = 0;
467         ias_cmd->cmd_cmd        = swab16(CMD_IASETUP | CMD_LAST);
468         ias_cmd->cmd_link       = 0xffff;
469
470         memcpy((char *)&ias_cmd->iaddr,(char *) dev->dev_addr,ETH_ALEN);
471
472         p->scb->cbl_offset = make16(ias_cmd);
473
474         p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
475         sun3_attn586();
476
477         WAIT_4_STAT_COMPL(ias_cmd);
478
479         if((swab16(ias_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_OK|STAT_COMPL)) {
480                 printk("%s (82586): individual address setup command failed: %04x\n",dev->name,swab16(ias_cmd->cmd_status));
481                 return 1;
482         }
483
484         /*
485          * TDR, wire check .. e.g. no resistor e.t.c
486          */
487
488         tdr_cmd = (struct tdr_cmd_struct *)ptr;
489
490         tdr_cmd->cmd_status     = 0;
491         tdr_cmd->cmd_cmd        = swab16(CMD_TDR | CMD_LAST);
492         tdr_cmd->cmd_link       = 0xffff;
493         tdr_cmd->status         = 0;
494
495         p->scb->cbl_offset = make16(tdr_cmd);
496         p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
497         sun3_attn586();
498
499         WAIT_4_STAT_COMPL(tdr_cmd);
500
501         if(!(swab16(tdr_cmd->cmd_status) & STAT_COMPL))
502         {
503                 printk("%s: Problems while running the TDR.\n",dev->name);
504         }
505         else
506         {
507                 DELAY_16(); /* wait for result */
508                 result = swab16(tdr_cmd->status);
509
510                 p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
511                 sun3_attn586(); /* ack the interrupts */
512
513                 if(result & TDR_LNK_OK)
514                         ;
515                 else if(result & TDR_XCVR_PRB)
516                         printk("%s: TDR: Transceiver problem. Check the cable(s)!\n",dev->name);
517                 else if(result & TDR_ET_OPN)
518                         printk("%s: TDR: No correct termination %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
519                 else if(result & TDR_ET_SRT)
520                 {
521                         if (result & TDR_TIMEMASK) /* time == 0 -> strange :-) */
522                                 printk("%s: TDR: Detected a short circuit %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
523                 }
524                 else
525                         printk("%s: TDR: Unknown status %04x\n",dev->name,result);
526         }
527
528         /*
529          * Multicast setup
530          */
531         if(num_addrs && !(dev->flags & IFF_PROMISC) )
532         {
533                 mc_cmd = (struct mcsetup_cmd_struct *) ptr;
534                 mc_cmd->cmd_status = 0;
535                 mc_cmd->cmd_cmd = swab16(CMD_MCSETUP | CMD_LAST);
536                 mc_cmd->cmd_link = 0xffff;
537                 mc_cmd->mc_cnt = swab16(num_addrs * 6);
538
539                 i = 0;
540                 netdev_for_each_mc_addr(dmi, dev)
541                         memcpy((char *) mc_cmd->mc_list[i++],
542                                dmi->dmi_addr, ETH_ALEN);
543
544                 p->scb->cbl_offset = make16(mc_cmd);
545                 p->scb->cmd_cuc = CUC_START;
546                 sun3_attn586();
547
548                 WAIT_4_STAT_COMPL(mc_cmd);
549
550                 if( (swab16(mc_cmd->cmd_status) & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
551                         printk("%s: Can't apply multicast-address-list.\n",dev->name);
552         }
553
554         /*
555          * alloc nop/xmit-cmds
556          */
557 #if (NUM_XMIT_BUFFS == 1)
558         for(i=0;i<2;i++)
559         {
560                 p->nop_cmds[i]                  = (struct nop_cmd_struct *)ptr;
561                 p->nop_cmds[i]->cmd_cmd         = swab16(CMD_NOP);
562                 p->nop_cmds[i]->cmd_status      = 0;
563                 p->nop_cmds[i]->cmd_link        = make16((p->nop_cmds[i]));
564                 ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
565         }
566 #else
567         for(i=0;i<NUM_XMIT_BUFFS;i++)
568         {
569                 p->nop_cmds[i]                  = (struct nop_cmd_struct *)ptr;
570                 p->nop_cmds[i]->cmd_cmd         = swab16(CMD_NOP);
571                 p->nop_cmds[i]->cmd_status      = 0;
572                 p->nop_cmds[i]->cmd_link        = make16((p->nop_cmds[i]));
573                 ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
574         }
575 #endif
576
577         ptr = alloc_rfa(dev,(void *)ptr); /* init receive-frame-area */
578
579         /*
580          * alloc xmit-buffs / init xmit_cmds
581          */
582         for(i=0;i<NUM_XMIT_BUFFS;i++)
583         {
584                 p->xmit_cmds[i] = (struct transmit_cmd_struct *)ptr; /*transmit cmd/buff 0*/
585                 ptr = (char *) ptr + sizeof(struct transmit_cmd_struct);
586                 p->xmit_cbuffs[i] = (char *)ptr; /* char-buffs */
587                 ptr = (char *) ptr + XMIT_BUFF_SIZE;
588                 p->xmit_buffs[i] = (struct tbd_struct *)ptr; /* TBD */
589                 ptr = (char *) ptr + sizeof(struct tbd_struct);
590                 if((void *)ptr > (void *)dev->mem_end)
591                 {
592                         printk("%s: not enough shared-mem for your configuration!\n",dev->name);
593                         return 1;
594                 }
595                 memset((char *)(p->xmit_cmds[i]) ,0, sizeof(struct transmit_cmd_struct));
596                 memset((char *)(p->xmit_buffs[i]),0, sizeof(struct tbd_struct));
597                 p->xmit_cmds[i]->cmd_link = make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]);
598                 p->xmit_cmds[i]->cmd_status = swab16(STAT_COMPL);
599                 p->xmit_cmds[i]->cmd_cmd = swab16(CMD_XMIT | CMD_INT);
600                 p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i]));
601                 p->xmit_buffs[i]->next = 0xffff;
602                 p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i]));
603         }
604
605         p->xmit_count = 0;
606         p->xmit_last    = 0;
607 #ifndef NO_NOPCOMMANDS
608         p->nop_point    = 0;
609 #endif
610
611          /*
612                 * 'start transmitter'
613                 */
614 #ifndef NO_NOPCOMMANDS
615         p->scb->cbl_offset = make16(p->nop_cmds[0]);
616         p->scb->cmd_cuc = CUC_START;
617         sun3_attn586();
618         WAIT_4_SCB_CMD();
619 #else
620         p->xmit_cmds[0]->cmd_link = make16(p->xmit_cmds[0]);
621         p->xmit_cmds[0]->cmd_cmd        = swab16(CMD_XMIT | CMD_SUSPEND | CMD_INT);
622 #endif
623
624         /*
625          * ack. interrupts
626          */
627         p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
628         sun3_attn586();
629         DELAY_16();
630
631         sun3_enaint();
632         sun3_active();
633
634         return 0;
635 }
636
637 /******************************************************
638  * This is a helper routine for sun3_82586_rnr_int() and init586().
639  * It sets up the Receive Frame Area (RFA).
640  */
641
642 static void *alloc_rfa(struct net_device *dev,void *ptr)
643 {
644         volatile struct rfd_struct *rfd = (struct rfd_struct *)ptr;
645         volatile struct rbd_struct *rbd;
646         int i;
647         struct priv *p = netdev_priv(dev);
648
649         memset((char *) rfd,0,sizeof(struct rfd_struct)*(p->num_recv_buffs+rfdadd));
650         p->rfd_first = rfd;
651
652         for(i = 0; i < (p->num_recv_buffs+rfdadd); i++) {
653                 rfd[i].next = make16(rfd + (i+1) % (p->num_recv_buffs+rfdadd) );
654                 rfd[i].rbd_offset = 0xffff;
655         }
656         rfd[p->num_recv_buffs-1+rfdadd].last = RFD_SUSP;         /* RU suspend */
657
658         ptr = (void *) (rfd + (p->num_recv_buffs + rfdadd) );
659
660         rbd = (struct rbd_struct *) ptr;
661         ptr = (void *) (rbd + p->num_recv_buffs);
662
663          /* clr descriptors */
664         memset((char *) rbd,0,sizeof(struct rbd_struct)*(p->num_recv_buffs));
665
666         for(i=0;i<p->num_recv_buffs;i++)
667         {
668                 rbd[i].next = make16((rbd + (i+1) % p->num_recv_buffs));
669                 rbd[i].size = swab16(RECV_BUFF_SIZE);
670                 rbd[i].buffer = make24(ptr);
671                 ptr = (char *) ptr + RECV_BUFF_SIZE;
672         }
673
674         p->rfd_top      = p->rfd_first;
675         p->rfd_last = p->rfd_first + (p->num_recv_buffs - 1 + rfdadd);
676
677         p->scb->rfa_offset              = make16(p->rfd_first);
678         p->rfd_first->rbd_offset        = make16(rbd);
679
680         return ptr;
681 }
682
683
684 /**************************************************
685  * Interrupt Handler ...
686  */
687
688 static irqreturn_t sun3_82586_interrupt(int irq,void *dev_id)
689 {
690         struct net_device *dev = dev_id;
691         unsigned short stat;
692         int cnt=0;
693         struct priv *p;
694
695         if (!dev) {
696                 printk ("sun3_82586-interrupt: irq %d for unknown device.\n",irq);
697                 return IRQ_NONE;
698         }
699         p = netdev_priv(dev);
700
701         if(debuglevel > 1)
702                 printk("I");
703
704         WAIT_4_SCB_CMD(); /* wait for last command      */
705
706         while((stat=p->scb->cus & STAT_MASK))
707         {
708                 p->scb->cmd_cuc = stat;
709                 sun3_attn586();
710
711                 if(stat & STAT_FR)       /* received a frame */
712                         sun3_82586_rcv_int(dev);
713
714                 if(stat & STAT_RNR) /* RU went 'not ready' */
715                 {
716                         printk("(R)");
717                         if(p->scb->rus & RU_SUSPEND) /* special case: RU_SUSPEND */
718                         {
719                                 WAIT_4_SCB_CMD();
720                                 p->scb->cmd_ruc = RUC_RESUME;
721                                 sun3_attn586();
722                                 WAIT_4_SCB_CMD_RUC();
723                         }
724                         else
725                         {
726                                 printk("%s: Receiver-Unit went 'NOT READY': %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->rus);
727                                 sun3_82586_rnr_int(dev);
728                         }
729                 }
730
731                 if(stat & STAT_CX)              /* command with I-bit set complete */
732                          sun3_82586_xmt_int(dev);
733
734 #ifndef NO_NOPCOMMANDS
735                 if(stat & STAT_CNA)     /* CU went 'not ready' */
736                 {
737                         if(netif_running(dev))
738                                 printk("%s: oops! CU has left active state. stat: %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->cus);
739                 }
740 #endif
741
742                 if(debuglevel > 1)
743                         printk("%d",cnt++);
744
745                 WAIT_4_SCB_CMD(); /* wait for ack. (sun3_82586_xmt_int can be faster than ack!!) */
746                 if(p->scb->cmd_cuc)      /* timed out? */
747                 {
748                         printk("%s: Acknowledge timed out.\n",dev->name);
749                         sun3_disint();
750                         break;
751                 }
752         }
753
754         if(debuglevel > 1)
755                 printk("i");
756         return IRQ_HANDLED;
757 }
758
759 /*******************************************************
760  * receive-interrupt
761  */
762
763 static void sun3_82586_rcv_int(struct net_device *dev)
764 {
765         int status,cnt=0;
766         unsigned short totlen;
767         struct sk_buff *skb;
768         struct rbd_struct *rbd;
769         struct priv *p = netdev_priv(dev);
770
771         if(debuglevel > 0)
772                 printk("R");
773
774         for(;(status = p->rfd_top->stat_high) & RFD_COMPL;)
775         {
776                         rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset);
777
778                         if(status & RFD_OK) /* frame received without error? */
779                         {
780                                 if( (totlen = swab16(rbd->status)) & RBD_LAST) /* the first and the last buffer? */
781                                 {
782                                         totlen &= RBD_MASK; /* length of this frame */
783                                         rbd->status = 0;
784                                         skb = (struct sk_buff *) dev_alloc_skb(totlen+2);
785                                         if(skb != NULL)
786                                         {
787                                                 skb_reserve(skb,2);
788                                                 skb_put(skb,totlen);
789                                                 skb_copy_to_linear_data(skb,(char *) p->base+swab32((unsigned long) rbd->buffer),totlen);
790                                                 skb->protocol=eth_type_trans(skb,dev);
791                                                 netif_rx(skb);
792                                                 p->stats.rx_packets++;
793                                         }
794                                         else
795                                                 p->stats.rx_dropped++;
796                                 }
797                                 else
798                                 {
799                                         int rstat;
800                                                  /* free all RBD's until RBD_LAST is set */
801                                         totlen = 0;
802                                         while(!((rstat=swab16(rbd->status)) & RBD_LAST))
803                                         {
804                                                 totlen += rstat & RBD_MASK;
805                                                 if(!rstat)
806                                                 {
807                                                         printk("%s: Whoops .. no end mark in RBD list\n",dev->name);
808                                                         break;
809                                                 }
810                                                 rbd->status = 0;
811                                                 rbd = (struct rbd_struct *) make32(rbd->next);
812                                         }
813                                         totlen += rstat & RBD_MASK;
814                                         rbd->status = 0;
815                                         printk("%s: received oversized frame! length: %d\n",dev->name,totlen);
816                                         p->stats.rx_dropped++;
817                          }
818                 }
819                 else /* frame !(ok), only with 'save-bad-frames' */
820                 {
821                         printk("%s: oops! rfd-error-status: %04x\n",dev->name,status);
822                         p->stats.rx_errors++;
823                 }
824                 p->rfd_top->stat_high = 0;
825                 p->rfd_top->last = RFD_SUSP; /* maybe exchange by RFD_LAST */
826                 p->rfd_top->rbd_offset = 0xffff;
827                 p->rfd_last->last = 0;                          /* delete RFD_SUSP      */
828                 p->rfd_last = p->rfd_top;
829                 p->rfd_top = (struct rfd_struct *) make32(p->rfd_top->next); /* step to next RFD */
830                 p->scb->rfa_offset = make16(p->rfd_top);
831
832                 if(debuglevel > 0)
833                         printk("%d",cnt++);
834         }
835
836         if(automatic_resume)
837         {
838                 WAIT_4_SCB_CMD();
839                 p->scb->cmd_ruc = RUC_RESUME;
840                 sun3_attn586();
841                 WAIT_4_SCB_CMD_RUC();
842         }
843
844 #ifdef WAIT_4_BUSY
845         {
846                 int i;
847                 for(i=0;i<1024;i++)
848                 {
849                         if(p->rfd_top->status)
850                                 break;
851                         DELAY_16();
852                         if(i == 1023)
853                                 printk("%s: RU hasn't fetched next RFD (not busy/complete)\n",dev->name);
854                 }
855         }
856 #endif
857
858 #if 0
859         if(!at_least_one)
860         {
861                 int i;
862                 volatile struct rfd_struct *rfds=p->rfd_top;
863                 volatile struct rbd_struct *rbds;
864                 printk("%s: received a FC intr. without having a frame: %04x %d\n",dev->name,status,old_at_least);
865                 for(i=0;i< (p->num_recv_buffs+4);i++)
866                 {
867                         rbds = (struct rbd_struct *) make32(rfds->rbd_offset);
868                         printk("%04x:%04x ",rfds->status,rbds->status);
869                         rfds = (struct rfd_struct *) make32(rfds->next);
870                 }
871                 printk("\nerrs: %04x %04x stat: %04x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->status);
872                 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);
873         }
874         old_at_least = at_least_one;
875 #endif
876
877         if(debuglevel > 0)
878                 printk("r");
879 }
880
881 /**********************************************************
882  * handle 'Receiver went not ready'.
883  */
884
885 static void sun3_82586_rnr_int(struct net_device *dev)
886 {
887         struct priv *p = netdev_priv(dev);
888
889         p->stats.rx_errors++;
890
891         WAIT_4_SCB_CMD();               /* wait for the last cmd, WAIT_4_FULLSTAT?? */
892         p->scb->cmd_ruc = RUC_ABORT; /* usually the RU is in the 'no resource'-state .. abort it now. */
893         sun3_attn586();
894         WAIT_4_SCB_CMD_RUC();           /* wait for accept cmd. */
895
896         alloc_rfa(dev,(char *)p->rfd_first);
897 /* maybe add a check here, before restarting the RU */
898         startrecv586(dev); /* restart RU */
899
900         printk("%s: Receive-Unit restarted. Status: %04x\n",dev->name,p->scb->rus);
901
902 }
903
904 /**********************************************************
905  * handle xmit - interrupt
906  */
907
908 static void sun3_82586_xmt_int(struct net_device *dev)
909 {
910         int status;
911         struct priv *p = netdev_priv(dev);
912
913         if(debuglevel > 0)
914                 printk("X");
915
916         status = swab16(p->xmit_cmds[p->xmit_last]->cmd_status);
917         if(!(status & STAT_COMPL))
918                 printk("%s: strange .. xmit-int without a 'COMPLETE'\n",dev->name);
919
920         if(status & STAT_OK)
921         {
922                 p->stats.tx_packets++;
923                 p->stats.collisions += (status & TCMD_MAXCOLLMASK);
924         }
925         else
926         {
927                 p->stats.tx_errors++;
928                 if(status & TCMD_LATECOLL) {
929                         printk("%s: late collision detected.\n",dev->name);
930                         p->stats.collisions++;
931                 }
932                 else if(status & TCMD_NOCARRIER) {
933                         p->stats.tx_carrier_errors++;
934                         printk("%s: no carrier detected.\n",dev->name);
935                 }
936                 else if(status & TCMD_LOSTCTS)
937                         printk("%s: loss of CTS detected.\n",dev->name);
938                 else if(status & TCMD_UNDERRUN) {
939                         p->stats.tx_fifo_errors++;
940                         printk("%s: DMA underrun detected.\n",dev->name);
941                 }
942                 else if(status & TCMD_MAXCOLL) {
943                         printk("%s: Max. collisions exceeded.\n",dev->name);
944                         p->stats.collisions += 16;
945                 }
946         }
947
948 #if (NUM_XMIT_BUFFS > 1)
949         if( (++p->xmit_last) == NUM_XMIT_BUFFS)
950                 p->xmit_last = 0;
951 #endif
952         netif_wake_queue(dev);
953 }
954
955 /***********************************************************
956  * (re)start the receiver
957  */
958
959 static void startrecv586(struct net_device *dev)
960 {
961         struct priv *p = netdev_priv(dev);
962
963         WAIT_4_SCB_CMD();
964         WAIT_4_SCB_CMD_RUC();
965         p->scb->rfa_offset = make16(p->rfd_first);
966         p->scb->cmd_ruc = RUC_START;
967         sun3_attn586();         /* start cmd. */
968         WAIT_4_SCB_CMD_RUC();   /* wait for accept cmd. (no timeout!!) */
969 }
970
971 static void sun3_82586_timeout(struct net_device *dev)
972 {
973         struct priv *p = netdev_priv(dev);
974 #ifndef NO_NOPCOMMANDS
975         if(p->scb->cus & CU_ACTIVE) /* COMMAND-UNIT active? */
976         {
977                 netif_wake_queue(dev);
978 #ifdef DEBUG
979                 printk("%s: strange ... timeout with CU active?!?\n",dev->name);
980                 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);
981 #endif
982                 p->scb->cmd_cuc = CUC_ABORT;
983                 sun3_attn586();
984                 WAIT_4_SCB_CMD();
985                 p->scb->cbl_offset = make16(p->nop_cmds[p->nop_point]);
986                 p->scb->cmd_cuc = CUC_START;
987                 sun3_attn586();
988                 WAIT_4_SCB_CMD();
989                 dev->trans_start = jiffies;
990                 return 0;
991         }
992 #endif
993         {
994 #ifdef DEBUG
995                 printk("%s: xmitter timed out, try to restart! stat: %02x\n",dev->name,p->scb->cus);
996                 printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
997                 printk("%s: check, whether you set the right interrupt number!\n",dev->name);
998 #endif
999                 sun3_82586_close(dev);
1000                 sun3_82586_open(dev);
1001         }
1002         dev->trans_start = jiffies;
1003 }
1004
1005 /******************************************************
1006  * send frame
1007  */
1008
1009 static int sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
1010 {
1011         int len,i;
1012 #ifndef NO_NOPCOMMANDS
1013         int next_nop;
1014 #endif
1015         struct priv *p = netdev_priv(dev);
1016
1017         if(skb->len > XMIT_BUFF_SIZE)
1018         {
1019                 printk("%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n",dev->name,XMIT_BUFF_SIZE,skb->len);
1020                 return NETDEV_TX_OK;
1021         }
1022
1023         netif_stop_queue(dev);
1024
1025 #if(NUM_XMIT_BUFFS > 1)
1026         if(test_and_set_bit(0,(void *) &p->lock)) {
1027                 printk("%s: Queue was locked\n",dev->name);
1028                 return NETDEV_TX_BUSY;
1029         }
1030         else
1031 #endif
1032         {
1033                 len = skb->len;
1034                 if (len < ETH_ZLEN) {
1035                         memset((void *)p->xmit_cbuffs[p->xmit_count], 0,
1036                                ETH_ZLEN);
1037                         len = ETH_ZLEN;
1038                 }
1039                 skb_copy_from_linear_data(skb, (void *)p->xmit_cbuffs[p->xmit_count], skb->len);
1040
1041 #if (NUM_XMIT_BUFFS == 1)
1042 #       ifdef NO_NOPCOMMANDS
1043
1044 #ifdef DEBUG
1045                 if(p->scb->cus & CU_ACTIVE)
1046                 {
1047                         printk("%s: Hmmm .. CU is still running and we wanna send a new packet.\n",dev->name);
1048                         printk("%s: stat: %04x %04x\n",dev->name,p->scb->cus,swab16(p->xmit_cmds[0]->cmd_status));
1049                 }
1050 #endif
1051
1052                 p->xmit_buffs[0]->size = swab16(TBD_LAST | len);
1053                 for(i=0;i<16;i++)
1054                 {
1055                         p->xmit_cmds[0]->cmd_status = 0;
1056                         WAIT_4_SCB_CMD();
1057                         if( (p->scb->cus & CU_STATUS) == CU_SUSPEND)
1058                                 p->scb->cmd_cuc = CUC_RESUME;
1059                         else
1060                         {
1061                                 p->scb->cbl_offset = make16(p->xmit_cmds[0]);
1062                                 p->scb->cmd_cuc = CUC_START;
1063                         }
1064
1065                         sun3_attn586();
1066                         dev->trans_start = jiffies;
1067                         if(!i)
1068                                 dev_kfree_skb(skb);
1069                         WAIT_4_SCB_CMD();
1070                         if( (p->scb->cus & CU_ACTIVE)) /* test it, because CU sometimes doesn't start immediately */
1071                                 break;
1072                         if(p->xmit_cmds[0]->cmd_status)
1073                                 break;
1074                         if(i==15)
1075                                 printk("%s: Can't start transmit-command.\n",dev->name);
1076                 }
1077 #       else
1078                 next_nop = (p->nop_point + 1) & 0x1;
1079                 p->xmit_buffs[0]->size = swab16(TBD_LAST | len);
1080
1081                 p->xmit_cmds[0]->cmd_link        = p->nop_cmds[next_nop]->cmd_link
1082                         = make16((p->nop_cmds[next_nop]));
1083                 p->xmit_cmds[0]->cmd_status = p->nop_cmds[next_nop]->cmd_status = 0;
1084
1085                 p->nop_cmds[p->nop_point]->cmd_link = make16((p->xmit_cmds[0]));
1086                 dev->trans_start = jiffies;
1087                 p->nop_point = next_nop;
1088                 dev_kfree_skb(skb);
1089 #       endif
1090 #else
1091                 p->xmit_buffs[p->xmit_count]->size = swab16(TBD_LAST | len);
1092                 if( (next_nop = p->xmit_count + 1) == NUM_XMIT_BUFFS )
1093                         next_nop = 0;
1094
1095                 p->xmit_cmds[p->xmit_count]->cmd_status = 0;
1096                 /* linkpointer of xmit-command already points to next nop cmd */
1097                 p->nop_cmds[next_nop]->cmd_link = make16((p->nop_cmds[next_nop]));
1098                 p->nop_cmds[next_nop]->cmd_status = 0;
1099
1100                 p->nop_cmds[p->xmit_count]->cmd_link = make16((p->xmit_cmds[p->xmit_count]));
1101                 dev->trans_start = jiffies;
1102                 p->xmit_count = next_nop;
1103
1104                 {
1105                         unsigned long flags;
1106                         local_irq_save(flags);
1107                         if(p->xmit_count != p->xmit_last)
1108                                 netif_wake_queue(dev);
1109                         p->lock = 0;
1110                         local_irq_restore(flags);
1111                 }
1112                 dev_kfree_skb(skb);
1113 #endif
1114         }
1115         return NETDEV_TX_OK;
1116 }
1117
1118 /*******************************************
1119  * Someone wanna have the statistics
1120  */
1121
1122 static struct net_device_stats *sun3_82586_get_stats(struct net_device *dev)
1123 {
1124         struct priv *p = netdev_priv(dev);
1125         unsigned short crc,aln,rsc,ovrn;
1126
1127         crc = swab16(p->scb->crc_errs); /* get error-statistic from the ni82586 */
1128         p->scb->crc_errs = 0;
1129         aln = swab16(p->scb->aln_errs);
1130         p->scb->aln_errs = 0;
1131         rsc = swab16(p->scb->rsc_errs);
1132         p->scb->rsc_errs = 0;
1133         ovrn = swab16(p->scb->ovrn_errs);
1134         p->scb->ovrn_errs = 0;
1135
1136         p->stats.rx_crc_errors += crc;
1137         p->stats.rx_fifo_errors += ovrn;
1138         p->stats.rx_frame_errors += aln;
1139         p->stats.rx_dropped += rsc;
1140
1141         return &p->stats;
1142 }
1143
1144 /********************************************************
1145  * Set MC list ..
1146  */
1147
1148 static void set_multicast_list(struct net_device *dev)
1149 {
1150         netif_stop_queue(dev);
1151         sun3_disint();
1152         alloc586(dev);
1153         init586(dev);
1154         startrecv586(dev);
1155         sun3_enaint();
1156         netif_wake_queue(dev);
1157 }
1158
1159 #ifdef MODULE
1160 #error This code is not currently supported as a module
1161 static struct net_device *dev_sun3_82586;
1162
1163 int init_module(void)
1164 {
1165         dev_sun3_82586 = sun3_82586_probe(-1);
1166         if (IS_ERR(dev_sun3_82586))
1167                 return PTR_ERR(dev_sun3_82586);
1168         return 0;
1169 }
1170
1171 void cleanup_module(void)
1172 {
1173         unsigned long ioaddr = dev_sun3_82586->base_addr;
1174         unregister_netdev(dev_sun3_82586);
1175         release_region(ioaddr, SUN3_82586_TOTAL_SIZE);
1176         iounmap((void *)ioaddr);
1177         free_netdev(dev_sun3_82586);
1178 }
1179 #endif /* MODULE */
1180
1181 #if 0
1182 /*
1183  * DUMP .. we expect a not running CMD unit and enough space
1184  */
1185 void sun3_82586_dump(struct net_device *dev,void *ptr)
1186 {
1187         struct priv *p = netdev_priv(dev);
1188         struct dump_cmd_struct *dump_cmd = (struct dump_cmd_struct *) ptr;
1189         int i;
1190
1191         p->scb->cmd_cuc = CUC_ABORT;
1192         sun3_attn586();
1193         WAIT_4_SCB_CMD();
1194         WAIT_4_SCB_CMD_RUC();
1195
1196         dump_cmd->cmd_status = 0;
1197         dump_cmd->cmd_cmd = CMD_DUMP | CMD_LAST;
1198         dump_cmd->dump_offset = make16((dump_cmd + 1));
1199         dump_cmd->cmd_link = 0xffff;
1200
1201         p->scb->cbl_offset = make16(dump_cmd);
1202         p->scb->cmd_cuc = CUC_START;
1203         sun3_attn586();
1204         WAIT_4_STAT_COMPL(dump_cmd);
1205
1206         if( (dump_cmd->cmd_status & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
1207                                 printk("%s: Can't get dump information.\n",dev->name);
1208
1209         for(i=0;i<170;i++) {
1210                 printk("%02x ",(int) ((unsigned char *) (dump_cmd + 1))[i]);
1211                 if(i % 24 == 23)
1212                         printk("\n");
1213         }
1214         printk("\n");
1215 }
1216 #endif
1217
1218 MODULE_LICENSE("GPL");