Deleted Added
full compact
1c1
< /* $FreeBSD: head/sys/dev/isp/isp.c 64095 2000-08-01 06:51:05Z mjacob $ */
---
> /* $FreeBSD: head/sys/dev/isp/isp.c 65140 2000-08-27 23:38:44Z mjacob $ */
597a598
> isp->isp_loaded_fw = 1;
598a600
> isp->isp_loaded_fw = 0;
753c755
< if (isp->isp_fast_mttr) {
---
> if (sdp_chan0->isp_fast_mttr) {
926c928
<
---
> sdf = DPARM_SAFE_DFLT;
928,929c930,933
< * If we're in LVD mode, then we pretty much should
< * only disable tagged queuing.
---
> * It is not quite clear when this changed over so that
> * we could force narrow and async for 1000/1020 cards,
> * but assume that this is only the case for loaded
> * firmware.
931,946c935,936
< if (IS_ULTRA2(isp) && sdp->isp_lvdmode) {
< sdf = DPARM_DEFAULT & ~DPARM_TQING;
< } else {
< int rvf = ISP_FW_REVX(isp->isp_fwrev);
< sdf = DPARM_SAFE_DFLT;
<
< /*
< * It is not quite clear when this changed over so that
< * we could force narrow and async, so assume >= 7.55
< * for i/t F/W and = 4.55 for initiator f/w.
< */
< if ((ISP_FW_REV(4, 55, 0) <= rvf &&
< (ISP_FW_REV(5, 0, 0) > rvf)) ||
< (ISP_FW_REV(7, 55, 0) <= rvf)) {
< sdf |= DPARM_NARROW | DPARM_ASYNC;
< }
---
> if (isp->isp_loaded_fw) {
> sdf |= DPARM_NARROW | DPARM_ASYNC;
951,953c941,947
< mbs.param[3] =
< (sdp->isp_devparam[tgt].sync_offset << 8) |
< (sdp->isp_devparam[tgt].sync_period);
---
> if ((sdf & DPARM_SYNC) == 0) {
> mbs.param[3] = 0;
> } else {
> mbs.param[3] =
> (sdp->isp_devparam[tgt].sync_offset << 8) |
> (sdp->isp_devparam[tgt].sync_period);
> }
960,962c954
< mbs.param[3] =
< (sdp->isp_devparam[tgt].sync_offset << 8) |
< (sdp->isp_devparam[tgt].sync_period);
---
> mbs.param[3] = 0;
968,991d959
< #if 0
< /*
< * We don't update dev_flags with what we've set
< * because that's not the ultimate goal setting.
< * If we succeed with the command, we *do* update
< * cur_dflags by getting target parameters.
< */
< mbs.param[0] = MBOX_GET_TARGET_PARAMS;
< mbs.param[1] = (tgt << 8) | (channel << 15);
< isp_mboxcmd(isp, &mbs, MBLOGALL);
< if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
< /*
< * Urrr.... We'll set cur_dflags to DPARM_SAFE_DFLT so
< * we don't try and do tags if tags aren't enabled.
< */
< sdp->isp_devparam[tgt].cur_dflags = DPARM_SAFE_DFLT;
< } else {
< sdp->isp_devparam[tgt].cur_dflags = mbs.param[2];
< sdp->isp_devparam[tgt].cur_offset = mbs.param[3] >> 8;
< sdp->isp_devparam[tgt].cur_period = mbs.param[3] & 0xff;
< }
< isp_prt(isp, ISP_LOGTDEBUG0,
< "set flags 0x%x got 0x%x back for target %d",
< sdf, mbs.param[2], tgt);
993d960
< #else
995,1000c962,966
< * We don't update any information because we need to run
< * at least one command per target to cause a new state
< * to be latched.
< */
< #endif
< /*
---
> * We don't update any information directly from the f/w
> * because we need to run at least one command to cause a
> * new state to be latched up. So, we just assume that we
> * converge to the values we just had set.
> *
1006c972
< sdp->isp_devparam[tgt].cur_dflags &= ~DPARM_TQING;
---
> sdp->isp_devparam[tgt].cur_dflags = sdf & ~DPARM_TQING;
1017a984,990
> for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
> if (sdp->isp_devparam[tgt].dev_refresh) {
> isp->isp_sendmarker |= (1 << channel);
> isp->isp_update |= (1 << channel);
> break;
> }
> }
1041,1046c1014
< #ifdef ISP_TARGET_MODE
< fcp->isp_fwoptions = ICBOPT_TGT_ENABLE;
< #else
< fcp->isp_fwoptions = 0;
< #endif
< fcp->isp_fwoptions |= ICBOPT_FAIRNESS;
---
>
1047a1016,1022
> * Firmware Options are either retrieved from NVRAM or
> * are patched elsewhere. We check them for sanity here
> * and make changes based on board revision, but otherwise
> * let others decide policy.
> */
>
> /*
1053,1054c1028
< fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
< fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS;
---
>
1063,1067d1036
< #ifndef ISP_NO_FASTPOST_FC
< fcp->isp_fwoptions |= ICBOPT_FAST_POST;
< #endif
< if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX)
< fcp->isp_fwoptions |= ICBOPT_FULL_DUPLEX;
1069a1039,1043
> * Insist on Port Database Update Async notifications
> */
> fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
>
> /*
1099c1073,1076
< #ifdef PRET_A_PORTE
---
> /*
> * Right now we just set extended options to prefer point-to-point
> * over loop based upon some soft config options.
> */
1110d1086
< #endif
1124a1101,1102
> isp_prt(isp, ISP_LOGDEBUG1,
> "isp_fibre_init: fwoptions 0x%x", fcp->isp_fwoptions);
1296c1274,1275
< count, GET_NANOSEC(&hra), GET_NANOSEC(&hrb), enano);
---
> count, (long) GET_NANOSEC(&hra), (long) GET_NANOSEC(&hrb),
> enano);
2224a2204,2207
> /*
> * If we don't know what tag to use, use HEAD OF QUEUE
> * for Request Sense or Ordered (for safety's sake).
> */
2383a2367,2370
> /*
> * XXX: Look for command in the REQUEST QUEUE. That is,
> * XXX: It hasen't been picked up by firmware yet.
> */
2402d2388
<
2404a2391,2392
> {
> int ena = *(int *)arg;
2406d2393
< int ena = *(int *)arg;
2412a2400,2425
> } else {
> fcparam *fcp = isp->isp_param;
> /*
> * We assume somebody has quiesced this bus.
> */
> if (ena) {
> if (fcp->isp_fwoptions & ICBOPT_TGT_ENABLE) {
> return (0);
> }
> fcp->isp_fwoptions |= ICBOPT_TGT_ENABLE;
> } else {
> if (!(fcp->isp_fwoptions & ICBOPT_TGT_ENABLE)) {
> return (0);
> }
> fcp->isp_fwoptions &= ~ICBOPT_TGT_ENABLE;
> }
> isp->isp_state = ISP_NILSTATE;
> isp_reset(isp);
> if (isp->isp_state != ISP_RESETSTATE) {
> break;
> }
> isp_init(isp);
> if (isp->isp_state != ISP_INITSTATE) {
> break;
> }
> isp->isp_state = ISP_RUNSTATE;
2414a2428
> }
2592a2607
> MEMZERO(sp, sizeof (isphdr_t));
2602a2618
> MEMZERO(sp, sizeof (isphdr_t));
2640a2657
> MEMZERO(sp, sizeof (isphdr_t));
2647a2665
> MEMZERO(sp, sizeof (isphdr_t));
2661,2665c2679,2680
< *XS_STSP(xs) = sp->req_scsi_status & 0xff;
< if (IS_SCSI(isp)) {
< if (sp->req_state_flags & RQSF_GOT_SENSE) {
< XS_SAVE_SENSE(xs, sp);
< }
---
>
> if (IS_FC(isp) && (sp->req_scsi_status & RQCS_SV)) {
2667,2669c2682,2684
< * A new synchronous rate was negotiated for this
< * target. Mark state such that we'll go look up
< * that which has changed later.
---
> * Fibre Channel F/W doesn't say we got status
> * if there's Sense Data instead. I guess they
> * think it goes w/o saying.
2671,2682c2686
< if (sp->req_status_flags & RQSTF_NEGOTIATION) {
< sdparam *sdp = isp->isp_param;
< sdp += XS_CHANNEL(xs);
< sdp->isp_devparam[XS_TGT(xs)].dev_refresh = 1;
< isp->isp_update |= (1 << XS_CHANNEL(xs));
< }
< } else {
< if (sp->req_scsi_status & RQCS_SV) {
< XS_SAVE_SENSE(xs, sp);
< /* force that we 'got' sense */
< sp->req_state_flags |= RQSF_GOT_SENSE;
< }
---
> sp->req_state_flags |= RQSF_GOT_STATUS;
2683a2688,2690
> if (sp->req_state_flags & RQSF_GOT_STATUS) {
> *XS_STSP(xs) = sp->req_scsi_status & 0xff;
> }
2685c2692,2693
< if (sp->req_header.rqs_entry_type == RQSTYPE_RESPONSE) {
---
> switch (sp->req_header.rqs_entry_type) {
> case RQSTYPE_RESPONSE:
2692c2700,2737
< } else if (sp->req_header.rqs_entry_type == RQSTYPE_REQUEST) {
---
> if (IS_SCSI(isp)) {
> XS_RESID(xs) = sp->req_resid;
> if ((sp->req_state_flags & RQSF_GOT_STATUS) &&
> (*XS_STSP(xs) == SCSI_CHECK) &&
> (sp->req_state_flags & RQSF_GOT_SENSE)) {
> XS_SAVE_SENSE(xs, sp);
> }
> /*
> * A new synchronous rate was negotiated for
> * this target. Mark state such that we'll go
> * look up that which has changed later.
> */
> if (sp->req_status_flags & RQSTF_NEGOTIATION) {
> int t = XS_TGT(xs);
> sdparam *sdp = isp->isp_param;
> sdp += XS_CHANNEL(xs);
> sdp->isp_devparam[t].dev_refresh = 1;
> isp->isp_update |=
> (1 << XS_CHANNEL(xs));
> }
> } else {
> if (sp->req_status_flags & RQSF_XFER_COMPLETE) {
> XS_RESID(xs) = 0;
> } else if (sp->req_scsi_status & RQCS_RESID) {
> XS_RESID(xs) = sp->req_resid;
> } else {
> XS_RESID(xs) = 0;
> }
> if ((sp->req_state_flags & RQSF_GOT_STATUS) &&
> (*XS_STSP(xs) == SCSI_CHECK) &&
> (sp->req_scsi_status & RQCS_SV)) {
> XS_SAVE_SENSE(xs, sp);
> }
> }
> isp_prt(isp, ISP_LOGDEBUG2, "asked for %d got resid %d",
> XS_XFRLEN(xs), sp->req_resid);
> break;
> case RQSTYPE_REQUEST:
2702c2747,2749
< } else {
---
> XS_RESID(xs) = XS_XFRLEN(xs);
> break;
> default:
2708a2756
> break;
2710,2716c2758,2761
< if (IS_SCSI(isp)) {
< XS_RESID(xs) = sp->req_resid;
< } else if (sp->req_scsi_status & RQCS_RV) {
< XS_RESID(xs) = sp->req_resid;
< isp_prt(isp, ISP_LOGDEBUG2, "cnt %d rsd %d",
< XS_XFRLEN(xs), sp->req_resid);
< }
---
>
> /*
> * Free any dma resources. As a side effect, this may
> * also do any cache flushing necessary for data coherence. */
2719a2765
>
2741a2788
> MEMZERO(sp, sizeof (isphdr_t));
2786,2787d2832
< case MBOX_COMMAND_COMPLETE: /* sometimes these show up */
< break;
2860,2862c2905,2907
< ((sdparam *)isp->isp_param)->isp_diffmode = 0;
< ((sdparam *)isp->isp_param)->isp_ultramode = 0;
< ((sdparam *)isp->isp_param)->isp_lvdmode = 1;
---
> SDPARAM(isp)->isp_diffmode = 0;
> SDPARAM(isp)->isp_ultramode = 0;
> SDPARAM(isp)->isp_lvdmode = 1;
2867,2869c2912,2914
< ((sdparam *)isp->isp_param)->isp_diffmode = 1;
< ((sdparam *)isp->isp_param)->isp_ultramode = 0;
< ((sdparam *)isp->isp_param)->isp_lvdmode = 0;
---
> SDPARAM(isp)->isp_diffmode = 1;
> SDPARAM(isp)->isp_ultramode = 0;
> SDPARAM(isp)->isp_lvdmode = 0;
2874,2876c2919,2921
< ((sdparam *)isp->isp_param)->isp_diffmode = 0;
< ((sdparam *)isp->isp_param)->isp_ultramode = 1;
< ((sdparam *)isp->isp_param)->isp_lvdmode = 0;
---
> SDPARAM(isp)->isp_diffmode = 0;
> SDPARAM(isp)->isp_ultramode = 1;
> SDPARAM(isp)->isp_lvdmode = 0;
2898,2899c2943,2953
< /* Should only occur when Fast Posting Set for 2100s */
< isp_prt(isp, ISP_LOGDEBUG3, "Fast Posting CTIO done");
---
> #ifdef ISP_TARGET_MODE
> /*
> * Bus gets overloaded with the handle. Dual bus
> * cards don't put bus# into the handle.
> */
> bus = (ISP_READ(isp, OUTMAILBOX2) << 16) |
> ISP_READ(isp, OUTMAILBOX1);
> isp_target_async(isp, bus, mbox);
> #else
> isp_prt(isp, ISP_LOGINFO, "Fast Posting CTIO done");
> #endif
2903c2957
< ((fcparam *) isp->isp_param)->isp_lipseq =
---
> FCPARAM(isp)->isp_lipseq =
2905,2906c2959,2960
< ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
< ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_LIP_RCVD;
---
> FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
> FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD;
2917,2918c2971,2972
< ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
< ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_LIP_RCVD;
---
> FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
> FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD;
2928,2929c2982,2983
< ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
< ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_NIL;
---
> FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
> FCPARAM(isp)->isp_loopstate = LOOP_NIL;
2939,2940c2993,2994
< ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
< ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_NIL;
---
> FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
> FCPARAM(isp)->isp_loopstate = LOOP_NIL;
2950c3004
< ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_PDB_RCVD;
---
> FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD;
2960c3014
< ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_PDB_RCVD;
---
> FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD;
2965,2966c3019,3020
< if (((fcparam *) isp->isp_param)->isp_onfabric)
< ((fcparam *) isp->isp_param)->isp_topo = TOPO_N_PORT;
---
> if (FCPARAM(isp)->isp_onfabric)
> FCPARAM(isp)->isp_topo = TOPO_N_PORT;
2968c3022
< ((fcparam *) isp->isp_param)->isp_topo = TOPO_F_PORT;
---
> FCPARAM(isp)->isp_topo = TOPO_F_PORT;
2971,2972c3025,3026
< ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
< ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_LIP_RCVD;
---
> FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
> FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD;
3023a3078,3080
> case RQSTYPE_STATUS_CONT:
> isp_prt(isp, ISP_LOGINFO, "Ignored Continuation Response");
> return (0);
3063c3120
< isp_prt(isp, ISP_LOGDEBUG0,
---
> isp_prt(isp, ISP_LOGDEBUG1,
3166,3169c3223
< if (IS_FC(isp)) {
< XS_RESID(xs) = sp->req_resid;
< break;
< }
---
> XS_RESID(xs) = sp->req_resid;
3250,3252c3304
< if (IS_FC(isp)) {
< XS_RESID(xs) = sp->req_resid;
< }
---
> XS_RESID(xs) = sp->req_resid;
3417d3468
< isp_done(xs);
3419a3471
> isp_done(xs);
4043c4095
< int bus;
---
> int bus, upmask;
4045,4046c4097,4098
< for (bus = 0; isp->isp_update != 0; bus++) {
< if (isp->isp_update & (1 << bus)) {
---
> for (bus = 0, upmask = isp->isp_update; upmask != 0; bus++) {
> if (upmask & (1 << bus)) {
4048d4099
< isp->isp_update ^= (1 << bus);
4049a4101
> upmask &= ~(1 << bus);
4061a4114
> isp->isp_update &= ~(1 << bus);
4062a4116,4118
> /*
> * There are no 'per-bus' settings for Fibre Channel.
> */
4065d4120
<
4073a4129,4130
> sdp->isp_devparam[tgt].dev_update = 0;
> sdp->isp_devparam[tgt].dev_refresh = 0;
4078d4134
<
4085c4141,4149
< if (sdp->isp_devparam[tgt].dev_update) {
---
>
> /*
> * Refresh overrides set
> */
> if (sdp->isp_devparam[tgt].dev_refresh) {
> mbs.param[0] = MBOX_GET_TARGET_PARAMS;
> sdp->isp_devparam[tgt].dev_refresh = 0;
> get = 1;
> } else if (sdp->isp_devparam[tgt].dev_update) {
4086a4151,4157
> /*
> * Make sure dev_flags has "Renegotiate on Error"
> * on and "Freeze Queue on Error" off.
> */
> sdp->isp_devparam[tgt].dev_flags |= DPARM_RENEG;
> sdp->isp_devparam[tgt].dev_flags &= ~DPARM_QFRZ;
>
4087a4159
>
4089,4090c4161,4162
< * Insist that PARITY must be enabled if SYNC
< * is enabled.
---
> * Insist that PARITY must be enabled
> * if SYNC or WIDE is enabled.
4092c4164
< if (mbs.param[2] & DPARM_SYNC) {
---
> if ((mbs.param[2] & (DPARM_SYNC|DPARM_WIDE)) != 0) {
4095,4098c4167,4174
< mbs.param[3] =
< (sdp->isp_devparam[tgt].sync_offset << 8) |
< (sdp->isp_devparam[tgt].sync_period);
< sdp->isp_devparam[tgt].dev_update = 0;
---
>
> if ((mbs.param[2] & DPARM_SYNC) == 0) {
> mbs.param[3] = 0;
> } else {
> mbs.param[3] =
> (sdp->isp_devparam[tgt].sync_offset << 8) |
> (sdp->isp_devparam[tgt].sync_period);
> }
4101,4102c4177,4179
< * RQSTF_NEGOTIATION set will cause
< * the dev_refresh/announce cycle.
---
> * RQSTF_NEGOTIATION set canl cause
> * the dev_refresh/announce cycle also.
> &
4113d4189
< sdp->isp_devparam[tgt].dev_refresh = 1;
4117a4194,4195
> sdp->isp_devparam[tgt].dev_update = 0;
> sdp->isp_devparam[tgt].dev_refresh = 1;
4119,4122d4196
< } else if (sdp->isp_devparam[tgt].dev_refresh) {
< mbs.param[0] = MBOX_GET_TARGET_PARAMS;
< sdp->isp_devparam[tgt].dev_refresh = 0;
< get = 1;
4140a4215,4222
>
> for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
> if (sdp->isp_devparam[tgt].dev_update ||
> sdp->isp_devparam[tgt].dev_refresh) {
> isp->isp_update |= (1 << bus);
> break;
> }
> }
4161c4243
< fcp->isp_execthrottle = ICB_DFLT_THROTTLE;
---
> fcp->isp_execthrottle = ISP_EXEC_THROTTLE;
4167a4250,4258
> fcp->isp_fwoptions = 0;
> fcp->isp_fwoptions |= ICBOPT_FAIRNESS;
> fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
> fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS;
> #ifndef ISP_NO_FASTPOST_FC
> fcp->isp_fwoptions |= ICBOPT_FAST_POST;
> #endif
> if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX)
> fcp->isp_fwoptions |= ICBOPT_FULL_DUPLEX;
4169a4261,4266
> * Make sure this is turned off now until we get
> * extended options from NVRAM
> */
> fcp->isp_fwoptions &= ~ICBOPT_EXTENDED;
>
> /*
4258a4356,4360
> } else if (IS_ULTRA3(isp)) {
> sdp->isp_devparam[tgt].sync_offset =
> ISP_80M_SYNCPARMS >> 8;
> sdp->isp_devparam[tgt].sync_period =
> ISP_80M_SYNCPARMS & 0xff;
4264c4366
< } else {
---
> } else if (IS_1240(isp)) {
4268a4371,4375
> } else {
> sdp->isp_devparam[tgt].sync_offset =
> ISP_20M_SYNCPARMS_1040 >> 8;
> sdp->isp_devparam[tgt].sync_period =
> ISP_20M_SYNCPARMS_1040 & 0xff;
4316c4423
< "bus %d tgt %d flags %x offset %x period %x",
---
> "Initial bus %d tgt %d flags %x offset %x period %x",
4342c4449
< sdp->isp_devparam[tgt].exc_throttle = 16;
---
> sdp->isp_devparam[tgt].exc_throttle = ISP_EXEC_THROTTLE;
4592c4699
< isp->isp_fast_mttr = ISP_NVRAM_FAST_MTTR_ENABLE(nvram_data);
---
> sdp->isp_fast_mttr = ISP_NVRAM_FAST_MTTR_ENABLE(nvram_data);