📄 if_fza.c
字号:
return(1); } else if((sc->reg_status & ADAPTER_STATE) != STATE_UNINITIALIZED) { printf("fza%d: Down Line Upgrade can not change to Uninitialized Mode",ifp->if_unit); smp_unlock(&sc->lk_fza_softc); splx(s); return(1); } } /* * set the DLU and reset bit */ sc->reg_reset = DLU_MODE | RESET ; if(!fzadlu(ifp->if_unit,sc,ife->ife_data,ife->ife_offset,ife->ife_blklen)) { smp_unlock(&sc->lk_fza_softc); splx(s); return(1); /* dlu failure */ } /* * if this is last block, blast flush */ if(ife->ife_lastblk == IFE_LASTBLOCK ) { int i; sc->reg_reset &= ~RESET ; /* * wait for 90 seconds for blast FLUSH finish */ for (i = 9000; i > 0 && !(sc->reg_intr & DLU_DONE); i--) DELAY(10000); /* * check the DLU_DONE bit */ if(!(sc->reg_intr & DLU_DONE)) { printf("fza%d: Code Update not complete - image may be corrupted",ifp->if_unit); smp_unlock(&sc->lk_fza_softc); splx(s); return(1); } else { switch ( sc->reg_status & DLU_STATUS ) { case DLU_FAILURE: printf("fza%d: DLU fatal failure - Brain Dead \n",ifp->if_unit); smp_unlock(&sc->lk_fza_softc); splx(s); return(1); break; case DLU_ERROR: printf("fza%d: DLU error - Recoverable \n",ifp->if_unit); smp_unlock(&sc->lk_fza_softc); splx(s); return(1); break; case DLU_SUCCESS: sc->reg_reset = FZAREG_CLEAR ; break; } } } /* turn off the interface */ smp_unlock(&sc->lk_fza_softc); splx(s); return (0); break; default: error = EINVAL; }done: return(error);}fzadlu(unit,sc,data,offset,blklen)int unit,offset,blklen;register struct fza_softc *sc;char *data;{ char *pmiaddr,*bufaddr = data; u_short stmp,stmp1; int i; pmiaddr = (char *)(sc->basereg + FZA_DLU_ADDR + offset) ; if(dludebug) printf("\n dlu address 0x%x size %d data --->",pmiaddr,blklen); for ( i = blklen ; i >= 2 ; i = i - 2, bufaddr = bufaddr + 2 ) { *((u_short *)pmiaddr) = stmp = htons(*((u_short *)bufaddr)); stmp1 = *(u_short *)pmiaddr; pmiaddr = pmiaddr + 2; if(dludebug) printf("%d New %x OLD %x ",i, stmp1, *((u_short *)bufaddr)); /* * check the status */ if(sc->reg_intr & PM_PARITY_ERR) { printf("fza%d, Down Line Load parity error \n",unit); return(0); } } if(i > 0 ) { *(u_short *)pmiaddr = htons(*((u_short *)bufaddr)) & 0xff00 ; stmp1 = *(u_short *)pmiaddr; /* * check the status */ if(sc->reg_intr & PM_PARITY_ERR) { printf("fza%d, Down Line Load parity error \n",unit); return(0); } } if(dludebug) printf("\n");return(1);}/* * FZA watchdog timer (runs once per second). Schedule a "read counters" * command and "read status" to update the per-unit counter block. */fzawatch (unit) int unit;{ register struct fza_softc *sc = &fza_softc[unit]; register struct ifnet *ifp = &sc->is_if; static int status; int s; if ((sc->reg_status & ADAPTER_STATE) != STATE_HALTED ) { s = splimp(); smp_lock(&sc->lk_fza_softc, LK_RETRY); /* * Schedule a read counters cmd to update the counter * block for this unit. */ fzamkcmd(sc,CMD_RDCNTR,unit); if(status++ > 3 ) { /* * schedule a read status command */ fzamkcmd(sc,CMD_STATUS,unit); status = 0; } smp_unlock(&sc->lk_fza_softc); splx(s); } ifp->if_timer = 1;}/* * FZA INIT command and wait until done */fzacmdinit(sc,unit)register struct fza_softc *sc;int unit;{ register FZACMDRING *cp; int delay,index = sc->cmdindex; if((cp=fzamkcmd(sc,CMD_INIT,unit))) { /* * wait 2 seconds for the INIT command done - only need one * second */ for (delay = 200 ; delay > 0 && !(sc->reg_intr & CMD_DONE); delay--) DELAY(10000); sc->lcmdindex++; if(!(sc->reg_intr & CMD_DONE)) { printf("fza%d: INIT command timeout \n",unit); if(fzadebug) PRT_REG(sc) return(0); } else if(!(fzacmdstatus(sc,cp->status_id,unit,"fzacmdinit"))) { if(fzadebug) PRT_REG(sc) return(0); } else { if(fzadebug) printf("fza%d: INIT command successed \n",unit); bcopy((caddr_t)(cp->buf_addr+sc->basereg),sc->initblk, sizeof(struct fzainit)); return(sizeof(struct fza_softc)); } } else return(0);} fzainitdesc(rp,bp,m,m1)register FZARCVRING *rp;register struct rmbuf *bp; struct mbuf *m, *m1;{ rp->rmc = 0; bp->mbufb=m1; bp->phymbufb = svtophy(mtod(m1,u_long *)); rp->bufaddr2 = bp->phymbufb >> FZASHIFT ; bp->mbufa=m; bp->phymbufa = svtophy(mtod(m,u_long *)); rp->bufaddr1 = ( bp->phymbufa >> FZASHIFT) & ~FZA_HOST_OWN ;}fzaselftest(sc,unit)register struct fza_softc *sc;int unit;{ register int delay; /* * perform the self test */ sc->reg_reset = RESET ; DELAY(1000); sc->reg_reset = FZAREG_CLEAR; /* * wait 40 seconds (adapter need 25 seconds) for FZA state * change from Reseting state to Uninitialized state */ for (delay = 4000 ; delay > 0 && !(sc->reg_intr & STATE_CHG); delay--) DELAY(10000); /* * check for the state change */ if (!( sc->reg_intr & STATE_CHG) ) { /* * didn't change state */ printf("fza%d: selftest timeout, couldn't pass selftest id %d\n", unit,(sc->reg_status & ID_FIELD)); if(fzadebug) PRT_REG(sc) return(0); } else if ( sc->reg_status != STATE_UNINITIALIZED ) { printf("fza%d: selftest error, couldn't change to Uninitialied state id %d \n",unit,(sc->reg_status & ID_FIELD)); if(fzadebug) PRT_REG(sc) return(0); } else { if(fzadebug) printf("fza%d: selftest successed\n"); }return(1);}fzafillinit(sc,pt)register struct fza_softc *sc;struct fzainit *pt;{ bcopy(&pt->mla[0],&sc->is_addr[0],6); bcopy(&pt->mla[0],&sc->is_dpaddr[0],6); /* * fill out the default characteristics value */ sc->t_max = pt->def_t_max; sc->t_req = pt->def_t_req; sc->tvx = pt->def_tvx; sc->lem_threshold= pt->lem_threshold; sc->pmd_type = pt->pmd_type; sc->smt_version = pt->smt_version; /* * fill out the ring address and number of ring entrys */ sc->rring=(FZARCVRING *)(pt->rcvbase_addr + sc->basereg); sc->tring=(FZAXMTRING *)(pt->xmtbase_addr + sc->basereg); sc->smttring=(FZASMTRING *)(pt->smtxmt_addr + sc->basereg); sc->smtrring=(FZASMTRING *)(pt->smtrcv_addr + sc->basereg); sc->nrmcxmt = pt->xmt_entry; sc->nsmtxmt = pt->smtxmt_entry; sc->nsmtrcv = pt->smtrcv_entry; /* * fill out the adapter specific information */ bcopy(&pt->pmc_rev[0],&sc->pmc_rev[0],4); bcopy(&pt->phy_rev[0],&sc->phy_rev[0],4); bcopy(&pt->fw_rev[0],&sc->fw_rev[0],4); sc->mop_type = pt->mop_type; sc->station_id.lo = pt->def_station_id.lo; sc->station_id.hi = pt->def_station_id.hi;}fzagetstatus(sc,ctr,fs) register struct fza_softc *sc; register struct fstatus *ctr; register struct fzastatus *fs;{ /* * Fill out the fddi status */ bzero(ctr, sizeof(struct fstatus)); /* * assign the default characterists value * and revision number */ ctr->t_req = sc->t_req; ctr->t_max = sc->t_max; ctr->tvx = sc->tvx; ctr->lem_threshold = sc->lem_threshold; ctr->pmd_type = sc->pmd_type ; ctr->smt_version = sc->smt_version ; bcopy(&sc->phy_rev[0],&ctr->phy_rev[0],4); bcopy(&sc->fw_rev[0],&ctr->fw_rev[0],4); /* * When the adapter in HALT state, we can * not issue the get status command */ if((sc->reg_status & ADAPTER_STATE) == STATE_HALTED ) { ctr->led_state = 2 ; /* Red */ ctr->link_state = 1 ; /* Off Ready */ ctr->dup_add_test = 0 ; /* Unknown */ ctr->ring_purge_state = 0 ; /* Purger Off */ ctr->phy_state = 2 ; /* Off Ready */ } else { ctr->led_state = fs->led_state; ctr->link_state = fs->link_state; ctr->phy_state = fs->phy_state ; ctr->dup_add_test = fs->dup_add_test; ctr->ring_purge_state = fs->ring_purge_state; } ctr->state = (sc->reg_status & ADAPTER_STATE) >> 8 ; ctr->rmt_state = fs->rmt_state; ctr->neg_trt = fs->neg_trt; bcopy(&fs->upstream[0],&ctr->upstream[0],6); ctr->una_timed_out = fs->una_timed_out; ctr->frame_strip_mode = fs->frame_strip_mode; ctr->claim_token_mode = fs->claim_token_mode; ctr->neighbor_phy_type = fs->neighbor_phy_type; ctr->rej_reason = fs->rej_reason; ctr->phy_link_error = fs->phy_link_error; bcopy(sc->is_dpaddr,&ctr->mla[0],6); ctr->ring_error = fs->ring_error & 0x0f ; bcopy(&fs->dir_beacon[0],&ctr->dir_beacon[0],6);} fzagetctrs(sc,ctr,xcmd) register struct fza_softc *sc; register struct fstat *ctr; register struct _fzactrs *xcmd;{ register int seconds; /* * Fill out the fddi counters through the ethernet counter * "estat" structure. It is based upon the information * returned by the CMD_{RDC,RCC}CNTR command and driver * maintained counter. */ bzero(ctr, sizeof(struct fstat)); seconds = fstc_second = time.tv_sec - sc->ztime; if (seconds & 0xffff0000) ctr->fst_second = 0xffff; else ctr->fst_second = seconds & 0xffff; /* driver counter */ ctr->fst_bytercvd = fstc_bytercvd; ctr->fst_bytesent = fstc_bytesent; ctr->fst_pdurcvd = fstc_pdurcvd; ctr->fst_pdusent = fstc_pdusent; ctr->fst_mbytercvd = fstc_mbytercvd; ctr->fst_mpdurcvd = fstc_mpdurcvd; ctr->fst_mbytesent = fstc_mbytesent; ctr->fst_mpdusent = fstc_mpdusent; ctr->fst_pduunrecog = fstc_pduunrecog = sc->is_ctrblk.est_unrecog; ctr->fst_mpduunrecog = fstc_mpduunrecog; ctr->fst_fcserror = fstc_fcserror ; ctr->fst_fseerror = fstc_fseerror ; ctr->fst_pdulen = fstc_pdulen; ctr->fst_pdualig = fstc_pdualig; /* adapter counter */ if (xcmd->frame_count.hi) ctr->fst_frame = fstc_frame = 0xffffffff; else ctr->fst_frame = fstc_frame = xcmd->frame_count.lo; if (xcmd->error_count.hi) ctr->fst_error = fstc_error = 0xffffffff; else ctr->fst_error = fstc_error = xcmd->error_count.lo; if (xcmd->lost_count.hi) ctr->fst_lost = fstc_lost = 0xffffffff; else ctr->fst_lost = fstc_lost = xcmd->lost_count.lo; if (xcmd->xmt_fail.hi || (xcmd->xmt_fail.lo & 0xffff0000)) ctr->fst_sendfail = fstc_sendfail = 0xffff; else ctr->fst_sendfail = fstc_sendfail = *(u_short*)(&xcmd->xmt_fail.lo); if (xcmd->xmt_underrun.hi || (xcmd->xmt_underrun.lo & 0xffff0000)) ctr->fst_underrun = fstc_underrun = 0xffff; else ctr->fst_underrun = fstc_underrun = *(u_short*)(&xcmd->xmt_underrun.lo); if ( xcmd->rcv_overrun.hi || (xcmd->rcv_overrun.lo & 0xffff0000)) ctr->fst_overrun = fstc_overrun = 0xffff; else ctr->fst_overrun = fstc_overrun = *(u_short*)(&xcmd->rcv_overrun.lo); if (xcmd->sysbuf.hi || (xcmd->sysbuf.lo & 0xffff0000)) ctr->fst_sysbuf = fstc_sysbuf = 0xffff; else ctr->fst_sysbuf = fstc_sysbuf = *(u_short*)(&xcmd->sysbuf.lo); if (xcmd->ring_init_init.hi || (xcmd->ring_init_init.lo & 0xffff0000)) ctr->fst_ringinit = fstc_ringinit = 0xffff; else ctr->fst_ringinit = fstc_ringinit = *(u_short*)(&xcmd->ring_init_init.lo); if (xcmd->ring_init_rcv.hi || (xcmd->ring_init_rcv.lo & 0xffff0000)) ctr->fst_ringinitrcv = fstc_ringinitrcv = 0xffff; else ctr->fst_ringinitrcv = fstc_ringinitrcv = *(u_short*)(&xcmd->ring_init_rcv.lo); if (xcmd->ring_beacon_init.hi || (xcmd->ring_beacon_init.lo & 0xffff0000)) ctr->fst_ringbeacon = fstc_ringbeacon = 0xfffff; else ctr->fst_ringbeacon = fstc_ringbeacon = *(u_short*)(&xcmd->ring_beacon_init.lo); if (xcmd->dup_addr_fail.hi || (xcmd->dup_addr_fail.lo & 0xffff0000)) ctr->fst_dupaddfail = fstc_dupaddfail = 0xffff; else ctr->fst_dupaddfail = fstc_dupaddfail = *(u_short*)(&xcmd->dup_addr_fail.lo); if (xcmd->ring_purge_err.hi || (xcmd->ring_purge_err.lo & 0xffff0000)) ctr->fst_ringpurge = fstc_ringpurge = 0xffff; else ctr->fst_ringpurge = fstc_ringpurge = *(u_short*)(&xcmd->ring_purge_err.lo); if (xcmd->dup_token.hi || (xcmd->dup_token.lo & 0xffff0000)) ctr->fst_duptoken = fstc_duptoken = 0xffff; else ctr->fst_duptoken = fstc_duptoken = *(u_short*)(&xcmd->dup_token.lo); if (xcmd->bridge_strip_err.hi || (xcmd->bridge_strip_err.lo & 0xffff0000)) ctr->fst_bridgestrip= fstc_bridgestrip= 0xffff; else ctr->fst_bridgestrip= fstc_bridgestrip= *(u_short*)(&xcmd->bridge_strip_err.lo); if (xcmd->trace_init.hi || (xcmd->trace_init.lo & 0xffff0000)) ctr->fst_traceinit= fstc_traceinit= 0xffff; else ctr->fst_traceinit= fstc_traceinit= *(u_short*)(&xcmd->trace_init.lo); if (xcmd->trace_rcvd.hi || (xcmd->trace_rcvd.lo & 0xffff0000)) ctr->fst_tracerecv= fstc_tracerecv= 0xffff; else ctr->fst_tracerecv= fstc_tracerecv= *(u_short*)(&xcmd->trace_rcvd.lo); if (xcmd->lem_rej.hi || (xcmd->lem_rej.lo & 0xffff0000)) ctr->fst_lem_rej= fstc_lem_rej= 0xffff; else ctr->fst_lem_rej= fstc_lem_rej= *(u_short*)(&xcmd->lem_rej.lo); if (xcmd->lct_rej.hi || (xcmd->lct_rej.lo & 0xffff0000)) ctr->fst_lct_rej= fstc_lct_rej= 0xffff; else ctr->fst_lct_rej = fstc_lct_rej= *(u_short*)(&xcmd->lct_rej.lo); if (xcmd->tne_exp_rej.hi || (xcmd->tne_exp_rej.lo & 0xffff0000)) ctr->fst_tne_exp_rej= fstc_tne_exp_rej= 0xffff; else ctr->fst_tne_exp_rej = fstc_tne_exp_rej= *(u_short*)(&xcmd->tne_exp_rej.lo); if (xcmd->connection.hi || (xcmd->connection.lo & 0xffff0000)) ctr->fst_connection= fstc_connection= 0xffff; else ctr->fst_connection= fstc_connection= *(u_short*)(&xcmd->connection.lo) ;}F
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -