Deleted Added
full compact
isp.c (85395) isp.c (87635)
1/* $FreeBSD: head/sys/dev/isp/isp.c 85395 2001-10-23 23:05:20Z mjacob $ */
1/* $FreeBSD: head/sys/dev/isp/isp.c 87635 2001-12-11 00:18:45Z 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, 2000, 2001 by Matthew Jacob
7 * Feral Software
8 * All rights reserved.
9 *

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

104 "%s RAAN 0x%x DLAN 0x%x DDMAB 0x%x CDMAB 0x%x SELTIME %d MQD %d";
105static const char sc2[] = "%s CHAN %d TGT %d FLAGS 0x%x 0x%x/0x%x";
106static const char sc3[] = "Generated";
107static const char sc4[] = "NVRAM";
108
109/*
110 * Local function prototypes.
111 */
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, 2000, 2001 by Matthew Jacob
7 * Feral Software
8 * All rights reserved.
9 *

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

104 "%s RAAN 0x%x DLAN 0x%x DDMAB 0x%x CDMAB 0x%x SELTIME %d MQD %d";
105static const char sc2[] = "%s CHAN %d TGT %d FLAGS 0x%x 0x%x/0x%x";
106static const char sc3[] = "Generated";
107static const char sc4[] = "NVRAM";
108
109/*
110 * Local function prototypes.
111 */
112static int isp_parse_async __P((struct ispsoftc *, int));
113static int isp_handle_other_response
114__P((struct ispsoftc *, ispstatusreq_t *, u_int16_t *));
115static void isp_parse_status
116__P((struct ispsoftc *, ispstatusreq_t *, XS_T *));
117static void isp_fastpost_complete __P((struct ispsoftc *, u_int16_t));
118static void isp_scsi_init __P((struct ispsoftc *));
119static void isp_scsi_channel_init __P((struct ispsoftc *, int));
120static void isp_fibre_init __P((struct ispsoftc *));
121static void isp_mark_getpdb_all __P((struct ispsoftc *));
122static int isp_getmap __P((struct ispsoftc *, fcpos_map_t *));
123static int isp_getpdb __P((struct ispsoftc *, int, isp_pdb_t *));
124static u_int64_t isp_get_portname __P((struct ispsoftc *, int, int));
125static int isp_fclink_test __P((struct ispsoftc *, int));
126static char *isp2100_fw_statename __P((int));
127static int isp_pdb_sync __P((struct ispsoftc *));
128static int isp_scan_loop __P((struct ispsoftc *));
129static int isp_scan_fabric __P((struct ispsoftc *));
130static void isp_register_fc4_type __P((struct ispsoftc *));
131static void isp_fw_state __P((struct ispsoftc *));
132static void isp_mboxcmd __P((struct ispsoftc *, mbreg_t *, int));
112static int isp_parse_async(struct ispsoftc *, int);
113static int isp_handle_other_response(struct ispsoftc *, int, isphdr_t *,
114 u_int16_t *);
115static void
116isp_parse_status(struct ispsoftc *, ispstatusreq_t *, XS_T *);
117static void isp_fastpost_complete(struct ispsoftc *, u_int16_t);
118static void isp_scsi_init(struct ispsoftc *);
119static void isp_scsi_channel_init(struct ispsoftc *, int);
120static void isp_fibre_init(struct ispsoftc *);
121static void isp_mark_getpdb_all(struct ispsoftc *);
122static int isp_getmap(struct ispsoftc *, fcpos_map_t *);
123static int isp_getpdb(struct ispsoftc *, int, isp_pdb_t *);
124static u_int64_t isp_get_portname(struct ispsoftc *, int, int);
125static int isp_fclink_test(struct ispsoftc *, int);
126static char *isp2100_fw_statename(int);
127static int isp_pdb_sync(struct ispsoftc *);
128static int isp_scan_loop(struct ispsoftc *);
129static int isp_scan_fabric(struct ispsoftc *);
130static void isp_register_fc4_type(struct ispsoftc *);
131static void isp_fw_state(struct ispsoftc *);
132static void isp_mboxcmd(struct ispsoftc *, mbreg_t *, int);
133
133
134static void isp_update __P((struct ispsoftc *));
135static void isp_update_bus __P((struct ispsoftc *, int));
136static void isp_setdfltparm __P((struct ispsoftc *, int));
137static int isp_read_nvram __P((struct ispsoftc *));
138static void isp_rdnvram_word __P((struct ispsoftc *, int, u_int16_t *));
139static void isp_parse_nvram_1020 __P((struct ispsoftc *, u_int8_t *));
140static void isp_parse_nvram_1080 __P((struct ispsoftc *, int, u_int8_t *));
141static void isp_parse_nvram_12160 __P((struct ispsoftc *, int, u_int8_t *));
142static void isp_parse_nvram_2100 __P((struct ispsoftc *, u_int8_t *));
134static void isp_update(struct ispsoftc *);
135static void isp_update_bus(struct ispsoftc *, int);
136static void isp_setdfltparm(struct ispsoftc *, int);
137static int isp_read_nvram(struct ispsoftc *);
138static void isp_rdnvram_word(struct ispsoftc *, int, u_int16_t *);
139static void isp_parse_nvram_1020(struct ispsoftc *, u_int8_t *);
140static void isp_parse_nvram_1080(struct ispsoftc *, int, u_int8_t *);
141static void isp_parse_nvram_12160(struct ispsoftc *, int, u_int8_t *);
142static void isp_parse_nvram_2100(struct ispsoftc *, u_int8_t *);
143
144/*
145 * Reset Hardware.
146 *
147 * Hit the chip over the head, download new f/w if available and set it running.
148 *
149 * Locking done elsewhere.
150 */

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

687 return;
688 }
689
690 /*
691 * The SBus firmware that we are using apparently does not return
692 * major, minor, micro revisions in the mailbox registers, which
693 * is really, really, annoying.
694 */
143
144/*
145 * Reset Hardware.
146 *
147 * Hit the chip over the head, download new f/w if available and set it running.
148 *
149 * Locking done elsewhere.
150 */

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

687 return;
688 }
689
690 /*
691 * The SBus firmware that we are using apparently does not return
692 * major, minor, micro revisions in the mailbox registers, which
693 * is really, really, annoying.
694 */
695 if (isp->isp_bustype == ISP_BT_SBUS) {
695 if (ISP_SBUS_SUPPORTED && isp->isp_bustype == ISP_BT_SBUS) {
696 if (dodnld) {
697#ifdef ISP_TARGET_MODE
698 isp->isp_fwrev[0] = 7;
699 isp->isp_fwrev[1] = 55;
700#else
701 isp->isp_fwrev[0] = 1;
702 isp->isp_fwrev[1] = 37;
703#endif

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

1102 * Fibre Channel specific initialization.
1103 *
1104 * Locks are held before coming here.
1105 */
1106static void
1107isp_fibre_init(struct ispsoftc *isp)
1108{
1109 fcparam *fcp;
696 if (dodnld) {
697#ifdef ISP_TARGET_MODE
698 isp->isp_fwrev[0] = 7;
699 isp->isp_fwrev[1] = 55;
700#else
701 isp->isp_fwrev[0] = 1;
702 isp->isp_fwrev[1] = 37;
703#endif

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

1102 * Fibre Channel specific initialization.
1103 *
1104 * Locks are held before coming here.
1105 */
1106static void
1107isp_fibre_init(struct ispsoftc *isp)
1108{
1109 fcparam *fcp;
1110 isp_icb_t *icbp;
1110 isp_icb_t local, *icbp = &local;
1111 mbreg_t mbs;
1112 int loopid;
1113 u_int64_t nwwn, pwwn;
1114
1115 fcp = isp->isp_param;
1116
1117 /*
1118 * Do this *before* initializing the firmware.

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

1124 /*
1125 * If we have no role (neither target nor initiator), return.
1126 */
1127 if (isp->isp_role == ISP_ROLE_NONE) {
1128 return;
1129 }
1130
1131 loopid = DEFAULT_LOOPID(isp);
1111 mbreg_t mbs;
1112 int loopid;
1113 u_int64_t nwwn, pwwn;
1114
1115 fcp = isp->isp_param;
1116
1117 /*
1118 * Do this *before* initializing the firmware.

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

1124 /*
1125 * If we have no role (neither target nor initiator), return.
1126 */
1127 if (isp->isp_role == ISP_ROLE_NONE) {
1128 return;
1129 }
1130
1131 loopid = DEFAULT_LOOPID(isp);
1132 icbp = (isp_icb_t *) fcp->isp_scratch;
1133 MEMZERO(icbp, sizeof (*icbp));
1132 MEMZERO(icbp, sizeof (*icbp));
1134
1135 icbp->icb_version = ICB_VERSION1;
1136
1137 /*
1138 * Firmware Options are either retrieved from NVRAM or
1139 * are patched elsewhere. We check them for sanity here
1140 * and make changes based on board revision, but otherwise
1141 * let others decide policy.
1142 */

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

1284 icbp->icb_rqstaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_rquest_dma);
1285 icbp->icb_rqstaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_rquest_dma);
1286 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_result_dma);
1287 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_result_dma);
1288 icbp->icb_respaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_result_dma);
1289 icbp->icb_respaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_result_dma);
1290 isp_prt(isp, ISP_LOGDEBUG1,
1291 "isp_fibre_init: fwoptions 0x%x", fcp->isp_fwoptions);
1133 icbp->icb_version = ICB_VERSION1;
1134
1135 /*
1136 * Firmware Options are either retrieved from NVRAM or
1137 * are patched elsewhere. We check them for sanity here
1138 * and make changes based on board revision, but otherwise
1139 * let others decide policy.
1140 */

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

1282 icbp->icb_rqstaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_rquest_dma);
1283 icbp->icb_rqstaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_rquest_dma);
1284 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_result_dma);
1285 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_result_dma);
1286 icbp->icb_respaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_result_dma);
1287 icbp->icb_respaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_result_dma);
1288 isp_prt(isp, ISP_LOGDEBUG1,
1289 "isp_fibre_init: fwoptions 0x%x", fcp->isp_fwoptions);
1292 ISP_SWIZZLE_ICB(isp, icbp);
1290 isp_put_icb(isp, icbp, (isp_icb_t *)fcp->isp_scratch);
1293
1291
1294
1295 /*
1296 * Init the firmware
1297 */
1298 mbs.param[0] = MBOX_INIT_FIRMWARE;
1299 mbs.param[1] = 0;
1300 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
1301 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
1302 mbs.param[4] = 0;

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

1378 * mbs.param[4] = 0;
1379 * mbs.param[5] = 0;
1380 *
1381 */
1382 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
1383 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
1384 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR);
1385 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1292 /*
1293 * Init the firmware
1294 */
1295 mbs.param[0] = MBOX_INIT_FIRMWARE;
1296 mbs.param[1] = 0;
1297 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
1298 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
1299 mbs.param[4] = 0;

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

1375 * mbs.param[4] = 0;
1376 * mbs.param[5] = 0;
1377 *
1378 */
1379 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
1380 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
1381 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR);
1382 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1386 ISP_UNSWIZZLE_AND_COPY_PDBP(isp, pdbp, fcp->isp_scratch);
1383 isp_get_pdb(isp, (isp_pdb_t *)fcp->isp_scratch, pdbp);
1387 return (0);
1388 }
1389 return (-1);
1390}
1391
1392static u_int64_t
1393isp_get_portname(struct ispsoftc *isp, int loopid, int nodename)
1394{

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

2259 return (0);
2260}
2261
2262static int
2263isp_scan_fabric(struct ispsoftc *isp)
2264{
2265 fcparam *fcp = isp->isp_param;
2266 u_int32_t portid, first_portid, last_portid;
1384 return (0);
1385 }
1386 return (-1);
1387}
1388
1389static u_int64_t
1390isp_get_portname(struct ispsoftc *isp, int loopid, int nodename)
1391{

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

2256 return (0);
2257}
2258
2259static int
2260isp_scan_fabric(struct ispsoftc *isp)
2261{
2262 fcparam *fcp = isp->isp_param;
2263 u_int32_t portid, first_portid, last_portid;
2267 sns_screq_t *reqp;
2268 sns_scrsp_t *resp;
2269 mbreg_t mbs;
2270 int hicap, first_portid_seen, last_port_same;
2271
2272 if (fcp->isp_onfabric == 0) {
2273 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2274 return (0);
2275 }
2276
2264 int hicap, first_portid_seen, last_port_same;
2265
2266 if (fcp->isp_onfabric == 0) {
2267 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2268 return (0);
2269 }
2270
2277 reqp = (sns_screq_t *) fcp->isp_scratch;
2278 resp = (sns_scrsp_t *) (&((char *)fcp->isp_scratch)[0x100]);
2271
2279 /*
2280 * Since Port IDs are 24 bits, we can check against having seen
2281 * anything yet with this value.
2282 */
2283 last_port_same = 0;
2284 last_portid = 0xffffffff; /* not a port */
2285 first_portid = portid = fcp->isp_portid;
2286 fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
2287
2272 /*
2273 * Since Port IDs are 24 bits, we can check against having seen
2274 * anything yet with this value.
2275 */
2276 last_port_same = 0;
2277 last_portid = 0xffffffff; /* not a port */
2278 first_portid = portid = fcp->isp_portid;
2279 fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
2280
2281
2288 for (first_portid_seen = hicap = 0; hicap < 65535; hicap++) {
2282 for (first_portid_seen = hicap = 0; hicap < 65535; hicap++) {
2289 MEMZERO((void *) reqp, SNS_GAN_REQ_SIZE);
2290 reqp->snscb_rblen = SNS_GAN_RESP_SIZE >> 1;
2291 reqp->snscb_addr[RQRSP_ADDR0015] =
2292 DMA_WD0(fcp->isp_scdma + 0x100);
2293 reqp->snscb_addr[RQRSP_ADDR1631] =
2294 DMA_WD1(fcp->isp_scdma + 0x100);
2295 reqp->snscb_addr[RQRSP_ADDR3247] =
2296 DMA_WD2(fcp->isp_scdma + 0x100);
2297 reqp->snscb_addr[RQRSP_ADDR4863] =
2298 DMA_WD3(fcp->isp_scdma + 0x100);
2299 reqp->snscb_sblen = 6;
2300 reqp->snscb_data[0] = SNS_GAN;
2301 reqp->snscb_data[4] = portid & 0xffff;
2302 reqp->snscb_data[5] = (portid >> 16) & 0xff;
2303 ISP_SWIZZLE_SNS_REQ(isp, reqp);
2283 mbreg_t mbs;
2284 sns_screq_t *rq;
2285 sns_scrsp_t *rs0, *rs1;
2286 u_int8_t sc[SNS_GAN_REQ_SIZE];
2287
2288 rq = (sns_screq_t *)sc;
2289 MEMZERO((void *) rq, SNS_GAN_REQ_SIZE);
2290 rq->snscb_rblen = SNS_GAN_RESP_SIZE >> 1;
2291 rq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma+0x100);
2292 rq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma+0x100);
2293 rq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+0x100);
2294 rq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+0x100);
2295 rq->snscb_sblen = 6;
2296 rq->snscb_data[0] = SNS_GAN;
2297 rq->snscb_data[4] = portid & 0xffff;
2298 rq->snscb_data[5] = (portid >> 16) & 0xff;
2299 isp_put_sns_request(isp, rq, (sns_screq_t *) fcp->isp_scratch);
2300 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GAN_REQ_SIZE);
2304 mbs.param[0] = MBOX_SEND_SNS;
2305 mbs.param[1] = SNS_GAN_REQ_SIZE >> 1;
2306 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2307 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2308 /*
2309 * Leave 4 and 5 alone
2310 */
2311 mbs.param[6] = DMA_WD3(fcp->isp_scdma);

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

2346 isp_prt(isp, ISP_LOGERR, "SNS Failed- %s", m);
2347 }
2348 return (-1);
2349 }
2350 if (fcp->isp_fwstate != FW_READY ||
2351 fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
2352 return (-1);
2353 }
2301 mbs.param[0] = MBOX_SEND_SNS;
2302 mbs.param[1] = SNS_GAN_REQ_SIZE >> 1;
2303 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2304 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2305 /*
2306 * Leave 4 and 5 alone
2307 */
2308 mbs.param[6] = DMA_WD3(fcp->isp_scdma);

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

2343 isp_prt(isp, ISP_LOGERR, "SNS Failed- %s", m);
2344 }
2345 return (-1);
2346 }
2347 if (fcp->isp_fwstate != FW_READY ||
2348 fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
2349 return (-1);
2350 }
2354 ISP_UNSWIZZLE_SNS_RSP(isp, resp, SNS_GAN_RESP_SIZE >> 1);
2355 portid = (((u_int32_t) resp->snscb_port_id[0]) << 16) |
2356 (((u_int32_t) resp->snscb_port_id[1]) << 8) |
2357 (((u_int32_t) resp->snscb_port_id[2]));
2358 (void) isp_async(isp, ISPASYNC_FABRIC_DEV, resp);
2351 MEMORYBARRIER(isp, SYNC_SFORCPU, 0x100, SNS_GAN_RESP_SIZE);
2352 rs1 = (sns_scrsp_t *) fcp->isp_scratch;
2353 rs0 = (sns_scrsp_t *) ((u_int8_t *)fcp->isp_scratch + 0x100);
2354 isp_get_sns_response(isp, rs0, rs1, SNS_GAN_RESP_SIZE >> 1);
2355 portid = (((u_int32_t) rs1->snscb_port_id[0]) << 16) |
2356 (((u_int32_t) rs1->snscb_port_id[1]) << 8) |
2357 (((u_int32_t) rs1->snscb_port_id[2]));
2358 (void) isp_async(isp, ISPASYNC_FABRIC_DEV, rs1);
2359 if (first_portid == portid) {
2360 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2361 return (0);
2362 }
2363 if (portid == last_portid) {
2364 if (last_port_same++ > 20) {
2365 isp_prt(isp, ISP_LOGWARN,
2366 "tangled fabric database detected");

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

2381 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2382 return (0);
2383}
2384
2385static void
2386isp_register_fc4_type(struct ispsoftc *isp)
2387{
2388 fcparam *fcp = isp->isp_param;
2359 if (first_portid == portid) {
2360 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2361 return (0);
2362 }
2363 if (portid == last_portid) {
2364 if (last_port_same++ > 20) {
2365 isp_prt(isp, ISP_LOGWARN,
2366 "tangled fabric database detected");

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

2381 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2382 return (0);
2383}
2384
2385static void
2386isp_register_fc4_type(struct ispsoftc *isp)
2387{
2388 fcparam *fcp = isp->isp_param;
2389 sns_screq_t *reqp;
2389 u_int8_t local[SNS_RFT_REQ_SIZE];
2390 sns_screq_t *reqp = (sns_screq_t *) local;
2390 mbreg_t mbs;
2391
2391 mbreg_t mbs;
2392
2392 reqp = (sns_screq_t *) fcp->isp_scratch;
2393 MEMZERO((void *) reqp, SNS_RFT_REQ_SIZE);
2394 reqp->snscb_rblen = SNS_RFT_RESP_SIZE >> 1;
2395 reqp->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma + 0x100);
2396 reqp->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma + 0x100);
2397 reqp->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma + 0x100);
2398 reqp->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma + 0x100);
2399 reqp->snscb_sblen = 22;
2400 reqp->snscb_data[0] = SNS_RFT;
2401 reqp->snscb_data[4] = fcp->isp_portid & 0xffff;
2402 reqp->snscb_data[5] = (fcp->isp_portid >> 16) & 0xff;
2403 reqp->snscb_data[6] = 0x100; /* SCS - FCP */
2404#if 0
2405 reqp->snscb_data[6] |= 20; /* ISO/IEC 8802-2 LLC/SNAP */
2406#endif
2393 MEMZERO((void *) reqp, SNS_RFT_REQ_SIZE);
2394 reqp->snscb_rblen = SNS_RFT_RESP_SIZE >> 1;
2395 reqp->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma + 0x100);
2396 reqp->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma + 0x100);
2397 reqp->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma + 0x100);
2398 reqp->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma + 0x100);
2399 reqp->snscb_sblen = 22;
2400 reqp->snscb_data[0] = SNS_RFT;
2401 reqp->snscb_data[4] = fcp->isp_portid & 0xffff;
2402 reqp->snscb_data[5] = (fcp->isp_portid >> 16) & 0xff;
2403 reqp->snscb_data[6] = 0x100; /* SCS - FCP */
2404#if 0
2405 reqp->snscb_data[6] |= 20; /* ISO/IEC 8802-2 LLC/SNAP */
2406#endif
2407 ISP_SWIZZLE_SNS_REQ(isp, reqp);
2407 isp_put_sns_request(isp, reqp, (sns_screq_t *) fcp->isp_scratch);
2408 mbs.param[0] = MBOX_SEND_SNS;
2409 mbs.param[1] = SNS_RFT_REQ_SIZE >> 1;
2410 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2411 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2412 /*
2413 * Leave 4 and 5 alone
2414 */
2415 mbs.param[6] = DMA_WD3(fcp->isp_scdma);

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

2423/*
2424 * Start a command. Locking is assumed done in the caller.
2425 */
2426
2427int
2428isp_start(XS_T *xs)
2429{
2430 struct ispsoftc *isp;
2408 mbs.param[0] = MBOX_SEND_SNS;
2409 mbs.param[1] = SNS_RFT_REQ_SIZE >> 1;
2410 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2411 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2412 /*
2413 * Leave 4 and 5 alone
2414 */
2415 mbs.param[6] = DMA_WD3(fcp->isp_scdma);

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

2423/*
2424 * Start a command. Locking is assumed done in the caller.
2425 */
2426
2427int
2428isp_start(XS_T *xs)
2429{
2430 struct ispsoftc *isp;
2431 u_int16_t iptr, optr, handle;
2432 union {
2433 ispreq_t *_reqp;
2434 ispreqt2_t *_t2reqp;
2435 } _u;
2436#define reqp _u._reqp
2437#define t2reqp _u._t2reqp
2438#define UZSIZE max(sizeof (ispreq_t), sizeof (ispreqt2_t))
2431 u_int16_t nxti, optr, handle;
2432 u_int8_t local[QENTRY_LEN];
2433 ispreq_t *reqp, *qep;
2439 int target, i;
2440
2441 XS_INITERR(xs);
2442 isp = XS_ISP(xs);
2443
2444 /*
2445 * Check to make sure we're supporting initiator role.
2446 */

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

2662 /*
2663 * Next check to see if any HBA or Device
2664 * parameters need to be updated.
2665 */
2666 if (isp->isp_update != 0) {
2667 isp_update(isp);
2668 }
2669
2434 int target, i;
2435
2436 XS_INITERR(xs);
2437 isp = XS_ISP(xs);
2438
2439 /*
2440 * Check to make sure we're supporting initiator role.
2441 */

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

2657 /*
2658 * Next check to see if any HBA or Device
2659 * parameters need to be updated.
2660 */
2661 if (isp->isp_update != 0) {
2662 isp_update(isp);
2663 }
2664
2670 if (isp_getrqentry(isp, &iptr, &optr, (void **) &reqp)) {
2665 if (isp_getrqentry(isp, &nxti, &optr, (void **)&qep)) {
2671 isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow");
2672 XS_SETERR(xs, HBA_BOTCH);
2673 return (CMD_EAGAIN);
2674 }
2675
2676 /*
2677 * Now see if we need to synchronize the ISP with respect to anything.
2678 * We do dual duty here (cough) for synchronizing for busses other
2679 * than which we got here to send a command to.
2680 */
2666 isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow");
2667 XS_SETERR(xs, HBA_BOTCH);
2668 return (CMD_EAGAIN);
2669 }
2670
2671 /*
2672 * Now see if we need to synchronize the ISP with respect to anything.
2673 * We do dual duty here (cough) for synchronizing for busses other
2674 * than which we got here to send a command to.
2675 */
2676 reqp = (ispreq_t *) local;
2681 if (isp->isp_sendmarker) {
2682 u_int8_t n = (IS_DUALBUS(isp)? 2: 1);
2683 /*
2684 * Check ports to send markers for...
2685 */
2686 for (i = 0; i < n; i++) {
2687 if ((isp->isp_sendmarker & (1 << i)) == 0) {
2688 continue;
2689 }
2677 if (isp->isp_sendmarker) {
2678 u_int8_t n = (IS_DUALBUS(isp)? 2: 1);
2679 /*
2680 * Check ports to send markers for...
2681 */
2682 for (i = 0; i < n; i++) {
2683 if ((isp->isp_sendmarker & (1 << i)) == 0) {
2684 continue;
2685 }
2690 MEMZERO((void *) reqp, sizeof (*reqp));
2686 MEMZERO((void *) reqp, QENTRY_LEN);
2691 reqp->req_header.rqs_entry_count = 1;
2692 reqp->req_header.rqs_entry_type = RQSTYPE_MARKER;
2693 reqp->req_modifier = SYNC_ALL;
2694 reqp->req_target = i << 7; /* insert bus number */
2687 reqp->req_header.rqs_entry_count = 1;
2688 reqp->req_header.rqs_entry_type = RQSTYPE_MARKER;
2689 reqp->req_modifier = SYNC_ALL;
2690 reqp->req_target = i << 7; /* insert bus number */
2695 ISP_SWIZZLE_REQUEST(isp, reqp);
2696 ISP_ADD_REQUEST(isp, iptr);
2697
2698 if (isp_getrqentry(isp, &iptr, &optr, (void **)&reqp)) {
2691 isp_put_request(isp, reqp, qep);
2692 ISP_ADD_REQUEST(isp, nxti);
2693 isp->isp_sendmarker &= ~(1 << i);
2694 if (isp_getrqentry(isp, &nxti, &optr, (void **) &qep)) {
2699 isp_prt(isp, ISP_LOGDEBUG0,
2700 "Request Queue Overflow+");
2701 XS_SETERR(xs, HBA_BOTCH);
2702 return (CMD_EAGAIN);
2703 }
2704 }
2705 }
2706
2695 isp_prt(isp, ISP_LOGDEBUG0,
2696 "Request Queue Overflow+");
2697 XS_SETERR(xs, HBA_BOTCH);
2698 return (CMD_EAGAIN);
2699 }
2700 }
2701 }
2702
2707 MEMZERO((void *) reqp, UZSIZE);
2703 MEMZERO((void *)reqp, QENTRY_LEN);
2708 reqp->req_header.rqs_entry_count = 1;
2709 if (IS_FC(isp)) {
2710 reqp->req_header.rqs_entry_type = RQSTYPE_T2RQS;
2711 } else {
2712 if (XS_CDBLEN(xs) > 12)
2713 reqp->req_header.rqs_entry_type = RQSTYPE_CMDONLY;
2714 else
2715 reqp->req_header.rqs_entry_type = RQSTYPE_REQUEST;

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

2723 /* XS_RESID(xs) = 0; */
2724
2725 /*
2726 * Fibre Channel always requires some kind of tag.
2727 * The Qlogic drivers seem be happy not to use a tag,
2728 * but this breaks for some devices (IBM drives).
2729 */
2730 if (XS_TAG_P(xs)) {
2704 reqp->req_header.rqs_entry_count = 1;
2705 if (IS_FC(isp)) {
2706 reqp->req_header.rqs_entry_type = RQSTYPE_T2RQS;
2707 } else {
2708 if (XS_CDBLEN(xs) > 12)
2709 reqp->req_header.rqs_entry_type = RQSTYPE_CMDONLY;
2710 else
2711 reqp->req_header.rqs_entry_type = RQSTYPE_REQUEST;

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

2719 /* XS_RESID(xs) = 0; */
2720
2721 /*
2722 * Fibre Channel always requires some kind of tag.
2723 * The Qlogic drivers seem be happy not to use a tag,
2724 * but this breaks for some devices (IBM drives).
2725 */
2726 if (XS_TAG_P(xs)) {
2731 t2reqp->req_flags = XS_TAG_TYPE(xs);
2727 ((ispreqt2_t *)reqp)->req_flags = XS_TAG_TYPE(xs);
2732 } else {
2733 /*
2734 * If we don't know what tag to use, use HEAD OF QUEUE
2735 * for Request Sense or Simple.
2736 */
2737 if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */
2728 } else {
2729 /*
2730 * If we don't know what tag to use, use HEAD OF QUEUE
2731 * for Request Sense or Simple.
2732 */
2733 if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */
2738 t2reqp->req_flags = REQFLAG_HTAG;
2734 ((ispreqt2_t *)reqp)->req_flags = REQFLAG_HTAG;
2739 else
2735 else
2740 t2reqp->req_flags = REQFLAG_STAG;
2736 ((ispreqt2_t *)reqp)->req_flags = REQFLAG_STAG;
2741 }
2742 } else {
2743 sdparam *sdp = (sdparam *)isp->isp_param;
2744 sdp += XS_CHANNEL(xs);
2745 if ((sdp->isp_devparam[target].actv_flags & DPARM_TQING) &&
2746 XS_TAG_P(xs)) {
2747 reqp->req_flags = XS_TAG_TYPE(xs);
2748 }
2749 }
2750 reqp->req_target = target | (XS_CHANNEL(xs) << 7);
2751 if (IS_SCSI(isp)) {
2752 reqp->req_lun_trn = XS_LUN(xs);
2753 reqp->req_cdblen = XS_CDBLEN(xs);
2754 } else {
2755 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN)
2737 }
2738 } else {
2739 sdparam *sdp = (sdparam *)isp->isp_param;
2740 sdp += XS_CHANNEL(xs);
2741 if ((sdp->isp_devparam[target].actv_flags & DPARM_TQING) &&
2742 XS_TAG_P(xs)) {
2743 reqp->req_flags = XS_TAG_TYPE(xs);
2744 }
2745 }
2746 reqp->req_target = target | (XS_CHANNEL(xs) << 7);
2747 if (IS_SCSI(isp)) {
2748 reqp->req_lun_trn = XS_LUN(xs);
2749 reqp->req_cdblen = XS_CDBLEN(xs);
2750 } else {
2751 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN)
2756 t2reqp->req_scclun = XS_LUN(xs);
2752 ((ispreqt2_t *)reqp)->req_scclun = XS_LUN(xs);
2757 else
2753 else
2758 t2reqp->req_lun_trn = XS_LUN(xs);
2754 ((ispreqt2_t *)reqp)->req_lun_trn = XS_LUN(xs);
2759 }
2760 MEMCPY(reqp->req_cdb, XS_CDBP(xs), XS_CDBLEN(xs));
2761
2762 reqp->req_time = XS_TIME(xs) / 1000;
2755 }
2756 MEMCPY(reqp->req_cdb, XS_CDBP(xs), XS_CDBLEN(xs));
2757
2758 reqp->req_time = XS_TIME(xs) / 1000;
2763 if (reqp->req_time == 0 && XS_TIME(xs))
2759 if (reqp->req_time == 0 && XS_TIME(xs)) {
2764 reqp->req_time = 1;
2760 reqp->req_time = 1;
2765
2766 /*
2767 * Always give a bit more leeway to commands after a bus reset.
2768 * XXX: DOES NOT DISTINGUISH WHICH PORT MAY HAVE BEEN SYNCED
2769 */
2770 if (isp->isp_sendmarker && reqp->req_time < 5) {
2771 reqp->req_time = 5;
2772 }
2761 }
2762
2773 if (isp_save_xs(isp, xs, &handle)) {
2774 isp_prt(isp, ISP_LOGDEBUG0, "out of xflist pointers");
2775 XS_SETERR(xs, HBA_BOTCH);
2776 return (CMD_EAGAIN);
2777 }
2778 reqp->req_handle = handle;
2763 if (isp_save_xs(isp, xs, &handle)) {
2764 isp_prt(isp, ISP_LOGDEBUG0, "out of xflist pointers");
2765 XS_SETERR(xs, HBA_BOTCH);
2766 return (CMD_EAGAIN);
2767 }
2768 reqp->req_handle = handle;
2769
2779 /*
2780 * Set up DMA and/or do any bus swizzling of the request entry
2781 * so that the Qlogic F/W understands what is being asked of it.
2770 /*
2771 * Set up DMA and/or do any bus swizzling of the request entry
2772 * so that the Qlogic F/W understands what is being asked of it.
2782 */
2783 i = ISP_DMASETUP(isp, xs, reqp, &iptr, optr);
2773 */
2774 i = ISP_DMASETUP(isp, xs, reqp, &nxti, optr);
2784 if (i != CMD_QUEUED) {
2785 isp_destroy_handle(isp, handle);
2786 /*
2787 * dmasetup sets actual error in packet, and
2788 * return what we were given to return.
2789 */
2790 return (i);
2791 }
2792 XS_SETERR(xs, HBA_NOERROR);
2793 isp_prt(isp, ISP_LOGDEBUG2,
2794 "START cmd for %d.%d.%d cmd 0x%x datalen %ld",
2795 XS_CHANNEL(xs), target, XS_LUN(xs), XS_CDBP(xs)[0],
2796 (long) XS_XFRLEN(xs));
2775 if (i != CMD_QUEUED) {
2776 isp_destroy_handle(isp, handle);
2777 /*
2778 * dmasetup sets actual error in packet, and
2779 * return what we were given to return.
2780 */
2781 return (i);
2782 }
2783 XS_SETERR(xs, HBA_NOERROR);
2784 isp_prt(isp, ISP_LOGDEBUG2,
2785 "START cmd for %d.%d.%d cmd 0x%x datalen %ld",
2786 XS_CHANNEL(xs), target, XS_LUN(xs), XS_CDBP(xs)[0],
2787 (long) XS_XFRLEN(xs));
2797 ISP_ADD_REQUEST(isp, iptr);
2788 ISP_ADD_REQUEST(isp, nxti);
2798 isp->isp_nactive++;
2789 isp->isp_nactive++;
2799 if (isp->isp_sendmarker)
2800 isp->isp_sendmarker = 0;
2801 return (CMD_QUEUED);
2790 return (CMD_QUEUED);
2802#undef reqp
2803#undef t2reqp
2804}
2805
2806/*
2807 * isp control
2808 * Locks (ints blocked) assumed held.
2809 */
2810
2811int

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

3002 int i, nlooked = 0, ndone = 0;
3003
3004 /*
3005 * Is this a mailbox related interrupt?
3006 * The mailbox semaphore will be nonzero if so.
3007 */
3008 if (sema) {
3009 if (mbox & 0x4000) {
2791}
2792
2793/*
2794 * isp control
2795 * Locks (ints blocked) assumed held.
2796 */
2797
2798int

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

2989 int i, nlooked = 0, ndone = 0;
2990
2991 /*
2992 * Is this a mailbox related interrupt?
2993 * The mailbox semaphore will be nonzero if so.
2994 */
2995 if (sema) {
2996 if (mbox & 0x4000) {
3010 int obits, i = 0;
3011 if ((obits = isp->isp_mboxbsy) != 0) {
2997 if (isp->isp_mboxbsy) {
2998 int i = 0, obits = isp->isp_obits;
3012 isp->isp_mboxtmp[i++] = mbox;
3013 for (i = 1; i < MAX_MAILBOX; i++) {
3014 if ((obits & (1 << i)) == 0) {
3015 continue;
3016 }
3017 isp->isp_mboxtmp[i] =
3018 ISP_READ(isp, MBOX_OFF(i));
3019 }

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

3114 isr, junk, iptr, optr);
3115 isp->isp_intbogus++;
3116 }
3117 }
3118 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
3119 ISP_WRITE(isp, BIU_SEMA, 0);
3120
3121 while (optr != iptr) {
2999 isp->isp_mboxtmp[i++] = mbox;
3000 for (i = 1; i < MAX_MAILBOX; i++) {
3001 if ((obits & (1 << i)) == 0) {
3002 continue;
3003 }
3004 isp->isp_mboxtmp[i] =
3005 ISP_READ(isp, MBOX_OFF(i));
3006 }

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

3101 isr, junk, iptr, optr);
3102 isp->isp_intbogus++;
3103 }
3104 }
3105 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
3106 ISP_WRITE(isp, BIU_SEMA, 0);
3107
3108 while (optr != iptr) {
3122 ispstatusreq_t *sp;
3109 ispstatusreq_t local, *sp = &local;
3110 isphdr_t *hp;
3111 int type;
3123 u_int16_t oop;
3124 int buddaboom = 0;
3125
3112 u_int16_t oop;
3113 int buddaboom = 0;
3114
3126 sp = (ispstatusreq_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr);
3115 hp = (isphdr_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr);
3127 oop = optr;
3128 optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN(isp));
3129 nlooked++;
3130 /*
3116 oop = optr;
3117 optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN(isp));
3118 nlooked++;
3119 /*
3131 * Do any appropriate unswizzling of what the Qlogic f/w has
3132 * written into memory so it makes sense to us. This is a
3133 * per-platform thing. Also includes any memory barriers.
3120 * Synchronize our view of this response queue entry.
3134 */
3121 */
3135 ISP_UNSWIZZLE_RESPONSE(isp, sp, oop);
3136 if (sp->req_header.rqs_entry_type != RQSTYPE_RESPONSE) {
3137 if (isp_handle_other_response(isp, sp, &optr) == 0) {
3138 MEMZERO(sp, sizeof (isphdr_t));
3122 MEMORYBARRIER(isp, SYNC_RESULT, oop, QENTRY_LEN);
3123
3124 type = isp_get_response_type(isp, hp);
3125
3126 if (type == RQSTYPE_RESPONSE) {
3127 isp_get_response(isp, (ispstatusreq_t *) hp, sp);
3128 } else {
3129 if (!isp_handle_other_response(isp, type, hp, &optr)) {
3130 MEMZERO(hp, QENTRY_LEN); /* PERF */
3139 continue;
3140 }
3131 continue;
3132 }
3133
3141 /*
3134 /*
3135 * After this point, we'll just look at the header as
3136 * we don't know how to deal with the rest of the
3137 * response.
3138 */
3139 isp_get_response(isp, (ispstatusreq_t *) hp, sp);
3140
3141 /*
3142 * It really has to be a bounced request just copied
3143 * from the request queue to the response queue. If
3144 * not, something bad has happened.
3145 */
3146 if (sp->req_header.rqs_entry_type != RQSTYPE_REQUEST) {
3147 isp_prt(isp, ISP_LOGERR, notresp,
3148 sp->req_header.rqs_entry_type, oop, optr,
3149 nlooked);
3150 if (isp->isp_dblev & ISP_LOGDEBUG0) {
3151 isp_print_bytes(isp, "Queue Entry",
3152 QENTRY_LEN, sp);
3153 }
3142 * It really has to be a bounced request just copied
3143 * from the request queue to the response queue. If
3144 * not, something bad has happened.
3145 */
3146 if (sp->req_header.rqs_entry_type != RQSTYPE_REQUEST) {
3147 isp_prt(isp, ISP_LOGERR, notresp,
3148 sp->req_header.rqs_entry_type, oop, optr,
3149 nlooked);
3150 if (isp->isp_dblev & ISP_LOGDEBUG0) {
3151 isp_print_bytes(isp, "Queue Entry",
3152 QENTRY_LEN, sp);
3153 }
3154 MEMZERO(sp, sizeof (isphdr_t));
3154 MEMZERO(hp, QENTRY_LEN); /* PERF */
3155 continue;
3156 }
3157 buddaboom = 1;
3158 }
3159
3160 if (sp->req_header.rqs_flags & 0xf) {
3161#define _RQS_OFLAGS \
3162 ~(RQSFLAG_CONTINUATION|RQSFLAG_FULL|RQSFLAG_BADHEADER|RQSFLAG_BADPACKET)

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

3185 isp_prt(isp, ISP_LOGERR,
3186 "unknown flags (0x%x) in response",
3187 sp->req_header.rqs_flags);
3188 buddaboom++;
3189 }
3190#undef _RQS_OFLAGS
3191 }
3192 if (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1) {
3155 continue;
3156 }
3157 buddaboom = 1;
3158 }
3159
3160 if (sp->req_header.rqs_flags & 0xf) {
3161#define _RQS_OFLAGS \
3162 ~(RQSFLAG_CONTINUATION|RQSFLAG_FULL|RQSFLAG_BADHEADER|RQSFLAG_BADPACKET)

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

3185 isp_prt(isp, ISP_LOGERR,
3186 "unknown flags (0x%x) in response",
3187 sp->req_header.rqs_flags);
3188 buddaboom++;
3189 }
3190#undef _RQS_OFLAGS
3191 }
3192 if (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1) {
3193 MEMZERO(sp, sizeof (isphdr_t));
3193 MEMZERO(hp, QENTRY_LEN); /* PERF */
3194 isp_prt(isp, ISP_LOGERR,
3195 "bad request handle %d (type 0x%x, flags 0x%x)",
3196 sp->req_handle, sp->req_header.rqs_entry_type,
3197 sp->req_header.rqs_flags);
3198 WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, optr);
3199 continue;
3200 }
3201 xs = isp_find_xs(isp, sp->req_handle);
3202 if (xs == NULL) {
3194 isp_prt(isp, ISP_LOGERR,
3195 "bad request handle %d (type 0x%x, flags 0x%x)",
3196 sp->req_handle, sp->req_header.rqs_entry_type,
3197 sp->req_header.rqs_flags);
3198 WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, optr);
3199 continue;
3200 }
3201 xs = isp_find_xs(isp, sp->req_handle);
3202 if (xs == NULL) {
3203 MEMZERO(sp, sizeof (isphdr_t));
3203 MEMZERO(hp, QENTRY_LEN); /* PERF */
3204 isp_prt(isp, ISP_LOGERR,
3205 "cannot find handle 0x%x in xflist",
3206 sp->req_handle);
3207 WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, optr);
3208 continue;
3209 }
3210 isp_destroy_handle(isp, sp->req_handle);
3211 if (sp->req_status_flags & RQSTF_BUS_RESET) {
3204 isp_prt(isp, ISP_LOGERR,
3205 "cannot find handle 0x%x in xflist",
3206 sp->req_handle);
3207 WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, optr);
3208 continue;
3209 }
3210 isp_destroy_handle(isp, sp->req_handle);
3211 if (sp->req_status_flags & RQSTF_BUS_RESET) {
3212 XS_SETERR(xs, HBA_BUSRESET);
3212 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
3213 }
3214 if (buddaboom) {
3215 XS_SETERR(xs, HBA_BOTCH);
3216 }
3217
3218 if (IS_FC(isp) && (sp->req_scsi_status & RQCS_SV)) {
3219 /*

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

3327 isp_prt(isp, ISP_LOGALL, finmsg, XS_CHANNEL(xs),
3328 XS_TGT(xs), XS_LUN(xs), XS_XFRLEN(xs), XS_RESID(xs),
3329 *XS_STSP(xs), skey, XS_ERR(xs));
3330 }
3331
3332 if (isp->isp_nactive > 0)
3333 isp->isp_nactive--;
3334 complist[ndone++] = xs; /* defer completion call until later */
3213 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
3214 }
3215 if (buddaboom) {
3216 XS_SETERR(xs, HBA_BOTCH);
3217 }
3218
3219 if (IS_FC(isp) && (sp->req_scsi_status & RQCS_SV)) {
3220 /*

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

3328 isp_prt(isp, ISP_LOGALL, finmsg, XS_CHANNEL(xs),
3329 XS_TGT(xs), XS_LUN(xs), XS_XFRLEN(xs), XS_RESID(xs),
3330 *XS_STSP(xs), skey, XS_ERR(xs));
3331 }
3332
3333 if (isp->isp_nactive > 0)
3334 isp->isp_nactive--;
3335 complist[ndone++] = xs; /* defer completion call until later */
3335 MEMZERO(sp, sizeof (isphdr_t));
3336 MEMZERO(hp, QENTRY_LEN); /* PERF */
3336 if (ndone == MAX_REQUESTQ_COMPLETIONS) {
3337 break;
3338 }
3339 }
3340
3341 /*
3342 * If we looked at any commands, then it's valid to find out
3343 * what the outpointer is. It also is a trigger to update the

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

3646
3647/*
3648 * Handle other response entries. A pointer to the request queue output
3649 * index is here in case we want to eat several entries at once, although
3650 * this is not used currently.
3651 */
3652
3653static int
3337 if (ndone == MAX_REQUESTQ_COMPLETIONS) {
3338 break;
3339 }
3340 }
3341
3342 /*
3343 * If we looked at any commands, then it's valid to find out
3344 * what the outpointer is. It also is a trigger to update the

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

3647
3648/*
3649 * Handle other response entries. A pointer to the request queue output
3650 * index is here in case we want to eat several entries at once, although
3651 * this is not used currently.
3652 */
3653
3654static int
3654isp_handle_other_response(struct ispsoftc *isp,
3655 ispstatusreq_t *sp, u_int16_t *optrp)
3655isp_handle_other_response(struct ispsoftc *isp, int type,
3656 isphdr_t *hp, u_int16_t *optrp)
3656{
3657{
3657 switch (sp->req_header.rqs_entry_type) {
3658 switch (type) {
3658 case RQSTYPE_STATUS_CONT:
3659 isp_prt(isp, ISP_LOGINFO, "Ignored Continuation Response");
3660 return (0);
3661 case RQSTYPE_ATIO:
3662 case RQSTYPE_CTIO:
3663 case RQSTYPE_ENABLE_LUN:
3664 case RQSTYPE_MODIFY_LUN:
3665 case RQSTYPE_NOTIFY:
3666 case RQSTYPE_NOTIFY_ACK:
3667 case RQSTYPE_CTIO1:
3668 case RQSTYPE_ATIO2:
3669 case RQSTYPE_CTIO2:
3670 case RQSTYPE_CTIO3:
3671#ifdef ISP_TARGET_MODE
3659 case RQSTYPE_STATUS_CONT:
3660 isp_prt(isp, ISP_LOGINFO, "Ignored Continuation Response");
3661 return (0);
3662 case RQSTYPE_ATIO:
3663 case RQSTYPE_CTIO:
3664 case RQSTYPE_ENABLE_LUN:
3665 case RQSTYPE_MODIFY_LUN:
3666 case RQSTYPE_NOTIFY:
3667 case RQSTYPE_NOTIFY_ACK:
3668 case RQSTYPE_CTIO1:
3669 case RQSTYPE_ATIO2:
3670 case RQSTYPE_CTIO2:
3671 case RQSTYPE_CTIO3:
3672#ifdef ISP_TARGET_MODE
3672 return (isp_target_notify(isp, sp, optrp));
3673 return (isp_target_notify(isp, (ispstatusreq_t *) hp, optrp));
3673#else
3674 optrp = optrp;
3675 /* FALLTHROUGH */
3676#endif
3677 case RQSTYPE_REQUEST:
3678 default:
3674#else
3675 optrp = optrp;
3676 /* FALLTHROUGH */
3677#endif
3678 case RQSTYPE_REQUEST:
3679 default:
3679 if (isp_async(isp, ISPASYNC_UNHANDLED_RESPONSE, sp)) {
3680 if (isp_async(isp, ISPASYNC_UNHANDLED_RESPONSE, hp)) {
3680 return (0);
3681 }
3682 isp_prt(isp, ISP_LOGWARN, "Unhandled Response Type 0x%x",
3681 return (0);
3682 }
3683 isp_prt(isp, ISP_LOGWARN, "Unhandled Response Type 0x%x",
3683 sp->req_header.rqs_entry_type);
3684 isp_get_response_type(isp, hp));
3684 return (-1);
3685 }
3686}
3687
3688static void
3689isp_parse_status(struct ispsoftc *isp, ispstatusreq_t *sp, XS_T *xs)
3690{
3691 switch (sp->req_completion_status & 0xff) {

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

4563 isp->isp_mboxtmp[box] = mbp->param[box] = 0;
4564 }
4565
4566 isp->isp_lastmbxcmd = opcode;
4567
4568 /*
4569 * We assume that we can't overwrite a previous command.
4570 */
3685 return (-1);
3686 }
3687}
3688
3689static void
3690isp_parse_status(struct ispsoftc *isp, ispstatusreq_t *sp, XS_T *xs)
3691{
3692 switch (sp->req_completion_status & 0xff) {

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

4564 isp->isp_mboxtmp[box] = mbp->param[box] = 0;
4565 }
4566
4567 isp->isp_lastmbxcmd = opcode;
4568
4569 /*
4570 * We assume that we can't overwrite a previous command.
4571 */
4571 isp->isp_mboxbsy = obits;
4572 isp->isp_obits = obits;
4573 isp->isp_mboxbsy = 1;
4572
4573 /*
4574 * Set Host Interrupt condition so that RISC will pick up mailbox regs.
4575 */
4576 ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT);
4577
4578 /*
4579 * While we haven't finished the command, spin our wheels here.
4580 */
4581 MBOX_WAIT_COMPLETE(isp);
4582
4574
4575 /*
4576 * Set Host Interrupt condition so that RISC will pick up mailbox regs.
4577 */
4578 ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT);
4579
4580 /*
4581 * While we haven't finished the command, spin our wheels here.
4582 */
4583 MBOX_WAIT_COMPLETE(isp);
4584
4585 if (isp->isp_mboxbsy) {
4586 /*
4587 * Command timed out.
4588 */
4589 isp->isp_mboxbsy = 0;
4590 MBOX_RELEASE(isp);
4591 return;
4592 }
4593
4583 /*
4584 * Copy back output registers.
4585 */
4586 for (box = 0; box < MAX_MAILBOX; box++) {
4587 if (obits & (1 << box)) {
4588 mbp->param[box] = isp->isp_mboxtmp[box];
4589 }
4590 }

--- 995 unchanged lines hidden ---
4594 /*
4595 * Copy back output registers.
4596 */
4597 for (box = 0; box < MAX_MAILBOX; box++) {
4598 if (obits & (1 << box)) {
4599 mbp->param[box] = isp->isp_mboxtmp[box];
4600 }
4601 }

--- 995 unchanged lines hidden ---