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