Lines Matching refs:isp

55 #include <dev/isp/isp_freebsd.h>
147 isp_change_fw_state(ispsoftc_t *isp, int chan, int state)
149 fcparam *fcp = FCPARAM(isp, chan);
153 isp_prt(isp, ISP_LOGCONFIG|ISP_LOG_SANCFG,
160 isp_get_flash_addrs(ispsoftc_t *isp)
162 fcparam *fcp = FCPARAM(isp, 0);
165 if (IS_28XX(isp)) {
168 } else if (IS_26XX(isp)) { /* 26xx and 27xx are identical */
171 } else if (IS_25XX(isp)) {
179 r = isp_read_flthdr_2xxx(isp);
181 isp_read_flt_2xxx(isp);
183 if (IS_28XX(isp)) {
185 } else if (IS_26XX(isp)) {
188 } else if (IS_25XX(isp)) {
194 fcp->flt_region_nvram += ISP2400_NVRAM_PORT_ADDR(isp->isp_port);
207 isp_reset(ispsoftc_t *isp, int do_load_defaults)
217 isp->isp_state = ISP_NILSTATE;
218 ISP_DISABLE_INTS(isp);
224 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_HOST_INT);
225 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT);
226 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_PAUSE);
228 switch (isp->isp_type) {
251 ISP_WRITE(isp, BIU2400_CSR, BIU2400_DMA_STOP|(3 << 4));
254 val = ISP_READ(isp, BIU2400_CSR);
260 isp_prt(isp, ISP_LOGERR, "DMA Failed to Stop on Reset");
265 ISP_WRITE(isp, BIU2400_CSR, BIU2400_SOFT_RESET|BIU2400_DMA_STOP|(3 << 4));
269 val = ISP_READ(isp, OUTMAILBOX0);
277 isp_prt(isp, ISP_LOGERR, "The ROM code is busy after 50ms.");
280 isp_prt(isp, ISP_LOGERR, "Board configuration error.");
283 isp_prt(isp, ISP_LOGERR, "Unknown RISC Status Code 0x%x.", val);
290 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RESET);
291 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RELEASE);
292 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RESET);
299 val = ISP_READ(isp, OUTMAILBOX0);
307 isp_prt(isp, ISP_LOGERR, "The ROM code is busy after 50ms.");
310 isp_prt(isp, ISP_LOGERR, "Board configuration error.");
313 isp_prt(isp, ISP_LOGERR, "Unknown RISC Status Code 0x%x.", val);
317 isp->isp_reqidx = isp->isp_reqodx = 0;
318 isp->isp_resodx = 0;
319 isp->isp_atioodx = 0;
320 ISP_WRITE(isp, BIU2400_REQINP, 0);
321 ISP_WRITE(isp, BIU2400_REQOUTP, 0);
322 ISP_WRITE(isp, BIU2400_RSPINP, 0);
323 ISP_WRITE(isp, BIU2400_RSPOUTP, 0);
324 if (!IS_26XX(isp)) {
325 ISP_WRITE(isp, BIU2400_PRI_REQINP, 0);
326 ISP_WRITE(isp, BIU2400_PRI_REQOUTP, 0);
328 ISP_WRITE(isp, BIU2400_ATIO_RSPINP, 0);
329 ISP_WRITE(isp, BIU2400_ATIO_RSPOUTP, 0);
342 isp_mboxcmd(isp, &mbs);
344 isp_prt(isp, ISP_LOGERR, "NOP command failed (%x)", mbs.param[0]);
362 int nmbox = ISP_NMBOX(isp);
367 isp_mboxcmd(isp, &mbs);
373 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]);
385 if (ISP_MBOXDMASETUP(isp) != 0) {
386 isp_prt(isp, ISP_LOGERR, "Cannot setup DMA");
414 fcparam *fcp = FCPARAM(isp, 0);
417 isp_get_flash_addrs(isp);
429 if (!(isp->isp_confopts & ISP_CFG_NORELOAD)) {
431 snprintf(fwname, sizeof(fwname), "isp_%04x", isp->isp_did);
432 isp->isp_osinfo.ispfw = firmware_get(fwname);
433 if (isp->isp_osinfo.ispfw != NULL) {
434 isp->isp_mdvec->dv_ispfw = isp->isp_osinfo.ispfw->data;
435 const uint32_t *ispfwptr = isp->isp_mdvec->dv_ispfw;
438 isp_prt(isp, ISP_LOGCONFIG,
444 isp_prt(isp, ISP_LOGCONFIG,
449 isp_prt(isp, ISP_LOGDEBUG0,
457 if (IS_27XX(isp)) {
458 switch (isp_load_risc(isp, 0)) {
475 if (isp->isp_osinfo.ispfw != NULL)
481 if (isp->isp_osinfo.ispfw != NULL)
487 const uint32_t *ptr = isp->isp_mdvec->dv_ispfw;
493 isp_prt(isp, ISP_LOGDEBUG2,
504 nw = min(wl, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)) / 4);
505 cp = isp->isp_rquest;
507 ISP_IOXPUT_32(isp, ptr[wi + i], &cp[i]);
508 if (isp_load_ram(isp, cp, la, nw) != 0) {
509 isp_prt(isp, ISP_LOGERR,
525 if (isp->isp_osinfo.ispfw != NULL)
526 firmware_put(isp->isp_osinfo.ispfw, FIRMWARE_UNLOAD);
528 isp_prt(isp, ISP_LOGCONFIG,
537 isp_mboxcmd(isp, &mbs);
539 isp_prt(isp, ISP_LOGERR, "%s: 0x%x", dcrc,
543 } else if (IS_26XX(isp)) {
544 isp_prt(isp, ISP_LOGCONFIG,
547 isp_mboxcmd(isp, &mbs);
549 isp_prt(isp, ISP_LOGERR, "Flash F/W load failed");
563 if (!IS_26XX(isp))
566 if (IS_27XX(isp))
569 isp_mboxcmd(isp, &mbs);
573 isp_prt(isp, ISP_LOGDEBUG0, "Firmware ability mask: 0x%x",
575 if (IS_26XX(isp)) {
577 isp_prt(isp, ISP_LOGINFO, "Maximum supported speed: %s",
582 if (IS_28XX(isp) && (mbs.param[5] & 0x400)) {
583 isp_prt(isp, ISP_LOGINFO,
592 isp_mboxcmd(isp, &mbs);
597 isp->isp_fwrev[0] = mbs.param[1];
598 isp->isp_fwrev[1] = mbs.param[2];
599 isp->isp_fwrev[2] = mbs.param[3];
600 isp->isp_fwattr = mbs.param[6];
601 isp->isp_fwattr_h = mbs.param[15];
602 if (isp->isp_fwattr & ISP_FW_ATTR_EXTNDED) {
603 isp->isp_fwattr_ext[0] = mbs.param[16];
604 isp->isp_fwattr_ext[1] = mbs.param[17];
607 isp_prt(isp, ISP_LOGCONFIG, "Board Type %s, Chip Revision 0x%x, %s F/W Revision %d.%d.%d",
608 btype, isp->isp_revision, dodnld ? "loaded" : "resident",
609 isp->isp_fwrev[0], isp->isp_fwrev[1], isp->isp_fwrev[2]);
611 "%u.%u.%u", isp->isp_fwrev[0], isp->isp_fwrev[1],
612 isp->isp_fwrev[2]);
613 if (!dodnld && !IS_26XX(isp))
617 fwt = isp->isp_fwattr;
618 buf = FCPARAM(isp, 0)->isp_scanscratch;
673 isp_prt(isp, ISP_LOGCONFIG, "%s", buf);
675 fwt = isp->isp_fwattr_h;
676 buf = FCPARAM(isp, 0)->isp_scanscratch;
718 isp_prt(isp, ISP_LOGCONFIG, "%s", buf);
720 fwt = isp->isp_fwattr_ext[0];
721 buf = FCPARAM(isp, 0)->isp_scanscratch;
747 isp_prt(isp, ISP_LOGCONFIG, "%s", buf);
749 fwt = isp->isp_fwattr_ext[1];
750 buf = FCPARAM(isp, 0)->isp_scanscratch;
756 isp_prt(isp, ISP_LOGCONFIG, "%s", buf);
764 isp_mboxcmd(isp, &mbs);
767 isp->isp_maxcmds = MIN(mbs.param[3], ISP_HANDLE_MAX - ISP_HANDLE_RESERVE);
768 isp_prt(isp, ISP_LOGCONFIG, "%d max I/O command limit set", isp->isp_maxcmds);
775 if (isp->isp_nchan > 1) {
776 if (!ISP_CAP_MULTI_ID(isp)) {
777 isp_prt(isp, ISP_LOGWARN, "non-MULTIID f/w loaded, "
778 "only can enable 1 of %d channels", isp->isp_nchan);
779 isp->isp_nchan = 1;
780 } else if (!ISP_CAP_VP0(isp)) {
781 isp_prt(isp, ISP_LOGWARN, "We can not use MULTIID "
783 isp->isp_nchan = 1;
790 if (ISP_MBOXDMASETUP(isp) != 0) {
791 isp_prt(isp, ISP_LOGERR, "Cannot setup DMA");
798 if (ISP_IRQSETUP(isp) != 0) {
799 isp_prt(isp, ISP_LOGERR, "Cannot setup IRQ");
802 ISP_ENABLE_INTS(isp);
804 for (i = 0; i < isp->isp_nchan; i++)
805 isp_change_fw_state(isp, i, FW_CONFIG_WAIT);
807 isp->isp_state = ISP_RESETSTATE;
815 for (i = 0; i < isp->isp_nchan; i++)
816 isp_setdfltfcparm(isp, i);
824 isp_stop(ispsoftc_t *isp)
828 isp->isp_state = ISP_NILSTATE;
838 isp_mboxcmd(isp, &mbs);
846 isp_shutdown(ispsoftc_t *isp)
849 if (isp->isp_state >= ISP_RESETSTATE)
850 isp_stop(isp);
851 ISP_DISABLE_INTS(isp);
852 ISP_WRITE(isp, BIU2400_ICR, 0);
853 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_PAUSE);
862 isp_init(ispsoftc_t *isp)
873 for (chan = 0; chan < isp->isp_nchan; chan++) {
874 fcp = FCPARAM(isp, chan);
879 if (chan == isp->isp_nchan) {
880 isp_prt(isp, ISP_LOG_WARN1, "all %d channels with role 'none'", chan);
884 isp->isp_state = ISP_INITSTATE;
889 fcp = FCPARAM(isp, 0);
896 isp_mboxcmd(isp, &mbs);
905 if (isp->isp_nchan > 1 && ISP_CAP_VP0(isp)) {
920 icbp->icb_maxfrmlen = DEFAULT_FRAMESIZE(isp);
923 if (IS_28XX(isp))
926 isp_prt(isp, ISP_LOGERR,
928 DEFAULT_FRAMESIZE(isp), icbp->icb_maxfrmlen);
931 if (!IS_26XX(isp))
940 icbp->icb_xchgcnt = MIN(isp->isp_maxcmds / 2, ATPDPSIZE);
942 icbp->icb_xchgcnt = isp->isp_maxcmds;
946 ownloopid = (isp->isp_confopts & ISP_CFG_OWNLOOPID) != 0;
956 if (isp->isp_confopts & ISP_CFG_NOFCTAPE) {
959 if (isp->isp_confopts & ISP_CFG_FCTAPE) {
963 for (chan = 0; chan < isp->isp_nchan; chan++) {
965 FCPARAM(isp, chan)->fctape_enabled = 1;
967 FCPARAM(isp, chan)->fctape_enabled = 0;
970 switch (isp->isp_confopts & ISP_CFG_PORT_PREF) {
1007 isp_prt(isp, ISP_LOGWARN, "bad value %x in fwopt2 timer field", icbp->icb_fwoptions2 & ICB2400_OPT2_TIMER_MASK);
1012 if (IS_26XX(isp)) {
1021 if (isp->isp_confopts & ISP_CFG_1GB) {
1024 } else if (isp->isp_confopts & ISP_CFG_2GB) {
1027 } else if (isp->isp_confopts & ISP_CFG_4GB) {
1030 } else if (isp->isp_confopts & ISP_CFG_8GB) {
1033 } else if (isp->isp_confopts & ISP_CFG_16GB) {
1036 } else if (isp->isp_confopts & ISP_CFG_32GB) {
1039 } else if (isp->isp_confopts & ISP_CFG_64GB) {
1052 if (isp->isp_type <= ISP_HA_FC_2500)
1056 if (isp->isp_type <= ISP_HA_FC_2400)
1074 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)),
1079 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)));
1081 isp_prt(isp, ISP_LOGERR, "No valid WWNs to use");
1084 icbp->icb_rspnsin = isp->isp_resodx;
1085 icbp->icb_rqstout = isp->isp_reqidx;
1088 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp);
1090 isp_prt(isp, ISP_LOGERR, "bad request queue length %d", icbp->icb_rqstqlen);
1093 icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp);
1095 isp_prt(isp, ISP_LOGERR, "bad result queue length %d",
1099 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_rquest_dma);
1100 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_rquest_dma);
1101 icbp->icb_rqstaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_rquest_dma);
1102 icbp->icb_rqstaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_rquest_dma);
1104 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_result_dma);
1105 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_result_dma);
1106 icbp->icb_respaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_result_dma);
1107 icbp->icb_respaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_result_dma);
1111 icbp->icb_atio_in = isp->isp_atioodx;
1112 icbp->icb_atioqlen = ATIO_QUEUE_LEN(isp);
1114 isp_prt(isp, ISP_LOGERR, "bad ATIO queue length %d", icbp->icb_atioqlen);
1117 icbp->icb_atioqaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_atioq_dma);
1118 icbp->icb_atioqaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_atioq_dma);
1119 icbp->icb_atioqaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_atioq_dma);
1120 icbp->icb_atioqaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_atioq_dma);
1121 isp_prt(isp, ISP_LOGDEBUG0, "isp_init: atioq %04x%04x%04x%04x", DMA_WD3(isp->isp_atioq_dma), DMA_WD2(isp->isp_atioq_dma),
1122 DMA_WD1(isp->isp_atioq_dma), DMA_WD0(isp->isp_atioq_dma));
1125 if (ISP_CAP_MSIX(isp) && isp->isp_nirq >= 2) {
1127 if (IS_26XX(isp) && isp->isp_nirq >= 3)
1131 isp_prt(isp, ISP_LOGDEBUG0, "isp_init: fwopt1 0x%x fwopt2 0x%x fwopt3 0x%x", icbp->icb_fwoptions1, icbp->icb_fwoptions2, icbp->icb_fwoptions3);
1133 isp_prt(isp, ISP_LOGDEBUG0, "isp_init: rqst %04x%04x%04x%04x rsp %04x%04x%04x%04x", DMA_WD3(isp->isp_rquest_dma), DMA_WD2(isp->isp_rquest_dma),
1134 DMA_WD1(isp->isp_rquest_dma), DMA_WD0(isp->isp_rquest_dma), DMA_WD3(isp->isp_result_dma), DMA_WD2(isp->isp_result_dma),
1135 DMA_WD1(isp->isp_result_dma), DMA_WD0(isp->isp_result_dma));
1137 if (FC_SCRATCH_ACQUIRE(isp, 0)) {
1138 isp_prt(isp, ISP_LOGERR, sacq);
1142 isp_put_icb_2400(isp, icbp, fcp->isp_scratch);
1143 if (isp->isp_dblev & ISP_LOGDEBUG1) {
1144 isp_print_bytes(isp, "isp_init",
1151 if (isp->isp_nchan > 1) {
1158 if (ISP_CAP_VP0(isp)) {
1160 vpinfo.vp_count = isp->isp_nchan;
1163 vpinfo.vp_count = isp->isp_nchan - 1;
1169 isp_put_icb_2400_vpinfo(isp, &vpinfo, vdst);
1171 for (; chan < isp->isp_nchan; chan++) {
1175 fcp2 = FCPARAM(isp, chan);
1185 if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
1193 if (ISP_CAP_VP0(isp))
1198 isp_put_vp_port_info(isp, &pi, pdst);
1201 if (isp->isp_dblev & ISP_LOGDEBUG1) {
1202 isp_print_bytes(isp, "isp_init",
1212 if (isp->isp_nchan > 1) {
1222 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));
1223 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (*icbp), 0);
1224 isp_mboxcmd(isp, &mbs);
1225 FC_SCRATCH_RELEASE(isp, 0);
1234 isp->isp_state = ISP_RUNSTATE;
1238 isp_fc_enable_vp(ispsoftc_t *isp, int chan)
1240 fcparam *fcp = FCPARAM(isp, chan);
1259 if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
1265 retval = isp_exec_entry_queue(isp, &vp, &vp, 5);
1267 isp_prt(isp, ISP_LOGERR, "%s: VP_MODIFY of chan %d error %d",
1273 isp_prt(isp, ISP_LOGERR,
1282 isp_fc_disable_vp(ispsoftc_t *isp, int chan)
1291 if (ISP_CAP_VP0(isp)) {
1301 retval = isp_exec_entry_queue(isp, &vp, &vp, 5);
1303 isp_prt(isp, ISP_LOGERR, "%s: VP_CTRL of chan %d error %d",
1309 isp_prt(isp, ISP_LOGERR,
1319 isp_fc_change_role(ispsoftc_t *isp, int chan, int new_role)
1321 fcparam *fcp = FCPARAM(isp, chan);
1324 if (chan >= isp->isp_nchan) {
1325 isp_prt(isp, ISP_LOGWARN, "%s: bad channel %d", __func__, chan);
1330 for (was = 0, i = 0; i < isp->isp_nchan; i++) {
1331 if (FCPARAM(isp, i)->role != ISP_ROLE_NONE)
1336 return (isp_reinit(isp, 0));
1339 res = isp_fc_disable_vp(isp, chan);
1340 isp_clear_portdb(isp, chan);
1344 res = isp_fc_enable_vp(isp, chan);
1349 isp_clear_portdb(ispsoftc_t *isp, int chan)
1351 fcparam *fcp = FCPARAM(isp, chan);
1362 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp);
1377 isp_mark_portdb(ispsoftc_t *isp, int chan)
1379 fcparam *fcp = FCPARAM(isp, chan);
1399 isp_plogx(ispsoftc_t *isp, int chan, uint16_t handle, uint32_t portid, int flags)
1407 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d PLOGX %s PortID 0x%06x nphdl 0x%x",
1420 retval = isp_exec_entry_queue(isp, &pl, &pl, 3 * ICB_LOGIN_TOV);
1422 isp_prt(isp, ISP_LOGERR, "%s: PLOGX of chan %d error %d",
1430 isp_prt(isp, ISP_LOGWARN,
1503 isp_prt(isp, lev, "Chan %d PLOGX PortID 0x%06x to N-Port handle 0x%x: %s",
1510 isp_getpdb(ispsoftc_t *isp, int chan, uint16_t id, isp_pdb_t *pdb)
1521 mbs.param[2] = DMA_WD1(isp->isp_iocb_dma);
1522 mbs.param[3] = DMA_WD0(isp->isp_iocb_dma);
1523 mbs.param[6] = DMA_WD3(isp->isp_iocb_dma);
1524 mbs.param[7] = DMA_WD2(isp->isp_iocb_dma);
1526 MEMORYBARRIER(isp, SYNC_IFORDEV, 0, sizeof(un), chan);
1528 isp_mboxcmd(isp, &mbs);
1532 MEMORYBARRIER(isp, SYNC_IFORCPU, 0, sizeof(un), chan);
1533 isp_get_pdb_24xx(isp, isp->isp_iocb, &un.bill);
1540 isp_prt(isp, ISP_LOGDEBUG0,
1561 isp_gethandles(ispsoftc_t *isp, int chan, uint16_t *handles, int *num, int loop)
1563 fcparam *fcp = FCPARAM(isp, chan);
1576 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
1577 isp_prt(isp, ISP_LOGERR, sacq);
1580 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, ISP_FC_SCRLEN, chan);
1581 isp_mboxcmd(isp, &mbs);
1583 FC_SCRATCH_RELEASE(isp, chan);
1586 MEMORYBARRIER(isp, SYNC_SFORCPU, 0, ISP_FC_SCRLEN, chan);
1589 isp_get_pnhle_24xx(isp, &elp4[i], &el4);
1596 FC_SCRATCH_RELEASE(isp, chan);
1601 isp_dump_chip_portdb(ispsoftc_t *isp, int chan)
1606 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGINFO, "Chan %d chip port dump", chan);
1608 if (isp_getpdb(isp, chan, nphdl, &pdb)) {
1611 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGINFO, "Chan %d Handle 0x%04x "
1620 isp_get_wwn(ispsoftc_t *isp, int chan, int nphdl, int nodename)
1631 isp_mboxcmd(isp, &mbs);
1651 isp_fclink_test(ispsoftc_t *isp, int chan, int usdelay)
1659 fcp = FCPARAM(isp, chan);
1666 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC link test", chan);
1673 isp_change_fw_state(isp, chan, isp_fw_state(isp, chan));
1682 ISP_SLEEP(isp, 1000);
1685 isp_prt(isp, ISP_LOG_SANCFG,
1696 isp_mboxcmd(isp, &mbs);
1726 r = isp_getpdb(isp, chan, NPH_FL_ID, &pdb);
1728 isp_prt(isp, ISP_LOGWARN,
1736 r = isp_register_fc4_type(isp, chan);
1741 r = isp_register_fc4_features_24xx(isp, chan);
1746 r = isp_register_port_name_24xx(isp, chan);
1751 isp_register_node_name_24xx(isp, chan);
1762 isp_mboxcmd(isp, &mbs);
1784 isp_prt(isp, ISP_LOG_SANCFG,
1789 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGCONFIG,
1792 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGCONFIG,
1796 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC link test done", chan);
1812 isp_pdb_sync(ispsoftc_t *isp, int chan)
1814 fcparam *fcp = FCPARAM(isp, chan);
1823 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC PDB sync", chan);
1837 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp);
1839 (void) isp_plogx(isp, chan, lp->handle,
1852 isp_async(isp, ISPASYNC_DEV_ARRIVED, chan, lp);
1856 isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp);
1862 isp_async(isp, ISPASYNC_DEV_STAYED, chan, lp);
1867 isp_prt(isp, ISP_LOGWARN,
1870 isp_dump_portdb(isp, chan);
1875 isp_prt(isp, ISP_LOG_SANCFG,
1881 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC PDB sync done", chan);
1886 isp_pdb_add_update(ispsoftc_t *isp, int chan, isp_pdb_t *pdb)
1895 if (isp_find_pdb_by_wwpn(isp, chan, wwpn, &lp)) {
1897 isp_prt(isp, ISP_LOGERR,
1900 FC_PORTDB_TGT(isp, chan, lp), lp->state);
1901 isp_dump_portdb(isp, chan);
1915 isp_prt(isp, ISP_LOG_SANCFG,
1927 isp_prt(isp, ISP_LOG_SANCFG,
1934 if (!isp_find_pdb_empty(isp, chan, &lp)) {
1935 isp_prt(isp, ISP_LOGERR, "Chan %d out of portdb entries", chan);
1948 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Port 0x%06x@0x%04x is new",
1956 isp_scan_loop(ispsoftc_t *isp, int chan)
1958 fcparam *fcp = FCPARAM(isp, chan);
1969 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC loop scan", chan);
1972 isp_prt(isp, ISP_LOG_SANCFG,
1980 r = isp_gethandles(isp, chan, handles, &lim, 1);
1982 isp_prt(isp, ISP_LOG_SANCFG,
1984 isp_prt(isp, ISP_LOG_SANCFG,
1989 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Got %d handles",
1995 isp_mark_portdb(isp, chan);
2008 r = isp_getpdb(isp, chan, handle, &pdb);
2011 isp_prt(isp, ISP_LOG_SANCFG,
2016 isp_prt(isp, ISP_LOGDEBUG1,
2022 isp_pdb_add_update(isp, chan, &pdb);
2027 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC loop scan done", chan);
2032 isp_ct_passthru(ispsoftc_t *isp, int chan, uint32_t cmd_bcnt, uint32_t rsp_bcnt)
2034 fcparam *fcp = FCPARAM(isp, chan);
2038 if (isp->isp_dblev & ISP_LOGDEBUG1)
2039 isp_print_bytes(isp, "CT request", cmd_bcnt, fcp->isp_scratch);
2049 pt.ctp_vpidx = ISP_GET_VPIDX(isp, chan);
2061 retval = isp_exec_entry_queue(isp, &pt, &pt, 2 * pt.ctp_time);
2063 isp_prt(isp, ISP_LOGERR, "%s: CTP of chan %d error %d",
2069 isp_prt(isp, ISP_LOGWARN,
2075 if (isp->isp_dblev & ISP_LOGDEBUG1)
2076 isp_print_bytes(isp, "CT response", rsp_bcnt, fcp->isp_scratch);
2093 isp_gid_pt(ispsoftc_t *isp, int chan)
2095 fcparam *fcp = FCPARAM(isp, chan);
2099 isp_prt(isp, ISP_LOGDEBUG0, "Chan %d requesting GID_PT", chan);
2100 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
2101 isp_prt(isp, ISP_LOGERR, sacq);
2112 isp_put_ct_hdr(isp, &ct, (ct_hdr_t *)scp);
2118 if (isp_ct_passthru(isp, chan, sizeof(ct) + sizeof(uint32_t), GIDLEN)) {
2119 FC_SCRATCH_RELEASE(isp, chan);
2123 isp_get_gid_xx_response(isp, (sns_gid_xx_rsp_t *)scp,
2125 FC_SCRATCH_RELEASE(isp, chan);
2130 isp_gff_id(ispsoftc_t *isp, int chan, uint32_t portid)
2132 fcparam *fcp = FCPARAM(isp, chan);
2142 isp_prt(isp, ISP_LOGDEBUG0, "Chan %d requesting GFF_ID", chan);
2143 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
2144 isp_prt(isp, ISP_LOGERR, sacq);
2155 isp_put_ct_hdr(isp, &ct, (ct_hdr_t *)scp);
2157 ISP_IOZPUT_32(isp, portid, rp);
2159 if (isp_ct_passthru(isp, chan, sizeof(ct) + sizeof(uint32_t),
2161 FC_SCRATCH_RELEASE(isp, chan);
2165 isp_get_gff_id_response(isp, (sns_gff_id_rsp_t *)scp, &rsp);
2177 if (((ISP_SWAP32(isp, rsp.snscb_fc4_features[FC4_SCSI / 8]) >>
2181 FC_SCRATCH_RELEASE(isp, chan);
2182 isp_prt(isp, ISP_LOGDEBUG0, "Chan %d GFF_ID result is %d", chan, res);
2187 isp_gft_id(ispsoftc_t *isp, int chan, uint32_t portid)
2189 fcparam *fcp = FCPARAM(isp, chan);
2199 isp_prt(isp, ISP_LOGDEBUG0, "Chan %d requesting GFT_ID", chan);
2200 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
2201 isp_prt(isp, ISP_LOGERR, sacq);
2212 isp_put_ct_hdr(isp, &ct, (ct_hdr_t *)scp);
2214 ISP_IOZPUT_32(isp, portid, rp);
2216 if (isp_ct_passthru(isp, chan, sizeof(ct) + sizeof(uint32_t),
2218 FC_SCRATCH_RELEASE(isp, chan);
2222 isp_get_gft_id_response(isp, (sns_gft_id_rsp_t *)scp, &rsp);
2234 FC_SCRATCH_RELEASE(isp, chan);
2235 isp_prt(isp, ISP_LOGDEBUG0, "Chan %d GFT_ID result is %d", chan, res);
2240 isp_scan_fabric(ispsoftc_t *isp, int chan)
2242 fcparam *fcp = FCPARAM(isp, chan);
2254 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC fabric scan", chan);
2258 isp_prt(isp, ISP_LOG_SANCFG,
2265 FC_SCRATCH_RELEASE(isp, chan);
2266 isp_prt(isp, ISP_LOG_SANCFG,
2274 r = isp_getpdb(isp, chan, NPH_FL_ID, &pdb);
2276 isp_dump_chip_portdb(isp, chan);
2281 isp_prt(isp, ISP_LOG_SANCFG,
2287 r = isp_gid_pt(isp, chan);
2311 isp_prt(isp, level, "Chan %d Fabric Nameserver rejected GID_PT"
2325 isp_prt(isp, ISP_LOGWARN,
2329 isp_prt(isp, ISP_LOG_SANCFG,
2355 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d removing duplicate PortID 0x%06x entry from list", chan, portid);
2373 isp_mark_portdb(isp, chan);
2378 isp_prt(isp, ISP_LOG_SANCFG,
2381 isp_prt(isp, ISP_LOG_SANCFG,
2387 isp_prt(isp, ISP_LOG_SANCFG,
2393 if (isp_find_pdb_by_portid(isp, chan, portid, &lp)) {
2395 isp_prt(isp, ISP_LOGERR,
2398 FC_PORTDB_TGT(isp, chan, lp), lp->state);
2399 isp_dump_portdb(isp, chan);
2421 r = isp_getpdb(isp, chan, lp->handle, &pdb);
2426 isp_prt(isp, ISP_LOG_SANCFG,
2432 isp_pdb_add_update(isp, chan, &pdb);
2438 isp_prt(isp, ISP_LOG_SANCFG,
2443 r = isp_gff_id(isp, chan, portid);
2445 isp_prt(isp, ISP_LOG_SANCFG,
2450 r = isp_gft_id(isp, chan, portid);
2452 isp_prt(isp, ISP_LOG_SANCFG,
2457 if (isp_login_device(isp, chan, portid, &pdb,
2458 &FCPARAM(isp, 0)->isp_lasthdl)) {
2464 isp_pdb_add_update(isp, chan, &pdb);
2470 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC fabric scan done", chan);
2478 isp_login_device(ispsoftc_t *isp, int chan, uint32_t portid, isp_pdb_t *p, uint16_t *ohp)
2483 handle = isp_next_handle(isp, ohp);
2485 if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC)
2489 r = isp_getpdb(isp, chan, handle, p);
2493 handle = isp_next_handle(isp, ohp);
2498 if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC)
2504 r = isp_plogx(isp, chan, handle, portid, PLOGX_FLG_CMD_PLOGI);
2513 if (isp_plogx(isp, chan, r >> 16, portid, PLOGX_FLG_CMD_LOGO | PLOGX_FLG_IMPLICIT | PLOGX_FLG_FREE_NPHDL)) {
2514 isp_prt(isp, ISP_LOGERR, "baw... logout of %x failed", r >> 16);
2516 if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC)
2518 r = isp_plogx(isp, chan, handle, portid, PLOGX_FLG_CMD_PLOGI);
2524 handle = isp_next_handle(isp, ohp);
2533 isp_prt(isp, ISP_LOGWARN, "Chan %d PLOGI 0x%06x failed", chan, portid);
2542 r = isp_getpdb(isp, chan, handle, p);
2544 isp_prt(isp, ISP_LOGERR, "Chan %d new device 0x%06x@0x%x disappeared", chan, portid, handle);
2549 isp_prt(isp, ISP_LOGERR, "Chan %d new device 0x%06x@0x%x changed (0x%06x@0x%0x)",
2557 isp_register_fc4_type(ispsoftc_t *isp, int chan)
2559 fcparam *fcp = FCPARAM(isp, chan);
2564 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
2565 isp_prt(isp, ISP_LOGERR, sacq);
2580 isp_put_rft_id(isp, &rp, (rft_id_t *)scp);
2582 if (isp_ct_passthru(isp, chan, sizeof(rft_id_t), sizeof(ct_hdr_t))) {
2583 FC_SCRATCH_RELEASE(isp, chan);
2587 isp_get_ct_hdr(isp, (ct_hdr_t *) scp, ct);
2588 FC_SCRATCH_RELEASE(isp, chan);
2590 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "Chan %d Register FC4 Type rejected", chan);
2593 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Register FC4 Type accepted", chan);
2595 isp_prt(isp, ISP_LOGWARN, "Chan %d Register FC4 Type: 0x%x", chan, ct->ct_cmd_resp);
2602 isp_register_fc4_features_24xx(ispsoftc_t *isp, int chan)
2604 fcparam *fcp = FCPARAM(isp, chan);
2609 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
2610 isp_prt(isp, ISP_LOGERR, sacq);
2633 isp_put_rff_id(isp, &rp, (rff_id_t *)scp);
2634 if (isp->isp_dblev & ISP_LOGDEBUG1)
2635 isp_print_bytes(isp, "CT request", sizeof(rft_id_t), scp);
2637 if (isp_ct_passthru(isp, chan, sizeof(rft_id_t), sizeof(ct_hdr_t))) {
2638 FC_SCRATCH_RELEASE(isp, chan);
2642 isp_get_ct_hdr(isp, (ct_hdr_t *) scp, ct);
2643 FC_SCRATCH_RELEASE(isp, chan);
2645 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1,
2649 isp_prt(isp, ISP_LOG_SANCFG,
2652 isp_prt(isp, ISP_LOGWARN,
2660 isp_register_port_name_24xx(ispsoftc_t *isp, int chan)
2662 fcparam *fcp = FCPARAM(isp, chan);
2668 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
2669 isp_prt(isp, ISP_LOGERR, sacq);
2692 ":%s", device_get_nameunit(isp->isp_dev));
2699 isp_put_rspn_id(isp, &rp, (rspn_id_t *)scp);
2701 if (isp_ct_passthru(isp, chan, len, sizeof(ct_hdr_t))) {
2702 FC_SCRATCH_RELEASE(isp, chan);
2706 isp_get_ct_hdr(isp, (ct_hdr_t *) scp, ct);
2707 FC_SCRATCH_RELEASE(isp, chan);
2709 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1,
2713 isp_prt(isp, ISP_LOG_SANCFG,
2716 isp_prt(isp, ISP_LOGWARN,
2724 isp_register_node_name_24xx(ispsoftc_t *isp, int chan)
2726 fcparam *fcp = FCPARAM(isp, chan);
2732 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
2733 isp_prt(isp, ISP_LOGERR, sacq);
2755 isp_put_rsnn_nn(isp, &rp, (rsnn_nn_t *)scp);
2757 if (isp_ct_passthru(isp, chan, len, sizeof(ct_hdr_t))) {
2758 FC_SCRATCH_RELEASE(isp, chan);
2762 isp_get_ct_hdr(isp, (ct_hdr_t *) scp, ct);
2763 FC_SCRATCH_RELEASE(isp, chan);
2765 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1,
2769 isp_prt(isp, ISP_LOG_SANCFG,
2772 isp_prt(isp, ISP_LOGWARN,
2780 isp_next_handle(ispsoftc_t *isp, uint16_t *ohp)
2796 isp_prt(isp, ISP_LOGERR, "Out of port handles!");
2802 for (chan = 0; chan < isp->isp_nchan; chan++) {
2803 fcp = FCPARAM(isp, chan);
2823 ispsoftc_t *isp;
2832 isp = XS_ISP(xs);
2842 isp_prt(isp, ISP_LOGERR, "unsupported cdb length (%d, CDB[0]=0x%x)", XS_CDBLEN(xs), XS_CDBP(xs)[0] & 0xff);
2852 fcp = FCPARAM(isp, XS_CHANNEL(xs));
2855 isp_prt(isp, ISP_LOG_WARN1,
2862 if (isp->isp_state != ISP_RUNSTATE) {
2863 isp_prt(isp, ISP_LOGERR, "Adapter not at RUNSTATE");
2868 isp_prt(isp, ISP_LOGDEBUG2, "XS_TGT(xs)=%d", target);
2876 isp_prt(isp, ISP_LOGDEBUG1,
2882 isp_prt(isp, ISP_LOGDEBUG1,
2888 isp_prt(isp, ISP_LOGDEBUG1,
2897 qep = isp_getrqentry(isp);
2899 isp_prt(isp, ISP_LOG_WARN1, "Request Queue Overflow");
2911 if (ISP_TST_SENDMARKER(isp, XS_CHANNEL(xs))) {
2917 isp_put_marker_24xx(isp, m, qep);
2918 ISP_SYNC_REQUEST(isp);
2919 ISP_SET_SENDMARKER(isp, XS_CHANNEL(xs), 0);
2928 isp_prt(isp, ISP_LOGERR, "Command Length %u too long for this chip", cdblen);
2948 if (FCPARAM(isp, XS_CHANNEL(xs))->fctape_enabled && (lp->prli_word3 & PRLI_WD3_RETRY)) {
2949 if (FCP_NEXT_CRN(isp, &reqp->req_crn, xs)) {
2950 isp_prt(isp, ISP_LOG_WARN1,
2961 reqp->req_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(xs));
2964 reqp->req_handle = isp_allocate_handle(isp, xs, ISP_HANDLE_INITIATOR);
2966 isp_prt(isp, ISP_LOG_WARN1, "out of xflist pointers");
2977 dmaresult = ISP_DMASETUP(isp, xs, reqp);
2979 isp_destroy_handle(isp, reqp->req_handle);
2986 isp_xs_prt(isp, xs, ISP_LOGDEBUG0, "START cmd cdb[0]=0x%x datalen %ld", XS_CDBP(xs)[0], (long) XS_XFRLEN(xs));
2991 * isp control
2996 isp_control(ispsoftc_t *isp, ispctl_t ctl, ...)
3012 isp_prt(isp, ISP_LOGERR, "BUS RESET NOT IMPLEMENTED");
3024 fcp = FCPARAM(isp, chan);
3027 isp_prt(isp, ISP_LOGWARN, "Chan %d trying to reset bad target %d", chan, tgt);
3032 isp_prt(isp, ISP_LOGWARN, "Chan %d abort of no longer valid target %d", chan, tgt);
3046 tmf->tmf_vpidx = ISP_GET_VPIDX(isp, chan);
3048 isp_prt(isp, ISP_LOGALL, "Chan %d Reset N-Port Handle 0x%04x @ Port 0x%06x", chan, lp->handle, lp->portid);
3051 if (isp_exec_entry_mbox(isp, tmf, sp, 2 * tmf->tmf_timeout))
3056 isp_prt(isp, ISP_LOGWARN, "Chan %d reset of target %d returned 0x%x", chan, tgt, sp->req_completion_status);
3070 handle = isp_find_handle(isp, xs);
3072 isp_prt(isp, ISP_LOGWARN, "cannot find handle for command to abort");
3076 fcp = FCPARAM(isp, chan);
3078 isp_prt(isp, ISP_LOGWARN, "Chan %d trying to abort bad target %d", chan, tgt);
3083 isp_prt(isp, ISP_LOGWARN, "Chan %d abort of no longer valid target %d", chan, tgt);
3086 isp_prt(isp, ISP_LOGALL, "Chan %d Abort Cmd for N-Port 0x%04x @ Port 0x%06x", chan, lp->handle, lp->portid);
3094 ab->abrt_vpidx = ISP_GET_VPIDX(isp, chan);
3096 if (isp_exec_entry_mbox(isp, ab, ab, 5))
3101 isp_prt(isp, ISP_LOGWARN, "Chan %d handle %d abort returned 0x%x", chan, tgt, ab->abrt_nphdl);
3114 return (isp_fclink_test(isp, chan, usdelay));
3121 return (isp_scan_fabric(isp, chan));
3128 return (isp_scan_loop(isp, chan));
3135 return (isp_pdb_sync(isp, chan));
3148 return (isp_getpdb(isp, chan, tgt, pdb));
3163 *wwnn = isp_get_wwn(isp, chan, tgt, 1);
3169 *wwnp = isp_get_wwn(isp, chan, tgt, 0);
3181 isp_mboxcmd(isp, mbr);
3194 return (isp_plogx(isp, p->channel, p->handle, p->portid, p->flags));
3197 isp_next_handle(isp, &p->handle);
3198 r = isp_plogx(isp, p->channel, p->handle, p->portid, p->flags);
3215 return (isp_fc_change_role(isp, chan, role));
3218 isp_prt(isp, ISP_LOGERR, "Unknown Control Opcode 0x%x", ctl);
3234 isp_intr_atioq(ispsoftc_t *isp)
3239 iptr = ISP_READ(isp, BIU2400_ATIO_RSPINP);
3240 optr = isp->isp_atioodx;
3243 MEMORYBARRIER(isp, SYNC_ATIOQ, oop, QENTRY_LEN, -1);
3244 addr = ISP_QUEUE_ENTRY(isp->isp_atioq, oop);
3250 (void) isp_target_notify(isp, addr, &oop,
3251 ATIO_QUEUE_LEN(isp));
3255 isp_print_qentry(isp, "?ATIOQ entry?", oop, addr);
3258 optr = ISP_NXT_QENTRY(oop, ATIO_QUEUE_LEN(isp));
3260 if (isp->isp_atioodx != optr) {
3261 ISP_WRITE(isp, BIU2400_ATIO_RSPOUTP, optr);
3262 isp->isp_atioodx = optr;
3268 isp_intr_mbox(ispsoftc_t *isp, uint16_t mbox0)
3272 if (!isp->isp_mboxbsy) {
3273 isp_prt(isp, ISP_LOGWARN, "mailbox 0x%x with no waiters", mbox0);
3276 obits = isp->isp_obits;
3277 isp->isp_mboxtmp[0] = mbox0;
3278 for (i = 1; i < ISP_NMBOX(isp); i++) {
3281 isp->isp_mboxtmp[i] = ISP_READ(isp, MBOX_OFF(i));
3283 isp->isp_mboxbsy = 0;
3287 isp_intr_respq(ispsoftc_t *isp)
3304 if (isp->isp_state != ISP_RUNSTATE) {
3305 isp_prt(isp, ISP_LOGINFO, "respq interrupt when not ready");
3309 iptr = ISP_READ(isp, BIU2400_RSPINP);
3310 optr = isp->isp_resodx;
3316 hp = (isphdr_t *) ISP_QUEUE_ENTRY(isp->isp_result, cptr);
3317 optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN(isp));
3322 MEMORYBARRIER(isp, SYNC_RESULT, cptr, QENTRY_LEN, -1);
3323 if (isp->isp_dblev & ISP_LOGDEBUG1)
3324 isp_print_qentry(isp, "Response Queue Entry", cptr, hp);
3325 isp_get_hdr(isp, hp, &sp->req_header);
3332 isp_print_qentry(isp, "invalid entry type", cptr, hp);
3336 isp_print_qentry(isp, "invalid entry parameter", cptr, hp);
3340 isp_print_qentry(isp, "invalid entry count", cptr, hp);
3344 isp_print_qentry(isp, "invalid entry order", cptr, hp);
3356 if (isp_handle_control(isp, hp)) {
3363 isp_get_24xx_response(isp, (isp24xx_statusreq_t *)hp, sp);
3366 isp_prt(isp, ISP_LOG_WARN1, "Marker Response");
3370 isp_get_cont_response(isp, (ispstatus_cont_t *)hp, scp);
3378 isp_prt(isp, ISP_LOGDEBUG0|ISP_LOG_CWARN,
3383 isp_prt(isp, ISP_LOG_WARN1, "Ignored Continuation Response");
3392 isp_target_notify(isp, hp, &cptr, RESULT_QUEUE_LEN(isp));
3396 sptr = ISP_NXT_QENTRY(sptr, RESULT_QUEUE_LEN(isp));
3397 hp = (isphdr_t *)ISP_QUEUE_ENTRY(isp->isp_result, sptr);
3400 optr = ISP_NXT_QENTRY(cptr, RESULT_QUEUE_LEN(isp));
3404 isp_handle_rpt_id_acq(isp, hp);
3409 isp_prt(isp, ISP_LOGERR, notresp, etype, cptr, optr);
3414 xs = isp_find_xs(isp, sp->req_handle);
3422 isp_prt(isp, ISP_LOGERR, "cannot find handle 0x%x (status 0x%x)",
3468 isp_xs_prt(isp, xs, ISP_LOGWARN,
3475 isp_parse_status_24xx(isp, sp, xs);
3481 isp_prt(isp, ISP_LOGDEBUG0|ISP_LOG_CWARN,
3487 ISP_DMAFREE(isp, xs);
3488 isp_destroy_handle(isp, sp->req_handle);
3501 if (optr != isp->isp_resodx) {
3502 ISP_WRITE(isp, BIU2400_RSPOUTP, optr);
3503 isp->isp_resodx = optr;
3509 isp_intr_async(ispsoftc_t *isp, uint16_t mbox)
3514 isp_prt(isp, ISP_LOGDEBUG2, "Async Mbox 0x%x", mbox);
3518 isp->isp_state = ISP_CRASHED;
3519 for (chan = 0; chan < isp->isp_nchan; chan++) {
3520 FCPARAM(isp, chan)->isp_loopstate = LOOP_NIL;
3521 isp_change_fw_state(isp, chan, FW_CONFIG_WAIT);
3527 if (isp->isp_mboxbsy) {
3528 isp->isp_obits = 1;
3529 isp->isp_mboxtmp[0] = MBOX_HOST_INTERFACE_ERROR;
3530 isp->isp_mboxbsy = 0;
3536 isp_async(isp, ISPASYNC_FW_CRASH);
3540 isp_prt(isp, ISP_LOGERR, "Request Queue Transfer Error");
3544 isp_prt(isp, ISP_LOGERR, "Response Queue Transfer Error");
3548 isp_prt(isp, ISP_LOGERR, "ATIO Queue Transfer Error");
3559 for (chan = 0; chan < isp->isp_nchan; chan++) {
3560 fcp = FCPARAM(isp, chan);
3567 ISP_SET_SENDMARKER(isp, chan, 1);
3568 isp_async(isp, ISPASYNC_LIP, chan);
3570 isp_target_async(isp, chan, mbox);
3581 for (i = j = 0; i < ISP_HANDLE_NUM(isp); i++) {
3585 hdp = &isp->isp_xflist[i];
3594 isp_prt(isp, ISP_LOG_WARN1,
3602 isp_prt(isp, ISP_LOGERR, lipd, chan, j);
3613 for (chan = 0; chan < isp->isp_nchan; chan++) {
3614 fcp = FCPARAM(isp, chan);
3620 ISP_SET_SENDMARKER(isp, chan, 1);
3621 isp_async(isp, ISPASYNC_LOOP_UP, chan);
3623 isp_target_async(isp, chan, mbox);
3633 for (chan = 0; chan < isp->isp_nchan; chan++) {
3634 fcp = FCPARAM(isp, chan);
3637 ISP_SET_SENDMARKER(isp, chan, 1);
3640 isp_async(isp, ISPASYNC_LOOP_DOWN, chan);
3642 isp_target_async(isp, chan, mbox);
3652 for (chan = 0; chan < isp->isp_nchan; chan++) {
3653 fcp = FCPARAM(isp, chan);
3656 ISP_SET_SENDMARKER(isp, chan, 1);
3659 isp_async(isp, ISPASYNC_LOOP_RESET, chan);
3661 isp_target_async(isp, chan, mbox);
3670 nphdl = ISP_READ(isp, OUTMAILBOX1);
3671 nlstate = ISP_READ(isp, OUTMAILBOX2);
3672 reason = ISP_READ(isp, OUTMAILBOX3) >> 8;
3673 if (ISP_CAP_MULTI_ID(isp)) {
3674 chan = ISP_READ(isp, OUTMAILBOX3) & 0xff;
3677 echan = isp->isp_nchan - 1;
3678 } else if (chan >= isp->isp_nchan) {
3687 fcp = FCPARAM(isp, chan);
3698 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan,
3707 portid = ((ISP_READ(isp, OUTMAILBOX1) & 0xff) << 16) |
3708 ISP_READ(isp, OUTMAILBOX2);
3709 if (ISP_CAP_MULTI_ID(isp)) {
3710 chan = ISP_READ(isp, OUTMAILBOX3) & 0xff;
3711 if (chan >= isp->isp_nchan)
3716 fcp = FCPARAM(isp, chan);
3723 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan,
3728 isp_prt(isp, ISP_LOGWARN, "Error logging disabled (reason 0x%x)",
3729 ISP_READ(isp, OUTMAILBOX1));
3732 isp_prt(isp, ISP_LOGWARN, "P2P init error (reason 0x%x)",
3733 ISP_READ(isp, OUTMAILBOX1));
3736 isp_prt(isp, ISP_LOGWARN, "Receive Error");
3739 isp_prt(isp, ISP_LOGTDEBUG0, "LS_RJT sent");
3742 isp_prt(isp, ISP_LOGDEBUG0, "FW restart complete");
3745 isp_prt(isp, ISP_LOGERR, "Temperature alert (subcode 0x%x)",
3746 ISP_READ(isp, OUTMAILBOX1));
3749 isp_prt(isp, ISP_LOGDEBUG0, "Inter-driver communication complete");
3752 isp_prt(isp, ISP_LOGDEBUG0, "Inter-driver communication notification");
3755 isp_prt(isp, ISP_LOGDEBUG0, "Inter-driver communication time extended");
3758 isp_prt(isp, ISP_LOGDEBUG0, "Transceiver insertion (0x%x)",
3759 ISP_READ(isp, OUTMAILBOX1));
3762 isp_prt(isp, ISP_LOGDEBUG0, "Transceiver removal");
3765 isp_prt(isp, ISP_LOGDEBUG0, "NIC Firmware State Change");
3768 isp_prt(isp, ISP_LOGDEBUG0, "Autoload FW init complete");
3771 isp_prt(isp, ISP_LOGERR, "Autoload FW init failure");
3774 isp_prt(isp, ISP_LOGWARN, "Unknown Async Code 0x%x", mbox);
3783 isp_handle_control(ispsoftc_t *isp, isphdr_t *hp)
3801 ISP_IOXGET_32(isp, (uint32_t *)(hp + 1), hdl);
3804 ptr = isp_find_xs(isp, hdl);
3806 isp_destroy_handle(isp, hdl);
3816 isp_handle_rpt_id_acq(ispsoftc_t *isp, isphdr_t *hp)
3823 isp_get_ridacq(isp, (isp_ridacq_t *)hp, &rid);
3827 for (chan = 0; chan < isp->isp_nchan; chan++) {
3828 fcp = FCPARAM(isp, chan);
3835 isp_async(isp, ISPASYNC_CHANGE_NOTIFY,
3839 isp_async(isp, ISPASYNC_LOOP_DOWN,
3844 fcp = FCPARAM(isp, rid.ridacq_vp_index);
3850 isp_async(isp, ISPASYNC_CHANGE_NOTIFY,
3854 isp_async(isp, ISPASYNC_LOOP_DOWN,
3861 isp_parse_status_24xx(ispsoftc_t *isp, isp24xx_statusreq_t *sp, XS_T *xs)
3871 isp_xs_prt(isp, xs, ISP_LOGERR, "DMA error");
3877 isp_xs_prt(isp, xs, ISP_LOGERR, "Transport Error");
3883 isp_xs_prt(isp, xs, ISP_LOGWARN, "reset destroyed command");
3884 FCPARAM(isp, chan)->sendmarker = 1;
3890 isp_xs_prt(isp, xs, ISP_LOGERR, "Command Aborted");
3891 FCPARAM(isp, chan)->sendmarker = 1;
3897 isp_xs_prt(isp, xs, ISP_LOGWARN, "Command Timed Out");
3904 isp_xs_prt(isp, xs, ISP_LOGERR, "Data Overrun");
3910 isp_prt(isp, ISP_LOGERR, "Chan %d data reassembly error for target %d", chan, XS_TGT(xs));
3916 isp_prt(isp, ISP_LOGERR, "Chan %d target %d sent ABTS", chan, XS_TGT(xs));
3930 isp_xs_prt(isp, xs, ISP_LOGWARN, bun, XS_XFRLEN(xs), sp->req_resid, (ru_marked)? "marked" : "not marked");
3936 isp_xs_prt(isp, xs, ISP_LOG_WARN1, "Data Underrun (%d) for command 0x%x", sp->req_resid, XS_CDBP(xs)[0] & 0xff);
3947 fcparam *fcp = FCPARAM(isp, XS_CHANNEL(xs));
3959 isp_prt(isp, ISP_LOGINFO, "Chan %d port %s for target %d",
3975 isp_prt(isp, ISP_LOGWARN, "port changed for target %d chan %d", XS_TGT(xs), chan);
3983 isp_prt(isp, ISP_LOGWARN, "f/w resource unavailable for target %d chan %d", XS_TGT(xs), chan);
3991 isp_prt(isp, ISP_LOGWARN, "command for target %d overlapped task management for chan %d", XS_TGT(xs), chan);
3999 isp_prt(isp, ISP_LOGERR, "Unknown Completion Status 0x%x on chan %d", sp->req_completion_status, chan);
4282 isp_mboxcmd(ispsoftc_t *isp, mbreg_t *mbp)
4291 isp_prt(isp, ISP_LOGERR, "Unknown Command 0x%x", opcode);
4301 isp_prt(isp, ISP_LOGDEBUG3, "Mailbox Command '%s'", cname);
4318 isp_prt(isp, ISP_LOGERR, "no parameters for 0x%x", opcode);
4322 for (box = 0; box < ISP_NMBOX(isp); box++) {
4324 isp_prt(isp, ISP_LOGDEBUG3, "IN mbox %d = 0x%04x", box,
4326 ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]);
4328 isp->isp_mboxtmp[box] = mbp->param[box] = 0;
4331 isp->isp_obits = obits;
4332 isp->isp_mboxbsy = 1;
4337 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_SET_HOST_INT);
4344 if (!isp->isp_mboxbsy)
4346 ISP_RUN_ISR(isp);
4347 if (!isp->isp_mboxbsy)
4355 if (isp->isp_mboxbsy) {
4356 isp->isp_mboxbsy = 0;
4357 isp_prt(isp, ISP_LOGWARN, "Mailbox Command (0x%x) Timeout (%uus) (%s:%d)",
4366 for (box = 0; box < ISP_NMBOX(isp); box++) {
4368 mbp->param[box] = isp->isp_mboxtmp[box];
4369 isp_prt(isp, ISP_LOGDEBUG3, "OUT mbox %d = 0x%04x", box,
4439 isp_prt(isp, ISP_LOGALL, "Mailbox Command '%s' failed (%s%s)",
4445 isp_fw_state(ispsoftc_t *isp, int chan)
4450 isp_mboxcmd(isp, &mbs);
4457 isp_setdfltfcparm(ispsoftc_t *isp, int chan)
4459 fcparam *fcp = FCPARAM(isp, chan);
4464 fcp->role = DEFAULT_ROLE(isp, chan);
4467 fcp->isp_loopid = DEFAULT_LOOPID(isp, chan);
4468 fcp->isp_wwnn_nvram = DEFAULT_NODEWWN(isp, chan);
4469 fcp->isp_wwpn_nvram = DEFAULT_PORTWWN(isp, chan);
4478 if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX)
4488 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
4494 j = isp_read_nvram(isp);
4500 isp->isp_confopts |= ISP_CFG_NONVRAM;
4504 fcp->isp_wwnn = ACTIVE_NODEWWN(isp, chan);
4505 fcp->isp_wwpn = ACTIVE_PORTWWN(isp, chan);
4506 isp_prt(isp, ISP_LOGCONFIG, "Chan %d 0x%08x%08x/0x%08x%08x Role %s",
4519 isp_reinit(ispsoftc_t *isp, int do_load_defaults)
4523 if (isp->isp_state > ISP_RESETSTATE)
4524 isp_stop(isp);
4525 if (isp->isp_state != ISP_RESETSTATE)
4526 isp_reset(isp, do_load_defaults);
4527 if (isp->isp_state != ISP_RESETSTATE) {
4529 isp_prt(isp, ISP_LOGERR, "%s: cannot reset card", __func__);
4533 isp_init(isp);
4534 if (isp->isp_state > ISP_RESETSTATE &&
4535 isp->isp_state != ISP_RUNSTATE) {
4537 isp_prt(isp, ISP_LOGERR, "%s: cannot init card", __func__);
4538 ISP_DISABLE_INTS(isp);
4542 isp_clear_commands(isp);
4543 for (i = 0; i < isp->isp_nchan; i++)
4544 isp_clear_portdb(isp, i);
4552 flash_data_addr(ispsoftc_t *isp, uint32_t faddr)
4554 fcparam *fcp = FCPARAM(isp, 0);
4560 isp_read_flash_dword(ispsoftc_t *isp, uint32_t addr, uint32_t *data)
4564 ISP_WRITE(isp, BIU2400_FLASH_ADDR, addr & ~0x80000000);
4566 if (ISP_READ(isp, BIU2400_FLASH_ADDR & 0x80000000)) {
4567 *data = ISP_READ(isp, BIU2400_FLASH_DATA);
4572 isp_prt(isp, ISP_LOGERR,
4579 isp_read_flash_data(ispsoftc_t *isp, uint32_t *dwptr, uint32_t faddr, uint32_t dwords)
4585 faddr = flash_data_addr(isp, faddr);
4587 rval = isp_read_flash_dword(isp, faddr, dwptr);
4597 isp_rd_2xxx_flash(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
4599 fcparam *fcp = FCPARAM(isp, 0);
4603 ISP_WRITE(isp, BIU2400_FLASH_ADDR, (base + addr) & ~0x80000000);
4606 if (ISP_READ(isp, BIU2400_FLASH_ADDR & 0x80000000)) {
4607 *rp = ISP_READ(isp, BIU2400_FLASH_DATA);
4608 ISP_SWIZZLE_NVRAM_LONG(isp, rp);
4612 isp_prt(isp, ISP_LOGERR,
4618 isp_read_flthdr_2xxx(ispsoftc_t *isp)
4620 fcparam *fcp = FCPARAM(isp, 0);
4629 isp_prt(isp, ISP_LOGDEBUG0, "FLTL[DEF]: 0x%x", addr);
4631 isp_rd_2xxx_flash(isp, addr++, dptr++);
4636 ISP_IOXGET_16(isp, &dptr[lwrds], tmp);
4643 isp_parse_flthdr_2xxx(isp, flthdr_data);
4649 isp_parse_flthdr_2xxx(ispsoftc_t *isp, uint8_t *flthdr_data)
4651 fcparam *fcp = FCPARAM(isp, 0);
4660 isp_prt(isp, ISP_LOGERR,
4664 isp_prt(isp, ISP_LOGDEBUG0,
4670 isp_read_flt_2xxx(ispsoftc_t *isp)
4672 fcparam *fcp = FCPARAM(isp, 0);
4681 isp_prt(isp, ISP_LOGDEBUG0, "FLT[DEF]: regions=%d",
4684 isp_rd_2xxx_flash(isp, addr++, dptr++);
4686 retval = isp_parse_flt_2xxx(isp, flt_data);
4691 isp_parse_flt_2xxx(ispsoftc_t *isp, uint8_t *flt_data)
4693 fcparam *fcp = FCPARAM(isp, 0);
4711 isp_prt(isp, ISP_LOGDEBUG0,
4725 if (isp->isp_port == 0)
4729 if (isp->isp_port == 1)
4733 if (!IS_27XX(isp))
4735 if (isp->isp_port == 2)
4739 if (!IS_27XX(isp))
4741 if (isp->isp_port == 3)
4745 if (isp->isp_port == 0)
4749 if (isp->isp_port == 1)
4753 if (!IS_27XX(isp))
4755 if (isp->isp_port == 2)
4759 if (!IS_27XX(isp))
4761 if (isp->isp_port == 3)
4771 if (isp->isp_port == 0)
4775 if (isp->isp_port == 1)
4782 if (isp->isp_port == 0)
4786 if (isp->isp_port == 1)
4790 if (IS_27XX(isp))
4794 if (IS_27XX(isp))
4798 if (IS_27XX(isp))
4802 if (IS_27XX(isp))
4806 if (IS_27XX(isp))
4810 if (IS_27XX(isp))
4814 if (IS_27XX(isp))
4815 if (isp->isp_port == 0)
4819 if (IS_27XX(isp))
4820 if (isp->isp_port == 1)
4824 if (IS_27XX(isp))
4825 if (isp->isp_port == 2)
4829 if (IS_27XX(isp))
4830 if (isp->isp_port == 3)
4835 if (IS_27XX(isp)) {
4837 if (isp->isp_port == 0)
4843 if (IS_27XX(isp))
4844 if (isp->isp_port == 1)
4849 if (IS_27XX(isp))
4850 if (isp->isp_port == 2)
4855 if (IS_27XX(isp))
4856 if (isp->isp_port == 3)
4861 isp_prt(isp, ISP_LOGCONFIG,
4873 isp_print_image(ispsoftc_t *isp, char *name, struct isp_image_status *image_status)
4875 isp_prt(isp, ISP_LOGDEBUG0,
4944 isp_compare_image_generation(ispsoftc_t *isp,
4953 isp_prt(isp, ISP_LOGDEBUG0, "generation delta = %d", delta);
4959 isp_get_aux_images(ispsoftc_t *isp, struct active_regions *active_regions)
4961 fcparam *fcp = FCPARAM(isp, 0);
4967 isp_prt(isp, ISP_LOGWARN,
4972 isp_read_flash_data(isp, (uint32_t *)&pri_aux_image_status,
4975 isp_print_image(isp, "Primary aux image", &pri_aux_image_status);
4978 isp_prt(isp, ISP_LOGERR,
4985 isp_prt(isp, ISP_LOGERR,
4993 isp_prt(isp, ISP_LOGCONFIG,
5000 isp_prt(isp, ISP_LOGWARN,
5005 isp_read_flash_data(isp, (uint32_t *)&sec_aux_image_status,
5008 isp_print_image(isp, "Secondary aux image", &sec_aux_image_status);
5011 isp_prt(isp, ISP_LOGERR,
5018 isp_prt(isp, ISP_LOGERR,
5026 isp_prt(isp, ISP_LOGCONFIG,
5034 if (isp_compare_image_generation(isp, &pri_aux_image_status,
5048 isp_prt(isp, ISP_LOGDEBUG0,
5058 isp_get_active_image(ispsoftc_t *isp, struct active_regions * active_regions)
5060 fcparam *fcp = FCPARAM(isp, 0);
5066 isp_prt(isp, ISP_LOGWARN,
5071 if (isp_read_flash_data(isp, (uint32_t *) &pri_image_status,
5076 isp_print_image(isp, "Primary image", &pri_image_status);
5079 isp_prt(isp, ISP_LOGERR,
5086 isp_prt(isp, ISP_LOGERR,
5094 isp_prt(isp, ISP_LOGCONFIG,
5101 isp_prt(isp, ISP_LOGWARN,
5106 if (isp_read_flash_data(isp, (uint32_t *) &sec_image_status,
5111 isp_print_image(isp, "Secondary image", &sec_image_status);
5114 isp_prt(isp, ISP_LOGERR,
5120 isp_prt(isp, ISP_LOGERR,
5128 isp_prt(isp, ISP_LOGCONFIG,
5139 isp_compare_image_generation(isp,
5145 isp_prt(isp, ISP_LOGDEBUG0, "active image %s (%u)",
5155 static bool isp_risc_firmware_invalid(ispsoftc_t *isp, uint32_t *dword)
5162 isp_load_ram(ispsoftc_t *isp, uint32_t *data, uint32_t risc_addr,
5168 MEMORYBARRIER(isp, SYNC_REQUEST, 0, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)), -1);
5171 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
5172 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
5175 mbs.param[6] = DMA_WD3(isp->isp_rquest_dma);
5176 mbs.param[7] = DMA_WD2(isp->isp_rquest_dma);
5178 isp_prt(isp, ISP_LOGDEBUG0,
5181 isp_mboxcmd(isp, &mbs);
5183 isp_prt(isp, ISP_LOGERR, "F/W download failed");
5191 isp_load_risc_flash(ispsoftc_t *isp, uint32_t *srisc_addr, uint32_t faddr)
5193 fcparam *fcp = FCPARAM(isp, 0);
5202 isp_prt(isp, ISP_LOGDEBUG0,
5205 dcode = isp->isp_rquest;
5206 isp_read_flash_data(isp, dcode, faddr, 8);
5207 if (isp_risc_firmware_invalid(isp, dcode)) {
5210 isp_prt(isp, ISP_LOGERR,
5212 isp_prt(isp, ISP_LOGERR,
5222 isp_prt(isp, ISP_LOGCONFIG,
5228 if (isp->isp_osinfo.ispfw != NULL) {
5235 if (isp->isp_confopts & ISP_CFG_FWLOAD_FORCE) {
5236 isp_prt(isp, ISP_LOGCONFIG,
5243 isp_prt(isp, ISP_LOGCONFIG,
5247 isp_prt(isp, ISP_LOGCONFIG,
5252 dcode = isp->isp_rquest;
5255 isp_prt(isp, ISP_LOGDEBUG0, "Loading segment %u", j);
5256 isp_read_flash_data(isp, dcode, faddr, 10);
5260 dlen = min(risc_size, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)) / 4);
5265 isp_prt(isp, ISP_LOGDEBUG0,
5268 isp_read_flash_data(isp, dcode, faddr, dlen);
5273 rval = isp_load_ram(isp, dcode, risc_addr, dlen);
5275 isp_prt(isp, ISP_LOGERR,
5291 isp_load_risc(ispsoftc_t *isp, uint32_t *srisc_addr)
5293 fcparam *fcp = FCPARAM(isp, 0);
5301 if (!IS_27XX(isp))
5304 isp_get_active_image(isp, &active_regions);
5309 isp_prt(isp, ISP_LOGCONFIG,
5311 rval = isp_load_risc_flash(isp, srisc_addr, fcp->flt_region_fw_sec);
5315 isp_prt(isp, ISP_LOGCONFIG,
5317 rval = isp_load_risc_flash(isp, srisc_addr, fcp->flt_region_fw);
5322 isp_read_nvram(ispsoftc_t *isp)
5324 fcparam *fcp = FCPARAM(isp, 0);
5330 if (IS_27XX(isp))
5331 isp_get_aux_images(isp, &active_regions);
5335 if (IS_28XX(isp)) {
5339 isp_prt(isp, ISP_LOGCONFIG, "Loading %s NVRAM image",
5346 isp_rd_2xxx_flash(isp, addr++, dptr++);
5350 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM header (%x %x %x)",
5358 ISP_IOXGET_32(isp, &dptr[lwrds], tmp);
5362 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM checksum");
5366 isp_parse_nvram_2400(isp, nvram_data);
5372 isp_parse_nvram_2400(ispsoftc_t *isp, uint8_t *nvram_data)
5374 fcparam *fcp = FCPARAM(isp, 0);
5377 isp_prt(isp, ISP_LOGDEBUG0,
5384 isp_prt(isp, ISP_LOGDEBUG0,
5406 if ((isp->isp_confopts & ISP_CFG_OWNFSZ) == 0) {
5407 DEFAULT_FRAMESIZE(isp) =
5410 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) {