Deleted Added
full compact
isp.c (64095) isp.c (65140)
1/* $FreeBSD: head/sys/dev/isp/isp.c 64095 2000-08-01 06:51:05Z mjacob $ */
1/* $FreeBSD: head/sys/dev/isp/isp.c 65140 2000-08-27 23:38:44Z mjacob $ */
2/*
3 * Machine and OS Independent (well, as best as possible)
4 * code for the Qlogic ISP SCSI adapters.
5 *
6 * Copyright (c) 1997, 1998, 1999 by Matthew Jacob
7 * NASA/Ames Research Center
8 * All rights reserved.
9 *

--- 580 unchanged lines hidden (view full) ---

590 */
591 mbs.param[0] = MBOX_VERIFY_CHECKSUM;
592 mbs.param[1] = ISP_CODE_ORG;
593 isp_mboxcmd(isp, &mbs, MBLOGNONE);
594 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
595 isp_prt(isp, ISP_LOGERR, "Ram Checksum Failure");
596 return;
597 }
2/*
3 * Machine and OS Independent (well, as best as possible)
4 * code for the Qlogic ISP SCSI adapters.
5 *
6 * Copyright (c) 1997, 1998, 1999 by Matthew Jacob
7 * NASA/Ames Research Center
8 * All rights reserved.
9 *

--- 580 unchanged lines hidden (view full) ---

590 */
591 mbs.param[0] = MBOX_VERIFY_CHECKSUM;
592 mbs.param[1] = ISP_CODE_ORG;
593 isp_mboxcmd(isp, &mbs, MBLOGNONE);
594 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
595 isp_prt(isp, ISP_LOGERR, "Ram Checksum Failure");
596 return;
597 }
598 isp->isp_loaded_fw = 1;
598 } else {
599 } else {
600 isp->isp_loaded_fw = 0;
599 isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download");
600 }
601
602 /*
603 * Now start it rolling.
604 *
605 * If we didn't actually download f/w,
606 * we still need to (re)start it.

--- 138 unchanged lines hidden (view full) ---

745 sdp_chan1++;
746 }
747
748 /* First do overall per-card settings. */
749
750 /*
751 * If we have fast memory timing enabled, turn it on.
752 */
601 isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download");
602 }
603
604 /*
605 * Now start it rolling.
606 *
607 * If we didn't actually download f/w,
608 * we still need to (re)start it.

--- 138 unchanged lines hidden (view full) ---

747 sdp_chan1++;
748 }
749
750 /* First do overall per-card settings. */
751
752 /*
753 * If we have fast memory timing enabled, turn it on.
754 */
753 if (isp->isp_fast_mttr) {
755 if (sdp_chan0->isp_fast_mttr) {
754 ISP_WRITE(isp, RISC_MTR, 0x1313);
755 }
756
757 /*
758 * Set Retry Delay and Count.
759 * You set both channels at the same time.
760 */
761 mbs.param[0] = MBOX_SET_RETRY_COUNT;

--- 156 unchanged lines hidden (view full) ---

918 */
919 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
920 int lun;
921 u_int16_t sdf;
922
923 if (sdp->isp_devparam[tgt].dev_enable == 0) {
924 continue;
925 }
756 ISP_WRITE(isp, RISC_MTR, 0x1313);
757 }
758
759 /*
760 * Set Retry Delay and Count.
761 * You set both channels at the same time.
762 */
763 mbs.param[0] = MBOX_SET_RETRY_COUNT;

--- 156 unchanged lines hidden (view full) ---

920 */
921 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
922 int lun;
923 u_int16_t sdf;
924
925 if (sdp->isp_devparam[tgt].dev_enable == 0) {
926 continue;
927 }
926
928 sdf = DPARM_SAFE_DFLT;
927 /*
929 /*
928 * If we're in LVD mode, then we pretty much should
929 * only disable tagged queuing.
930 * It is not quite clear when this changed over so that
931 * we could force narrow and async for 1000/1020 cards,
932 * but assume that this is only the case for loaded
933 * firmware.
930 */
934 */
931 if (IS_ULTRA2(isp) && sdp->isp_lvdmode) {
932 sdf = DPARM_DEFAULT & ~DPARM_TQING;
933 } else {
934 int rvf = ISP_FW_REVX(isp->isp_fwrev);
935 sdf = DPARM_SAFE_DFLT;
936
937 /*
938 * It is not quite clear when this changed over so that
939 * we could force narrow and async, so assume >= 7.55
940 * for i/t F/W and = 4.55 for initiator f/w.
941 */
942 if ((ISP_FW_REV(4, 55, 0) <= rvf &&
943 (ISP_FW_REV(5, 0, 0) > rvf)) ||
944 (ISP_FW_REV(7, 55, 0) <= rvf)) {
945 sdf |= DPARM_NARROW | DPARM_ASYNC;
946 }
935 if (isp->isp_loaded_fw) {
936 sdf |= DPARM_NARROW | DPARM_ASYNC;
947 }
948 mbs.param[0] = MBOX_SET_TARGET_PARAMS;
949 mbs.param[1] = (tgt << 8) | (channel << 15);
950 mbs.param[2] = sdf;
937 }
938 mbs.param[0] = MBOX_SET_TARGET_PARAMS;
939 mbs.param[1] = (tgt << 8) | (channel << 15);
940 mbs.param[2] = sdf;
951 mbs.param[3] =
952 (sdp->isp_devparam[tgt].sync_offset << 8) |
953 (sdp->isp_devparam[tgt].sync_period);
941 if ((sdf & DPARM_SYNC) == 0) {
942 mbs.param[3] = 0;
943 } else {
944 mbs.param[3] =
945 (sdp->isp_devparam[tgt].sync_offset << 8) |
946 (sdp->isp_devparam[tgt].sync_period);
947 }
954 isp_mboxcmd(isp, &mbs, MBLOGALL);
955 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
956 sdf = DPARM_SAFE_DFLT;
957 mbs.param[0] = MBOX_SET_TARGET_PARAMS;
958 mbs.param[1] = (tgt << 8) | (channel << 15);
959 mbs.param[2] = sdf;
948 isp_mboxcmd(isp, &mbs, MBLOGALL);
949 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
950 sdf = DPARM_SAFE_DFLT;
951 mbs.param[0] = MBOX_SET_TARGET_PARAMS;
952 mbs.param[1] = (tgt << 8) | (channel << 15);
953 mbs.param[2] = sdf;
960 mbs.param[3] =
961 (sdp->isp_devparam[tgt].sync_offset << 8) |
962 (sdp->isp_devparam[tgt].sync_period);
954 mbs.param[3] = 0;
963 isp_mboxcmd(isp, &mbs, MBLOGALL);
964 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
965 continue;
966 }
967 }
955 isp_mboxcmd(isp, &mbs, MBLOGALL);
956 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
957 continue;
958 }
959 }
968#if 0
969 /*
970 * We don't update dev_flags with what we've set
971 * because that's not the ultimate goal setting.
972 * If we succeed with the command, we *do* update
973 * cur_dflags by getting target parameters.
974 */
975 mbs.param[0] = MBOX_GET_TARGET_PARAMS;
976 mbs.param[1] = (tgt << 8) | (channel << 15);
977 isp_mboxcmd(isp, &mbs, MBLOGALL);
978 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
979 /*
980 * Urrr.... We'll set cur_dflags to DPARM_SAFE_DFLT so
981 * we don't try and do tags if tags aren't enabled.
982 */
983 sdp->isp_devparam[tgt].cur_dflags = DPARM_SAFE_DFLT;
984 } else {
985 sdp->isp_devparam[tgt].cur_dflags = mbs.param[2];
986 sdp->isp_devparam[tgt].cur_offset = mbs.param[3] >> 8;
987 sdp->isp_devparam[tgt].cur_period = mbs.param[3] & 0xff;
988 }
989 isp_prt(isp, ISP_LOGTDEBUG0,
990 "set flags 0x%x got 0x%x back for target %d",
991 sdf, mbs.param[2], tgt);
992
960
993#else
994 /*
961 /*
995 * We don't update any information because we need to run
996 * at least one command per target to cause a new state
997 * to be latched.
998 */
999#endif
1000 /*
962 * We don't update any information directly from the f/w
963 * because we need to run at least one command to cause a
964 * new state to be latched up. So, we just assume that we
965 * converge to the values we just had set.
966 *
1001 * Ensure that we don't believe tagged queuing is enabled yet.
1002 * It turns out that sometimes the ISP just ignores our
1003 * attempts to set parameters for devices that it hasn't
1004 * seen yet.
1005 */
967 * Ensure that we don't believe tagged queuing is enabled yet.
968 * It turns out that sometimes the ISP just ignores our
969 * attempts to set parameters for devices that it hasn't
970 * seen yet.
971 */
1006 sdp->isp_devparam[tgt].cur_dflags &= ~DPARM_TQING;
972 sdp->isp_devparam[tgt].cur_dflags = sdf & ~DPARM_TQING;
1007 for (lun = 0; lun < (int) isp->isp_maxluns; lun++) {
1008 mbs.param[0] = MBOX_SET_DEV_QUEUE_PARAMS;
1009 mbs.param[1] = (channel << 15) | (tgt << 8) | lun;
1010 mbs.param[2] = sdp->isp_max_queue_depth;
1011 mbs.param[3] = sdp->isp_devparam[tgt].exc_throttle;
1012 isp_mboxcmd(isp, &mbs, MBLOGALL);
1013 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1014 break;
1015 }
1016 }
1017 }
973 for (lun = 0; lun < (int) isp->isp_maxluns; lun++) {
974 mbs.param[0] = MBOX_SET_DEV_QUEUE_PARAMS;
975 mbs.param[1] = (channel << 15) | (tgt << 8) | lun;
976 mbs.param[2] = sdp->isp_max_queue_depth;
977 mbs.param[3] = sdp->isp_devparam[tgt].exc_throttle;
978 isp_mboxcmd(isp, &mbs, MBLOGALL);
979 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
980 break;
981 }
982 }
983 }
984 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
985 if (sdp->isp_devparam[tgt].dev_refresh) {
986 isp->isp_sendmarker |= (1 << channel);
987 isp->isp_update |= (1 << channel);
988 break;
989 }
990 }
1018}
1019
1020/*
1021 * Fibre Channel specific initialization.
1022 *
1023 * Locks are held before coming here.
1024 */
1025static void

--- 7 unchanged lines hidden (view full) ---

1033
1034 fcp = isp->isp_param;
1035
1036 loopid = DEFAULT_LOOPID(isp);
1037 icbp = (isp_icb_t *) fcp->isp_scratch;
1038 MEMZERO(icbp, sizeof (*icbp));
1039
1040 icbp->icb_version = ICB_VERSION1;
991}
992
993/*
994 * Fibre Channel specific initialization.
995 *
996 * Locks are held before coming here.
997 */
998static void

--- 7 unchanged lines hidden (view full) ---

1006
1007 fcp = isp->isp_param;
1008
1009 loopid = DEFAULT_LOOPID(isp);
1010 icbp = (isp_icb_t *) fcp->isp_scratch;
1011 MEMZERO(icbp, sizeof (*icbp));
1012
1013 icbp->icb_version = ICB_VERSION1;
1041#ifdef ISP_TARGET_MODE
1042 fcp->isp_fwoptions = ICBOPT_TGT_ENABLE;
1043#else
1044 fcp->isp_fwoptions = 0;
1045#endif
1046 fcp->isp_fwoptions |= ICBOPT_FAIRNESS;
1014
1047 /*
1015 /*
1016 * Firmware Options are either retrieved from NVRAM or
1017 * are patched elsewhere. We check them for sanity here
1018 * and make changes based on board revision, but otherwise
1019 * let others decide policy.
1020 */
1021
1022 /*
1048 * If this is a 2100 < revision 5, we have to turn off FAIRNESS.
1049 */
1050 if ((isp->isp_type == ISP_HA_FC_2100) && isp->isp_revision < 5) {
1051 fcp->isp_fwoptions &= ~ICBOPT_FAIRNESS;
1052 }
1023 * If this is a 2100 < revision 5, we have to turn off FAIRNESS.
1024 */
1025 if ((isp->isp_type == ISP_HA_FC_2100) && isp->isp_revision < 5) {
1026 fcp->isp_fwoptions &= ~ICBOPT_FAIRNESS;
1027 }
1053 fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
1054 fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS;
1028
1055 /*
1056 * We have to use FULL LOGIN even though it resets the loop too much
1057 * because otherwise port database entries don't get updated after
1058 * a LIP- this is a known f/w bug for 2100 f/w less than 1.17.0.
1059 */
1060 if (ISP_FW_REVX(isp->isp_fwrev) < ISP_FW_REV(1, 17, 0)) {
1061 fcp->isp_fwoptions |= ICBOPT_FULL_LOGIN;
1062 }
1029 /*
1030 * We have to use FULL LOGIN even though it resets the loop too much
1031 * because otherwise port database entries don't get updated after
1032 * a LIP- this is a known f/w bug for 2100 f/w less than 1.17.0.
1033 */
1034 if (ISP_FW_REVX(isp->isp_fwrev) < ISP_FW_REV(1, 17, 0)) {
1035 fcp->isp_fwoptions |= ICBOPT_FULL_LOGIN;
1036 }
1063#ifndef ISP_NO_FASTPOST_FC
1064 fcp->isp_fwoptions |= ICBOPT_FAST_POST;
1065#endif
1066 if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX)
1067 fcp->isp_fwoptions |= ICBOPT_FULL_DUPLEX;
1068
1069 /*
1037
1038 /*
1039 * Insist on Port Database Update Async notifications
1040 */
1041 fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
1042
1043 /*
1070 * We don't set ICBOPT_PORTNAME because we want our
1071 * Node Name && Port Names to be distinct.
1072 */
1073
1074 icbp->icb_fwoptions = fcp->isp_fwoptions;
1075 icbp->icb_maxfrmlen = fcp->isp_maxfrmlen;
1076 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN ||
1077 icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) {

--- 13 unchanged lines hidden (view full) ---

1091 isp_prt(isp, ISP_LOGERR,
1092 "bad execution throttle of %d- using 16",
1093 fcp->isp_execthrottle);
1094 icbp->icb_execthrottle = ICB_DFLT_THROTTLE;
1095 }
1096 icbp->icb_retry_delay = fcp->isp_retry_delay;
1097 icbp->icb_retry_count = fcp->isp_retry_count;
1098 icbp->icb_hardaddr = loopid;
1044 * We don't set ICBOPT_PORTNAME because we want our
1045 * Node Name && Port Names to be distinct.
1046 */
1047
1048 icbp->icb_fwoptions = fcp->isp_fwoptions;
1049 icbp->icb_maxfrmlen = fcp->isp_maxfrmlen;
1050 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN ||
1051 icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) {

--- 13 unchanged lines hidden (view full) ---

1065 isp_prt(isp, ISP_LOGERR,
1066 "bad execution throttle of %d- using 16",
1067 fcp->isp_execthrottle);
1068 icbp->icb_execthrottle = ICB_DFLT_THROTTLE;
1069 }
1070 icbp->icb_retry_delay = fcp->isp_retry_delay;
1071 icbp->icb_retry_count = fcp->isp_retry_count;
1072 icbp->icb_hardaddr = loopid;
1099#ifdef PRET_A_PORTE
1073 /*
1074 * Right now we just set extended options to prefer point-to-point
1075 * over loop based upon some soft config options.
1076 */
1100 if (IS_2200(isp)) {
1101 icbp->icb_fwoptions |= ICBOPT_EXTENDED;
1102 /*
1103 * Prefer or force Point-To-Point instead Loop?
1104 */
1105 if (isp->isp_confopts & ISP_CFG_NPORT)
1106 icbp->icb_xfwoptions = ICBXOPT_PTP_2_LOOP;
1107 else
1108 icbp->icb_xfwoptions = ICBXOPT_LOOP_2_PTP;
1109 }
1077 if (IS_2200(isp)) {
1078 icbp->icb_fwoptions |= ICBOPT_EXTENDED;
1079 /*
1080 * Prefer or force Point-To-Point instead Loop?
1081 */
1082 if (isp->isp_confopts & ISP_CFG_NPORT)
1083 icbp->icb_xfwoptions = ICBXOPT_PTP_2_LOOP;
1084 else
1085 icbp->icb_xfwoptions = ICBXOPT_LOOP_2_PTP;
1086 }
1110#endif
1111 icbp->icb_logintime = 60; /* 60 second login timeout */
1112
1113 if (fcp->isp_nodewwn) {
1114 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_nodewwn);
1115 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_portwwn);
1116 } else {
1117 fcp->isp_fwoptions &= ~(ICBOPT_USE_PORTNAME|ICBOPT_FULL_LOGIN);
1118 }
1119 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp);
1120 icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp);
1121 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_rquest_dma);
1122 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_rquest_dma);
1123 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_result_dma);
1124 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_result_dma);
1087 icbp->icb_logintime = 60; /* 60 second login timeout */
1088
1089 if (fcp->isp_nodewwn) {
1090 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_nodewwn);
1091 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_portwwn);
1092 } else {
1093 fcp->isp_fwoptions &= ~(ICBOPT_USE_PORTNAME|ICBOPT_FULL_LOGIN);
1094 }
1095 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp);
1096 icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp);
1097 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_rquest_dma);
1098 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_rquest_dma);
1099 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_result_dma);
1100 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_result_dma);
1101 isp_prt(isp, ISP_LOGDEBUG1,
1102 "isp_fibre_init: fwoptions 0x%x", fcp->isp_fwoptions);
1125 ISP_SWIZZLE_ICB(isp, icbp);
1126
1127 /*
1128 * Do this *before* initializing the firmware.
1129 */
1130 isp_mark_getpdb_all(isp);
1131 fcp->isp_fwstate = FW_CONFIG_WAIT;
1132 fcp->isp_loopstate = LOOP_NIL;

--- 155 unchanged lines hidden (view full) ---

1288 enano = NANOTIME_SUB(&hrb, &hra);
1289
1290 /*
1291 * If the elapsed time is less than 1 millisecond,
1292 * delay a period of time up to that millisecond of
1293 * waiting.
1294 */
1295 isp_prt(isp, ISP_LOGDEBUG3, "usec%d: 0x%lx->0x%lx enano %u",
1103 ISP_SWIZZLE_ICB(isp, icbp);
1104
1105 /*
1106 * Do this *before* initializing the firmware.
1107 */
1108 isp_mark_getpdb_all(isp);
1109 fcp->isp_fwstate = FW_CONFIG_WAIT;
1110 fcp->isp_loopstate = LOOP_NIL;

--- 155 unchanged lines hidden (view full) ---

1266 enano = NANOTIME_SUB(&hrb, &hra);
1267
1268 /*
1269 * If the elapsed time is less than 1 millisecond,
1270 * delay a period of time up to that millisecond of
1271 * waiting.
1272 */
1273 isp_prt(isp, ISP_LOGDEBUG3, "usec%d: 0x%lx->0x%lx enano %u",
1296 count, GET_NANOSEC(&hra), GET_NANOSEC(&hrb), enano);
1274 count, (long) GET_NANOSEC(&hra), (long) GET_NANOSEC(&hrb),
1275 enano);
1297
1298 /*
1299 * This peculiar code is an attempt to try and avoid
1300 * invoking u_int64_t math support functions for some
1301 * platforms where linkage is a problem.
1302 */
1303 if (enano < (1000 * 1000)) {
1304 count += 1000;

--- 912 unchanged lines hidden (view full) ---

2217 /*
2218 * Fibre Channel always requires some kind of tag.
2219 * The Qlogic drivers seem be happy not to use a tag,
2220 * but this breaks for some devices (IBM drives).
2221 */
2222 if (XS_TAG_P(xs)) {
2223 t2reqp->req_flags = XS_TAG_TYPE(xs);
2224 } else {
1276
1277 /*
1278 * This peculiar code is an attempt to try and avoid
1279 * invoking u_int64_t math support functions for some
1280 * platforms where linkage is a problem.
1281 */
1282 if (enano < (1000 * 1000)) {
1283 count += 1000;

--- 912 unchanged lines hidden (view full) ---

2196 /*
2197 * Fibre Channel always requires some kind of tag.
2198 * The Qlogic drivers seem be happy not to use a tag,
2199 * but this breaks for some devices (IBM drives).
2200 */
2201 if (XS_TAG_P(xs)) {
2202 t2reqp->req_flags = XS_TAG_TYPE(xs);
2203 } else {
2204 /*
2205 * If we don't know what tag to use, use HEAD OF QUEUE
2206 * for Request Sense or Ordered (for safety's sake).
2207 */
2225 if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */
2226 t2reqp->req_flags = REQFLAG_HTAG;
2227 else
2228 t2reqp->req_flags = REQFLAG_OTAG;
2229 }
2230 } else {
2231 sdparam *sdp = (sdparam *)isp->isp_param;
2232 if ((sdp->isp_devparam[target].cur_dflags & DPARM_TQING) &&

--- 143 unchanged lines hidden (view full) ---

2376 (bus << 15) | (XS_TGT(xs) << 8) | XS_LUN(xs);
2377 }
2378 mbs.param[3] = handle >> 16;
2379 mbs.param[2] = handle & 0xffff;
2380 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_ERROR);
2381 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
2382 return (0);
2383 }
2208 if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */
2209 t2reqp->req_flags = REQFLAG_HTAG;
2210 else
2211 t2reqp->req_flags = REQFLAG_OTAG;
2212 }
2213 } else {
2214 sdparam *sdp = (sdparam *)isp->isp_param;
2215 if ((sdp->isp_devparam[target].cur_dflags & DPARM_TQING) &&

--- 143 unchanged lines hidden (view full) ---

2359 (bus << 15) | (XS_TGT(xs) << 8) | XS_LUN(xs);
2360 }
2361 mbs.param[3] = handle >> 16;
2362 mbs.param[2] = handle & 0xffff;
2363 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_ERROR);
2364 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
2365 return (0);
2366 }
2367 /*
2368 * XXX: Look for command in the REQUEST QUEUE. That is,
2369 * XXX: It hasen't been picked up by firmware yet.
2370 */
2384 break;
2385
2386 case ISPCTL_UPDATE_PARAMS:
2387 isp_update(isp);
2388 return (0);
2389
2390 case ISPCTL_FCLINK_TEST:
2391 if (IS_FC(isp)) {
2392 int usdelay = (arg)? *((int *) arg) : 250000;
2393 return (isp_fclink_test(isp, usdelay));
2394 }
2395 break;
2396
2397 case ISPCTL_PDB_SYNC:
2398 if (IS_FC(isp)) {
2399 return (isp_pdb_sync(isp, -1));
2400 }
2401 break;
2371 break;
2372
2373 case ISPCTL_UPDATE_PARAMS:
2374 isp_update(isp);
2375 return (0);
2376
2377 case ISPCTL_FCLINK_TEST:
2378 if (IS_FC(isp)) {
2379 int usdelay = (arg)? *((int *) arg) : 250000;
2380 return (isp_fclink_test(isp, usdelay));
2381 }
2382 break;
2383
2384 case ISPCTL_PDB_SYNC:
2385 if (IS_FC(isp)) {
2386 return (isp_pdb_sync(isp, -1));
2387 }
2388 break;
2402
2403#ifdef ISP_TARGET_MODE
2404 case ISPCTL_TOGGLE_TMODE:
2389#ifdef ISP_TARGET_MODE
2390 case ISPCTL_TOGGLE_TMODE:
2391 {
2392 int ena = *(int *)arg;
2405 if (IS_SCSI(isp)) {
2393 if (IS_SCSI(isp)) {
2406 int ena = *(int *)arg;
2407 mbs.param[0] = MBOX_ENABLE_TARGET_MODE;
2408 mbs.param[1] = (ena)? ENABLE_TARGET_FLAG : 0;
2409 isp_mboxcmd(isp, &mbs, MBLOGALL);
2410 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2411 break;
2412 }
2394 mbs.param[0] = MBOX_ENABLE_TARGET_MODE;
2395 mbs.param[1] = (ena)? ENABLE_TARGET_FLAG : 0;
2396 isp_mboxcmd(isp, &mbs, MBLOGALL);
2397 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2398 break;
2399 }
2400 } else {
2401 fcparam *fcp = isp->isp_param;
2402 /*
2403 * We assume somebody has quiesced this bus.
2404 */
2405 if (ena) {
2406 if (fcp->isp_fwoptions & ICBOPT_TGT_ENABLE) {
2407 return (0);
2408 }
2409 fcp->isp_fwoptions |= ICBOPT_TGT_ENABLE;
2410 } else {
2411 if (!(fcp->isp_fwoptions & ICBOPT_TGT_ENABLE)) {
2412 return (0);
2413 }
2414 fcp->isp_fwoptions &= ~ICBOPT_TGT_ENABLE;
2415 }
2416 isp->isp_state = ISP_NILSTATE;
2417 isp_reset(isp);
2418 if (isp->isp_state != ISP_RESETSTATE) {
2419 break;
2420 }
2421 isp_init(isp);
2422 if (isp->isp_state != ISP_INITSTATE) {
2423 break;
2424 }
2425 isp->isp_state = ISP_RUNSTATE;
2413 }
2414 return (0);
2426 }
2427 return (0);
2428 }
2415#endif
2416 }
2417 return (-1);
2418}
2419
2420/*
2421 * Interrupt Service Routine(s).
2422 *

--- 162 unchanged lines hidden (view full) ---

2585 /*
2586 * Do any appropriate unswizzling of what the Qlogic f/w has
2587 * written into memory so it makes sense to us. This is a
2588 * per-platform thing. Also includes any memory barriers.
2589 */
2590 ISP_UNSWIZZLE_RESPONSE(isp, sp, oop);
2591 if (sp->req_header.rqs_entry_type != RQSTYPE_RESPONSE) {
2592 if (isp_handle_other_response(isp, sp, &optr) == 0) {
2429#endif
2430 }
2431 return (-1);
2432}
2433
2434/*
2435 * Interrupt Service Routine(s).
2436 *

--- 162 unchanged lines hidden (view full) ---

2599 /*
2600 * Do any appropriate unswizzling of what the Qlogic f/w has
2601 * written into memory so it makes sense to us. This is a
2602 * per-platform thing. Also includes any memory barriers.
2603 */
2604 ISP_UNSWIZZLE_RESPONSE(isp, sp, oop);
2605 if (sp->req_header.rqs_entry_type != RQSTYPE_RESPONSE) {
2606 if (isp_handle_other_response(isp, sp, &optr) == 0) {
2607 MEMZERO(sp, sizeof (isphdr_t));
2593 continue;
2594 }
2595 /*
2596 * It really has to be a bounced request just copied
2597 * from the request queue to the response queue. If
2598 * not, something bad has happened.
2599 */
2600 if (sp->req_header.rqs_entry_type != RQSTYPE_REQUEST) {
2601 isp_prt(isp, ISP_LOGERR, notresp,
2602 sp->req_header.rqs_entry_type, oop, optr);
2608 continue;
2609 }
2610 /*
2611 * It really has to be a bounced request just copied
2612 * from the request queue to the response queue. If
2613 * not, something bad has happened.
2614 */
2615 if (sp->req_header.rqs_entry_type != RQSTYPE_REQUEST) {
2616 isp_prt(isp, ISP_LOGERR, notresp,
2617 sp->req_header.rqs_entry_type, oop, optr);
2618 MEMZERO(sp, sizeof (isphdr_t));
2603 continue;
2604 }
2605 buddaboom = 1;
2606 }
2607
2608 if (sp->req_header.rqs_flags & 0xf) {
2609#define _RQS_OFLAGS \
2610 ~(RQSFLAG_CONTINUATION|RQSFLAG_FULL|RQSFLAG_BADHEADER|RQSFLAG_BADPACKET)

--- 22 unchanged lines hidden (view full) ---

2633 isp_prt(isp, ISP_LOGERR,
2634 "unknown flags (0x%x) in response",
2635 sp->req_header.rqs_flags);
2636 buddaboom++;
2637 }
2638#undef _RQS_OFLAGS
2639 }
2640 if (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1) {
2619 continue;
2620 }
2621 buddaboom = 1;
2622 }
2623
2624 if (sp->req_header.rqs_flags & 0xf) {
2625#define _RQS_OFLAGS \
2626 ~(RQSFLAG_CONTINUATION|RQSFLAG_FULL|RQSFLAG_BADHEADER|RQSFLAG_BADPACKET)

--- 22 unchanged lines hidden (view full) ---

2649 isp_prt(isp, ISP_LOGERR,
2650 "unknown flags (0x%x) in response",
2651 sp->req_header.rqs_flags);
2652 buddaboom++;
2653 }
2654#undef _RQS_OFLAGS
2655 }
2656 if (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1) {
2657 MEMZERO(sp, sizeof (isphdr_t));
2641 isp_prt(isp, ISP_LOGERR,
2642 "bad request handle %d", sp->req_handle);
2643 ISP_WRITE(isp, INMAILBOX5, optr);
2644 continue;
2645 }
2646 xs = isp_find_xs(isp, sp->req_handle);
2647 if (xs == NULL) {
2658 isp_prt(isp, ISP_LOGERR,
2659 "bad request handle %d", sp->req_handle);
2660 ISP_WRITE(isp, INMAILBOX5, optr);
2661 continue;
2662 }
2663 xs = isp_find_xs(isp, sp->req_handle);
2664 if (xs == NULL) {
2665 MEMZERO(sp, sizeof (isphdr_t));
2648 isp_prt(isp, ISP_LOGERR,
2649 "cannot find handle 0x%x in xflist",
2650 sp->req_handle);
2651 ISP_WRITE(isp, INMAILBOX5, optr);
2652 continue;
2653 }
2654 isp_destroy_handle(isp, sp->req_handle);
2655 if (sp->req_status_flags & RQSTF_BUS_RESET) {
2656 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
2657 }
2658 if (buddaboom) {
2659 XS_SETERR(xs, HBA_BOTCH);
2660 }
2666 isp_prt(isp, ISP_LOGERR,
2667 "cannot find handle 0x%x in xflist",
2668 sp->req_handle);
2669 ISP_WRITE(isp, INMAILBOX5, optr);
2670 continue;
2671 }
2672 isp_destroy_handle(isp, sp->req_handle);
2673 if (sp->req_status_flags & RQSTF_BUS_RESET) {
2674 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
2675 }
2676 if (buddaboom) {
2677 XS_SETERR(xs, HBA_BOTCH);
2678 }
2661 *XS_STSP(xs) = sp->req_scsi_status & 0xff;
2662 if (IS_SCSI(isp)) {
2663 if (sp->req_state_flags & RQSF_GOT_SENSE) {
2664 XS_SAVE_SENSE(xs, sp);
2665 }
2679
2680 if (IS_FC(isp) && (sp->req_scsi_status & RQCS_SV)) {
2666 /*
2681 /*
2667 * A new synchronous rate was negotiated for this
2668 * target. Mark state such that we'll go look up
2669 * that which has changed later.
2682 * Fibre Channel F/W doesn't say we got status
2683 * if there's Sense Data instead. I guess they
2684 * think it goes w/o saying.
2670 */
2685 */
2671 if (sp->req_status_flags & RQSTF_NEGOTIATION) {
2672 sdparam *sdp = isp->isp_param;
2673 sdp += XS_CHANNEL(xs);
2674 sdp->isp_devparam[XS_TGT(xs)].dev_refresh = 1;
2675 isp->isp_update |= (1 << XS_CHANNEL(xs));
2676 }
2677 } else {
2678 if (sp->req_scsi_status & RQCS_SV) {
2679 XS_SAVE_SENSE(xs, sp);
2680 /* force that we 'got' sense */
2681 sp->req_state_flags |= RQSF_GOT_SENSE;
2682 }
2686 sp->req_state_flags |= RQSF_GOT_STATUS;
2683 }
2687 }
2688 if (sp->req_state_flags & RQSF_GOT_STATUS) {
2689 *XS_STSP(xs) = sp->req_scsi_status & 0xff;
2690 }
2684
2691
2685 if (sp->req_header.rqs_entry_type == RQSTYPE_RESPONSE) {
2692 switch (sp->req_header.rqs_entry_type) {
2693 case RQSTYPE_RESPONSE:
2686 XS_SET_STATE_STAT(isp, xs, sp);
2687 isp_parse_status(isp, sp, xs);
2688 if ((XS_NOERR(xs) || XS_ERR(xs) == HBA_NOERROR) &&
2689 (*XS_STSP(xs) == SCSI_BUSY)) {
2690 XS_SETERR(xs, HBA_TGTBSY);
2691 }
2694 XS_SET_STATE_STAT(isp, xs, sp);
2695 isp_parse_status(isp, sp, xs);
2696 if ((XS_NOERR(xs) || XS_ERR(xs) == HBA_NOERROR) &&
2697 (*XS_STSP(xs) == SCSI_BUSY)) {
2698 XS_SETERR(xs, HBA_TGTBSY);
2699 }
2692 } else if (sp->req_header.rqs_entry_type == RQSTYPE_REQUEST) {
2700 if (IS_SCSI(isp)) {
2701 XS_RESID(xs) = sp->req_resid;
2702 if ((sp->req_state_flags & RQSF_GOT_STATUS) &&
2703 (*XS_STSP(xs) == SCSI_CHECK) &&
2704 (sp->req_state_flags & RQSF_GOT_SENSE)) {
2705 XS_SAVE_SENSE(xs, sp);
2706 }
2707 /*
2708 * A new synchronous rate was negotiated for
2709 * this target. Mark state such that we'll go
2710 * look up that which has changed later.
2711 */
2712 if (sp->req_status_flags & RQSTF_NEGOTIATION) {
2713 int t = XS_TGT(xs);
2714 sdparam *sdp = isp->isp_param;
2715 sdp += XS_CHANNEL(xs);
2716 sdp->isp_devparam[t].dev_refresh = 1;
2717 isp->isp_update |=
2718 (1 << XS_CHANNEL(xs));
2719 }
2720 } else {
2721 if (sp->req_status_flags & RQSF_XFER_COMPLETE) {
2722 XS_RESID(xs) = 0;
2723 } else if (sp->req_scsi_status & RQCS_RESID) {
2724 XS_RESID(xs) = sp->req_resid;
2725 } else {
2726 XS_RESID(xs) = 0;
2727 }
2728 if ((sp->req_state_flags & RQSF_GOT_STATUS) &&
2729 (*XS_STSP(xs) == SCSI_CHECK) &&
2730 (sp->req_scsi_status & RQCS_SV)) {
2731 XS_SAVE_SENSE(xs, sp);
2732 }
2733 }
2734 isp_prt(isp, ISP_LOGDEBUG2, "asked for %d got resid %d",
2735 XS_XFRLEN(xs), sp->req_resid);
2736 break;
2737 case RQSTYPE_REQUEST:
2693 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
2694 /*
2695 * Force Queue Full status.
2696 */
2697 *XS_STSP(xs) = SCSI_QFULL;
2698 XS_SETERR(xs, HBA_NOERROR);
2699 } else if (XS_NOERR(xs)) {
2700 XS_SETERR(xs, HBA_BOTCH);
2701 }
2738 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
2739 /*
2740 * Force Queue Full status.
2741 */
2742 *XS_STSP(xs) = SCSI_QFULL;
2743 XS_SETERR(xs, HBA_NOERROR);
2744 } else if (XS_NOERR(xs)) {
2745 XS_SETERR(xs, HBA_BOTCH);
2746 }
2702 } else {
2747 XS_RESID(xs) = XS_XFRLEN(xs);
2748 break;
2749 default:
2703 isp_prt(isp, ISP_LOGWARN,
2704 "unhandled respose queue type 0x%x",
2705 sp->req_header.rqs_entry_type);
2706 if (XS_NOERR(xs)) {
2707 XS_SETERR(xs, HBA_BOTCH);
2708 }
2750 isp_prt(isp, ISP_LOGWARN,
2751 "unhandled respose queue type 0x%x",
2752 sp->req_header.rqs_entry_type);
2753 if (XS_NOERR(xs)) {
2754 XS_SETERR(xs, HBA_BOTCH);
2755 }
2756 break;
2709 }
2757 }
2710 if (IS_SCSI(isp)) {
2711 XS_RESID(xs) = sp->req_resid;
2712 } else if (sp->req_scsi_status & RQCS_RV) {
2713 XS_RESID(xs) = sp->req_resid;
2714 isp_prt(isp, ISP_LOGDEBUG2, "cnt %d rsd %d",
2715 XS_XFRLEN(xs), sp->req_resid);
2716 }
2758
2759 /*
2760 * Free any dma resources. As a side effect, this may
2761 * also do any cache flushing necessary for data coherence. */
2717 if (XS_XFRLEN(xs)) {
2718 ISP_DMAFREE(isp, xs, sp->req_handle);
2719 }
2762 if (XS_XFRLEN(xs)) {
2763 ISP_DMAFREE(isp, xs, sp->req_handle);
2764 }
2765
2720 if (((isp->isp_dblev & (ISP_LOGDEBUG2|ISP_LOGDEBUG3))) ||
2721 ((isp->isp_dblev & ISP_LOGDEBUG1) && !XS_NOERR(xs))) {
2722 char skey;
2723 if (sp->req_state_flags & RQSF_GOT_SENSE) {
2724 skey = XS_SNSKEY(xs) & 0xf;
2725 if (skey < 10)
2726 skey += '0';
2727 else

--- 6 unchanged lines hidden (view full) ---

2734 isp_prt(isp, ISP_LOGALL, finmsg, XS_CHANNEL(xs),
2735 XS_TGT(xs), XS_LUN(xs), XS_XFRLEN(xs), XS_RESID(xs),
2736 *XS_STSP(xs), skey, XS_ERR(xs));
2737 }
2738
2739 if (isp->isp_nactive > 0)
2740 isp->isp_nactive--;
2741 complist[ndone++] = xs; /* defer completion call until later */
2766 if (((isp->isp_dblev & (ISP_LOGDEBUG2|ISP_LOGDEBUG3))) ||
2767 ((isp->isp_dblev & ISP_LOGDEBUG1) && !XS_NOERR(xs))) {
2768 char skey;
2769 if (sp->req_state_flags & RQSF_GOT_SENSE) {
2770 skey = XS_SNSKEY(xs) & 0xf;
2771 if (skey < 10)
2772 skey += '0';
2773 else

--- 6 unchanged lines hidden (view full) ---

2780 isp_prt(isp, ISP_LOGALL, finmsg, XS_CHANNEL(xs),
2781 XS_TGT(xs), XS_LUN(xs), XS_XFRLEN(xs), XS_RESID(xs),
2782 *XS_STSP(xs), skey, XS_ERR(xs));
2783 }
2784
2785 if (isp->isp_nactive > 0)
2786 isp->isp_nactive--;
2787 complist[ndone++] = xs; /* defer completion call until later */
2788 MEMZERO(sp, sizeof (isphdr_t));
2742 if (ndone == MAX_REQUESTQ_COMPLETIONS) {
2743 break;
2744 }
2745 }
2746
2747 /*
2748 * If we looked at any commands, then it's valid to find out
2749 * what the outpointer is. It also is a trigger to update the

--- 28 unchanged lines hidden (view full) ---

2778
2779 if (IS_DUALBUS(isp)) {
2780 bus = ISP_READ(isp, OUTMAILBOX6);
2781 } else {
2782 bus = 0;
2783 }
2784
2785 switch (mbox) {
2789 if (ndone == MAX_REQUESTQ_COMPLETIONS) {
2790 break;
2791 }
2792 }
2793
2794 /*
2795 * If we looked at any commands, then it's valid to find out
2796 * what the outpointer is. It also is a trigger to update the

--- 28 unchanged lines hidden (view full) ---

2825
2826 if (IS_DUALBUS(isp)) {
2827 bus = ISP_READ(isp, OUTMAILBOX6);
2828 } else {
2829 bus = 0;
2830 }
2831
2832 switch (mbox) {
2786 case MBOX_COMMAND_COMPLETE: /* sometimes these show up */
2787 break;
2788 case ASYNC_BUS_RESET:
2789 isp->isp_sendmarker |= (1 << bus);
2790#ifdef ISP_TARGET_MODE
2791 isp_target_async(isp, bus, mbox);
2792#endif
2793 isp_async(isp, ISPASYNC_BUS_RESET, &bus);
2794 break;
2795 case ASYNC_SYSTEM_ERROR:

--- 56 unchanged lines hidden (view full) ---

2852 isp_prt(isp, ISP_LOGERR, "SCSI Bus reset after DATA Overrun");
2853 break;
2854
2855 case ASYNC_BUS_TRANSIT:
2856 mbox = ISP_READ(isp, OUTMAILBOX2);
2857 switch (mbox & 0x1c00) {
2858 case SXP_PINS_LVD_MODE:
2859 isp_prt(isp, ISP_LOGINFO, "Transition to LVD mode");
2833 case ASYNC_BUS_RESET:
2834 isp->isp_sendmarker |= (1 << bus);
2835#ifdef ISP_TARGET_MODE
2836 isp_target_async(isp, bus, mbox);
2837#endif
2838 isp_async(isp, ISPASYNC_BUS_RESET, &bus);
2839 break;
2840 case ASYNC_SYSTEM_ERROR:

--- 56 unchanged lines hidden (view full) ---

2897 isp_prt(isp, ISP_LOGERR, "SCSI Bus reset after DATA Overrun");
2898 break;
2899
2900 case ASYNC_BUS_TRANSIT:
2901 mbox = ISP_READ(isp, OUTMAILBOX2);
2902 switch (mbox & 0x1c00) {
2903 case SXP_PINS_LVD_MODE:
2904 isp_prt(isp, ISP_LOGINFO, "Transition to LVD mode");
2860 ((sdparam *)isp->isp_param)->isp_diffmode = 0;
2861 ((sdparam *)isp->isp_param)->isp_ultramode = 0;
2862 ((sdparam *)isp->isp_param)->isp_lvdmode = 1;
2905 SDPARAM(isp)->isp_diffmode = 0;
2906 SDPARAM(isp)->isp_ultramode = 0;
2907 SDPARAM(isp)->isp_lvdmode = 1;
2863 break;
2864 case SXP_PINS_HVD_MODE:
2865 isp_prt(isp, ISP_LOGINFO,
2866 "Transition to Differential mode");
2908 break;
2909 case SXP_PINS_HVD_MODE:
2910 isp_prt(isp, ISP_LOGINFO,
2911 "Transition to Differential mode");
2867 ((sdparam *)isp->isp_param)->isp_diffmode = 1;
2868 ((sdparam *)isp->isp_param)->isp_ultramode = 0;
2869 ((sdparam *)isp->isp_param)->isp_lvdmode = 0;
2912 SDPARAM(isp)->isp_diffmode = 1;
2913 SDPARAM(isp)->isp_ultramode = 0;
2914 SDPARAM(isp)->isp_lvdmode = 0;
2870 break;
2871 case SXP_PINS_SE_MODE:
2872 isp_prt(isp, ISP_LOGINFO,
2873 "Transition to Single Ended mode");
2915 break;
2916 case SXP_PINS_SE_MODE:
2917 isp_prt(isp, ISP_LOGINFO,
2918 "Transition to Single Ended mode");
2874 ((sdparam *)isp->isp_param)->isp_diffmode = 0;
2875 ((sdparam *)isp->isp_param)->isp_ultramode = 1;
2876 ((sdparam *)isp->isp_param)->isp_lvdmode = 0;
2919 SDPARAM(isp)->isp_diffmode = 0;
2920 SDPARAM(isp)->isp_ultramode = 1;
2921 SDPARAM(isp)->isp_lvdmode = 0;
2877 break;
2878 default:
2879 isp_prt(isp, ISP_LOGWARN,
2880 "Transition to Unknown Mode 0x%x", mbox);
2881 break;
2882 }
2883 /*
2884 * XXX: Set up to renegotiate again!

--- 5 unchanged lines hidden (view full) ---

2890 case ASYNC_CMD_CMPLT:
2891 fast_post_handle = (ISP_READ(isp, OUTMAILBOX2) << 16) |
2892 ISP_READ(isp, OUTMAILBOX1);
2893 isp_prt(isp, ISP_LOGDEBUG3, "fast post completion of %u",
2894 fast_post_handle);
2895 break;
2896
2897 case ASYNC_CTIO_DONE:
2922 break;
2923 default:
2924 isp_prt(isp, ISP_LOGWARN,
2925 "Transition to Unknown Mode 0x%x", mbox);
2926 break;
2927 }
2928 /*
2929 * XXX: Set up to renegotiate again!

--- 5 unchanged lines hidden (view full) ---

2935 case ASYNC_CMD_CMPLT:
2936 fast_post_handle = (ISP_READ(isp, OUTMAILBOX2) << 16) |
2937 ISP_READ(isp, OUTMAILBOX1);
2938 isp_prt(isp, ISP_LOGDEBUG3, "fast post completion of %u",
2939 fast_post_handle);
2940 break;
2941
2942 case ASYNC_CTIO_DONE:
2898 /* Should only occur when Fast Posting Set for 2100s */
2899 isp_prt(isp, ISP_LOGDEBUG3, "Fast Posting CTIO done");
2943#ifdef ISP_TARGET_MODE
2944 /*
2945 * Bus gets overloaded with the handle. Dual bus
2946 * cards don't put bus# into the handle.
2947 */
2948 bus = (ISP_READ(isp, OUTMAILBOX2) << 16) |
2949 ISP_READ(isp, OUTMAILBOX1);
2950 isp_target_async(isp, bus, mbox);
2951#else
2952 isp_prt(isp, ISP_LOGINFO, "Fast Posting CTIO done");
2953#endif
2900 break;
2901
2902 case ASYNC_LIP_OCCURRED:
2954 break;
2955
2956 case ASYNC_LIP_OCCURRED:
2903 ((fcparam *) isp->isp_param)->isp_lipseq =
2957 FCPARAM(isp)->isp_lipseq =
2904 ISP_READ(isp, OUTMAILBOX1);
2958 ISP_READ(isp, OUTMAILBOX1);
2905 ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
2906 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_LIP_RCVD;
2959 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
2960 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD;
2907 isp->isp_sendmarker = 1;
2908 isp_mark_getpdb_all(isp);
2909 isp_prt(isp, ISP_LOGINFO, "LIP occurred");
2910#ifdef ISP_TARGET_MODE
2911 isp_target_async(isp, bus, mbox);
2912#endif
2913 break;
2914
2915 case ASYNC_LOOP_UP:
2916 isp->isp_sendmarker = 1;
2961 isp->isp_sendmarker = 1;
2962 isp_mark_getpdb_all(isp);
2963 isp_prt(isp, ISP_LOGINFO, "LIP occurred");
2964#ifdef ISP_TARGET_MODE
2965 isp_target_async(isp, bus, mbox);
2966#endif
2967 break;
2968
2969 case ASYNC_LOOP_UP:
2970 isp->isp_sendmarker = 1;
2917 ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
2918 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_LIP_RCVD;
2971 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
2972 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD;
2919 isp_mark_getpdb_all(isp);
2920 isp_async(isp, ISPASYNC_LOOP_UP, NULL);
2921#ifdef ISP_TARGET_MODE
2922 isp_target_async(isp, bus, mbox);
2923#endif
2924 break;
2925
2926 case ASYNC_LOOP_DOWN:
2927 isp->isp_sendmarker = 1;
2973 isp_mark_getpdb_all(isp);
2974 isp_async(isp, ISPASYNC_LOOP_UP, NULL);
2975#ifdef ISP_TARGET_MODE
2976 isp_target_async(isp, bus, mbox);
2977#endif
2978 break;
2979
2980 case ASYNC_LOOP_DOWN:
2981 isp->isp_sendmarker = 1;
2928 ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
2929 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_NIL;
2982 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
2983 FCPARAM(isp)->isp_loopstate = LOOP_NIL;
2930 isp_mark_getpdb_all(isp);
2931 isp_async(isp, ISPASYNC_LOOP_DOWN, NULL);
2932#ifdef ISP_TARGET_MODE
2933 isp_target_async(isp, bus, mbox);
2934#endif
2935 break;
2936
2937 case ASYNC_LOOP_RESET:
2938 isp->isp_sendmarker = 1;
2984 isp_mark_getpdb_all(isp);
2985 isp_async(isp, ISPASYNC_LOOP_DOWN, NULL);
2986#ifdef ISP_TARGET_MODE
2987 isp_target_async(isp, bus, mbox);
2988#endif
2989 break;
2990
2991 case ASYNC_LOOP_RESET:
2992 isp->isp_sendmarker = 1;
2939 ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
2940 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_NIL;
2993 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
2994 FCPARAM(isp)->isp_loopstate = LOOP_NIL;
2941 isp_mark_getpdb_all(isp);
2942 isp_prt(isp, ISP_LOGINFO, "Loop RESET");
2943#ifdef ISP_TARGET_MODE
2944 isp_target_async(isp, bus, mbox);
2945#endif
2946 break;
2947
2948 case ASYNC_PDB_CHANGED:
2949 isp->isp_sendmarker = 1;
2995 isp_mark_getpdb_all(isp);
2996 isp_prt(isp, ISP_LOGINFO, "Loop RESET");
2997#ifdef ISP_TARGET_MODE
2998 isp_target_async(isp, bus, mbox);
2999#endif
3000 break;
3001
3002 case ASYNC_PDB_CHANGED:
3003 isp->isp_sendmarker = 1;
2950 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_PDB_RCVD;
3004 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD;
2951 isp_mark_getpdb_all(isp);
2952 isp_prt(isp, ISP_LOGINFO, "Port Database Changed");
2953 break;
2954
2955 case ASYNC_CHANGE_NOTIFY:
2956 isp_mark_getpdb_all(isp);
2957 /*
2958 * Not correct, but it will force us to rescan the loop.
2959 */
3005 isp_mark_getpdb_all(isp);
3006 isp_prt(isp, ISP_LOGINFO, "Port Database Changed");
3007 break;
3008
3009 case ASYNC_CHANGE_NOTIFY:
3010 isp_mark_getpdb_all(isp);
3011 /*
3012 * Not correct, but it will force us to rescan the loop.
3013 */
2960 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_PDB_RCVD;
3014 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD;
2961 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, NULL);
2962 break;
2963
2964 case ASYNC_PTPMODE:
3015 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, NULL);
3016 break;
3017
3018 case ASYNC_PTPMODE:
2965 if (((fcparam *) isp->isp_param)->isp_onfabric)
2966 ((fcparam *) isp->isp_param)->isp_topo = TOPO_N_PORT;
3019 if (FCPARAM(isp)->isp_onfabric)
3020 FCPARAM(isp)->isp_topo = TOPO_N_PORT;
2967 else
3021 else
2968 ((fcparam *) isp->isp_param)->isp_topo = TOPO_F_PORT;
3022 FCPARAM(isp)->isp_topo = TOPO_F_PORT;
2969 isp_mark_getpdb_all(isp);
2970 isp->isp_sendmarker = 1;
3023 isp_mark_getpdb_all(isp);
3024 isp->isp_sendmarker = 1;
2971 ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
2972 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_LIP_RCVD;
3025 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
3026 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD;
2973#ifdef ISP_TARGET_MODE
2974 isp_target_async(isp, bus, mbox);
2975#endif
2976 isp_prt(isp, ISP_LOGINFO, "Point-to-Point mode");
2977 break;
2978
2979 case ASYNC_CONNMODE:
2980 mbox = ISP_READ(isp, OUTMAILBOX1);

--- 35 unchanged lines hidden (view full) ---

3016
3017static int
3018isp_handle_other_response(isp, sp, optrp)
3019 struct ispsoftc *isp;
3020 ispstatusreq_t *sp;
3021 u_int16_t *optrp;
3022{
3023 switch (sp->req_header.rqs_entry_type) {
3027#ifdef ISP_TARGET_MODE
3028 isp_target_async(isp, bus, mbox);
3029#endif
3030 isp_prt(isp, ISP_LOGINFO, "Point-to-Point mode");
3031 break;
3032
3033 case ASYNC_CONNMODE:
3034 mbox = ISP_READ(isp, OUTMAILBOX1);

--- 35 unchanged lines hidden (view full) ---

3070
3071static int
3072isp_handle_other_response(isp, sp, optrp)
3073 struct ispsoftc *isp;
3074 ispstatusreq_t *sp;
3075 u_int16_t *optrp;
3076{
3077 switch (sp->req_header.rqs_entry_type) {
3078 case RQSTYPE_STATUS_CONT:
3079 isp_prt(isp, ISP_LOGINFO, "Ignored Continuation Response");
3080 return (0);
3024 case RQSTYPE_ATIO:
3025 case RQSTYPE_CTIO:
3026 case RQSTYPE_ENABLE_LUN:
3027 case RQSTYPE_MODIFY_LUN:
3028 case RQSTYPE_NOTIFY:
3029 case RQSTYPE_NOTIFY_ACK:
3030 case RQSTYPE_CTIO1:
3031 case RQSTYPE_ATIO2:

--- 23 unchanged lines hidden (view full) ---

3055 case RQCS_COMPLETE:
3056 if (XS_NOERR(xs)) {
3057 XS_SETERR(xs, HBA_NOERROR);
3058 }
3059 return;
3060
3061 case RQCS_INCOMPLETE:
3062 if ((sp->req_state_flags & RQSF_GOT_TARGET) == 0) {
3081 case RQSTYPE_ATIO:
3082 case RQSTYPE_CTIO:
3083 case RQSTYPE_ENABLE_LUN:
3084 case RQSTYPE_MODIFY_LUN:
3085 case RQSTYPE_NOTIFY:
3086 case RQSTYPE_NOTIFY_ACK:
3087 case RQSTYPE_CTIO1:
3088 case RQSTYPE_ATIO2:

--- 23 unchanged lines hidden (view full) ---

3112 case RQCS_COMPLETE:
3113 if (XS_NOERR(xs)) {
3114 XS_SETERR(xs, HBA_NOERROR);
3115 }
3116 return;
3117
3118 case RQCS_INCOMPLETE:
3119 if ((sp->req_state_flags & RQSF_GOT_TARGET) == 0) {
3063 isp_prt(isp, ISP_LOGDEBUG0,
3120 isp_prt(isp, ISP_LOGDEBUG1,
3064 "Selection Timeout for %d.%d.%d",
3065 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
3066 if (XS_NOERR(xs)) {
3067 XS_SETERR(xs, HBA_SELTIMEOUT);
3068 }
3069 return;
3070 }
3071 isp_prt(isp, ISP_LOGERR,

--- 86 unchanged lines hidden (view full) ---

3158 isp_prt(isp, ISP_LOGWARN, "command timed out for %d.%d.%d",
3159 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3160 if (XS_NOERR(xs)) {
3161 XS_SETERR(xs, HBA_CMDTIMEOUT);
3162 }
3163 return;
3164
3165 case RQCS_DATA_OVERRUN:
3121 "Selection Timeout for %d.%d.%d",
3122 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
3123 if (XS_NOERR(xs)) {
3124 XS_SETERR(xs, HBA_SELTIMEOUT);
3125 }
3126 return;
3127 }
3128 isp_prt(isp, ISP_LOGERR,

--- 86 unchanged lines hidden (view full) ---

3215 isp_prt(isp, ISP_LOGWARN, "command timed out for %d.%d.%d",
3216 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3217 if (XS_NOERR(xs)) {
3218 XS_SETERR(xs, HBA_CMDTIMEOUT);
3219 }
3220 return;
3221
3222 case RQCS_DATA_OVERRUN:
3166 if (IS_FC(isp)) {
3167 XS_RESID(xs) = sp->req_resid;
3168 break;
3169 }
3223 XS_RESID(xs) = sp->req_resid;
3170 isp_prt(isp, ISP_LOGERR, "data overrun for command on %d.%d.%d",
3171 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3172 if (XS_NOERR(xs)) {
3173 XS_SETERR(xs, HBA_DATAOVR);
3174 }
3175 return;
3176
3177 case RQCS_COMMAND_OVERRUN:

--- 64 unchanged lines hidden (view full) ---

3242 break;
3243
3244 case RQCS_UNEXP_BUS_FREE:
3245 isp_prt(isp, ISP_LOGERR, "%d.%d.%d had an unexpected bus free",
3246 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3247 break;
3248
3249 case RQCS_DATA_UNDERRUN:
3224 isp_prt(isp, ISP_LOGERR, "data overrun for command on %d.%d.%d",
3225 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3226 if (XS_NOERR(xs)) {
3227 XS_SETERR(xs, HBA_DATAOVR);
3228 }
3229 return;
3230
3231 case RQCS_COMMAND_OVERRUN:

--- 64 unchanged lines hidden (view full) ---

3296 break;
3297
3298 case RQCS_UNEXP_BUS_FREE:
3299 isp_prt(isp, ISP_LOGERR, "%d.%d.%d had an unexpected bus free",
3300 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3301 break;
3302
3303 case RQCS_DATA_UNDERRUN:
3250 if (IS_FC(isp)) {
3251 XS_RESID(xs) = sp->req_resid;
3252 }
3304 XS_RESID(xs) = sp->req_resid;
3253 if (XS_NOERR(xs)) {
3254 XS_SETERR(xs, HBA_NOERROR);
3255 }
3256 return;
3257
3258 case RQCS_XACT_ERR1:
3259 isp_prt(isp, ISP_LOGERR, xact1, XS_CHANNEL(xs),
3260 XS_TGT(xs), XS_LUN(xs));

--- 148 unchanged lines hidden (view full) ---

3409 * that all data transferred.
3410 */
3411 XS_SET_STATE_STAT(isp, xs, NULL);
3412 XS_RESID(xs) = 0;
3413 *XS_STSP(xs) = SCSI_GOOD;
3414 if (XS_XFRLEN(xs)) {
3415 ISP_DMAFREE(isp, xs, fph);
3416 }
3305 if (XS_NOERR(xs)) {
3306 XS_SETERR(xs, HBA_NOERROR);
3307 }
3308 return;
3309
3310 case RQCS_XACT_ERR1:
3311 isp_prt(isp, ISP_LOGERR, xact1, XS_CHANNEL(xs),
3312 XS_TGT(xs), XS_LUN(xs));

--- 148 unchanged lines hidden (view full) ---

3461 * that all data transferred.
3462 */
3463 XS_SET_STATE_STAT(isp, xs, NULL);
3464 XS_RESID(xs) = 0;
3465 *XS_STSP(xs) = SCSI_GOOD;
3466 if (XS_XFRLEN(xs)) {
3467 ISP_DMAFREE(isp, xs, fph);
3468 }
3417 isp_done(xs);
3418 if (isp->isp_nactive)
3419 isp->isp_nactive--;
3469 if (isp->isp_nactive)
3470 isp->isp_nactive--;
3471 isp_done(xs);
3420}
3421
3422#define HIBYT(x) ((x) >> 0x8)
3423#define LOBYT(x) ((x) & 0xff)
3424#define ISPOPMAP(a, b) (((a) << 8) | (b))
3425static u_int16_t mbpscsi[] = {
3426 ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */
3427 ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */

--- 607 unchanged lines hidden (view full) ---

4035 fcp->isp_fwstate = mbs.param[1];
4036 }
4037}
4038
4039static void
4040isp_update(isp)
4041 struct ispsoftc *isp;
4042{
3472}
3473
3474#define HIBYT(x) ((x) >> 0x8)
3475#define LOBYT(x) ((x) & 0xff)
3476#define ISPOPMAP(a, b) (((a) << 8) | (b))
3477static u_int16_t mbpscsi[] = {
3478 ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */
3479 ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */

--- 607 unchanged lines hidden (view full) ---

4087 fcp->isp_fwstate = mbs.param[1];
4088 }
4089}
4090
4091static void
4092isp_update(isp)
4093 struct ispsoftc *isp;
4094{
4043 int bus;
4095 int bus, upmask;
4044
4096
4045 for (bus = 0; isp->isp_update != 0; bus++) {
4046 if (isp->isp_update & (1 << bus)) {
4097 for (bus = 0, upmask = isp->isp_update; upmask != 0; bus++) {
4098 if (upmask & (1 << bus)) {
4047 isp_update_bus(isp, bus);
4099 isp_update_bus(isp, bus);
4048 isp->isp_update ^= (1 << bus);
4049 }
4100 }
4101 upmask &= ~(1 << bus);
4050 }
4051}
4052
4053static void
4054isp_update_bus(isp, bus)
4055 struct ispsoftc *isp;
4056 int bus;
4057{
4058 int tgt;
4059 mbreg_t mbs;
4060 sdparam *sdp;
4061
4102 }
4103}
4104
4105static void
4106isp_update_bus(isp, bus)
4107 struct ispsoftc *isp;
4108 int bus;
4109{
4110 int tgt;
4111 mbreg_t mbs;
4112 sdparam *sdp;
4113
4114 isp->isp_update &= ~(1 << bus);
4062 if (IS_FC(isp)) {
4115 if (IS_FC(isp)) {
4116 /*
4117 * There are no 'per-bus' settings for Fibre Channel.
4118 */
4063 return;
4064 }
4119 return;
4120 }
4065
4066 sdp = isp->isp_param;
4067 sdp += bus;
4068
4069 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
4070 u_int16_t flags, period, offset;
4071 int get;
4072
4073 if (sdp->isp_devparam[tgt].dev_enable == 0) {
4121 sdp = isp->isp_param;
4122 sdp += bus;
4123
4124 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
4125 u_int16_t flags, period, offset;
4126 int get;
4127
4128 if (sdp->isp_devparam[tgt].dev_enable == 0) {
4129 sdp->isp_devparam[tgt].dev_update = 0;
4130 sdp->isp_devparam[tgt].dev_refresh = 0;
4074 isp_prt(isp, ISP_LOGDEBUG1,
4075 "skipping target %d bus %d update", tgt, bus);
4076 continue;
4077 }
4131 isp_prt(isp, ISP_LOGDEBUG1,
4132 "skipping target %d bus %d update", tgt, bus);
4133 continue;
4134 }
4078
4079 /*
4080 * If the goal is to update the status of the device,
4081 * take what's in dev_flags and try and set the device
4082 * toward that. Otherwise, if we're just refreshing the
4083 * current device state, get the current parameters.
4084 */
4135 /*
4136 * If the goal is to update the status of the device,
4137 * take what's in dev_flags and try and set the device
4138 * toward that. Otherwise, if we're just refreshing the
4139 * current device state, get the current parameters.
4140 */
4085 if (sdp->isp_devparam[tgt].dev_update) {
4141
4142 /*
4143 * Refresh overrides set
4144 */
4145 if (sdp->isp_devparam[tgt].dev_refresh) {
4146 mbs.param[0] = MBOX_GET_TARGET_PARAMS;
4147 sdp->isp_devparam[tgt].dev_refresh = 0;
4148 get = 1;
4149 } else if (sdp->isp_devparam[tgt].dev_update) {
4086 mbs.param[0] = MBOX_SET_TARGET_PARAMS;
4150 mbs.param[0] = MBOX_SET_TARGET_PARAMS;
4151 /*
4152 * Make sure dev_flags has "Renegotiate on Error"
4153 * on and "Freeze Queue on Error" off.
4154 */
4155 sdp->isp_devparam[tgt].dev_flags |= DPARM_RENEG;
4156 sdp->isp_devparam[tgt].dev_flags &= ~DPARM_QFRZ;
4157
4087 mbs.param[2] = sdp->isp_devparam[tgt].dev_flags;
4158 mbs.param[2] = sdp->isp_devparam[tgt].dev_flags;
4159
4088 /*
4160 /*
4089 * Insist that PARITY must be enabled if SYNC
4090 * is enabled.
4161 * Insist that PARITY must be enabled
4162 * if SYNC or WIDE is enabled.
4091 */
4163 */
4092 if (mbs.param[2] & DPARM_SYNC) {
4164 if ((mbs.param[2] & (DPARM_SYNC|DPARM_WIDE)) != 0) {
4093 mbs.param[2] |= DPARM_PARITY;
4094 }
4165 mbs.param[2] |= DPARM_PARITY;
4166 }
4095 mbs.param[3] =
4096 (sdp->isp_devparam[tgt].sync_offset << 8) |
4097 (sdp->isp_devparam[tgt].sync_period);
4098 sdp->isp_devparam[tgt].dev_update = 0;
4167
4168 if ((mbs.param[2] & DPARM_SYNC) == 0) {
4169 mbs.param[3] = 0;
4170 } else {
4171 mbs.param[3] =
4172 (sdp->isp_devparam[tgt].sync_offset << 8) |
4173 (sdp->isp_devparam[tgt].sync_period);
4174 }
4099 /*
4100 * A command completion later that has
4175 /*
4176 * A command completion later that has
4101 * RQSTF_NEGOTIATION set will cause
4102 * the dev_refresh/announce cycle.
4177 * RQSTF_NEGOTIATION set canl cause
4178 * the dev_refresh/announce cycle also.
4179 &
4103 *
4104 * Note: It is really important to update our current
4105 * flags with at least the state of TAG capabilities-
4106 * otherwise we might try and send a tagged command
4107 * when we have it all turned off. So change it here
4108 * to say that current already matches goal.
4109 */
4110 sdp->isp_devparam[tgt].cur_dflags &= ~DPARM_TQING;
4111 sdp->isp_devparam[tgt].cur_dflags |=
4112 (sdp->isp_devparam[tgt].dev_flags & DPARM_TQING);
4180 *
4181 * Note: It is really important to update our current
4182 * flags with at least the state of TAG capabilities-
4183 * otherwise we might try and send a tagged command
4184 * when we have it all turned off. So change it here
4185 * to say that current already matches goal.
4186 */
4187 sdp->isp_devparam[tgt].cur_dflags &= ~DPARM_TQING;
4188 sdp->isp_devparam[tgt].cur_dflags |=
4189 (sdp->isp_devparam[tgt].dev_flags & DPARM_TQING);
4113 sdp->isp_devparam[tgt].dev_refresh = 1;
4114 isp_prt(isp, ISP_LOGDEBUG2,
4115 "bus %d set tgt %d flags 0x%x off 0x%x period 0x%x",
4116 bus, tgt, mbs.param[2], mbs.param[3] >> 8,
4117 mbs.param[3] & 0xff);
4190 isp_prt(isp, ISP_LOGDEBUG2,
4191 "bus %d set tgt %d flags 0x%x off 0x%x period 0x%x",
4192 bus, tgt, mbs.param[2], mbs.param[3] >> 8,
4193 mbs.param[3] & 0xff);
4194 sdp->isp_devparam[tgt].dev_update = 0;
4195 sdp->isp_devparam[tgt].dev_refresh = 1;
4118 get = 0;
4196 get = 0;
4119 } else if (sdp->isp_devparam[tgt].dev_refresh) {
4120 mbs.param[0] = MBOX_GET_TARGET_PARAMS;
4121 sdp->isp_devparam[tgt].dev_refresh = 0;
4122 get = 1;
4123 } else {
4124 continue;
4125 }
4126 mbs.param[1] = (bus << 15) | (tgt << 8) ;
4127 isp_mboxcmd(isp, &mbs, MBLOGALL);
4128 if (get == 0) {
4129 isp->isp_sendmarker |= (1 << bus);
4130 continue;
4131 }
4132 flags = mbs.param[2];
4133 period = mbs.param[3] & 0xff;
4134 offset = mbs.param[3] >> 8;
4135 sdp->isp_devparam[tgt].cur_dflags = flags;
4136 sdp->isp_devparam[tgt].cur_period = period;
4137 sdp->isp_devparam[tgt].cur_offset = offset;
4138 get = (bus << 16) | tgt;
4139 (void) isp_async(isp, ISPASYNC_NEW_TGT_PARAMS, &get);
4140 }
4197 } else {
4198 continue;
4199 }
4200 mbs.param[1] = (bus << 15) | (tgt << 8) ;
4201 isp_mboxcmd(isp, &mbs, MBLOGALL);
4202 if (get == 0) {
4203 isp->isp_sendmarker |= (1 << bus);
4204 continue;
4205 }
4206 flags = mbs.param[2];
4207 period = mbs.param[3] & 0xff;
4208 offset = mbs.param[3] >> 8;
4209 sdp->isp_devparam[tgt].cur_dflags = flags;
4210 sdp->isp_devparam[tgt].cur_period = period;
4211 sdp->isp_devparam[tgt].cur_offset = offset;
4212 get = (bus << 16) | tgt;
4213 (void) isp_async(isp, ISPASYNC_NEW_TGT_PARAMS, &get);
4214 }
4215
4216 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
4217 if (sdp->isp_devparam[tgt].dev_update ||
4218 sdp->isp_devparam[tgt].dev_refresh) {
4219 isp->isp_update |= (1 << bus);
4220 break;
4221 }
4222 }
4141}
4142
4143static void
4144isp_setdfltparm(isp, channel)
4145 struct ispsoftc *isp;
4146 int channel;
4147{
4148 int tgt;

--- 4 unchanged lines hidden (view full) ---

4153 fcparam *fcp = (fcparam *) isp->isp_param;
4154 fcp += channel;
4155 if (fcp->isp_gotdparms) {
4156 return;
4157 }
4158 fcp->isp_gotdparms = 1;
4159 fcp->isp_maxfrmlen = ICB_DFLT_FRMLEN;
4160 fcp->isp_maxalloc = ICB_DFLT_ALLOC;
4223}
4224
4225static void
4226isp_setdfltparm(isp, channel)
4227 struct ispsoftc *isp;
4228 int channel;
4229{
4230 int tgt;

--- 4 unchanged lines hidden (view full) ---

4235 fcparam *fcp = (fcparam *) isp->isp_param;
4236 fcp += channel;
4237 if (fcp->isp_gotdparms) {
4238 return;
4239 }
4240 fcp->isp_gotdparms = 1;
4241 fcp->isp_maxfrmlen = ICB_DFLT_FRMLEN;
4242 fcp->isp_maxalloc = ICB_DFLT_ALLOC;
4161 fcp->isp_execthrottle = ICB_DFLT_THROTTLE;
4243 fcp->isp_execthrottle = ISP_EXEC_THROTTLE;
4162 fcp->isp_retry_delay = ICB_DFLT_RDELAY;
4163 fcp->isp_retry_count = ICB_DFLT_RCOUNT;
4164 /* Platform specific.... */
4165 fcp->isp_loopid = DEFAULT_LOOPID(isp);
4166 fcp->isp_nodewwn = DEFAULT_NODEWWN(isp);
4167 fcp->isp_portwwn = DEFAULT_PORTWWN(isp);
4244 fcp->isp_retry_delay = ICB_DFLT_RDELAY;
4245 fcp->isp_retry_count = ICB_DFLT_RCOUNT;
4246 /* Platform specific.... */
4247 fcp->isp_loopid = DEFAULT_LOOPID(isp);
4248 fcp->isp_nodewwn = DEFAULT_NODEWWN(isp);
4249 fcp->isp_portwwn = DEFAULT_PORTWWN(isp);
4250 fcp->isp_fwoptions = 0;
4251 fcp->isp_fwoptions |= ICBOPT_FAIRNESS;
4252 fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
4253 fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS;
4254#ifndef ISP_NO_FASTPOST_FC
4255 fcp->isp_fwoptions |= ICBOPT_FAST_POST;
4256#endif
4257 if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX)
4258 fcp->isp_fwoptions |= ICBOPT_FULL_DUPLEX;
4168
4169 /*
4259
4260 /*
4261 * Make sure this is turned off now until we get
4262 * extended options from NVRAM
4263 */
4264 fcp->isp_fwoptions &= ~ICBOPT_EXTENDED;
4265
4266 /*
4170 * Now try and read NVRAM
4171 */
4172 if ((isp->isp_confopts & (ISP_CFG_NONVRAM|ISP_CFG_OWNWWN)) ||
4173 (isp_read_nvram(isp))) {
4174 isp_prt(isp, ISP_LOGINFO,
4175 "Node WWN 0x%08x%08x, Port WWN 0x%08x%08x",
4176 (u_int32_t) (fcp->isp_nodewwn >> 32),
4177 (u_int32_t) (fcp->isp_nodewwn & 0xffffffff),

--- 73 unchanged lines hidden (view full) ---

4251 (isp->isp_bustype == ISP_BT_PCI &&
4252 isp->isp_type < ISP_HA_SCSI_1040) ||
4253 (isp->isp_clock && isp->isp_clock < 60) ||
4254 (sdp->isp_ultramode == 0)) {
4255 sdp->isp_devparam[tgt].sync_offset =
4256 ISP_10M_SYNCPARMS >> 8;
4257 sdp->isp_devparam[tgt].sync_period =
4258 ISP_10M_SYNCPARMS & 0xff;
4267 * Now try and read NVRAM
4268 */
4269 if ((isp->isp_confopts & (ISP_CFG_NONVRAM|ISP_CFG_OWNWWN)) ||
4270 (isp_read_nvram(isp))) {
4271 isp_prt(isp, ISP_LOGINFO,
4272 "Node WWN 0x%08x%08x, Port WWN 0x%08x%08x",
4273 (u_int32_t) (fcp->isp_nodewwn >> 32),
4274 (u_int32_t) (fcp->isp_nodewwn & 0xffffffff),

--- 73 unchanged lines hidden (view full) ---

4348 (isp->isp_bustype == ISP_BT_PCI &&
4349 isp->isp_type < ISP_HA_SCSI_1040) ||
4350 (isp->isp_clock && isp->isp_clock < 60) ||
4351 (sdp->isp_ultramode == 0)) {
4352 sdp->isp_devparam[tgt].sync_offset =
4353 ISP_10M_SYNCPARMS >> 8;
4354 sdp->isp_devparam[tgt].sync_period =
4355 ISP_10M_SYNCPARMS & 0xff;
4356 } else if (IS_ULTRA3(isp)) {
4357 sdp->isp_devparam[tgt].sync_offset =
4358 ISP_80M_SYNCPARMS >> 8;
4359 sdp->isp_devparam[tgt].sync_period =
4360 ISP_80M_SYNCPARMS & 0xff;
4259 } else if (IS_ULTRA2(isp)) {
4260 sdp->isp_devparam[tgt].sync_offset =
4261 ISP_40M_SYNCPARMS >> 8;
4262 sdp->isp_devparam[tgt].sync_period =
4263 ISP_40M_SYNCPARMS & 0xff;
4361 } else if (IS_ULTRA2(isp)) {
4362 sdp->isp_devparam[tgt].sync_offset =
4363 ISP_40M_SYNCPARMS >> 8;
4364 sdp->isp_devparam[tgt].sync_period =
4365 ISP_40M_SYNCPARMS & 0xff;
4264 } else {
4366 } else if (IS_1240(isp)) {
4265 sdp->isp_devparam[tgt].sync_offset =
4266 ISP_20M_SYNCPARMS >> 8;
4267 sdp->isp_devparam[tgt].sync_period =
4268 ISP_20M_SYNCPARMS & 0xff;
4367 sdp->isp_devparam[tgt].sync_offset =
4368 ISP_20M_SYNCPARMS >> 8;
4369 sdp->isp_devparam[tgt].sync_period =
4370 ISP_20M_SYNCPARMS & 0xff;
4371 } else {
4372 sdp->isp_devparam[tgt].sync_offset =
4373 ISP_20M_SYNCPARMS_1040 >> 8;
4374 sdp->isp_devparam[tgt].sync_period =
4375 ISP_20M_SYNCPARMS_1040 & 0xff;
4269 }
4270
4271 /*
4272 * Don't get current target parameters if we've been
4273 * told not to use NVRAM- it's really the same thing.
4274 */
4275 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
4276

--- 31 unchanged lines hidden (view full) ---

4308 (ISP_20M_SYNCPARMS & 0xff))) {
4309 sdp->isp_devparam[tgt].sync_offset =
4310 ISP_10M_SYNCPARMS >> 8;
4311 sdp->isp_devparam[tgt].sync_period =
4312 ISP_10M_SYNCPARMS & 0xff;
4313 }
4314 }
4315 isp_prt(isp, ISP_LOGDEBUG1,
4376 }
4377
4378 /*
4379 * Don't get current target parameters if we've been
4380 * told not to use NVRAM- it's really the same thing.
4381 */
4382 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
4383

--- 31 unchanged lines hidden (view full) ---

4415 (ISP_20M_SYNCPARMS & 0xff))) {
4416 sdp->isp_devparam[tgt].sync_offset =
4417 ISP_10M_SYNCPARMS >> 8;
4418 sdp->isp_devparam[tgt].sync_period =
4419 ISP_10M_SYNCPARMS & 0xff;
4420 }
4421 }
4422 isp_prt(isp, ISP_LOGDEBUG1,
4316 "bus %d tgt %d flags %x offset %x period %x",
4423 "Initial bus %d tgt %d flags %x offset %x period %x",
4317 channel, tgt, sdp->isp_devparam[tgt].dev_flags,
4318 sdp->isp_devparam[tgt].sync_offset,
4319 sdp->isp_devparam[tgt].sync_period);
4320 }
4321
4322 /*
4323 * Establish default some more default parameters.
4324 */

--- 9 unchanged lines hidden (view full) ---

4334 sdp->isp_selection_timeout = 250;
4335 sdp->isp_max_queue_depth = MAXISPREQUEST(isp);
4336 sdp->isp_tag_aging = 8;
4337 sdp->isp_bus_reset_delay = 3;
4338 sdp->isp_retry_count = 2;
4339 sdp->isp_retry_delay = 2;
4340
4341 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
4424 channel, tgt, sdp->isp_devparam[tgt].dev_flags,
4425 sdp->isp_devparam[tgt].sync_offset,
4426 sdp->isp_devparam[tgt].sync_period);
4427 }
4428
4429 /*
4430 * Establish default some more default parameters.
4431 */

--- 9 unchanged lines hidden (view full) ---

4441 sdp->isp_selection_timeout = 250;
4442 sdp->isp_max_queue_depth = MAXISPREQUEST(isp);
4443 sdp->isp_tag_aging = 8;
4444 sdp->isp_bus_reset_delay = 3;
4445 sdp->isp_retry_count = 2;
4446 sdp->isp_retry_delay = 2;
4447
4448 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
4342 sdp->isp_devparam[tgt].exc_throttle = 16;
4449 sdp->isp_devparam[tgt].exc_throttle = ISP_EXEC_THROTTLE;
4343 sdp->isp_devparam[tgt].dev_enable = 1;
4344 }
4345}
4346
4347/*
4348 * Re-initialize the ISP and complete all orphaned commands
4349 * with a 'botched' notice. The reset/init routines should
4350 * not disturb an already active list of commands.

--- 233 unchanged lines hidden (view full) ---

4584 ISP_NVRAM_TAG_AGE_LIMIT(nvram_data);
4585
4586 sdp->isp_selection_timeout =
4587 ISP_NVRAM_SELECTION_TIMEOUT(nvram_data);
4588
4589 sdp->isp_max_queue_depth =
4590 ISP_NVRAM_MAX_QUEUE_DEPTH(nvram_data);
4591
4450 sdp->isp_devparam[tgt].dev_enable = 1;
4451 }
4452}
4453
4454/*
4455 * Re-initialize the ISP and complete all orphaned commands
4456 * with a 'botched' notice. The reset/init routines should
4457 * not disturb an already active list of commands.

--- 233 unchanged lines hidden (view full) ---

4691 ISP_NVRAM_TAG_AGE_LIMIT(nvram_data);
4692
4693 sdp->isp_selection_timeout =
4694 ISP_NVRAM_SELECTION_TIMEOUT(nvram_data);
4695
4696 sdp->isp_max_queue_depth =
4697 ISP_NVRAM_MAX_QUEUE_DEPTH(nvram_data);
4698
4592 isp->isp_fast_mttr = ISP_NVRAM_FAST_MTTR_ENABLE(nvram_data);
4699 sdp->isp_fast_mttr = ISP_NVRAM_FAST_MTTR_ENABLE(nvram_data);
4593 for (i = 0; i < MAX_TARGETS; i++) {
4594 sdp->isp_devparam[i].dev_enable =
4595 ISP_NVRAM_TGT_DEVICE_ENABLE(nvram_data, i);
4596 sdp->isp_devparam[i].exc_throttle =
4597 ISP_NVRAM_TGT_EXEC_THROTTLE(nvram_data, i);
4598 sdp->isp_devparam[i].sync_offset =
4599 ISP_NVRAM_TGT_SYNC_OFFSET(nvram_data, i);
4600 sdp->isp_devparam[i].sync_period =

--- 242 unchanged lines hidden ---
4700 for (i = 0; i < MAX_TARGETS; i++) {
4701 sdp->isp_devparam[i].dev_enable =
4702 ISP_NVRAM_TGT_DEVICE_ENABLE(nvram_data, i);
4703 sdp->isp_devparam[i].exc_throttle =
4704 ISP_NVRAM_TGT_EXEC_THROTTLE(nvram_data, i);
4705 sdp->isp_devparam[i].sync_offset =
4706 ISP_NVRAM_TGT_SYNC_OFFSET(nvram_data, i);
4707 sdp->isp_devparam[i].sync_period =

--- 242 unchanged lines hidden ---