Lines Matching +full:rate +full:- +full:lp +full:- +full:ms

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2009-2020 Alexander Motin <mav@FreeBSD.org>
5 * Copyright (c) 1997-2009 by Matthew Jacob
34 * code for the Qlogic ISP SCSI and FC-SCSI adapters.
151 if (fcp->isp_fwstate == state)
154 "Chan %d Firmware state <%s->%s>", chan,
155 isp_fc_fw_statename(fcp->isp_fwstate), isp_fc_fw_statename(state));
156 fcp->isp_fwstate = state;
166 fcp->flash_data_addr = ISP28XX_BASE_ADDR;
167 fcp->flt_region_flt = ISP28XX_FLT_ADDR;
169 fcp->flash_data_addr = ISP27XX_BASE_ADDR;
170 fcp->flt_region_flt = ISP27XX_FLT_ADDR;
172 fcp->flash_data_addr = ISP25XX_BASE_ADDR;
173 fcp->flt_region_flt = ISP25XX_FLT_ADDR;
175 fcp->flash_data_addr = ISP24XX_BASE_ADDR;
176 fcp->flt_region_flt = ISP24XX_FLT_ADDR;
178 fcp->flt_length = 0;
184 fcp->flt_region_nvram = 0x300000;
186 fcp->flash_data_addr = 0x7fe7c000;
187 fcp->flt_region_nvram = 0;
189 fcp->flt_region_nvram = 0x48000;
191 fcp->flash_data_addr = 0x7ffe0000;
192 fcp->flt_region_nvram = 0;
194 fcp->flt_region_nvram += ISP2400_NVRAM_PORT_ADDR(isp->isp_port);
217 isp->isp_state = ISP_NILSTATE;
228 switch (isp->isp_type) {
277 isp_prt(isp, ISP_LOGERR, "The ROM code is busy after 50ms.");
295 * Post-RISC Reset stuff.
307 isp_prt(isp, ISP_LOGERR, "The ROM code is busy after 50ms.");
317 isp->isp_reqidx = isp->isp_reqodx = 0;
318 isp->isp_resodx = 0;
319 isp->isp_atioodx = 0;
420 snprintf(fcp->fw_version_ispfw, sizeof(fcp->fw_version_ispfw),
422 snprintf(fcp->fw_version_flash, sizeof(fcp->fw_version_flash),
424 snprintf(fcp->fw_version_run, sizeof(fcp->fw_version_run),
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;
437 fcp->fw_ispfwrev[i] = ispfwptr[4 + i];
440 snprintf(fcp->fw_version_ispfw,
441 sizeof(fcp->fw_version_ispfw),
442 "%u.%u.%u", fcp->fw_ispfwrev[0],
443 fcp->fw_ispfwrev[1], fcp->fw_ispfwrev[2]);
446 fcp->fw_ispfwrev[0], fcp->fw_ispfwrev[1],
447 fcp->fw_ispfwrev[2], fcp->fw_ispfwrev[3]);
475 if (isp->isp_osinfo.ispfw != NULL)
481 if (isp->isp_osinfo.ispfw != NULL)
487 const uint32_t *ptr = isp->isp_mdvec->dv_ispfw;
505 cp = isp->isp_rquest;
515 wl -= nw;
525 if (isp->isp_osinfo.ispfw != NULL)
526 firmware_put(isp->isp_osinfo.ispfw, FIRMWARE_UNLOAD);
572 fcp->fw_ability_mask = (mbs.param[3] << 16) | mbs.param[2];
574 fcp->fw_ability_mask);
576 fcp->max_supported_speed = mbs.param[2] & (0x1 | 0x2);
578 fcp->max_supported_speed == 0 ? "16Gbit/s" :
579 fcp->max_supported_speed == 1 ? "32Gbit/s" :
580 fcp->max_supported_speed == 2 ? "64Gbit/s" : "unknown");
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];
608 btype, isp->isp_revision, dodnld ? "loaded" : "resident",
609 isp->isp_fwrev[0], isp->isp_fwrev[1], isp->isp_fwrev[2]);
610 snprintf(fcp->fw_version_run, sizeof(fcp->fw_version_run),
611 "%u.%u.%u", isp->isp_fwrev[0], isp->isp_fwrev[1],
612 isp->isp_fwrev[2]);
614 snprintf(fcp->fw_version_flash, sizeof(fcp->fw_version_flash),
615 "%s", fcp->fw_version_run);
617 fwt = isp->isp_fwattr;
618 buf = FCPARAM(isp, 0)->isp_scanscratch;
622 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s Class2", buf);
626 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s IP", buf);
630 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s MultiID", buf);
634 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s SB2", buf);
638 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s T10CRC", buf);
642 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s VI", buf);
646 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s MQ", buf);
650 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s MSIX", buf);
654 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s FCOE", buf);
658 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s VP0_Decoupling", buf);
662 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s (Experimental)", buf);
666 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s HotFW", buf);
670 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf),
675 fwt = isp->isp_fwattr_h;
676 buf = FCPARAM(isp, 0)->isp_scanscratch;
680 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s ExtVP", buf);
684 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s VN2VN", buf);
688 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s EXMOFF", buf);
692 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s NPMOFF", buf);
696 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s DIFCHOP", buf);
700 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s SRIOV", buf);
704 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s NVMe", buf);
708 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s NVMe(updated)", buf);
712 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s NVMe(first burst)", buf);
715 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf),
720 fwt = isp->isp_fwattr_ext[0];
721 buf = FCPARAM(isp, 0)->isp_scanscratch;
725 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s ASICTMP", buf);
729 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s ATIOMQ", buf);
733 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s EDIF", buf);
737 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s SCM", buf);
741 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s NVMe-2", buf);
744 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf),
749 fwt = isp->isp_fwattr_ext[1];
750 buf = FCPARAM(isp, 0)->isp_scanscratch;
753 ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf),
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);
771 * If we don't have Multi-ID f/w loaded, we need to restrict channels to one.
772 * Only make this check for non-SCSI cards (I'm not sure firmware attributes
775 if (isp->isp_nchan > 1) {
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;
783 isp->isp_nchan = 1;
804 for (i = 0; i < isp->isp_nchan; i++)
807 isp->isp_state = ISP_RESETSTATE;
815 for (i = 0; i < isp->isp_nchan; i++)
828 isp->isp_state = ISP_NILSTATE;
849 if (isp->isp_state >= ISP_RESETSTATE)
873 for (chan = 0; chan < isp->isp_nchan; chan++) {
875 if (fcp->role != ISP_ROLE_NONE) {
879 if (chan == isp->isp_nchan) {
884 isp->isp_state = ISP_INITSTATE;
902 icbp->icb_fwoptions1 = fcp->isp_fwoptions;
903 icbp->icb_fwoptions2 = fcp->isp_xfwoptions;
904 icbp->icb_fwoptions3 = fcp->isp_zfwoptions;
905 if (isp->isp_nchan > 1 && ISP_CAP_VP0(isp)) {
906 icbp->icb_fwoptions1 &= ~ICB2400_OPT1_INI_DISABLE;
907 icbp->icb_fwoptions1 |= ICB2400_OPT1_TGT_ENABLE;
909 if (fcp->role & ISP_ROLE_TARGET)
910 icbp->icb_fwoptions1 |= ICB2400_OPT1_TGT_ENABLE;
912 icbp->icb_fwoptions1 &= ~ICB2400_OPT1_TGT_ENABLE;
913 if (fcp->role & ISP_ROLE_INITIATOR)
914 icbp->icb_fwoptions1 &= ~ICB2400_OPT1_INI_DISABLE;
916 icbp->icb_fwoptions1 |= ICB2400_OPT1_INI_DISABLE;
919 icbp->icb_version = ICB_VERSION1;
920 icbp->icb_maxfrmlen = DEFAULT_FRAMESIZE(isp);
921 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN || icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) {
922 icbp->icb_maxfrmlen = ICB_DFLT_FRMLEN;
924 icbp->icb_maxfrmlen = ICB_DFLT_FRMLEN_28XX;
927 "bad frame length (%d) from NVRAM - using %d",
928 DEFAULT_FRAMESIZE(isp), icbp->icb_maxfrmlen);
932 icbp->icb_execthrottle = 0xffff;
938 if (icbp->icb_fwoptions1 & ICB2400_OPT1_TGT_ENABLE) {
939 if ((icbp->icb_fwoptions1 & ICB2400_OPT1_INI_DISABLE) == 0)
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;
947 icbp->icb_hardaddr = fcp->isp_loopid;
948 if (icbp->icb_hardaddr >= LOCAL_LOOP_LIM) {
949 icbp->icb_hardaddr = 0;
954 icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS;
956 if (isp->isp_confopts & ISP_CFG_NOFCTAPE) {
957 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_FCTAPE;
959 if (isp->isp_confopts & ISP_CFG_FCTAPE) {
960 icbp->icb_fwoptions2 |= ICB2400_OPT2_FCTAPE;
963 for (chan = 0; chan < isp->isp_nchan; chan++) {
964 if (icbp->icb_fwoptions2 & ICB2400_OPT2_FCTAPE)
965 FCPARAM(isp, chan)->fctape_enabled = 1;
967 FCPARAM(isp, chan)->fctape_enabled = 0;
970 switch (isp->isp_confopts & ISP_CFG_PORT_PREF) {
972 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
973 icbp->icb_fwoptions2 |= ICB2400_OPT2_LOOP_ONLY;
976 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
977 icbp->icb_fwoptions2 |= ICB2400_OPT2_PTP_ONLY;
982 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
983 icbp->icb_fwoptions2 |= ICB2400_OPT2_LOOP_2_PTP;
987 switch (icbp->icb_fwoptions2 & ICB2400_OPT2_TOPO_MASK) {
993 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
994 icbp->icb_fwoptions2 |= ICB2400_OPT2_LOOP_2_PTP;
999 switch (icbp->icb_fwoptions2 & ICB2400_OPT2_TIMER_MASK) {
1002 icbp->icb_idelaytimer = 0;
1007 isp_prt(isp, ISP_LOGWARN, "bad value %x in fwopt2 timer field", icbp->icb_fwoptions2 & ICB2400_OPT2_TIMER_MASK);
1008 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TIMER_MASK;
1014 icbp->icb_fwoptions2 |= ICB2400_OPT2_ENA_IHR;
1015 icbp->icb_fwoptions2 |= ICB2400_OPT2_ENA_IHA;
1018 if ((icbp->icb_fwoptions3 & ICB2400_OPT3_RSPSZ_MASK) == 0) {
1019 icbp->icb_fwoptions3 |= ICB2400_OPT3_RSPSZ_24;
1021 if (isp->isp_confopts & ISP_CFG_1GB) {
1022 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
1023 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_1GB;
1024 } else if (isp->isp_confopts & ISP_CFG_2GB) {
1025 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
1026 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_2GB;
1027 } else if (isp->isp_confopts & ISP_CFG_4GB) {
1028 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
1029 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_4GB;
1030 } else if (isp->isp_confopts & ISP_CFG_8GB) {
1031 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
1032 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_8GB;
1033 } else if (isp->isp_confopts & ISP_CFG_16GB) {
1034 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
1035 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_16GB;
1036 } else if (isp->isp_confopts & ISP_CFG_32GB) {
1037 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
1038 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_32GB;
1039 } else if (isp->isp_confopts & ISP_CFG_64GB) {
1040 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
1041 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_64GB;
1043 switch (icbp->icb_fwoptions3 & ICB2400_OPT3_RATE_MASK) {
1052 if (isp->isp_type <= ISP_HA_FC_2500)
1056 if (isp->isp_type <= ISP_HA_FC_2400)
1060 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
1061 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_AUTO;
1066 icbp->icb_fwoptions3 |= ICB2400_OPT3_SOFTID;
1068 icbp->icb_logintime = ICB_LOGIN_TOV;
1070 if (fcp->isp_wwnn && fcp->isp_wwpn) {
1071 icbp->icb_fwoptions1 |= ICB2400_OPT1_BOTH_WWNS;
1072 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_wwpn);
1073 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_wwnn);
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)),
1075 ((uint32_t) (fcp->isp_wwpn >> 32)), ((uint32_t) (fcp->isp_wwpn)));
1076 } else if (fcp->isp_wwpn) {
1077 icbp->icb_fwoptions1 &= ~ICB2400_OPT1_BOTH_WWNS;
1078 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_wwpn);
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)));
1084 icbp->icb_rspnsin = isp->isp_resodx;
1085 icbp->icb_rqstout = isp->isp_reqidx;
1086 icbp->icb_retry_count = fcp->isp_retry_count;
1088 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp);
1089 if (icbp->icb_rqstqlen < 8) {
1090 isp_prt(isp, ISP_LOGERR, "bad request queue length %d", icbp->icb_rqstqlen);
1093 icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp);
1094 if (icbp->icb_rsltqlen < 8) {
1096 icbp->icb_rsltqlen);
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);
1113 if (icbp->icb_atioqlen < 8) {
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) {
1126 icbp->icb_msixresp = 1;
1127 if (IS_26XX(isp) && isp->isp_nirq >= 3)
1128 icbp->icb_msixatio = 2;
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));
1141 ISP_MEMZERO(fcp->isp_scratch, ISP_FC_SCRLEN);
1142 isp_put_icb_2400(isp, icbp, fcp->isp_scratch);
1143 if (isp->isp_dblev & ISP_LOGDEBUG1) {
1145 sizeof (*icbp), fcp->isp_scratch);
1151 if (isp->isp_nchan > 1) {
1160 vpinfo.vp_count = isp->isp_nchan;
1163 vpinfo.vp_count = isp->isp_nchan - 1;
1166 off = fcp->isp_scratch;
1171 for (; chan < isp->isp_nchan; chan++) {
1176 if (fcp2->role != ISP_ROLE_NONE) {
1179 if (fcp2->role & ISP_ROLE_INITIATOR)
1181 if ((fcp2->role & ISP_ROLE_TARGET) == 0)
1183 if (fcp2->isp_loopid < LOCAL_LOOP_LIM) {
1184 pi.vp_port_loopid = fcp2->isp_loopid;
1185 if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
1190 MAKE_NODE_NAME_FROM_WWN(pi.vp_port_portname, fcp2->isp_wwpn);
1191 MAKE_NODE_NAME_FROM_WWN(pi.vp_port_nodename, fcp2->isp_wwnn);
1192 off = fcp->isp_scratch;
1196 off += ICB2400_VPINFO_PORT_OFF(chan - 1);
1201 if (isp->isp_dblev & ISP_LOGDEBUG1) {
1203 amt - ICB2400_VPINFO_OFF,
1204 (char *)fcp->isp_scratch + ICB2400_VPINFO_OFF);
1212 if (isp->isp_nchan > 1) {
1218 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
1219 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
1220 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
1221 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
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));
1234 isp->isp_state = ISP_RUNSTATE;
1253 if (fcp->role & ISP_ROLE_INITIATOR)
1255 if ((fcp->role & ISP_ROLE_TARGET) == 0)
1257 if (fcp->isp_loopid < LOCAL_LOOP_LIM) {
1258 vp.vp_mod_ports[0].loopid = fcp->isp_loopid;
1259 if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
1262 MAKE_NODE_NAME_FROM_WWN(vp.vp_mod_ports[0].wwpn, fcp->isp_wwpn);
1263 MAKE_NODE_NAME_FROM_WWN(vp.vp_mod_ports[0].wwnn, fcp->isp_wwnn);
1295 chan--; /* VP0 can not be controlled in this case. */
1324 if (chan >= isp->isp_nchan) {
1328 if (fcp->role == new_role)
1330 for (was = 0, i = 0; i < isp->isp_nchan; i++) {
1331 if (FCPARAM(isp, i)->role != ISP_ROLE_NONE)
1334 if (was == 0 || (was == 1 && fcp->role != ISP_ROLE_NONE)) {
1335 fcp->role = new_role;
1338 if (fcp->role != ISP_ROLE_NONE) {
1342 fcp->role = new_role;
1343 if (fcp->role != ISP_ROLE_NONE)
1352 fcportdb_t *lp;
1356 lp = &fcp->portdb[i];
1357 switch (lp->state) {
1361 lp->state = FC_PORTDB_STATE_NIL;
1362 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp);
1366 lp->state = FC_PORTDB_STATE_NIL;
1371 panic("Don't know how to clear state %d\n", lp->state);
1380 fcportdb_t *lp;
1384 lp = &fcp->portdb[i];
1385 if (lp->state == FC_PORTDB_STATE_NIL)
1387 if (lp->portid >= DOMAIN_CONTROLLER_BASE &&
1388 lp->portid <= DOMAIN_CONTROLLER_END)
1390 fcp->portdb[i].probational = 1;
1433 return (-1);
1439 retval = -1;
1481 ISP_SNPRINTF(buf, sizeof (buf), "already logged in with N-Port handle 0x%x", parm1);
1503 isp_prt(isp, lev, "Chan %d PLOGX PortID 0x%06x to N-Port handle 0x%x: %s",
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);
1533 isp_get_pdb_24xx(isp, isp->isp_iocb, &un.bill);
1534 pdb->handle = un.bill.pdb_handle;
1535 pdb->prli_word0 = un.bill.pdb_prli_svc0;
1536 pdb->prli_word3 = un.bill.pdb_prli_svc3;
1537 pdb->portid = BITS2WORD_24XX(un.bill.pdb_portid_bits);
1538 ISP_MEMCPY(pdb->portname, un.bill.pdb_portname, 8);
1539 ISP_MEMCPY(pdb->nodename, un.bill.pdb_nodename, 8);
1542 chan, id, pdb->portid, un.bill.pdb_flags,
1570 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
1571 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
1572 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
1573 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
1578 return (-1);
1587 elp4 = fcp->isp_scratch;
1591 if (loop && (p >> 8) != (fcp->isp_portid >> 8))
1661 if (fcp->isp_loopstate < LOOP_HAVE_LINK)
1662 return (-1);
1663 if (fcp->isp_loopstate >= LOOP_LTEST_DONE)
1674 if (fcp->isp_fwstate == FW_READY) {
1677 if (fcp->isp_loopstate < LOOP_HAVE_LINK)
1684 if (fcp->isp_fwstate != FW_READY) {
1687 chan, isp_fc_fw_statename(fcp->isp_fwstate));
1688 return (-1);
1698 return (-1);
1704 fcp->isp_topo = topo;
1705 fcp->isp_portid = mbs.param[2] | (mbs.param[3] << 16);
1707 if (!TOPO_IS_FABRIC(fcp->isp_topo)) {
1708 fcp->isp_loopid = mbs.param[1] & 0xff;
1709 } else if (fcp->isp_topo != TOPO_F_PORT) {
1710 uint8_t alpa = fcp->isp_portid;
1717 fcp->isp_loopid = i;
1721 fcp->isp_loopstate = LOOP_HAVE_ADDR;
1723 fcp->isp_loopstate = LOOP_TESTING_LINK;
1725 if (fcp->isp_topo == TOPO_F_PORT || fcp->isp_topo == TOPO_FL_PORT) {
1730 fcp->isp_topo = TOPO_PTP_STUB;
1734 fcp->isp_fabric_params = mbs.param[7];
1735 fcp->isp_sns_hdl = NPH_SNS_ID;
1737 if (fcp->isp_loopstate < LOOP_TESTING_LINK)
1742 if (fcp->isp_loopstate < LOOP_TESTING_LINK)
1747 if (fcp->isp_loopstate < LOOP_TESTING_LINK)
1752 if (fcp->isp_loopstate < LOOP_TESTING_LINK)
1758 fcp->isp_gbspeed = 1;
1761 /* mbs.param[2] undefined if we're just getting rate */
1765 fcp->isp_gbspeed = 10;
1767 fcp->isp_gbspeed = 64;
1769 fcp->isp_gbspeed = 32;
1771 fcp->isp_gbspeed = 16;
1773 fcp->isp_gbspeed = 8;
1775 fcp->isp_gbspeed = 4;
1777 fcp->isp_gbspeed = 2;
1779 fcp->isp_gbspeed = 1;
1782 if (fcp->isp_loopstate < LOOP_TESTING_LINK) {
1788 fcp->isp_loopstate = LOOP_LTEST_DONE;
1791 chan, (uintmax_t)fcp->isp_wwpn, (uintmax_t)fcp->isp_wwnn);
1794 chan, fcp->isp_gbspeed, isp_fc_toponame(fcp), fcp->isp_portid,
1795 fcp->isp_loopid);
1815 fcportdb_t *lp;
1818 if (fcp->isp_loopstate < LOOP_FSCAN_DONE)
1819 return (-1);
1820 if (fcp->isp_loopstate >= LOOP_READY)
1825 fcp->isp_loopstate = LOOP_SYNCING_PDB;
1828 lp = &fcp->portdb[dbidx];
1830 if (lp->state == FC_PORTDB_STATE_NIL)
1832 if (lp->probational && lp->state != FC_PORTDB_STATE_ZOMBIE)
1833 lp->state = FC_PORTDB_STATE_DEAD;
1834 switch (lp->state) {
1836 lp->state = FC_PORTDB_STATE_NIL;
1837 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp);
1838 if ((lp->portid & 0xffff00) != 0) {
1839 (void) isp_plogx(isp, chan, lp->handle,
1840 lp->portid,
1851 lp->state = FC_PORTDB_STATE_VALID;
1852 isp_async(isp, ISPASYNC_DEV_ARRIVED, chan, lp);
1855 lp->state = FC_PORTDB_STATE_VALID;
1856 isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp);
1857 lp->portid = lp->new_portid;
1858 lp->prli_word0 = lp->new_prli_word0;
1859 lp->prli_word3 = lp->new_prli_word3;
1862 isp_async(isp, ISPASYNC_DEV_STAYED, chan, lp);
1869 lp->state, dbidx);
1874 if (fcp->isp_loopstate < LOOP_SYNCING_PDB) {
1880 fcp->isp_loopstate = LOOP_READY;
1888 fcportdb_t *lp;
1891 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb->nodename);
1892 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb->portname);
1895 if (isp_find_pdb_by_wwpn(isp, chan, wwpn, &lp)) {
1896 if (!lp->probational) {
1899 chan, lp->portid, lp->handle,
1900 FC_PORTDB_TGT(isp, chan, lp), lp->state);
1904 lp->probational = 0;
1905 lp->node_wwn = wwnn;
1908 if (lp->portid == pdb->portid &&
1909 lp->handle == pdb->handle &&
1910 lp->prli_word3 == pdb->prli_word3 &&
1911 ((pdb->prli_word0 & PRLI_WD0_EST_IMAGE_PAIR) ==
1912 (lp->prli_word0 & PRLI_WD0_EST_IMAGE_PAIR))) {
1913 if (lp->state != FC_PORTDB_STATE_NEW)
1914 lp->state = FC_PORTDB_STATE_VALID;
1917 chan, pdb->portid, pdb->handle);
1922 lp->state = FC_PORTDB_STATE_CHANGED;
1923 lp->handle = pdb->handle;
1924 lp->new_portid = pdb->portid;
1925 lp->new_prli_word0 = pdb->prli_word0;
1926 lp->new_prli_word3 = pdb->prli_word3;
1929 chan, pdb->portid, pdb->handle);
1934 if (!isp_find_pdb_empty(isp, chan, &lp)) {
1939 ISP_MEMZERO(lp, sizeof (fcportdb_t));
1940 lp->probational = 0;
1941 lp->state = FC_PORTDB_STATE_NEW;
1942 lp->portid = lp->new_portid = pdb->portid;
1943 lp->prli_word0 = lp->new_prli_word0 = pdb->prli_word0;
1944 lp->prli_word3 = lp->new_prli_word3 = pdb->prli_word3;
1945 lp->handle = pdb->handle;
1946 lp->port_wwn = wwpn;
1947 lp->node_wwn = wwnn;
1949 chan, pdb->portid, pdb->handle);
1964 if (fcp->isp_loopstate < LOOP_LTEST_DONE)
1965 return (-1);
1966 if (fcp->isp_loopstate >= LOOP_LSCAN_DONE)
1970 fcp->isp_loopstate = LOOP_SCANNING_LOOP;
1971 if (TOPO_IS_FABRIC(fcp->isp_topo)) {
1974 fcp->isp_loopstate = LOOP_LSCAN_DONE;
1978 handles = (uint16_t *)fcp->isp_scanscratch;
1986 return (-1);
2009 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
2024 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
2026 fcp->isp_loopstate = LOOP_LSCAN_DONE;
2038 if (isp->isp_dblev & ISP_LOGDEBUG1)
2039 isp_print_bytes(isp, "CT request", cmd_bcnt, fcp->isp_scratch);
2047 pt.ctp_nphdl = fcp->isp_sns_hdl;
2054 pt.ctp_dataseg[0].ds_base = DMA_LO32(fcp->isp_scdma);
2055 pt.ctp_dataseg[0].ds_basehi = DMA_HI32(fcp->isp_scdma);
2057 pt.ctp_dataseg[1].ds_base = DMA_LO32(fcp->isp_scdma);
2058 pt.ctp_dataseg[1].ds_basehi = DMA_HI32(fcp->isp_scdma);
2070 "Chan %d CT pass-through returned 0x%x",
2072 return (-1);
2075 if (isp->isp_dblev & ISP_LOGDEBUG1)
2076 isp_print_bytes(isp, "CT response", rsp_bcnt, fcp->isp_scratch);
2087 * We use CT Pass-through IOCB.
2090 #define NGENT ((GIDLEN - 16) >> 2)
2097 uint8_t *scp = fcp->isp_scratch;
2102 return (-1);
2105 /* Build the CT command and execute via pass-through. */
2111 ct.ct_bcnt_resid = (GIDLEN - 16) >> 2;
2120 return (-1);
2124 (sns_gid_xx_rsp_t *)fcp->isp_scanscratch, NGENT);
2135 uint8_t *scp = fcp->isp_scratch;
2137 int i, res = -1;
2139 if (!fcp->isp_use_gff_id) /* User may block GFF_ID use. */
2148 /* Build the CT command and execute via pass-through. */
2154 ct.ct_bcnt_resid = (SNS_GFF_ID_RESP_SIZE - sizeof(ct)) / 4;
2192 uint8_t *scp = fcp->isp_scratch;
2194 int i, res = -1;
2196 if (!fcp->isp_use_gft_id) /* User may block GFT_ID use. */
2205 /* Build the CT command and execute via pass-through. */
2211 ct.ct_bcnt_resid = (SNS_GFT_ID_RESP_SIZE - sizeof(ct)) / 4;
2243 fcportdb_t *lp;
2249 if (fcp->isp_loopstate < LOOP_LSCAN_DONE)
2250 return (-1);
2251 if (fcp->isp_loopstate >= LOOP_FSCAN_DONE)
2255 fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
2256 if (!TOPO_IS_FABRIC(fcp->isp_topo)) {
2257 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2263 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
2279 fcp->isp_loopstate = LOOP_LTEST_DONE;
2283 return (-1);
2288 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC)
2291 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2292 return (-1);
2294 fcp->isp_loopstate = LOOP_LTEST_DONE; /* try again */
2295 return (-1);
2298 rs = (sns_gid_xx_rsp_t *) fcp->isp_scanscratch;
2299 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC)
2301 if (rs->snscb_cthdr.ct_cmd_resp != LS_ACC) {
2303 /* FC-4 Type and Port Type not registered are not errors. */
2304 if (rs->snscb_cthdr.ct_reason == 9 &&
2305 (rs->snscb_cthdr.ct_explanation == 0x07 ||
2306 rs->snscb_cthdr.ct_explanation == 0x0a)) {
2313 rs->snscb_cthdr.ct_reason,
2314 rs->snscb_cthdr.ct_explanation);
2315 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2316 return (-1);
2320 for (portidx = 0; portidx < NGENT-1; portidx++) {
2321 if (rs->snscb_ports[portidx].control & 0x80)
2324 if ((rs->snscb_ports[portidx].control & 0x80) == 0) {
2337 ((rs->snscb_ports[portidx].portid[0]) << 16) |
2338 ((rs->snscb_ports[portidx].portid[1]) << 8) |
2339 ((rs->snscb_ports[portidx].portid[2]));
2343 ((rs->snscb_ports[npidx].portid[0]) << 16) |
2344 ((rs->snscb_ports[npidx].portid[1]) << 8) |
2345 ((rs->snscb_ports[npidx].portid[2]));
2352 rs->snscb_ports[npidx].portid[0] = 0;
2353 rs->snscb_ports[npidx].portid[1] = 0;
2354 rs->snscb_ports[npidx].portid[2] = 0;
2364 * for probational entries- if we find one, then an old entry is
2375 portid = ((rs->snscb_ports[portidx].portid[0]) << 16) |
2376 ((rs->snscb_ports[portidx].portid[1]) << 8) |
2377 ((rs->snscb_ports[portidx].portid[2]));
2386 if (portid == fcp->isp_portid) {
2393 if (isp_find_pdb_by_portid(isp, chan, portid, &lp)) {
2394 if (!lp->probational) {
2397 chan, lp->portid, lp->handle,
2398 FC_PORTDB_TGT(isp, chan, lp), lp->state);
2403 if (lp->state == FC_PORTDB_STATE_ZOMBIE)
2421 r = isp_getpdb(isp, chan, lp->handle, &pdb);
2422 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC)
2425 lp->state = FC_PORTDB_STATE_DEAD;
2428 chan, portid, lp->handle, r);
2437 if ((fcp->role & ISP_ROLE_INITIATOR) == 0) {
2458 &FCPARAM(isp, 0)->isp_lasthdl)) {
2459 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC)
2467 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC)
2469 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2485 if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC)
2486 return (-1);
2491 if (p->portid != portid) {
2498 if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC)
2499 return (-1);
2516 if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC)
2517 return (-1);
2534 return (-1);
2545 return (-1);
2548 if (p->handle != handle || p->portid != portid) {
2550 chan, portid, handle, p->portid, p->handle);
2551 return (-1);
2562 uint8_t *scp = fcp->isp_scratch;
2566 return (-1);
2569 /* Build the CT command and execute via pass-through. */
2571 ct->ct_revision = CT_REVISION;
2572 ct->ct_fcs_type = CT_FC_TYPE_FC;
2573 ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS;
2574 ct->ct_cmd_resp = SNS_RFT_ID;
2575 ct->ct_bcnt_resid = (sizeof (rft_id_t) - sizeof (ct_hdr_t)) >> 2;
2576 rp.rftid_portid[0] = fcp->isp_portid >> 16;
2577 rp.rftid_portid[1] = fcp->isp_portid >> 8;
2578 rp.rftid_portid[2] = fcp->isp_portid;
2584 return (-1);
2589 if (ct->ct_cmd_resp == LS_RJT) {
2591 return (-1);
2592 } else if (ct->ct_cmd_resp == LS_ACC) {
2595 isp_prt(isp, ISP_LOGWARN, "Chan %d Register FC4 Type: 0x%x", chan, ct->ct_cmd_resp);
2596 return (-1);
2607 uint8_t *scp = fcp->isp_scratch;
2611 return (-1);
2619 ct->ct_revision = CT_REVISION;
2620 ct->ct_fcs_type = CT_FC_TYPE_FC;
2621 ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS;
2622 ct->ct_cmd_resp = SNS_RFF_ID;
2623 ct->ct_bcnt_resid = (sizeof (rff_id_t) - sizeof (ct_hdr_t)) >> 2;
2624 rp.rffid_portid[0] = fcp->isp_portid >> 16;
2625 rp.rffid_portid[1] = fcp->isp_portid >> 8;
2626 rp.rffid_portid[2] = fcp->isp_portid;
2628 if (fcp->role & ISP_ROLE_TARGET)
2630 if (fcp->role & ISP_ROLE_INITIATOR)
2634 if (isp->isp_dblev & ISP_LOGDEBUG1)
2639 return (-1);
2644 if (ct->ct_cmd_resp == LS_RJT) {
2647 return (-1);
2648 } else if (ct->ct_cmd_resp == LS_ACC) {
2653 "Chan %d Register FC4 Features: 0x%x", chan, ct->ct_cmd_resp);
2654 return (-1);
2665 uint8_t *scp = fcp->isp_scratch;
2670 return (-1);
2678 ct->ct_revision = CT_REVISION;
2679 ct->ct_fcs_type = CT_FC_TYPE_FC;
2680 ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS;
2681 ct->ct_cmd_resp = SNS_RSPN_ID;
2682 rp.rspnid_portid[0] = fcp->isp_portid >> 16;
2683 rp.rspnid_portid[1] = fcp->isp_portid >> 8;
2684 rp.rspnid_portid[2] = fcp->isp_portid;
2692 ":%s", device_get_nameunit(isp->isp_dev));
2698 ct->ct_bcnt_resid = (len - sizeof(ct_hdr_t)) >> 2;
2703 return (-1);
2708 if (ct->ct_cmd_resp == LS_RJT) {
2711 return (-1);
2712 } else if (ct->ct_cmd_resp == LS_ACC) {
2717 "Chan %d Register Symbolic Port Name: 0x%x", chan, ct->ct_cmd_resp);
2718 return (-1);
2729 uint8_t *scp = fcp->isp_scratch;
2734 return (-1);
2742 ct->ct_revision = CT_REVISION;
2743 ct->ct_fcs_type = CT_FC_TYPE_FC;
2744 ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS;
2745 ct->ct_cmd_resp = SNS_RSNN_NN;
2746 MAKE_NODE_NAME_FROM_WWN(rp.rsnnnn_nodename, fcp->isp_wwnn);
2754 ct->ct_bcnt_resid = (len - sizeof(ct_hdr_t)) >> 2;
2759 return (-1);
2764 if (ct->ct_cmd_resp == LS_RJT) {
2767 return (-1);
2768 } else if (ct->ct_cmd_resp == LS_ACC) {
2773 "Chan %d Register Symbolic Node Name: 0x%x", chan, ct->ct_cmd_resp);
2774 return (-1);
2794 if (handle > NPH_RESERVED - 1) {
2802 for (chan = 0; chan < isp->isp_nchan; chan++) {
2804 if (fcp->role == ISP_ROLE_NONE)
2807 if (fcp->portdb[i].state != FC_PORTDB_STATE_NIL &&
2808 fcp->portdb[i].handle == handle)
2828 fcportdb_t *lp;
2854 if ((fcp->role & ISP_ROLE_INITIATOR) == 0) {
2862 if (isp->isp_state != ISP_RUNSTATE) {
2869 lp = &fcp->portdb[target];
2871 lp->is_target == 0) {
2875 if (fcp->isp_loopstate != LOOP_READY) {
2881 if (lp->state == FC_PORTDB_STATE_ZOMBIE) {
2887 if (lp->state != FC_PORTDB_STATE_VALID) {
2890 XS_CHANNEL(xs), target, (uintmax_t)XS_LUN(xs), lp->state);
2913 m->mrk_header.rqs_entry_count = 1;
2914 m->mrk_header.rqs_entry_type = RQSTYPE_MARKER;
2915 m->mrk_modifier = SYNC_ALL;
2916 m->mrk_vphdl = XS_CHANNEL(xs);
2927 if (cdblen > sizeof (reqp->req_cdb)) {
2933 reqp->req_header.rqs_entry_type = RQSTYPE_T7RQS;
2934 reqp->req_header.rqs_entry_count = 1;
2935 reqp->req_nphdl = lp->handle;
2936 reqp->req_time = XS_TIME(xs);
2937 be64enc(reqp->req_lun, CAM_EXTLUN_BYTE_SWIZZLE(XS_LUN(xs)));
2939 reqp->req_alen_datadir = FCP_CMND_DATA_READ;
2941 reqp->req_alen_datadir = FCP_CMND_DATA_WRITE;
2943 reqp->req_task_attribute = XS_TAG_TYPE(xs);
2945 reqp->req_task_attribute = FCP_CMND_TASK_ATTR_SIMPLE;
2946 reqp->req_task_attribute |= (XS_PRIORITY(xs) << FCP_CMND_PRIO_SHIFT) &
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)) {
2957 ISP_MEMCPY(reqp->req_cdb, XS_CDBP(xs), cdblen);
2958 reqp->req_dl = XS_XFRLEN(xs);
2959 reqp->req_tidlo = lp->portid;
2960 reqp->req_tidhi = lp->portid >> 16;
2961 reqp->req_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(xs));
2964 reqp->req_handle = isp_allocate_handle(isp, xs, ISP_HANDLE_INITIATOR);
2965 if (reqp->req_handle == 0) {
2979 isp_destroy_handle(isp, reqp->req_handle);
2999 fcportdb_t *lp;
3030 lp = &fcp->portdb[tgt];
3031 if (lp->is_target == 0 || lp->state != FC_PORTDB_STATE_VALID) {
3038 tmf->tmf_header.rqs_entry_type = RQSTYPE_TSK_MGMT;
3039 tmf->tmf_header.rqs_entry_count = 1;
3040 tmf->tmf_nphdl = lp->handle;
3041 tmf->tmf_delay = 2;
3042 tmf->tmf_timeout = 4;
3043 tmf->tmf_flags = ISP24XX_TMF_TARGET_RESET;
3044 tmf->tmf_tidlo = lp->portid;
3045 tmf->tmf_tidhi = lp->portid >> 16;
3046 tmf->tmf_vpidx = ISP_GET_VPIDX(isp, chan);
3047 fcp->sendmarker = 1;
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))
3054 if (sp->req_completion_status == 0)
3056 isp_prt(isp, ISP_LOGWARN, "Chan %d reset of target %d returned 0x%x", chan, tgt, sp->req_completion_status);
3081 lp = &fcp->portdb[tgt];
3082 if (lp->is_target == 0 || lp->state != FC_PORTDB_STATE_VALID) {
3086 isp_prt(isp, ISP_LOGALL, "Chan %d Abort Cmd for N-Port 0x%04x @ Port 0x%06x", chan, lp->handle, lp->portid);
3088 ab->abrt_header.rqs_entry_type = RQSTYPE_ABORT_IO;
3089 ab->abrt_header.rqs_entry_count = 1;
3090 ab->abrt_handle = lp->handle;
3091 ab->abrt_cmd_handle = handle;
3092 ab->abrt_tidlo = lp->portid;
3093 ab->abrt_tidhi = lp->portid >> 16;
3094 ab->abrt_vpidx = ISP_GET_VPIDX(isp, chan);
3099 if (ab->abrt_nphdl == ISP24XX_ABRT_OKAY)
3101 isp_prt(isp, ISP_LOGWARN, "Chan %d handle %d abort returned 0x%x", chan, tgt, ab->abrt_nphdl);
3193 if ((p->flags & PLOGX_FLG_CMD_MASK) != PLOGX_FLG_CMD_PLOGI || (p->handle != NIL_HANDLE)) {
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);
3200 p->handle = r >> 16;
3222 return (-1);
3240 optr = isp->isp_atioodx;
3243 MEMORYBARRIER(isp, SYNC_ATIOQ, oop, QENTRY_LEN, -1);
3244 addr = ISP_QUEUE_ENTRY(isp->isp_atioq, oop);
3245 switch (((isphdr_t *)addr)->rqs_entry_type) {
3260 if (isp->isp_atioodx != optr) {
3262 isp->isp_atioodx = optr;
3272 if (!isp->isp_mboxbsy) {
3276 obits = isp->isp_obits;
3277 isp->isp_mboxtmp[0] = mbox0;
3281 isp->isp_mboxtmp[i] = ISP_READ(isp, MBOX_OFF(i));
3283 isp->isp_mboxbsy = 0;
3304 if (isp->isp_state != ISP_RUNSTATE) {
3310 optr = isp->isp_resodx;
3316 hp = (isphdr_t *) ISP_QUEUE_ENTRY(isp->isp_result, cptr);
3322 MEMORYBARRIER(isp, SYNC_RESULT, cptr, QENTRY_LEN, -1);
3323 if (isp->isp_dblev & ISP_LOGDEBUG1)
3325 isp_get_hdr(isp, hp, &sp->req_header);
3331 if (sp->req_header.rqs_flags & RQSFLAG_BADTYPE) {
3335 if (sp->req_header.rqs_flags & RQSFLAG_BADPARAM) {
3339 if (sp->req_header.rqs_flags & RQSFLAG_BADCOUNT) {
3343 if (sp->req_header.rqs_flags & RQSFLAG_BADORDER) {
3348 etype = sp->req_header.rqs_entry_type;
3372 slen = min(cont, sizeof(scp->req_sense_data));
3373 XS_SENSE_APPEND(cont_xs, scp->req_sense_data, slen);
3374 cont -= slen;
3397 hp = (isphdr_t *)ISP_QUEUE_ENTRY(isp->isp_result, sptr);
3408 /* We don't know what was this -- log and skip. */
3414 xs = isp_find_xs(isp, sp->req_handle);
3420 if (sp->req_completion_status != RQCS_ABORTED &&
3421 sp->req_completion_status != RQCS_RESET_OCCURRED)
3423 sp->req_handle, sp->req_completion_status);
3428 resp = snsp = sp->req_rsp_sense;
3430 scsi_status = sp->req_scsi_status;
3432 rlen = sp->req_response_len;
3436 totslen = sp->req_sense_len;
3437 slen = MIN(totslen, sizeof(sp->req_rsp_sense) - rlen);
3441 XS_SET_RESID(xs, sp->req_fcp_residual);
3479 cont = totslen - slen;
3488 isp_destroy_handle(isp, sp->req_handle);
3501 if (optr != isp->isp_resodx) {
3503 isp->isp_resodx = optr;
3518 isp->isp_state = ISP_CRASHED;
3519 for (chan = 0; chan < isp->isp_nchan; chan++) {
3520 FCPARAM(isp, chan)->isp_loopstate = LOOP_NIL;
3527 if (isp->isp_mboxbsy) {
3528 isp->isp_obits = 1;
3529 isp->isp_mboxtmp[0] = MBOX_HOST_INTERFACE_ERROR;
3530 isp->isp_mboxbsy = 0;
3559 for (chan = 0; chan < isp->isp_nchan; chan++) {
3561 int topo = fcp->isp_topo;
3563 if (fcp->role == ISP_ROLE_NONE)
3565 if (fcp->isp_loopstate > LOOP_HAVE_LINK)
3566 fcp->isp_loopstate = LOOP_HAVE_LINK;
3585 hdp = &isp->isp_xflist[i];
3586 if (ISP_H2HT(hdp->handle) != ISP_HANDLE_INITIATOR) {
3589 xs = hdp->cmd;
3613 for (chan = 0; chan < isp->isp_nchan; chan++) {
3615 if (fcp->role == ISP_ROLE_NONE)
3617 fcp->isp_linkstate = 1;
3618 if (fcp->isp_loopstate < LOOP_HAVE_LINK)
3619 fcp->isp_loopstate = LOOP_HAVE_LINK;
3633 for (chan = 0; chan < isp->isp_nchan; chan++) {
3635 if (fcp->role == ISP_ROLE_NONE)
3638 fcp->isp_linkstate = 0;
3639 fcp->isp_loopstate = LOOP_NIL;
3652 for (chan = 0; chan < isp->isp_nchan; chan++) {
3654 if (fcp->role == ISP_ROLE_NONE)
3657 if (fcp->isp_loopstate > LOOP_HAVE_LINK)
3658 fcp->isp_loopstate = LOOP_HAVE_LINK;
3677 echan = isp->isp_nchan - 1;
3678 } else if (chan >= isp->isp_nchan) {
3688 if (fcp->role == ISP_ROLE_NONE)
3690 if (fcp->isp_loopstate > LOOP_LTEST_DONE) {
3692 nphdl == fcp->isp_login_hdl &&
3695 fcp->isp_loopstate = LOOP_LTEST_DONE;
3696 } else if (fcp->isp_loopstate < LOOP_HAVE_LINK)
3697 fcp->isp_loopstate = LOOP_HAVE_LINK;
3711 if (chan >= isp->isp_nchan)
3717 if (fcp->role == ISP_ROLE_NONE)
3719 if (fcp->isp_loopstate > LOOP_LTEST_DONE)
3720 fcp->isp_loopstate = LOOP_LTEST_DONE;
3721 else if (fcp->isp_loopstate < LOOP_HAVE_LINK)
3722 fcp->isp_loopstate = LOOP_HAVE_LINK;
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");
3788 switch (hp->rqs_entry_type) {
3827 for (chan = 0; chan < isp->isp_nchan; chan++) {
3829 if (fcp->role == ISP_ROLE_NONE)
3831 c = (chan == 0) ? 127 : (chan - 1);
3834 fcp->isp_loopstate = LOOP_HAVE_LINK;
3838 fcp->isp_loopstate = LOOP_NIL;
3847 fcp->isp_topo = (rid.ridacq_map[0] >> 9) & 0x7;
3848 fcp->isp_portid = portid;
3849 fcp->isp_loopstate = LOOP_HAVE_ADDR;
3853 fcp->isp_loopstate = LOOP_NIL;
3866 switch (sp->req_completion_status) {
3884 FCPARAM(isp, chan)->sendmarker = 1;
3891 FCPARAM(isp, chan)->sendmarker = 1;
3903 XS_SET_RESID(xs, sp->req_resid);
3922 ru_marked = (sp->req_scsi_status & RQCS_RU) != 0;
3925 * if we got a non-zero status.
3927 sv_marked = (sp->req_scsi_status & (RQCS_SV|RQCS_RV)) != 0;
3929 (sp->req_resid > XS_XFRLEN(xs))) {
3930 isp_xs_prt(isp, xs, ISP_LOGWARN, bun, XS_XFRLEN(xs), sp->req_resid, (ru_marked)? "marked" : "not marked");
3935 XS_SET_RESID(xs, sp->req_resid);
3936 isp_xs_prt(isp, xs, ISP_LOG_WARN1, "Data Underrun (%d) for command 0x%x", sp->req_resid, XS_CDBP(xs)[0] & 0xff);
3946 uint8_t sts = sp->req_completion_status & 0xff;
3948 fcportdb_t *lp;
3951 * It was there (maybe)- treat as a selection timeout.
3965 lp = &fcp->portdb[XS_TGT(xs)];
3966 if (lp->state == FC_PORTDB_STATE_ZOMBIE) {
3999 isp_prt(isp, ISP_LOGERR, "Unknown Completion Status 0x%x on chan %d", sp->req_completion_status, chan);
4152 "NO-OP", /* 00h */
4245 "GET/SET DATA RATE",
4251 "GET FC-AL POSITION MAP",
4288 opcode = mbp->param[0];
4290 mbp->param[0] = MBOX_INVALID_COMMAND;
4306 ibits |= mbp->ibits;
4307 obits |= mbp->obits;
4312 ibits &= mbp->ibitm;
4313 obits &= mbp->obitm;
4317 mbp->param[0] = MBOX_COMMAND_PARAM_ERROR;
4325 mbp->param[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;
4342 to = (mbp->timeout == 0) ? MBCMD_DEFAULT_TIMEOUT : mbp->timeout;
4344 if (!isp->isp_mboxbsy)
4347 if (!isp->isp_mboxbsy)
4355 if (isp->isp_mboxbsy) {
4356 isp->isp_mboxbsy = 0;
4358 opcode, to, mbp->func, mbp->lineno);
4359 mbp->param[0] = MBOX_TIMEOUT;
4368 mbp->param[box] = isp->isp_mboxtmp[box];
4370 mbp->param[box]);
4375 if (mbp->logval == 0 || mbp->param[0] == MBOX_COMMAND_COMPLETE)
4378 if ((mbp->param[0] & 0xbfe0) == 0 &&
4379 (mbp->logval & MBLOGMASK(mbp->param[0])) == 0)
4384 switch (mbp->param[0]) {
4397 mbp->param[1]);
4434 ISP_SNPRINTF(mname, sizeof(mname), "error 0x%x", mbp->param[0]);
4464 fcp->role = DEFAULT_ROLE(isp, chan);
4465 fcp->isp_retry_delay = ICB_DFLT_RDELAY;
4466 fcp->isp_retry_count = ICB_DFLT_RCOUNT;
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);
4470 fcp->isp_fwoptions = 0;
4471 fcp->isp_xfwoptions = 0;
4472 fcp->isp_zfwoptions = 0;
4473 fcp->isp_lasthdl = NIL_HANDLE;
4474 fcp->isp_login_hdl = NIL_HANDLE;
4476 fcp->isp_fwoptions |= ICB2400_OPT1_FAIRNESS;
4477 fcp->isp_fwoptions |= ICB2400_OPT1_HARD_ADDRESS;
4478 if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX)
4479 fcp->isp_fwoptions |= ICB2400_OPT1_FULL_DUPLEX;
4480 fcp->isp_fwoptions |= ICB2400_OPT1_BOTH_WWNS;
4481 fcp->isp_xfwoptions |= ICB2400_OPT2_LOOP_2_PTP;
4482 fcp->isp_zfwoptions |= ICB2400_OPT3_RATE_AUTO;
4488 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
4500 isp->isp_confopts |= ISP_CFG_NONVRAM;
4504 fcp->isp_wwnn = ACTIVE_NODEWWN(isp, chan);
4505 fcp->isp_wwpn = ACTIVE_PORTWWN(isp, chan);
4507 chan, (uint32_t) (fcp->isp_wwnn >> 32), (uint32_t) (fcp->isp_wwnn),
4508 (uint32_t) (fcp->isp_wwpn >> 32), (uint32_t) (fcp->isp_wwpn),
4509 isp_class3_roles[fcp->role]);
4513 * Re-initialize the ISP and complete all orphaned commands
4523 if (isp->isp_state > ISP_RESETSTATE)
4525 if (isp->isp_state != ISP_RESETSTATE)
4527 if (isp->isp_state != ISP_RESETSTATE) {
4534 if (isp->isp_state > ISP_RESETSTATE &&
4535 isp->isp_state != ISP_RUNSTATE) {
4543 for (i = 0; i < isp->isp_nchan; i++)
4556 return (fcp->flash_data_addr + faddr);
4601 uint32_t base = fcp->flash_data_addr;
4626 addr = fcp->flt_region_flt;
4640 retval = -1;
4655 fcp->flt_length = le16toh((uint16_t) (ISP2XXX_FLT_LENGTH(flthdr_data)));
4658 if ((fcp->flt_length == 0) ||
4659 (fcp->flt_length > (FLT_HEADER_SIZE + FLT_REGIONS_SIZE))) {
4662 fcp->flt_length, fcp->flt_length);
4666 ver, fcp->flt_length, fcp->flt_length, csum);
4674 int len = fcp->flt_length - FLT_HEADER_SIZE;
4677 fcp->flt_region_entries = len / FLT_REGION_SIZE;
4679 addr = fcp->flt_region_flt + (FLT_HEADER_SIZE >> 2);
4682 fcp->flt_region_entries);
4695 struct flt_region region[fcp->flt_region_entries];
4697 for (count = 0; count < fcp->flt_region_entries; count++) {
4718 fcp->flt_region_fw = region[count].start;
4721 fcp->flt_region_boot = region[count].start;
4724 fcp->flt_region_vpd_nvram = region[count].start;
4725 if (isp->isp_port == 0)
4726 fcp->flt_region_vpd = region[count].start;
4729 if (isp->isp_port == 1)
4730 fcp->flt_region_vpd = region[count].start;
4735 if (isp->isp_port == 2)
4736 fcp->flt_region_vpd = region[count].start;
4741 if (isp->isp_port == 3)
4742 fcp->flt_region_vpd = region[count].start;
4745 if (isp->isp_port == 0)
4746 fcp->flt_region_nvram = region[count].start;
4749 if (isp->isp_port == 1)
4750 fcp->flt_region_nvram = region[count].start;
4755 if (isp->isp_port == 2)
4756 fcp->flt_region_nvram = region[count].start;
4761 if (isp->isp_port == 3)
4762 fcp->flt_region_nvram = region[count].start;
4765 fcp->flt_region_fdt = region[count].start;
4768 fcp->flt_region_flt = region[count].start;
4771 if (isp->isp_port == 0)
4772 fcp->flt_region_npiv_conf = region[count].start;
4775 if (isp->isp_port == 1)
4776 fcp->flt_region_npiv_conf = region[count].start;
4779 fcp->flt_region_gold_fw = region[count].start;
4782 if (isp->isp_port == 0)
4783 fcp->flt_region_fcp_prio = region[count].start;
4786 if (isp->isp_port == 1)
4787 fcp->flt_region_fcp_prio = region[count].start;
4791 fcp->flt_region_img_status_pri = region[count].start;
4795 fcp->flt_region_img_status_sec = region[count].start;
4799 fcp->flt_region_fw_sec = region[count].start;
4803 fcp->flt_region_boot_sec = region[count].start;
4807 fcp->flt_region_aux_img_status_pri = region[count].start;
4811 fcp->flt_region_aux_img_status_sec = region[count].start;
4815 if (isp->isp_port == 0)
4816 fcp->flt_region_nvram_sec = region[count].start;
4820 if (isp->isp_port == 1)
4821 fcp->flt_region_nvram_sec = region[count].start;
4825 if (isp->isp_port == 2)
4826 fcp->flt_region_nvram_sec = region[count].start;
4830 if (isp->isp_port == 3)
4831 fcp->flt_region_nvram_sec = region[count].start;
4836 fcp->flt_region_vpd_nvram_sec = region[count].start;
4837 if (isp->isp_port == 0)
4838 fcp->flt_region_vpd_sec = region[count].start;
4844 if (isp->isp_port == 1)
4845 fcp->flt_region_vpd_sec = region[count].start;
4850 if (isp->isp_port == 2)
4851 fcp->flt_region_vpd_sec = region[count].start;
4856 if (isp->isp_port == 3)
4857 fcp->flt_region_vpd_sec = region[count].start;
4864 fcp->flt_region_boot, fcp->flt_region_fw, fcp->flt_region_vpd_nvram,
4865 fcp->flt_region_vpd, fcp->flt_region_nvram, fcp->flt_region_fdt,
4866 fcp->flt_region_flt, fcp->flt_region_npiv_conf,
4867 fcp->flt_region_fcp_prio);
4878 image_status->image_status_mask,
4879 le16toh(image_status->generation),
4880 image_status->ver_major,
4881 image_status->ver_minor,
4882 image_status->bitmap,
4883 le32toh(image_status->checksum),
4884 le32toh(image_status->signature));
4890 unsigned long signature = le32toh(image_status->signature);
4898 unsigned long signature = le32toh(image_status->signature);
4911 for ( ; n--; p++)
4920 return (aux->bitmap & bitmask ?
4927 active_regions->aux.board_config =
4930 active_regions->aux.vpd_nvram =
4933 active_regions->aux.npiv_config_0_1 =
4936 active_regions->aux.npiv_config_2_3 =
4939 active_regions->aux.nvme_params =
4950 le16toh(pri_image_status->generation) -
4951 le16toh(sec_image_status->generation);
4966 if (!fcp->flt_region_aux_img_status_pri) {
4973 fcp->flt_region_aux_img_status_pri,
4999 if (!fcp->flt_region_aux_img_status_sec) {
5006 fcp->flt_region_aux_img_status_sec,
5050 active_regions->aux.board_config,
5051 active_regions->aux.vpd_nvram,
5052 active_regions->aux.npiv_config_0_1,
5053 active_regions->aux.npiv_config_2_3,
5054 active_regions->aux.nvme_params);
5065 if (!fcp->flt_region_img_status_pri) {
5072 fcp->flt_region_img_status_pri, sizeof(pri_image_status) >> 2) !=
5100 if (!fcp->flt_region_img_status_sec) {
5107 fcp->flt_region_img_status_sec, sizeof(sec_image_status) >> 2) !=
5135 active_regions->global = ISP27XX_PRIMARY_IMAGE;
5138 if (!active_regions->global ||
5141 active_regions->global = ISP27XX_SECONDARY_IMAGE;
5146 active_regions->global == ISP27XX_DEFAULT_IMAGE ?
5148 active_regions->global == ISP27XX_PRIMARY_IMAGE ?
5150 active_regions->global == ISP27XX_SECONDARY_IMAGE ?
5152 active_regions->global);
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);
5205 dcode = isp->isp_rquest;
5208 snprintf(fcp->fw_version_flash, sizeof(fcp->fw_version_flash),
5218 fcp->fw_flashrev[i] = be32toh(dcode[4 + i]);
5219 snprintf(fcp->fw_version_flash, sizeof(fcp->fw_version_flash),
5220 "%u.%u.%u", fcp->fw_flashrev[0], fcp->fw_flashrev[1],
5221 fcp->fw_flashrev[2]);
5224 fcp->fw_flashrev[0], fcp->fw_flashrev[1],
5225 fcp->fw_flashrev[2], fcp->fw_flashrev[3]);
5228 if (isp->isp_osinfo.ispfw != NULL) {
5231 if (ISP_FW_NEWER_THANX(fcp->fw_ispfwrev, fcp->fw_flashrev)) {
5235 if (isp->isp_confopts & ISP_CFG_FWLOAD_FORCE) {
5252 dcode = isp->isp_rquest;
5266 "Loading fragment %u: 0x%x <- 0x%x (0x%lx dwords)",
5283 risc_size -= dlen;
5311 rval = isp_load_risc_flash(isp, srisc_addr, fcp->flt_region_fw_sec);
5317 rval = isp_load_risc_flash(isp, srisc_addr, fcp->flt_region_fw);
5333 addr = fcp->flt_region_nvram;
5337 addr = fcp->flt_region_nvram_sec;
5352 retval = -1;
5363 retval = -1;
5392 fcp->isp_wwpn_nvram = wwn;
5400 if (wwn == 0 && (fcp->isp_wwpn_nvram >> 60) == 2) {
5401 wwn = fcp->isp_wwpn_nvram;
5404 fcp->isp_wwnn_nvram = wwn;
5406 if ((isp->isp_confopts & ISP_CFG_OWNFSZ) == 0) {
5410 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) {
5411 fcp->isp_loopid = ISP2400_NVRAM_HARDLOOPID(nvram_data);
5413 fcp->isp_fwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS1(nvram_data);
5414 fcp->isp_xfwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS2(nvram_data);
5415 fcp->isp_zfwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS3(nvram_data);