static void ni52_rnr_int(struct device *dev) { struct priv *p = (struct priv *) dev->priv; p->stats.rx_errors++; while(p->scb->cmd); /* wait for the last cmd */ p->scb->cmd = RUC_ABORT; ni_attn586(); while(p->scb->cmd); /* wait for accept cmd. */ alloc_rfa(dev,(char *)p->rfd_first); startrecv586(dev); /* restart */ }
static void elmc_rnr_int(struct net_device *dev) { struct priv *p = (struct priv *) dev->priv; p->stats.rx_errors++; WAIT_4_SCB_CMD(); /* wait for the last cmd */ p->scb->cmd = RUC_ABORT; /* usually the RU is in the 'no resource'-state .. abort it now. */ elmc_attn586(); WAIT_4_SCB_CMD(); /* wait for accept cmd. */ alloc_rfa(dev, (char *) p->rfd_first); startrecv586(dev); /* restart RU */ printk(KERN_WARNING "%s: Receive-Unit restarted. Status: %04x\n", dev->name, p->scb->status); }
static void sun3_82586_rnr_int(struct net_device *dev) { struct priv *p = netdev_priv(dev); dev->stats.rx_errors++; WAIT_4_SCB_CMD(); /* wait for the last cmd, WAIT_4_FULLSTAT?? */ p->scb->cmd_ruc = RUC_ABORT; /* usually the RU is in the 'no resource'-state .. abort it now. */ sun3_attn586(); WAIT_4_SCB_CMD_RUC(); /* wait for accept cmd. */ alloc_rfa(dev,(char *)p->rfd_first); /* maybe add a check here, before restarting the RU */ startrecv586(dev); /* restart RU */ printk("%s: Receive-Unit restarted. Status: %04x\n",dev->name,p->scb->rus); }
static void ni52_rnr_int(struct net_device *dev) { struct priv *p = netdev_priv(dev); dev->stats.rx_errors++; wait_for_scb_cmd(dev); /* */ writeb(RUC_ABORT, &p->scb->cmd_ruc); /* */ ni_attn586(); wait_for_scb_cmd_ruc(dev); /* */ alloc_rfa(dev, p->rfd_first); /* */ startrecv586(dev); /* */ printk(KERN_ERR "%s: Receive-Unit restarted. Status: %04x\n", dev->name, readb(&p->scb->rus)); }
static void ni52_rnr_int(struct net_device *dev) { struct priv *p = netdev_priv(dev); p->stats.rx_errors++; wait_for_scb_cmd(dev); /* wait for the last cmd, WAIT_4_FULLSTAT?? */ writeb(RUC_ABORT, &p->scb->cmd_ruc); /* usually the RU is in the 'no resource'-state .. abort it now. */ ni_attn586(); wait_for_scb_cmd_ruc(dev); /* wait for accept cmd. */ alloc_rfa(dev, p->rfd_first); /* maybe add a check here, before restarting the RU */ startrecv586(dev); /* restart RU */ printk(KERN_ERR "%s: Receive-Unit restarted. Status: %04x\n", dev->name, readb(&p->scb->rus)); }
static int init586(struct net_device *dev) { void *ptr; int i,result=0; struct priv *p = netdev_priv(dev); volatile struct configure_cmd_struct *cfg_cmd; volatile struct iasetup_cmd_struct *ias_cmd; volatile struct tdr_cmd_struct *tdr_cmd; volatile struct mcsetup_cmd_struct *mc_cmd; struct netdev_hw_addr *ha; int num_addrs=netdev_mc_count(dev); ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct)); cfg_cmd = (struct configure_cmd_struct *)ptr; /* configure-command */ cfg_cmd->cmd_status = 0; cfg_cmd->cmd_cmd = swab16(CMD_CONFIGURE | CMD_LAST); cfg_cmd->cmd_link = 0xffff; cfg_cmd->byte_cnt = 0x0a; /* number of cfg bytes */ cfg_cmd->fifo = fifo; /* fifo-limit (8=tx:32/rx:64) */ cfg_cmd->sav_bf = 0x40; /* hold or discard bad recv frames (bit 7) */ cfg_cmd->adr_len = 0x2e; /* addr_len |!src_insert |pre-len |loopback */ cfg_cmd->priority = 0x00; cfg_cmd->ifs = 0x60; cfg_cmd->time_low = 0x00; cfg_cmd->time_high = 0xf2; cfg_cmd->promisc = 0; if(dev->flags & IFF_ALLMULTI) { int len = ((char *) p->iscp - (char *) ptr - 8) / 6; if(num_addrs > len) { printk("%s: switching to promisc. mode\n",dev->name); cfg_cmd->promisc = 1; } } if(dev->flags&IFF_PROMISC) cfg_cmd->promisc = 1; cfg_cmd->carr_coll = 0x00; p->scb->cbl_offset = make16(cfg_cmd); p->scb->cmd_ruc = 0; p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */ sun3_attn586(); WAIT_4_STAT_COMPL(cfg_cmd); if((swab16(cfg_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_COMPL|STAT_OK)) { printk("%s: configure command failed: %x\n",dev->name,swab16(cfg_cmd->cmd_status)); return 1; } /* * individual address setup */ ias_cmd = (struct iasetup_cmd_struct *)ptr; ias_cmd->cmd_status = 0; ias_cmd->cmd_cmd = swab16(CMD_IASETUP | CMD_LAST); ias_cmd->cmd_link = 0xffff; memcpy((char *)&ias_cmd->iaddr,(char *) dev->dev_addr,ETH_ALEN); p->scb->cbl_offset = make16(ias_cmd); p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */ sun3_attn586(); WAIT_4_STAT_COMPL(ias_cmd); if((swab16(ias_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_OK|STAT_COMPL)) { printk("%s (82586): individual address setup command failed: %04x\n",dev->name,swab16(ias_cmd->cmd_status)); return 1; } /* * TDR, wire check .. e.g. no resistor e.t.c */ tdr_cmd = (struct tdr_cmd_struct *)ptr; tdr_cmd->cmd_status = 0; tdr_cmd->cmd_cmd = swab16(CMD_TDR | CMD_LAST); tdr_cmd->cmd_link = 0xffff; tdr_cmd->status = 0; p->scb->cbl_offset = make16(tdr_cmd); p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */ sun3_attn586(); WAIT_4_STAT_COMPL(tdr_cmd); if(!(swab16(tdr_cmd->cmd_status) & STAT_COMPL)) { printk("%s: Problems while running the TDR.\n",dev->name); } else { DELAY_16(); /* wait for result */ result = swab16(tdr_cmd->status); p->scb->cmd_cuc = p->scb->cus & STAT_MASK; sun3_attn586(); /* ack the interrupts */ if(result & TDR_LNK_OK) ; else if(result & TDR_XCVR_PRB) printk("%s: TDR: Transceiver problem. Check the cable(s)!\n",dev->name); else if(result & TDR_ET_OPN) printk("%s: TDR: No correct termination %d clocks away.\n",dev->name,result & TDR_TIMEMASK); else if(result & TDR_ET_SRT) { if (result & TDR_TIMEMASK) /* time == 0 -> strange :-) */ printk("%s: TDR: Detected a short circuit %d clocks away.\n",dev->name,result & TDR_TIMEMASK); } else printk("%s: TDR: Unknown status %04x\n",dev->name,result); } /* * Multicast setup */ if(num_addrs && !(dev->flags & IFF_PROMISC) ) { mc_cmd = (struct mcsetup_cmd_struct *) ptr; mc_cmd->cmd_status = 0; mc_cmd->cmd_cmd = swab16(CMD_MCSETUP | CMD_LAST); mc_cmd->cmd_link = 0xffff; mc_cmd->mc_cnt = swab16(num_addrs * 6); i = 0; netdev_for_each_mc_addr(ha, dev) memcpy((char *) mc_cmd->mc_list[i++], ha->addr, ETH_ALEN); p->scb->cbl_offset = make16(mc_cmd); p->scb->cmd_cuc = CUC_START; sun3_attn586(); WAIT_4_STAT_COMPL(mc_cmd); if( (swab16(mc_cmd->cmd_status) & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) ) printk("%s: Can't apply multicast-address-list.\n",dev->name); } /* * alloc nop/xmit-cmds */ #if (NUM_XMIT_BUFFS == 1) for(i=0;i<2;i++) { p->nop_cmds[i] = (struct nop_cmd_struct *)ptr; p->nop_cmds[i]->cmd_cmd = swab16(CMD_NOP); p->nop_cmds[i]->cmd_status = 0; p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i])); ptr = (char *) ptr + sizeof(struct nop_cmd_struct); } #else for(i=0;i<NUM_XMIT_BUFFS;i++) { p->nop_cmds[i] = (struct nop_cmd_struct *)ptr; p->nop_cmds[i]->cmd_cmd = swab16(CMD_NOP); p->nop_cmds[i]->cmd_status = 0; p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i])); ptr = (char *) ptr + sizeof(struct nop_cmd_struct); } #endif ptr = alloc_rfa(dev,(void *)ptr); /* init receive-frame-area */ /* * alloc xmit-buffs / init xmit_cmds */ for(i=0;i<NUM_XMIT_BUFFS;i++) { p->xmit_cmds[i] = (struct transmit_cmd_struct *)ptr; /*transmit cmd/buff 0*/ ptr = (char *) ptr + sizeof(struct transmit_cmd_struct); p->xmit_cbuffs[i] = (char *)ptr; /* char-buffs */ ptr = (char *) ptr + XMIT_BUFF_SIZE; p->xmit_buffs[i] = (struct tbd_struct *)ptr; /* TBD */ ptr = (char *) ptr + sizeof(struct tbd_struct); if((void *)ptr > (void *)dev->mem_end) { printk("%s: not enough shared-mem for your configuration!\n",dev->name); return 1; } memset((char *)(p->xmit_cmds[i]) ,0, sizeof(struct transmit_cmd_struct)); memset((char *)(p->xmit_buffs[i]),0, sizeof(struct tbd_struct)); p->xmit_cmds[i]->cmd_link = make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]); p->xmit_cmds[i]->cmd_status = swab16(STAT_COMPL); p->xmit_cmds[i]->cmd_cmd = swab16(CMD_XMIT | CMD_INT); p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i])); p->xmit_buffs[i]->next = 0xffff; p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i])); } p->xmit_count = 0; p->xmit_last = 0; #ifndef NO_NOPCOMMANDS p->nop_point = 0; #endif /* * 'start transmitter' */ #ifndef NO_NOPCOMMANDS p->scb->cbl_offset = make16(p->nop_cmds[0]); p->scb->cmd_cuc = CUC_START; sun3_attn586(); WAIT_4_SCB_CMD(); #else p->xmit_cmds[0]->cmd_link = make16(p->xmit_cmds[0]); p->xmit_cmds[0]->cmd_cmd = swab16(CMD_XMIT | CMD_SUSPEND | CMD_INT); #endif /* * ack. interrupts */ p->scb->cmd_cuc = p->scb->cus & STAT_MASK; sun3_attn586(); DELAY_16(); sun3_enaint(); sun3_active(); return 0; }
static int init586(struct net_device *dev) { void __iomem *ptr; int i, result = 0; struct priv *p = netdev_priv(dev); struct configure_cmd_struct __iomem *cfg_cmd; struct iasetup_cmd_struct __iomem *ias_cmd; struct tdr_cmd_struct __iomem *tdr_cmd; struct mcsetup_cmd_struct __iomem *mc_cmd; struct netdev_hw_addr *ha; int num_addrs = netdev_mc_count(dev); ptr = p->scb + 1; cfg_cmd = ptr; /* */ writew(0, &cfg_cmd->cmd_status); writew(CMD_CONFIGURE | CMD_LAST, &cfg_cmd->cmd_cmd); writew(0xFFFF, &cfg_cmd->cmd_link); /* */ writeb(0x0a, &cfg_cmd->byte_cnt); /* */ writeb(fifo, &cfg_cmd->fifo); /* */ writeb(0x40, &cfg_cmd->sav_bf); /* */ writeb(0x2e, &cfg_cmd->adr_len); writeb(0x00, &cfg_cmd->priority); writeb(0x60, &cfg_cmd->ifs); writeb(0x00, &cfg_cmd->time_low); writeb(0xf2, &cfg_cmd->time_high); writeb(0x00, &cfg_cmd->promisc); if (dev->flags & IFF_ALLMULTI) { int len = ((char __iomem *)p->iscp - (char __iomem *)ptr - 8) / 6; if (num_addrs > len) { printk(KERN_ERR "%s: switching to promisc. mode\n", dev->name); writeb(0x01, &cfg_cmd->promisc); } } if (dev->flags & IFF_PROMISC) writeb(0x01, &cfg_cmd->promisc); writeb(0x00, &cfg_cmd->carr_coll); writew(make16(cfg_cmd), &p->scb->cbl_offset); writeb(0, &p->scb->cmd_ruc); writeb(CUC_START, &p->scb->cmd_cuc); /* */ ni_attn586(); wait_for_stat_compl(cfg_cmd); if ((readw(&cfg_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_COMPL|STAT_OK)) { printk(KERN_ERR "%s: configure command failed: %x\n", dev->name, readw(&cfg_cmd->cmd_status)); return 1; } /* */ ias_cmd = ptr; writew(0, &ias_cmd->cmd_status); writew(CMD_IASETUP | CMD_LAST, &ias_cmd->cmd_cmd); writew(0xffff, &ias_cmd->cmd_link); memcpy_toio(&ias_cmd->iaddr, (char *)dev->dev_addr, ETH_ALEN); writew(make16(ias_cmd), &p->scb->cbl_offset); writeb(CUC_START, &p->scb->cmd_cuc); /* */ ni_attn586(); wait_for_stat_compl(ias_cmd); if ((readw(&ias_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_OK|STAT_COMPL)) { printk(KERN_ERR "%s (ni52): individual address setup command failed: %04x\n", dev->name, readw(&ias_cmd->cmd_status)); return 1; } /* */ tdr_cmd = ptr; writew(0, &tdr_cmd->cmd_status); writew(CMD_TDR | CMD_LAST, &tdr_cmd->cmd_cmd); writew(0xffff, &tdr_cmd->cmd_link); writew(0, &tdr_cmd->status); writew(make16(tdr_cmd), &p->scb->cbl_offset); writeb(CUC_START, &p->scb->cmd_cuc); /* */ ni_attn586(); wait_for_stat_compl(tdr_cmd); if (!(readw(&tdr_cmd->cmd_status) & STAT_COMPL)) printk(KERN_ERR "%s: Problems while running the TDR.\n", dev->name); else { udelay(16); result = readw(&tdr_cmd->status); writeb(readb(&p->scb->cus) & STAT_MASK, &p->scb->cmd_cuc); ni_attn586(); /* */ if (result & TDR_LNK_OK) ; else if (result & TDR_XCVR_PRB) printk(KERN_ERR "%s: TDR: Transceiver problem. Check the cable(s)!\n", dev->name); else if (result & TDR_ET_OPN) printk(KERN_ERR "%s: TDR: No correct termination %d clocks away.\n", dev->name, result & TDR_TIMEMASK); else if (result & TDR_ET_SRT) { /* */ if (result & TDR_TIMEMASK) printk(KERN_ERR "%s: TDR: Detected a short circuit %d clocks away.\n", dev->name, result & TDR_TIMEMASK); } else printk(KERN_ERR "%s: TDR: Unknown status %04x\n", dev->name, result); } /* */ if (num_addrs && !(dev->flags & IFF_PROMISC)) { mc_cmd = ptr; writew(0, &mc_cmd->cmd_status); writew(CMD_MCSETUP | CMD_LAST, &mc_cmd->cmd_cmd); writew(0xffff, &mc_cmd->cmd_link); writew(num_addrs * 6, &mc_cmd->mc_cnt); i = 0; netdev_for_each_mc_addr(ha, dev) memcpy_toio(mc_cmd->mc_list[i++], ha->addr, 6); writew(make16(mc_cmd), &p->scb->cbl_offset); writeb(CUC_START, &p->scb->cmd_cuc); ni_attn586(); wait_for_stat_compl(mc_cmd); if ((readw(&mc_cmd->cmd_status) & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK)) printk(KERN_ERR "%s: Can't apply multicast-address-list.\n", dev->name); } /* */ #if (NUM_XMIT_BUFFS == 1) for (i = 0; i < 2; i++) { p->nop_cmds[i] = ptr; writew(CMD_NOP, &p->nop_cmds[i]->cmd_cmd); writew(0, &p->nop_cmds[i]->cmd_status); writew(make16(p->nop_cmds[i]), &p->nop_cmds[i]->cmd_link); ptr = ptr + sizeof(struct nop_cmd_struct); } #else for (i = 0; i < NUM_XMIT_BUFFS; i++) { p->nop_cmds[i] = ptr; writew(CMD_NOP, &p->nop_cmds[i]->cmd_cmd); writew(0, &p->nop_cmds[i]->cmd_status); writew(make16(p->nop_cmds[i]), &p->nop_cmds[i]->cmd_link); ptr = ptr + sizeof(struct nop_cmd_struct); } #endif ptr = alloc_rfa(dev, ptr); /* */ /* */ for (i = 0; i < NUM_XMIT_BUFFS; i++) { /* */ p->xmit_cmds[i] = ptr; ptr = ptr + sizeof(struct transmit_cmd_struct); p->xmit_cbuffs[i] = ptr; /* */ ptr = ptr + XMIT_BUFF_SIZE; p->xmit_buffs[i] = ptr; /* */ ptr = ptr + sizeof(struct tbd_struct); if ((void __iomem *)ptr > (void __iomem *)p->iscp) { printk(KERN_ERR "%s: not enough shared-mem for your configuration!\n", dev->name); return 1; } memset_io(p->xmit_cmds[i], 0, sizeof(struct transmit_cmd_struct)); memset_io(p->xmit_buffs[i], 0, sizeof(struct tbd_struct)); writew(make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]), &p->xmit_cmds[i]->cmd_link); writew(STAT_COMPL, &p->xmit_cmds[i]->cmd_status); writew(CMD_XMIT|CMD_INT, &p->xmit_cmds[i]->cmd_cmd); writew(make16(p->xmit_buffs[i]), &p->xmit_cmds[i]->tbd_offset); writew(0xffff, &p->xmit_buffs[i]->next); writel(make24(p->xmit_cbuffs[i]), &p->xmit_buffs[i]->buffer); } p->xmit_count = 0; p->xmit_last = 0; #ifndef NO_NOPCOMMANDS p->nop_point = 0; #endif /* */ #ifndef NO_NOPCOMMANDS writew(make16(p->nop_cmds[0]), &p->scb->cbl_offset); writeb(CUC_START, &p->scb->cmd_cuc); ni_attn586(); wait_for_scb_cmd(dev); #else writew(make16(p->xmit_cmds[0]), &p->xmit_cmds[0]->cmd_link); writew(CMD_XMIT | CMD_SUSPEND | CMD_INT, &p->xmit_cmds[0]->cmd_cmd); #endif /* */ writeb(readb(&p->scb->cus) & STAT_MASK, &p->scb->cmd_cuc); ni_attn586(); udelay(16); ni_enaint(); return 0; }
static int init586(struct net_device *dev) { void *ptr; unsigned long s; int i, result = 0; struct priv *p = (struct priv *) dev->priv; volatile struct configure_cmd_struct *cfg_cmd; volatile struct iasetup_cmd_struct *ias_cmd; volatile struct tdr_cmd_struct *tdr_cmd; volatile struct mcsetup_cmd_struct *mc_cmd; struct dev_mc_list *dmi = dev->mc_list; int num_addrs = dev->mc_count; ptr = (void *) ((char *) p->scb + sizeof(struct scb_struct)); cfg_cmd = (struct configure_cmd_struct *) ptr; /* configure-command */ cfg_cmd->cmd_status = 0; cfg_cmd->cmd_cmd = CMD_CONFIGURE | CMD_LAST; cfg_cmd->cmd_link = 0xffff; cfg_cmd->byte_cnt = 0x0a; /* number of cfg bytes */ cfg_cmd->fifo = 0x08; /* fifo-limit (8=tx:32/rx:64) */ cfg_cmd->sav_bf = 0x40; /* hold or discard bad recv frames (bit 7) */ cfg_cmd->adr_len = 0x2e; /* addr_len |!src_insert |pre-len |loopback */ cfg_cmd->priority = 0x00; cfg_cmd->ifs = 0x60; cfg_cmd->time_low = 0x00; cfg_cmd->time_high = 0xf2; cfg_cmd->promisc = 0; if (dev->flags & (IFF_ALLMULTI | IFF_PROMISC)) { cfg_cmd->promisc = 1; dev->flags |= IFF_PROMISC; } cfg_cmd->carr_coll = 0x00; p->scb->cbl_offset = make16(cfg_cmd); p->scb->cmd = CUC_START; /* cmd.-unit start */ elmc_id_attn586(); s = jiffies; /* warning: only active with interrupts on !! */ while (!(cfg_cmd->cmd_status & STAT_COMPL)) { if (jiffies - s > 30*HZ/100) break; } if ((cfg_cmd->cmd_status & (STAT_OK | STAT_COMPL)) != (STAT_COMPL | STAT_OK)) { printk(KERN_WARNING "%s (elmc): configure command failed: %x\n", dev->name, cfg_cmd->cmd_status); return 1; } /* * individual address setup */ ias_cmd = (struct iasetup_cmd_struct *) ptr; ias_cmd->cmd_status = 0; ias_cmd->cmd_cmd = CMD_IASETUP | CMD_LAST; ias_cmd->cmd_link = 0xffff; memcpy((char *) &ias_cmd->iaddr, (char *) dev->dev_addr, ETH_ALEN); p->scb->cbl_offset = make16(ias_cmd); p->scb->cmd = CUC_START; /* cmd.-unit start */ elmc_id_attn586(); s = jiffies; while (!(ias_cmd->cmd_status & STAT_COMPL)) { if (jiffies - s > 30*HZ/100) break; } if ((ias_cmd->cmd_status & (STAT_OK | STAT_COMPL)) != (STAT_OK | STAT_COMPL)) { printk(KERN_WARNING "%s (elmc): individual address setup command failed: %04x\n", dev->name, ias_cmd->cmd_status); return 1; } /* * TDR, wire check .. e.g. no resistor e.t.c */ tdr_cmd = (struct tdr_cmd_struct *) ptr; tdr_cmd->cmd_status = 0; tdr_cmd->cmd_cmd = CMD_TDR | CMD_LAST; tdr_cmd->cmd_link = 0xffff; tdr_cmd->status = 0; p->scb->cbl_offset = make16(tdr_cmd); p->scb->cmd = CUC_START; /* cmd.-unit start */ elmc_attn586(); s = jiffies; while (!(tdr_cmd->cmd_status & STAT_COMPL)) { if (jiffies - s > 30*HZ/100) { printk(KERN_WARNING "%s: %d Problems while running the TDR.\n", dev->name, __LINE__); result = 1; break; } } if (!result) { DELAY(2); /* wait for result */ result = tdr_cmd->status; p->scb->cmd = p->scb->status & STAT_MASK; elmc_id_attn586(); /* ack the interrupts */ if (result & TDR_LNK_OK) { /* empty */ } else if (result & TDR_XCVR_PRB) { printk(KERN_WARNING "%s: TDR: Transceiver problem!\n", dev->name); } else if (result & TDR_ET_OPN) { printk(KERN_WARNING "%s: TDR: No correct termination %d clocks away.\n", dev->name, result & TDR_TIMEMASK); } else if (result & TDR_ET_SRT) { if (result & TDR_TIMEMASK) /* time == 0 -> strange :-) */ printk(KERN_WARNING "%s: TDR: Detected a short circuit %d clocks away.\n", dev->name, result & TDR_TIMEMASK); } else { printk(KERN_WARNING "%s: TDR: Unknown status %04x\n", dev->name, result); } } /* * ack interrupts */ p->scb->cmd = p->scb->status & STAT_MASK; elmc_id_attn586(); /* * alloc nop/xmit-cmds */ #if (NUM_XMIT_BUFFS == 1) for (i = 0; i < 2; i++) { p->nop_cmds[i] = (struct nop_cmd_struct *) ptr; p->nop_cmds[i]->cmd_cmd = CMD_NOP; p->nop_cmds[i]->cmd_status = 0; p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i])); ptr = (char *) ptr + sizeof(struct nop_cmd_struct); } p->xmit_cmds[0] = (struct transmit_cmd_struct *) ptr; /* transmit cmd/buff 0 */ ptr = (char *) ptr + sizeof(struct transmit_cmd_struct); #else for (i = 0; i < NUM_XMIT_BUFFS; i++) { p->nop_cmds[i] = (struct nop_cmd_struct *) ptr; p->nop_cmds[i]->cmd_cmd = CMD_NOP; p->nop_cmds[i]->cmd_status = 0; p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i])); ptr = (char *) ptr + sizeof(struct nop_cmd_struct); p->xmit_cmds[i] = (struct transmit_cmd_struct *) ptr; /*transmit cmd/buff 0 */ ptr = (char *) ptr + sizeof(struct transmit_cmd_struct); } #endif ptr = alloc_rfa(dev, (void *) ptr); /* init receive-frame-area */ /* * Multicast setup */ if (dev->mc_count) { /* I don't understand this: do we really need memory after the init? */ int len = ((char *) p->iscp - (char *) ptr - 8) / 6; if (len <= 0) { printk(KERN_ERR "%s: Ooooops, no memory for MC-Setup!\n", dev->name); } else { if (len < num_addrs) { num_addrs = len; printk(KERN_WARNING "%s: Sorry, can only apply %d MC-Address(es).\n", dev->name, num_addrs); } mc_cmd = (struct mcsetup_cmd_struct *) ptr; mc_cmd->cmd_status = 0; mc_cmd->cmd_cmd = CMD_MCSETUP | CMD_LAST; mc_cmd->cmd_link = 0xffff; mc_cmd->mc_cnt = num_addrs * 6; for (i = 0; i < num_addrs; i++) { memcpy((char *) mc_cmd->mc_list[i], dmi->dmi_addr, 6); dmi = dmi->next; } p->scb->cbl_offset = make16(mc_cmd); p->scb->cmd = CUC_START; elmc_id_attn586(); s = jiffies; while (!(mc_cmd->cmd_status & STAT_COMPL)) { if (jiffies - s > 30*HZ/100) break; } if (!(mc_cmd->cmd_status & STAT_COMPL)) { printk(KERN_WARNING "%s: Can't apply multicast-address-list.\n", dev->name); } } } /* * alloc xmit-buffs / init xmit_cmds */ for (i = 0; i < NUM_XMIT_BUFFS; i++) { p->xmit_cbuffs[i] = (char *) ptr; /* char-buffs */ ptr = (char *) ptr + XMIT_BUFF_SIZE; p->xmit_buffs[i] = (struct tbd_struct *) ptr; /* TBD */ ptr = (char *) ptr + sizeof(struct tbd_struct); if ((void *) ptr > (void *) p->iscp) { printk(KERN_ERR "%s: not enough shared-mem for your configuration!\n", dev->name); return 1; } memset((char *) (p->xmit_cmds[i]), 0, sizeof(struct transmit_cmd_struct)); memset((char *) (p->xmit_buffs[i]), 0, sizeof(struct tbd_struct)); p->xmit_cmds[i]->cmd_status = STAT_COMPL; p->xmit_cmds[i]->cmd_cmd = CMD_XMIT | CMD_INT; p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i])); p->xmit_buffs[i]->next = 0xffff; p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i])); } p->xmit_count = 0; p->xmit_last = 0; #ifndef NO_NOPCOMMANDS p->nop_point = 0; #endif /* * 'start transmitter' (nop-loop) */ #ifndef NO_NOPCOMMANDS p->scb->cbl_offset = make16(p->nop_cmds[0]); p->scb->cmd = CUC_START; elmc_id_attn586(); WAIT_4_SCB_CMD(); #else p->xmit_cmds[0]->cmd_link = 0xffff; p->xmit_cmds[0]->cmd_cmd = CMD_XMIT | CMD_LAST | CMD_INT; #endif return 0; }
static int init586(struct device *dev) { void *ptr; unsigned long s; int i,result=0; struct priv *p = (struct priv *) dev->priv; volatile struct configure_cmd_struct *cfg_cmd; volatile struct iasetup_cmd_struct *ias_cmd; volatile struct tdr_cmd_struct *tdr_cmd; ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct)); cfg_cmd = (struct configure_cmd_struct *)ptr; /* configure-command */ cfg_cmd->byte_cnt = 0x04; /* number of cfg bytes */ cfg_cmd->fifo = 0xc8; /* fifo-limit (8=tx:32/rx:64) | monitor */ cfg_cmd->sav_bf = 0x40; /* hold or discard bad recv frames (bit 7) */ cfg_cmd->adr_len = 0x2e; /* addr_len |!src_insert |pre-len |loopback */ cfg_cmd->cmd_status = 0; cfg_cmd->cmd_cmd = CMD_CONFIGURE | CMD_LAST; cfg_cmd->cmd_link = 0xffff; p->scb->cbl_offset = make16(cfg_cmd); p->scb->cmd = CUC_START; /* cmd.-unit start */ ni_attn586(); s = jiffies; /* warning: only active with interrupts on !! */ while(!(cfg_cmd->cmd_status & STAT_COMPL)) if(jiffies-s > 30) break; if((cfg_cmd->cmd_status & (STAT_OK|STAT_COMPL)) != (STAT_COMPL|STAT_OK)) { printk("%s (ni52): configure command failed: %x\n",dev->name,cfg_cmd->cmd_status); return 1; } /* * individual address setup */ ias_cmd = (struct iasetup_cmd_struct *)ptr; ias_cmd->cmd_status = 0; ias_cmd->cmd_cmd = CMD_IASETUP | CMD_LAST; ias_cmd->cmd_link = 0xffff; memcpy((char *)&ias_cmd->iaddr,(char *) dev->dev_addr,ETH_ALEN); p->scb->cbl_offset = make16(ias_cmd); p->scb->cmd = CUC_START; /* cmd.-unit start */ ni_attn586(); s = jiffies; while(!(ias_cmd->cmd_status & STAT_COMPL)) if(jiffies-s > 30) break; if((ias_cmd->cmd_status & (STAT_OK|STAT_COMPL)) != (STAT_OK|STAT_COMPL)) { printk("%s (ni52): individual address setup command failed: %04x\n",dev->name,ias_cmd->cmd_status); return 1; } /* * TDR, wire check .. e.g. no resistor e.t.c */ tdr_cmd = (struct tdr_cmd_struct *)ptr; tdr_cmd->cmd_status = 0; tdr_cmd->cmd_cmd = CMD_TDR | CMD_LAST; tdr_cmd->cmd_link = 0xffff; tdr_cmd->status = 0; p->scb->cbl_offset = make16(tdr_cmd); p->scb->cmd = CUC_START; /* cmd.-unit start */ ni_attn586(); s = jiffies; while(!(tdr_cmd->cmd_status & STAT_COMPL)) if(jiffies - s > 30) { printk("%s: Problems while running the TDR.\n",dev->name); result = 1; } if(!result) { DELAY(2); /* wait for result */ result = tdr_cmd->status; p->scb->cmd = p->scb->status & STAT_MASK; ni_attn586(); /* ack the interrupts */ if(result & TDR_LNK_OK) ; else if(result & TDR_XCVR_PRB) printk("%s: TDR: Transceiver problem!\n",dev->name); else if(result & TDR_ET_OPN) printk("%s: TDR: No correct termination %d clocks away.\n",dev->name,result & TDR_TIMEMASK); else if(result & TDR_ET_SRT) { if (result & TDR_TIMEMASK) /* time == 0 -> strange :-) */ printk("%s: TDR: Detected a short circuit %d clocks away.\n",dev->name,result & TDR_TIMEMASK); } else printk("%s: TDR: Unknown status %04x\n",dev->name,result); } /* * ack interrupts */ p->scb->cmd = p->scb->status & STAT_MASK; ni_attn586(); /* * alloc nop/xmit-cmds */ #ifdef ONLY_ONE_XMIT_BUF for(i=0;i<2;i++) { p->nop_cmds[i] = (struct nop_cmd_struct *)ptr; p->nop_cmds[i]->cmd_cmd = 0; p->nop_cmds[i]->cmd_status = 0; p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i])); ptr += sizeof(struct nop_cmd_struct); } p->xmit_cmds[0] = (struct transmit_cmd_struct *)ptr; /* transmit cmd/buff 0 */ ptr += sizeof(struct transmit_cmd_struct); #else for(i=0;i<NUM_XMIT_BUFFS;i++) { p->nop_cmds[i] = (struct nop_cmd_struct *)ptr; p->nop_cmds[i]->cmd_cmd = 0; p->nop_cmds[i]->cmd_status = 0; p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i])); ptr += sizeof(struct nop_cmd_struct); p->xmit_cmds[i] = (struct transmit_cmd_struct *)ptr; /* transmit cmd/buff 0 */ ptr += sizeof(struct transmit_cmd_struct); } #endif ptr = alloc_rfa(dev,(void *)ptr); /* init receive-frame-area */ /* * alloc xmit-buffs */ for(i=0;i<NUM_XMIT_BUFFS;i++) { p->xmit_cbuffs[i] = (char *)ptr; /* char-buffs */ ptr += XMIT_BUFF_SIZE; p->xmit_buffs[i] = (struct tbd_struct *)ptr; /* TBD */ ptr += sizeof(struct tbd_struct); if((void *)ptr > (void *)p->iscp) { printk("%s: not enough shared-mem for your configuration!\n",dev->name); return 1; } memset((char *)(p->xmit_cmds[i]) ,0, sizeof(struct transmit_cmd_struct)); memset((char *)(p->xmit_buffs[i]),0, sizeof(struct tbd_struct)); p->xmit_cmds[i]->cmd_status = STAT_COMPL; p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i])); p->xmit_buffs[i]->next = 0xffff; p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i])); } p->xmit_count = 0; p->xmit_last = 0; #ifndef NO_NOPCOMMANDS p->nop_point = 0; #endif /* * 'start transmitter' (nop-loop) */ #ifndef NO_NOPCOMMANDS p->scb->cbl_offset = make16(p->nop_cmds[0]); p->scb->cmd = CUC_START; ni_attn586(); while(p->scb->cmd); #else /* p->nop_cmds[0]->cmd_link = make16(p->nop_cmds[1]); p->nop_cmds[1]->cmd_link = make16(p->xmit_cmds[0]); */ p->xmit_cmds[0]->cmd_link = 0xffff; p->xmit_cmds[0]->cmd_cmd = CMD_XMIT | CMD_LAST | CMD_INT; #endif return 0; }
static int init586(struct net_device *dev) { void __iomem *ptr; int i, result = 0; struct priv *p = (struct priv *)dev->priv; struct configure_cmd_struct __iomem *cfg_cmd; struct iasetup_cmd_struct __iomem *ias_cmd; struct tdr_cmd_struct __iomem *tdr_cmd; struct mcsetup_cmd_struct __iomem *mc_cmd; struct dev_mc_list *dmi = dev->mc_list; int num_addrs = dev->mc_count; ptr = p->scb + 1; cfg_cmd = ptr; /* configure-command */ writew(0, &cfg_cmd->cmd_status); writew(CMD_CONFIGURE | CMD_LAST, &cfg_cmd->cmd_cmd); writew(0xFFFF, &cfg_cmd->cmd_link); /* number of cfg bytes */ writeb(0x0a, &cfg_cmd->byte_cnt); /* fifo-limit (8=tx:32/rx:64) */ writeb(fifo, &cfg_cmd->fifo); /* hold or discard bad recv frames (bit 7) */ writeb(0x40, &cfg_cmd->sav_bf); /* addr_len |!src_insert |pre-len |loopback */ writeb(0x2e, &cfg_cmd->adr_len); writeb(0x00, &cfg_cmd->priority); writeb(0x60, &cfg_cmd->ifs);; writeb(0x00, &cfg_cmd->time_low); writeb(0xf2, &cfg_cmd->time_high); writeb(0x00, &cfg_cmd->promisc);; if (dev->flags & IFF_ALLMULTI) { int len = ((char __iomem *)p->iscp - (char __iomem *)ptr - 8) / 6; if (num_addrs > len) { printk(KERN_ERR "%s: switching to promisc. mode\n", dev->name); dev->flags |= IFF_PROMISC; } } if (dev->flags & IFF_PROMISC) writeb(0x01, &cfg_cmd->promisc); writeb(0x00, &cfg_cmd->carr_coll); writew(make16(cfg_cmd), &p->scb->cbl_offset); writeb(0, &p->scb->cmd_ruc); writeb(CUC_START, &p->scb->cmd_cuc); /* cmd.-unit start */ ni_attn586(); wait_for_stat_compl(cfg_cmd); if ((readw(&cfg_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_COMPL|STAT_OK)) { printk(KERN_ERR "%s: configure command failed: %x\n", dev->name, readw(&cfg_cmd->cmd_status)); return 1; } /* * individual address setup */ ias_cmd = ptr; writew(0, &ias_cmd->cmd_status); writew(CMD_IASETUP | CMD_LAST, &ias_cmd->cmd_cmd); writew(0xffff, &ias_cmd->cmd_link); memcpy_toio(&ias_cmd->iaddr, (char *)dev->dev_addr, ETH_ALEN); writew(make16(ias_cmd), &p->scb->cbl_offset); writeb(CUC_START, &p->scb->cmd_cuc); /* cmd.-unit start */ ni_attn586(); wait_for_stat_compl(ias_cmd); if ((readw(&ias_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_OK|STAT_COMPL)) { printk(KERN_ERR "%s (ni52): individual address setup command failed: %04x\n", dev->name, readw(&ias_cmd->cmd_status)); return 1; } /* * TDR, wire check .. e.g. no resistor e.t.c */ tdr_cmd = ptr; writew(0, &tdr_cmd->cmd_status); writew(CMD_TDR | CMD_LAST, &tdr_cmd->cmd_cmd); writew(0xffff, &tdr_cmd->cmd_link); writew(0, &tdr_cmd->status); writew(make16(tdr_cmd), &p->scb->cbl_offset); writeb(CUC_START, &p->scb->cmd_cuc); /* cmd.-unit start */ ni_attn586(); wait_for_stat_compl(tdr_cmd); if (!(readw(&tdr_cmd->cmd_status) & STAT_COMPL)) printk(KERN_ERR "%s: Problems while running the TDR.\n", dev->name); else { udelay(16); result = readw(&tdr_cmd->status); writeb(readb(&p->scb->cus) & STAT_MASK, &p->scb->cmd_cuc); ni_attn586(); /* ack the interrupts */ if (result & TDR_LNK_OK) ; else if (result & TDR_XCVR_PRB) printk(KERN_ERR "%s: TDR: Transceiver problem. Check the cable(s)!\n", dev->name); else if (result & TDR_ET_OPN) printk(KERN_ERR "%s: TDR: No correct termination %d clocks away.\n", dev->name, result & TDR_TIMEMASK); else if (result & TDR_ET_SRT) { /* time == 0 -> strange :-) */ if (result & TDR_TIMEMASK) printk(KERN_ERR "%s: TDR: Detected a short circuit %d clocks away.\n", dev->name, result & TDR_TIMEMASK); } else printk(KERN_ERR "%s: TDR: Unknown status %04x\n", dev->name, result); } /* * Multicast setup */ if (num_addrs && !(dev->flags & IFF_PROMISC)) { mc_cmd = ptr; writew(0, &mc_cmd->cmd_status); writew(CMD_MCSETUP | CMD_LAST, &mc_cmd->cmd_cmd); writew(0xffff, &mc_cmd->cmd_link); writew(num_addrs * 6, &mc_cmd->mc_cnt); for (i = 0; i < num_addrs; i++, dmi = dmi->next) memcpy_toio(mc_cmd->mc_list[i], dmi->dmi_addr, 6); writew(make16(mc_cmd), &p->scb->cbl_offset); writeb(CUC_START, &p->scb->cmd_cuc); ni_attn586(); wait_for_stat_compl(mc_cmd); if ((readw(&mc_cmd->cmd_status) & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK)) printk(KERN_ERR "%s: Can't apply multicast-address-list.\n", dev->name); } /* * alloc nop/xmit-cmds */ #if (NUM_XMIT_BUFFS == 1) for (i = 0; i < 2; i++) { p->nop_cmds[i] = ptr; writew(CMD_NOP, &p->nop_cmds[i]->cmd_cmd); writew(0, &p->nop_cmds[i]->cmd_status); writew(make16(p->nop_cmds[i]), &p->nop_cmds[i]->cmd_link); ptr = ptr + sizeof(struct nop_cmd_struct); } #else for (i = 0; i < NUM_XMIT_BUFFS; i++) { p->nop_cmds[i] = ptr; writew(CMD_NOP, &p->nop_cmds[i]->cmd_cmd); writew(0, &p->nop_cmds[i]->cmd_status); writew(make16(p->nop_cmds[i]), &p->nop_cmds[i]->cmd_link); ptr = ptr + sizeof(struct nop_cmd_struct); } #endif ptr = alloc_rfa(dev, ptr); /* init receive-frame-area */ /* * alloc xmit-buffs / init xmit_cmds */ for (i = 0; i < NUM_XMIT_BUFFS; i++) { /* Transmit cmd/buff 0 */ p->xmit_cmds[i] = ptr; ptr = ptr + sizeof(struct transmit_cmd_struct); p->xmit_cbuffs[i] = ptr; /* char-buffs */ ptr = ptr + XMIT_BUFF_SIZE; p->xmit_buffs[i] = ptr; /* TBD */ ptr = ptr + sizeof(struct tbd_struct); if ((void __iomem *)ptr > (void __iomem *)p->iscp) { printk(KERN_ERR "%s: not enough shared-mem for your configuration!\n", dev->name); return 1; } memset_io(p->xmit_cmds[i], 0, sizeof(struct transmit_cmd_struct)); memset_io(p->xmit_buffs[i], 0, sizeof(struct tbd_struct)); writew(make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]), &p->xmit_cmds[i]->cmd_link); writew(STAT_COMPL, &p->xmit_cmds[i]->cmd_status); writew(CMD_XMIT|CMD_INT, &p->xmit_cmds[i]->cmd_cmd); writew(make16(p->xmit_buffs[i]), &p->xmit_cmds[i]->tbd_offset); writew(0xffff, &p->xmit_buffs[i]->next); writel(make24(p->xmit_cbuffs[i]), &p->xmit_buffs[i]->buffer); } p->xmit_count = 0; p->xmit_last = 0; #ifndef NO_NOPCOMMANDS p->nop_point = 0; #endif /* * 'start transmitter' */ #ifndef NO_NOPCOMMANDS writew(make16(p->nop_cmds[0]), &p->scb->cbl_offset); writeb(CUC_START, &p->scb->cmd_cuc); ni_attn586(); wait_for_scb_cmd(dev); #else writew(make16(p->xmit_cmds[0]), &p->xmit_cmds[0]->cmd_link); writew(CMD_XMIT | CMD_SUSPEND | CMD_INT, &p->xmit_cmds[0]->cmd_cmd); #endif /* * ack. interrupts */ writeb(readb(&p->scb->cus) & STAT_MASK, &p->scb->cmd_cuc); ni_attn586(); udelay(16); ni_enaint(); return 0; }