2 * Copyright (c) 1997-2009 by Matthew Jacob
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * Machine and OS Independent (well, as best as possible)
31 * code for the Qlogic ISP SCSI and FC-SCSI adapters.
35 * Inspiration and ideas about this driver are from Erik Moe's Linux driver
36 * (qlogicisp.c) and Dave Miller's SBus version of same (qlogicisp.c). Some
37 * ideas dredged from the Solaris driver.
41 * Include header file appropriate for platform we're building on.
44 #include <sys/cdefs.h>
45 __KERNEL_RCSID(0, "$NetBSD$");
46 #include <dev/ic/isp_netbsd.h>
49 #include <sys/cdefs.h>
50 __FBSDID("$FreeBSD$");
51 #include <dev/isp/isp_freebsd.h>
54 #include <dev/ic/isp_openbsd.h>
57 #include "isp_linux.h"
60 #include "isp_solaris.h"
66 #define MBOX_DELAY_COUNT 1000000 / 100
71 static const char notresp[] = "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d) nlooked %d";
72 static const char bun[] = "bad underrun (count %d, resid %d, status %s)";
73 static const char lipd[] = "Chan %d LIP destroyed %d active commands";
74 static const char sacq[] = "unable to acquire scratch area";
76 static const uint8_t alpa_map[] = {
77 0xef, 0xe8, 0xe4, 0xe2, 0xe1, 0xe0, 0xdc, 0xda,
78 0xd9, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xce,
79 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc7, 0xc6, 0xc5,
80 0xc3, 0xbc, 0xba, 0xb9, 0xb6, 0xb5, 0xb4, 0xb3,
81 0xb2, 0xb1, 0xae, 0xad, 0xac, 0xab, 0xaa, 0xa9,
82 0xa7, 0xa6, 0xa5, 0xa3, 0x9f, 0x9e, 0x9d, 0x9b,
83 0x98, 0x97, 0x90, 0x8f, 0x88, 0x84, 0x82, 0x81,
84 0x80, 0x7c, 0x7a, 0x79, 0x76, 0x75, 0x74, 0x73,
85 0x72, 0x71, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x69,
86 0x67, 0x66, 0x65, 0x63, 0x5c, 0x5a, 0x59, 0x56,
87 0x55, 0x54, 0x53, 0x52, 0x51, 0x4e, 0x4d, 0x4c,
88 0x4b, 0x4a, 0x49, 0x47, 0x46, 0x45, 0x43, 0x3c,
89 0x3a, 0x39, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31,
90 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x27, 0x26,
91 0x25, 0x23, 0x1f, 0x1e, 0x1d, 0x1b, 0x18, 0x17,
92 0x10, 0x0f, 0x08, 0x04, 0x02, 0x01, 0x00
96 * Local function prototypes.
98 static int isp_parse_async(ispsoftc_t *, uint16_t);
99 static int isp_parse_async_fc(ispsoftc_t *, uint16_t);
100 static int isp_handle_other_response(ispsoftc_t *, int, isphdr_t *, uint32_t *);
101 static void isp_parse_status(ispsoftc_t *, ispstatusreq_t *, XS_T *, long *); static void
102 isp_parse_status_24xx(ispsoftc_t *, isp24xx_statusreq_t *, XS_T *, long *);
103 static void isp_fastpost_complete(ispsoftc_t *, uint32_t);
104 static int isp_mbox_continue(ispsoftc_t *);
105 static void isp_scsi_init(ispsoftc_t *);
106 static void isp_scsi_channel_init(ispsoftc_t *, int);
107 static void isp_fibre_init(ispsoftc_t *);
108 static void isp_fibre_init_2400(ispsoftc_t *);
109 static void isp_clear_portdb(ispsoftc_t *, int);
110 static void isp_mark_portdb(ispsoftc_t *, int);
111 static int isp_plogx(ispsoftc_t *, int, uint16_t, uint32_t, int, int);
112 static int isp_port_login(ispsoftc_t *, uint16_t, uint32_t);
113 static int isp_port_logout(ispsoftc_t *, uint16_t, uint32_t);
114 static int isp_getpdb(ispsoftc_t *, int, uint16_t, isp_pdb_t *, int);
115 static int isp_gethandles(ispsoftc_t *, int, uint16_t *, int *, int, int);
116 static void isp_dump_chip_portdb(ispsoftc_t *, int, int);
117 static uint64_t isp_get_wwn(ispsoftc_t *, int, int, int);
118 static int isp_fclink_test(ispsoftc_t *, int, int);
119 static int isp_pdb_sync(ispsoftc_t *, int);
120 static int isp_scan_loop(ispsoftc_t *, int);
121 static int isp_gid_ft_sns(ispsoftc_t *, int);
122 static int isp_gid_ft_ct_passthru(ispsoftc_t *, int);
123 static int isp_scan_fabric(ispsoftc_t *, int);
124 static int isp_login_device(ispsoftc_t *, int, uint32_t, isp_pdb_t *, uint16_t *);
125 static int isp_send_change_request(ispsoftc_t *, int);
126 static int isp_register_fc4_type(ispsoftc_t *, int);
127 static int isp_register_fc4_type_24xx(ispsoftc_t *, int);
128 static int isp_register_fc4_features_24xx(ispsoftc_t *, int);
129 static uint16_t isp_next_handle(ispsoftc_t *, uint16_t *);
130 static int isp_fw_state(ispsoftc_t *, int);
131 static void isp_mboxcmd_qnw(ispsoftc_t *, mbreg_t *, int);
132 static void isp_mboxcmd(ispsoftc_t *, mbreg_t *);
134 static void isp_spi_update(ispsoftc_t *, int);
135 static void isp_setdfltsdparm(ispsoftc_t *);
136 static void isp_setdfltfcparm(ispsoftc_t *, int);
137 static int isp_read_nvram(ispsoftc_t *, int);
138 static int isp_read_nvram_2400(ispsoftc_t *, uint8_t *);
139 static void isp_rdnvram_word(ispsoftc_t *, int, uint16_t *);
140 static void isp_rd_2400_nvram(ispsoftc_t *, uint32_t, uint32_t *);
141 static void isp_parse_nvram_1020(ispsoftc_t *, uint8_t *);
142 static void isp_parse_nvram_1080(ispsoftc_t *, int, uint8_t *);
143 static void isp_parse_nvram_12160(ispsoftc_t *, int, uint8_t *);
144 static void isp_parse_nvram_2100(ispsoftc_t *, uint8_t *);
145 static void isp_parse_nvram_2400(ispsoftc_t *, uint8_t *);
148 isp_change_fw_state(ispsoftc_t *isp, int chan, int state)
150 fcparam *fcp = FCPARAM(isp, chan);
152 if (fcp->isp_fwstate == state)
154 isp_prt(isp, ISP_LOGCONFIG|ISP_LOG_SANCFG,
155 "Chan %d Firmware state <%s->%s>", chan,
156 isp_fc_fw_statename(fcp->isp_fwstate), isp_fc_fw_statename(state));
157 fcp->isp_fwstate = state;
163 * Hit the chip over the head, download new f/w if available and set it running.
165 * Locking done elsewhere.
169 isp_reset(ispsoftc_t *isp, int do_load_defaults)
174 uint32_t code_org, val;
175 int loops, i, dodnld = 1;
176 const char *btype = "????";
177 static const char dcrc[] = "Downloaded RISC Code Checksum Failure";
179 isp->isp_state = ISP_NILSTATE;
182 ISP_DISABLE_INTS(isp);
187 * Basic types (SCSI, FibreChannel and PCI or SBus)
188 * have been set in the MD code. We figure out more
189 * here. Possibly more refined types based upon PCI
190 * identification. Chip revision has been gathered.
192 * After we've fired this chip up, zero out the conf1 register
193 * for SCSI adapters and do other settings for the 2100.
196 ISP_DISABLE_INTS(isp);
199 * Pick an initial maxcmds value which will be used
200 * to allocate xflist pointer space. It may be changed
201 * later by the firmware.
204 isp->isp_maxcmds = 4096;
205 } else if (IS_2322(isp)) {
206 isp->isp_maxcmds = 2048;
207 } else if (IS_23XX(isp) || IS_2200(isp)) {
208 isp->isp_maxcmds = 1024;
210 isp->isp_maxcmds = 512;
214 * Set up DMA for the request and response queues.
216 * We do this now so we can use the request queue
217 * for dma to load firmware from.
219 if (ISP_MBOXDMASETUP(isp) != 0) {
220 isp_prt(isp, ISP_LOGERR, "Cannot setup DMA");
225 * Set up default request/response queue in-pointer/out-pointer
229 isp->isp_rqstinrp = BIU2400_REQINP;
230 isp->isp_rqstoutrp = BIU2400_REQOUTP;
231 isp->isp_respinrp = BIU2400_RSPINP;
232 isp->isp_respoutrp = BIU2400_RSPOUTP;
233 } else if (IS_23XX(isp)) {
234 isp->isp_rqstinrp = BIU_REQINP;
235 isp->isp_rqstoutrp = BIU_REQOUTP;
236 isp->isp_respinrp = BIU_RSPINP;
237 isp->isp_respoutrp = BIU_RSPOUTP;
239 isp->isp_rqstinrp = INMAILBOX4;
240 isp->isp_rqstoutrp = OUTMAILBOX4;
241 isp->isp_respinrp = OUTMAILBOX5;
242 isp->isp_respoutrp = INMAILBOX5;
246 * Put the board into PAUSE mode (so we can read the SXP registers
247 * or write FPM/FBM registers).
250 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_HOST_INT);
251 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT);
252 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_PAUSE);
254 ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE);
258 switch (isp->isp_type) {
289 * While we're paused, reset the FPM module and FBM
292 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS);
293 ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET);
294 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS);
295 ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL);
296 ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS);
298 } else if (IS_1240(isp)) {
303 sdp = SDPARAM(isp, 0);
304 sdp->isp_ultramode = 1;
305 sdp = SDPARAM(isp, 1);
306 sdp->isp_ultramode = 1;
308 * XXX: Should probably do some bus sensing.
310 } else if (IS_ULTRA3(isp)) {
311 sdparam *sdp = isp->isp_param;
313 isp->isp_clock = 100;
317 else if (IS_12160(isp))
321 sdp->isp_lvdmode = 1;
323 if (IS_DUALBUS(isp)) {
325 sdp->isp_lvdmode = 1;
327 } else if (IS_ULTRA2(isp)) {
328 static const char m[] = "bus %d is in %s Mode";
330 sdparam *sdp = SDPARAM(isp, 0);
332 isp->isp_clock = 100;
336 else if (IS_1080(isp))
341 l = ISP_READ(isp, SXP_PINS_DIFF) & ISP1080_MODE_MASK;
343 case ISP1080_LVD_MODE:
344 sdp->isp_lvdmode = 1;
345 isp_prt(isp, ISP_LOGCONFIG, m, 0, "LVD");
347 case ISP1080_HVD_MODE:
348 sdp->isp_diffmode = 1;
349 isp_prt(isp, ISP_LOGCONFIG, m, 0, "Differential");
351 case ISP1080_SE_MODE:
352 sdp->isp_ultramode = 1;
353 isp_prt(isp, ISP_LOGCONFIG, m, 0, "Single-Ended");
356 isp_prt(isp, ISP_LOGERR,
357 "unknown mode on bus %d (0x%x)", 0, l);
361 if (IS_DUALBUS(isp)) {
362 sdp = SDPARAM(isp, 1);
363 l = ISP_READ(isp, SXP_PINS_DIFF|SXP_BANK1_SELECT);
364 l &= ISP1080_MODE_MASK;
366 case ISP1080_LVD_MODE:
367 sdp->isp_lvdmode = 1;
368 isp_prt(isp, ISP_LOGCONFIG, m, 1, "LVD");
370 case ISP1080_HVD_MODE:
371 sdp->isp_diffmode = 1;
372 isp_prt(isp, ISP_LOGCONFIG,
373 m, 1, "Differential");
375 case ISP1080_SE_MODE:
376 sdp->isp_ultramode = 1;
377 isp_prt(isp, ISP_LOGCONFIG,
378 m, 1, "Single-Ended");
381 isp_prt(isp, ISP_LOGERR,
382 "unknown mode on bus %d (0x%x)", 1, l);
387 sdparam *sdp = SDPARAM(isp, 0);
388 i = ISP_READ(isp, BIU_CONF0) & BIU_CONF0_HW_MASK;
391 isp_prt(isp, ISP_LOGALL, "Unknown Chip Type 0x%x", i);
395 isp->isp_type = ISP_HA_SCSI_1020;
400 * Some 1020A chips are Ultra Capable, but don't
401 * run the clock rate up for that unless told to
402 * do so by the Ultra Capable bits being set.
405 isp->isp_type = ISP_HA_SCSI_1020A;
410 isp->isp_type = ISP_HA_SCSI_1040;
415 isp->isp_type = ISP_HA_SCSI_1040A;
420 isp->isp_type = ISP_HA_SCSI_1040B;
425 isp->isp_type = ISP_HA_SCSI_1040C;
430 * Now, while we're at it, gather info about ultra
431 * and/or differential mode.
433 if (ISP_READ(isp, SXP_PINS_DIFF) & SXP_PINS_DIFF_MODE) {
434 isp_prt(isp, ISP_LOGCONFIG, "Differential Mode");
435 sdp->isp_diffmode = 1;
437 sdp->isp_diffmode = 0;
439 i = ISP_READ(isp, RISC_PSR);
440 if (isp->isp_bustype == ISP_BT_SBUS) {
441 i &= RISC_PSR_SBUS_ULTRA;
443 i &= RISC_PSR_PCI_ULTRA;
446 isp_prt(isp, ISP_LOGCONFIG, "Ultra Mode Capable");
447 sdp->isp_ultramode = 1;
449 * If we're in Ultra Mode, we have to be 60MHz clock-
450 * even for the SBus version.
454 sdp->isp_ultramode = 0;
456 * Clock is known. Gronk.
461 * Machine dependent clock (if set) overrides
462 * our generic determinations.
464 if (isp->isp_mdvec->dv_clock) {
465 if (isp->isp_mdvec->dv_clock < isp->isp_clock) {
466 isp->isp_clock = isp->isp_mdvec->dv_clock;
473 * Clear instrumentation
475 isp->isp_intcnt = isp->isp_intbogus = 0;
478 * Do MD specific pre initialization
483 * Hit the chip over the head with hammer,
484 * and give it a chance to recover.
488 ISP_WRITE(isp, BIU_ICR, BIU_ICR_SOFT_RESET);
495 * Clear data && control DMA engines.
497 ISP_WRITE(isp, CDMA_CONTROL, DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT);
498 ISP_WRITE(isp, DDMA_CONTROL, DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT);
501 } else if (IS_24XX(isp)) {
503 * Stop DMA and wait for it to stop.
505 ISP_WRITE(isp, BIU2400_CSR, BIU2400_DMA_STOP|(3 << 4));
506 for (val = loops = 0; loops < 30000; loops++) {
508 val = ISP_READ(isp, BIU2400_CSR);
509 if ((val & BIU2400_DMA_ACTIVE) == 0) {
513 if (val & BIU2400_DMA_ACTIVE) {
515 isp_prt(isp, ISP_LOGERR, "DMA Failed to Stop on Reset");
519 * Hold it in SOFT_RESET and STOP state for 100us.
521 ISP_WRITE(isp, BIU2400_CSR, BIU2400_SOFT_RESET|BIU2400_DMA_STOP|(3 << 4));
523 for (loops = 0; loops < 10000; loops++) {
525 val = ISP_READ(isp, OUTMAILBOX0);
527 for (val = loops = 0; loops < 500000; loops ++) {
528 val = ISP_READ(isp, BIU2400_CSR);
529 if ((val & BIU2400_SOFT_RESET) == 0) {
533 if (val & BIU2400_SOFT_RESET) {
535 isp_prt(isp, ISP_LOGERR, "Failed to come out of reset");
539 ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET);
546 * Clear data && control DMA engines.
548 ISP_WRITE(isp, CDMA2100_CONTROL, DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
549 ISP_WRITE(isp, TDMA2100_CONTROL, DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
550 ISP_WRITE(isp, RDMA2100_CONTROL, DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
554 * Wait for ISP to be ready to go...
556 loops = MBOX_DELAY_COUNT;
559 if (!(ISP_READ(isp, BIU_ICR) & BIU_ICR_SOFT_RESET)) {
562 } else if (IS_24XX(isp)) {
563 if (ISP_READ(isp, OUTMAILBOX0) == 0) {
567 if (!(ISP_READ(isp, BIU2100_CSR) & BIU2100_SOFT_RESET))
572 ISP_DUMPREGS(isp, "chip reset timed out");
579 * After we've fired this chip up, zero out the conf1 register
580 * for SCSI adapters and other settings for the 2100.
584 ISP_WRITE(isp, BIU_CONF1, 0);
585 } else if (!IS_24XX(isp)) {
586 ISP_WRITE(isp, BIU2100_CSR, 0);
590 * Reset RISC Processor
593 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RESET);
594 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RELEASE);
595 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RESET);
597 ISP_WRITE(isp, HCCR, HCCR_CMD_RESET);
599 ISP_WRITE(isp, BIU_SEMA, 0);
603 * Post-RISC Reset stuff.
606 for (val = loops = 0; loops < 5000000; loops++) {
608 val = ISP_READ(isp, OUTMAILBOX0);
615 isp_prt(isp, ISP_LOGERR, "reset didn't clear");
618 } else if (IS_SCSI(isp)) {
619 uint16_t tmp = isp->isp_mdvec->dv_conf1;
621 * Busted FIFO. Turn off all but burst enables.
623 if (isp->isp_type == ISP_HA_SCSI_1040A) {
624 tmp &= BIU_BURST_ENABLE;
626 ISP_SETBITS(isp, BIU_CONF1, tmp);
627 if (tmp & BIU_BURST_ENABLE) {
628 ISP_SETBITS(isp, CDMA_CONF, DMA_ENABLE_BURST);
629 ISP_SETBITS(isp, DDMA_CONF, DMA_ENABLE_BURST);
631 if (SDPARAM(isp, 0)->isp_ptisp) {
632 if (SDPARAM(isp, 0)->isp_ultramode) {
633 while (ISP_READ(isp, RISC_MTR) != 0x1313) {
634 ISP_WRITE(isp, RISC_MTR, 0x1313);
635 ISP_WRITE(isp, HCCR, HCCR_CMD_STEP);
638 ISP_WRITE(isp, RISC_MTR, 0x1212);
641 * PTI specific register
643 ISP_WRITE(isp, RISC_EMB, DUAL_BANK);
645 ISP_WRITE(isp, RISC_MTR, 0x1212);
647 ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
649 ISP_WRITE(isp, RISC_MTR2100, 0x1212);
650 if (IS_2200(isp) || IS_23XX(isp)) {
651 ISP_WRITE(isp, HCCR, HCCR_2X00_DISABLE_PARITY_PAUSE);
653 ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
656 ISP_WRITE(isp, isp->isp_rqstinrp, 0);
657 ISP_WRITE(isp, isp->isp_rqstoutrp, 0);
658 ISP_WRITE(isp, isp->isp_respinrp, 0);
659 ISP_WRITE(isp, isp->isp_respoutrp, 0);
662 ISP_WRITE(isp, BIU2400_PRI_REQINP, 0);
663 ISP_WRITE(isp, BIU2400_PRI_REQOUTP, 0);
665 ISP_WRITE(isp, BIU2400_ATIO_RSPINP, 0);
666 ISP_WRITE(isp, BIU2400_ATIO_RSPOUTP, 0);
670 * Do MD specific post initialization
675 * Wait for everything to finish firing up.
677 * Avoid doing this on early 2312s because you can generate a PCI
678 * parity error (chip breakage).
680 if (IS_2312(isp) && isp->isp_revision < 2) {
683 loops = MBOX_DELAY_COUNT;
684 while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) {
688 isp_prt(isp, ISP_LOGERR, "MBOX_BUSY never cleared on reset");
695 * Up until this point we've done everything by just reading or
696 * setting registers. From this point on we rely on at least *some*
697 * kind of firmware running in the card.
701 * Do some sanity checking by running a NOP command.
702 * If it succeeds, the ROM firmware is now running.
704 MBSINIT(&mbs, MBOX_NO_OP, MBLOGALL, 0);
705 isp_mboxcmd(isp, &mbs);
706 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
707 isp_prt(isp, ISP_LOGERR, "NOP command failed (%x)", mbs.param[0]);
713 * Do some operational tests
716 if (IS_SCSI(isp) || IS_24XX(isp)) {
717 static const uint16_t patterns[MAX_MAILBOX] = {
718 0x0000, 0xdead, 0xbeef, 0xffff,
719 0xa5a5, 0x5a5a, 0x7f7f, 0x7ff7,
720 0x3421, 0xabcd, 0xdcba, 0xfeef,
721 0xbead, 0xdebe, 0x2222, 0x3333,
722 0x5555, 0x6666, 0x7777, 0xaaaa,
723 0xffff, 0xdddd, 0x9999, 0x1fbc,
724 0x6666, 0x6677, 0x1122, 0x33ff,
725 0x0000, 0x0001, 0x1000, 0x1010,
727 int nmbox = ISP_NMBOX(isp);
730 MBSINIT(&mbs, MBOX_MAILBOX_REG_TEST, MBLOGALL, 0);
731 for (i = 1; i < nmbox; i++) {
732 mbs.param[i] = patterns[i];
734 isp_mboxcmd(isp, &mbs);
735 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
739 for (i = 1; i < nmbox; i++) {
740 if (mbs.param[i] != patterns[i]) {
742 isp_prt(isp, ISP_LOGERR, "Register Test Failed at Register %d: should have 0x%04x but got 0x%04x", i, patterns[i], mbs.param[i]);
749 * Download new Firmware, unless requested not to do so.
750 * This is made slightly trickier in some cases where the
751 * firmware of the ROM revision is newer than the revision
752 * compiled into the driver. So, where we used to compare
753 * versions of our f/w and the ROM f/w, now we just see
754 * whether we have f/w at all and whether a config flag
755 * has disabled our download.
757 if ((isp->isp_mdvec->dv_ispfw == NULL) || (isp->isp_confopts & ISP_CFG_NORELOAD)) {
762 code_org = ISP_CODE_ORG_2400;
763 } else if (IS_23XX(isp)) {
764 code_org = ISP_CODE_ORG_2300;
766 code_org = ISP_CODE_ORG;
769 isp->isp_loaded_fw = 0;
770 if (dodnld && IS_24XX(isp)) {
771 const uint32_t *ptr = isp->isp_mdvec->dv_ispfw;
775 * Keep loading until we run out of f/w.
777 code_org = ptr[2]; /* 1st load address is our start addr */
783 isp_prt(isp, ISP_LOGDEBUG0, "load 0x%x words of code at load address 0x%x", ptr[3], ptr[2]);
789 while (wi < ptr[3]) {
793 nw = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)) >> 2;
797 cp = isp->isp_rquest;
798 for (i = 0; i < nw; i++) {
799 ISP_IOXPUT_32(isp, ptr[wi++], &cp[i]);
802 MEMORYBARRIER(isp, SYNC_REQUEST, 0, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)), -1);
804 MBSINIT(&mbs, 0, MBLOGALL, 0);
805 if (la < 0x10000 && nw < 0x10000) {
806 mbs.param[0] = MBOX_LOAD_RISC_RAM_2100;
808 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
809 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
811 mbs.param[6] = DMA_WD3(isp->isp_rquest_dma);
812 mbs.param[7] = DMA_WD2(isp->isp_rquest_dma);
813 isp_prt(isp, ISP_LOGDEBUG0, "LOAD RISC RAM 2100 %u words at load address 0x%x", nw, la);
814 } else if (wordload) {
819 ucd.cp = (const uint32_t *)cp;
820 mbs.param[0] = MBOX_WRITE_RAM_WORD_EXTENDED;
822 mbs.param[2] = (*ucd.np);
823 mbs.param[3] = (*ucd.np) >> 16;
824 mbs.param[8] = la >> 16;
825 isp->isp_mbxwrk0 = nw - 1;
826 isp->isp_mbxworkp = ucd.np+1;
827 isp->isp_mbxwrk1 = (la + 1);
828 isp->isp_mbxwrk8 = (la + 1) >> 16;
829 isp_prt(isp, ISP_LOGDEBUG0, "WRITE RAM WORD EXTENDED %u words at load address 0x%x", nw, la);
831 mbs.param[0] = MBOX_LOAD_RISC_RAM;
833 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
834 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
835 mbs.param[4] = nw >> 16;
837 mbs.param[6] = DMA_WD3(isp->isp_rquest_dma);
838 mbs.param[7] = DMA_WD2(isp->isp_rquest_dma);
839 mbs.param[8] = la >> 16;
840 isp_prt(isp, ISP_LOGDEBUG0, "LOAD RISC RAM %u words at load address 0x%x", nw, la);
842 isp_mboxcmd(isp, &mbs);
843 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
844 if (mbs.param[0] == MBOX_HOST_INTERFACE_ERROR) {
845 isp_prt(isp, ISP_LOGERR, "switching to word load");
849 isp_prt(isp, ISP_LOGERR, "F/W Risc Ram Load Failed");
861 isp->isp_loaded_fw = 1;
862 } else if (dodnld && IS_23XX(isp)) {
863 const uint16_t *ptr = isp->isp_mdvec->dv_ispfw;
864 uint16_t wi, wl, segno;
873 isp_prt(isp, ISP_LOGDEBUG0, "load 0x%x words of code at load address 0x%x", ptr[3], la);
878 while (wi < ptr[3]) {
882 nw = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)) >> 1;
886 if (nw > (1 << 15)) {
889 cp = isp->isp_rquest;
890 for (i = 0; i < nw; i++) {
891 ISP_IOXPUT_16(isp, ptr[wi++], &cp[i]);
894 MEMORYBARRIER(isp, SYNC_REQUEST, 0, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)), -1);
895 MBSINIT(&mbs, 0, MBLOGALL, 0);
897 mbs.param[0] = MBOX_LOAD_RISC_RAM_2100;
899 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
900 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
902 mbs.param[6] = DMA_WD3(isp->isp_rquest_dma);
903 mbs.param[7] = DMA_WD2(isp->isp_rquest_dma);
904 isp_prt(isp, ISP_LOGDEBUG1, "LOAD RISC RAM 2100 %u words at load address 0x%x\n", nw, la);
906 mbs.param[0] = MBOX_LOAD_RISC_RAM;
908 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
909 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
911 mbs.param[6] = DMA_WD3(isp->isp_rquest_dma);
912 mbs.param[7] = DMA_WD2(isp->isp_rquest_dma);
913 mbs.param[8] = la >> 16;
914 isp_prt(isp, ISP_LOGDEBUG1, "LOAD RISC RAM %u words at load address 0x%x\n", nw, la);
916 isp_mboxcmd(isp, &mbs);
917 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
918 isp_prt(isp, ISP_LOGERR, "F/W Risc Ram Load Failed");
934 * If we're a 2322, the firmware actually comes in
935 * three chunks. We loaded the first at the code_org
936 * address. The other two chunks, which follow right
937 * after each other in memory here, get loaded at
938 * addresses specfied at offset 0x9..0xB.
943 la = ptr[5] | ((ptr[4] & 0x3f) << 16);
945 isp->isp_loaded_fw = 1;
951 ucd.cp = isp->isp_mdvec->dv_ispfw;
952 isp->isp_mbxworkp = &ucd.np[1];
953 isp->isp_mbxwrk0 = ucd.np[3] - 1;
954 isp->isp_mbxwrk1 = code_org + 1;
955 MBSINIT(&mbs, MBOX_WRITE_RAM_WORD, MBLOGNONE, 0);
956 mbs.param[1] = code_org;
957 mbs.param[2] = ucd.np[0];
958 isp_prt(isp, ISP_LOGDEBUG1, "WRITE RAM %u words at load address 0x%x", ucd.np[3], code_org);
959 isp_mboxcmd(isp, &mbs);
960 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
961 isp_prt(isp, ISP_LOGERR, "F/W download failed at word %d", isp->isp_mbxwrk1 - code_org);
965 } else if (IS_26XX(isp)) {
966 MBSINIT(&mbs, MBOX_LOAD_FLASH_FIRMWARE, MBLOGALL, 5000000);
969 isp_mboxcmd(isp, &mbs);
970 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
971 isp_prt(isp, ISP_LOGERR, "Flash F/W load failed");
976 isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download");
980 * If we loaded firmware, verify its checksum
982 if (isp->isp_loaded_fw) {
983 MBSINIT(&mbs, MBOX_VERIFY_CHECKSUM, MBLOGNONE, 0);
985 mbs.param[1] = code_org >> 16;
986 mbs.param[2] = code_org;
988 mbs.param[1] = code_org;
990 isp_mboxcmd(isp, &mbs);
991 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
992 isp_prt(isp, ISP_LOGERR, dcrc);
999 * Now start it rolling.
1001 * If we didn't actually download f/w,
1002 * we still need to (re)start it.
1006 MBSINIT(&mbs, MBOX_EXEC_FIRMWARE, MBLOGALL, 5000000);
1008 mbs.param[1] = code_org >> 16;
1009 mbs.param[2] = code_org;
1010 if (isp->isp_loaded_fw) {
1015 } else if (IS_2322(isp)) {
1016 mbs.param[1] = code_org;
1017 if (isp->isp_loaded_fw) {
1023 mbs.param[1] = code_org;
1025 isp_mboxcmd(isp, &mbs);
1026 if (IS_2322(isp) || IS_24XX(isp)) {
1027 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1035 * Set CLOCK RATE, but only if asked to.
1037 if (isp->isp_clock) {
1038 MBSINIT(&mbs, MBOX_SET_CLOCK_RATE, MBLOGALL, 0);
1039 mbs.param[1] = isp->isp_clock;
1040 isp_mboxcmd(isp, &mbs);
1041 /* we will try not to care if this fails */
1046 * Ask the chip for the current firmware version.
1047 * This should prove that the new firmware is working.
1049 MBSINIT(&mbs, MBOX_ABOUT_FIRMWARE, MBLOGALL, 0);
1050 isp_mboxcmd(isp, &mbs);
1051 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1057 * The SBus firmware that we are using apparently does not return
1058 * major, minor, micro revisions in the mailbox registers, which
1059 * is really, really, annoying.
1061 if (ISP_SBUS_SUPPORTED && isp->isp_bustype == ISP_BT_SBUS) {
1063 #ifdef ISP_TARGET_MODE
1064 isp->isp_fwrev[0] = 7;
1065 isp->isp_fwrev[1] = 55;
1067 isp->isp_fwrev[0] = 1;
1068 isp->isp_fwrev[1] = 37;
1070 isp->isp_fwrev[2] = 0;
1073 isp->isp_fwrev[0] = mbs.param[1];
1074 isp->isp_fwrev[1] = mbs.param[2];
1075 isp->isp_fwrev[2] = mbs.param[3];
1080 * We do not believe firmware attributes for 2100 code less
1081 * than 1.17.0, unless it's the firmware we specifically
1084 * Note that all 22XX and later f/w is greater than 1.X.0.
1086 if ((ISP_FW_OLDER_THAN(isp, 1, 17, 1))) {
1087 #ifdef USE_SMALLER_2100_FIRMWARE
1088 isp->isp_fwattr = ISP_FW_ATTR_SCCLUN;
1090 isp->isp_fwattr = 0;
1093 isp->isp_fwattr = mbs.param[6];
1096 isp->isp_fwattr |= ((uint64_t) mbs.param[15]) << 16;
1097 if (isp->isp_fwattr & ISP2400_FW_ATTR_EXTNDED) {
1099 (((uint64_t) mbs.param[16]) << 32) |
1100 (((uint64_t) mbs.param[17]) << 48);
1104 isp->isp_fwattr = 0;
1107 isp_prt(isp, ISP_LOGCONFIG, "Board Type %s, Chip Revision 0x%x, %s F/W Revision %d.%d.%d",
1108 btype, isp->isp_revision, dodnld? "loaded" : "resident", isp->isp_fwrev[0], isp->isp_fwrev[1], isp->isp_fwrev[2]);
1110 fwt = isp->isp_fwattr;
1112 buf = FCPARAM(isp, 0)->isp_scratch;
1113 ISP_SNPRINTF(buf, ISP_FC_SCRLEN, "Attributes:");
1114 if (fwt & ISP2400_FW_ATTR_CLASS2) {
1115 fwt ^=ISP2400_FW_ATTR_CLASS2;
1116 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s Class2", buf);
1118 if (fwt & ISP2400_FW_ATTR_IP) {
1119 fwt ^=ISP2400_FW_ATTR_IP;
1120 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s IP", buf);
1122 if (fwt & ISP2400_FW_ATTR_MULTIID) {
1123 fwt ^=ISP2400_FW_ATTR_MULTIID;
1124 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s MultiID", buf);
1126 if (fwt & ISP2400_FW_ATTR_SB2) {
1127 fwt ^=ISP2400_FW_ATTR_SB2;
1128 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s SB2", buf);
1130 if (fwt & ISP2400_FW_ATTR_T10CRC) {
1131 fwt ^=ISP2400_FW_ATTR_T10CRC;
1132 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s T10CRC", buf);
1134 if (fwt & ISP2400_FW_ATTR_VI) {
1135 fwt ^=ISP2400_FW_ATTR_VI;
1136 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s VI", buf);
1138 if (fwt & ISP2400_FW_ATTR_MQ) {
1139 fwt ^=ISP2400_FW_ATTR_MQ;
1140 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s MQ", buf);
1142 if (fwt & ISP2400_FW_ATTR_MSIX) {
1143 fwt ^=ISP2400_FW_ATTR_MSIX;
1144 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s MSIX", buf);
1146 if (fwt & ISP2400_FW_ATTR_FCOE) {
1147 fwt ^=ISP2400_FW_ATTR_FCOE;
1148 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s FCOE", buf);
1150 if (fwt & ISP2400_FW_ATTR_VP0) {
1151 fwt ^= ISP2400_FW_ATTR_VP0;
1152 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s VP0_Decoupling", buf);
1154 if (fwt & ISP2400_FW_ATTR_EXPFW) {
1155 fwt ^= ISP2400_FW_ATTR_EXPFW;
1156 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s (Experimental)", buf);
1158 if (fwt & ISP2400_FW_ATTR_HOTFW) {
1159 fwt ^= ISP2400_FW_ATTR_HOTFW;
1160 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s HotFW", buf);
1162 fwt &= ~ISP2400_FW_ATTR_EXTNDED;
1163 if (fwt & ISP2400_FW_ATTR_EXTVP) {
1164 fwt ^= ISP2400_FW_ATTR_EXTVP;
1165 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s ExtVP", buf);
1167 if (fwt & ISP2400_FW_ATTR_VN2VN) {
1168 fwt ^= ISP2400_FW_ATTR_VN2VN;
1169 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s VN2VN", buf);
1171 if (fwt & ISP2400_FW_ATTR_EXMOFF) {
1172 fwt ^= ISP2400_FW_ATTR_EXMOFF;
1173 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s EXMOFF", buf);
1175 if (fwt & ISP2400_FW_ATTR_NPMOFF) {
1176 fwt ^= ISP2400_FW_ATTR_NPMOFF;
1177 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s NPMOFF", buf);
1179 if (fwt & ISP2400_FW_ATTR_DIFCHOP) {
1180 fwt ^= ISP2400_FW_ATTR_DIFCHOP;
1181 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s DIFCHOP", buf);
1183 if (fwt & ISP2400_FW_ATTR_SRIOV) {
1184 fwt ^= ISP2400_FW_ATTR_SRIOV;
1185 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s SRIOV", buf);
1187 if (fwt & ISP2400_FW_ATTR_ASICTMP) {
1188 fwt ^= ISP2400_FW_ATTR_ASICTMP;
1189 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s ASICTMP", buf);
1191 if (fwt & ISP2400_FW_ATTR_ATIOMQ) {
1192 fwt ^= ISP2400_FW_ATTR_ATIOMQ;
1193 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s ATIOMQ", buf);
1196 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s (unknown 0x%08x%08x)", buf,
1197 (uint32_t) (fwt >> 32), (uint32_t) fwt);
1199 isp_prt(isp, ISP_LOGCONFIG, "%s", buf);
1200 } else if (IS_FC(isp)) {
1201 buf = FCPARAM(isp, 0)->isp_scratch;
1202 ISP_SNPRINTF(buf, ISP_FC_SCRLEN, "Attributes:");
1203 if (fwt & ISP_FW_ATTR_TMODE) {
1204 fwt ^=ISP_FW_ATTR_TMODE;
1205 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s TargetMode", buf);
1207 if (fwt & ISP_FW_ATTR_SCCLUN) {
1208 fwt ^=ISP_FW_ATTR_SCCLUN;
1209 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s SCC-Lun", buf);
1211 if (fwt & ISP_FW_ATTR_FABRIC) {
1212 fwt ^=ISP_FW_ATTR_FABRIC;
1213 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s Fabric", buf);
1215 if (fwt & ISP_FW_ATTR_CLASS2) {
1216 fwt ^=ISP_FW_ATTR_CLASS2;
1217 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s Class2", buf);
1219 if (fwt & ISP_FW_ATTR_FCTAPE) {
1220 fwt ^=ISP_FW_ATTR_FCTAPE;
1221 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s FC-Tape", buf);
1223 if (fwt & ISP_FW_ATTR_IP) {
1224 fwt ^=ISP_FW_ATTR_IP;
1225 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s IP", buf);
1227 if (fwt & ISP_FW_ATTR_VI) {
1228 fwt ^=ISP_FW_ATTR_VI;
1229 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s VI", buf);
1231 if (fwt & ISP_FW_ATTR_VI_SOLARIS) {
1232 fwt ^=ISP_FW_ATTR_VI_SOLARIS;
1233 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s VI_SOLARIS", buf);
1235 if (fwt & ISP_FW_ATTR_2KLOGINS) {
1236 fwt ^=ISP_FW_ATTR_2KLOGINS;
1237 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s 2K-Login", buf);
1240 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s (unknown 0x%08x%08x)", buf,
1241 (uint32_t) (fwt >> 32), (uint32_t) fwt);
1243 isp_prt(isp, ISP_LOGCONFIG, "%s", buf);
1247 MBSINIT(&mbs, MBOX_GET_RESOURCE_COUNT, MBLOGALL, 0);
1248 isp_mboxcmd(isp, &mbs);
1249 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1253 if (isp->isp_maxcmds >= mbs.param[3]) {
1254 isp->isp_maxcmds = mbs.param[3];
1257 MBSINIT(&mbs, MBOX_GET_FIRMWARE_STATUS, MBLOGALL, 0);
1258 isp_mboxcmd(isp, &mbs);
1259 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1263 if (isp->isp_maxcmds >= mbs.param[2]) {
1264 isp->isp_maxcmds = mbs.param[2];
1267 isp_prt(isp, ISP_LOGCONFIG, "%d max I/O command limit set", isp->isp_maxcmds);
1270 * If we don't have Multi-ID f/w loaded, we need to restrict channels to one.
1271 * Only make this check for non-SCSI cards (I'm not sure firmware attributes
1274 if (IS_FC(isp) && isp->isp_nchan > 1) {
1275 if (!ISP_CAP_MULTI_ID(isp)) {
1276 isp_prt(isp, ISP_LOGWARN, "non-MULTIID f/w loaded, "
1277 "only can enable 1 of %d channels", isp->isp_nchan);
1279 } else if (!ISP_CAP_VP0(isp)) {
1280 isp_prt(isp, ISP_LOGWARN, "We can not use MULTIID "
1281 "feature properly without VP0_Decoupling");
1286 for (i = 0; i < isp->isp_nchan; i++)
1287 isp_change_fw_state(isp, i, FW_CONFIG_WAIT);
1289 if (isp->isp_dead) {
1291 ISP_DISABLE_INTS(isp);
1295 isp->isp_state = ISP_RESETSTATE;
1298 * Okay- now that we have new firmware running, we now (re)set our
1299 * notion of how many luns we support. This is somewhat tricky because
1300 * if we haven't loaded firmware, we sometimes do not have an easy way
1301 * of knowing how many luns we support.
1303 * Expanded lun firmware gives you 32 luns for SCSI cards and
1304 * 16384 luns for Fibre Channel cards.
1306 * It turns out that even for QLogic 2100s with ROM 1.10 and above
1307 * we do get a firmware attributes word returned in mailbox register 6.
1309 * Because the lun is in a different position in the Request Queue
1310 * Entry structure for Fibre Channel with expanded lun firmware, we
1311 * can only support one lun (lun zero) when we don't know what kind
1312 * of firmware we're running.
1316 if (IS_ULTRA2(isp) || IS_ULTRA3(isp)) {
1317 isp->isp_maxluns = 32;
1319 isp->isp_maxluns = 8;
1322 isp->isp_maxluns = 8;
1325 if (ISP_CAP_SCCFW(isp)) {
1326 isp->isp_maxluns = 0; /* No limit -- 2/8 bytes */
1328 isp->isp_maxluns = 16;
1333 * We get some default values established. As a side
1334 * effect, NVRAM is read here (unless overriden by
1335 * a configuration flag).
1337 if (do_load_defaults) {
1339 isp_setdfltsdparm(isp);
1341 for (i = 0; i < isp->isp_nchan; i++) {
1342 isp_setdfltfcparm(isp, i);
1349 * Clean firmware shutdown.
1352 isp_deinit(ispsoftc_t *isp)
1356 isp->isp_state = ISP_NILSTATE;
1357 MBSINIT(&mbs, MBOX_STOP_FIRMWARE, MBLOGALL, 500000);
1366 isp_mboxcmd(isp, &mbs);
1367 return (mbs.param[0] == MBOX_COMMAND_COMPLETE ? 0 : mbs.param[0]);
1371 * Initialize Parameters of Hardware to a known state.
1373 * Locks are held before coming here.
1376 isp_init(ispsoftc_t *isp)
1380 isp_fibre_init_2400(isp);
1382 isp_fibre_init(isp);
1387 GET_NANOTIME(&isp->isp_init_time);
1391 isp_scsi_init(ispsoftc_t *isp)
1393 sdparam *sdp_chan0, *sdp_chan1;
1396 isp->isp_state = ISP_INITSTATE;
1398 sdp_chan0 = SDPARAM(isp, 0);
1399 sdp_chan1 = sdp_chan0;
1400 if (IS_DUALBUS(isp)) {
1401 sdp_chan1 = SDPARAM(isp, 1);
1404 /* First do overall per-card settings. */
1407 * If we have fast memory timing enabled, turn it on.
1409 if (sdp_chan0->isp_fast_mttr) {
1410 ISP_WRITE(isp, RISC_MTR, 0x1313);
1414 * Set Retry Delay and Count.
1415 * You set both channels at the same time.
1417 MBSINIT(&mbs, MBOX_SET_RETRY_COUNT, MBLOGALL, 0);
1418 mbs.param[1] = sdp_chan0->isp_retry_count;
1419 mbs.param[2] = sdp_chan0->isp_retry_delay;
1420 mbs.param[6] = sdp_chan1->isp_retry_count;
1421 mbs.param[7] = sdp_chan1->isp_retry_delay;
1422 isp_mboxcmd(isp, &mbs);
1423 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1428 * Set ASYNC DATA SETUP time. This is very important.
1430 MBSINIT(&mbs, MBOX_SET_ASYNC_DATA_SETUP_TIME, MBLOGALL, 0);
1431 mbs.param[1] = sdp_chan0->isp_async_data_setup;
1432 mbs.param[2] = sdp_chan1->isp_async_data_setup;
1433 isp_mboxcmd(isp, &mbs);
1434 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1439 * Set ACTIVE Negation State.
1441 MBSINIT(&mbs, MBOX_SET_ACT_NEG_STATE, MBLOGNONE, 0);
1443 (sdp_chan0->isp_req_ack_active_neg << 4) |
1444 (sdp_chan0->isp_data_line_active_neg << 5);
1446 (sdp_chan1->isp_req_ack_active_neg << 4) |
1447 (sdp_chan1->isp_data_line_active_neg << 5);
1448 isp_mboxcmd(isp, &mbs);
1449 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1450 isp_prt(isp, ISP_LOGERR,
1451 "failed to set active negation state (%d,%d), (%d,%d)",
1452 sdp_chan0->isp_req_ack_active_neg,
1453 sdp_chan0->isp_data_line_active_neg,
1454 sdp_chan1->isp_req_ack_active_neg,
1455 sdp_chan1->isp_data_line_active_neg);
1462 * Set the Tag Aging limit
1464 MBSINIT(&mbs, MBOX_SET_TAG_AGE_LIMIT, MBLOGALL, 0);
1465 mbs.param[1] = sdp_chan0->isp_tag_aging;
1466 mbs.param[2] = sdp_chan1->isp_tag_aging;
1467 isp_mboxcmd(isp, &mbs);
1468 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1469 isp_prt(isp, ISP_LOGERR, "failed to set tag age limit (%d,%d)",
1470 sdp_chan0->isp_tag_aging, sdp_chan1->isp_tag_aging);
1475 * Set selection timeout.
1477 MBSINIT(&mbs, MBOX_SET_SELECT_TIMEOUT, MBLOGALL, 0);
1478 mbs.param[1] = sdp_chan0->isp_selection_timeout;
1479 mbs.param[2] = sdp_chan1->isp_selection_timeout;
1480 isp_mboxcmd(isp, &mbs);
1481 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1485 /* now do per-channel settings */
1486 isp_scsi_channel_init(isp, 0);
1487 if (IS_DUALBUS(isp))
1488 isp_scsi_channel_init(isp, 1);
1491 * Now enable request/response queues
1494 if (IS_ULTRA2(isp) || IS_1240(isp)) {
1495 MBSINIT(&mbs, MBOX_INIT_RES_QUEUE_A64, MBLOGALL, 0);
1496 mbs.param[1] = RESULT_QUEUE_LEN(isp);
1497 mbs.param[2] = DMA_WD1(isp->isp_result_dma);
1498 mbs.param[3] = DMA_WD0(isp->isp_result_dma);
1500 mbs.param[6] = DMA_WD3(isp->isp_result_dma);
1501 mbs.param[7] = DMA_WD2(isp->isp_result_dma);
1502 isp_mboxcmd(isp, &mbs);
1503 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1506 isp->isp_residx = isp->isp_resodx = mbs.param[5];
1508 MBSINIT(&mbs, MBOX_INIT_REQ_QUEUE_A64, MBLOGALL, 0);
1509 mbs.param[1] = RQUEST_QUEUE_LEN(isp);
1510 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
1511 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
1513 mbs.param[6] = DMA_WD3(isp->isp_result_dma);
1514 mbs.param[7] = DMA_WD2(isp->isp_result_dma);
1515 isp_mboxcmd(isp, &mbs);
1516 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1519 isp->isp_reqidx = isp->isp_reqodx = mbs.param[4];
1521 MBSINIT(&mbs, MBOX_INIT_RES_QUEUE, MBLOGALL, 0);
1522 mbs.param[1] = RESULT_QUEUE_LEN(isp);
1523 mbs.param[2] = DMA_WD1(isp->isp_result_dma);
1524 mbs.param[3] = DMA_WD0(isp->isp_result_dma);
1526 isp_mboxcmd(isp, &mbs);
1527 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1530 isp->isp_residx = isp->isp_resodx = mbs.param[5];
1532 MBSINIT(&mbs, MBOX_INIT_REQ_QUEUE, MBLOGALL, 0);
1533 mbs.param[1] = RQUEST_QUEUE_LEN(isp);
1534 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
1535 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
1537 isp_mboxcmd(isp, &mbs);
1538 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1541 isp->isp_reqidx = isp->isp_reqodx = mbs.param[4];
1545 * Turn on LVD transitions for ULTRA2 or better and other features
1547 * Now that we have 32 bit handles, don't do any fast posting
1548 * any more. For Ultra2/Ultra3 cards, we can turn on 32 bit RIO
1549 * operation or use fast posting. To be conservative, we'll only
1550 * do this for Ultra3 cards now because the other cards are so
1551 * rare for this author to find and test with.
1554 MBSINIT(&mbs, MBOX_SET_FW_FEATURES, MBLOGALL, 0);
1556 mbs.param[1] |= FW_FEATURE_LVD_NOTIFY;
1559 mbs.param[1] |= FW_FEATURE_FAST_POST;
1562 mbs.param[1] |= FW_FEATURE_RIO_32BIT;
1564 if (mbs.param[1] != 0) {
1565 uint16_t sfeat = mbs.param[1];
1566 isp_mboxcmd(isp, &mbs);
1567 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1568 isp_prt(isp, ISP_LOGINFO,
1569 "Enabled FW features (0x%x)", sfeat);
1573 isp->isp_state = ISP_RUNSTATE;
1577 isp_scsi_channel_init(ispsoftc_t *isp, int chan)
1583 sdp = SDPARAM(isp, chan);
1586 * Set (possibly new) Initiator ID.
1588 MBSINIT(&mbs, MBOX_SET_INIT_SCSI_ID, MBLOGALL, 0);
1589 mbs.param[1] = (chan << 7) | sdp->isp_initiator_id;
1590 isp_mboxcmd(isp, &mbs);
1591 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1594 isp_prt(isp, ISP_LOGINFO, "Chan %d Initiator ID is %d",
1595 chan, sdp->isp_initiator_id);
1599 * Set current per-target parameters to an initial safe minimum.
1601 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
1605 if (sdp->isp_devparam[tgt].dev_enable == 0) {
1608 #ifndef ISP_TARGET_MODE
1609 sdf = sdp->isp_devparam[tgt].goal_flags;
1610 sdf &= DPARM_SAFE_DFLT;
1612 * It is not quite clear when this changed over so that
1613 * we could force narrow and async for 1000/1020 cards,
1614 * but assume that this is only the case for loaded
1617 if (isp->isp_loaded_fw) {
1618 sdf |= DPARM_NARROW | DPARM_ASYNC;
1622 * The !$*!)$!$)* f/w uses the same index into some
1623 * internal table to decide how to respond to negotiations,
1624 * so if we've said "let's be safe" for ID X, and ID X
1625 * selects *us*, the negotiations will back to 'safe'
1626 * (as in narrow/async). What the f/w *should* do is
1627 * use the initiator id settings to decide how to respond.
1629 sdp->isp_devparam[tgt].goal_flags = sdf = DPARM_DEFAULT;
1631 MBSINIT(&mbs, MBOX_SET_TARGET_PARAMS, MBLOGNONE, 0);
1632 mbs.param[1] = (chan << 15) | (tgt << 8);
1634 if ((sdf & DPARM_SYNC) == 0) {
1638 (sdp->isp_devparam[tgt].goal_offset << 8) |
1639 (sdp->isp_devparam[tgt].goal_period);
1641 isp_prt(isp, ISP_LOGDEBUG0, "Initial Settings bus%d tgt%d flags 0x%x off 0x%x per 0x%x",
1642 chan, tgt, mbs.param[2], mbs.param[3] >> 8, mbs.param[3] & 0xff);
1643 isp_mboxcmd(isp, &mbs);
1644 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1645 sdf = DPARM_SAFE_DFLT;
1646 MBSINIT(&mbs, MBOX_SET_TARGET_PARAMS, MBLOGALL, 0);
1647 mbs.param[1] = (tgt << 8) | (chan << 15);
1650 isp_mboxcmd(isp, &mbs);
1651 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1657 * We don't update any information directly from the f/w
1658 * because we need to run at least one command to cause a
1659 * new state to be latched up. So, we just assume that we
1660 * converge to the values we just had set.
1662 * Ensure that we don't believe tagged queuing is enabled yet.
1663 * It turns out that sometimes the ISP just ignores our
1664 * attempts to set parameters for devices that it hasn't
1667 sdp->isp_devparam[tgt].actv_flags = sdf & ~DPARM_TQING;
1668 for (lun = 0; lun < (int) isp->isp_maxluns; lun++) {
1669 MBSINIT(&mbs, MBOX_SET_DEV_QUEUE_PARAMS, MBLOGALL, 0);
1670 mbs.param[1] = (chan << 15) | (tgt << 8) | lun;
1671 mbs.param[2] = sdp->isp_max_queue_depth;
1672 mbs.param[3] = sdp->isp_devparam[tgt].exc_throttle;
1673 isp_mboxcmd(isp, &mbs);
1674 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1679 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
1680 if (sdp->isp_devparam[tgt].dev_refresh) {
1681 sdp->sendmarker = 1;
1689 * Fibre Channel specific initialization.
1692 isp_fibre_init(ispsoftc_t *isp)
1695 isp_icb_t local, *icbp = &local;
1699 * We only support one channel on non-24XX cards
1701 fcp = FCPARAM(isp, 0);
1702 if (fcp->role == ISP_ROLE_NONE)
1705 isp->isp_state = ISP_INITSTATE;
1706 ISP_MEMZERO(icbp, sizeof (*icbp));
1707 icbp->icb_version = ICB_VERSION1;
1708 icbp->icb_fwoptions = fcp->isp_fwoptions;
1711 * Firmware Options are either retrieved from NVRAM or
1712 * are patched elsewhere. We check them for sanity here
1713 * and make changes based on board revision, but otherwise
1714 * let others decide policy.
1718 * If this is a 2100 < revision 5, we have to turn off FAIRNESS.
1720 if (IS_2100(isp) && isp->isp_revision < 5) {
1721 icbp->icb_fwoptions &= ~ICBOPT_FAIRNESS;
1725 * We have to use FULL LOGIN even though it resets the loop too much
1726 * because otherwise port database entries don't get updated after
1727 * a LIP- this is a known f/w bug for 2100 f/w less than 1.17.0.
1729 if (!ISP_FW_NEWER_THAN(isp, 1, 17, 0)) {
1730 icbp->icb_fwoptions |= ICBOPT_FULL_LOGIN;
1734 * Insist on Port Database Update Async notifications
1736 icbp->icb_fwoptions |= ICBOPT_PDBCHANGE_AE;
1739 * Make sure that target role reflects into fwoptions.
1741 if (fcp->role & ISP_ROLE_TARGET) {
1742 icbp->icb_fwoptions |= ICBOPT_TGT_ENABLE;
1744 icbp->icb_fwoptions &= ~ICBOPT_TGT_ENABLE;
1748 * For some reason my 2200 does not generate ATIOs in target mode
1749 * if initiator is disabled. Extra logins are better then target
1750 * not working at all.
1752 if ((fcp->role & ISP_ROLE_INITIATOR) || IS_2100(isp) || IS_2200(isp)) {
1753 icbp->icb_fwoptions &= ~ICBOPT_INI_DISABLE;
1755 icbp->icb_fwoptions |= ICBOPT_INI_DISABLE;
1758 icbp->icb_maxfrmlen = DEFAULT_FRAMESIZE(isp);
1759 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN || icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) {
1760 isp_prt(isp, ISP_LOGERR, "bad frame length (%d) from NVRAM- using %d", DEFAULT_FRAMESIZE(isp), ICB_DFLT_FRMLEN);
1761 icbp->icb_maxfrmlen = ICB_DFLT_FRMLEN;
1763 icbp->icb_maxalloc = fcp->isp_maxalloc;
1764 if (icbp->icb_maxalloc < 1) {
1765 isp_prt(isp, ISP_LOGERR, "bad maximum allocation (%d)- using 16", fcp->isp_maxalloc);
1766 icbp->icb_maxalloc = 16;
1768 icbp->icb_execthrottle = DEFAULT_EXEC_THROTTLE(isp);
1769 if (icbp->icb_execthrottle < 1) {
1770 isp_prt(isp, ISP_LOGERR, "bad execution throttle of %d- using %d", DEFAULT_EXEC_THROTTLE(isp), ICB_DFLT_THROTTLE);
1771 icbp->icb_execthrottle = ICB_DFLT_THROTTLE;
1773 icbp->icb_retry_delay = fcp->isp_retry_delay;
1774 icbp->icb_retry_count = fcp->isp_retry_count;
1775 if (fcp->isp_loopid < LOCAL_LOOP_LIM) {
1776 icbp->icb_hardaddr = fcp->isp_loopid;
1777 if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
1778 icbp->icb_fwoptions |= ICBOPT_HARD_ADDRESS;
1780 icbp->icb_fwoptions |= ICBOPT_PREV_ADDRESS;
1784 * Right now we just set extended options to prefer point-to-point
1785 * over loop based upon some soft config options.
1787 * NB: for the 2300, ICBOPT_EXTENDED is required.
1791 * We can't have Fast Posting any more- we now
1792 * have 32 bit handles.
1794 icbp->icb_fwoptions &= ~ICBOPT_FAST_POST;
1795 } else if (IS_2200(isp) || IS_23XX(isp)) {
1796 icbp->icb_fwoptions |= ICBOPT_EXTENDED;
1798 icbp->icb_xfwoptions = fcp->isp_xfwoptions;
1800 if (ISP_CAP_FCTAPE(isp)) {
1801 if (isp->isp_confopts & ISP_CFG_NOFCTAPE)
1802 icbp->icb_xfwoptions &= ~ICBXOPT_FCTAPE;
1804 if (isp->isp_confopts & ISP_CFG_FCTAPE)
1805 icbp->icb_xfwoptions |= ICBXOPT_FCTAPE;
1807 if (icbp->icb_xfwoptions & ICBXOPT_FCTAPE) {
1808 icbp->icb_fwoptions &= ~ICBOPT_FULL_LOGIN; /* per documents */
1809 icbp->icb_xfwoptions |= ICBXOPT_FCTAPE_CCQ|ICBXOPT_FCTAPE_CONFIRM;
1810 FCPARAM(isp, 0)->fctape_enabled = 1;
1812 FCPARAM(isp, 0)->fctape_enabled = 0;
1815 icbp->icb_xfwoptions &= ~ICBXOPT_FCTAPE;
1816 FCPARAM(isp, 0)->fctape_enabled = 0;
1820 * Prefer or force Point-To-Point instead Loop?
1822 switch (isp->isp_confopts & ISP_CFG_PORT_PREF) {
1824 icbp->icb_xfwoptions &= ~ICBXOPT_TOPO_MASK;
1825 icbp->icb_xfwoptions |= ICBXOPT_PTP_2_LOOP;
1827 case ISP_CFG_NPORT_ONLY:
1828 icbp->icb_xfwoptions &= ~ICBXOPT_TOPO_MASK;
1829 icbp->icb_xfwoptions |= ICBXOPT_PTP_ONLY;
1831 case ISP_CFG_LPORT_ONLY:
1832 icbp->icb_xfwoptions &= ~ICBXOPT_TOPO_MASK;
1833 icbp->icb_xfwoptions |= ICBXOPT_LOOP_ONLY;
1837 * Let NVRAM settings define it if they are sane
1839 switch (icbp->icb_xfwoptions & ICBXOPT_TOPO_MASK) {
1840 case ICBXOPT_PTP_2_LOOP:
1841 case ICBXOPT_PTP_ONLY:
1842 case ICBXOPT_LOOP_ONLY:
1843 case ICBXOPT_LOOP_2_PTP:
1846 icbp->icb_xfwoptions &= ~ICBXOPT_TOPO_MASK;
1847 icbp->icb_xfwoptions |= ICBXOPT_LOOP_2_PTP;
1853 * We can't have Fast Posting any more- we now
1854 * have 32 bit handles.
1856 * RIO seemed to have to much breakage.
1858 * Just opt for safety.
1860 icbp->icb_xfwoptions &= ~ICBXOPT_RIO_16BIT;
1861 icbp->icb_fwoptions &= ~ICBOPT_FAST_POST;
1864 * QLogic recommends that FAST Posting be turned
1865 * off for 23XX cards and instead allow the HBA
1866 * to write response queue entries and interrupt
1867 * after a delay (ZIO).
1869 icbp->icb_fwoptions &= ~ICBOPT_FAST_POST;
1870 if ((fcp->isp_xfwoptions & ICBXOPT_TIMER_MASK) == ICBXOPT_ZIO) {
1871 icbp->icb_xfwoptions |= ICBXOPT_ZIO;
1872 icbp->icb_idelaytimer = 10;
1874 icbp->icb_zfwoptions = fcp->isp_zfwoptions;
1875 if (isp->isp_confopts & ISP_CFG_1GB) {
1876 icbp->icb_zfwoptions &= ~ICBZOPT_RATE_MASK;
1877 icbp->icb_zfwoptions |= ICBZOPT_RATE_1GB;
1878 } else if (isp->isp_confopts & ISP_CFG_2GB) {
1879 icbp->icb_zfwoptions &= ~ICBZOPT_RATE_MASK;
1880 icbp->icb_zfwoptions |= ICBZOPT_RATE_2GB;
1882 switch (icbp->icb_zfwoptions & ICBZOPT_RATE_MASK) {
1883 case ICBZOPT_RATE_1GB:
1884 case ICBZOPT_RATE_2GB:
1885 case ICBZOPT_RATE_AUTO:
1888 icbp->icb_zfwoptions &= ~ICBZOPT_RATE_MASK;
1889 icbp->icb_zfwoptions |= ICBZOPT_RATE_AUTO;
1898 * For 22XX > 2.1.26 && 23XX, set some options.
1900 if (ISP_FW_NEWER_THAN(isp, 2, 26, 0)) {
1901 MBSINIT(&mbs, MBOX_SET_FIRMWARE_OPTIONS, MBLOGALL, 0);
1902 mbs.param[1] = IFCOPT1_DISF7SWTCH|IFCOPT1_LIPASYNC|IFCOPT1_LIPF8;
1905 if (ISP_FW_NEWER_THAN(isp, 3, 16, 0)) {
1906 mbs.param[1] |= IFCOPT1_EQFQASYNC|IFCOPT1_CTIO_RETRY;
1907 if (fcp->role & ISP_ROLE_TARGET) {
1908 if (ISP_FW_NEWER_THAN(isp, 3, 25, 0)) {
1909 mbs.param[1] |= IFCOPT1_ENAPURE;
1911 mbs.param[3] = IFCOPT3_NOPRLI;
1914 isp_mboxcmd(isp, &mbs);
1915 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1919 icbp->icb_logintime = ICB_LOGIN_TOV;
1921 #ifdef ISP_TARGET_MODE
1922 if (icbp->icb_fwoptions & ICBOPT_TGT_ENABLE) {
1923 icbp->icb_lunenables = 0xffff;
1924 icbp->icb_ccnt = 0xff;
1925 icbp->icb_icnt = 0xff;
1926 icbp->icb_lunetimeout = ICB_LUN_ENABLE_TOV;
1929 if (fcp->isp_wwnn && fcp->isp_wwpn) {
1930 icbp->icb_fwoptions |= ICBOPT_BOTH_WWNS;
1931 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_wwnn);
1932 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_wwpn);
1933 isp_prt(isp, ISP_LOGDEBUG1,
1934 "Setting ICB Node 0x%08x%08x Port 0x%08x%08x",
1935 ((uint32_t) (fcp->isp_wwnn >> 32)),
1936 ((uint32_t) (fcp->isp_wwnn)),
1937 ((uint32_t) (fcp->isp_wwpn >> 32)),
1938 ((uint32_t) (fcp->isp_wwpn)));
1939 } else if (fcp->isp_wwpn) {
1940 icbp->icb_fwoptions &= ~ICBOPT_BOTH_WWNS;
1941 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_wwpn);
1942 isp_prt(isp, ISP_LOGDEBUG1,
1943 "Setting ICB Port 0x%08x%08x",
1944 ((uint32_t) (fcp->isp_wwpn >> 32)),
1945 ((uint32_t) (fcp->isp_wwpn)));
1947 isp_prt(isp, ISP_LOGERR, "No valid WWNs to use");
1950 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp);
1951 if (icbp->icb_rqstqlen < 1) {
1952 isp_prt(isp, ISP_LOGERR, "bad request queue length");
1954 icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp);
1955 if (icbp->icb_rsltqlen < 1) {
1956 isp_prt(isp, ISP_LOGERR, "bad result queue length");
1958 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_rquest_dma);
1959 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_rquest_dma);
1960 icbp->icb_rqstaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_rquest_dma);
1961 icbp->icb_rqstaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_rquest_dma);
1962 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_result_dma);
1963 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_result_dma);
1964 icbp->icb_respaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_result_dma);
1965 icbp->icb_respaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_result_dma);
1967 if (FC_SCRATCH_ACQUIRE(isp, 0)) {
1968 isp_prt(isp, ISP_LOGERR, sacq);
1971 isp_prt(isp, ISP_LOGDEBUG0, "isp_fibre_init: fwopt 0x%x xfwopt 0x%x zfwopt 0x%x",
1972 icbp->icb_fwoptions, icbp->icb_xfwoptions, icbp->icb_zfwoptions);
1973 if (isp->isp_dblev & ISP_LOGDEBUG1)
1974 isp_print_bytes(isp, "isp_fibre_init", sizeof (*icbp), icbp);
1976 isp_put_icb(isp, icbp, (isp_icb_t *)fcp->isp_scratch);
1981 MBSINIT(&mbs, MBOX_INIT_FIRMWARE, MBLOGALL, 30000000);
1983 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
1984 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
1985 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
1986 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
1987 isp_prt(isp, ISP_LOGDEBUG0, "INIT F/W from %p (%08x%08x)",
1988 fcp->isp_scratch, (uint32_t) ((uint64_t)fcp->isp_scdma >> 32),
1989 (uint32_t) fcp->isp_scdma);
1990 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (*icbp), 0);
1991 isp_mboxcmd(isp, &mbs);
1992 FC_SCRATCH_RELEASE(isp, 0);
1993 if (mbs.param[0] != MBOX_COMMAND_COMPLETE)
1995 isp->isp_reqidx = 0;
1996 isp->isp_reqodx = 0;
1997 isp->isp_residx = 0;
1998 isp->isp_resodx = 0;
2001 * Whatever happens, we're now committed to being here.
2003 isp->isp_state = ISP_RUNSTATE;
2007 isp_fibre_init_2400(ispsoftc_t *isp)
2010 isp_icb_2400_t local, *icbp = &local;
2015 * Check to see whether all channels have *some* kind of role
2017 for (chan = 0; chan < isp->isp_nchan; chan++) {
2018 fcp = FCPARAM(isp, chan);
2019 if (fcp->role != ISP_ROLE_NONE) {
2023 if (chan == isp->isp_nchan) {
2024 isp_prt(isp, ISP_LOG_WARN1, "all %d channels with role 'none'", chan);
2028 isp->isp_state = ISP_INITSTATE;
2031 * Start with channel 0.
2033 fcp = FCPARAM(isp, 0);
2036 * Turn on LIP F8 async event (1)
2038 MBSINIT(&mbs, MBOX_SET_FIRMWARE_OPTIONS, MBLOGALL, 0);
2040 isp_mboxcmd(isp, &mbs);
2041 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2045 ISP_MEMZERO(icbp, sizeof (*icbp));
2046 icbp->icb_fwoptions1 = fcp->isp_fwoptions;
2047 icbp->icb_fwoptions2 = fcp->isp_xfwoptions;
2048 icbp->icb_fwoptions3 = fcp->isp_zfwoptions;
2049 if (isp->isp_nchan > 1 && ISP_CAP_VP0(isp)) {
2050 icbp->icb_fwoptions1 &= ~ICB2400_OPT1_INI_DISABLE;
2051 icbp->icb_fwoptions1 |= ICB2400_OPT1_TGT_ENABLE;
2053 if (fcp->role & ISP_ROLE_TARGET)
2054 icbp->icb_fwoptions1 |= ICB2400_OPT1_TGT_ENABLE;
2056 icbp->icb_fwoptions1 &= ~ICB2400_OPT1_TGT_ENABLE;
2057 if (fcp->role & ISP_ROLE_INITIATOR)
2058 icbp->icb_fwoptions1 &= ~ICB2400_OPT1_INI_DISABLE;
2060 icbp->icb_fwoptions1 |= ICB2400_OPT1_INI_DISABLE;
2063 icbp->icb_version = ICB_VERSION1;
2064 icbp->icb_maxfrmlen = DEFAULT_FRAMESIZE(isp);
2065 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN || icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) {
2066 isp_prt(isp, ISP_LOGERR, "bad frame length (%d) from NVRAM- using %d", DEFAULT_FRAMESIZE(isp), ICB_DFLT_FRMLEN);
2067 icbp->icb_maxfrmlen = ICB_DFLT_FRMLEN;
2070 icbp->icb_execthrottle = DEFAULT_EXEC_THROTTLE(isp);
2071 if (icbp->icb_execthrottle < 1) {
2072 isp_prt(isp, ISP_LOGERR, "bad execution throttle of %d- using %d", DEFAULT_EXEC_THROTTLE(isp), ICB_DFLT_THROTTLE);
2073 icbp->icb_execthrottle = ICB_DFLT_THROTTLE;
2077 * Set target exchange count. Take half if we are supporting both roles.
2079 if (icbp->icb_fwoptions1 & ICB2400_OPT1_TGT_ENABLE) {
2080 icbp->icb_xchgcnt = isp->isp_maxcmds;
2081 if ((icbp->icb_fwoptions1 & ICB2400_OPT1_INI_DISABLE) == 0)
2082 icbp->icb_xchgcnt >>= 1;
2085 if (fcp->isp_loopid < LOCAL_LOOP_LIM) {
2086 icbp->icb_hardaddr = fcp->isp_loopid;
2087 if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
2088 icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS;
2090 icbp->icb_fwoptions1 |= ICB2400_OPT1_PREV_ADDRESS;
2093 if (isp->isp_confopts & ISP_CFG_NOFCTAPE) {
2094 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_FCTAPE;
2096 if (isp->isp_confopts & ISP_CFG_FCTAPE) {
2097 icbp->icb_fwoptions2 |= ICB2400_OPT2_FCTAPE;
2100 for (chan = 0; chan < isp->isp_nchan; chan++) {
2101 if (icbp->icb_fwoptions2 & ICB2400_OPT2_FCTAPE)
2102 FCPARAM(isp, chan)->fctape_enabled = 1;
2104 FCPARAM(isp, chan)->fctape_enabled = 0;
2107 switch (isp->isp_confopts & ISP_CFG_PORT_PREF) {
2108 case ISP_CFG_NPORT_ONLY:
2109 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
2110 icbp->icb_fwoptions2 |= ICB2400_OPT2_PTP_ONLY;
2112 case ISP_CFG_LPORT_ONLY:
2113 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
2114 icbp->icb_fwoptions2 |= ICB2400_OPT2_LOOP_ONLY;
2117 /* ISP_CFG_PTP_2_LOOP not available in 24XX/25XX */
2118 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
2119 icbp->icb_fwoptions2 |= ICB2400_OPT2_LOOP_2_PTP;
2123 switch (icbp->icb_fwoptions2 & ICB2400_OPT2_TIMER_MASK) {
2124 case ICB2400_OPT2_ZIO:
2125 case ICB2400_OPT2_ZIO1:
2126 icbp->icb_idelaytimer = 0;
2131 isp_prt(isp, ISP_LOGWARN, "bad value %x in fwopt2 timer field", icbp->icb_fwoptions2 & ICB2400_OPT2_TIMER_MASK);
2132 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TIMER_MASK;
2137 /* We don't support MSI-X yet, so set this unconditionally. */
2138 icbp->icb_fwoptions2 |= ICB2400_OPT2_ENA_IHR;
2139 icbp->icb_fwoptions2 |= ICB2400_OPT2_ENA_IHA;
2142 if ((icbp->icb_fwoptions3 & ICB2400_OPT3_RSPSZ_MASK) == 0) {
2143 icbp->icb_fwoptions3 |= ICB2400_OPT3_RSPSZ_24;
2145 if (isp->isp_confopts & ISP_CFG_1GB) {
2146 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
2147 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_1GB;
2148 } else if (isp->isp_confopts & ISP_CFG_2GB) {
2149 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
2150 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_2GB;
2151 } else if (isp->isp_confopts & ISP_CFG_4GB) {
2152 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
2153 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_4GB;
2154 } else if (isp->isp_confopts & ISP_CFG_8GB) {
2155 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
2156 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_8GB;
2157 } else if (isp->isp_confopts & ISP_CFG_16GB) {
2158 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
2159 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_16GB;
2161 switch (icbp->icb_fwoptions3 & ICB2400_OPT3_RATE_MASK) {
2162 case ICB2400_OPT3_RATE_4GB:
2163 case ICB2400_OPT3_RATE_8GB:
2164 case ICB2400_OPT3_RATE_16GB:
2165 case ICB2400_OPT3_RATE_AUTO:
2167 case ICB2400_OPT3_RATE_2GB:
2168 if (isp->isp_type <= ISP_HA_FC_2500)
2171 case ICB2400_OPT3_RATE_1GB:
2172 if (isp->isp_type <= ISP_HA_FC_2400)
2176 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
2177 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_AUTO;
2181 icbp->icb_logintime = ICB_LOGIN_TOV;
2183 if (fcp->isp_wwnn && fcp->isp_wwpn) {
2184 icbp->icb_fwoptions1 |= ICB2400_OPT1_BOTH_WWNS;
2185 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_wwpn);
2186 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_wwnn);
2187 isp_prt(isp, ISP_LOGDEBUG1, "Setting ICB Node 0x%08x%08x Port 0x%08x%08x", ((uint32_t) (fcp->isp_wwnn >> 32)), ((uint32_t) (fcp->isp_wwnn)),
2188 ((uint32_t) (fcp->isp_wwpn >> 32)), ((uint32_t) (fcp->isp_wwpn)));
2189 } else if (fcp->isp_wwpn) {
2190 icbp->icb_fwoptions1 &= ~ICB2400_OPT1_BOTH_WWNS;
2191 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_wwpn);
2192 isp_prt(isp, ISP_LOGDEBUG1, "Setting ICB Node to be same as Port 0x%08x%08x", ((uint32_t) (fcp->isp_wwpn >> 32)), ((uint32_t) (fcp->isp_wwpn)));
2194 isp_prt(isp, ISP_LOGERR, "No valid WWNs to use");
2197 icbp->icb_retry_count = fcp->isp_retry_count;
2199 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp);
2200 if (icbp->icb_rqstqlen < 8) {
2201 isp_prt(isp, ISP_LOGERR, "bad request queue length %d", icbp->icb_rqstqlen);
2204 icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp);
2205 if (icbp->icb_rsltqlen < 8) {
2206 isp_prt(isp, ISP_LOGERR, "bad result queue length %d",
2207 icbp->icb_rsltqlen);
2210 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_rquest_dma);
2211 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_rquest_dma);
2212 icbp->icb_rqstaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_rquest_dma);
2213 icbp->icb_rqstaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_rquest_dma);
2215 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_result_dma);
2216 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_result_dma);
2217 icbp->icb_respaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_result_dma);
2218 icbp->icb_respaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_result_dma);
2220 #ifdef ISP_TARGET_MODE
2221 /* unconditionally set up the ATIO queue if we support target mode */
2222 icbp->icb_atioqlen = RESULT_QUEUE_LEN(isp);
2223 if (icbp->icb_atioqlen < 8) {
2224 isp_prt(isp, ISP_LOGERR, "bad ATIO queue length %d", icbp->icb_atioqlen);
2227 icbp->icb_atioqaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_atioq_dma);
2228 icbp->icb_atioqaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_atioq_dma);
2229 icbp->icb_atioqaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_atioq_dma);
2230 icbp->icb_atioqaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_atioq_dma);
2231 isp_prt(isp, ISP_LOGDEBUG0, "isp_fibre_init_2400: atioq %04x%04x%04x%04x", DMA_WD3(isp->isp_atioq_dma), DMA_WD2(isp->isp_atioq_dma),
2232 DMA_WD1(isp->isp_atioq_dma), DMA_WD0(isp->isp_atioq_dma));
2235 isp_prt(isp, ISP_LOGDEBUG0, "isp_fibre_init_2400: fwopt1 0x%x fwopt2 0x%x fwopt3 0x%x", icbp->icb_fwoptions1, icbp->icb_fwoptions2, icbp->icb_fwoptions3);
2237 isp_prt(isp, ISP_LOGDEBUG0, "isp_fibre_init_2400: rqst %04x%04x%04x%04x rsp %04x%04x%04x%04x", DMA_WD3(isp->isp_rquest_dma), DMA_WD2(isp->isp_rquest_dma),
2238 DMA_WD1(isp->isp_rquest_dma), DMA_WD0(isp->isp_rquest_dma), DMA_WD3(isp->isp_result_dma), DMA_WD2(isp->isp_result_dma),
2239 DMA_WD1(isp->isp_result_dma), DMA_WD0(isp->isp_result_dma));
2241 if (isp->isp_dblev & ISP_LOGDEBUG1) {
2242 isp_print_bytes(isp, "isp_fibre_init_2400", sizeof (*icbp), icbp);
2245 if (FC_SCRATCH_ACQUIRE(isp, 0)) {
2246 isp_prt(isp, ISP_LOGERR, sacq);
2249 ISP_MEMZERO(fcp->isp_scratch, ISP_FC_SCRLEN);
2250 isp_put_icb_2400(isp, icbp, fcp->isp_scratch);
2253 * Now fill in information about any additional channels
2255 if (isp->isp_nchan > 1) {
2256 isp_icb_2400_vpinfo_t vpinfo, *vdst;
2257 vp_port_info_t pi, *pdst;
2261 vpinfo.vp_global_options = ICB2400_VPGOPT_GEN_RIDA;
2262 if (ISP_CAP_VP0(isp)) {
2263 vpinfo.vp_global_options |= ICB2400_VPGOPT_VP0_DECOUPLE;
2264 vpinfo.vp_count = isp->isp_nchan;
2267 vpinfo.vp_count = isp->isp_nchan - 1;
2270 off = fcp->isp_scratch;
2271 off += ICB2400_VPINFO_OFF;
2272 vdst = (isp_icb_2400_vpinfo_t *) off;
2273 isp_put_icb_2400_vpinfo(isp, &vpinfo, vdst);
2274 amt = ICB2400_VPINFO_OFF + sizeof (isp_icb_2400_vpinfo_t);
2275 for (; chan < isp->isp_nchan; chan++) {
2278 ISP_MEMZERO(&pi, sizeof (pi));
2279 fcp2 = FCPARAM(isp, chan);
2280 if (fcp2->role != ISP_ROLE_NONE) {
2281 pi.vp_port_options = ICB2400_VPOPT_ENABLED |
2282 ICB2400_VPOPT_ENA_SNSLOGIN;
2283 if (fcp2->role & ISP_ROLE_INITIATOR)
2284 pi.vp_port_options |= ICB2400_VPOPT_INI_ENABLE;
2285 if ((fcp2->role & ISP_ROLE_TARGET) == 0)
2286 pi.vp_port_options |= ICB2400_VPOPT_TGT_DISABLE;
2288 if (fcp2->isp_loopid < LOCAL_LOOP_LIM) {
2289 pi.vp_port_loopid = fcp2->isp_loopid;
2290 if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
2291 pi.vp_port_options |= ICB2400_VPOPT_HARD_ADDRESS;
2293 pi.vp_port_options |= ICB2400_VPOPT_PREV_ADDRESS;
2295 MAKE_NODE_NAME_FROM_WWN(pi.vp_port_portname, fcp2->isp_wwpn);
2296 MAKE_NODE_NAME_FROM_WWN(pi.vp_port_nodename, fcp2->isp_wwnn);
2297 off = fcp->isp_scratch;
2298 if (ISP_CAP_VP0(isp))
2299 off += ICB2400_VPINFO_PORT_OFF(chan);
2301 off += ICB2400_VPINFO_PORT_OFF(chan - 1);
2302 pdst = (vp_port_info_t *) off;
2303 isp_put_vp_port_info(isp, &pi, pdst);
2304 amt += ICB2400_VPOPT_WRITE_SIZE;
2306 if (isp->isp_dblev & ISP_LOGDEBUG1) {
2307 isp_print_bytes(isp, "isp_fibre_init_2400",
2308 amt - ICB2400_VPINFO_OFF,
2309 (char *)fcp->isp_scratch + ICB2400_VPINFO_OFF);
2316 MBSINIT(&mbs, 0, MBLOGALL, 30000000);
2317 if (isp->isp_nchan > 1) {
2318 mbs.param[0] = MBOX_INIT_FIRMWARE_MULTI_ID;
2320 mbs.param[0] = MBOX_INIT_FIRMWARE;
2323 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2324 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2325 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
2326 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
2327 isp_prt(isp, ISP_LOGDEBUG0, "INIT F/W from %04x%04x%04x%04x", DMA_WD3(fcp->isp_scdma), DMA_WD2(fcp->isp_scdma), DMA_WD1(fcp->isp_scdma), DMA_WD0(fcp->isp_scdma));
2328 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (*icbp), 0);
2329 isp_mboxcmd(isp, &mbs);
2330 FC_SCRATCH_RELEASE(isp, 0);
2332 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2335 isp->isp_reqidx = 0;
2336 isp->isp_reqodx = 0;
2337 isp->isp_residx = 0;
2338 isp->isp_resodx = 0;
2339 isp->isp_atioodx = 0;
2342 * Whatever happens, we're now committed to being here.
2344 isp->isp_state = ISP_RUNSTATE;
2348 isp_fc_enable_vp(ispsoftc_t *isp, int chan)
2350 fcparam *fcp = FCPARAM(isp, chan);
2353 uint8_t resp[QENTRY_LEN];
2355 /* Build a VP MODIFY command in memory */
2356 ISP_MEMZERO(&vp, sizeof(vp));
2357 vp.vp_mod_hdr.rqs_entry_type = RQSTYPE_VP_MODIFY;
2358 vp.vp_mod_hdr.rqs_entry_count = 1;
2360 vp.vp_mod_idx0 = chan;
2361 vp.vp_mod_cmd = VP_MODIFY_ENA;
2362 vp.vp_mod_ports[0].options = ICB2400_VPOPT_ENABLED |
2363 ICB2400_VPOPT_ENA_SNSLOGIN;
2364 if (fcp->role & ISP_ROLE_INITIATOR)
2365 vp.vp_mod_ports[0].options |= ICB2400_VPOPT_INI_ENABLE;
2366 if ((fcp->role & ISP_ROLE_TARGET) == 0)
2367 vp.vp_mod_ports[0].options |= ICB2400_VPOPT_TGT_DISABLE;
2368 if (fcp->isp_loopid < LOCAL_LOOP_LIM) {
2369 vp.vp_mod_ports[0].loopid = fcp->isp_loopid;
2370 if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
2371 vp.vp_mod_ports[0].options |= ICB2400_VPOPT_HARD_ADDRESS;
2373 vp.vp_mod_ports[0].options |= ICB2400_VPOPT_PREV_ADDRESS;
2375 MAKE_NODE_NAME_FROM_WWN(vp.vp_mod_ports[0].wwpn, fcp->isp_wwpn);
2376 MAKE_NODE_NAME_FROM_WWN(vp.vp_mod_ports[0].wwnn, fcp->isp_wwnn);
2378 /* Prepare space for response in memory */
2379 memset(resp, 0xff, sizeof(resp));
2380 vp.vp_mod_hdl = isp_allocate_handle(isp, resp, ISP_HANDLE_CTRL);
2381 if (vp.vp_mod_hdl == 0) {
2382 isp_prt(isp, ISP_LOGERR,
2383 "%s: VP_MODIFY of Chan %d out of handles", __func__, chan);
2387 /* Send request and wait for response. */
2388 reqp = isp_getrqentry(isp);
2390 isp_prt(isp, ISP_LOGERR,
2391 "%s: VP_MODIFY of Chan %d out of rqent", __func__, chan);
2392 isp_destroy_handle(isp, vp.vp_mod_hdl);
2395 isp_put_vp_modify(isp, &vp, (vp_modify_t *)reqp);
2396 ISP_SYNC_REQUEST(isp);
2397 if (msleep(resp, &isp->isp_lock, 0, "VP_MODIFY", 5*hz) == EWOULDBLOCK) {
2398 isp_prt(isp, ISP_LOGERR,
2399 "%s: VP_MODIFY of Chan %d timed out", __func__, chan);
2400 isp_destroy_handle(isp, vp.vp_mod_hdl);
2403 isp_get_vp_modify(isp, (vp_modify_t *)resp, &vp);
2405 if (vp.vp_mod_hdr.rqs_flags != 0 || vp.vp_mod_status != VP_STS_OK) {
2406 isp_prt(isp, ISP_LOGERR,
2407 "%s: VP_MODIFY of Chan %d failed with flags %x status %d",
2408 __func__, chan, vp.vp_mod_hdr.rqs_flags, vp.vp_mod_status);
2415 isp_fc_disable_vp(ispsoftc_t *isp, int chan)
2419 uint8_t resp[QENTRY_LEN];
2421 /* Build a VP CTRL command in memory */
2422 ISP_MEMZERO(&vp, sizeof(vp));
2423 vp.vp_ctrl_hdr.rqs_entry_type = RQSTYPE_VP_CTRL;
2424 vp.vp_ctrl_hdr.rqs_entry_count = 1;
2425 if (ISP_CAP_VP0(isp)) {
2426 vp.vp_ctrl_status = 1;
2428 vp.vp_ctrl_status = 0;
2429 chan--; /* VP0 can not be controlled in this case. */
2431 vp.vp_ctrl_command = VP_CTRL_CMD_DISABLE_VP_LOGO_ALL;
2432 vp.vp_ctrl_vp_count = 1;
2433 vp.vp_ctrl_idmap[chan / 16] |= (1 << chan % 16);
2435 /* Prepare space for response in memory */
2436 memset(resp, 0xff, sizeof(resp));
2437 vp.vp_ctrl_handle = isp_allocate_handle(isp, resp, ISP_HANDLE_CTRL);
2438 if (vp.vp_ctrl_handle == 0) {
2439 isp_prt(isp, ISP_LOGERR,
2440 "%s: VP_CTRL of Chan %d out of handles", __func__, chan);
2444 /* Send request and wait for response. */
2445 reqp = isp_getrqentry(isp);
2447 isp_prt(isp, ISP_LOGERR,
2448 "%s: VP_CTRL of Chan %d out of rqent", __func__, chan);
2449 isp_destroy_handle(isp, vp.vp_ctrl_handle);
2452 isp_put_vp_ctrl_info(isp, &vp, (vp_ctrl_info_t *)reqp);
2453 ISP_SYNC_REQUEST(isp);
2454 if (msleep(resp, &isp->isp_lock, 0, "VP_CTRL", 5*hz) == EWOULDBLOCK) {
2455 isp_prt(isp, ISP_LOGERR,
2456 "%s: VP_CTRL of Chan %d timed out", __func__, chan);
2457 isp_destroy_handle(isp, vp.vp_ctrl_handle);
2460 isp_get_vp_ctrl_info(isp, (vp_ctrl_info_t *)resp, &vp);
2462 if (vp.vp_ctrl_hdr.rqs_flags != 0 || vp.vp_ctrl_status != 0) {
2463 isp_prt(isp, ISP_LOGERR,
2464 "%s: VP_CTRL of Chan %d failed with flags %x status %d %d",
2465 __func__, chan, vp.vp_ctrl_hdr.rqs_flags,
2466 vp.vp_ctrl_status, vp.vp_ctrl_index_fail);
2473 isp_fc_change_role(ispsoftc_t *isp, int chan, int new_role)
2475 fcparam *fcp = FCPARAM(isp, chan);
2476 int i, was, res = 0;
2478 if (chan >= isp->isp_nchan) {
2479 isp_prt(isp, ISP_LOGWARN, "%s: bad channel %d", __func__, chan);
2482 if (fcp->role == new_role)
2484 for (was = 0, i = 0; i < isp->isp_nchan; i++) {
2485 if (FCPARAM(isp, i)->role != ISP_ROLE_NONE)
2488 if (was == 0 || (was == 1 && fcp->role != ISP_ROLE_NONE)) {
2489 fcp->role = new_role;
2490 return (isp_reinit(isp, 0));
2492 if (fcp->role != ISP_ROLE_NONE) {
2493 res = isp_fc_disable_vp(isp, chan);
2494 isp_clear_portdb(isp, chan);
2496 fcp->role = new_role;
2497 if (fcp->role != ISP_ROLE_NONE)
2498 res = isp_fc_enable_vp(isp, chan);
2503 isp_clear_portdb(ispsoftc_t *isp, int chan)
2505 fcparam *fcp = FCPARAM(isp, chan);
2509 for (i = 0; i < MAX_FC_TARG; i++) {
2510 lp = &fcp->portdb[i];
2511 switch (lp->state) {
2512 case FC_PORTDB_STATE_DEAD:
2513 case FC_PORTDB_STATE_CHANGED:
2514 case FC_PORTDB_STATE_VALID:
2515 lp->state = FC_PORTDB_STATE_NIL;
2516 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp);
2518 case FC_PORTDB_STATE_NIL:
2519 case FC_PORTDB_STATE_NEW:
2520 lp->state = FC_PORTDB_STATE_NIL;
2522 case FC_PORTDB_STATE_ZOMBIE:
2525 panic("Don't know how to clear state %d\n", lp->state);
2531 isp_mark_portdb(ispsoftc_t *isp, int chan)
2533 fcparam *fcp = FCPARAM(isp, chan);
2537 for (i = 0; i < MAX_FC_TARG; i++) {
2538 lp = &fcp->portdb[i];
2539 if (lp->state == FC_PORTDB_STATE_NIL)
2541 if (lp->portid >= DOMAIN_CONTROLLER_BASE &&
2542 lp->portid <= DOMAIN_CONTROLLER_END)
2544 fcp->portdb[i].probational = 1;
2549 * Perform an IOCB PLOGI or LOGO via EXECUTE IOCB A64 for 24XX cards
2550 * or via FABRIC LOGIN/FABRIC LOGOUT for other cards.
2553 isp_plogx(ispsoftc_t *isp, int chan, uint16_t handle, uint32_t portid, int flags, int gs)
2556 uint8_t q[QENTRY_LEN];
2560 uint32_t sst, parm1;
2565 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d PLOGX %s PortID 0x%06x nphdl 0x%x",
2566 chan, (flags & PLOGX_FLG_CMD_MASK) == PLOGX_FLG_CMD_PLOGI ?
2567 "Login":"Logout", portid, handle);
2568 if (!IS_24XX(isp)) {
2569 int action = flags & PLOGX_FLG_CMD_MASK;
2570 if (action == PLOGX_FLG_CMD_PLOGI) {
2571 return (isp_port_login(isp, handle, portid));
2572 } else if (action == PLOGX_FLG_CMD_LOGO) {
2573 return (isp_port_logout(isp, handle, portid));
2575 return (MBOX_INVALID_COMMAND);
2579 ISP_MEMZERO(q, QENTRY_LEN);
2580 plp = (isp_plogx_t *) q;
2581 plp->plogx_header.rqs_entry_count = 1;
2582 plp->plogx_header.rqs_entry_type = RQSTYPE_LOGIN;
2583 plp->plogx_handle = 0xffffffff;
2584 plp->plogx_nphdl = handle;
2585 plp->plogx_vphdl = chan;
2586 plp->plogx_portlo = portid;
2587 plp->plogx_rspsz_porthi = (portid >> 16) & 0xff;
2588 plp->plogx_flags = flags;
2590 if (isp->isp_dblev & ISP_LOGDEBUG1) {
2591 isp_print_bytes(isp, "IOCB LOGX", QENTRY_LEN, plp);
2595 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
2596 isp_prt(isp, ISP_LOGERR, sacq);
2600 fcp = FCPARAM(isp, chan);
2601 scp = fcp->isp_scratch;
2602 isp_put_plogx(isp, plp, (isp_plogx_t *) scp);
2604 MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
2605 MBCMD_DEFAULT_TIMEOUT + ICB_LOGIN_TOV * 1000000);
2606 mbs.param[1] = QENTRY_LEN;
2607 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2608 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2609 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
2610 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
2611 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, QENTRY_LEN, chan);
2612 isp_mboxcmd(isp, &mbs);
2613 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2614 rval = mbs.param[0];
2617 MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
2619 isp_get_plogx(isp, (isp_plogx_t *) scp, plp);
2620 if (isp->isp_dblev & ISP_LOGDEBUG1) {
2621 isp_print_bytes(isp, "IOCB LOGX response", QENTRY_LEN, plp);
2624 if (plp->plogx_status == PLOGX_STATUS_OK) {
2627 } else if (plp->plogx_status != PLOGX_STATUS_IOCBERR) {
2628 isp_prt(isp, ISP_LOGWARN,
2629 "status 0x%x on port login IOCB channel %d",
2630 plp->plogx_status, chan);
2635 sst = plp->plogx_ioparm[0].lo16 | (plp->plogx_ioparm[0].hi16 << 16);
2636 parm1 = plp->plogx_ioparm[1].lo16 | (plp->plogx_ioparm[1].hi16 << 16);
2643 case PLOGX_IOCBERR_NOLINK:
2646 case PLOGX_IOCBERR_NOIOCB:
2647 msg = "no IOCB buffer";
2649 case PLOGX_IOCBERR_NOXGHG:
2650 msg = "no Exchange Control Block";
2652 case PLOGX_IOCBERR_FAILED:
2653 ISP_SNPRINTF(buf, sizeof (buf), "reason 0x%x (last LOGIN state 0x%x)", parm1 & 0xff, (parm1 >> 8) & 0xff);
2656 case PLOGX_IOCBERR_NOFABRIC:
2659 case PLOGX_IOCBERR_NOTREADY:
2660 msg = "firmware not ready";
2662 case PLOGX_IOCBERR_NOLOGIN:
2663 ISP_SNPRINTF(buf, sizeof (buf), "not logged in (last state 0x%x)", parm1);
2665 rval = MBOX_NOT_LOGGED_IN;
2667 case PLOGX_IOCBERR_REJECT:
2668 ISP_SNPRINTF(buf, sizeof (buf), "LS_RJT = 0x%x", parm1);
2671 case PLOGX_IOCBERR_NOPCB:
2672 msg = "no PCB allocated";
2674 case PLOGX_IOCBERR_EINVAL:
2675 ISP_SNPRINTF(buf, sizeof (buf), "invalid parameter at offset 0x%x", parm1);
2678 case PLOGX_IOCBERR_PORTUSED:
2679 lev = ISP_LOG_SANCFG|ISP_LOG_WARN1;
2680 ISP_SNPRINTF(buf, sizeof (buf), "already logged in with N-Port handle 0x%x", parm1);
2682 rval = MBOX_PORT_ID_USED | (parm1 << 16);
2684 case PLOGX_IOCBERR_HNDLUSED:
2685 lev = ISP_LOG_SANCFG|ISP_LOG_WARN1;
2686 ISP_SNPRINTF(buf, sizeof (buf), "handle already used for PortID 0x%06x", parm1);
2688 rval = MBOX_LOOP_ID_USED;
2690 case PLOGX_IOCBERR_NOHANDLE:
2691 msg = "no handle allocated";
2693 case PLOGX_IOCBERR_NOFLOGI:
2694 msg = "no FLOGI_ACC";
2697 ISP_SNPRINTF(buf, sizeof (buf), "status %x from %x", plp->plogx_status, flags);
2702 isp_prt(isp, ISP_LOGERR, "Chan %d PLOGX PortID 0x%06x to N-Port handle 0x%x: %s", chan, portid, handle, msg);
2706 FC_SCRATCH_RELEASE(isp, chan);
2712 isp_port_login(ispsoftc_t *isp, uint16_t handle, uint32_t portid)
2716 MBSINIT(&mbs, MBOX_FABRIC_LOGIN, MBLOGNONE, 500000);
2717 if (ISP_CAP_2KLOGIN(isp)) {
2718 mbs.param[1] = handle;
2719 mbs.ibits = (1 << 10);
2721 mbs.param[1] = handle << 8;
2723 mbs.param[2] = portid >> 16;
2724 mbs.param[3] = portid;
2725 mbs.logval = MBLOGNONE;
2726 mbs.timeout = 500000;
2727 isp_mboxcmd(isp, &mbs);
2729 switch (mbs.param[0]) {
2730 case MBOX_PORT_ID_USED:
2731 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: portid 0x%06x already logged in as 0x%x", portid, mbs.param[1]);
2732 return (MBOX_PORT_ID_USED | (mbs.param[1] << 16));
2734 case MBOX_LOOP_ID_USED:
2735 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: handle 0x%x in use for port id 0x%02xXXXX", handle, mbs.param[1] & 0xff);
2736 return (MBOX_LOOP_ID_USED);
2738 case MBOX_COMMAND_COMPLETE:
2741 case MBOX_COMMAND_ERROR:
2742 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: error 0x%x in PLOGI to port 0x%06x", mbs.param[1], portid);
2743 return (MBOX_COMMAND_ERROR);
2745 case MBOX_ALL_IDS_USED:
2746 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: all IDs used for fabric login");
2747 return (MBOX_ALL_IDS_USED);
2750 isp_prt(isp, ISP_LOG_SANCFG, "isp_port_login: error 0x%x on port login of 0x%06x@0x%0x", mbs.param[0], portid, handle);
2751 return (mbs.param[0]);
2756 * Pre-24XX fabric port logout
2758 * Note that portid is not used
2761 isp_port_logout(ispsoftc_t *isp, uint16_t handle, uint32_t portid)
2765 MBSINIT(&mbs, MBOX_FABRIC_LOGOUT, MBLOGNONE, 500000);
2766 if (ISP_CAP_2KLOGIN(isp)) {
2767 mbs.param[1] = handle;
2768 mbs.ibits = (1 << 10);
2770 mbs.param[1] = handle << 8;
2772 isp_mboxcmd(isp, &mbs);
2773 return (mbs.param[0] == MBOX_COMMAND_COMPLETE? 0 : mbs.param[0]);
2777 isp_getpdb(ispsoftc_t *isp, int chan, uint16_t id, isp_pdb_t *pdb, int dolock)
2779 fcparam *fcp = FCPARAM(isp, chan);
2782 isp_pdb_21xx_t fred;
2783 isp_pdb_24xx_t bill;
2786 MBSINIT(&mbs, MBOX_GET_PORT_DB,
2787 MBLOGALL & ~MBLOGMASK(MBOX_COMMAND_PARAM_ERROR), 250000);
2789 mbs.ibits = (1 << 9)|(1 << 10);
2791 mbs.param[9] = chan;
2792 } else if (ISP_CAP_2KLOGIN(isp)) {
2795 mbs.param[1] = id << 8;
2797 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2798 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2799 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
2800 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
2802 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
2803 isp_prt(isp, ISP_LOGERR, sacq);
2807 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (un), chan);
2808 isp_mboxcmd(isp, &mbs);
2809 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2811 FC_SCRATCH_RELEASE(isp, chan);
2813 return (mbs.param[0] | (mbs.param[1] << 16));
2816 isp_get_pdb_24xx(isp, fcp->isp_scratch, &un.bill);
2817 pdb->handle = un.bill.pdb_handle;
2818 pdb->prli_word3 = un.bill.pdb_prli_svc3;
2819 pdb->portid = BITS2WORD_24XX(un.bill.pdb_portid_bits);
2820 ISP_MEMCPY(pdb->portname, un.bill.pdb_portname, 8);
2821 ISP_MEMCPY(pdb->nodename, un.bill.pdb_nodename, 8);
2822 isp_prt(isp, ISP_LOGDEBUG1,
2823 "Chan %d handle 0x%x Port 0x%06x flags 0x%x curstate %x",
2824 chan, id, pdb->portid, un.bill.pdb_flags,
2825 un.bill.pdb_curstate);
2826 if (un.bill.pdb_curstate < PDB2400_STATE_PLOGI_DONE || un.bill.pdb_curstate > PDB2400_STATE_LOGGED_IN) {
2827 mbs.param[0] = MBOX_NOT_LOGGED_IN;
2829 FC_SCRATCH_RELEASE(isp, chan);
2831 return (mbs.param[0]);
2834 isp_get_pdb_21xx(isp, fcp->isp_scratch, &un.fred);
2835 pdb->handle = un.fred.pdb_loopid;
2836 pdb->prli_word3 = un.fred.pdb_prli_svc3;
2837 pdb->portid = BITS2WORD(un.fred.pdb_portid_bits);
2838 ISP_MEMCPY(pdb->portname, un.fred.pdb_portname, 8);
2839 ISP_MEMCPY(pdb->nodename, un.fred.pdb_nodename, 8);
2840 isp_prt(isp, ISP_LOGDEBUG1,
2841 "Chan %d handle 0x%x Port 0x%06x", chan, id, pdb->portid);
2844 FC_SCRATCH_RELEASE(isp, chan);
2850 isp_gethandles(ispsoftc_t *isp, int chan, uint16_t *handles, int *num,
2851 int dolock, int loop)
2853 fcparam *fcp = FCPARAM(isp, chan);
2855 isp_pnhle_21xx_t el1, *elp1;
2856 isp_pnhle_23xx_t el3, *elp3;
2857 isp_pnhle_24xx_t el4, *elp4;
2862 MBSINIT(&mbs, MBOX_GET_ID_LIST, MBLOGALL, 250000);
2864 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2865 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2866 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
2867 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
2868 mbs.param[8] = ISP_FC_SCRLEN;
2869 mbs.param[9] = chan;
2871 mbs.ibits = (1 << 1)|(1 << 2)|(1 << 3)|(1 << 6);
2872 mbs.param[1] = DMA_WD1(fcp->isp_scdma);
2873 mbs.param[2] = DMA_WD0(fcp->isp_scdma);
2874 mbs.param[3] = DMA_WD3(fcp->isp_scdma);
2875 mbs.param[6] = DMA_WD2(fcp->isp_scdma);
2878 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
2879 isp_prt(isp, ISP_LOGERR, sacq);
2883 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, ISP_FC_SCRLEN, chan);
2884 isp_mboxcmd(isp, &mbs);
2885 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2887 FC_SCRATCH_RELEASE(isp, chan);
2889 return (mbs.param[0] | (mbs.param[1] << 16));
2891 elp1 = fcp->isp_scratch;
2892 elp3 = fcp->isp_scratch;
2893 elp4 = fcp->isp_scratch;
2894 for (i = 0, j = 0; i < mbs.param[1] && j < *num; i++) {
2896 isp_get_pnhle_24xx(isp, &elp4[i], &el4);
2897 p = el4.pnhle_port_id_lo |
2898 (el4.pnhle_port_id_hi << 16);
2899 h = el4.pnhle_handle;
2900 } else if (IS_23XX(isp)) {
2901 isp_get_pnhle_23xx(isp, &elp3[i], &el3);
2902 p = el3.pnhle_port_id_lo |
2903 (el3.pnhle_port_id_hi << 16);
2904 h = el3.pnhle_handle;
2906 isp_get_pnhle_21xx(isp, &elp1[i], &el1);
2907 p = el1.pnhle_port_id_lo |
2908 ((el1.pnhle_port_id_hi_handle & 0xff) << 16);
2909 h = el1.pnhle_port_id_hi_handle >> 8;
2911 if (loop && (p >> 8) != (fcp->isp_portid >> 8))
2917 FC_SCRATCH_RELEASE(isp, chan);
2922 isp_dump_chip_portdb(ispsoftc_t *isp, int chan, int dolock)
2925 uint16_t lim, nphdl;
2927 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGINFO, "Chan %d chip port dump", chan);
2928 if (ISP_CAP_2KLOGIN(isp)) {
2933 for (nphdl = 0; nphdl != lim; nphdl++) {
2934 if (isp_getpdb(isp, chan, nphdl, &pdb, dolock)) {
2937 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGINFO, "Chan %d Handle 0x%04x "
2938 "PortID 0x%06x WWPN 0x%02x%02x%02x%02x%02x%02x%02x%02x",
2939 chan, nphdl, pdb.portid, pdb.portname[0], pdb.portname[1],
2940 pdb.portname[2], pdb.portname[3], pdb.portname[4],
2941 pdb.portname[5], pdb.portname[6], pdb.portname[7]);
2946 isp_get_wwn(ispsoftc_t *isp, int chan, int nphdl, int nodename)
2948 uint64_t wwn = INI_NONE;
2951 MBSINIT(&mbs, MBOX_GET_PORT_NAME,
2952 MBLOGALL & ~MBLOGMASK(MBOX_COMMAND_PARAM_ERROR), 500000);
2953 if (ISP_CAP_2KLOGIN(isp)) {
2954 mbs.param[1] = nphdl;
2958 mbs.param[9] = chan;
2961 mbs.param[1] = nphdl << 8;
2966 isp_mboxcmd(isp, &mbs);
2967 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2972 (((uint64_t)(mbs.param[2] >> 8)) << 56) |
2973 (((uint64_t)(mbs.param[2] & 0xff)) << 48) |
2974 (((uint64_t)(mbs.param[3] >> 8)) << 40) |
2975 (((uint64_t)(mbs.param[3] & 0xff)) << 32) |
2976 (((uint64_t)(mbs.param[6] >> 8)) << 24) |
2977 (((uint64_t)(mbs.param[6] & 0xff)) << 16) |
2978 (((uint64_t)(mbs.param[7] >> 8)) << 8) |
2979 (((uint64_t)(mbs.param[7] & 0xff)));
2982 (((uint64_t)(mbs.param[2] & 0xff)) << 56) |
2983 (((uint64_t)(mbs.param[2] >> 8)) << 48) |
2984 (((uint64_t)(mbs.param[3] & 0xff)) << 40) |
2985 (((uint64_t)(mbs.param[3] >> 8)) << 32) |
2986 (((uint64_t)(mbs.param[6] & 0xff)) << 24) |
2987 (((uint64_t)(mbs.param[6] >> 8)) << 16) |
2988 (((uint64_t)(mbs.param[7] & 0xff)) << 8) |
2989 (((uint64_t)(mbs.param[7] >> 8)));
2995 * Make sure we have good FC link.
2999 isp_fclink_test(ispsoftc_t *isp, int chan, int usdelay)
3006 NANOTIME_T hra, hrb;
3008 fcp = FCPARAM(isp, chan);
3010 if (fcp->isp_loopstate < LOOP_HAVE_LINK)
3012 if (fcp->isp_loopstate >= LOOP_LTEST_DONE)
3015 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC link test", chan);
3016 fcp->isp_loopstate = LOOP_TESTING_LINK;
3019 * Wait up to N microseconds for F/W to go to a ready state.
3023 isp_change_fw_state(isp, chan, isp_fw_state(isp, chan));
3024 if (fcp->isp_fwstate == FW_READY) {
3027 if (fcp->isp_loopstate < LOOP_TESTING_LINK)
3030 if ((NANOTIME_SUB(&hrb, &hra) / 1000 + 1000 >= usdelay))
3032 ISP_SLEEP(isp, 1000);
3034 if (fcp->isp_fwstate != FW_READY) {
3035 isp_prt(isp, ISP_LOG_SANCFG,
3036 "Chan %d Firmware is not ready (%s)",
3037 chan, isp_fc_fw_statename(fcp->isp_fwstate));
3042 * Get our Loop ID and Port ID.
3044 MBSINIT(&mbs, MBOX_GET_LOOP_ID, MBLOGALL, 0);
3045 mbs.param[9] = chan;
3046 isp_mboxcmd(isp, &mbs);
3047 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3053 * Don't bother with fabric if we are using really old
3054 * 2100 firmware. It's just not worth it.
3056 if (ISP_FW_NEWER_THAN(isp, 1, 15, 37))
3057 fcp->isp_topo = TOPO_FL_PORT;
3059 fcp->isp_topo = TOPO_NL_PORT;
3061 int topo = (int) mbs.param[6];
3062 if (topo < TOPO_NL_PORT || topo > TOPO_PTP_STUB) {
3063 topo = TOPO_PTP_STUB;
3065 fcp->isp_topo = topo;
3067 fcp->isp_portid = mbs.param[2] | (mbs.param[3] << 16);
3069 if (!TOPO_IS_FABRIC(fcp->isp_topo)) {
3070 fcp->isp_loopid = mbs.param[1] & 0xff;
3071 } else if (fcp->isp_topo != TOPO_F_PORT) {
3072 uint8_t alpa = fcp->isp_portid;
3074 for (i = 0; alpa_map[i]; i++) {
3075 if (alpa_map[i] == alpa)
3079 fcp->isp_loopid = i;
3082 if (fcp->isp_topo == TOPO_F_PORT || fcp->isp_topo == TOPO_FL_PORT) {
3083 nphdl = IS_24XX(isp) ? NPH_FL_ID : FL_ID;
3084 r = isp_getpdb(isp, chan, nphdl, &pdb, 1);
3085 if (r != 0 || pdb.portid == 0) {
3087 fcp->isp_topo = TOPO_NL_PORT;
3089 isp_prt(isp, ISP_LOGWARN,
3090 "fabric topology, but cannot get info about fabric controller (0x%x)", r);
3091 fcp->isp_topo = TOPO_PTP_STUB;
3097 fcp->isp_fabric_params = mbs.param[7];
3098 fcp->isp_sns_hdl = NPH_SNS_ID;
3099 r = isp_register_fc4_type_24xx(isp, chan);
3101 isp_register_fc4_features_24xx(isp, chan);
3103 fcp->isp_sns_hdl = SNS_ID;
3104 r = isp_register_fc4_type(isp, chan);
3105 if (r == 0 && fcp->role == ISP_ROLE_TARGET)
3106 isp_send_change_request(isp, chan);
3109 isp_prt(isp, ISP_LOGWARN|ISP_LOG_SANCFG, "%s: register fc4 type failed", __func__);
3115 /* Get link speed. */
3116 fcp->isp_gbspeed = 1;
3117 if (IS_23XX(isp) || IS_24XX(isp)) {
3118 MBSINIT(&mbs, MBOX_GET_SET_DATA_RATE, MBLOGALL, 3000000);
3119 mbs.param[1] = MBGSD_GET_RATE;
3120 /* mbs.param[2] undefined if we're just getting rate */
3121 isp_mboxcmd(isp, &mbs);
3122 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
3123 if (mbs.param[1] == MBGSD_10GB)
3124 fcp->isp_gbspeed = 10;
3125 else if (mbs.param[1] == MBGSD_16GB)
3126 fcp->isp_gbspeed = 16;
3127 else if (mbs.param[1] == MBGSD_8GB)
3128 fcp->isp_gbspeed = 8;
3129 else if (mbs.param[1] == MBGSD_4GB)
3130 fcp->isp_gbspeed = 4;
3131 else if (mbs.param[1] == MBGSD_2GB)
3132 fcp->isp_gbspeed = 2;
3133 else if (mbs.param[1] == MBGSD_1GB)
3134 fcp->isp_gbspeed = 1;
3138 if (fcp->isp_loopstate < LOOP_TESTING_LINK) {
3140 isp_prt(isp, ISP_LOG_SANCFG,
3141 "Chan %d FC link test aborted", chan);
3144 fcp->isp_loopstate = LOOP_LTEST_DONE;
3145 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGCONFIG,
3146 "Chan %d WWPN %016jx WWNN %016jx",
3147 chan, (uintmax_t)fcp->isp_wwpn, (uintmax_t)fcp->isp_wwnn);
3148 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGCONFIG,
3149 "Chan %d %dGb %s PortID 0x%06x LoopID 0x%02x",
3150 chan, fcp->isp_gbspeed, isp_fc_toponame(fcp), fcp->isp_portid,
3152 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC link test done", chan);
3157 * Complete the synchronization of our Port Database.
3159 * At this point, we've scanned the local loop (if any) and the fabric
3160 * and performed fabric logins on all new devices.
3162 * Our task here is to go through our port database removing any entities
3163 * that are still marked probational (issuing PLOGO for ones which we had
3164 * PLOGI'd into) or are dead, and notifying upper layers about new/changed
3168 isp_pdb_sync(ispsoftc_t *isp, int chan)
3170 fcparam *fcp = FCPARAM(isp, chan);
3174 if (fcp->isp_loopstate < LOOP_FSCAN_DONE)
3176 if (fcp->isp_loopstate >= LOOP_READY)
3179 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC PDB sync", chan);
3181 fcp->isp_loopstate = LOOP_SYNCING_PDB;
3183 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
3184 lp = &fcp->portdb[dbidx];
3186 if (lp->state == FC_PORTDB_STATE_NIL)
3188 if (lp->probational && lp->state != FC_PORTDB_STATE_ZOMBIE)
3189 lp->state = FC_PORTDB_STATE_DEAD;
3190 switch (lp->state) {
3191 case FC_PORTDB_STATE_DEAD:
3192 lp->state = FC_PORTDB_STATE_NIL;
3193 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp);
3194 if (lp->autologin == 0) {
3195 (void) isp_plogx(isp, chan, lp->handle,
3197 PLOGX_FLG_CMD_LOGO |
3198 PLOGX_FLG_IMPLICIT |
3199 PLOGX_FLG_FREE_NPHDL, 0);
3202 * Note that we might come out of this with our state
3203 * set to FC_PORTDB_STATE_ZOMBIE.
3206 case FC_PORTDB_STATE_NEW:
3207 lp->state = FC_PORTDB_STATE_VALID;
3208 isp_async(isp, ISPASYNC_DEV_ARRIVED, chan, lp);
3210 case FC_PORTDB_STATE_CHANGED:
3211 lp->state = FC_PORTDB_STATE_VALID;
3212 isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp);
3213 lp->portid = lp->new_portid;
3214 lp->prli_word3 = lp->new_prli_word3;
3216 case FC_PORTDB_STATE_VALID:
3217 isp_async(isp, ISPASYNC_DEV_STAYED, chan, lp);
3219 case FC_PORTDB_STATE_ZOMBIE:
3222 isp_prt(isp, ISP_LOGWARN,
3223 "isp_pdb_sync: state %d for idx %d",
3225 isp_dump_portdb(isp, chan);
3229 if (fcp->isp_loopstate < LOOP_SYNCING_PDB) {
3230 isp_prt(isp, ISP_LOG_SANCFG,
3231 "Chan %d FC PDB sync aborted", chan);
3235 fcp->isp_loopstate = LOOP_READY;
3236 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC PDB sync done", chan);
3241 isp_pdb_add_update(ispsoftc_t *isp, int chan, isp_pdb_t *pdb)
3244 uint64_t wwnn, wwpn;
3246 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb->nodename);
3247 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb->portname);
3249 /* Search port database for the same WWPN. */
3250 if (isp_find_pdb_by_wwpn(isp, chan, wwpn, &lp)) {
3251 if (!lp->probational) {
3252 isp_prt(isp, ISP_LOGERR,
3253 "Chan %d Port 0x%06x@0x%04x [%d] is not probational (0x%x)",
3254 chan, lp->portid, lp->handle,
3255 FC_PORTDB_TGT(isp, chan, lp), lp->state);
3256 isp_dump_portdb(isp, chan);
3259 lp->probational = 0;
3260 lp->node_wwn = wwnn;
3262 /* Old device, nothing new. */
3263 if (lp->portid == pdb->portid &&
3264 lp->handle == pdb->handle &&
3265 lp->prli_word3 == pdb->prli_word3) {
3266 if (lp->state != FC_PORTDB_STATE_NEW)
3267 lp->state = FC_PORTDB_STATE_VALID;
3268 isp_prt(isp, ISP_LOG_SANCFG,
3269 "Chan %d Port 0x%06x@0x%04x is valid",
3270 chan, pdb->portid, pdb->handle);
3274 /* Something has changed. */
3275 lp->state = FC_PORTDB_STATE_CHANGED;
3276 lp->handle = pdb->handle;
3277 lp->new_portid = pdb->portid;
3278 lp->new_prli_word3 = pdb->prli_word3;
3279 isp_prt(isp, ISP_LOG_SANCFG,
3280 "Chan %d Port 0x%06x@0x%04x is changed",
3281 chan, pdb->portid, pdb->handle);
3285 /* It seems like a new port. Find an empty slot for it. */
3286 if (!isp_find_pdb_empty(isp, chan, &lp)) {
3287 isp_prt(isp, ISP_LOGERR, "Chan %d out of portdb entries", chan);
3291 ISP_MEMZERO(lp, sizeof (fcportdb_t));
3293 lp->probational = 0;
3294 lp->state = FC_PORTDB_STATE_NEW;
3295 lp->portid = lp->new_portid = pdb->portid;
3296 lp->prli_word3 = lp->new_prli_word3 = pdb->prli_word3;
3297 lp->handle = pdb->handle;
3298 lp->port_wwn = wwpn;
3299 lp->node_wwn = wwnn;
3300 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Port 0x%06x@0x%04x is new",
3301 chan, pdb->portid, pdb->handle);
3305 * Fix port IDs for logged-in initiators on pre-2400 chips.
3306 * For those chips we are not receiving login events, adding initiators
3307 * based on ATIO requests, but there is no port ID in that structure.
3310 isp_fix_portids(ispsoftc_t *isp, int chan)
3312 fcparam *fcp = FCPARAM(isp, chan);
3317 for (i = 0; i < MAX_FC_TARG; i++) {
3318 fcportdb_t *lp = &fcp->portdb[i];
3320 if (lp->state == FC_PORTDB_STATE_NIL ||
3321 lp->state == FC_PORTDB_STATE_ZOMBIE)
3323 if (VALID_PORT(lp->portid))
3326 r = isp_getpdb(isp, chan, lp->handle, &pdb, 1);
3327 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
3330 isp_prt(isp, ISP_LOGDEBUG1,
3331 "Chan %d FC Scan Loop handle %d returned %x",
3332 chan, lp->handle, r);
3336 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3337 if (lp->port_wwn != wwpn)
3339 lp->portid = lp->new_portid = pdb.portid;
3340 isp_prt(isp, ISP_LOG_SANCFG,
3341 "Chan %d Port 0x%06x@0x%04x is fixed",
3342 chan, pdb.portid, pdb.handle);
3347 * Scan local loop for devices.
3350 isp_scan_loop(ispsoftc_t *isp, int chan)
3352 fcparam *fcp = FCPARAM(isp, chan);
3355 uint16_t handles[LOCAL_LOOP_LIM];
3358 if (fcp->isp_loopstate < LOOP_LTEST_DONE)
3360 if (fcp->isp_loopstate >= LOOP_LSCAN_DONE)
3363 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC loop scan", chan);
3364 fcp->isp_loopstate = LOOP_SCANNING_LOOP;
3365 if (TOPO_IS_FABRIC(fcp->isp_topo)) {
3366 if (!IS_24XX(isp)) {
3367 isp_fix_portids(isp, chan);
3368 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
3371 isp_prt(isp, ISP_LOG_SANCFG,
3372 "Chan %d FC loop scan done (no loop)", chan);
3373 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3377 lim = LOCAL_LOOP_LIM;
3378 r = isp_gethandles(isp, chan, handles, &lim, 1, 1);
3380 isp_prt(isp, ISP_LOG_SANCFG,
3381 "Chan %d Getting list of handles failed with %x", chan, r);
3382 isp_prt(isp, ISP_LOG_SANCFG,
3383 "Chan %d FC loop scan done (bad)", chan);
3387 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Got %d handles",
3391 * Run through the list and get the port database info for each one.
3393 isp_mark_portdb(isp, chan);
3394 for (idx = 0; idx < lim; idx++) {
3395 handle = handles[idx];
3398 * Don't scan "special" ids.
3400 if (ISP_CAP_2KLOGIN(isp)) {
3401 if (handle >= NPH_RESERVED)
3404 if (handle >= FL_ID && handle <= SNS_ID)
3409 * In older cards with older f/w GET_PORT_DATABASE has been
3410 * known to hang. This trick gets around that problem.
3412 if (IS_2100(isp) || IS_2200(isp)) {
3413 uint64_t node_wwn = isp_get_wwn(isp, chan, handle, 1);
3414 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
3416 isp_prt(isp, ISP_LOG_SANCFG,
3417 "Chan %d FC loop scan aborted", chan);
3420 if (node_wwn == INI_NONE) {
3426 * Get the port database entity for this index.
3428 r = isp_getpdb(isp, chan, handle, &pdb, 1);
3429 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
3432 isp_prt(isp, ISP_LOGDEBUG1,
3433 "Chan %d FC Scan Loop handle %d returned %x",
3438 isp_pdb_add_update(isp, chan, &pdb);
3440 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
3442 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3443 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC loop scan done", chan);
3448 * Scan the fabric for devices and add them to our port database.
3450 * Use the GID_FT command to get all Port IDs for FC4 SCSI devices it knows.
3452 * For 2100-23XX cards, we can use the SNS mailbox command to pass simple
3453 * name server commands to the switch management server via the QLogic f/w.
3455 * For the 24XX card, we have to use CT-Pass through run via the Execute IOCB
3458 * The net result is to leave the list of Port IDs setting untranslated in
3459 * offset IGPOFF of the FC scratch area, whereupon we'll canonicalize it to
3460 * host order at OGPOFF.
3464 * Take half of our scratch area to store Port IDs
3466 #define GIDLEN (ISP_FC_SCRLEN >> 1)
3467 #define NGENT ((GIDLEN - 16) >> 2)
3470 #define OGPOFF (ISP_FC_SCRLEN >> 1)
3471 #define XTXOFF (ISP_FC_SCRLEN - (3 * QENTRY_LEN)) /* CT request */
3472 #define CTXOFF (ISP_FC_SCRLEN - (2 * QENTRY_LEN)) /* Request IOCB */
3473 #define ZTXOFF (ISP_FC_SCRLEN - (1 * QENTRY_LEN)) /* Response IOCB */
3476 isp_gid_ft_sns(ispsoftc_t *isp, int chan)
3479 sns_gid_ft_req_t _x;
3480 uint8_t _y[SNS_GID_FT_REQ_SIZE];
3482 fcparam *fcp = FCPARAM(isp, chan);
3483 sns_gid_ft_req_t *rq = &un._x;
3484 uint8_t *scp = fcp->isp_scratch;
3487 isp_prt(isp, ISP_LOGDEBUG0, "Chan %d scanning fabric (GID_FT) via SNS", chan);
3489 ISP_MEMZERO(rq, SNS_GID_FT_REQ_SIZE);
3490 rq->snscb_rblen = GIDLEN >> 1;
3491 rq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma + IGPOFF);
3492 rq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma + IGPOFF);
3493 rq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma + IGPOFF);
3494 rq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma + IGPOFF);
3495 rq->snscb_sblen = 6;
3496 rq->snscb_cmd = SNS_GID_FT;
3497 rq->snscb_mword_div_2 = NGENT;
3498 rq->snscb_fc4_type = FC4_SCSI;
3500 isp_put_gid_ft_request(isp, rq, (sns_gid_ft_req_t *)&scp[CTXOFF]);
3501 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GID_FT_REQ_SIZE, chan);
3503 MBSINIT(&mbs, MBOX_SEND_SNS, MBLOGALL, 10000000);
3504 mbs.param[0] = MBOX_SEND_SNS;
3505 mbs.param[1] = SNS_GID_FT_REQ_SIZE >> 1;
3506 mbs.param[2] = DMA_WD1(fcp->isp_scdma + CTXOFF);
3507 mbs.param[3] = DMA_WD0(fcp->isp_scdma + CTXOFF);
3508 mbs.param[6] = DMA_WD3(fcp->isp_scdma + CTXOFF);
3509 mbs.param[7] = DMA_WD2(fcp->isp_scdma + CTXOFF);
3510 isp_mboxcmd(isp, &mbs);
3511 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3512 if (mbs.param[0] == MBOX_INVALID_COMMAND) {
3522 isp_gid_ft_ct_passthru(ispsoftc_t *isp, int chan)
3525 fcparam *fcp = FCPARAM(isp, chan);
3529 uint8_t q[QENTRY_LEN];
3534 uint8_t *scp = fcp->isp_scratch;
3536 isp_prt(isp, ISP_LOGDEBUG0, "Chan %d scanning fabric (GID_FT) via CT", chan);
3539 * Build a Passthrough IOCB in memory.
3542 ISP_MEMZERO(un.q, QENTRY_LEN);
3543 pt->ctp_header.rqs_entry_count = 1;
3544 pt->ctp_header.rqs_entry_type = RQSTYPE_CT_PASSTHRU;
3545 pt->ctp_handle = 0xffffffff;
3546 pt->ctp_nphdl = fcp->isp_sns_hdl;
3547 pt->ctp_cmd_cnt = 1;
3548 pt->ctp_vpidx = ISP_GET_VPIDX(isp, chan);
3550 pt->ctp_rsp_cnt = 1;
3551 pt->ctp_rsp_bcnt = GIDLEN;
3552 pt->ctp_cmd_bcnt = sizeof (*ct) + sizeof (uint32_t);
3553 pt->ctp_dataseg[0].ds_base = DMA_LO32(fcp->isp_scdma+XTXOFF);
3554 pt->ctp_dataseg[0].ds_basehi = DMA_HI32(fcp->isp_scdma+XTXOFF);
3555 pt->ctp_dataseg[0].ds_count = sizeof (*ct) + sizeof (uint32_t);
3556 pt->ctp_dataseg[1].ds_base = DMA_LO32(fcp->isp_scdma+IGPOFF);
3557 pt->ctp_dataseg[1].ds_basehi = DMA_HI32(fcp->isp_scdma+IGPOFF);
3558 pt->ctp_dataseg[1].ds_count = GIDLEN;
3559 if (isp->isp_dblev & ISP_LOGDEBUG1) {
3560 isp_print_bytes(isp, "ct IOCB", QENTRY_LEN, pt);
3562 isp_put_ct_pt(isp, pt, (isp_ct_pt_t *) &scp[CTXOFF]);
3565 * Build the CT header and command in memory.
3567 * Note that the CT header has to end up as Big Endian format in memory.
3570 ISP_MEMZERO(ct, sizeof (*ct));
3571 ct->ct_revision = CT_REVISION;
3572 ct->ct_fcs_type = CT_FC_TYPE_FC;
3573 ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS;
3574 ct->ct_cmd_resp = SNS_GID_FT;
3575 ct->ct_bcnt_resid = (GIDLEN - 16) >> 2;
3577 isp_put_ct_hdr(isp, ct, (ct_hdr_t *) &scp[XTXOFF]);
3578 rp = (uint32_t *) &scp[XTXOFF+sizeof (*ct)];
3579 ISP_IOZPUT_32(isp, FC4_SCSI, rp);
3580 if (isp->isp_dblev & ISP_LOGDEBUG1) {
3581 isp_print_bytes(isp, "CT HDR + payload after put",
3582 sizeof (*ct) + sizeof (uint32_t), &scp[XTXOFF]);
3584 ISP_MEMZERO(&scp[ZTXOFF], QENTRY_LEN);
3585 MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
3586 MBCMD_DEFAULT_TIMEOUT + pt->ctp_time * 1000000);
3587 mbs.param[1] = QENTRY_LEN;
3588 mbs.param[2] = DMA_WD1(fcp->isp_scdma + CTXOFF);
3589 mbs.param[3] = DMA_WD0(fcp->isp_scdma + CTXOFF);
3590 mbs.param[6] = DMA_WD3(fcp->isp_scdma + CTXOFF);
3591 mbs.param[7] = DMA_WD2(fcp->isp_scdma + CTXOFF);
3592 MEMORYBARRIER(isp, SYNC_SFORDEV, XTXOFF, 2 * QENTRY_LEN, chan);
3593 isp_mboxcmd(isp, &mbs);
3594 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3597 MEMORYBARRIER(isp, SYNC_SFORCPU, ZTXOFF, QENTRY_LEN, chan);
3599 isp_get_ct_pt(isp, (isp_ct_pt_t *) &scp[ZTXOFF], pt);
3600 if (isp->isp_dblev & ISP_LOGDEBUG1) {
3601 isp_print_bytes(isp, "IOCB response", QENTRY_LEN, pt);
3604 if (pt->ctp_status && pt->ctp_status != RQCS_DATA_UNDERRUN) {
3605 isp_prt(isp, ISP_LOGWARN,
3606 "Chan %d ISP GID FT CT Passthrough returned 0x%x",
3607 chan, pt->ctp_status);
3610 MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN, chan);
3611 if (isp->isp_dblev & ISP_LOGDEBUG1) {
3612 isp_print_bytes(isp, "CT response", GIDLEN, &scp[IGPOFF]);
3618 isp_scan_fabric(ispsoftc_t *isp, int chan)
3620 fcparam *fcp = FCPARAM(isp, chan);
3625 int portidx, portlim, r;
3626 sns_gid_ft_rsp_t *rs0, *rs1;
3628 if (fcp->isp_loopstate < LOOP_LSCAN_DONE)
3630 if (fcp->isp_loopstate >= LOOP_FSCAN_DONE)
3633 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC fabric scan", chan);
3634 fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
3635 if (!TOPO_IS_FABRIC(fcp->isp_topo)) {
3636 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3637 isp_prt(isp, ISP_LOG_SANCFG,
3638 "Chan %d FC fabric scan done (no fabric)", chan);
3642 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
3643 isp_prt(isp, ISP_LOGERR, sacq);
3645 isp_prt(isp, ISP_LOG_SANCFG,
3646 "Chan %d FC fabric scan done (bad)", chan);
3649 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3651 FC_SCRATCH_RELEASE(isp, chan);
3652 isp_prt(isp, ISP_LOG_SANCFG,
3653 "Chan %d FC fabric scan aborted", chan);
3658 * Make sure we still are logged into the fabric controller.
3660 nphdl = IS_24XX(isp) ? NPH_FL_ID : FL_ID;
3661 r = isp_getpdb(isp, chan, nphdl, &pdb, 0);
3662 if ((r & 0xffff) == MBOX_NOT_LOGGED_IN) {
3663 isp_dump_chip_portdb(isp, chan, 0);
3666 fcp->isp_loopstate = LOOP_LTEST_DONE;
3667 FC_SCRATCH_RELEASE(isp, chan);
3671 /* Get list of port IDs from SNS. */
3673 r = isp_gid_ft_ct_passthru(isp, chan);
3675 r = isp_gid_ft_sns(isp, chan);
3676 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC)
3679 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3680 FC_SCRATCH_RELEASE(isp, chan);
3683 fcp->isp_loopstate = LOOP_LTEST_DONE; /* try again */
3684 FC_SCRATCH_RELEASE(isp, chan);
3688 MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN, chan);
3689 rs0 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+IGPOFF);
3690 rs1 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+OGPOFF);
3691 isp_get_gid_ft_response(isp, rs0, rs1, NGENT);
3692 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC)
3694 if (rs1->snscb_cthdr.ct_cmd_resp != LS_ACC) {
3696 if (rs1->snscb_cthdr.ct_reason == 9 && rs1->snscb_cthdr.ct_explanation == 7) {
3697 level = ISP_LOG_SANCFG;
3699 level = ISP_LOGWARN;
3701 isp_prt(isp, level, "Chan %d Fabric Nameserver rejected GID_FT"
3702 " (Reason=0x%x Expl=0x%x)", chan,
3703 rs1->snscb_cthdr.ct_reason,
3704 rs1->snscb_cthdr.ct_explanation);
3705 FC_SCRATCH_RELEASE(isp, chan);
3706 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3710 /* Check our buffer was big enough to get the full list. */
3711 for (portidx = 0; portidx < NGENT-1; portidx++) {
3712 if (rs1->snscb_ports[portidx].control & 0x80)
3715 if ((rs1->snscb_ports[portidx].control & 0x80) == 0) {
3716 isp_prt(isp, ISP_LOGWARN,
3717 "fabric too big for scratch area: increase ISP_FC_SCRLEN");
3719 portlim = portidx + 1;
3720 isp_prt(isp, ISP_LOG_SANCFG,
3721 "Chan %d Got %d ports back from name server", chan, portlim);
3723 /* Go through the list and remove duplicate port ids. */
3724 for (portidx = 0; portidx < portlim; portidx++) {
3728 ((rs1->snscb_ports[portidx].portid[0]) << 16) |
3729 ((rs1->snscb_ports[portidx].portid[1]) << 8) |
3730 ((rs1->snscb_ports[portidx].portid[2]));
3732 for (npidx = portidx + 1; npidx < portlim; npidx++) {
3733 uint32_t new_portid =
3734 ((rs1->snscb_ports[npidx].portid[0]) << 16) |
3735 ((rs1->snscb_ports[npidx].portid[1]) << 8) |
3736 ((rs1->snscb_ports[npidx].portid[2]));
3737 if (new_portid == portid) {
3742 if (npidx < portlim) {
3743 rs1->snscb_ports[npidx].portid[0] = 0;
3744 rs1->snscb_ports[npidx].portid[1] = 0;
3745 rs1->snscb_ports[npidx].portid[2] = 0;
3746 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d removing duplicate PortID 0x%06x entry from list", chan, portid);
3751 * We now have a list of Port IDs for all FC4 SCSI devices
3752 * that the Fabric Name server knows about.
3754 * For each entry on this list go through our port database looking
3755 * for probational entries- if we find one, then an old entry is
3756 * maybe still this one. We get some information to find out.
3758 * Otherwise, it's a new fabric device, and we log into it
3759 * (unconditionally). After searching the entire database
3760 * again to make sure that we never ever ever ever have more
3761 * than one entry that has the same PortID or the same
3762 * WWNN/WWPN duple, we enter the device into our database.
3764 isp_mark_portdb(isp, chan);
3765 for (portidx = 0; portidx < portlim; portidx++) {
3766 portid = ((rs1->snscb_ports[portidx].portid[0]) << 16) |
3767 ((rs1->snscb_ports[portidx].portid[1]) << 8) |
3768 ((rs1->snscb_ports[portidx].portid[2]));
3769 isp_prt(isp, ISP_LOG_SANCFG,
3770 "Chan %d Checking fabric port 0x%06x", chan, portid);
3772 isp_prt(isp, ISP_LOG_SANCFG,
3773 "Chan %d Port at idx %d is zero",
3777 if (portid == fcp->isp_portid) {
3778 isp_prt(isp, ISP_LOG_SANCFG,
3779 "Chan %d Port 0x%06x is our", chan, portid);
3783 /* Now search the entire port database for the same portid. */
3784 if (isp_find_pdb_by_portid(isp, chan, portid, &lp)) {
3785 if (!lp->probational) {
3786 isp_prt(isp, ISP_LOGERR,
3787 "Chan %d Port 0x%06x@0x%04x [%d] is not probational (0x%x)",
3788 chan, lp->portid, lp->handle,
3789 FC_PORTDB_TGT(isp, chan, lp), lp->state);
3790 FC_SCRATCH_RELEASE(isp, chan);
3791 isp_dump_portdb(isp, chan);
3796 * See if we're still logged into it.
3798 * If we aren't, mark it as a dead device and
3799 * leave the new portid in the database entry
3800 * for somebody further along to decide what to
3801 * do (policy choice).
3803 * If we are, check to see if it's the same
3804 * device still (it should be). If for some
3805 * reason it isn't, mark it as a changed device
3806 * and leave the new portid and role in the
3807 * database entry for somebody further along to
3808 * decide what to do (policy choice).
3810 r = isp_getpdb(isp, chan, lp->handle, &pdb, 0);
3811 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC)
3814 lp->state = FC_PORTDB_STATE_DEAD;
3815 isp_prt(isp, ISP_LOG_SANCFG,
3816 "Chan %d Port 0x%06x handle 0x%x is dead (%d)",
3817 chan, portid, lp->handle, r);
3821 isp_pdb_add_update(isp, chan, &pdb);
3826 if ((fcp->role & ISP_ROLE_INITIATOR) == 0) {
3827 isp_prt(isp, ISP_LOG_SANCFG,
3828 "Chan %d Port 0x%06x is not logged in", chan, portid);
3832 if (isp_login_device(isp, chan, portid, &pdb,
3833 &FCPARAM(isp, 0)->isp_lasthdl)) {
3834 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC)
3839 isp_pdb_add_update(isp, chan, &pdb);
3842 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC)
3844 FC_SCRATCH_RELEASE(isp, chan);
3845 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3846 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC fabric scan done", chan);
3851 * Find an unused handle and try and use to login to a port.
3854 isp_login_device(ispsoftc_t *isp, int chan, uint32_t portid, isp_pdb_t *p, uint16_t *ohp)
3859 if (ISP_CAP_2KLOGIN(isp)) {
3865 handle = isp_next_handle(isp, ohp);
3866 for (i = 0; i < lim; i++) {
3867 if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC)
3870 /* Check if this handle is free. */
3871 r = isp_getpdb(isp, chan, handle, p, 0);
3873 if (p->portid != portid) {
3874 /* This handle is busy, try next one. */
3875 handle = isp_next_handle(isp, ohp);
3880 if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC)
3884 * Now try and log into the device
3886 r = isp_plogx(isp, chan, handle, portid, PLOGX_FLG_CMD_PLOGI, 1);
3889 } else if ((r & 0xffff) == MBOX_PORT_ID_USED) {
3891 * If we get here, then the firmwware still thinks we're logged into this device, but with a different
3892 * handle. We need to break that association. We used to try and just substitute the handle, but then
3893 * failed to get any data via isp_getpdb (below).
3895 if (isp_plogx(isp, chan, r >> 16, portid, PLOGX_FLG_CMD_LOGO | PLOGX_FLG_IMPLICIT | PLOGX_FLG_FREE_NPHDL, 1)) {
3896 isp_prt(isp, ISP_LOGERR, "baw... logout of %x failed", r >> 16);
3898 if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC)
3900 r = isp_plogx(isp, chan, handle, portid, PLOGX_FLG_CMD_PLOGI, 1);
3904 } else if ((r & 0xffff) == MBOX_LOOP_ID_USED) {
3905 /* Try the next handle. */
3906 handle = isp_next_handle(isp, ohp);
3915 isp_prt(isp, ISP_LOGWARN, "Chan %d PLOGI 0x%06x failed", chan, portid);
3920 * If we successfully logged into it, get the PDB for it
3921 * so we can crosscheck that it is still what we think it
3922 * is and that we also have the role it plays
3924 r = isp_getpdb(isp, chan, handle, p, 0);
3926 isp_prt(isp, ISP_LOGERR, "Chan %d new device 0x%06x@0x%x disappeared", chan, portid, handle);
3930 if (p->handle != handle || p->portid != portid) {
3931 isp_prt(isp, ISP_LOGERR, "Chan %d new device 0x%06x@0x%x changed (0x%06x@0x%0x)",
3932 chan, portid, handle, p->portid, p->handle);
3939 isp_send_change_request(ispsoftc_t *isp, int chan)
3943 MBSINIT(&mbs, MBOX_SEND_CHANGE_REQUEST, MBLOGALL, 500000);
3944 mbs.param[1] = 0x03;
3945 mbs.param[9] = chan;
3946 isp_mboxcmd(isp, &mbs);
3947 return (mbs.param[0] == MBOX_COMMAND_COMPLETE ? 0 : -1);
3951 isp_register_fc4_type(ispsoftc_t *isp, int chan)
3953 fcparam *fcp = FCPARAM(isp, chan);
3954 uint8_t local[SNS_RFT_ID_REQ_SIZE];
3955 sns_screq_t *reqp = (sns_screq_t *) local;
3958 ISP_MEMZERO((void *) reqp, SNS_RFT_ID_REQ_SIZE);
3959 reqp->snscb_rblen = SNS_RFT_ID_RESP_SIZE >> 1;
3960 reqp->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma + 0x100);
3961 reqp->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma + 0x100);
3962 reqp->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma + 0x100);
3963 reqp->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma + 0x100);
3964 reqp->snscb_sblen = 22;
3965 reqp->snscb_data[0] = SNS_RFT_ID;
3966 reqp->snscb_data[4] = fcp->isp_portid & 0xffff;
3967 reqp->snscb_data[5] = (fcp->isp_portid >> 16) & 0xff;
3968 reqp->snscb_data[6] = (1 << FC4_SCSI);
3969 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
3970 isp_prt(isp, ISP_LOGERR, sacq);
3973 isp_put_sns_request(isp, reqp, (sns_screq_t *) fcp->isp_scratch);
3974 MBSINIT(&mbs, MBOX_SEND_SNS, MBLOGALL, 1000000);
3975 mbs.param[1] = SNS_RFT_ID_REQ_SIZE >> 1;
3976 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
3977 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
3978 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
3979 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
3980 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_RFT_ID_REQ_SIZE, chan);
3981 isp_mboxcmd(isp, &mbs);
3982 FC_SCRATCH_RELEASE(isp, chan);
3983 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
3991 isp_register_fc4_type_24xx(ispsoftc_t *isp, int chan)
3994 fcparam *fcp = FCPARAM(isp, chan);
3998 uint8_t q[QENTRY_LEN];
4003 uint8_t *scp = fcp->isp_scratch;
4005 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
4006 isp_prt(isp, ISP_LOGERR, sacq);
4011 * Build a Passthrough IOCB in memory.
4013 ISP_MEMZERO(un.q, QENTRY_LEN);
4015 pt->ctp_header.rqs_entry_count = 1;
4016 pt->ctp_header.rqs_entry_type = RQSTYPE_CT_PASSTHRU;
4017 pt->ctp_handle = 0xffffffff;
4018 pt->ctp_nphdl = fcp->isp_sns_hdl;
4019 pt->ctp_cmd_cnt = 1;
4020 pt->ctp_vpidx = ISP_GET_VPIDX(isp, chan);
4022 pt->ctp_rsp_cnt = 1;
4023 pt->ctp_rsp_bcnt = sizeof (ct_hdr_t);
4024 pt->ctp_cmd_bcnt = sizeof (rft_id_t);
4025 pt->ctp_dataseg[0].ds_base = DMA_LO32(fcp->isp_scdma+XTXOFF);
4026 pt->ctp_dataseg[0].ds_basehi = DMA_HI32(fcp->isp_scdma+XTXOFF);
4027 pt->ctp_dataseg[0].ds_count = sizeof (rft_id_t);
4028 pt->ctp_dataseg[1].ds_base = DMA_LO32(fcp->isp_scdma+IGPOFF);
4029 pt->ctp_dataseg[1].ds_basehi = DMA_HI32(fcp->isp_scdma+IGPOFF);
4030 pt->ctp_dataseg[1].ds_count = sizeof (ct_hdr_t);
4031 isp_put_ct_pt(isp, pt, (isp_ct_pt_t *) &scp[CTXOFF]);
4032 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4033 isp_print_bytes(isp, "IOCB CT Request", QENTRY_LEN, pt);
4037 * Build the CT header and command in memory.
4039 * Note that the CT header has to end up as Big Endian format in memory.
4041 ISP_MEMZERO(&un.clocal, sizeof (un.clocal));
4042 ct = &un.clocal.rftid_hdr;
4043 ct->ct_revision = CT_REVISION;
4044 ct->ct_fcs_type = CT_FC_TYPE_FC;
4045 ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS;
4046 ct->ct_cmd_resp = SNS_RFT_ID;
4047 ct->ct_bcnt_resid = (sizeof (rft_id_t) - sizeof (ct_hdr_t)) >> 2;
4049 rp->rftid_portid[0] = fcp->isp_portid >> 16;
4050 rp->rftid_portid[1] = fcp->isp_portid >> 8;
4051 rp->rftid_portid[2] = fcp->isp_portid;
4052 rp->rftid_fc4types[FC4_SCSI >> 5] = 1 << (FC4_SCSI & 0x1f);
4053 isp_put_rft_id(isp, rp, (rft_id_t *) &scp[XTXOFF]);
4054 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4055 isp_print_bytes(isp, "CT Header", QENTRY_LEN, &scp[XTXOFF]);
4058 ISP_MEMZERO(&scp[ZTXOFF], sizeof (ct_hdr_t));
4060 MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
4061 MBCMD_DEFAULT_TIMEOUT + pt->ctp_time * 1000000);
4062 mbs.param[1] = QENTRY_LEN;
4063 mbs.param[2] = DMA_WD1(fcp->isp_scdma + CTXOFF);
4064 mbs.param[3] = DMA_WD0(fcp->isp_scdma + CTXOFF);
4065 mbs.param[6] = DMA_WD3(fcp->isp_scdma + CTXOFF);
4066 mbs.param[7] = DMA_WD2(fcp->isp_scdma + CTXOFF);
4067 MEMORYBARRIER(isp, SYNC_SFORDEV, XTXOFF, 2 * QENTRY_LEN, chan);
4068 isp_mboxcmd(isp, &mbs);
4069 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4070 FC_SCRATCH_RELEASE(isp, chan);
4073 MEMORYBARRIER(isp, SYNC_SFORCPU, ZTXOFF, QENTRY_LEN, chan);
4075 isp_get_ct_pt(isp, (isp_ct_pt_t *) &scp[ZTXOFF], pt);
4076 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4077 isp_print_bytes(isp, "IOCB response", QENTRY_LEN, pt);
4079 if (pt->ctp_status) {
4080 FC_SCRATCH_RELEASE(isp, chan);
4081 isp_prt(isp, ISP_LOGWARN,
4082 "Chan %d Register FC4 Type CT Passthrough returned 0x%x",
4083 chan, pt->ctp_status);
4087 isp_get_ct_hdr(isp, (ct_hdr_t *) &scp[IGPOFF], ct);
4088 FC_SCRATCH_RELEASE(isp, chan);
4090 if (ct->ct_cmd_resp == LS_RJT) {
4091 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "Chan %d Register FC4 Type rejected", chan);
4093 } else if (ct->ct_cmd_resp == LS_ACC) {
4094 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Register FC4 Type accepted", chan);
4097 isp_prt(isp, ISP_LOGWARN, "Chan %d Register FC4 Type: 0x%x", chan, ct->ct_cmd_resp);
4103 isp_register_fc4_features_24xx(ispsoftc_t *isp, int chan)
4106 fcparam *fcp = FCPARAM(isp, chan);
4110 uint8_t q[QENTRY_LEN];
4115 uint8_t *scp = fcp->isp_scratch;
4117 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
4118 isp_prt(isp, ISP_LOGERR, sacq);
4123 * Build a Passthrough IOCB in memory.
4125 ISP_MEMZERO(un.q, QENTRY_LEN);
4127 pt->ctp_header.rqs_entry_count = 1;
4128 pt->ctp_header.rqs_entry_type = RQSTYPE_CT_PASSTHRU;
4129 pt->ctp_handle = 0xffffffff;
4130 pt->ctp_nphdl = fcp->isp_sns_hdl;
4131 pt->ctp_cmd_cnt = 1;
4132 pt->ctp_vpidx = ISP_GET_VPIDX(isp, chan);
4134 pt->ctp_rsp_cnt = 1;
4135 pt->ctp_rsp_bcnt = sizeof (ct_hdr_t);
4136 pt->ctp_cmd_bcnt = sizeof (rff_id_t);
4137 pt->ctp_dataseg[0].ds_base = DMA_LO32(fcp->isp_scdma+XTXOFF);
4138 pt->ctp_dataseg[0].ds_basehi = DMA_HI32(fcp->isp_scdma+XTXOFF);
4139 pt->ctp_dataseg[0].ds_count = sizeof (rff_id_t);
4140 pt->ctp_dataseg[1].ds_base = DMA_LO32(fcp->isp_scdma+IGPOFF);
4141 pt->ctp_dataseg[1].ds_basehi = DMA_HI32(fcp->isp_scdma+IGPOFF);
4142 pt->ctp_dataseg[1].ds_count = sizeof (ct_hdr_t);
4143 isp_put_ct_pt(isp, pt, (isp_ct_pt_t *) &scp[CTXOFF]);
4144 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4145 isp_print_bytes(isp, "IOCB CT Request", QENTRY_LEN, pt);
4149 * Build the CT header and command in memory.
4151 * Note that the CT header has to end up as Big Endian format in memory.
4153 ISP_MEMZERO(&un.clocal, sizeof (un.clocal));
4154 ct = &un.clocal.rffid_hdr;
4155 ct->ct_revision = CT_REVISION;
4156 ct->ct_fcs_type = CT_FC_TYPE_FC;
4157 ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS;
4158 ct->ct_cmd_resp = SNS_RFF_ID;
4159 ct->ct_bcnt_resid = (sizeof (rff_id_t) - sizeof (ct_hdr_t)) >> 2;
4161 rp->rffid_portid[0] = fcp->isp_portid >> 16;
4162 rp->rffid_portid[1] = fcp->isp_portid >> 8;
4163 rp->rffid_portid[2] = fcp->isp_portid;
4164 rp->rffid_fc4features = 0;
4165 if (fcp->role & ISP_ROLE_TARGET)
4166 rp->rffid_fc4features |= 1;
4167 if (fcp->role & ISP_ROLE_INITIATOR)
4168 rp->rffid_fc4features |= 2;
4169 rp->rffid_fc4type = FC4_SCSI;
4170 isp_put_rff_id(isp, rp, (rff_id_t *) &scp[XTXOFF]);
4171 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4172 isp_print_bytes(isp, "CT Header", QENTRY_LEN, &scp[XTXOFF]);
4175 ISP_MEMZERO(&scp[ZTXOFF], sizeof (ct_hdr_t));
4177 MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
4178 MBCMD_DEFAULT_TIMEOUT + pt->ctp_time * 1000000);
4179 mbs.param[1] = QENTRY_LEN;
4180 mbs.param[2] = DMA_WD1(fcp->isp_scdma + CTXOFF);
4181 mbs.param[3] = DMA_WD0(fcp->isp_scdma + CTXOFF);
4182 mbs.param[6] = DMA_WD3(fcp->isp_scdma + CTXOFF);
4183 mbs.param[7] = DMA_WD2(fcp->isp_scdma + CTXOFF);
4184 MEMORYBARRIER(isp, SYNC_SFORDEV, XTXOFF, 2 * QENTRY_LEN, chan);
4185 isp_mboxcmd(isp, &mbs);
4186 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4187 FC_SCRATCH_RELEASE(isp, chan);
4190 MEMORYBARRIER(isp, SYNC_SFORCPU, ZTXOFF, QENTRY_LEN, chan);
4192 isp_get_ct_pt(isp, (isp_ct_pt_t *) &scp[ZTXOFF], pt);
4193 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4194 isp_print_bytes(isp, "IOCB response", QENTRY_LEN, pt);
4196 if (pt->ctp_status) {
4197 FC_SCRATCH_RELEASE(isp, chan);
4198 isp_prt(isp, ISP_LOGWARN,
4199 "Chan %d Register FC4 Features CT Passthrough returned 0x%x",
4200 chan, pt->ctp_status);
4204 isp_get_ct_hdr(isp, (ct_hdr_t *) &scp[IGPOFF], ct);
4205 FC_SCRATCH_RELEASE(isp, chan);
4207 if (ct->ct_cmd_resp == LS_RJT) {
4208 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1,
4209 "Chan %d Register FC4 Features rejected", chan);
4211 } else if (ct->ct_cmd_resp == LS_ACC) {
4212 isp_prt(isp, ISP_LOG_SANCFG,
4213 "Chan %d Register FC4 Features accepted", chan);
4216 isp_prt(isp, ISP_LOGWARN,
4217 "Chan %d Register FC4 Features: 0x%x", chan, ct->ct_cmd_resp);
4223 isp_next_handle(ispsoftc_t *isp, uint16_t *ohp)
4227 uint16_t handle, minh, maxh;
4230 if (ISP_CAP_2KLOGIN(isp)) {
4232 maxh = NPH_RESERVED - 1;
4240 if (handle == NIL_HANDLE) {
4244 if (handle > maxh) {
4246 isp_prt(isp, ISP_LOGERR, "Out of port handles!");
4247 return (NIL_HANDLE);
4252 for (chan = 0; chan < isp->isp_nchan; chan++) {
4253 fcp = FCPARAM(isp, chan);
4254 if (fcp->role == ISP_ROLE_NONE)
4256 for (i = 0; i < MAX_FC_TARG; i++) {
4257 if (fcp->portdb[i].state != FC_PORTDB_STATE_NIL &&
4258 fcp->portdb[i].handle == handle)
4267 * Start a command. Locking is assumed done in the caller.
4275 uint8_t local[QENTRY_LEN];
4280 int target, dmaresult;
4286 * Check command CDB length, etc.. We really are limited to 16 bytes
4287 * for Fibre Channel, but can do up to 44 bytes in parallel SCSI,
4288 * but probably only if we're running fairly new firmware (we'll
4289 * let the old f/w choke on an extended command queue entry).
4292 if (XS_CDBLEN(xs) > (IS_FC(isp)? 16 : 44) || XS_CDBLEN(xs) == 0) {
4293 isp_prt(isp, ISP_LOGERR, "unsupported cdb length (%d, CDB[0]=0x%x)", XS_CDBLEN(xs), XS_CDBP(xs)[0] & 0xff);
4294 XS_SETERR(xs, HBA_BOTCH);
4295 return (CMD_COMPLETE);
4299 * Translate the target to device handle as appropriate, checking
4300 * for correct device state as well.
4302 target = XS_TGT(xs);
4304 fcparam *fcp = FCPARAM(isp, XS_CHANNEL(xs));
4306 if ((fcp->role & ISP_ROLE_INITIATOR) == 0) {
4307 isp_prt(isp, ISP_LOG_WARN1,
4308 "%d.%d.%jx I am not an initiator",
4309 XS_CHANNEL(xs), target, (uintmax_t)XS_LUN(xs));
4310 XS_SETERR(xs, HBA_SELTIMEOUT);
4311 return (CMD_COMPLETE);
4314 if (isp->isp_state != ISP_RUNSTATE) {
4315 isp_prt(isp, ISP_LOGERR, "Adapter not at RUNSTATE");
4316 XS_SETERR(xs, HBA_BOTCH);
4317 return (CMD_COMPLETE);
4323 if (fcp->isp_loopstate != LOOP_READY) {
4324 return (CMD_RQLATER);
4327 isp_prt(isp, ISP_LOGDEBUG2, "XS_TGT(xs)=%d", target);
4328 lp = &fcp->portdb[target];
4329 if (target < 0 || target >= MAX_FC_TARG ||
4330 lp->is_target == 0) {
4331 XS_SETERR(xs, HBA_SELTIMEOUT);
4332 return (CMD_COMPLETE);
4334 if (lp->state == FC_PORTDB_STATE_ZOMBIE) {
4335 isp_prt(isp, ISP_LOGDEBUG1,
4336 "%d.%d.%jx target zombie",
4337 XS_CHANNEL(xs), target, (uintmax_t)XS_LUN(xs));
4338 return (CMD_RQLATER);
4340 if (lp->state != FC_PORTDB_STATE_VALID) {
4341 isp_prt(isp, ISP_LOGDEBUG1,
4342 "%d.%d.%jx bad db port state 0x%x",
4343 XS_CHANNEL(xs), target, (uintmax_t)XS_LUN(xs), lp->state);
4344 XS_SETERR(xs, HBA_SELTIMEOUT);
4345 return (CMD_COMPLETE);
4348 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
4349 if (isp->isp_state != ISP_RUNSTATE) {
4350 isp_prt(isp, ISP_LOGERR, "Adapter not at RUNSTATE");
4351 XS_SETERR(xs, HBA_BOTCH);
4352 return (CMD_COMPLETE);
4356 isp_spi_update(isp, XS_CHANNEL(xs));
4363 qep = isp_getrqentry(isp);
4365 isp_prt(isp, ISP_LOG_WARN1, "Request Queue Overflow");
4366 XS_SETERR(xs, HBA_BOTCH);
4367 return (CMD_EAGAIN);
4369 XS_SETERR(xs, HBA_NOERROR);
4372 * Now see if we need to synchronize the ISP with respect to anything.
4373 * We do dual duty here (cough) for synchronizing for busses other
4374 * than which we got here to send a command to.
4376 reqp = (ispreq_t *) local;
4377 ISP_MEMZERO(local, QENTRY_LEN);
4378 if (ISP_TST_SENDMARKER(isp, XS_CHANNEL(xs))) {
4380 isp_marker_24xx_t *m = (isp_marker_24xx_t *) reqp;
4381 m->mrk_header.rqs_entry_count = 1;
4382 m->mrk_header.rqs_entry_type = RQSTYPE_MARKER;
4383 m->mrk_modifier = SYNC_ALL;
4384 m->mrk_vphdl = XS_CHANNEL(xs);
4385 isp_put_marker_24xx(isp, m, qep);
4387 isp_marker_t *m = (isp_marker_t *) reqp;
4388 m->mrk_header.rqs_entry_count = 1;
4389 m->mrk_header.rqs_entry_type = RQSTYPE_MARKER;
4390 m->mrk_target = (XS_CHANNEL(xs) << 7); /* bus # */
4391 m->mrk_modifier = SYNC_ALL;
4392 isp_put_marker(isp, m, qep);
4394 ISP_SYNC_REQUEST(isp);
4395 ISP_SET_SENDMARKER(isp, XS_CHANNEL(xs), 0);
4399 reqp->req_header.rqs_entry_count = 1;
4402 * Select and install Header Code.
4403 * Note that it might be overridden before going out
4404 * if we're on a 64 bit platform. The lower level
4405 * code (isp_send_cmd) will select the appropriate
4406 * 64 bit variant if it needs to.
4409 reqp->req_header.rqs_entry_type = RQSTYPE_T7RQS;
4410 } else if (IS_FC(isp)) {
4411 reqp->req_header.rqs_entry_type = RQSTYPE_T2RQS;
4413 if (XS_CDBLEN(xs) > 12) {
4414 reqp->req_header.rqs_entry_type = RQSTYPE_CMDONLY;
4416 reqp->req_header.rqs_entry_type = RQSTYPE_REQUEST;
4421 * Set task attributes
4426 ttype = XS_TAG_TYPE(xs);
4428 if (XS_CDBP(xs)[0] == 0x3) {
4429 ttype = REQFLAG_HTAG;
4431 ttype = REQFLAG_STAG;
4434 if (ttype == REQFLAG_OTAG) {
4435 ttype = FCP_CMND_TASK_ATTR_ORDERED;
4436 } else if (ttype == REQFLAG_HTAG) {
4437 ttype = FCP_CMND_TASK_ATTR_HEAD;
4439 ttype = FCP_CMND_TASK_ATTR_SIMPLE;
4441 ((ispreqt7_t *)reqp)->req_task_attribute = ttype;
4442 } else if (IS_FC(isp)) {
4444 * See comment in isp_intr
4446 /* XS_SET_RESID(xs, 0); */
4449 * Fibre Channel always requires some kind of tag.
4450 * The Qlogic drivers seem be happy not to use a tag,
4451 * but this breaks for some devices (IBM drives).
4454 ((ispreqt2_t *)reqp)->req_flags = XS_TAG_TYPE(xs);
4457 * If we don't know what tag to use, use HEAD OF QUEUE
4458 * for Request Sense or Simple.
4460 if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */
4461 ((ispreqt2_t *)reqp)->req_flags = REQFLAG_HTAG;
4463 ((ispreqt2_t *)reqp)->req_flags = REQFLAG_STAG;
4466 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
4467 if ((sdp->isp_devparam[target].actv_flags & DPARM_TQING) && XS_TAG_P(xs)) {
4468 reqp->req_flags = XS_TAG_TYPE(xs);
4472 tptr = &reqp->req_time;
4475 * NB: we do not support long CDBs (yet)
4477 cdblen = XS_CDBLEN(xs);
4480 if (cdblen > sizeof (reqp->req_cdb)) {
4481 isp_prt(isp, ISP_LOGERR, "Command Length %u too long for this chip", cdblen);
4482 XS_SETERR(xs, HBA_BOTCH);
4483 return (CMD_COMPLETE);
4485 reqp->req_target = target | (XS_CHANNEL(xs) << 7);
4486 reqp->req_lun_trn = XS_LUN(xs);
4487 cdbp = reqp->req_cdb;
4488 reqp->req_cdblen = cdblen;
4489 } else if (IS_24XX(isp)) {
4490 ispreqt7_t *t7 = (ispreqt7_t *)local;
4492 if (cdblen > sizeof (t7->req_cdb)) {
4493 isp_prt(isp, ISP_LOGERR, "Command Length %u too long for this chip", cdblen);
4494 XS_SETERR(xs, HBA_BOTCH);
4495 return (CMD_COMPLETE);
4498 t7->req_nphdl = lp->handle;
4499 t7->req_tidlo = lp->portid;
4500 t7->req_tidhi = lp->portid >> 16;
4501 t7->req_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(xs));
4502 #if __FreeBSD_version >= 1000700
4503 be64enc(t7->req_lun, CAM_EXTLUN_BYTE_SWIZZLE(XS_LUN(xs)));
4505 if (XS_LUN(xs) >= 256) {
4506 t7->req_lun[0] = XS_LUN(xs) >> 8;
4507 t7->req_lun[0] |= 0x40;
4509 t7->req_lun[1] = XS_LUN(xs);
4511 if (FCPARAM(isp, XS_CHANNEL(xs))->fctape_enabled && (lp->prli_word3 & PRLI_WD3_RETRY)) {
4512 if (FCP_NEXT_CRN(isp, &t7->req_crn, xs)) {
4513 isp_prt(isp, ISP_LOG_WARN1,
4514 "%d.%d.%jx cannot generate next CRN",
4515 XS_CHANNEL(xs), target, (uintmax_t)XS_LUN(xs));
4516 XS_SETERR(xs, HBA_BOTCH);
4517 return (CMD_EAGAIN);
4520 tptr = &t7->req_time;
4523 ispreqt2_t *t2 = (ispreqt2_t *)local;
4525 if (cdblen > sizeof t2->req_cdb) {
4526 isp_prt(isp, ISP_LOGERR, "Command Length %u too long for this chip", cdblen);
4527 XS_SETERR(xs, HBA_BOTCH);
4528 return (CMD_COMPLETE);
4530 if (FCPARAM(isp, XS_CHANNEL(xs))->fctape_enabled && (lp->prli_word3 & PRLI_WD3_RETRY)) {
4531 if (FCP_NEXT_CRN(isp, &t2->req_crn, xs)) {
4532 isp_prt(isp, ISP_LOG_WARN1,
4533 "%d.%d.%jx cannot generate next CRN",
4534 XS_CHANNEL(xs), target, (uintmax_t)XS_LUN(xs));
4535 XS_SETERR(xs, HBA_BOTCH);
4536 return (CMD_EAGAIN);
4539 if (ISP_CAP_2KLOGIN(isp)) {
4540 ispreqt2e_t *t2e = (ispreqt2e_t *)local;
4541 t2e->req_target = lp->handle;
4542 t2e->req_scclun = XS_LUN(xs);
4543 #if __FreeBSD_version < 1000700
4544 if (XS_LUN(xs) >= 256)
4545 t2e->req_scclun |= 0x4000;
4547 cdbp = t2e->req_cdb;
4548 } else if (ISP_CAP_SCCFW(isp)) {
4549 ispreqt2_t *t2 = (ispreqt2_t *)local;
4550 t2->req_target = lp->handle;
4551 t2->req_scclun = XS_LUN(xs);
4552 #if __FreeBSD_version < 1000700
4553 if (XS_LUN(xs) >= 256)
4554 t2->req_scclun |= 0x4000;
4558 t2->req_target = lp->handle;
4559 t2->req_lun_trn = XS_LUN(xs);
4563 ISP_MEMCPY(cdbp, XS_CDBP(xs), cdblen);
4565 *tptr = (XS_TIME(xs) + 999) / 1000;
4566 if (IS_24XX(isp) && *tptr > 0x1999) {
4570 /* Whew. Thankfully the same for type 7 requests */
4571 reqp->req_handle = isp_allocate_handle(isp, xs, ISP_HANDLE_INITIATOR);
4572 if (reqp->req_handle == 0) {
4573 isp_prt(isp, ISP_LOG_WARN1, "out of xflist pointers");
4574 XS_SETERR(xs, HBA_BOTCH);
4575 return (CMD_EAGAIN);
4579 * Set up DMA and/or do any platform dependent swizzling of the request entry
4580 * so that the Qlogic F/W understands what is being asked of it.
4582 * The callee is responsible for adding all requests at this point.
4584 dmaresult = ISP_DMASETUP(isp, xs, reqp);
4585 if (dmaresult != CMD_QUEUED) {
4586 isp_destroy_handle(isp, reqp->req_handle);
4588 * dmasetup sets actual error in packet, and
4589 * return what we were given to return.
4593 isp_xs_prt(isp, xs, ISP_LOGDEBUG0, "START cmd cdb[0]=0x%x datalen %ld", XS_CDBP(xs)[0], (long) XS_XFRLEN(xs));
4595 return (CMD_QUEUED);
4600 * Locks (ints blocked) assumed held.
4604 isp_control(ispsoftc_t *isp, ispctl_t ctl, ...)
4613 case ISPCTL_RESET_BUS:
4615 * Issue a bus reset.
4618 isp_prt(isp, ISP_LOGERR, "BUS RESET NOT IMPLEMENTED");
4620 } else if (IS_FC(isp)) {
4625 chan = va_arg(ap, int);
4627 mbs.param[1] = SDPARAM(isp, chan)->isp_bus_reset_delay;
4628 if (mbs.param[1] < 2) {
4631 mbs.param[2] = chan;
4633 MBSINIT(&mbs, MBOX_BUS_RESET, MBLOGALL, 0);
4634 ISP_SET_SENDMARKER(isp, chan, 1);
4635 isp_mboxcmd(isp, &mbs);
4636 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4639 isp_prt(isp, ISP_LOGINFO, "driver initiated bus reset of bus %d", chan);
4642 case ISPCTL_RESET_DEV:
4644 chan = va_arg(ap, int);
4645 tgt = va_arg(ap, int);
4648 uint8_t local[QENTRY_LEN];
4650 isp24xx_statusreq_t *sp;
4651 fcparam *fcp = FCPARAM(isp, chan);
4654 if (tgt < 0 || tgt >= MAX_FC_TARG) {
4655 isp_prt(isp, ISP_LOGWARN, "Chan %d trying to reset bad target %d", chan, tgt);
4658 lp = &fcp->portdb[tgt];
4659 if (lp->is_target == 0 ||
4660 lp->state != FC_PORTDB_STATE_VALID) {
4661 isp_prt(isp, ISP_LOGWARN, "Chan %d abort of no longer valid target %d", chan, tgt);
4665 tmf = (isp24xx_tmf_t *) local;
4666 ISP_MEMZERO(tmf, QENTRY_LEN);
4667 tmf->tmf_header.rqs_entry_type = RQSTYPE_TSK_MGMT;
4668 tmf->tmf_header.rqs_entry_count = 1;
4669 tmf->tmf_nphdl = lp->handle;
4671 tmf->tmf_timeout = 4;
4672 tmf->tmf_flags = ISP24XX_TMF_TARGET_RESET;
4673 tmf->tmf_tidlo = lp->portid;
4674 tmf->tmf_tidhi = lp->portid >> 16;
4675 tmf->tmf_vpidx = ISP_GET_VPIDX(isp, chan);
4676 isp_prt(isp, ISP_LOGALL, "Chan %d Reset N-Port Handle 0x%04x @ Port 0x%06x", chan, lp->handle, lp->portid);
4677 MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
4678 MBCMD_DEFAULT_TIMEOUT + tmf->tmf_timeout * 1000000);
4679 mbs.param[1] = QENTRY_LEN;
4680 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
4681 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
4682 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
4683 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
4685 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
4686 isp_prt(isp, ISP_LOGERR, sacq);
4689 isp_put_24xx_tmf(isp, tmf, fcp->isp_scratch);
4690 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, QENTRY_LEN, chan);
4691 fcp->sendmarker = 1;
4692 isp_mboxcmd(isp, &mbs);
4693 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4694 FC_SCRATCH_RELEASE(isp, chan);
4697 MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
4698 sp = (isp24xx_statusreq_t *) local;
4699 isp_get_24xx_response(isp, &((isp24xx_statusreq_t *)fcp->isp_scratch)[1], sp);
4700 FC_SCRATCH_RELEASE(isp, chan);
4701 if (sp->req_completion_status == 0) {
4704 isp_prt(isp, ISP_LOGWARN, "Chan %d reset of target %d returned 0x%x", chan, tgt, sp->req_completion_status);
4706 } else if (IS_FC(isp)) {
4707 if (ISP_CAP_2KLOGIN(isp)) {
4709 mbs.ibits = (1 << 10);
4711 mbs.param[1] = (tgt << 8);
4714 mbs.param[1] = (chan << 15) | (tgt << 8);
4716 MBSINIT(&mbs, MBOX_ABORT_TARGET, MBLOGALL, 0);
4717 mbs.param[2] = 3; /* 'delay', in seconds */
4718 isp_mboxcmd(isp, &mbs);
4719 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4722 isp_prt(isp, ISP_LOGINFO, "Target %d on Bus %d Reset Succeeded", tgt, chan);
4723 ISP_SET_SENDMARKER(isp, chan, 1);
4726 case ISPCTL_ABORT_CMD:
4728 xs = va_arg(ap, XS_T *);
4732 chan = XS_CHANNEL(xs);
4734 handle = isp_find_handle(isp, xs);
4736 isp_prt(isp, ISP_LOGWARN, "cannot find handle for command to abort");
4740 isp24xx_abrt_t local, *ab = &local, *ab2;
4744 fcp = FCPARAM(isp, chan);
4745 if (tgt < 0 || tgt >= MAX_FC_TARG) {
4746 isp_prt(isp, ISP_LOGWARN, "Chan %d trying to abort bad target %d", chan, tgt);
4749 lp = &fcp->portdb[tgt];
4750 if (lp->is_target == 0 ||
4751 lp->state != FC_PORTDB_STATE_VALID) {
4752 isp_prt(isp, ISP_LOGWARN, "Chan %d abort of no longer valid target %d", chan, tgt);
4755 isp_prt(isp, ISP_LOGALL, "Chan %d Abort Cmd for N-Port 0x%04x @ Port 0x%06x", chan, lp->handle, lp->portid);
4756 ISP_MEMZERO(ab, QENTRY_LEN);
4757 ab->abrt_header.rqs_entry_type = RQSTYPE_ABORT_IO;
4758 ab->abrt_header.rqs_entry_count = 1;
4759 ab->abrt_handle = lp->handle;
4760 ab->abrt_cmd_handle = handle;
4761 ab->abrt_tidlo = lp->portid;
4762 ab->abrt_tidhi = lp->portid >> 16;
4763 ab->abrt_vpidx = ISP_GET_VPIDX(isp, chan);
4765 ISP_MEMZERO(&mbs, sizeof (mbs));
4766 MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 5000000);
4767 mbs.param[1] = QENTRY_LEN;
4768 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
4769 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
4770 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
4771 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
4773 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
4774 isp_prt(isp, ISP_LOGERR, sacq);
4777 isp_put_24xx_abrt(isp, ab, fcp->isp_scratch);
4778 ab2 = (isp24xx_abrt_t *) &((uint8_t *)fcp->isp_scratch)[QENTRY_LEN];
4779 ab2->abrt_nphdl = 0xdeaf;
4780 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, 2 * QENTRY_LEN, chan);
4781 isp_mboxcmd(isp, &mbs);
4782 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4783 FC_SCRATCH_RELEASE(isp, chan);
4786 MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
4787 isp_get_24xx_abrt(isp, ab2, ab);
4788 FC_SCRATCH_RELEASE(isp, chan);
4789 if (ab->abrt_nphdl == ISP24XX_ABRT_OKAY) {
4792 isp_prt(isp, ISP_LOGWARN, "Chan %d handle %d abort returned 0x%x", chan, tgt, ab->abrt_nphdl);
4794 } else if (IS_FC(isp)) {
4795 if (ISP_CAP_SCCFW(isp)) {
4796 if (ISP_CAP_2KLOGIN(isp)) {
4799 mbs.param[1] = tgt << 8;
4801 mbs.param[6] = XS_LUN(xs);
4803 mbs.param[1] = tgt << 8 | XS_LUN(xs);
4806 mbs.param[1] = (chan << 15) | (tgt << 8) | XS_LUN(xs);
4808 MBSINIT(&mbs, MBOX_ABORT,
4809 MBLOGALL & ~MBLOGMASK(MBOX_COMMAND_ERROR), 0);
4810 mbs.param[2] = handle;
4811 isp_mboxcmd(isp, &mbs);
4812 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4817 case ISPCTL_UPDATE_PARAMS:
4820 chan = va_arg(ap, int);
4822 isp_spi_update(isp, chan);
4825 case ISPCTL_FCLINK_TEST:
4830 chan = va_arg(ap, int);
4831 usdelay = va_arg(ap, int);
4836 return (isp_fclink_test(isp, chan, usdelay));
4840 case ISPCTL_SCAN_FABRIC:
4844 chan = va_arg(ap, int);
4846 return (isp_scan_fabric(isp, chan));
4850 case ISPCTL_SCAN_LOOP:
4854 chan = va_arg(ap, int);
4856 return (isp_scan_loop(isp, chan));
4860 case ISPCTL_PDB_SYNC:
4864 chan = va_arg(ap, int);
4866 return (isp_pdb_sync(isp, chan));
4870 case ISPCTL_SEND_LIP:
4872 if (IS_FC(isp) && !IS_24XX(isp)) {
4873 MBSINIT(&mbs, MBOX_INIT_LIP, MBLOGALL, 0);
4874 if (ISP_CAP_2KLOGIN(isp)) {
4875 mbs.ibits = (1 << 10);
4877 isp_mboxcmd(isp, &mbs);
4878 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
4884 case ISPCTL_GET_PDB:
4888 chan = va_arg(ap, int);
4889 tgt = va_arg(ap, int);
4890 pdb = va_arg(ap, isp_pdb_t *);
4892 return (isp_getpdb(isp, chan, tgt, pdb, 1));
4896 case ISPCTL_GET_NAMES:
4898 uint64_t *wwnn, *wwnp;
4900 chan = va_arg(ap, int);
4901 tgt = va_arg(ap, int);
4902 wwnn = va_arg(ap, uint64_t *);
4903 wwnp = va_arg(ap, uint64_t *);
4905 if (wwnn == NULL && wwnp == NULL) {
4909 *wwnn = isp_get_wwn(isp, chan, tgt, 1);
4910 if (*wwnn == INI_NONE) {
4915 *wwnp = isp_get_wwn(isp, chan, tgt, 0);
4916 if (*wwnp == INI_NONE) {
4922 case ISPCTL_RUN_MBOXCMD:
4925 mbr = va_arg(ap, mbreg_t *);
4927 isp_mboxcmd(isp, mbr);
4936 p = va_arg(ap, isp_plcmd_t *);
4939 if ((p->flags & PLOGX_FLG_CMD_MASK) != PLOGX_FLG_CMD_PLOGI || (p->handle != NIL_HANDLE)) {
4940 return (isp_plogx(isp, p->channel, p->handle, p->portid, p->flags, 0));
4943 isp_next_handle(isp, &p->handle);
4944 r = isp_plogx(isp, p->channel, p->handle, p->portid, p->flags, 0);
4945 if ((r & 0xffff) == MBOX_PORT_ID_USED) {
4946 p->handle = r >> 16;
4950 } while ((r & 0xffff) == MBOX_LOOP_ID_USED);
4953 case ISPCTL_CHANGE_ROLE:
4958 chan = va_arg(ap, int);
4959 role = va_arg(ap, int);
4961 r = isp_fc_change_role(isp, chan, role);
4966 isp_prt(isp, ISP_LOGERR, "Unknown Control Opcode 0x%x", ctl);
4974 * Interrupt Service Routine(s).
4976 * External (OS) framework has done the appropriate locking,
4977 * and the locking will be held throughout this function.
4981 * Limit our stack depth by sticking with the max likely number
4982 * of completions on a request queue at any one time.
4984 #ifndef MAX_REQUESTQ_COMPLETIONS
4985 #define MAX_REQUESTQ_COMPLETIONS 32
4989 isp_intr(ispsoftc_t *isp, uint16_t isr, uint16_t sema, uint16_t info)
4991 XS_T *complist[MAX_REQUESTQ_COMPLETIONS], *xs;
4992 uint32_t iptr, optr, junk;
4993 int i, nlooked = 0, ndone = 0, continuations_expected = 0;
4994 int etype, last_etype = 0;
4998 * Is this a mailbox related interrupt?
4999 * The mailbox semaphore will be nonzero if so.
5003 if (info & MBOX_COMMAND_COMPLETE) {
5004 isp->isp_intmboxc++;
5005 if (isp->isp_mboxbsy) {
5006 int obits = isp->isp_obits;
5007 isp->isp_mboxtmp[0] = info;
5008 for (i = 1; i < ISP_NMBOX(isp); i++) {
5009 if ((obits & (1 << i)) == 0) {
5012 isp->isp_mboxtmp[i] = ISP_READ(isp, MBOX_OFF(i));
5014 if (isp->isp_mbxwrk0) {
5015 if (isp_mbox_continue(isp) == 0) {
5019 MBOX_NOTIFY_COMPLETE(isp);
5021 isp_prt(isp, ISP_LOGWARN, "mailbox cmd (0x%x) with no waiters", info);
5024 i = IS_FC(isp)? isp_parse_async_fc(isp, info) : isp_parse_async(isp, info);
5029 if ((IS_FC(isp) && info != ASYNC_RIOZIO_STALL) || isp->isp_state != ISP_RUNSTATE) {
5035 * We can't be getting this now.
5037 if (isp->isp_state != ISP_RUNSTATE) {
5039 * This seems to happen to 23XX and 24XX cards- don't know why.
5041 if (isp->isp_mboxbsy && isp->isp_lastmbxcmd == MBOX_ABOUT_FIRMWARE) {
5044 isp_prt(isp, ISP_LOGINFO, "interrupt (ISR=%x SEMA=%x INFO=%x) "
5045 "when not ready", isr, sema, info);
5047 * Thank you very much! *Burrrp*!
5049 isp->isp_residx = ISP_READ(isp, isp->isp_respinrp);
5050 isp->isp_resodx = isp->isp_residx;
5051 ISP_WRITE(isp, isp->isp_respoutrp, isp->isp_resodx);
5053 ISP_DISABLE_INTS(isp);
5058 #ifdef ISP_TARGET_MODE
5060 * Check for ATIO Queue entries.
5063 (isr == ISPR2HST_ATIO_UPDATE || isr == ISPR2HST_ATIO_RSPQ_UPDATE ||
5064 isr == ISPR2HST_ATIO_UPDATE2)) {
5065 iptr = ISP_READ(isp, BIU2400_ATIO_RSPINP);
5066 optr = isp->isp_atioodx;
5068 while (optr != iptr) {
5069 uint8_t qe[QENTRY_LEN];
5075 MEMORYBARRIER(isp, SYNC_ATIOQ, oop, QENTRY_LEN, -1);
5076 addr = ISP_QUEUE_ENTRY(isp->isp_atioq, oop);
5077 isp_get_hdr(isp, addr, (isphdr_t *)qe);
5078 hp = (isphdr_t *)qe;
5079 switch (hp->rqs_entry_type) {
5080 case RQSTYPE_NOTIFY:
5082 (void) isp_target_notify(isp, addr, &oop);
5085 isp_print_qentry(isp, "?ATIOQ entry?", oop, addr);
5088 optr = ISP_NXT_QENTRY(oop, RESULT_QUEUE_LEN(isp));
5090 if (isp->isp_atioodx != optr) {
5091 ISP_WRITE(isp, BIU2400_ATIO_RSPOUTP, optr);
5092 isp->isp_atioodx = optr;
5098 * You *must* read the Response Queue In Pointer
5099 * prior to clearing the RISC interrupt.
5101 * Debounce the 2300 if revision less than 2.
5103 if (IS_2100(isp) || (IS_2300(isp) && isp->isp_revision < 2)) {
5106 iptr = ISP_READ(isp, isp->isp_respinrp);
5107 junk = ISP_READ(isp, isp->isp_respinrp);
5108 } while (junk != iptr && ++i < 1000);
5111 isp_prt(isp, ISP_LOGWARN, "Response Queue Out Pointer Unstable (%x, %x)", iptr, junk);
5115 iptr = ISP_READ(isp, isp->isp_respinrp);
5118 optr = isp->isp_resodx;
5119 if (optr == iptr && sema == 0) {
5121 * There are a lot of these- reasons unknown- mostly on
5122 * faster Alpha machines.
5124 * I tried delaying after writing HCCR_CMD_CLEAR_RISC_INT to
5125 * make sure the old interrupt went away (to avoid 'ringing'
5126 * effects), but that didn't stop this from occurring.
5130 } else if (IS_23XX(isp)) {
5132 iptr = ISP_READ(isp, isp->isp_respinrp);
5133 junk = ISP_READ(isp, BIU_R2HSTSLO);
5135 junk = ISP_READ(isp, BIU_ISR);
5138 if (IS_23XX(isp) || IS_24XX(isp)) {
5141 sema = ISP_READ(isp, BIU_SEMA);
5142 info = ISP_READ(isp, OUTMAILBOX0);
5143 if ((sema & 0x3) && (info & 0x8000)) {
5147 isp->isp_intbogus++;
5148 isp_prt(isp, ISP_LOGDEBUG1, "bogus intr- isr %x (%x) iptr %x optr %x", isr, junk, iptr, optr);
5151 isp->isp_residx = iptr;
5153 while (optr != iptr) {
5154 uint8_t qe[QENTRY_LEN];
5155 ispstatusreq_t *sp = (ispstatusreq_t *) qe;
5157 int buddaboom, scsi_status, completion_status;
5158 int req_status_flags, req_state_flags;
5159 uint8_t *snsp, *resp;
5160 uint32_t rlen, slen, totslen;
5164 hp = (isphdr_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr);
5166 optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN(isp));
5169 buddaboom = req_status_flags = req_state_flags = 0;
5173 * Synchronize our view of this response queue entry.
5175 MEMORYBARRIER(isp, SYNC_RESULT, oop, QENTRY_LEN, -1);
5176 isp_get_hdr(isp, hp, &sp->req_header);
5177 etype = sp->req_header.rqs_entry_type;
5179 if (IS_24XX(isp) && etype == RQSTYPE_RESPONSE) {
5180 isp24xx_statusreq_t *sp2 = (isp24xx_statusreq_t *)qe;
5181 isp_get_24xx_response(isp, (isp24xx_statusreq_t *)hp, sp2);
5182 if (isp->isp_dblev & ISP_LOGDEBUG1) {
5183 isp_print_bytes(isp, "Response Queue Entry", QENTRY_LEN, sp2);
5185 scsi_status = sp2->req_scsi_status;
5186 completion_status = sp2->req_completion_status;
5187 if ((scsi_status & 0xff) != 0)
5188 req_state_flags = RQSF_GOT_STATUS;
5190 req_state_flags = 0;
5191 resid = sp2->req_resid;
5192 } else if (etype == RQSTYPE_RESPONSE) {
5193 isp_get_response(isp, (ispstatusreq_t *) hp, sp);
5194 if (isp->isp_dblev & ISP_LOGDEBUG1) {
5195 isp_print_bytes(isp, "Response Queue Entry", QENTRY_LEN, sp);
5197 scsi_status = sp->req_scsi_status;
5198 completion_status = sp->req_completion_status;
5199 req_status_flags = sp->req_status_flags;
5200 req_state_flags = sp->req_state_flags;
5201 resid = sp->req_resid;
5202 } else if (etype == RQSTYPE_RIO1) {
5203 isp_rio1_t *rio = (isp_rio1_t *) qe;
5204 isp_get_rio1(isp, (isp_rio1_t *) hp, rio);
5205 if (isp->isp_dblev & ISP_LOGDEBUG1) {
5206 isp_print_bytes(isp, "Response Queue Entry", QENTRY_LEN, rio);
5208 for (i = 0; i < rio->req_header.rqs_seqno; i++) {
5209 isp_fastpost_complete(isp, rio->req_handles[i]);
5211 if (isp->isp_fpcchiwater < rio->req_header.rqs_seqno) {
5212 isp->isp_fpcchiwater = rio->req_header.rqs_seqno;
5214 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5217 } else if (etype == RQSTYPE_RIO2) {
5218 isp_prt(isp, ISP_LOGERR, "dropping RIO2 response");
5219 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5222 } else if (etype == RQSTYPE_STATUS_CONT) {
5223 isp_get_cont_response(isp, (ispstatus_cont_t *) hp, (ispstatus_cont_t *) sp);
5224 if (last_etype == RQSTYPE_RESPONSE && continuations_expected && ndone > 0 && (xs = complist[ndone-1]) != NULL) {
5225 ispstatus_cont_t *scp = (ispstatus_cont_t *) sp;
5226 XS_SENSE_APPEND(xs, scp->req_sense_data, sizeof (scp->req_sense_data));
5227 isp_prt(isp, ISP_LOGDEBUG0|ISP_LOG_CWARN, "%d more Status Continuations expected", --continuations_expected);
5229 isp_prt(isp, ISP_LOG_WARN1, "Ignored Continuation Response");
5231 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5235 * Somebody reachable via isp_handle_other_response
5236 * may have updated the response queue pointers for
5237 * us, so we reload our goal index.
5240 uint32_t tsto = oop;
5241 r = isp_handle_other_response(isp, etype, hp, &tsto);
5246 * If somebody updated the output pointer, then reset
5247 * optr to be one more than the updated amount.
5249 while (tsto != oop) {
5250 optr = ISP_NXT_QENTRY(tsto, RESULT_QUEUE_LEN(isp));
5253 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5259 * After this point, we'll just look at the header as
5260 * we don't know how to deal with the rest of the
5265 * It really has to be a bounced request just copied
5266 * from the request queue to the response queue. If
5267 * not, something bad has happened.
5269 if (etype != RQSTYPE_REQUEST) {
5270 isp_prt(isp, ISP_LOGERR, notresp, etype, oop, optr, nlooked);
5271 isp_print_bytes(isp, "Request Queue Entry", QENTRY_LEN, sp);
5272 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5277 scsi_status = sp->req_scsi_status;
5278 completion_status = sp->req_completion_status;
5279 req_status_flags = sp->req_status_flags;
5280 req_state_flags = sp->req_state_flags;
5281 resid = sp->req_resid;
5284 if (sp->req_header.rqs_flags & RQSFLAG_MASK) {
5285 if (sp->req_header.rqs_flags & RQSFLAG_CONTINUATION) {
5286 isp_print_bytes(isp, "unexpected continuation segment", QENTRY_LEN, sp);
5290 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
5291 isp_prt(isp, ISP_LOG_WARN1, "internal queues full");
5293 * We'll synthesize a QUEUE FULL message below.
5296 if (sp->req_header.rqs_flags & RQSFLAG_BADHEADER) {
5297 isp_print_bytes(isp, "bad header flag", QENTRY_LEN, sp);
5300 if (sp->req_header.rqs_flags & RQSFLAG_BADPACKET) {
5301 isp_print_bytes(isp, "bad request packet", QENTRY_LEN, sp);
5304 if (sp->req_header.rqs_flags & RQSFLAG_BADCOUNT) {
5305 isp_print_bytes(isp, "invalid entry count", QENTRY_LEN, sp);
5308 if (sp->req_header.rqs_flags & RQSFLAG_BADORDER) {
5309 isp_print_bytes(isp, "invalid IOCB ordering", QENTRY_LEN, sp);
5315 xs = isp_find_xs(isp, sp->req_handle);
5317 uint8_t ts = completion_status & 0xff;
5319 * Only whine if this isn't the expected fallout of
5320 * aborting the command or resetting the target.
5322 if (etype != RQSTYPE_RESPONSE) {
5323 isp_prt(isp, ISP_LOGERR, "cannot find handle 0x%x (type 0x%x)", sp->req_handle, etype);
5324 } else if (ts != RQCS_ABORTED && ts != RQCS_RESET_OCCURRED) {
5325 isp_prt(isp, ISP_LOGERR, "cannot find handle 0x%x (status 0x%x)", sp->req_handle, ts);
5327 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5331 if (req_status_flags & RQSTF_BUS_RESET) {
5332 isp_prt(isp, ISP_LOG_WARN1, "%d.%d.%jx bus was reset",
5333 XS_CHANNEL(xs), XS_TGT(xs), (uintmax_t)XS_LUN(xs));
5334 XS_SETERR(xs, HBA_BUSRESET);
5335 ISP_SET_SENDMARKER(isp, XS_CHANNEL(xs), 1);
5338 isp_prt(isp, ISP_LOG_WARN1, "%d.%d.%jx buddaboom",
5339 XS_CHANNEL(xs), XS_TGT(xs), (uintmax_t)XS_LUN(xs));
5340 XS_SETERR(xs, HBA_BOTCH);
5347 if (IS_24XX(isp) && (scsi_status & (RQCS_RV|RQCS_SV)) != 0) {
5348 resp = ((isp24xx_statusreq_t *)sp)->req_rsp_sense;
5349 rlen = ((isp24xx_statusreq_t *)sp)->req_response_len;
5350 } else if (IS_FC(isp) && (scsi_status & RQCS_RV) != 0) {
5351 resp = sp->req_response;
5352 rlen = sp->req_response_len;
5354 if (IS_FC(isp) && (scsi_status & RQCS_SV) != 0) {
5356 * Fibre Channel F/W doesn't say we got status
5357 * if there's Sense Data instead. I guess they
5358 * think it goes w/o saying.
5360 req_state_flags |= RQSF_GOT_STATUS|RQSF_GOT_SENSE;
5362 snsp = ((isp24xx_statusreq_t *)sp)->req_rsp_sense;
5364 totslen = ((isp24xx_statusreq_t *)sp)->req_sense_len;
5365 slen = (sizeof (((isp24xx_statusreq_t *)sp)->req_rsp_sense)) - rlen;
5369 snsp = sp->req_sense_data;
5370 totslen = sp->req_sense_len;
5371 slen = sizeof (sp->req_sense_data);
5375 } else if (IS_SCSI(isp) && (req_state_flags & RQSF_GOT_SENSE)) {
5376 snsp = sp->req_sense_data;
5377 totslen = sp->req_sense_len;
5378 slen = sizeof (sp->req_sense_data);
5382 if (req_state_flags & RQSF_GOT_STATUS) {
5383 *XS_STSP(xs) = scsi_status & 0xff;
5387 case RQSTYPE_RESPONSE:
5388 if (resp && rlen >= 4 && resp[FCP_RSPNS_CODE_OFFSET] != 0) {
5391 const char *rnames[10] = {
5392 "Task Management function complete",
5393 "FCP_DATA length different than FCP_BURST_LEN",
5394 "FCP_CMND fields invalid",
5395 "FCP_DATA parameter mismatch with FCP_DATA_RO",
5396 "Task Management function rejected",
5397 "Task Management function failed",
5400 "Task Management function succeeded",
5401 "Task Management function incorrect logical unit number",
5403 uint8_t code = resp[FCP_RSPNS_CODE_OFFSET];
5404 if (code >= 10 || rnames[code] == NULL) {
5405 ISP_SNPRINTF(lb, sizeof(lb),
5406 "Unknown FCP Response Code 0x%x",
5412 isp_xs_prt(isp, xs, ISP_LOGWARN,
5413 "FCP RESPONSE, LENGTH %u: %s CDB0=0x%02x",
5414 rlen, ptr, XS_CDBP(xs)[0] & 0xff);
5415 if (code != 0 && code != 8)
5416 XS_SETERR(xs, HBA_BOTCH);
5419 isp_parse_status_24xx(isp, (isp24xx_statusreq_t *)sp, xs, &resid);
5421 isp_parse_status(isp, (void *)sp, xs, &resid);
5423 if ((XS_NOERR(xs) || XS_ERR(xs) == HBA_NOERROR) && (*XS_STSP(xs) == SCSI_BUSY)) {
5424 XS_SETERR(xs, HBA_TGTBSY);
5427 XS_SET_RESID(xs, resid);
5429 * A new synchronous rate was negotiated for
5430 * this target. Mark state such that we'll go
5431 * look up that which has changed later.
5433 if (req_status_flags & RQSTF_NEGOTIATION) {
5435 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
5436 sdp->isp_devparam[t].dev_refresh = 1;
5440 if (req_status_flags & RQSF_XFER_COMPLETE) {
5441 XS_SET_RESID(xs, 0);
5442 } else if (scsi_status & RQCS_RESID) {
5443 XS_SET_RESID(xs, resid);
5445 XS_SET_RESID(xs, 0);
5449 if (totslen > slen) {
5450 continuations_expected += ((totslen - slen + QENTRY_LEN - 5) / (QENTRY_LEN - 4));
5451 if (ndone > (MAX_REQUESTQ_COMPLETIONS - continuations_expected - 1)) {
5452 /* we'll lose some stats, but that's a small price to pay */
5453 for (i = 0; i < ndone; i++) {
5455 isp->isp_rsltccmplt++;
5456 isp_done(complist[i]);
5461 isp_prt(isp, ISP_LOGDEBUG0|ISP_LOG_CWARN, "Expecting %d more Status Continuations for total sense length of %u",
5462 continuations_expected, totslen);
5464 XS_SAVE_SENSE(xs, snsp, totslen, slen);
5465 } else if ((req_status_flags & RQSF_GOT_STATUS) && (scsi_status & 0xff) == SCSI_CHECK && IS_FC(isp)) {
5466 isp_prt(isp, ISP_LOGWARN, "CHECK CONDITION w/o sense data for CDB=0x%x", XS_CDBP(xs)[0] & 0xff);
5467 isp_print_bytes(isp, "CC with no Sense", QENTRY_LEN, qe);
5469 isp_prt(isp, ISP_LOGDEBUG2, "asked for %ld got raw resid %ld settled for %ld", (long) XS_XFRLEN(xs), resid, (long) XS_GET_RESID(xs));
5471 case RQSTYPE_REQUEST:
5476 if (!IS_24XX(isp) && (sp->req_header.rqs_flags & RQSFLAG_FULL)) {
5478 * Force Queue Full status.
5480 *XS_STSP(xs) = SCSI_QFULL;
5481 XS_SETERR(xs, HBA_NOERROR);
5482 } else if (XS_NOERR(xs)) {
5483 isp_prt(isp, ISP_LOG_WARN1,
5484 "%d.%d.%jx badness at %s:%u",
5485 XS_CHANNEL(xs), XS_TGT(xs),
5486 (uintmax_t)XS_LUN(xs),
5487 __func__, __LINE__);
5488 XS_SETERR(xs, HBA_BOTCH);
5490 XS_SET_RESID(xs, XS_XFRLEN(xs));
5493 isp_print_bytes(isp, "Unhandled Response Type", QENTRY_LEN, qe);
5495 XS_SETERR(xs, HBA_BOTCH);
5501 * Free any DMA resources. As a side effect, this may
5502 * also do any cache flushing necessary for data coherence.
5504 if (XS_XFRLEN(xs)) {
5505 ISP_DMAFREE(isp, xs, sp->req_handle);
5507 isp_destroy_handle(isp, sp->req_handle);
5509 if (isp->isp_nactive > 0) {
5512 complist[ndone++] = xs; /* defer completion call until later */
5513 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5515 if (ndone == MAX_REQUESTQ_COMPLETIONS) {
5521 * If we looked at any commands, then it's valid to find out
5522 * what the outpointer is. It also is a trigger to update the
5523 * ISP's notion of what we've seen so far.
5526 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5527 isp->isp_resodx = optr;
5528 if (isp->isp_rscchiwater < ndone)
5529 isp->isp_rscchiwater = ndone;
5535 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT);
5537 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
5538 ISP_WRITE(isp, BIU_SEMA, 0);
5541 for (i = 0; i < ndone; i++) {
5544 if (((isp->isp_dblev & (ISP_LOGDEBUG1|ISP_LOGDEBUG2|ISP_LOGDEBUG3))) ||
5545 ((isp->isp_dblev & (ISP_LOGDEBUG0|ISP_LOG_CWARN) && ((!XS_NOERR(xs)) || (*XS_STSP(xs) != SCSI_GOOD))))) {
5546 isp_prt_endcmd(isp, xs);
5548 isp->isp_rsltccmplt++;
5559 isp_prt_endcmd(ispsoftc_t *isp, XS_T *xs)
5561 char cdbstr[16 * 5 + 1];
5564 lim = XS_CDBLEN(xs) > 16? 16 : XS_CDBLEN(xs);
5565 ISP_SNPRINTF(cdbstr, sizeof (cdbstr), "0x%02x ", XS_CDBP(xs)[0]);
5566 for (i = 1; i < lim; i++) {
5567 ISP_SNPRINTF(cdbstr, sizeof (cdbstr), "%s0x%02x ", cdbstr, XS_CDBP(xs)[i]);
5569 if (XS_SENSE_VALID(xs)) {
5570 isp_xs_prt(isp, xs, ISP_LOGALL, "FIN dl%d resid %ld CDB=%s SenseLength=%u/%u KEY/ASC/ASCQ=0x%02x/0x%02x/0x%02x",
5571 XS_XFRLEN(xs), (long) XS_GET_RESID(xs), cdbstr, XS_CUR_SNSLEN(xs), XS_TOT_SNSLEN(xs), XS_SNSKEY(xs), XS_SNSASC(xs), XS_SNSASCQ(xs));
5573 isp_xs_prt(isp, xs, ISP_LOGALL, "FIN dl%d resid %ld CDB=%s STS 0x%x XS_ERR=0x%x", XS_XFRLEN(xs), (long) XS_GET_RESID(xs), cdbstr, *XS_STSP(xs), XS_ERR(xs));
5578 * Parse an ASYNC mailbox complete
5580 * Return non-zero if the event has been acknowledged.
5583 isp_parse_async(ispsoftc_t *isp, uint16_t mbox)
5586 uint32_t h1 = 0, h2 = 0;
5590 * Pick up the channel, but not if this is a ASYNC_RIO32_2,
5591 * where Mailboxes 6/7 have the second handle.
5593 if (mbox != ASYNC_RIO32_2) {
5594 if (IS_DUALBUS(isp)) {
5595 chan = ISP_READ(isp, OUTMAILBOX6);
5598 isp_prt(isp, ISP_LOGDEBUG2, "Async Mbox 0x%x", mbox);
5601 case ASYNC_BUS_RESET:
5602 ISP_SET_SENDMARKER(isp, chan, 1);
5603 #ifdef ISP_TARGET_MODE
5604 if (isp_target_async(isp, chan, mbox)) {
5608 isp_async(isp, ISPASYNC_BUS_RESET, chan);
5610 case ASYNC_SYSTEM_ERROR:
5612 isp->isp_state = ISP_CRASHED;
5614 * Were we waiting for a mailbox command to complete?
5615 * If so, it's dead, so wake up the waiter.
5617 if (isp->isp_mboxbsy) {
5619 isp->isp_mboxtmp[0] = MBOX_HOST_INTERFACE_ERROR;
5620 MBOX_NOTIFY_COMPLETE(isp);
5623 * It's up to the handler for isp_async to reinit stuff and
5624 * restart the firmware
5626 isp_async(isp, ISPASYNC_FW_CRASH);
5630 case ASYNC_RQS_XFER_ERR:
5631 isp_prt(isp, ISP_LOGERR, "Request Queue Transfer Error");
5634 case ASYNC_RSP_XFER_ERR:
5635 isp_prt(isp, ISP_LOGERR, "Response Queue Transfer Error");
5640 * We've just been notified that the Queue has woken up.
5641 * We don't need to be chatty about this- just unlatch things
5644 mbox = ISP_READ(isp, isp->isp_rqstoutrp);
5647 case ASYNC_TIMEOUT_RESET:
5648 isp_prt(isp, ISP_LOGWARN, "timeout initiated SCSI bus reset of chan %d", chan);
5649 ISP_SET_SENDMARKER(isp, chan, 1);
5650 #ifdef ISP_TARGET_MODE
5651 if (isp_target_async(isp, chan, mbox)) {
5657 case ASYNC_DEVICE_RESET:
5658 isp_prt(isp, ISP_LOGINFO, "device reset on chan %d", chan);
5659 ISP_SET_SENDMARKER(isp, chan, 1);
5660 #ifdef ISP_TARGET_MODE
5661 if (isp_target_async(isp, chan, mbox)) {
5667 case ASYNC_EXTMSG_UNDERRUN:
5668 isp_prt(isp, ISP_LOGWARN, "extended message underrun");
5671 case ASYNC_SCAM_INT:
5672 isp_prt(isp, ISP_LOGINFO, "SCAM interrupt");
5675 case ASYNC_HUNG_SCSI:
5676 isp_prt(isp, ISP_LOGERR, "stalled SCSI Bus after DATA Overrun");
5677 /* XXX: Need to issue SCSI reset at this point */
5680 case ASYNC_KILLED_BUS:
5681 isp_prt(isp, ISP_LOGERR, "SCSI Bus reset after DATA Overrun");
5684 case ASYNC_BUS_TRANSIT:
5685 mbox = ISP_READ(isp, OUTMAILBOX2);
5686 switch (mbox & SXP_PINS_MODE_MASK) {
5687 case SXP_PINS_LVD_MODE:
5688 isp_prt(isp, ISP_LOGINFO, "Transition to LVD mode");
5689 SDPARAM(isp, chan)->isp_diffmode = 0;
5690 SDPARAM(isp, chan)->isp_ultramode = 0;
5691 SDPARAM(isp, chan)->isp_lvdmode = 1;
5693 case SXP_PINS_HVD_MODE:
5694 isp_prt(isp, ISP_LOGINFO,
5695 "Transition to Differential mode");
5696 SDPARAM(isp, chan)->isp_diffmode = 1;
5697 SDPARAM(isp, chan)->isp_ultramode = 0;
5698 SDPARAM(isp, chan)->isp_lvdmode = 0;
5700 case SXP_PINS_SE_MODE:
5701 isp_prt(isp, ISP_LOGINFO,
5702 "Transition to Single Ended mode");
5703 SDPARAM(isp, chan)->isp_diffmode = 0;
5704 SDPARAM(isp, chan)->isp_ultramode = 1;
5705 SDPARAM(isp, chan)->isp_lvdmode = 0;
5708 isp_prt(isp, ISP_LOGWARN,
5709 "Transition to Unknown Mode 0x%x", mbox);
5713 * XXX: Set up to renegotiate again!
5715 /* Can only be for a 1080... */
5716 ISP_SET_SENDMARKER(isp, chan, 1);
5719 case ASYNC_CMD_CMPLT:
5721 if (!IS_ULTRA3(isp)) {
5722 isp_prt(isp, ISP_LOGERR, "unexpected fast posting completion");
5726 h1 = (ISP_READ(isp, OUTMAILBOX2) << 16) | ISP_READ(isp, OUTMAILBOX1);
5730 h1 = (ISP_READ(isp, OUTMAILBOX2) << 16) | ISP_READ(isp, OUTMAILBOX1);
5731 h2 = (ISP_READ(isp, OUTMAILBOX7) << 16) | ISP_READ(isp, OUTMAILBOX6);
5739 isp_prt(isp, ISP_LOGERR, "unexpected 16 bit RIO handle");
5742 isp_prt(isp, ISP_LOGWARN, "%s: unhandled async code 0x%x", __func__, mbox);
5747 isp_prt(isp, ISP_LOGDEBUG3, "fast post/rio completion of 0x%08x", h1);
5748 isp_fastpost_complete(isp, h1);
5750 isp_prt(isp, ISP_LOGDEBUG3, "fast post/rio completion of 0x%08x", h2);
5751 isp_fastpost_complete(isp, h2);
5752 if (isp->isp_fpcchiwater < 2) {
5753 isp->isp_fpcchiwater = 2;
5756 if (isp->isp_fpcchiwater < 1) {
5757 isp->isp_fpcchiwater = 1;
5761 isp->isp_intoasync++;
5767 isp_parse_async_fc(ispsoftc_t *isp, uint16_t mbox)
5773 if (IS_DUALBUS(isp)) {
5774 chan = ISP_READ(isp, OUTMAILBOX6);
5778 isp_prt(isp, ISP_LOGDEBUG2, "Async Mbox 0x%x", mbox);
5781 case ASYNC_SYSTEM_ERROR:
5783 isp->isp_state = ISP_CRASHED;
5784 FCPARAM(isp, chan)->isp_loopstate = LOOP_NIL;
5785 isp_change_fw_state(isp, chan, FW_CONFIG_WAIT);
5787 * Were we waiting for a mailbox command to complete?
5788 * If so, it's dead, so wake up the waiter.
5790 if (isp->isp_mboxbsy) {
5792 isp->isp_mboxtmp[0] = MBOX_HOST_INTERFACE_ERROR;
5793 MBOX_NOTIFY_COMPLETE(isp);
5796 * It's up to the handler for isp_async to reinit stuff and
5797 * restart the firmware
5799 isp_async(isp, ISPASYNC_FW_CRASH);
5803 case ASYNC_RQS_XFER_ERR:
5804 isp_prt(isp, ISP_LOGERR, "Request Queue Transfer Error");
5807 case ASYNC_RSP_XFER_ERR:
5808 isp_prt(isp, ISP_LOGERR, "Response Queue Transfer Error");
5812 #ifdef ISP_TARGET_MODE
5814 isp_prt(isp, ISP_LOGERR, "ATIO Queue Transfer Error");
5818 isp_prt(isp, ISP_LOGERR, "%s: unexpected ASYNC_QWAKEUP code", __func__);
5821 case ASYNC_CMD_CMPLT:
5822 isp_fastpost_complete(isp, (ISP_READ(isp, OUTMAILBOX2) << 16) | ISP_READ(isp, OUTMAILBOX1));
5823 if (isp->isp_fpcchiwater < 1) {
5824 isp->isp_fpcchiwater = 1;
5828 case ASYNC_RIOZIO_STALL:
5831 case ASYNC_CTIO_DONE:
5832 #ifdef ISP_TARGET_MODE
5833 if (isp_target_async(isp, (ISP_READ(isp, OUTMAILBOX2) << 16) | ISP_READ(isp, OUTMAILBOX1), mbox)) {
5836 isp->isp_fphccmplt++;
5839 isp_prt(isp, ISP_LOGWARN, "unexpected ASYNC CTIO done");
5842 case ASYNC_LIP_ERROR:
5843 case ASYNC_LIP_NOS_OLS_RECV:
5844 case ASYNC_LIP_OCCURRED:
5847 * These are broadcast events that have to be sent across
5848 * all active channels.
5850 for (chan = 0; chan < isp->isp_nchan; chan++) {
5851 fcp = FCPARAM(isp, chan);
5852 int topo = fcp->isp_topo;
5854 if (fcp->role == ISP_ROLE_NONE)
5856 if (fcp->isp_loopstate > LOOP_HAVE_LINK)
5857 fcp->isp_loopstate = LOOP_HAVE_LINK;
5858 ISP_SET_SENDMARKER(isp, chan, 1);
5859 isp_async(isp, ISPASYNC_LIP, chan);
5860 #ifdef ISP_TARGET_MODE
5861 if (isp_target_async(isp, chan, mbox)) {
5866 * We've had problems with data corruption occuring on
5867 * commands that complete (with no apparent error) after
5868 * we receive a LIP. This has been observed mostly on
5869 * Local Loop topologies. To be safe, let's just mark
5870 * all active initiator commands as dead.
5872 if (topo == TOPO_NL_PORT || topo == TOPO_FL_PORT) {
5874 for (i = j = 0; i < isp->isp_maxcmds; i++) {
5878 hdp = &isp->isp_xflist[i];
5879 if (ISP_H2HT(hdp->handle) != ISP_HANDLE_INITIATOR) {
5883 if (XS_CHANNEL(xs) != chan) {
5887 isp_prt(isp, ISP_LOG_WARN1,
5888 "%d.%d.%jx bus reset set at %s:%u",
5889 XS_CHANNEL(xs), XS_TGT(xs),
5890 (uintmax_t)XS_LUN(xs),
5891 __func__, __LINE__);
5892 XS_SETERR(xs, HBA_BUSRESET);
5895 isp_prt(isp, ISP_LOGERR, lipd, chan, j);
5903 * This is a broadcast event that has to be sent across
5904 * all active channels.
5906 for (chan = 0; chan < isp->isp_nchan; chan++) {
5907 fcp = FCPARAM(isp, chan);
5908 if (fcp->role == ISP_ROLE_NONE)
5910 fcp->isp_linkstate = 1;
5911 if (fcp->isp_loopstate < LOOP_HAVE_LINK)
5912 fcp->isp_loopstate = LOOP_HAVE_LINK;
5913 ISP_SET_SENDMARKER(isp, chan, 1);
5914 isp_async(isp, ISPASYNC_LOOP_UP, chan);
5915 #ifdef ISP_TARGET_MODE
5916 if (isp_target_async(isp, chan, mbox)) {
5923 case ASYNC_LOOP_DOWN:
5925 * This is a broadcast event that has to be sent across
5926 * all active channels.
5928 for (chan = 0; chan < isp->isp_nchan; chan++) {
5929 fcp = FCPARAM(isp, chan);
5930 if (fcp->role == ISP_ROLE_NONE)
5932 ISP_SET_SENDMARKER(isp, chan, 1);
5933 fcp->isp_linkstate = 0;
5934 fcp->isp_loopstate = LOOP_NIL;
5935 isp_async(isp, ISPASYNC_LOOP_DOWN, chan);
5936 #ifdef ISP_TARGET_MODE
5937 if (isp_target_async(isp, chan, mbox)) {
5944 case ASYNC_LOOP_RESET:
5946 * This is a broadcast event that has to be sent across
5947 * all active channels.
5949 for (chan = 0; chan < isp->isp_nchan; chan++) {
5950 fcp = FCPARAM(isp, chan);
5951 if (fcp->role == ISP_ROLE_NONE)
5953 ISP_SET_SENDMARKER(isp, chan, 1);
5954 if (fcp->isp_loopstate > LOOP_HAVE_LINK)
5955 fcp->isp_loopstate = LOOP_HAVE_LINK;
5956 isp_async(isp, ISPASYNC_LOOP_RESET, chan);
5957 #ifdef ISP_TARGET_MODE
5958 if (isp_target_async(isp, chan, mbox)) {
5965 case ASYNC_PDB_CHANGED:
5967 int echan, nphdl, nlstate, reason;
5969 if (IS_23XX(isp) || IS_24XX(isp)) {
5970 nphdl = ISP_READ(isp, OUTMAILBOX1);
5971 nlstate = ISP_READ(isp, OUTMAILBOX2);
5973 nphdl = nlstate = 0xffff;
5976 reason = ISP_READ(isp, OUTMAILBOX3) >> 8;
5979 if (ISP_CAP_MULTI_ID(isp)) {
5980 chan = ISP_READ(isp, OUTMAILBOX3) & 0xff;
5981 if (chan == 0xff || nphdl == NIL_HANDLE) {
5983 echan = isp->isp_nchan - 1;
5984 } else if (chan >= isp->isp_nchan) {
5992 for (; chan <= echan; chan++) {
5993 fcp = FCPARAM(isp, chan);
5994 if (fcp->role == ISP_ROLE_NONE)
5996 if (fcp->isp_loopstate > LOOP_LTEST_DONE)
5997 fcp->isp_loopstate = LOOP_LTEST_DONE;
5998 else if (fcp->isp_loopstate < LOOP_HAVE_LINK)
5999 fcp->isp_loopstate = LOOP_HAVE_LINK;
6000 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan,
6001 ISPASYNC_CHANGE_PDB, nphdl, nlstate, reason);
6005 case ASYNC_CHANGE_NOTIFY:
6009 portid = ((ISP_READ(isp, OUTMAILBOX1) & 0xff) << 16) |
6010 ISP_READ(isp, OUTMAILBOX2);
6011 if (ISP_CAP_MULTI_ID(isp)) {
6012 chan = ISP_READ(isp, OUTMAILBOX3) & 0xff;
6013 if (chan >= isp->isp_nchan)
6018 fcp = FCPARAM(isp, chan);
6019 if (fcp->role == ISP_ROLE_NONE)
6021 if (fcp->isp_loopstate > LOOP_LTEST_DONE)
6022 fcp->isp_loopstate = LOOP_LTEST_DONE;
6023 else if (fcp->isp_loopstate < LOOP_HAVE_LINK)
6024 fcp->isp_loopstate = LOOP_HAVE_LINK;
6025 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan,
6026 ISPASYNC_CHANGE_SNS, portid);
6029 case ASYNC_ERR_LOGGING_DISABLED:
6030 isp_prt(isp, ISP_LOGWARN, "Error logging disabled (reason 0x%x)",
6031 ISP_READ(isp, OUTMAILBOX1));
6033 case ASYNC_CONNMODE:
6035 * This only applies to 2100 amd 2200 cards
6037 if (!IS_2200(isp) && !IS_2100(isp)) {
6038 isp_prt(isp, ISP_LOGWARN, "bad card for ASYNC_CONNMODE event");
6042 mbox = ISP_READ(isp, OUTMAILBOX1);
6045 isp_prt(isp, ISP_LOGINFO,
6046 "Point-to-Point -> Loop mode");
6049 isp_prt(isp, ISP_LOGINFO,
6050 "Loop -> Point-to-Point mode");
6052 case ISP_CONN_BADLIP:
6053 isp_prt(isp, ISP_LOGWARN,
6054 "Point-to-Point -> Loop mode (BAD LIP)");
6056 case ISP_CONN_FATAL:
6058 isp->isp_state = ISP_CRASHED;
6059 isp_prt(isp, ISP_LOGERR, "FATAL CONNECTION ERROR");
6060 isp_async(isp, ISPASYNC_FW_CRASH);
6062 case ISP_CONN_LOOPBACK:
6063 isp_prt(isp, ISP_LOGWARN,
6064 "Looped Back in Point-to-Point mode");
6067 isp_prt(isp, ISP_LOGWARN,
6068 "Unknown connection mode (0x%x)", mbox);
6071 ISP_SET_SENDMARKER(isp, chan, 1);
6072 FCPARAM(isp, chan)->isp_loopstate = LOOP_HAVE_LINK;
6073 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan, ISPASYNC_CHANGE_OTHER);
6075 case ASYNC_P2P_INIT_ERR:
6076 isp_prt(isp, ISP_LOGWARN, "P2P init error (reason 0x%x)",
6077 ISP_READ(isp, OUTMAILBOX1));
6081 isp_prt(isp, ISP_LOGWARN, "Receive Error");
6083 isp_prt(isp, ISP_LOGWARN, "unexpected ASYNC_RCV_ERR");
6086 case ASYNC_RJT_SENT: /* same as ASYNC_QFULL_SENT */
6088 isp_prt(isp, ISP_LOGTDEBUG0, "LS_RJT sent");
6091 isp_prt(isp, ISP_LOGTDEBUG0, "QFULL sent");
6094 case ASYNC_FW_RESTART_COMPLETE:
6095 isp_prt(isp, ISP_LOGDEBUG0, "FW restart complete");
6097 case ASYNC_TEMPERATURE_ALERT:
6098 isp_prt(isp, ISP_LOGERR, "Temperature alert (subcode 0x%x)",
6099 ISP_READ(isp, OUTMAILBOX1));
6101 case ASYNC_AUTOLOAD_FW_COMPLETE:
6102 isp_prt(isp, ISP_LOGDEBUG0, "Autoload FW init complete");
6104 case ASYNC_AUTOLOAD_FW_FAILURE:
6105 isp_prt(isp, ISP_LOGERR, "Autoload FW init failure");
6108 isp_prt(isp, ISP_LOGWARN, "Unknown Async Code 0x%x", mbox);
6111 if (mbox != ASYNC_CTIO_DONE && mbox != ASYNC_CMD_CMPLT) {
6112 isp->isp_intoasync++;
6118 * Handle other response entries. A pointer to the request queue output
6119 * index is here in case we want to eat several entries at once, although
6120 * this is not used currently.
6124 isp_handle_other_response(ispsoftc_t *isp, int type, isphdr_t *hp, uint32_t *optrp)
6132 case RQSTYPE_STATUS_CONT:
6133 isp_prt(isp, ISP_LOG_WARN1, "Ignored Continuation Response");
6135 case RQSTYPE_MARKER:
6136 isp_prt(isp, ISP_LOG_WARN1, "Marker Response");
6138 case RQSTYPE_RPT_ID_ACQ:
6139 isp_get_ridacq(isp, (isp_ridacq_t *)hp, &rid);
6140 if (rid.ridacq_format == 0) {
6141 for (chan = 0; chan < isp->isp_nchan; chan++) {
6142 fcparam *fcp = FCPARAM(isp, chan);
6143 if (fcp->role == ISP_ROLE_NONE)
6145 c = (chan == 0) ? 127 : (chan - 1);
6146 if (rid.ridacq_map[c / 16] & (1 << (c % 16)) ||
6148 fcp->isp_loopstate = LOOP_HAVE_LINK;
6149 isp_async(isp, ISPASYNC_CHANGE_NOTIFY,
6150 chan, ISPASYNC_CHANGE_OTHER);
6152 fcp->isp_loopstate = LOOP_NIL;
6153 isp_async(isp, ISPASYNC_LOOP_DOWN,
6158 fcparam *fcp = FCPARAM(isp, rid.ridacq_vp_index);
6159 if (rid.ridacq_vp_status == RIDACQ_STS_COMPLETE ||
6160 rid.ridacq_vp_status == RIDACQ_STS_CHANGED) {
6161 fcp->isp_loopstate = LOOP_HAVE_LINK;
6162 isp_async(isp, ISPASYNC_CHANGE_NOTIFY,
6163 rid.ridacq_vp_index, ISPASYNC_CHANGE_OTHER);
6165 fcp->isp_loopstate = LOOP_NIL;
6166 isp_async(isp, ISPASYNC_LOOP_DOWN,
6167 rid.ridacq_vp_index);
6171 case RQSTYPE_VP_MODIFY:
6172 case RQSTYPE_VP_CTRL:
6173 ISP_IOXGET_32(isp, (uint32_t *)(hp + 1), hdl);
6174 ptr = isp_find_xs(isp, hdl);
6176 isp_destroy_handle(isp, hdl);
6177 memcpy(ptr, hp, QENTRY_LEN);
6183 case RQSTYPE_ENABLE_LUN:
6184 case RQSTYPE_MODIFY_LUN:
6185 case RQSTYPE_NOTIFY:
6186 case RQSTYPE_NOTIFY_ACK:
6192 case RQSTYPE_ABTS_RCVD:
6193 case RQSTYPE_ABTS_RSP:
6194 isp->isp_rsltccmplt++; /* count as a response completion */
6195 #ifdef ISP_TARGET_MODE
6196 if (isp_target_notify(isp, (ispstatusreq_t *) hp, optrp)) {
6201 case RQSTYPE_REQUEST:
6204 if (type != isp_get_response_type(isp, hp)) {
6206 * This is questionable- we're just papering over
6207 * something we've seen on SMP linux in target
6208 * mode- we don't really know what's happening
6209 * here that causes us to think we've gotten
6210 * an entry, but that either the entry isn't
6211 * filled out yet or our CPU read data is stale.
6213 isp_prt(isp, ISP_LOGINFO,
6214 "unstable type in response queue");
6217 isp_prt(isp, ISP_LOGWARN, "Unhandled Response Type 0x%x",
6218 isp_get_response_type(isp, hp));
6224 isp_parse_status(ispsoftc_t *isp, ispstatusreq_t *sp, XS_T *xs, long *rp)
6226 switch (sp->req_completion_status & 0xff) {
6229 XS_SETERR(xs, HBA_NOERROR);
6233 case RQCS_INCOMPLETE:
6234 if ((sp->req_state_flags & RQSF_GOT_TARGET) == 0) {
6235 isp_xs_prt(isp, xs, ISP_LOG_WARN1, "Selection Timeout @ %s:%d", __func__, __LINE__);
6237 XS_SETERR(xs, HBA_SELTIMEOUT);
6238 *rp = XS_XFRLEN(xs);
6242 isp_xs_prt(isp, xs, ISP_LOGERR, "Command Incomplete, state 0x%x", sp->req_state_flags);
6245 case RQCS_DMA_ERROR:
6246 isp_xs_prt(isp, xs, ISP_LOGERR, "DMA Error");
6247 *rp = XS_XFRLEN(xs);
6250 case RQCS_TRANSPORT_ERROR:
6253 ISP_SNPRINTF(buf, sizeof (buf), "states=>");
6254 if (sp->req_state_flags & RQSF_GOT_BUS) {
6255 ISP_SNPRINTF(buf, sizeof (buf), "%s GOT_BUS", buf);
6257 if (sp->req_state_flags & RQSF_GOT_TARGET) {
6258 ISP_SNPRINTF(buf, sizeof (buf), "%s GOT_TGT", buf);
6260 if (sp->req_state_flags & RQSF_SENT_CDB) {
6261 ISP_SNPRINTF(buf, sizeof (buf), "%s SENT_CDB", buf);
6263 if (sp->req_state_flags & RQSF_XFRD_DATA) {
6264 ISP_SNPRINTF(buf, sizeof (buf), "%s XFRD_DATA", buf);
6266 if (sp->req_state_flags & RQSF_GOT_STATUS) {
6267 ISP_SNPRINTF(buf, sizeof (buf), "%s GOT_STS", buf);
6269 if (sp->req_state_flags & RQSF_GOT_SENSE) {
6270 ISP_SNPRINTF(buf, sizeof (buf), "%s GOT_SNS", buf);
6272 if (sp->req_state_flags & RQSF_XFER_COMPLETE) {
6273 ISP_SNPRINTF(buf, sizeof (buf), "%s XFR_CMPLT", buf);
6275 ISP_SNPRINTF(buf, sizeof (buf), "%s\nstatus=>", buf);
6276 if (sp->req_status_flags & RQSTF_DISCONNECT) {
6277 ISP_SNPRINTF(buf, sizeof (buf), "%s Disconnect", buf);
6279 if (sp->req_status_flags & RQSTF_SYNCHRONOUS) {
6280 ISP_SNPRINTF(buf, sizeof (buf), "%s Sync_xfr", buf);
6282 if (sp->req_status_flags & RQSTF_PARITY_ERROR) {
6283 ISP_SNPRINTF(buf, sizeof (buf), "%s Parity", buf);
6285 if (sp->req_status_flags & RQSTF_BUS_RESET) {
6286 ISP_SNPRINTF(buf, sizeof (buf), "%s Bus_Reset", buf);
6288 if (sp->req_status_flags & RQSTF_DEVICE_RESET) {
6289 ISP_SNPRINTF(buf, sizeof (buf), "%s Device_Reset", buf);
6291 if (sp->req_status_flags & RQSTF_ABORTED) {
6292 ISP_SNPRINTF(buf, sizeof (buf), "%s Aborted", buf);
6294 if (sp->req_status_flags & RQSTF_TIMEOUT) {
6295 ISP_SNPRINTF(buf, sizeof (buf), "%s Timeout", buf);
6297 if (sp->req_status_flags & RQSTF_NEGOTIATION) {
6298 ISP_SNPRINTF(buf, sizeof (buf), "%s Negotiation", buf);
6300 isp_xs_prt(isp, xs, ISP_LOGERR, "Transport Error: %s", buf);
6301 *rp = XS_XFRLEN(xs);
6304 case RQCS_RESET_OCCURRED:
6307 isp_xs_prt(isp, xs, ISP_LOGWARN, "Bus Reset destroyed command");
6308 for (chan = 0; chan < isp->isp_nchan; chan++) {
6309 FCPARAM(isp, chan)->sendmarker = 1;
6312 XS_SETERR(xs, HBA_BUSRESET);
6314 *rp = XS_XFRLEN(xs);
6318 isp_xs_prt(isp, xs, ISP_LOGERR, "Command Aborted");
6319 ISP_SET_SENDMARKER(isp, XS_CHANNEL(xs), 1);
6321 XS_SETERR(xs, HBA_ABORTED);
6326 isp_xs_prt(isp, xs, ISP_LOGWARN, "Command timed out");
6328 * XXX: Check to see if we logged out of the device.
6331 XS_SETERR(xs, HBA_CMDTIMEOUT);
6335 case RQCS_DATA_OVERRUN:
6336 XS_SET_RESID(xs, sp->req_resid);
6337 isp_xs_prt(isp, xs, ISP_LOGERR, "data overrun (%ld)", (long) XS_GET_RESID(xs));
6339 XS_SETERR(xs, HBA_DATAOVR);
6343 case RQCS_COMMAND_OVERRUN:
6344 isp_xs_prt(isp, xs, ISP_LOGERR, "command overrun");
6347 case RQCS_STATUS_OVERRUN:
6348 isp_xs_prt(isp, xs, ISP_LOGERR, "status overrun");
6351 case RQCS_BAD_MESSAGE:
6352 isp_xs_prt(isp, xs, ISP_LOGERR, "msg not COMMAND COMPLETE after status");
6355 case RQCS_NO_MESSAGE_OUT:
6356 isp_xs_prt(isp, xs, ISP_LOGERR, "No MESSAGE OUT phase after selection");
6359 case RQCS_EXT_ID_FAILED:
6360 isp_xs_prt(isp, xs, ISP_LOGERR, "EXTENDED IDENTIFY failed");
6363 case RQCS_IDE_MSG_FAILED:
6364 isp_xs_prt(isp, xs, ISP_LOGERR, "INITIATOR DETECTED ERROR rejected");
6367 case RQCS_ABORT_MSG_FAILED:
6368 isp_xs_prt(isp, xs, ISP_LOGERR, "ABORT OPERATION rejected");
6371 case RQCS_REJECT_MSG_FAILED:
6372 isp_xs_prt(isp, xs, ISP_LOGERR, "MESSAGE REJECT rejected");
6375 case RQCS_NOP_MSG_FAILED:
6376 isp_xs_prt(isp, xs, ISP_LOGERR, "NOP rejected");
6379 case RQCS_PARITY_ERROR_MSG_FAILED:
6380 isp_xs_prt(isp, xs, ISP_LOGERR, "MESSAGE PARITY ERROR rejected");
6383 case RQCS_DEVICE_RESET_MSG_FAILED:
6384 isp_xs_prt(isp, xs, ISP_LOGWARN, "BUS DEVICE RESET rejected");
6387 case RQCS_ID_MSG_FAILED:
6388 isp_xs_prt(isp, xs, ISP_LOGERR, "IDENTIFY rejected");
6391 case RQCS_UNEXP_BUS_FREE:
6392 isp_xs_prt(isp, xs, ISP_LOGERR, "Unexpected Bus Free");
6395 case RQCS_DATA_UNDERRUN:
6398 int ru_marked = (sp->req_scsi_status & RQCS_RU) != 0;
6399 if (!ru_marked || sp->req_resid > XS_XFRLEN(xs)) {
6400 isp_xs_prt(isp, xs, ISP_LOGWARN, bun, XS_XFRLEN(xs), sp->req_resid, (ru_marked)? "marked" : "not marked");
6402 XS_SETERR(xs, HBA_BOTCH);
6407 XS_SET_RESID(xs, sp->req_resid);
6409 XS_SETERR(xs, HBA_NOERROR);
6414 case RQCS_XACT_ERR1:
6415 isp_xs_prt(isp, xs, ISP_LOGERR, "HBA attempted queued transaction with disconnect not set");
6418 case RQCS_XACT_ERR2:
6419 isp_xs_prt(isp, xs, ISP_LOGERR,
6420 "HBA attempted queued transaction to target routine %jx",
6421 (uintmax_t)XS_LUN(xs));
6424 case RQCS_XACT_ERR3:
6425 isp_xs_prt(isp, xs, ISP_LOGERR, "HBA attempted queued cmd when queueing disabled");
6428 case RQCS_BAD_ENTRY:
6429 isp_prt(isp, ISP_LOGERR, "Invalid IOCB entry type detected");
6432 case RQCS_QUEUE_FULL:
6433 isp_xs_prt(isp, xs, ISP_LOG_WARN1, "internal queues full status 0x%x", *XS_STSP(xs));
6436 * If QFULL or some other status byte is set, then this
6437 * isn't an error, per se.
6439 * Unfortunately, some QLogic f/w writers have, in
6440 * some cases, ommitted to *set* status to QFULL.
6443 if (*XS_STSP(xs) != SCSI_GOOD && XS_NOERR(xs)) {
6444 XS_SETERR(xs, HBA_NOERROR);
6449 *XS_STSP(xs) = SCSI_QFULL;
6450 XS_SETERR(xs, HBA_NOERROR);
6453 case RQCS_PHASE_SKIPPED:
6454 isp_xs_prt(isp, xs, ISP_LOGERR, "SCSI phase skipped");
6457 case RQCS_ARQS_FAILED:
6458 isp_xs_prt(isp, xs, ISP_LOGERR, "Auto Request Sense Failed");
6460 XS_SETERR(xs, HBA_ARQFAIL);
6464 case RQCS_WIDE_FAILED:
6465 isp_xs_prt(isp, xs, ISP_LOGERR, "Wide Negotiation Failed");
6467 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
6468 sdp->isp_devparam[XS_TGT(xs)].goal_flags &= ~DPARM_WIDE;
6469 sdp->isp_devparam[XS_TGT(xs)].dev_update = 1;
6473 XS_SETERR(xs, HBA_NOERROR);
6477 case RQCS_SYNCXFER_FAILED:
6478 isp_xs_prt(isp, xs, ISP_LOGERR, "SDTR Message Failed");
6480 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
6481 sdp += XS_CHANNEL(xs);
6482 sdp->isp_devparam[XS_TGT(xs)].goal_flags &= ~DPARM_SYNC;
6483 sdp->isp_devparam[XS_TGT(xs)].dev_update = 1;
6488 case RQCS_LVD_BUSERR:
6489 isp_xs_prt(isp, xs, ISP_LOGERR, "Bad LVD condition");
6492 case RQCS_PORT_UNAVAILABLE:
6494 * No such port on the loop. Moral equivalent of SELTIMEO
6496 case RQCS_PORT_LOGGED_OUT:
6499 uint8_t sts = sp->req_completion_status & 0xff;
6502 * It was there (maybe)- treat as a selection timeout.
6504 if (sts == RQCS_PORT_UNAVAILABLE) {
6505 reason = "unavailable";
6510 isp_prt(isp, ISP_LOGINFO, "port %s for target %d", reason, XS_TGT(xs));
6513 * If we're on a local loop, force a LIP (which is overkill)
6514 * to force a re-login of this unit. If we're on fabric,
6515 * then we'll have to log in again as a matter of course.
6517 if (FCPARAM(isp, 0)->isp_topo == TOPO_NL_PORT ||
6518 FCPARAM(isp, 0)->isp_topo == TOPO_FL_PORT) {
6520 MBSINIT(&mbs, MBOX_INIT_LIP, MBLOGALL, 0);
6521 if (ISP_CAP_2KLOGIN(isp)) {
6522 mbs.ibits = (1 << 10);
6524 isp_mboxcmd_qnw(isp, &mbs, 1);
6527 XS_SETERR(xs, HBA_SELTIMEOUT);
6531 case RQCS_PORT_CHANGED:
6532 isp_prt(isp, ISP_LOGWARN, "port changed for target %d", XS_TGT(xs));
6534 XS_SETERR(xs, HBA_SELTIMEOUT);
6538 case RQCS_PORT_BUSY:
6539 isp_prt(isp, ISP_LOGWARN, "port busy for target %d", XS_TGT(xs));
6541 XS_SETERR(xs, HBA_TGTBSY);
6546 isp_prt(isp, ISP_LOGERR, "Unknown Completion Status 0x%x", sp->req_completion_status);
6550 XS_SETERR(xs, HBA_BOTCH);
6555 isp_parse_status_24xx(ispsoftc_t *isp, isp24xx_statusreq_t *sp, XS_T *xs, long *rp)
6557 int ru_marked, sv_marked;
6558 int chan = XS_CHANNEL(xs);
6560 switch (sp->req_completion_status) {
6563 XS_SETERR(xs, HBA_NOERROR);
6567 case RQCS_DMA_ERROR:
6568 isp_xs_prt(isp, xs, ISP_LOGERR, "DMA error");
6571 case RQCS_TRANSPORT_ERROR:
6572 isp_xs_prt(isp, xs, ISP_LOGERR, "Transport Error");
6575 case RQCS_RESET_OCCURRED:
6576 isp_xs_prt(isp, xs, ISP_LOGWARN, "reset destroyed command");
6577 FCPARAM(isp, chan)->sendmarker = 1;
6579 XS_SETERR(xs, HBA_BUSRESET);
6584 isp_xs_prt(isp, xs, ISP_LOGERR, "Command Aborted");
6585 FCPARAM(isp, chan)->sendmarker = 1;
6587 XS_SETERR(xs, HBA_ABORTED);
6592 isp_xs_prt(isp, xs, ISP_LOGWARN, "Command Timed Out");
6594 XS_SETERR(xs, HBA_CMDTIMEOUT);
6598 case RQCS_DATA_OVERRUN:
6599 XS_SET_RESID(xs, sp->req_resid);
6600 isp_xs_prt(isp, xs, ISP_LOGERR, "Data Overrun");
6602 XS_SETERR(xs, HBA_DATAOVR);
6606 case RQCS_24XX_DRE: /* data reassembly error */
6607 isp_prt(isp, ISP_LOGERR, "Chan %d data reassembly error for target %d", chan, XS_TGT(xs));
6609 XS_SETERR(xs, HBA_ABORTED);
6611 *rp = XS_XFRLEN(xs);
6614 case RQCS_24XX_TABORT: /* aborted by target */
6615 isp_prt(isp, ISP_LOGERR, "Chan %d target %d sent ABTS", chan, XS_TGT(xs));
6617 XS_SETERR(xs, HBA_ABORTED);
6621 case RQCS_DATA_UNDERRUN:
6622 ru_marked = (sp->req_scsi_status & RQCS_RU) != 0;
6624 * We can get an underrun w/o things being marked
6625 * if we got a non-zero status.
6627 sv_marked = (sp->req_scsi_status & (RQCS_SV|RQCS_RV)) != 0;
6628 if ((ru_marked == 0 && sv_marked == 0) ||
6629 (sp->req_resid > XS_XFRLEN(xs))) {
6630 isp_xs_prt(isp, xs, ISP_LOGWARN, bun, XS_XFRLEN(xs), sp->req_resid, (ru_marked)? "marked" : "not marked");
6632 XS_SETERR(xs, HBA_BOTCH);
6636 XS_SET_RESID(xs, sp->req_resid);
6637 isp_xs_prt(isp, xs, ISP_LOG_WARN1, "Data Underrun (%d) for command 0x%x", sp->req_resid, XS_CDBP(xs)[0] & 0xff);
6639 XS_SETERR(xs, HBA_NOERROR);
6643 case RQCS_PORT_UNAVAILABLE:
6645 * No such port on the loop. Moral equivalent of SELTIMEO
6647 case RQCS_PORT_LOGGED_OUT:
6650 uint8_t sts = sp->req_completion_status & 0xff;
6653 * It was there (maybe)- treat as a selection timeout.
6655 if (sts == RQCS_PORT_UNAVAILABLE) {
6656 reason = "unavailable";
6661 isp_prt(isp, ISP_LOGINFO, "Chan %d port %s for target %d",
6662 chan, reason, XS_TGT(xs));
6665 * There is no MBOX_INIT_LIP for the 24XX.
6668 XS_SETERR(xs, HBA_SELTIMEOUT);
6672 case RQCS_PORT_CHANGED:
6673 isp_prt(isp, ISP_LOGWARN, "port changed for target %d chan %d", XS_TGT(xs), chan);
6675 XS_SETERR(xs, HBA_SELTIMEOUT);
6680 case RQCS_24XX_ENOMEM: /* f/w resource unavailable */
6681 isp_prt(isp, ISP_LOGWARN, "f/w resource unavailable for target %d chan %d", XS_TGT(xs), chan);
6683 *XS_STSP(xs) = SCSI_BUSY;
6684 XS_SETERR(xs, HBA_TGTBSY);
6688 case RQCS_24XX_TMO: /* task management overrun */
6689 isp_prt(isp, ISP_LOGWARN, "command for target %d overlapped task management for chan %d", XS_TGT(xs), chan);
6691 *XS_STSP(xs) = SCSI_BUSY;
6692 XS_SETERR(xs, HBA_TGTBSY);
6697 isp_prt(isp, ISP_LOGERR, "Unknown Completion Status 0x%x on chan %d", sp->req_completion_status, chan);
6701 XS_SETERR(xs, HBA_BOTCH);
6706 isp_fastpost_complete(ispsoftc_t *isp, uint32_t fph)
6713 xs = isp_find_xs(isp, fph);
6715 isp_prt(isp, ISP_LOGWARN,
6716 "Command for fast post handle 0x%x not found", fph);
6719 isp_destroy_handle(isp, fph);
6722 * Since we don't have a result queue entry item,
6723 * we must believe that SCSI status is zero and
6724 * that all data transferred.
6726 XS_SET_RESID(xs, 0);
6727 *XS_STSP(xs) = SCSI_GOOD;
6728 if (XS_XFRLEN(xs)) {
6729 ISP_DMAFREE(isp, xs, fph);
6731 if (isp->isp_nactive) {
6734 isp->isp_fphccmplt++;
6739 isp_mbox_continue(ispsoftc_t *isp)
6745 switch (isp->isp_lastmbxcmd) {
6746 case MBOX_WRITE_RAM_WORD:
6747 case MBOX_READ_RAM_WORD:
6748 case MBOX_WRITE_RAM_WORD_EXTENDED:
6749 case MBOX_READ_RAM_WORD_EXTENDED:
6754 if (isp->isp_mboxtmp[0] != MBOX_COMMAND_COMPLETE) {
6755 isp->isp_mbxwrk0 = 0;
6760 * Clear the previous interrupt.
6763 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT);
6765 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
6766 ISP_WRITE(isp, BIU_SEMA, 0);
6770 * Continue with next word.
6772 ISP_MEMZERO(&mbs, sizeof (mbs));
6773 ptr = isp->isp_mbxworkp;
6774 switch (isp->isp_lastmbxcmd) {
6775 case MBOX_WRITE_RAM_WORD:
6776 mbs.param[1] = isp->isp_mbxwrk1++;
6777 mbs.param[2] = *ptr++;
6779 case MBOX_READ_RAM_WORD:
6780 *ptr++ = isp->isp_mboxtmp[2];
6781 mbs.param[1] = isp->isp_mbxwrk1++;
6783 case MBOX_WRITE_RAM_WORD_EXTENDED:
6785 uint32_t *lptr = (uint32_t *)ptr;
6786 mbs.param[2] = lptr[0];
6787 mbs.param[3] = lptr[0] >> 16;
6789 ptr = (uint16_t *)lptr;
6791 mbs.param[2] = *ptr++;
6793 offset = isp->isp_mbxwrk1;
6794 offset |= isp->isp_mbxwrk8 << 16;
6795 mbs.param[1] = offset;
6796 mbs.param[8] = offset >> 16;
6798 isp->isp_mbxwrk1 = offset;
6799 isp->isp_mbxwrk8 = offset >> 16;
6801 case MBOX_READ_RAM_WORD_EXTENDED:
6803 uint32_t *lptr = (uint32_t *)ptr;
6804 uint32_t val = isp->isp_mboxtmp[2];
6805 val |= (isp->isp_mboxtmp[3]) << 16;
6807 ptr = (uint16_t *)lptr;
6809 *ptr++ = isp->isp_mboxtmp[2];
6811 offset = isp->isp_mbxwrk1;
6812 offset |= isp->isp_mbxwrk8 << 16;
6813 mbs.param[1] = offset;
6814 mbs.param[8] = offset >> 16;
6816 isp->isp_mbxwrk1 = offset;
6817 isp->isp_mbxwrk8 = offset >> 16;
6820 isp->isp_mbxworkp = ptr;
6822 mbs.param[0] = isp->isp_lastmbxcmd;
6823 mbs.logval = MBLOGALL;
6824 isp_mboxcmd_qnw(isp, &mbs, 0);
6828 #define ISP_SCSI_IBITS(op) (mbpscsi[((op)<<1)])
6829 #define ISP_SCSI_OBITS(op) (mbpscsi[((op)<<1) + 1])
6830 #define ISP_SCSI_OPMAP(in, out) in, out
6831 static const uint8_t mbpscsi[] = {
6832 ISP_SCSI_OPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */
6833 ISP_SCSI_OPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */
6834 ISP_SCSI_OPMAP(0x03, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */
6835 ISP_SCSI_OPMAP(0x1f, 0x01), /* 0x03: MBOX_DUMP_RAM */
6836 ISP_SCSI_OPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */
6837 ISP_SCSI_OPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */
6838 ISP_SCSI_OPMAP(0x3f, 0x3f), /* 0x06: MBOX_MAILBOX_REG_TEST */
6839 ISP_SCSI_OPMAP(0x07, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */
6840 ISP_SCSI_OPMAP(0x01, 0x0f), /* 0x08: MBOX_ABOUT_FIRMWARE */
6841 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x09: */
6842 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x0a: */
6843 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x0b: */
6844 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x0c: */
6845 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x0d: */
6846 ISP_SCSI_OPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */
6847 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x0f: */
6848 ISP_SCSI_OPMAP(0x1f, 0x1f), /* 0x10: MBOX_INIT_REQ_QUEUE */
6849 ISP_SCSI_OPMAP(0x3f, 0x3f), /* 0x11: MBOX_INIT_RES_QUEUE */
6850 ISP_SCSI_OPMAP(0x0f, 0x0f), /* 0x12: MBOX_EXECUTE_IOCB */
6851 ISP_SCSI_OPMAP(0x03, 0x03), /* 0x13: MBOX_WAKE_UP */
6852 ISP_SCSI_OPMAP(0x01, 0x3f), /* 0x14: MBOX_STOP_FIRMWARE */
6853 ISP_SCSI_OPMAP(0x0f, 0x0f), /* 0x15: MBOX_ABORT */
6854 ISP_SCSI_OPMAP(0x03, 0x03), /* 0x16: MBOX_ABORT_DEVICE */
6855 ISP_SCSI_OPMAP(0x07, 0x07), /* 0x17: MBOX_ABORT_TARGET */
6856 ISP_SCSI_OPMAP(0x07, 0x07), /* 0x18: MBOX_BUS_RESET */
6857 ISP_SCSI_OPMAP(0x03, 0x07), /* 0x19: MBOX_STOP_QUEUE */
6858 ISP_SCSI_OPMAP(0x03, 0x07), /* 0x1a: MBOX_START_QUEUE */
6859 ISP_SCSI_OPMAP(0x03, 0x07), /* 0x1b: MBOX_SINGLE_STEP_QUEUE */
6860 ISP_SCSI_OPMAP(0x03, 0x07), /* 0x1c: MBOX_ABORT_QUEUE */
6861 ISP_SCSI_OPMAP(0x03, 0x4f), /* 0x1d: MBOX_GET_DEV_QUEUE_STATUS */
6862 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x1e: */
6863 ISP_SCSI_OPMAP(0x01, 0x07), /* 0x1f: MBOX_GET_FIRMWARE_STATUS */
6864 ISP_SCSI_OPMAP(0x01, 0x07), /* 0x20: MBOX_GET_INIT_SCSI_ID */
6865 ISP_SCSI_OPMAP(0x01, 0x07), /* 0x21: MBOX_GET_SELECT_TIMEOUT */
6866 ISP_SCSI_OPMAP(0x01, 0xc7), /* 0x22: MBOX_GET_RETRY_COUNT */
6867 ISP_SCSI_OPMAP(0x01, 0x07), /* 0x23: MBOX_GET_TAG_AGE_LIMIT */
6868 ISP_SCSI_OPMAP(0x01, 0x03), /* 0x24: MBOX_GET_CLOCK_RATE */
6869 ISP_SCSI_OPMAP(0x01, 0x07), /* 0x25: MBOX_GET_ACT_NEG_STATE */
6870 ISP_SCSI_OPMAP(0x01, 0x07), /* 0x26: MBOX_GET_ASYNC_DATA_SETUP_TIME */
6871 ISP_SCSI_OPMAP(0x01, 0x07), /* 0x27: MBOX_GET_PCI_PARAMS */
6872 ISP_SCSI_OPMAP(0x03, 0x4f), /* 0x28: MBOX_GET_TARGET_PARAMS */
6873 ISP_SCSI_OPMAP(0x03, 0x0f), /* 0x29: MBOX_GET_DEV_QUEUE_PARAMS */
6874 ISP_SCSI_OPMAP(0x01, 0x07), /* 0x2a: MBOX_GET_RESET_DELAY_PARAMS */
6875 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x2b: */
6876 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x2c: */
6877 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x2d: */
6878 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x2e: */
6879 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x2f: */
6880 ISP_SCSI_OPMAP(0x03, 0x03), /* 0x30: MBOX_SET_INIT_SCSI_ID */
6881 ISP_SCSI_OPMAP(0x07, 0x07), /* 0x31: MBOX_SET_SELECT_TIMEOUT */
6882 ISP_SCSI_OPMAP(0xc7, 0xc7), /* 0x32: MBOX_SET_RETRY_COUNT */
6883 ISP_SCSI_OPMAP(0x07, 0x07), /* 0x33: MBOX_SET_TAG_AGE_LIMIT */
6884 ISP_SCSI_OPMAP(0x03, 0x03), /* 0x34: MBOX_SET_CLOCK_RATE */
6885 ISP_SCSI_OPMAP(0x07, 0x07), /* 0x35: MBOX_SET_ACT_NEG_STATE */
6886 ISP_SCSI_OPMAP(0x07, 0x07), /* 0x36: MBOX_SET_ASYNC_DATA_SETUP_TIME */
6887 ISP_SCSI_OPMAP(0x07, 0x07), /* 0x37: MBOX_SET_PCI_CONTROL_PARAMS */
6888 ISP_SCSI_OPMAP(0x4f, 0x4f), /* 0x38: MBOX_SET_TARGET_PARAMS */
6889 ISP_SCSI_OPMAP(0x0f, 0x0f), /* 0x39: MBOX_SET_DEV_QUEUE_PARAMS */
6890 ISP_SCSI_OPMAP(0x07, 0x07), /* 0x3a: MBOX_SET_RESET_DELAY_PARAMS */
6891 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x3b: */
6892 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x3c: */
6893 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x3d: */
6894 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x3e: */
6895 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x3f: */
6896 ISP_SCSI_OPMAP(0x01, 0x03), /* 0x40: MBOX_RETURN_BIOS_BLOCK_ADDR */
6897 ISP_SCSI_OPMAP(0x3f, 0x01), /* 0x41: MBOX_WRITE_FOUR_RAM_WORDS */
6898 ISP_SCSI_OPMAP(0x03, 0x07), /* 0x42: MBOX_EXEC_BIOS_IOCB */
6899 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x43: */
6900 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x44: */
6901 ISP_SCSI_OPMAP(0x03, 0x03), /* 0x45: SET SYSTEM PARAMETER */
6902 ISP_SCSI_OPMAP(0x01, 0x03), /* 0x46: GET SYSTEM PARAMETER */
6903 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x47: */
6904 ISP_SCSI_OPMAP(0x01, 0xcf), /* 0x48: GET SCAM CONFIGURATION */
6905 ISP_SCSI_OPMAP(0xcf, 0xcf), /* 0x49: SET SCAM CONFIGURATION */
6906 ISP_SCSI_OPMAP(0x03, 0x03), /* 0x4a: MBOX_SET_FIRMWARE_FEATURES */
6907 ISP_SCSI_OPMAP(0x01, 0x03), /* 0x4b: MBOX_GET_FIRMWARE_FEATURES */
6908 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x4c: */
6909 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x4d: */
6910 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x4e: */
6911 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x4f: */
6912 ISP_SCSI_OPMAP(0xdf, 0xdf), /* 0x50: LOAD RAM A64 */
6913 ISP_SCSI_OPMAP(0xdf, 0xdf), /* 0x51: DUMP RAM A64 */
6914 ISP_SCSI_OPMAP(0xdf, 0xff), /* 0x52: INITIALIZE REQUEST QUEUE A64 */
6915 ISP_SCSI_OPMAP(0xef, 0xff), /* 0x53: INITIALIZE RESPONSE QUEUE A64 */
6916 ISP_SCSI_OPMAP(0xcf, 0x01), /* 0x54: EXECUCUTE COMMAND IOCB A64 */
6917 ISP_SCSI_OPMAP(0x07, 0x01), /* 0x55: ENABLE TARGET MODE */
6918 ISP_SCSI_OPMAP(0x03, 0x0f), /* 0x56: GET TARGET STATUS */
6919 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x57: */
6920 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x58: */
6921 ISP_SCSI_OPMAP(0x00, 0x00), /* 0x59: */
6922 ISP_SCSI_OPMAP(0x03, 0x03), /* 0x5a: SET DATA OVERRUN RECOVERY MODE */
6923 ISP_SCSI_OPMAP(0x01, 0x03), /* 0x5b: GET DATA OVERRUN RECOVERY MODE */
6924 ISP_SCSI_OPMAP(0x0f, 0x0f), /* 0x5c: SET HOST DATA */
6925 ISP_SCSI_OPMAP(0x01, 0x01) /* 0x5d: GET NOST DATA */
6927 #define MAX_SCSI_OPCODE 0x5d
6929 static const char *scsi_mbcmd_names[] = {
6946 "INIT REQUEST QUEUE",
6947 "INIT RESULT QUEUE",
6957 "SINGLE STEP QUEUE",
6959 "GET DEV QUEUE STATUS",
6961 "GET FIRMWARE STATUS",
6963 "GET SELECT TIMEOUT",
6965 "GET TAG AGE LIMIT",
6967 "GET ACT NEG STATE",
6968 "GET ASYNC DATA SETUP TIME",
6970 "GET TARGET PARAMS",
6971 "GET DEV QUEUE PARAMS",
6972 "GET RESET DELAY PARAMS",
6979 "SET SELECT TIMEOUT",
6981 "SET TAG AGE LIMIT",
6983 "SET ACT NEG STATE",
6984 "SET ASYNC DATA SETUP TIME",
6985 "SET PCI CONTROL PARAMS",
6986 "SET TARGET PARAMS",
6987 "SET DEV QUEUE PARAMS",
6988 "SET RESET DELAY PARAMS",
6994 "RETURN BIOS BLOCK ADDR",
6995 "WRITE FOUR RAM WORDS",
6999 "SET SYSTEM PARAMETER",
7000 "GET SYSTEM PARAMETER",
7002 "GET SCAM CONFIGURATION",
7003 "SET SCAM CONFIGURATION",
7004 "SET FIRMWARE FEATURES",
7005 "GET FIRMWARE FEATURES",
7012 "INITIALIZE REQUEST QUEUE A64",
7013 "INITIALIZE RESPONSE QUEUE A64",
7015 "ENABLE TARGET MODE",
7016 "GET TARGET MODE STATE",
7020 "SET DATA OVERRUN RECOVERY MODE",
7021 "GET DATA OVERRUN RECOVERY MODE",
7026 #define ISP_FC_IBITS(op) ((mbpfc[((op)<<3) + 0] << 24) | (mbpfc[((op)<<3) + 1] << 16) | (mbpfc[((op)<<3) + 2] << 8) | (mbpfc[((op)<<3) + 3]))
7027 #define ISP_FC_OBITS(op) ((mbpfc[((op)<<3) + 4] << 24) | (mbpfc[((op)<<3) + 5] << 16) | (mbpfc[((op)<<3) + 6] << 8) | (mbpfc[((op)<<3) + 7]))
7029 #define ISP_FC_OPMAP(in0, out0) 0, 0, 0, in0, 0, 0, 0, out0
7030 #define ISP_FC_OPMAP_HALF(in1, in0, out1, out0) 0, 0, in1, in0, 0, 0, out1, out0
7031 #define ISP_FC_OPMAP_FULL(in3, in2, in1, in0, out3, out2, out1, out0) in3, in2, in1, in0, out3, out2, out1, out0
7032 static const uint32_t mbpfc[] = {
7033 ISP_FC_OPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */
7034 ISP_FC_OPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */
7035 ISP_FC_OPMAP_HALF(0x07, 0xff, 0x00, 0x03), /* 0x02: MBOX_EXEC_FIRMWARE */
7036 ISP_FC_OPMAP(0xdf, 0x01), /* 0x03: MBOX_DUMP_RAM */
7037 ISP_FC_OPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */
7038 ISP_FC_OPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */
7039 ISP_FC_OPMAP_FULL(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */
7040 ISP_FC_OPMAP(0x07, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */
7041 ISP_FC_OPMAP_FULL(0x0, 0x0, 0x0, 0x01, 0x0, 0x3, 0x80, 0x7f), /* 0x08: MBOX_ABOUT_FIRMWARE */
7042 ISP_FC_OPMAP(0xdf, 0x01), /* 0x09: MBOX_LOAD_RISC_RAM_2100 */
7043 ISP_FC_OPMAP(0xdf, 0x01), /* 0x0a: DUMP RAM */
7044 ISP_FC_OPMAP_HALF(0x1, 0xff, 0x0, 0x01), /* 0x0b: MBOX_LOAD_RISC_RAM */
7045 ISP_FC_OPMAP(0x00, 0x00), /* 0x0c: */
7046 ISP_FC_OPMAP_HALF(0x1, 0x0f, 0x0, 0x01), /* 0x0d: MBOX_WRITE_RAM_WORD_EXTENDED */
7047 ISP_FC_OPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */
7048 ISP_FC_OPMAP_HALF(0x1, 0x03, 0x0, 0x0d), /* 0x0f: MBOX_READ_RAM_WORD_EXTENDED */
7049 ISP_FC_OPMAP(0x1f, 0x11), /* 0x10: MBOX_INIT_REQ_QUEUE */
7050 ISP_FC_OPMAP(0x2f, 0x21), /* 0x11: MBOX_INIT_RES_QUEUE */
7051 ISP_FC_OPMAP(0x0f, 0x01), /* 0x12: MBOX_EXECUTE_IOCB */
7052 ISP_FC_OPMAP(0x03, 0x03), /* 0x13: MBOX_WAKE_UP */
7053 ISP_FC_OPMAP_HALF(0x1, 0xff, 0x0, 0x03), /* 0x14: MBOX_STOP_FIRMWARE */
7054 ISP_FC_OPMAP(0x4f, 0x01), /* 0x15: MBOX_ABORT */
7055 ISP_FC_OPMAP(0x07, 0x01), /* 0x16: MBOX_ABORT_DEVICE */
7056 ISP_FC_OPMAP(0x07, 0x01), /* 0x17: MBOX_ABORT_TARGET */
7057 ISP_FC_OPMAP(0x03, 0x03), /* 0x18: MBOX_BUS_RESET */
7058 ISP_FC_OPMAP(0x07, 0x05), /* 0x19: MBOX_STOP_QUEUE */
7059 ISP_FC_OPMAP(0x07, 0x05), /* 0x1a: MBOX_START_QUEUE */
7060 ISP_FC_OPMAP(0x07, 0x05), /* 0x1b: MBOX_SINGLE_STEP_QUEUE */
7061 ISP_FC_OPMAP(0x07, 0x05), /* 0x1c: MBOX_ABORT_QUEUE */
7062 ISP_FC_OPMAP(0x07, 0x03), /* 0x1d: MBOX_GET_DEV_QUEUE_STATUS */
7063 ISP_FC_OPMAP(0x00, 0x00), /* 0x1e: */
7064 ISP_FC_OPMAP(0x01, 0x07), /* 0x1f: MBOX_GET_FIRMWARE_STATUS */
7065 ISP_FC_OPMAP_HALF(0x2, 0x01, 0x7e, 0xcf), /* 0x20: MBOX_GET_LOOP_ID */
7066 ISP_FC_OPMAP(0x00, 0x00), /* 0x21: */
7067 ISP_FC_OPMAP(0x03, 0x4b), /* 0x22: MBOX_GET_TIMEOUT_PARAMS */
7068 ISP_FC_OPMAP(0x00, 0x00), /* 0x23: */
7069 ISP_FC_OPMAP(0x00, 0x00), /* 0x24: */
7070 ISP_FC_OPMAP(0x00, 0x00), /* 0x25: */
7071 ISP_FC_OPMAP(0x00, 0x00), /* 0x26: */
7072 ISP_FC_OPMAP(0x00, 0x00), /* 0x27: */
7073 ISP_FC_OPMAP(0x01, 0x03), /* 0x28: MBOX_GET_FIRMWARE_OPTIONS */
7074 ISP_FC_OPMAP(0x03, 0x07), /* 0x29: MBOX_GET_PORT_QUEUE_PARAMS */
7075 ISP_FC_OPMAP(0x00, 0x00), /* 0x2a: */
7076 ISP_FC_OPMAP(0x00, 0x00), /* 0x2b: */
7077 ISP_FC_OPMAP(0x00, 0x00), /* 0x2c: */
7078 ISP_FC_OPMAP(0x00, 0x00), /* 0x2d: */
7079 ISP_FC_OPMAP(0x00, 0x00), /* 0x2e: */
7080 ISP_FC_OPMAP(0x00, 0x00), /* 0x2f: */
7081 ISP_FC_OPMAP(0x00, 0x00), /* 0x30: */
7082 ISP_FC_OPMAP(0x00, 0x00), /* 0x31: */
7083 ISP_FC_OPMAP(0x4b, 0x4b), /* 0x32: MBOX_SET_TIMEOUT_PARAMS */
7084 ISP_FC_OPMAP(0x00, 0x00), /* 0x33: */
7085 ISP_FC_OPMAP(0x00, 0x00), /* 0x34: */
7086 ISP_FC_OPMAP(0x00, 0x00), /* 0x35: */
7087 ISP_FC_OPMAP(0x00, 0x00), /* 0x36: */
7088 ISP_FC_OPMAP(0x00, 0x00), /* 0x37: */
7089 ISP_FC_OPMAP(0x0f, 0x01), /* 0x38: MBOX_SET_FIRMWARE_OPTIONS */
7090 ISP_FC_OPMAP(0x0f, 0x07), /* 0x39: MBOX_SET_PORT_QUEUE_PARAMS */
7091 ISP_FC_OPMAP(0x00, 0x00), /* 0x3a: */
7092 ISP_FC_OPMAP(0x00, 0x00), /* 0x3b: */
7093 ISP_FC_OPMAP(0x00, 0x00), /* 0x3c: */
7094 ISP_FC_OPMAP(0x00, 0x00), /* 0x3d: */
7095 ISP_FC_OPMAP(0x00, 0x00), /* 0x3e: */
7096 ISP_FC_OPMAP(0x00, 0x00), /* 0x3f: */
7097 ISP_FC_OPMAP(0x03, 0x01), /* 0x40: MBOX_LOOP_PORT_BYPASS */
7098 ISP_FC_OPMAP(0x03, 0x01), /* 0x41: MBOX_LOOP_PORT_ENABLE */
7099 ISP_FC_OPMAP_HALF(0x0, 0x01, 0x3, 0xcf), /* 0x42: MBOX_GET_RESOURCE_COUNT */
7100 ISP_FC_OPMAP(0x01, 0x01), /* 0x43: MBOX_REQUEST_OFFLINE_MODE */
7101 ISP_FC_OPMAP(0x00, 0x00), /* 0x44: */
7102 ISP_FC_OPMAP(0x00, 0x00), /* 0x45: */
7103 ISP_FC_OPMAP(0x00, 0x00), /* 0x46: */
7104 ISP_FC_OPMAP(0xcf, 0x03), /* 0x47: GET PORT_DATABASE ENHANCED */
7105 ISP_FC_OPMAP(0xcf, 0x0f), /* 0x48: MBOX_INIT_FIRMWARE_MULTI_ID */
7106 ISP_FC_OPMAP(0xcd, 0x01), /* 0x49: MBOX_GET_VP_DATABASE */
7107 ISP_FC_OPMAP_HALF(0x2, 0xcd, 0x0, 0x01), /* 0x4a: MBOX_GET_VP_DATABASE_ENTRY */
7108 ISP_FC_OPMAP(0x00, 0x00), /* 0x4b: */
7109 ISP_FC_OPMAP(0x00, 0x00), /* 0x4c: */
7110 ISP_FC_OPMAP(0x00, 0x00), /* 0x4d: */
7111 ISP_FC_OPMAP(0x00, 0x00), /* 0x4e: */
7112 ISP_FC_OPMAP(0x00, 0x00), /* 0x4f: */
7113 ISP_FC_OPMAP(0x00, 0x00), /* 0x50: */
7114 ISP_FC_OPMAP(0x00, 0x00), /* 0x51: */
7115 ISP_FC_OPMAP(0x00, 0x00), /* 0x52: */
7116 ISP_FC_OPMAP(0x00, 0x00), /* 0x53: */
7117 ISP_FC_OPMAP(0xcf, 0x01), /* 0x54: EXECUTE IOCB A64 */
7118 ISP_FC_OPMAP(0x00, 0x00), /* 0x55: */
7119 ISP_FC_OPMAP(0x00, 0x00), /* 0x56: */
7120 ISP_FC_OPMAP(0x00, 0x00), /* 0x57: */
7121 ISP_FC_OPMAP(0x00, 0x00), /* 0x58: */
7122 ISP_FC_OPMAP(0x00, 0x00), /* 0x59: */
7123 ISP_FC_OPMAP(0x00, 0x00), /* 0x5a: */
7124 ISP_FC_OPMAP(0x03, 0x01), /* 0x5b: MBOX_DRIVER_HEARTBEAT */
7125 ISP_FC_OPMAP(0xcf, 0x01), /* 0x5c: MBOX_FW_HEARTBEAT */
7126 ISP_FC_OPMAP(0x07, 0x1f), /* 0x5d: MBOX_GET_SET_DATA_RATE */
7127 ISP_FC_OPMAP(0x00, 0x00), /* 0x5e: */
7128 ISP_FC_OPMAP(0x00, 0x00), /* 0x5f: */
7129 ISP_FC_OPMAP(0xcf, 0x0f), /* 0x60: MBOX_INIT_FIRMWARE */
7130 ISP_FC_OPMAP(0x00, 0x00), /* 0x61: */
7131 ISP_FC_OPMAP(0x01, 0x01), /* 0x62: MBOX_INIT_LIP */
7132 ISP_FC_OPMAP(0xcd, 0x03), /* 0x63: MBOX_GET_FC_AL_POSITION_MAP */
7133 ISP_FC_OPMAP(0xcf, 0x01), /* 0x64: MBOX_GET_PORT_DB */
7134 ISP_FC_OPMAP(0x07, 0x01), /* 0x65: MBOX_CLEAR_ACA */
7135 ISP_FC_OPMAP(0x07, 0x01), /* 0x66: MBOX_TARGET_RESET */
7136 ISP_FC_OPMAP(0x07, 0x01), /* 0x67: MBOX_CLEAR_TASK_SET */
7137 ISP_FC_OPMAP(0x07, 0x01), /* 0x68: MBOX_ABORT_TASK_SET */
7138 ISP_FC_OPMAP(0x01, 0x07), /* 0x69: MBOX_GET_FW_STATE */
7139 ISP_FC_OPMAP_HALF(0x6, 0x03, 0x0, 0xcf), /* 0x6a: MBOX_GET_PORT_NAME */
7140 ISP_FC_OPMAP(0xcf, 0x01), /* 0x6b: MBOX_GET_LINK_STATUS */
7141 ISP_FC_OPMAP(0x0f, 0x01), /* 0x6c: MBOX_INIT_LIP_RESET */
7142 ISP_FC_OPMAP(0x00, 0x00), /* 0x6d: */
7143 ISP_FC_OPMAP(0xcf, 0x03), /* 0x6e: MBOX_SEND_SNS */
7144 ISP_FC_OPMAP(0x0f, 0x07), /* 0x6f: MBOX_FABRIC_LOGIN */
7145 ISP_FC_OPMAP_HALF(0x02, 0x03, 0x00, 0x03), /* 0x70: MBOX_SEND_CHANGE_REQUEST */
7146 ISP_FC_OPMAP(0x03, 0x03), /* 0x71: MBOX_FABRIC_LOGOUT */
7147 ISP_FC_OPMAP(0x0f, 0x0f), /* 0x72: MBOX_INIT_LIP_LOGIN */
7148 ISP_FC_OPMAP(0x00, 0x00), /* 0x73: */
7149 ISP_FC_OPMAP(0x07, 0x01), /* 0x74: LOGIN LOOP PORT */
7150 ISP_FC_OPMAP_HALF(0x03, 0xcf, 0x00, 0x07), /* 0x75: GET PORT/NODE NAME LIST */
7151 ISP_FC_OPMAP(0x4f, 0x01), /* 0x76: SET VENDOR ID */
7152 ISP_FC_OPMAP(0xcd, 0x01), /* 0x77: INITIALIZE IP MAILBOX */
7153 ISP_FC_OPMAP(0x00, 0x00), /* 0x78: */
7154 ISP_FC_OPMAP(0x00, 0x00), /* 0x79: */
7155 ISP_FC_OPMAP(0x00, 0x00), /* 0x7a: */
7156 ISP_FC_OPMAP(0x00, 0x00), /* 0x7b: */
7157 ISP_FC_OPMAP_HALF(0x03, 0x4f, 0x00, 0x07), /* 0x7c: Get ID List */
7158 ISP_FC_OPMAP(0xcf, 0x01), /* 0x7d: SEND LFA */
7159 ISP_FC_OPMAP(0x0f, 0x01) /* 0x7e: LUN RESET */
7161 #define MAX_FC_OPCODE 0x7e
7165 * (1): this sets bits 21..16 in mailbox register #8, which we nominally
7166 * do not access at this time in the core driver. The caller is
7167 * responsible for setting this register first (Gross!). The assumption
7168 * is that we won't overflow.
7171 static const char *fc_mbcmd_names[] = {
7185 "WRITE RAM WORD EXTENDED",
7187 "READ RAM WORD EXTENDED",
7188 "INIT REQUEST QUEUE", /* 10h */
7189 "INIT RESULT QUEUE",
7199 "SINGLE STEP QUEUE",
7201 "GET DEV QUEUE STATUS",
7203 "GET FIRMWARE STATUS",
7204 "GET LOOP ID", /* 20h */
7206 "GET TIMEOUT PARAMS",
7212 "GET FIRMWARE OPTIONS",
7213 "GET PORT QUEUE PARAMS",
7214 "GENERATE SYSTEM ERROR",
7220 "WRITE SFP", /* 30h */
7222 "SET TIMEOUT PARAMS",
7228 "SET FIRMWARE OPTIONS",
7229 "SET PORT QUEUE PARAMS",
7233 "RESTART NIC FIRMWARE",
7236 "LOOP PORT BYPASS", /* 40h */
7238 "GET RESOURCE COUNT",
7239 "REQUEST NON PARTICIPATING MODE",
7240 "DIAGNOSTIC ECHO TEST",
7241 "DIAGNOSTIC LOOPBACK",
7243 "GET PORT DATABASE ENHANCED",
7244 "INIT FIRMWARE MULTI ID",
7246 "GET VP DATABASE ENTRY",
7252 "GET FCF LIST", /* 50h */
7253 "GET DCBX PARAMETERS",
7264 "FIRMWARE HEARTBEAT",
7265 "GET/SET DATA RATE",
7268 "INIT FIRMWARE", /* 60h */
7269 "GET INIT CONTROL BLOCK",
7271 "GET FC-AL POSITION MAP",
7272 "GET PORT DATABASE",
7281 "GET LINK STATS & PRIVATE DATA CNTS",
7284 "SEND CHANGE REQUEST", /* 70h */
7289 "GET PORT/NODE NAME LIST",
7291 "INITIALIZE IP MAILBOX",
7302 isp_mboxcmd_qnw(ispsoftc_t *isp, mbreg_t *mbp, int nodelay)
7304 unsigned int ibits, obits, box, opcode;
7306 opcode = mbp->param[0];
7308 ibits = ISP_FC_IBITS(opcode);
7309 obits = ISP_FC_OBITS(opcode);
7311 ibits = ISP_SCSI_IBITS(opcode);
7312 obits = ISP_SCSI_OBITS(opcode);
7314 ibits |= mbp->ibits;
7315 obits |= mbp->obits;
7316 for (box = 0; box < ISP_NMBOX(isp); box++) {
7317 if (ibits & (1 << box)) {
7318 ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]);
7321 isp->isp_mboxtmp[box] = mbp->param[box] = 0;
7325 isp->isp_lastmbxcmd = opcode;
7326 isp->isp_obits = obits;
7327 isp->isp_mboxbsy = 1;
7330 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_SET_HOST_INT);
7332 ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT);
7335 * Oddly enough, if we're not delaying for an answer,
7336 * delay a bit to give the f/w a chance to pick up the
7345 isp_mboxcmd(ispsoftc_t *isp, mbreg_t *mbp)
7347 const char *cname, *xname, *sname;
7348 char tname[16], mname[16];
7349 unsigned int ibits, obits, box, opcode;
7351 opcode = mbp->param[0];
7353 if (opcode > MAX_FC_OPCODE) {
7354 mbp->param[0] = MBOX_INVALID_COMMAND;
7355 isp_prt(isp, ISP_LOGERR, "Unknown Command 0x%x", opcode);
7358 cname = fc_mbcmd_names[opcode];
7359 ibits = ISP_FC_IBITS(opcode);
7360 obits = ISP_FC_OBITS(opcode);
7362 if (opcode > MAX_SCSI_OPCODE) {
7363 mbp->param[0] = MBOX_INVALID_COMMAND;
7364 isp_prt(isp, ISP_LOGERR, "Unknown Command 0x%x", opcode);
7367 cname = scsi_mbcmd_names[opcode];
7368 ibits = ISP_SCSI_IBITS(opcode);
7369 obits = ISP_SCSI_OBITS(opcode);
7371 if (cname == NULL) {
7373 ISP_SNPRINTF(tname, sizeof tname, "opcode %x", opcode);
7375 isp_prt(isp, ISP_LOGDEBUG3, "Mailbox Command '%s'", cname);
7378 * Pick up any additional bits that the caller might have set.
7380 ibits |= mbp->ibits;
7381 obits |= mbp->obits;
7384 * Mask any bits that the caller wants us to mask
7386 ibits &= mbp->ibitm;
7387 obits &= mbp->obitm;
7390 if (ibits == 0 && obits == 0) {
7391 mbp->param[0] = MBOX_COMMAND_PARAM_ERROR;
7392 isp_prt(isp, ISP_LOGERR, "no parameters for 0x%x", opcode);
7397 * Get exclusive usage of mailbox registers.
7399 if (MBOX_ACQUIRE(isp)) {
7400 mbp->param[0] = MBOX_REGS_BUSY;
7404 for (box = 0; box < ISP_NMBOX(isp); box++) {
7405 if (ibits & (1 << box)) {
7406 isp_prt(isp, ISP_LOGDEBUG3, "IN mbox %d = 0x%04x", box,
7408 ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]);
7410 isp->isp_mboxtmp[box] = mbp->param[box] = 0;
7413 isp->isp_lastmbxcmd = opcode;
7416 * We assume that we can't overwrite a previous command.
7418 isp->isp_obits = obits;
7419 isp->isp_mboxbsy = 1;
7422 * Set Host Interrupt condition so that RISC will pick up mailbox regs.
7425 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_SET_HOST_INT);
7427 ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT);
7431 * While we haven't finished the command, spin our wheels here.
7433 MBOX_WAIT_COMPLETE(isp, mbp);
7436 * Did the command time out?
7438 if (mbp->param[0] == MBOX_TIMEOUT) {
7439 isp->isp_mboxbsy = 0;
7445 * Copy back output registers.
7447 for (box = 0; box < ISP_NMBOX(isp); box++) {
7448 if (obits & (1 << box)) {
7449 mbp->param[box] = isp->isp_mboxtmp[box];
7450 isp_prt(isp, ISP_LOGDEBUG3, "OUT mbox %d = 0x%04x", box,
7455 isp->isp_mboxbsy = 0;
7458 if (mbp->logval == 0 || mbp->param[0] == MBOX_COMMAND_COMPLETE)
7461 if ((mbp->param[0] & 0xbfe0) == 0 &&
7462 (mbp->logval & MBLOGMASK(mbp->param[0])) == 0)
7467 switch (mbp->param[0]) {
7468 case MBOX_INVALID_COMMAND:
7469 xname = "INVALID COMMAND";
7471 case MBOX_HOST_INTERFACE_ERROR:
7472 xname = "HOST INTERFACE ERROR";
7474 case MBOX_TEST_FAILED:
7475 xname = "TEST FAILED";
7477 case MBOX_COMMAND_ERROR:
7478 xname = "COMMAND ERROR";
7479 ISP_SNPRINTF(mname, sizeof(mname), " subcode 0x%x",
7483 case MBOX_COMMAND_PARAM_ERROR:
7484 xname = "COMMAND PARAMETER ERROR";
7486 case MBOX_PORT_ID_USED:
7487 xname = "PORT ID ALREADY IN USE";
7489 case MBOX_LOOP_ID_USED:
7490 xname = "LOOP ID ALREADY IN USE";
7492 case MBOX_ALL_IDS_USED:
7493 xname = "ALL LOOP IDS IN USE";
7495 case MBOX_NOT_LOGGED_IN:
7496 xname = "NOT LOGGED IN";
7498 case MBOX_LINK_DOWN_ERROR:
7499 xname = "LINK DOWN ERROR";
7501 case MBOX_LOOPBACK_ERROR:
7502 xname = "LOOPBACK ERROR";
7504 case MBOX_CHECKSUM_ERROR:
7505 xname = "CHECKSUM ERROR";
7507 case MBOX_INVALID_PRODUCT_KEY:
7508 xname = "INVALID PRODUCT KEY";
7510 case MBOX_REGS_BUSY:
7511 xname = "REGISTERS BUSY";
7517 ISP_SNPRINTF(mname, sizeof mname, "error 0x%x", mbp->param[0]);
7522 isp_prt(isp, ISP_LOGALL, "Mailbox Command '%s' failed (%s%s)",
7523 cname, xname, sname);
7528 isp_fw_state(ispsoftc_t *isp, int chan)
7533 MBSINIT(&mbs, MBOX_GET_FW_STATE, MBLOGALL, 0);
7534 isp_mboxcmd(isp, &mbs);
7535 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
7536 return (mbs.param[1]);
7543 isp_spi_update(ispsoftc_t *isp, int chan)
7551 * There are no 'per-bus' settings for Fibre Channel.
7555 sdp = SDPARAM(isp, chan);
7558 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7559 uint16_t flags, period, offset;
7562 if (sdp->isp_devparam[tgt].dev_enable == 0) {
7563 sdp->isp_devparam[tgt].dev_update = 0;
7564 sdp->isp_devparam[tgt].dev_refresh = 0;
7565 isp_prt(isp, ISP_LOGDEBUG0, "skipping target %d bus %d update", tgt, chan);
7569 * If the goal is to update the status of the device,
7570 * take what's in goal_flags and try and set the device
7571 * toward that. Otherwise, if we're just refreshing the
7572 * current device state, get the current parameters.
7575 MBSINIT(&mbs, 0, MBLOGALL, 0);
7578 * Refresh overrides set
7580 if (sdp->isp_devparam[tgt].dev_refresh) {
7581 mbs.param[0] = MBOX_GET_TARGET_PARAMS;
7583 } else if (sdp->isp_devparam[tgt].dev_update) {
7584 mbs.param[0] = MBOX_SET_TARGET_PARAMS;
7587 * Make sure goal_flags has "Renegotiate on Error"
7588 * on and "Freeze Queue on Error" off.
7590 sdp->isp_devparam[tgt].goal_flags |= DPARM_RENEG;
7591 sdp->isp_devparam[tgt].goal_flags &= ~DPARM_QFRZ;
7592 mbs.param[2] = sdp->isp_devparam[tgt].goal_flags;
7595 * Insist that PARITY must be enabled
7596 * if SYNC or WIDE is enabled.
7598 if ((mbs.param[2] & (DPARM_SYNC|DPARM_WIDE)) != 0) {
7599 mbs.param[2] |= DPARM_PARITY;
7602 if (mbs.param[2] & DPARM_SYNC) {
7604 (sdp->isp_devparam[tgt].goal_offset << 8) |
7605 (sdp->isp_devparam[tgt].goal_period);
7608 * A command completion later that has
7609 * RQSTF_NEGOTIATION set can cause
7610 * the dev_refresh/announce cycle also.
7612 * Note: It is really important to update our current
7613 * flags with at least the state of TAG capabilities-
7614 * otherwise we might try and send a tagged command
7615 * when we have it all turned off. So change it here
7616 * to say that current already matches goal.
7618 sdp->isp_devparam[tgt].actv_flags &= ~DPARM_TQING;
7619 sdp->isp_devparam[tgt].actv_flags |=
7620 (sdp->isp_devparam[tgt].goal_flags & DPARM_TQING);
7621 isp_prt(isp, ISP_LOGDEBUG0, "bus %d set tgt %d flags 0x%x off 0x%x period 0x%x",
7622 chan, tgt, mbs.param[2], mbs.param[3] >> 8, mbs.param[3] & 0xff);
7627 mbs.param[1] = (chan << 15) | (tgt << 8);
7628 isp_mboxcmd(isp, &mbs);
7629 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
7633 sdp->sendmarker = 1;
7634 sdp->isp_devparam[tgt].dev_update = 0;
7635 sdp->isp_devparam[tgt].dev_refresh = 1;
7637 sdp->isp_devparam[tgt].dev_refresh = 0;
7638 flags = mbs.param[2];
7639 period = mbs.param[3] & 0xff;
7640 offset = mbs.param[3] >> 8;
7641 sdp->isp_devparam[tgt].actv_flags = flags;
7642 sdp->isp_devparam[tgt].actv_period = period;
7643 sdp->isp_devparam[tgt].actv_offset = offset;
7644 isp_async(isp, ISPASYNC_NEW_TGT_PARAMS, chan, tgt);
7648 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7649 if (sdp->isp_devparam[tgt].dev_update ||
7650 sdp->isp_devparam[tgt].dev_refresh) {
7658 isp_setdfltsdparm(ispsoftc_t *isp)
7661 sdparam *sdp, *sdp1;
7663 sdp = SDPARAM(isp, 0);
7664 if (IS_DUALBUS(isp))
7670 * Establish some default parameters.
7672 sdp->isp_cmd_dma_burst_enable = 0;
7673 sdp->isp_data_dma_burst_enabl = 1;
7674 sdp->isp_fifo_threshold = 0;
7675 sdp->isp_initiator_id = DEFAULT_IID(isp, 0);
7676 if (isp->isp_type >= ISP_HA_SCSI_1040) {
7677 sdp->isp_async_data_setup = 9;
7679 sdp->isp_async_data_setup = 6;
7681 sdp->isp_selection_timeout = 250;
7682 sdp->isp_max_queue_depth = MAXISPREQUEST(isp);
7683 sdp->isp_tag_aging = 8;
7684 sdp->isp_bus_reset_delay = 5;
7686 * Don't retry selection, busy or queue full automatically- reflect
7689 sdp->isp_retry_count = 0;
7690 sdp->isp_retry_delay = 0;
7692 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7693 sdp->isp_devparam[tgt].exc_throttle = ISP_EXEC_THROTTLE;
7694 sdp->isp_devparam[tgt].dev_enable = 1;
7698 * The trick here is to establish a default for the default (honk!)
7699 * state (goal_flags). Then try and get the current status from
7700 * the card to fill in the current state. We don't, in fact, set
7701 * the default to the SAFE default state- that's not the goal state.
7703 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7705 sdp->isp_devparam[tgt].actv_offset = 0;
7706 sdp->isp_devparam[tgt].actv_period = 0;
7707 sdp->isp_devparam[tgt].actv_flags = 0;
7709 sdp->isp_devparam[tgt].goal_flags =
7710 sdp->isp_devparam[tgt].nvrm_flags = DPARM_DEFAULT;
7713 * We default to Wide/Fast for versions less than a 1040
7714 * (unless it's SBus).
7716 if (IS_ULTRA3(isp)) {
7717 off = ISP_80M_SYNCPARMS >> 8;
7718 per = ISP_80M_SYNCPARMS & 0xff;
7719 } else if (IS_ULTRA2(isp)) {
7720 off = ISP_40M_SYNCPARMS >> 8;
7721 per = ISP_40M_SYNCPARMS & 0xff;
7722 } else if (IS_1240(isp)) {
7723 off = ISP_20M_SYNCPARMS >> 8;
7724 per = ISP_20M_SYNCPARMS & 0xff;
7725 } else if ((isp->isp_bustype == ISP_BT_SBUS &&
7726 isp->isp_type < ISP_HA_SCSI_1020A) ||
7727 (isp->isp_bustype == ISP_BT_PCI &&
7728 isp->isp_type < ISP_HA_SCSI_1040) ||
7729 (isp->isp_clock && isp->isp_clock < 60) ||
7730 (sdp->isp_ultramode == 0)) {
7731 off = ISP_10M_SYNCPARMS >> 8;
7732 per = ISP_10M_SYNCPARMS & 0xff;
7734 off = ISP_20M_SYNCPARMS_1040 >> 8;
7735 per = ISP_20M_SYNCPARMS_1040 & 0xff;
7737 sdp->isp_devparam[tgt].goal_offset =
7738 sdp->isp_devparam[tgt].nvrm_offset = off;
7739 sdp->isp_devparam[tgt].goal_period =
7740 sdp->isp_devparam[tgt].nvrm_period = per;
7745 * If we're a dual bus card, just copy the data over
7749 sdp1->isp_initiator_id = DEFAULT_IID(isp, 1);
7753 * If we've not been told to avoid reading NVRAM, try and read it.
7754 * If we're successful reading it, we can then return because NVRAM
7755 * will tell us what the desired settings are. Otherwise, we establish
7756 * some reasonable 'fake' nvram and goal defaults.
7758 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
7761 if (isp_read_nvram(isp, 0) == 0) {
7762 if (IS_DUALBUS(isp)) {
7763 if (isp_read_nvram(isp, 1) == 0) {
7768 MBSINIT(&mbs, MBOX_GET_ACT_NEG_STATE, MBLOGNONE, 0);
7769 isp_mboxcmd(isp, &mbs);
7770 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
7771 sdp->isp_req_ack_active_neg = 1;
7772 sdp->isp_data_line_active_neg = 1;
7774 sdp1->isp_req_ack_active_neg = 1;
7775 sdp1->isp_data_line_active_neg = 1;
7778 sdp->isp_req_ack_active_neg =
7779 (mbs.param[1] >> 4) & 0x1;
7780 sdp->isp_data_line_active_neg =
7781 (mbs.param[1] >> 5) & 0x1;
7783 sdp1->isp_req_ack_active_neg =
7784 (mbs.param[2] >> 4) & 0x1;
7785 sdp1->isp_data_line_active_neg =
7786 (mbs.param[2] >> 5) & 0x1;
7794 isp_setdfltfcparm(ispsoftc_t *isp, int chan)
7796 fcparam *fcp = FCPARAM(isp, chan);
7799 * Establish some default parameters.
7801 fcp->role = DEFAULT_ROLE(isp, chan);
7802 fcp->isp_maxalloc = ICB_DFLT_ALLOC;
7803 fcp->isp_retry_delay = ICB_DFLT_RDELAY;
7804 fcp->isp_retry_count = ICB_DFLT_RCOUNT;
7805 fcp->isp_loopid = DEFAULT_LOOPID(isp, chan);
7806 fcp->isp_wwnn_nvram = DEFAULT_NODEWWN(isp, chan);
7807 fcp->isp_wwpn_nvram = DEFAULT_PORTWWN(isp, chan);
7808 fcp->isp_fwoptions = 0;
7809 fcp->isp_xfwoptions = 0;
7810 fcp->isp_zfwoptions = 0;
7811 fcp->isp_lasthdl = NIL_HANDLE;
7814 fcp->isp_fwoptions |= ICB2400_OPT1_FAIRNESS;
7815 fcp->isp_fwoptions |= ICB2400_OPT1_HARD_ADDRESS;
7816 if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX) {
7817 fcp->isp_fwoptions |= ICB2400_OPT1_FULL_DUPLEX;
7819 fcp->isp_fwoptions |= ICB2400_OPT1_BOTH_WWNS;
7820 fcp->isp_zfwoptions |= ICB2400_OPT3_RATE_AUTO;
7822 fcp->isp_fwoptions |= ICBOPT_FAIRNESS;
7823 fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
7824 fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS;
7825 if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX) {
7826 fcp->isp_fwoptions |= ICBOPT_FULL_DUPLEX;
7829 * Make sure this is turned off now until we get
7830 * extended options from NVRAM
7832 fcp->isp_fwoptions &= ~ICBOPT_EXTENDED;
7833 fcp->isp_zfwoptions |= ICBZOPT_RATE_AUTO;
7838 * Now try and read NVRAM unless told to not do so.
7839 * This will set fcparam's isp_wwnn_nvram && isp_wwpn_nvram.
7841 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
7844 * Give a couple of tries at reading NVRAM.
7846 for (i = 0; i < 2; i++) {
7847 j = isp_read_nvram(isp, chan);
7853 isp->isp_confopts |= ISP_CFG_NONVRAM;
7857 fcp->isp_wwnn = ACTIVE_NODEWWN(isp, chan);
7858 fcp->isp_wwpn = ACTIVE_PORTWWN(isp, chan);
7859 isp_prt(isp, ISP_LOGCONFIG, "Chan %d 0x%08x%08x/0x%08x%08x Role %s",
7860 chan, (uint32_t) (fcp->isp_wwnn >> 32), (uint32_t) (fcp->isp_wwnn),
7861 (uint32_t) (fcp->isp_wwpn >> 32), (uint32_t) (fcp->isp_wwpn),
7862 isp_class3_roles[fcp->role]);
7866 * Re-initialize the ISP and complete all orphaned commands
7867 * with a 'botched' notice. The reset/init routines should
7868 * not disturb an already active list of commands.
7872 isp_reinit(ispsoftc_t *isp, int do_load_defaults)
7876 if (isp->isp_state == ISP_RUNSTATE)
7878 if (isp->isp_state != ISP_RESETSTATE)
7879 isp_reset(isp, do_load_defaults);
7880 if (isp->isp_state != ISP_RESETSTATE) {
7882 isp_prt(isp, ISP_LOGERR, "%s: cannot reset card", __func__);
7883 ISP_DISABLE_INTS(isp);
7888 if (isp->isp_state > ISP_RESETSTATE &&
7889 isp->isp_state != ISP_RUNSTATE) {
7891 isp_prt(isp, ISP_LOGERR, "%s: cannot init card", __func__);
7892 ISP_DISABLE_INTS(isp);
7895 * If we're in ISP_ROLE_NONE, turn off the lasers.
7897 if (!IS_24XX(isp)) {
7898 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS);
7899 ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET);
7900 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS);
7901 ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL);
7902 ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS);
7908 isp->isp_nactive = 0;
7909 isp_clear_commands(isp);
7911 for (i = 0; i < isp->isp_nchan; i++)
7912 isp_clear_portdb(isp, i);
7921 isp_read_nvram(ispsoftc_t *isp, int bus)
7924 uint8_t csum, minversion;
7926 uint8_t _x[ISP2400_NVRAM_SIZE];
7927 uint16_t _s[ISP2400_NVRAM_SIZE>>1];
7929 #define nvram_data _n._x
7930 #define nvram_words _n._s
7933 return (isp_read_nvram_2400(isp, nvram_data));
7934 } else if (IS_FC(isp)) {
7935 amt = ISP2100_NVRAM_SIZE;
7937 } else if (IS_ULTRA2(isp)) {
7938 amt = ISP1080_NVRAM_SIZE;
7941 amt = ISP_NVRAM_SIZE;
7945 for (i = 0; i < amt>>1; i++) {
7946 isp_rdnvram_word(isp, i, &nvram_words[i]);
7949 if (nvram_data[0] != 'I' || nvram_data[1] != 'S' ||
7950 nvram_data[2] != 'P') {
7951 if (isp->isp_bustype != ISP_BT_SBUS) {
7952 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM header");
7953 isp_prt(isp, ISP_LOGDEBUG0, "%x %x %x", nvram_data[0], nvram_data[1], nvram_data[2]);
7959 for (csum = 0, i = 0; i < amt; i++) {
7960 csum += nvram_data[i];
7963 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM checksum");
7968 if (ISP_NVRAM_VERSION(nvram_data) < minversion) {
7969 isp_prt(isp, ISP_LOGWARN, "version %d NVRAM not understood",
7970 ISP_NVRAM_VERSION(nvram_data));
7975 if (IS_ULTRA3(isp)) {
7976 isp_parse_nvram_12160(isp, bus, nvram_data);
7977 } else if (IS_1080(isp)) {
7978 isp_parse_nvram_1080(isp, bus, nvram_data);
7979 } else if (IS_1280(isp) || IS_1240(isp)) {
7980 isp_parse_nvram_1080(isp, bus, nvram_data);
7981 } else if (IS_SCSI(isp)) {
7982 isp_parse_nvram_1020(isp, nvram_data);
7984 isp_parse_nvram_2100(isp, nvram_data);
7994 isp_read_nvram_2400(ispsoftc_t *isp, uint8_t *nvram_data)
7997 uint32_t addr, csum, lwrds, *dptr;
7999 if (isp->isp_port) {
8000 addr = ISP2400_NVRAM_PORT1_ADDR;
8002 addr = ISP2400_NVRAM_PORT0_ADDR;
8005 dptr = (uint32_t *) nvram_data;
8006 for (lwrds = 0; lwrds < ISP2400_NVRAM_SIZE >> 2; lwrds++) {
8007 isp_rd_2400_nvram(isp, addr++, dptr++);
8009 if (nvram_data[0] != 'I' || nvram_data[1] != 'S' ||
8010 nvram_data[2] != 'P') {
8011 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM header (%x %x %x)",
8012 nvram_data[0], nvram_data[1], nvram_data[2]);
8016 dptr = (uint32_t *) nvram_data;
8017 for (csum = 0, lwrds = 0; lwrds < ISP2400_NVRAM_SIZE >> 2; lwrds++) {
8019 ISP_IOXGET_32(isp, &dptr[lwrds], tmp);
8023 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM checksum");
8027 isp_parse_nvram_2400(isp, nvram_data);
8033 isp_rdnvram_word(ispsoftc_t *isp, int wo, uint16_t *rp)
8036 uint16_t bit, rqst, junk;
8038 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
8040 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
8044 wo &= ((ISP2100_NVRAM_SIZE >> 1) - 1);
8045 if (IS_2312(isp) && isp->isp_port) {
8048 rqst = (ISP_NVRAM_READ << 8) | wo;
8050 } else if (IS_ULTRA2(isp)) {
8051 wo &= ((ISP1080_NVRAM_SIZE >> 1) - 1);
8052 rqst = (ISP_NVRAM_READ << 8) | wo;
8055 wo &= ((ISP_NVRAM_SIZE >> 1) - 1);
8056 rqst = (ISP_NVRAM_READ << 6) | wo;
8061 * Clock the word select request out...
8063 for (i = cbits; i >= 0; i--) {
8064 if ((rqst >> i) & 1) {
8065 bit = BIU_NVRAM_SELECT | BIU_NVRAM_DATAOUT;
8067 bit = BIU_NVRAM_SELECT;
8069 ISP_WRITE(isp, BIU_NVRAM, bit);
8071 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
8072 ISP_WRITE(isp, BIU_NVRAM, bit | BIU_NVRAM_CLOCK);
8074 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
8075 ISP_WRITE(isp, BIU_NVRAM, bit);
8077 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
8080 * Now read the result back in (bits come back in MSB format).
8083 for (i = 0; i < 16; i++) {
8086 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
8088 rv = ISP_READ(isp, BIU_NVRAM);
8089 if (rv & BIU_NVRAM_DATAIN) {
8093 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
8095 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
8097 ISP_WRITE(isp, BIU_NVRAM, 0);
8099 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
8100 ISP_SWIZZLE_NVRAM_WORD(isp, rp);
8104 isp_rd_2400_nvram(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
8107 uint32_t base = 0x7ffe0000;
8111 base = 0x7fe7c000; /* XXX: Observation, may be wrong. */
8112 } else if (IS_25XX(isp)) {
8113 base = 0x7ff00000 | 0x48000;
8115 ISP_WRITE(isp, BIU2400_FLASH_ADDR, base | addr);
8116 for (loops = 0; loops < 5000; loops++) {
8118 tmp = ISP_READ(isp, BIU2400_FLASH_ADDR);
8119 if ((tmp & (1U << 31)) != 0) {
8123 if (tmp & (1U << 31)) {
8124 *rp = ISP_READ(isp, BIU2400_FLASH_DATA);
8125 ISP_SWIZZLE_NVRAM_LONG(isp, rp);
8132 isp_parse_nvram_1020(ispsoftc_t *isp, uint8_t *nvram_data)
8134 sdparam *sdp = SDPARAM(isp, 0);
8137 sdp->isp_fifo_threshold =
8138 ISP_NVRAM_FIFO_THRESHOLD(nvram_data) |
8139 (ISP_NVRAM_FIFO_THRESHOLD_128(nvram_data) << 2);
8141 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0)
8142 sdp->isp_initiator_id = ISP_NVRAM_INITIATOR_ID(nvram_data);
8144 sdp->isp_bus_reset_delay =
8145 ISP_NVRAM_BUS_RESET_DELAY(nvram_data);
8147 sdp->isp_retry_count =
8148 ISP_NVRAM_BUS_RETRY_COUNT(nvram_data);
8150 sdp->isp_retry_delay =
8151 ISP_NVRAM_BUS_RETRY_DELAY(nvram_data);
8153 sdp->isp_async_data_setup =
8154 ISP_NVRAM_ASYNC_DATA_SETUP_TIME(nvram_data);
8156 if (isp->isp_type >= ISP_HA_SCSI_1040) {
8157 if (sdp->isp_async_data_setup < 9) {
8158 sdp->isp_async_data_setup = 9;
8161 if (sdp->isp_async_data_setup != 6) {
8162 sdp->isp_async_data_setup = 6;
8166 sdp->isp_req_ack_active_neg =
8167 ISP_NVRAM_REQ_ACK_ACTIVE_NEGATION(nvram_data);
8169 sdp->isp_data_line_active_neg =
8170 ISP_NVRAM_DATA_LINE_ACTIVE_NEGATION(nvram_data);
8172 sdp->isp_data_dma_burst_enabl =
8173 ISP_NVRAM_DATA_DMA_BURST_ENABLE(nvram_data);
8175 sdp->isp_cmd_dma_burst_enable =
8176 ISP_NVRAM_CMD_DMA_BURST_ENABLE(nvram_data);
8178 sdp->isp_tag_aging =
8179 ISP_NVRAM_TAG_AGE_LIMIT(nvram_data);
8181 sdp->isp_selection_timeout =
8182 ISP_NVRAM_SELECTION_TIMEOUT(nvram_data);
8184 sdp->isp_max_queue_depth =
8185 ISP_NVRAM_MAX_QUEUE_DEPTH(nvram_data);
8187 sdp->isp_fast_mttr = ISP_NVRAM_FAST_MTTR_ENABLE(nvram_data);
8189 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
8190 sdp->isp_devparam[tgt].dev_enable =
8191 ISP_NVRAM_TGT_DEVICE_ENABLE(nvram_data, tgt);
8192 sdp->isp_devparam[tgt].exc_throttle =
8193 ISP_NVRAM_TGT_EXEC_THROTTLE(nvram_data, tgt);
8194 sdp->isp_devparam[tgt].nvrm_offset =
8195 ISP_NVRAM_TGT_SYNC_OFFSET(nvram_data, tgt);
8196 sdp->isp_devparam[tgt].nvrm_period =
8197 ISP_NVRAM_TGT_SYNC_PERIOD(nvram_data, tgt);
8199 * We probably shouldn't lie about this, but it
8200 * it makes it much safer if we limit NVRAM values
8203 if (isp->isp_type < ISP_HA_SCSI_1040) {
8205 * If we're not ultra, we can't possibly
8206 * be a shorter period than this.
8208 if (sdp->isp_devparam[tgt].nvrm_period < 0x19) {
8209 sdp->isp_devparam[tgt].nvrm_period = 0x19;
8211 if (sdp->isp_devparam[tgt].nvrm_offset > 0xc) {
8212 sdp->isp_devparam[tgt].nvrm_offset = 0x0c;
8215 if (sdp->isp_devparam[tgt].nvrm_offset > 0x8) {
8216 sdp->isp_devparam[tgt].nvrm_offset = 0x8;
8219 sdp->isp_devparam[tgt].nvrm_flags = 0;
8220 if (ISP_NVRAM_TGT_RENEG(nvram_data, tgt))
8221 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_RENEG;
8222 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_ARQ;
8223 if (ISP_NVRAM_TGT_TQING(nvram_data, tgt))
8224 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_TQING;
8225 if (ISP_NVRAM_TGT_SYNC(nvram_data, tgt))
8226 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_SYNC;
8227 if (ISP_NVRAM_TGT_WIDE(nvram_data, tgt))
8228 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_WIDE;
8229 if (ISP_NVRAM_TGT_PARITY(nvram_data, tgt))
8230 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_PARITY;
8231 if (ISP_NVRAM_TGT_DISC(nvram_data, tgt))
8232 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_DISC;
8233 sdp->isp_devparam[tgt].actv_flags = 0; /* we don't know */
8234 sdp->isp_devparam[tgt].goal_offset =
8235 sdp->isp_devparam[tgt].nvrm_offset;
8236 sdp->isp_devparam[tgt].goal_period =
8237 sdp->isp_devparam[tgt].nvrm_period;
8238 sdp->isp_devparam[tgt].goal_flags =
8239 sdp->isp_devparam[tgt].nvrm_flags;
8244 isp_parse_nvram_1080(ispsoftc_t *isp, int bus, uint8_t *nvram_data)
8246 sdparam *sdp = SDPARAM(isp, bus);
8249 sdp->isp_fifo_threshold =
8250 ISP1080_NVRAM_FIFO_THRESHOLD(nvram_data);
8252 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0)
8253 sdp->isp_initiator_id = ISP1080_NVRAM_INITIATOR_ID(nvram_data, bus);
8255 sdp->isp_bus_reset_delay =
8256 ISP1080_NVRAM_BUS_RESET_DELAY(nvram_data, bus);
8258 sdp->isp_retry_count =
8259 ISP1080_NVRAM_BUS_RETRY_COUNT(nvram_data, bus);
8261 sdp->isp_retry_delay =
8262 ISP1080_NVRAM_BUS_RETRY_DELAY(nvram_data, bus);
8264 sdp->isp_async_data_setup =
8265 ISP1080_NVRAM_ASYNC_DATA_SETUP_TIME(nvram_data, bus);
8267 sdp->isp_req_ack_active_neg =
8268 ISP1080_NVRAM_REQ_ACK_ACTIVE_NEGATION(nvram_data, bus);
8270 sdp->isp_data_line_active_neg =
8271 ISP1080_NVRAM_DATA_LINE_ACTIVE_NEGATION(nvram_data, bus);
8273 sdp->isp_data_dma_burst_enabl =
8274 ISP1080_NVRAM_BURST_ENABLE(nvram_data);
8276 sdp->isp_cmd_dma_burst_enable =
8277 ISP1080_NVRAM_BURST_ENABLE(nvram_data);
8279 sdp->isp_selection_timeout =
8280 ISP1080_NVRAM_SELECTION_TIMEOUT(nvram_data, bus);
8282 sdp->isp_max_queue_depth =
8283 ISP1080_NVRAM_MAX_QUEUE_DEPTH(nvram_data, bus);
8285 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
8286 sdp->isp_devparam[tgt].dev_enable =
8287 ISP1080_NVRAM_TGT_DEVICE_ENABLE(nvram_data, tgt, bus);
8288 sdp->isp_devparam[tgt].exc_throttle =
8289 ISP1080_NVRAM_TGT_EXEC_THROTTLE(nvram_data, tgt, bus);
8290 sdp->isp_devparam[tgt].nvrm_offset =
8291 ISP1080_NVRAM_TGT_SYNC_OFFSET(nvram_data, tgt, bus);
8292 sdp->isp_devparam[tgt].nvrm_period =
8293 ISP1080_NVRAM_TGT_SYNC_PERIOD(nvram_data, tgt, bus);
8294 sdp->isp_devparam[tgt].nvrm_flags = 0;
8295 if (ISP1080_NVRAM_TGT_RENEG(nvram_data, tgt, bus))
8296 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_RENEG;
8297 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_ARQ;
8298 if (ISP1080_NVRAM_TGT_TQING(nvram_data, tgt, bus))
8299 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_TQING;
8300 if (ISP1080_NVRAM_TGT_SYNC(nvram_data, tgt, bus))
8301 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_SYNC;
8302 if (ISP1080_NVRAM_TGT_WIDE(nvram_data, tgt, bus))
8303 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_WIDE;
8304 if (ISP1080_NVRAM_TGT_PARITY(nvram_data, tgt, bus))
8305 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_PARITY;
8306 if (ISP1080_NVRAM_TGT_DISC(nvram_data, tgt, bus))
8307 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_DISC;
8308 sdp->isp_devparam[tgt].actv_flags = 0;
8309 sdp->isp_devparam[tgt].goal_offset =
8310 sdp->isp_devparam[tgt].nvrm_offset;
8311 sdp->isp_devparam[tgt].goal_period =
8312 sdp->isp_devparam[tgt].nvrm_period;
8313 sdp->isp_devparam[tgt].goal_flags =
8314 sdp->isp_devparam[tgt].nvrm_flags;
8319 isp_parse_nvram_12160(ispsoftc_t *isp, int bus, uint8_t *nvram_data)
8321 sdparam *sdp = SDPARAM(isp, bus);
8324 sdp->isp_fifo_threshold =
8325 ISP12160_NVRAM_FIFO_THRESHOLD(nvram_data);
8327 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0)
8328 sdp->isp_initiator_id = ISP12160_NVRAM_INITIATOR_ID(nvram_data, bus);
8330 sdp->isp_bus_reset_delay =
8331 ISP12160_NVRAM_BUS_RESET_DELAY(nvram_data, bus);
8333 sdp->isp_retry_count =
8334 ISP12160_NVRAM_BUS_RETRY_COUNT(nvram_data, bus);
8336 sdp->isp_retry_delay =
8337 ISP12160_NVRAM_BUS_RETRY_DELAY(nvram_data, bus);
8339 sdp->isp_async_data_setup =
8340 ISP12160_NVRAM_ASYNC_DATA_SETUP_TIME(nvram_data, bus);
8342 sdp->isp_req_ack_active_neg =
8343 ISP12160_NVRAM_REQ_ACK_ACTIVE_NEGATION(nvram_data, bus);
8345 sdp->isp_data_line_active_neg =
8346 ISP12160_NVRAM_DATA_LINE_ACTIVE_NEGATION(nvram_data, bus);
8348 sdp->isp_data_dma_burst_enabl =
8349 ISP12160_NVRAM_BURST_ENABLE(nvram_data);
8351 sdp->isp_cmd_dma_burst_enable =
8352 ISP12160_NVRAM_BURST_ENABLE(nvram_data);
8354 sdp->isp_selection_timeout =
8355 ISP12160_NVRAM_SELECTION_TIMEOUT(nvram_data, bus);
8357 sdp->isp_max_queue_depth =
8358 ISP12160_NVRAM_MAX_QUEUE_DEPTH(nvram_data, bus);
8360 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
8361 sdp->isp_devparam[tgt].dev_enable =
8362 ISP12160_NVRAM_TGT_DEVICE_ENABLE(nvram_data, tgt, bus);
8363 sdp->isp_devparam[tgt].exc_throttle =
8364 ISP12160_NVRAM_TGT_EXEC_THROTTLE(nvram_data, tgt, bus);
8365 sdp->isp_devparam[tgt].nvrm_offset =
8366 ISP12160_NVRAM_TGT_SYNC_OFFSET(nvram_data, tgt, bus);
8367 sdp->isp_devparam[tgt].nvrm_period =
8368 ISP12160_NVRAM_TGT_SYNC_PERIOD(nvram_data, tgt, bus);
8369 sdp->isp_devparam[tgt].nvrm_flags = 0;
8370 if (ISP12160_NVRAM_TGT_RENEG(nvram_data, tgt, bus))
8371 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_RENEG;
8372 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_ARQ;
8373 if (ISP12160_NVRAM_TGT_TQING(nvram_data, tgt, bus))
8374 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_TQING;
8375 if (ISP12160_NVRAM_TGT_SYNC(nvram_data, tgt, bus))
8376 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_SYNC;
8377 if (ISP12160_NVRAM_TGT_WIDE(nvram_data, tgt, bus))
8378 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_WIDE;
8379 if (ISP12160_NVRAM_TGT_PARITY(nvram_data, tgt, bus))
8380 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_PARITY;
8381 if (ISP12160_NVRAM_TGT_DISC(nvram_data, tgt, bus))
8382 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_DISC;
8383 sdp->isp_devparam[tgt].actv_flags = 0;
8384 sdp->isp_devparam[tgt].goal_offset =
8385 sdp->isp_devparam[tgt].nvrm_offset;
8386 sdp->isp_devparam[tgt].goal_period =
8387 sdp->isp_devparam[tgt].nvrm_period;
8388 sdp->isp_devparam[tgt].goal_flags =
8389 sdp->isp_devparam[tgt].nvrm_flags;
8394 isp_parse_nvram_2100(ispsoftc_t *isp, uint8_t *nvram_data)
8396 fcparam *fcp = FCPARAM(isp, 0);
8400 * There is NVRAM storage for both Port and Node entities-
8401 * but the Node entity appears to be unused on all the cards
8402 * I can find. However, we should account for this being set
8403 * at some point in the future.
8405 * Qlogic WWNs have an NAA of 2, but usually nothing shows up in
8406 * bits 48..60. In the case of the 2202, it appears that they do
8407 * use bit 48 to distinguish between the two instances on the card.
8408 * The 2204, which I've never seen, *probably* extends this method.
8410 wwn = ISP2100_NVRAM_PORT_NAME(nvram_data);
8412 isp_prt(isp, ISP_LOGCONFIG, "NVRAM Port WWN 0x%08x%08x",
8413 (uint32_t) (wwn >> 32), (uint32_t) (wwn));
8414 if ((wwn >> 60) == 0) {
8415 wwn |= (((uint64_t) 2)<< 60);
8418 fcp->isp_wwpn_nvram = wwn;
8419 if (IS_2200(isp) || IS_23XX(isp)) {
8420 wwn = ISP2100_NVRAM_NODE_NAME(nvram_data);
8422 isp_prt(isp, ISP_LOGCONFIG, "NVRAM Node WWN 0x%08x%08x",
8423 (uint32_t) (wwn >> 32),
8425 if ((wwn >> 60) == 0) {
8426 wwn |= (((uint64_t) 2)<< 60);
8429 wwn = fcp->isp_wwpn_nvram & ~((uint64_t) 0xfff << 48);
8432 wwn &= ~((uint64_t) 0xfff << 48);
8434 fcp->isp_wwnn_nvram = wwn;
8436 fcp->isp_maxalloc = ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data);
8437 if ((isp->isp_confopts & ISP_CFG_OWNFSZ) == 0) {
8438 DEFAULT_FRAMESIZE(isp) =
8439 ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data);
8441 fcp->isp_retry_delay = ISP2100_NVRAM_RETRY_DELAY(nvram_data);
8442 fcp->isp_retry_count = ISP2100_NVRAM_RETRY_COUNT(nvram_data);
8443 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) {
8444 fcp->isp_loopid = ISP2100_NVRAM_HARDLOOPID(nvram_data);
8446 if ((isp->isp_confopts & ISP_CFG_OWNEXCTHROTTLE) == 0) {
8447 DEFAULT_EXEC_THROTTLE(isp) =
8448 ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data);
8450 fcp->isp_fwoptions = ISP2100_NVRAM_OPTIONS(nvram_data);
8451 isp_prt(isp, ISP_LOGDEBUG0,
8452 "NVRAM 0x%08x%08x 0x%08x%08x maxalloc %d maxframelen %d",
8453 (uint32_t) (fcp->isp_wwnn_nvram >> 32),
8454 (uint32_t) fcp->isp_wwnn_nvram,
8455 (uint32_t) (fcp->isp_wwpn_nvram >> 32),
8456 (uint32_t) fcp->isp_wwpn_nvram,
8457 ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data),
8458 ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data));
8459 isp_prt(isp, ISP_LOGDEBUG0,
8460 "execthrottle %d fwoptions 0x%x hardloop %d tov %d",
8461 ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data),
8462 ISP2100_NVRAM_OPTIONS(nvram_data),
8463 ISP2100_NVRAM_HARDLOOPID(nvram_data),
8464 ISP2100_NVRAM_TOV(nvram_data));
8465 fcp->isp_xfwoptions = ISP2100_XFW_OPTIONS(nvram_data);
8466 fcp->isp_zfwoptions = ISP2100_ZFW_OPTIONS(nvram_data);
8467 isp_prt(isp, ISP_LOGDEBUG0, "xfwoptions 0x%x zfw options 0x%x",
8468 ISP2100_XFW_OPTIONS(nvram_data), ISP2100_ZFW_OPTIONS(nvram_data));
8472 isp_parse_nvram_2400(ispsoftc_t *isp, uint8_t *nvram_data)
8474 fcparam *fcp = FCPARAM(isp, 0);
8477 isp_prt(isp, ISP_LOGDEBUG0,
8478 "NVRAM 0x%08x%08x 0x%08x%08x exchg_cnt %d maxframelen %d",
8479 (uint32_t) (ISP2400_NVRAM_NODE_NAME(nvram_data) >> 32),
8480 (uint32_t) (ISP2400_NVRAM_NODE_NAME(nvram_data)),
8481 (uint32_t) (ISP2400_NVRAM_PORT_NAME(nvram_data) >> 32),
8482 (uint32_t) (ISP2400_NVRAM_PORT_NAME(nvram_data)),
8483 ISP2400_NVRAM_EXCHANGE_COUNT(nvram_data),
8484 ISP2400_NVRAM_MAXFRAMELENGTH(nvram_data));
8485 isp_prt(isp, ISP_LOGDEBUG0,
8486 "NVRAM execthr %d loopid %d fwopt1 0x%x fwopt2 0x%x fwopt3 0x%x",
8487 ISP2400_NVRAM_EXECUTION_THROTTLE(nvram_data),
8488 ISP2400_NVRAM_HARDLOOPID(nvram_data),
8489 ISP2400_NVRAM_FIRMWARE_OPTIONS1(nvram_data),
8490 ISP2400_NVRAM_FIRMWARE_OPTIONS2(nvram_data),
8491 ISP2400_NVRAM_FIRMWARE_OPTIONS3(nvram_data));
8493 wwn = ISP2400_NVRAM_PORT_NAME(nvram_data);
8494 fcp->isp_wwpn_nvram = wwn;
8496 wwn = ISP2400_NVRAM_NODE_NAME(nvram_data);
8498 if ((wwn >> 60) != 2 && (wwn >> 60) != 5) {
8502 if (wwn == 0 && (fcp->isp_wwpn_nvram >> 60) == 2) {
8503 wwn = fcp->isp_wwpn_nvram;
8504 wwn &= ~((uint64_t) 0xfff << 48);
8506 fcp->isp_wwnn_nvram = wwn;
8508 if (ISP2400_NVRAM_EXCHANGE_COUNT(nvram_data)) {
8509 fcp->isp_maxalloc = ISP2400_NVRAM_EXCHANGE_COUNT(nvram_data);
8511 if ((isp->isp_confopts & ISP_CFG_OWNFSZ) == 0) {
8512 DEFAULT_FRAMESIZE(isp) =
8513 ISP2400_NVRAM_MAXFRAMELENGTH(nvram_data);
8515 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) {
8516 fcp->isp_loopid = ISP2400_NVRAM_HARDLOOPID(nvram_data);
8518 if ((isp->isp_confopts & ISP_CFG_OWNEXCTHROTTLE) == 0) {
8519 DEFAULT_EXEC_THROTTLE(isp) =
8520 ISP2400_NVRAM_EXECUTION_THROTTLE(nvram_data);
8522 fcp->isp_fwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS1(nvram_data);
8523 fcp->isp_xfwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS2(nvram_data);
8524 fcp->isp_zfwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS3(nvram_data);