Deleted Added
full compact
isp.c (157945) isp.c (160080)
1/*-
2 * Machine and OS Independent (well, as best as possible)
3 * code for the Qlogic ISP SCSI adapters.
4 *
5 * Copyright (c) 1997-2006 by Matthew Jacob
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

29
30/*
31 * Inspiration and ideas about this driver are from Erik Moe's Linux driver
32 * (qlogicisp.c) and Dave Miller's SBus version of same (qlogicisp.c). Some
33 * ideas dredged from the Solaris driver.
34 */
35#ifdef __FreeBSD__
36#include <sys/cdefs.h>
1/*-
2 * Machine and OS Independent (well, as best as possible)
3 * code for the Qlogic ISP SCSI adapters.
4 *
5 * Copyright (c) 1997-2006 by Matthew Jacob
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

29
30/*
31 * Inspiration and ideas about this driver are from Erik Moe's Linux driver
32 * (qlogicisp.c) and Dave Miller's SBus version of same (qlogicisp.c). Some
33 * ideas dredged from the Solaris driver.
34 */
35#ifdef __FreeBSD__
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/dev/isp/isp.c 157945 2006-04-21 18:46:35Z mjacob $");
37__FBSDID("$FreeBSD: head/sys/dev/isp/isp.c 160080 2006-07-03 08:24:09Z mjacob $");
38#endif
39
40/*
41 * Include header file appropriate for platform we're building on.
42 */
43#ifdef __NetBSD__
44#include <dev/ic/isp_netbsd.h>
45#endif

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

95 "HBA attempted queued cmd for %d.%d.%d when queueing disabled";
96static const char pskip[] =
97 "SCSI phase skipped for target %d.%d.%d";
98static const char topology[] =
99 "Loop ID %d, Port ID 0x%x, Loop State 0x%x, Topology '%s'";
100static const char swrej[] =
101 "Fabric Nameserver rejected %s (Reason=0x%x Expl=0x%x) for Port ID 0x%x";
102static const char finmsg[] =
38#endif
39
40/*
41 * Include header file appropriate for platform we're building on.
42 */
43#ifdef __NetBSD__
44#include <dev/ic/isp_netbsd.h>
45#endif

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

95 "HBA attempted queued cmd for %d.%d.%d when queueing disabled";
96static const char pskip[] =
97 "SCSI phase skipped for target %d.%d.%d";
98static const char topology[] =
99 "Loop ID %d, Port ID 0x%x, Loop State 0x%x, Topology '%s'";
100static const char swrej[] =
101 "Fabric Nameserver rejected %s (Reason=0x%x Expl=0x%x) for Port ID 0x%x";
102static const char finmsg[] =
103 "(%d.%d.%d): FIN dl%d resid %d STS 0x%x SKEY %c XS_ERR=0x%x";
103 "%d.%d.%d: FIN dl%d resid %d STS 0x%x SKEY %c XS_ERR=0x%x";
104static const char sc0[] =
105 "%s CHAN %d FTHRSH %d IID %d RESETD %d RETRYC %d RETRYD %d ASD 0x%x";
106static const char sc1[] =
107 "%s RAAN 0x%x DLAN 0x%x DDMAB 0x%x CDMAB 0x%x SELTIME %d MQD %d";
108static const char sc2[] = "%s CHAN %d TGT %d FLAGS 0x%x 0x%x/0x%x";
109static const char sc3[] = "Generated";
110static const char sc4[] = "NVRAM";
111static const char bun[] =

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

124static void isp_scsi_init(ispsoftc_t *);
125static void isp_scsi_channel_init(ispsoftc_t *, int);
126static void isp_fibre_init(ispsoftc_t *);
127static void isp_mark_getpdb_all(ispsoftc_t *);
128static int isp_getmap(ispsoftc_t *, fcpos_map_t *);
129static int isp_getpdb(ispsoftc_t *, int, isp_pdb_t *);
130static uint64_t isp_get_portname(ispsoftc_t *, int, int);
131static int isp_fclink_test(ispsoftc_t *, int);
104static const char sc0[] =
105 "%s CHAN %d FTHRSH %d IID %d RESETD %d RETRYC %d RETRYD %d ASD 0x%x";
106static const char sc1[] =
107 "%s RAAN 0x%x DLAN 0x%x DDMAB 0x%x CDMAB 0x%x SELTIME %d MQD %d";
108static const char sc2[] = "%s CHAN %d TGT %d FLAGS 0x%x 0x%x/0x%x";
109static const char sc3[] = "Generated";
110static const char sc4[] = "NVRAM";
111static const char bun[] =

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

124static void isp_scsi_init(ispsoftc_t *);
125static void isp_scsi_channel_init(ispsoftc_t *, int);
126static void isp_fibre_init(ispsoftc_t *);
127static void isp_mark_getpdb_all(ispsoftc_t *);
128static int isp_getmap(ispsoftc_t *, fcpos_map_t *);
129static int isp_getpdb(ispsoftc_t *, int, isp_pdb_t *);
130static uint64_t isp_get_portname(ispsoftc_t *, int, int);
131static int isp_fclink_test(ispsoftc_t *, int);
132static char *isp2100_fw_statename(int);
132static const char *isp2100_fw_statename(int);
133static int isp_pdb_sync(ispsoftc_t *);
134static int isp_scan_loop(ispsoftc_t *);
135static int isp_fabric_mbox_cmd(ispsoftc_t *, mbreg_t *);
136static int isp_scan_fabric(ispsoftc_t *, int);
137static void isp_register_fc4_type(ispsoftc_t *);
138static void isp_fw_state(ispsoftc_t *);
139static void isp_mboxcmd_qnw(ispsoftc_t *, mbreg_t *, int);
140static void isp_mboxcmd(ispsoftc_t *, mbreg_t *, int);

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

634 * whether we have f/w at all and whether a config flag
635 * has disabled our download.
636 */
637 if ((isp->isp_mdvec->dv_ispfw == NULL) ||
638 (isp->isp_confopts & ISP_CFG_NORELOAD)) {
639 dodnld = 0;
640 }
641
133static int isp_pdb_sync(ispsoftc_t *);
134static int isp_scan_loop(ispsoftc_t *);
135static int isp_fabric_mbox_cmd(ispsoftc_t *, mbreg_t *);
136static int isp_scan_fabric(ispsoftc_t *, int);
137static void isp_register_fc4_type(ispsoftc_t *);
138static void isp_fw_state(ispsoftc_t *);
139static void isp_mboxcmd_qnw(ispsoftc_t *, mbreg_t *, int);
140static void isp_mboxcmd(ispsoftc_t *, mbreg_t *, int);

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

634 * whether we have f/w at all and whether a config flag
635 * has disabled our download.
636 */
637 if ((isp->isp_mdvec->dv_ispfw == NULL) ||
638 (isp->isp_confopts & ISP_CFG_NORELOAD)) {
639 dodnld = 0;
640 }
641
642 if (IS_23XX(isp))
642 if (IS_23XX(isp)) {
643 code_org = ISP_CODE_ORG_2300;
643 code_org = ISP_CODE_ORG_2300;
644 else
644 } else {
645 code_org = ISP_CODE_ORG;
645 code_org = ISP_CODE_ORG;
646
646 }
647 if (dodnld) {
647 if (dodnld) {
648 isp->isp_mbxworkp = (void *) &isp->isp_mdvec->dv_ispfw[1];
649 isp->isp_mbxwrk0 = isp->isp_mdvec->dv_ispfw[3] - 1;
648 uint16_t *ptr = isp->isp_mdvec->dv_ispfw;
649
650 isp->isp_mbxworkp = &ptr[1];
651 isp->isp_mbxwrk0 = ptr[3] - 1;
650 isp->isp_mbxwrk1 = code_org + 1;
651 mbs.param[0] = MBOX_WRITE_RAM_WORD;
652 mbs.param[1] = code_org;
652 isp->isp_mbxwrk1 = code_org + 1;
653 mbs.param[0] = MBOX_WRITE_RAM_WORD;
654 mbs.param[1] = code_org;
653 mbs.param[2] = isp->isp_mdvec->dv_ispfw[0];
655 mbs.param[2] = ptr[0];
654 isp_mboxcmd(isp, &mbs, MBLOGNONE);
655 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
656 isp_prt(isp, ISP_LOGERR,
657 "F/W download failed at word %d",
658 isp->isp_mbxwrk1 - code_org);
659 dodnld = 0;
660 goto again;
661 }
656 isp_mboxcmd(isp, &mbs, MBLOGNONE);
657 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
658 isp_prt(isp, ISP_LOGERR,
659 "F/W download failed at word %d",
660 isp->isp_mbxwrk1 - code_org);
661 dodnld = 0;
662 goto again;
663 }
664
662 /*
663 * Verify that it downloaded correctly.
664 */
665 mbs.param[0] = MBOX_VERIFY_CHECKSUM;
666 mbs.param[1] = code_org;
667 isp_mboxcmd(isp, &mbs, MBLOGNONE);
668 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
669 isp_prt(isp, ISP_LOGERR, "Ram Checksum Failure");
670 return;
671 }
665 /*
666 * Verify that it downloaded correctly.
667 */
668 mbs.param[0] = MBOX_VERIFY_CHECKSUM;
669 mbs.param[1] = code_org;
670 isp_mboxcmd(isp, &mbs, MBLOGNONE);
671 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
672 isp_prt(isp, ISP_LOGERR, "Ram Checksum Failure");
673 return;
674 }
675
676 /*
677 * If we're a 2322 or 2422, the firmware actually comes
678 * in three chunks. We loaded the first at the code_org
679 * address. The other two chunks, which follow right
680 * after each other in memory here, get loaded at addresses
681 * specfied at offset 0x9..0xB.
682 */
683 if (IS_2322(isp)) {
684
685 ptr = &ptr[ptr[3]];
686 isp->isp_mbxworkp = &ptr[1];
687 isp->isp_mbxwrk0 = ptr[3] - 1;
688 isp->isp_mbxwrk1 = ptr[5] + 1;
689 isp->isp_mbxwrk8 = ptr[4];
690 mbs.param[0] = MBOX_WRITE_RAM_WORD_EXTENDED;
691 mbs.param[8] = ptr[4];
692 mbs.param[1] = ptr[5];
693 mbs.param[2] = ptr[0];
694 isp_mboxcmd(isp, &mbs, MBLOGNONE);
695 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
696 isp_prt(isp, ISP_LOGERR,
697 "Receive Sequencer F/W Load Failed");
698 return;
699 }
700
701 ptr = &ptr[ptr[3]];
702 isp->isp_mbxworkp = &ptr[1];
703 isp->isp_mbxwrk0 = ptr[3] - 1;
704 isp->isp_mbxwrk1 = ptr[5] + 1;
705 isp->isp_mbxwrk8 = ptr[4];
706 mbs.param[0] = MBOX_WRITE_RAM_WORD_EXTENDED;
707 mbs.param[8] = ptr[4];
708 mbs.param[1] = ptr[5];
709 mbs.param[2] = ptr[0];
710 isp_mboxcmd(isp, &mbs, MBLOGNONE);
711 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
712 isp_prt(isp, ISP_LOGERR,
713 "Transmit Sequencer F/W Load Failed");
714 return;
715 }
716 }
717
672 isp->isp_loaded_fw = 1;
673 } else {
674 isp->isp_loaded_fw = 0;
675 isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download");
676 }
677
678 /*
679 * Now start it rolling.
680 *
681 * If we didn't actually download f/w,
682 * we still need to (re)start it.
683 */
684
685
686 mbs.param[0] = MBOX_EXEC_FIRMWARE;
687 mbs.param[1] = code_org;
688 if (IS_2322(isp) || IS_24XX(isp)) {
689 if (isp->isp_loaded_fw) {
718 isp->isp_loaded_fw = 1;
719 } else {
720 isp->isp_loaded_fw = 0;
721 isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download");
722 }
723
724 /*
725 * Now start it rolling.
726 *
727 * If we didn't actually download f/w,
728 * we still need to (re)start it.
729 */
730
731
732 mbs.param[0] = MBOX_EXEC_FIRMWARE;
733 mbs.param[1] = code_org;
734 if (IS_2322(isp) || IS_24XX(isp)) {
735 if (isp->isp_loaded_fw) {
690 mbs.param[2] = 1;
691 } else {
692 mbs.param[2] = 0;
736 mbs.param[2] = 0;
737 } else {
738 mbs.param[2] = 1;
693 }
694 mbs.obits |= 2;
695 }
696
697 isp_mboxcmd(isp, &mbs, MBLOGNONE);
698 /*
699 * Give it a chance to start.
700 */

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

1027 mbs.param[0] = MBOX_SET_FW_FEATURES;
1028 mbs.param[1] = 0;
1029 if (IS_ULTRA2(isp))
1030 mbs.param[1] |= FW_FEATURE_LVD_NOTIFY;
1031#ifndef ISP_NO_RIO
1032 if (IS_ULTRA2(isp) || IS_1240(isp))
1033 mbs.param[1] |= FW_FEATURE_RIO_16BIT;
1034#else
739 }
740 mbs.obits |= 2;
741 }
742
743 isp_mboxcmd(isp, &mbs, MBLOGNONE);
744 /*
745 * Give it a chance to start.
746 */

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

1073 mbs.param[0] = MBOX_SET_FW_FEATURES;
1074 mbs.param[1] = 0;
1075 if (IS_ULTRA2(isp))
1076 mbs.param[1] |= FW_FEATURE_LVD_NOTIFY;
1077#ifndef ISP_NO_RIO
1078 if (IS_ULTRA2(isp) || IS_1240(isp))
1079 mbs.param[1] |= FW_FEATURE_RIO_16BIT;
1080#else
1035#ifndef ISP_NO_FASTPOST
1036 if (IS_ULTRA2(isp) || IS_1240(isp))
1037 mbs.param[1] |= FW_FEATURE_FAST_POST;
1038#endif
1081 if (IS_ULTRA2(isp) || IS_1240(isp))
1082 mbs.param[1] |= FW_FEATURE_FAST_POST;
1083#endif
1039#endif
1040 if (mbs.param[1] != 0) {
1041 uint16_t sfeat = mbs.param[1];
1042 isp_mboxcmd(isp, &mbs, MBLOGALL);
1043 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1044 isp_prt(isp, ISP_LOGINFO,
1045 "Enabled FW features (0x%x)", sfeat);
1046 }
1047 }

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

1268 isp_prt(isp, ISP_LOGERR,
1269 "bad execution throttle of %d- using 16",
1270 fcp->isp_execthrottle);
1271 icbp->icb_execthrottle = ICB_DFLT_THROTTLE;
1272 }
1273 icbp->icb_retry_delay = fcp->isp_retry_delay;
1274 icbp->icb_retry_count = fcp->isp_retry_count;
1275 icbp->icb_hardaddr = loopid;
1084 if (mbs.param[1] != 0) {
1085 uint16_t sfeat = mbs.param[1];
1086 isp_mboxcmd(isp, &mbs, MBLOGALL);
1087 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1088 isp_prt(isp, ISP_LOGINFO,
1089 "Enabled FW features (0x%x)", sfeat);
1090 }
1091 }

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

1312 isp_prt(isp, ISP_LOGERR,
1313 "bad execution throttle of %d- using 16",
1314 fcp->isp_execthrottle);
1315 icbp->icb_execthrottle = ICB_DFLT_THROTTLE;
1316 }
1317 icbp->icb_retry_delay = fcp->isp_retry_delay;
1318 icbp->icb_retry_count = fcp->isp_retry_count;
1319 icbp->icb_hardaddr = loopid;
1276 if (icbp->icb_hardaddr >= 125) {
1320 if (icbp->icb_hardaddr > 125) {
1277 /*
1278 * We end up with these Loop IDs for F-Port topologies
1279 */
1280 if (icbp->icb_hardaddr != 0xff && icbp->icb_hardaddr != 0x800) {
1281 isp_prt(isp, ISP_LOGERR,
1282 "bad hard address %u- resetting to zero",
1283 icbp->icb_hardaddr);
1284 }
1285 icbp->icb_hardaddr = 0;
1286 }
1321 /*
1322 * We end up with these Loop IDs for F-Port topologies
1323 */
1324 if (icbp->icb_hardaddr != 0xff && icbp->icb_hardaddr != 0x800) {
1325 isp_prt(isp, ISP_LOGERR,
1326 "bad hard address %u- resetting to zero",
1327 icbp->icb_hardaddr);
1328 }
1329 icbp->icb_hardaddr = 0;
1330 }
1331
1332 if (IS_2322(isp) || IS_24XX(isp)) {
1333 icbp->icb_fwoptions |= ICBOPT_HARD_ADDRESS;
1334 }
1335
1287 /*
1288 * Right now we just set extended options to prefer point-to-point
1289 * over loop based upon some soft config options.
1290 *
1291 * NB: for the 2300, ICBOPT_EXTENDED is required.
1292 */
1293 if (IS_2200(isp) || IS_23XX(isp)) {
1294 icbp->icb_fwoptions |= ICBOPT_EXTENDED;

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

1304 break;
1305 case ISP_CFG_LPORT_ONLY:
1306 icbp->icb_xfwoptions |= ICBXOPT_LOOP_ONLY;
1307 break;
1308 default:
1309 icbp->icb_xfwoptions |= ICBXOPT_LOOP_2_PTP;
1310 break;
1311 }
1336 /*
1337 * Right now we just set extended options to prefer point-to-point
1338 * over loop based upon some soft config options.
1339 *
1340 * NB: for the 2300, ICBOPT_EXTENDED is required.
1341 */
1342 if (IS_2200(isp) || IS_23XX(isp)) {
1343 icbp->icb_fwoptions |= ICBOPT_EXTENDED;

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

1353 break;
1354 case ISP_CFG_LPORT_ONLY:
1355 icbp->icb_xfwoptions |= ICBXOPT_LOOP_ONLY;
1356 break;
1357 default:
1358 icbp->icb_xfwoptions |= ICBXOPT_LOOP_2_PTP;
1359 break;
1360 }
1312 if (IS_23XX(isp)) {
1361 if (IS_2200(isp)) {
1362 if (ISP_FW_NEWER_THAN(isp, 1, 17, 0)) {
1363 icbp->icb_xfwoptions |= ICBXOPT_RIO_16BIT;
1364 icbp->icb_racctimer = 4;
1365 icbp->icb_idelaytimer = 8;
1366 }
1367 icbp->icb_fwoptions |= ICBOPT_FAST_POST;
1368 } else {
1313 /*
1314 * QLogic recommends that FAST Posting be turned
1315 * off for 23XX cards and instead allow the HBA
1316 * to write response queue entries and interrupt
1317 * after a delay (ZIO).
1369 /*
1370 * QLogic recommends that FAST Posting be turned
1371 * off for 23XX cards and instead allow the HBA
1372 * to write response queue entries and interrupt
1373 * after a delay (ZIO).
1318 *
1319 * If we set ZIO, it will disable fast posting,
1320 * so we don't need to clear it in fwoptions.
1321 *
1322 * Depending on the role we're selecting, we
1323 * chose fast posting or not as it still is
1324 * a win for target mode.
1325 */
1374 */
1326#ifndef ISP_NO_ZIO
1327 if (isp->isp_role == ISP_ROLE_TARGET) {
1328 icbp->icb_fwoptions |= ICBOPT_FAST_POST;
1329 } else {
1375 icbp->icb_fwoptions &= ~ICBOPT_FAST_POST;
1376 if ((fcp->isp_xfwoptions & ICBXOPT_TIMER_MASK) ==
1377 ICBXOPT_ZIO) {
1330 icbp->icb_xfwoptions |= ICBXOPT_ZIO;
1378 icbp->icb_xfwoptions |= ICBXOPT_ZIO;
1379 icbp->icb_idelaytimer = 10;
1331 }
1380 }
1332#else
1333 icbp->icb_fwoptions |= ICBOPT_FAST_POST;
1334#endif
1335#if 0
1336 /*
1337 * Values, in 100us increments. The default
1338 * is 2 (200us) if a value 0 (default) is
1339 * selected.
1340 */
1341 icbp->icb_idelaytimer = 2;
1342#endif
1343
1344 if (isp->isp_confopts & ISP_CFG_ONEGB) {
1345 icbp->icb_zfwoptions |= ICBZOPT_RATE_ONEGB;
1346 } else if (isp->isp_confopts & ISP_CFG_TWOGB) {
1347 icbp->icb_zfwoptions |= ICBZOPT_RATE_TWOGB;
1348 } else {
1349 icbp->icb_zfwoptions |= ICBZOPT_RATE_AUTO;
1350 }
1381 if (isp->isp_confopts & ISP_CFG_ONEGB) {
1382 icbp->icb_zfwoptions |= ICBZOPT_RATE_ONEGB;
1383 } else if (isp->isp_confopts & ISP_CFG_TWOGB) {
1384 icbp->icb_zfwoptions |= ICBZOPT_RATE_TWOGB;
1385 } else {
1386 icbp->icb_zfwoptions |= ICBZOPT_RATE_AUTO;
1387 }
1388 if (fcp->isp_zfwoptions & ICBZOPT_50_OHM) {
1389 icbp->icb_zfwoptions |= ICBZOPT_50_OHM;
1390 }
1351 }
1352 }
1353
1391 }
1392 }
1393
1354#ifndef ISP_NO_RIO_FC
1355 /*
1356 * RIO seems to be enabled in 2100s for fw >= 1.17.0.
1357 *
1358 * I've had some questionable problems with RIO on 2200.
1359 * More specifically, on a 2204 I had problems with RIO
1360 * on a Linux system where I was dropping commands right
1361 * and left. It's not clear to me what the actual problem
1362 * was.
1363 *
1364 * 23XX Cards do not support RIO. Instead they support ZIO.
1365 */
1366#if 0
1367 if (!IS_23XX(isp) && ISP_FW_NEWER_THAN(isp, 1, 17, 0)) {
1368 icbp->icb_xfwoptions |= ICBXOPT_RIO_16BIT;
1369 icbp->icb_racctimer = 4;
1370 icbp->icb_idelaytimer = 8;
1371 }
1372#endif
1373#endif
1374
1375 MEMZERO(&mbs, sizeof (mbs));
1376
1377 /*
1378 * For 22XX > 2.1.26 && 23XX, set some options.
1379 * XXX: Probably okay for newer 2100 f/w too.
1380 */
1381 if (ISP_FW_NEWER_THAN(isp, 2, 26, 0)) {
1382 /*

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

1427 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_rquest_dma);
1428 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_rquest_dma);
1429 icbp->icb_rqstaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_rquest_dma);
1430 icbp->icb_rqstaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_rquest_dma);
1431 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_result_dma);
1432 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_result_dma);
1433 icbp->icb_respaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_result_dma);
1434 icbp->icb_respaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_result_dma);
1394 MEMZERO(&mbs, sizeof (mbs));
1395
1396 /*
1397 * For 22XX > 2.1.26 && 23XX, set some options.
1398 * XXX: Probably okay for newer 2100 f/w too.
1399 */
1400 if (ISP_FW_NEWER_THAN(isp, 2, 26, 0)) {
1401 /*

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

1446 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_rquest_dma);
1447 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_rquest_dma);
1448 icbp->icb_rqstaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_rquest_dma);
1449 icbp->icb_rqstaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_rquest_dma);
1450 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_result_dma);
1451 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_result_dma);
1452 icbp->icb_respaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_result_dma);
1453 icbp->icb_respaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_result_dma);
1454
1435 isp_prt(isp, ISP_LOGDEBUG0,
1436 "isp_fibre_init: fwopt 0x%x xfwopt 0x%x zfwopt 0x%x",
1437 icbp->icb_fwoptions, icbp->icb_xfwoptions, icbp->icb_zfwoptions);
1438
1439 FC_SCRATCH_ACQUIRE(isp);
1440 isp_put_icb(isp, icbp, (isp_icb_t *)fcp->isp_scratch);
1441
1442 /*

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

1555{
1556 uint64_t wwn = 0;
1557 mbreg_t mbs;
1558
1559 MEMZERO(&mbs, sizeof (mbs));
1560 mbs.param[0] = MBOX_GET_PORT_NAME;
1561 if (IS_2KLOGIN(isp)) {
1562 mbs.param[1] = loopid;
1455 isp_prt(isp, ISP_LOGDEBUG0,
1456 "isp_fibre_init: fwopt 0x%x xfwopt 0x%x zfwopt 0x%x",
1457 icbp->icb_fwoptions, icbp->icb_xfwoptions, icbp->icb_zfwoptions);
1458
1459 FC_SCRATCH_ACQUIRE(isp);
1460 isp_put_icb(isp, icbp, (isp_icb_t *)fcp->isp_scratch);
1461
1462 /*

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

1575{
1576 uint64_t wwn = 0;
1577 mbreg_t mbs;
1578
1579 MEMZERO(&mbs, sizeof (mbs));
1580 mbs.param[0] = MBOX_GET_PORT_NAME;
1581 if (IS_2KLOGIN(isp)) {
1582 mbs.param[1] = loopid;
1563 if (nodename)
1564 mbs.param[10] = 1;
1565 mbs.obits |= (1 << 10);
1583 mbs.obits |= (1 << 10);
1584 if (nodename) {
1585 mbs.param[10] = 1;
1586 }
1566 } else {
1567 mbs.param[1] = loopid << 8;
1587 } else {
1588 mbs.param[1] = loopid << 8;
1568 if (nodename)
1589 if (nodename) {
1569 mbs.param[1] |= 1;
1590 mbs.param[1] |= 1;
1591 }
1570 }
1571 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR);
1572 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1573 wwn =
1592 }
1593 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR);
1594 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1595 wwn =
1574 (((uint64_t)(mbs.param[2] & 0xff)) << 56) |
1596 (((uint64_t)(mbs.param[2] & 0xff)) << 56) |
1575 (((uint64_t)(mbs.param[2] >> 8)) << 48) |
1576 (((uint64_t)(mbs.param[3] & 0xff)) << 40) |
1577 (((uint64_t)(mbs.param[3] >> 8)) << 32) |
1578 (((uint64_t)(mbs.param[6] & 0xff)) << 24) |
1579 (((uint64_t)(mbs.param[6] >> 8)) << 16) |
1580 (((uint64_t)(mbs.param[7] & 0xff)) << 8) |
1581 (((uint64_t)(mbs.param[7] >> 8)));
1582 }

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

1601 int count, check_for_fabric;
1602 uint8_t lwfs;
1603 fcparam *fcp;
1604 struct lportdb *lp;
1605 isp_pdb_t pdb;
1606
1607 fcp = isp->isp_param;
1608
1597 (((uint64_t)(mbs.param[2] >> 8)) << 48) |
1598 (((uint64_t)(mbs.param[3] & 0xff)) << 40) |
1599 (((uint64_t)(mbs.param[3] >> 8)) << 32) |
1600 (((uint64_t)(mbs.param[6] & 0xff)) << 24) |
1601 (((uint64_t)(mbs.param[6] >> 8)) << 16) |
1602 (((uint64_t)(mbs.param[7] & 0xff)) << 8) |
1603 (((uint64_t)(mbs.param[7] >> 8)));
1604 }

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

1623 int count, check_for_fabric;
1624 uint8_t lwfs;
1625 fcparam *fcp;
1626 struct lportdb *lp;
1627 isp_pdb_t pdb;
1628
1629 fcp = isp->isp_param;
1630
1631 isp_prt(isp, ISP_LOGDEBUG0, "FC Link Test Entry");
1632
1609 /*
1610 * XXX: Here is where we would start a 'loop dead' timeout
1611 */
1612
1613 /*
1614 * Wait up to N microseconds for F/W to go to a ready state.
1615 */
1616 lwfs = FW_CONFIG_WAIT;

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

1684 * Get our Loop ID (if possible). We really need to have it.
1685 */
1686 MEMZERO(&mbs, sizeof (mbs));
1687 mbs.param[0] = MBOX_GET_LOOP_ID;
1688 isp_mboxcmd(isp, &mbs, MBLOGALL);
1689 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1690 return (-1);
1691 }
1633 /*
1634 * XXX: Here is where we would start a 'loop dead' timeout
1635 */
1636
1637 /*
1638 * Wait up to N microseconds for F/W to go to a ready state.
1639 */
1640 lwfs = FW_CONFIG_WAIT;

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

1708 * Get our Loop ID (if possible). We really need to have it.
1709 */
1710 MEMZERO(&mbs, sizeof (mbs));
1711 mbs.param[0] = MBOX_GET_LOOP_ID;
1712 isp_mboxcmd(isp, &mbs, MBLOGALL);
1713 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1714 return (-1);
1715 }
1692 fcp->isp_loopid = mbs.param[1];
1716 if (IS_2KLOGIN(isp)) {
1717 fcp->isp_loopid = mbs.param[1];
1718 } else {
1719 fcp->isp_loopid = mbs.param[1] & 0xff;
1720 }
1693 if (fcp->isp_loopid == 0xffff) { /* happens with 2k login f/w */
1694 fcp->isp_loopid = MAX_FC_TARG-1;
1695 } else if (fcp->isp_loopid >= MAX_FC_TARG) {
1696 isp_prt(isp, ISP_LOGWARN, "bad initiator loopid (0x%x)", fcp->isp_loopid);
1697 fcp->isp_loopid = MAX_FC_TARG-1;
1698 }
1699 if (IS_2200(isp) || IS_23XX(isp)) {
1700 int topo = (int) mbs.param[6];

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

1835 break;
1836 case ISP_ROLE_BOTH:
1837 lp->roles = (SVC3_INI_ROLE|SVC3_TGT_ROLE) >> SVC3_ROLE_SHIFT;
1838 break;
1839 }
1840 lp->loggedin = lp->valid = 1;
1841 count = fcp->isp_iid;
1842 (void) isp_async(isp, ISPASYNC_PROMENADE, &count);
1721 if (fcp->isp_loopid == 0xffff) { /* happens with 2k login f/w */
1722 fcp->isp_loopid = MAX_FC_TARG-1;
1723 } else if (fcp->isp_loopid >= MAX_FC_TARG) {
1724 isp_prt(isp, ISP_LOGWARN, "bad initiator loopid (0x%x)", fcp->isp_loopid);
1725 fcp->isp_loopid = MAX_FC_TARG-1;
1726 }
1727 if (IS_2200(isp) || IS_23XX(isp)) {
1728 int topo = (int) mbs.param[6];

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

1863 break;
1864 case ISP_ROLE_BOTH:
1865 lp->roles = (SVC3_INI_ROLE|SVC3_TGT_ROLE) >> SVC3_ROLE_SHIFT;
1866 break;
1867 }
1868 lp->loggedin = lp->valid = 1;
1869 count = fcp->isp_iid;
1870 (void) isp_async(isp, ISPASYNC_PROMENADE, &count);
1871 isp_prt(isp, ISP_LOGDEBUG0, "FC Link Test Complete");
1843 return (0);
1844}
1845
1872 return (0);
1873}
1874
1846static char *
1875static const char *
1847isp2100_fw_statename(int state)
1848{
1849 switch(state) {
1850 case FW_CONFIG_WAIT: return "Config Wait";
1851 case FW_WAIT_AL_PA: return "Waiting for AL_PA";
1852 case FW_WAIT_LOGIN: return "Wait Login";
1853 case FW_READY: return "Ready";
1854 case FW_LOSS_OF_SYNC: return "Loss Of Sync";

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

2204 break;
2205 case TOPO_N_PORT:
2206 hival = 2;
2207 break;
2208 case TOPO_FL_PORT:
2209 hival = FC_PORT_ID;
2210 break;
2211 default:
1876isp2100_fw_statename(int state)
1877{
1878 switch(state) {
1879 case FW_CONFIG_WAIT: return "Config Wait";
1880 case FW_WAIT_AL_PA: return "Waiting for AL_PA";
1881 case FW_WAIT_LOGIN: return "Wait Login";
1882 case FW_READY: return "Ready";
1883 case FW_LOSS_OF_SYNC: return "Loss Of Sync";

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

2233 break;
2234 case TOPO_N_PORT:
2235 hival = 2;
2236 break;
2237 case TOPO_FL_PORT:
2238 hival = FC_PORT_ID;
2239 break;
2240 default:
2241 isp_prt(isp, ISP_LOGDEBUG0, "no loop scasn\n");
2212 fcp->isp_loopstate = LOOP_LSCAN_DONE;
2213 return (0);
2214 }
2215 fcp->isp_loopstate = LOOP_SCANNING_LOOP;
2216
2242 fcp->isp_loopstate = LOOP_LSCAN_DONE;
2243 return (0);
2244 }
2245 fcp->isp_loopstate = LOOP_SCANNING_LOOP;
2246
2247 isp_prt(isp, ISP_LOGDEBUG0, "scanning local loop 0..%d", hival);
2248
2249
2217 /*
2218 * make sure the temp port database is clean...
2219 */
2220 MEMZERO((void *)fcp->tport, sizeof (fcp->tport));
2221
2222 /*
2223 * Run through the local loop ports and get port database info
2224 * for each loop ID.
2225 *
2226 * There's a somewhat unexplained situation where the f/w passes back
2227 * the wrong database entity- if that happens, just restart (up to
2228 * FL_PORT_ID times).
2229 */
2230 for (lim = loopid = 0; loopid < hival; loopid++) {
2231 lp = &fcp->tport[loopid];
2232
2233 /*
2234 * Don't even try for ourselves...
2235 */
2250 /*
2251 * make sure the temp port database is clean...
2252 */
2253 MEMZERO((void *)fcp->tport, sizeof (fcp->tport));
2254
2255 /*
2256 * Run through the local loop ports and get port database info
2257 * for each loop ID.
2258 *
2259 * There's a somewhat unexplained situation where the f/w passes back
2260 * the wrong database entity- if that happens, just restart (up to
2261 * FL_PORT_ID times).
2262 */
2263 for (lim = loopid = 0; loopid < hival; loopid++) {
2264 lp = &fcp->tport[loopid];
2265
2266 /*
2267 * Don't even try for ourselves...
2268 */
2236 if (loopid == fcp->isp_loopid)
2269 if (loopid == fcp->isp_loopid) {
2237 continue;
2270 continue;
2271 }
2238
2272
2239 lp->node_wwn = isp_get_portname(isp, loopid, 1);
2240 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
2241 return (-1);
2242 if (lp->node_wwn == 0)
2243 continue;
2244 lp->port_wwn = isp_get_portname(isp, loopid, 0);
2245 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
2246 return (-1);
2247 if (lp->port_wwn == 0) {
2248 lp->node_wwn = 0;
2249 continue;
2273 if (IS_2100(isp) || IS_2200(isp)) {
2274 lp->node_wwn = isp_get_portname(isp, loopid, 1);
2275 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
2276 return (-1);
2277 }
2278 if (lp->node_wwn == 0) {
2279 continue;
2280 }
2250 }
2251
2252 /*
2253 * Get an entry....
2254 */
2255 if (isp_getpdb(isp, loopid, &pdb) != 0) {
2281 }
2282
2283 /*
2284 * Get an entry....
2285 */
2286 if (isp_getpdb(isp, loopid, &pdb) != 0) {
2256 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
2287 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
2257 return (-1);
2288 return (-1);
2289 }
2258 continue;
2259 }
2290 continue;
2291 }
2292
2260 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
2261 return (-1);
2262 }
2263
2264 /*
2265 * If the returned database element doesn't match what we
2266 * asked for, restart the process entirely (up to a point...).
2267 */

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

2518 uint32_t portid, first_portid, last_portid;
2519 int hicap, last_port_same;
2520
2521 if (fcp->isp_onfabric == 0) {
2522 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2523 return (0);
2524 }
2525
2293 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
2294 return (-1);
2295 }
2296
2297 /*
2298 * If the returned database element doesn't match what we
2299 * asked for, restart the process entirely (up to a point...).
2300 */

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

2551 uint32_t portid, first_portid, last_portid;
2552 int hicap, last_port_same;
2553
2554 if (fcp->isp_onfabric == 0) {
2555 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2556 return (0);
2557 }
2558
2559 isp_prt(isp, ISP_LOGDEBUG0, "scanning fabric (GA_NXT)");
2560
2526 FC_SCRATCH_ACQUIRE(isp);
2527
2528 /*
2529 * Since Port IDs are 24 bits, we can check against having seen
2530 * anything yet with this value.
2531 */
2532 last_port_same = 0;
2533 last_portid = 0xffffffff; /* not a port */

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

2684 sns_gid_ft_req_t *rq;
2685 sns_gid_ft_rsp_t *rs0, *rs1;
2686
2687 if (fcp->isp_onfabric == 0) {
2688 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2689 return (0);
2690 }
2691
2561 FC_SCRATCH_ACQUIRE(isp);
2562
2563 /*
2564 * Since Port IDs are 24 bits, we can check against having seen
2565 * anything yet with this value.
2566 */
2567 last_port_same = 0;
2568 last_portid = 0xffffffff; /* not a port */

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

2719 sns_gid_ft_req_t *rq;
2720 sns_gid_ft_rsp_t *rs0, *rs1;
2721
2722 if (fcp->isp_onfabric == 0) {
2723 fcp->isp_loopstate = LOOP_FSCAN_DONE;
2724 return (0);
2725 }
2726
2727 isp_prt(isp, ISP_LOGDEBUG0, "scanning fabric (GID_FT)");
2728
2692 FC_SCRATCH_ACQUIRE(isp);
2693 fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
2694
2695 rq = (sns_gid_ft_req_t *)fcp->tport;
2696 MEMZERO((void *) rq, SNS_GID_FT_REQ_SIZE);
2697 rq->snscb_rblen = GIDLEN >> 1;
2698 rq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma+IGPOFF);
2699 rq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma+IGPOFF);

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

3420 /*
3421 * Issue a bus reset.
3422 */
3423 mbs.param[0] = MBOX_BUS_RESET;
3424 mbs.param[2] = 0;
3425 if (IS_SCSI(isp)) {
3426 mbs.param[1] =
3427 ((sdparam *) isp->isp_param)->isp_bus_reset_delay;
2729 FC_SCRATCH_ACQUIRE(isp);
2730 fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
2731
2732 rq = (sns_gid_ft_req_t *)fcp->tport;
2733 MEMZERO((void *) rq, SNS_GID_FT_REQ_SIZE);
2734 rq->snscb_rblen = GIDLEN >> 1;
2735 rq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma+IGPOFF);
2736 rq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma+IGPOFF);

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

3457 /*
3458 * Issue a bus reset.
3459 */
3460 mbs.param[0] = MBOX_BUS_RESET;
3461 mbs.param[2] = 0;
3462 if (IS_SCSI(isp)) {
3463 mbs.param[1] =
3464 ((sdparam *) isp->isp_param)->isp_bus_reset_delay;
3428 if (mbs.param[1] < 2)
3465 if (mbs.param[1] < 2) {
3429 mbs.param[1] = 2;
3466 mbs.param[1] = 2;
3467 }
3430 bus = *((int *) arg);
3468 bus = *((int *) arg);
3431 if (IS_DUALBUS(isp))
3469 if (IS_DUALBUS(isp)) {
3432 mbs.param[2] = bus;
3470 mbs.param[2] = bus;
3471 }
3433 } else {
3434 mbs.param[1] = 10;
3435 bus = 0;
3436 }
3437 isp->isp_sendmarker |= (1 << bus);
3438 isp_mboxcmd(isp, &mbs, MBLOGALL);
3439 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3440 break;

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

3544 return (isp_pdb_sync(isp));
3545 }
3546 break;
3547
3548 case ISPCTL_SEND_LIP:
3549
3550 if (IS_FC(isp)) {
3551 mbs.param[0] = MBOX_INIT_LIP;
3472 } else {
3473 mbs.param[1] = 10;
3474 bus = 0;
3475 }
3476 isp->isp_sendmarker |= (1 << bus);
3477 isp_mboxcmd(isp, &mbs, MBLOGALL);
3478 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3479 break;

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

3583 return (isp_pdb_sync(isp));
3584 }
3585 break;
3586
3587 case ISPCTL_SEND_LIP:
3588
3589 if (IS_FC(isp)) {
3590 mbs.param[0] = MBOX_INIT_LIP;
3591 if (IS_2KLOGIN(isp)) {
3592 mbs.obits |= (1 << 10);
3593 }
3552 isp_mboxcmd(isp, &mbs, MBLOGALL);
3553 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
3554 return (0);
3555 }
3556 }
3557 break;
3558
3559 case ISPCTL_GET_POSMAP:

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

3961 (*XS_STSP(xs) == SCSI_CHECK) &&
3962 (sp->req_scsi_status & RQCS_SV)) {
3963 XS_SAVE_SENSE(xs, sp);
3964 /* solely for the benefit of debug */
3965 sp->req_state_flags |= RQSF_GOT_SENSE;
3966 }
3967 }
3968 isp_prt(isp, ISP_LOGDEBUG2,
3594 isp_mboxcmd(isp, &mbs, MBLOGALL);
3595 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
3596 return (0);
3597 }
3598 }
3599 break;
3600
3601 case ISPCTL_GET_POSMAP:

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

4003 (*XS_STSP(xs) == SCSI_CHECK) &&
4004 (sp->req_scsi_status & RQCS_SV)) {
4005 XS_SAVE_SENSE(xs, sp);
4006 /* solely for the benefit of debug */
4007 sp->req_state_flags |= RQSF_GOT_SENSE;
4008 }
4009 }
4010 isp_prt(isp, ISP_LOGDEBUG2,
3969 "asked for %ld got resid %ld", (long) XS_XFRLEN(xs),
3970 (long) sp->req_resid);
4011 "asked for %ld got raw resid %ld settled for %ld",
4012 (long) XS_XFRLEN(xs), (long) sp->req_resid,
4013 (long) XS_RESID(xs));
3971 break;
3972 case RQSTYPE_REQUEST:
3973 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
3974 /*
3975 * Force Queue Full status.
3976 */
3977 *XS_STSP(xs) = SCSI_QFULL;
3978 XS_SETERR(xs, HBA_NOERROR);

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

4080 isp->isp_sendmarker |= (1 << bus);
4081#ifdef ISP_TARGET_MODE
4082 if (isp_target_async(isp, bus, mbox))
4083 rval = -1;
4084#endif
4085 isp_async(isp, ISPASYNC_BUS_RESET, &bus);
4086 break;
4087 case ASYNC_SYSTEM_ERROR:
4014 break;
4015 case RQSTYPE_REQUEST:
4016 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
4017 /*
4018 * Force Queue Full status.
4019 */
4020 *XS_STSP(xs) = SCSI_QFULL;
4021 XS_SETERR(xs, HBA_NOERROR);

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

4123 isp->isp_sendmarker |= (1 << bus);
4124#ifdef ISP_TARGET_MODE
4125 if (isp_target_async(isp, bus, mbox))
4126 rval = -1;
4127#endif
4128 isp_async(isp, ISPASYNC_BUS_RESET, &bus);
4129 break;
4130 case ASYNC_SYSTEM_ERROR:
4131 isp->isp_state = ISP_CRASHED;
4132 if (IS_FC(isp)) {
4133 FCPARAM(isp)->isp_loopstate = LOOP_NIL;
4134 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
4135 }
4136 /*
4137 * Were we waiting for a mailbox command to complete?
4138 * If so, it's dead, so wake up the waiter.
4139 */
4140 if (isp->isp_mboxbsy) {
4141 isp->isp_obits = 1;
4142 isp->isp_mboxtmp[0] = MBOX_HOST_INTERFACE_ERROR;
4143 MBOX_NOTIFY_COMPLETE(isp);
4144 }
4088#ifdef ISP_FW_CRASH_DUMP
4089 /*
4090 * If we have crash dumps enabled, it's up to the handler
4091 * for isp_async to reinit stuff and restart the firmware
4092 * after performing the crash dump. The reason we do things
4093 * this way is that we may need to activate a kernel thread
4094 * to do all the crash dump goop.
4095 */

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

4805 * to force a re-login of this unit. If we're on fabric,
4806 * then we'll have to relogin as a matter of course.
4807 */
4808 if (FCPARAM(isp)->isp_topo == TOPO_NL_PORT ||
4809 FCPARAM(isp)->isp_topo == TOPO_FL_PORT) {
4810 mbreg_t mbs;
4811 MEMZERO(&mbs, sizeof (mbs));
4812 mbs.param[0] = MBOX_INIT_LIP;
4145#ifdef ISP_FW_CRASH_DUMP
4146 /*
4147 * If we have crash dumps enabled, it's up to the handler
4148 * for isp_async to reinit stuff and restart the firmware
4149 * after performing the crash dump. The reason we do things
4150 * this way is that we may need to activate a kernel thread
4151 * to do all the crash dump goop.
4152 */

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

4862 * to force a re-login of this unit. If we're on fabric,
4863 * then we'll have to relogin as a matter of course.
4864 */
4865 if (FCPARAM(isp)->isp_topo == TOPO_NL_PORT ||
4866 FCPARAM(isp)->isp_topo == TOPO_FL_PORT) {
4867 mbreg_t mbs;
4868 MEMZERO(&mbs, sizeof (mbs));
4869 mbs.param[0] = MBOX_INIT_LIP;
4870 if (IS_2KLOGIN(isp)) {
4871 mbs.obits |= (1 << 10);
4872 }
4813 isp_mboxcmd_qnw(isp, &mbs, 1);
4814 }
4815
4816 /*
4817 * Probably overkill.
4818 */
4819 isp->isp_sendmarker = 1;
4820 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD;

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

4888isp_mbox_continue(ispsoftc_t *isp)
4889{
4890 mbreg_t mbs;
4891 uint16_t *ptr;
4892
4893 switch (isp->isp_lastmbxcmd) {
4894 case MBOX_WRITE_RAM_WORD:
4895 case MBOX_READ_RAM_WORD:
4873 isp_mboxcmd_qnw(isp, &mbs, 1);
4874 }
4875
4876 /*
4877 * Probably overkill.
4878 */
4879 isp->isp_sendmarker = 1;
4880 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD;

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

4948isp_mbox_continue(ispsoftc_t *isp)
4949{
4950 mbreg_t mbs;
4951 uint16_t *ptr;
4952
4953 switch (isp->isp_lastmbxcmd) {
4954 case MBOX_WRITE_RAM_WORD:
4955 case MBOX_READ_RAM_WORD:
4956 case MBOX_WRITE_RAM_WORD_EXTENDED:
4896 case MBOX_READ_RAM_WORD_EXTENDED:
4897 break;
4898 default:
4899 return (1);
4900 }
4901 if (isp->isp_mboxtmp[0] != MBOX_COMMAND_COMPLETE) {
4902 isp->isp_mbxwrk0 = 0;
4903 return (-1);

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

4914 */
4915 MEMZERO(&mbs, sizeof (mbs));
4916 ptr = isp->isp_mbxworkp;
4917 switch (isp->isp_lastmbxcmd) {
4918 case MBOX_WRITE_RAM_WORD:
4919 mbs.param[2] = *ptr++;
4920 mbs.param[1] = isp->isp_mbxwrk1++;
4921 break;
4957 case MBOX_READ_RAM_WORD_EXTENDED:
4958 break;
4959 default:
4960 return (1);
4961 }
4962 if (isp->isp_mboxtmp[0] != MBOX_COMMAND_COMPLETE) {
4963 isp->isp_mbxwrk0 = 0;
4964 return (-1);

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

4975 */
4976 MEMZERO(&mbs, sizeof (mbs));
4977 ptr = isp->isp_mbxworkp;
4978 switch (isp->isp_lastmbxcmd) {
4979 case MBOX_WRITE_RAM_WORD:
4980 mbs.param[2] = *ptr++;
4981 mbs.param[1] = isp->isp_mbxwrk1++;
4982 break;
4983 case MBOX_WRITE_RAM_WORD_EXTENDED:
4984 mbs.param[2] = *ptr++;
4985 mbs.param[1] = isp->isp_mbxwrk1++;
4986 if (isp->isp_mbxwrk1 == 0) {
4987 isp->isp_mbxwrk8++;
4988 }
4989 mbs.param[8] = isp->isp_mbxwrk8;
4990 break;
4922 case MBOX_READ_RAM_WORD:
4991 case MBOX_READ_RAM_WORD:
4992 *ptr++ = isp->isp_mboxtmp[2];
4993 mbs.param[1] = isp->isp_mbxwrk1++;
4994 break;
4923 case MBOX_READ_RAM_WORD_EXTENDED:
4924 *ptr++ = isp->isp_mboxtmp[2];
4925 mbs.param[1] = isp->isp_mbxwrk1++;
4995 case MBOX_READ_RAM_WORD_EXTENDED:
4996 *ptr++ = isp->isp_mboxtmp[2];
4997 mbs.param[1] = isp->isp_mbxwrk1++;
4998 if (isp->isp_mbxwrk1 == 0) {
4999 isp->isp_mbxwrk8++;
5000 }
5001 mbs.param[8] = isp->isp_mbxwrk8;
4926 break;
4927 }
4928 isp->isp_mbxworkp = ptr;
4929 mbs.param[0] = isp->isp_lastmbxcmd;
4930 isp->isp_mbxwrk0 -= 1;
4931 isp_mboxcmd_qnw(isp, &mbs, 0);
4932 return (0);
4933}

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

5141 ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */
5142 ISPOPMAP(0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */
5143 ISPOPMAP(0x03, 0x05), /* 0x07: MBOX_VERIFY_CHECKSUM */
5144 ISPOPMAP(0x01, 0x4f), /* 0x08: MBOX_ABOUT_FIRMWARE */
5145 ISPOPMAP(0xdf, 0x01), /* 0x09: LOAD RAM */
5146 ISPOPMAP(0xdf, 0x01), /* 0x0a: DUMP RAM */
5147 ISPOPMAP(0x00, 0x00), /* 0x0b: */
5148 ISPOPMAP(0x00, 0x00), /* 0x0c: */
5002 break;
5003 }
5004 isp->isp_mbxworkp = ptr;
5005 mbs.param[0] = isp->isp_lastmbxcmd;
5006 isp->isp_mbxwrk0 -= 1;
5007 isp_mboxcmd_qnw(isp, &mbs, 0);
5008 return (0);
5009}

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

5217 ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */
5218 ISPOPMAP(0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */
5219 ISPOPMAP(0x03, 0x05), /* 0x07: MBOX_VERIFY_CHECKSUM */
5220 ISPOPMAP(0x01, 0x4f), /* 0x08: MBOX_ABOUT_FIRMWARE */
5221 ISPOPMAP(0xdf, 0x01), /* 0x09: LOAD RAM */
5222 ISPOPMAP(0xdf, 0x01), /* 0x0a: DUMP RAM */
5223 ISPOPMAP(0x00, 0x00), /* 0x0b: */
5224 ISPOPMAP(0x00, 0x00), /* 0x0c: */
5149 ISPOPMAP(0x00, 0x00), /* 0x0d: */
5225 ISPOPMAP(0x13, 0x01), /* 0x0d: MBOX_WRITE_RAM_WORD_EXTENDED) */
5150 ISPOPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */
5226 ISPOPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */
5151 ISPOPMAP(0x03, 0x07), /* 0x0f: MBOX_READ_RAM_WORD_EXTENDED(1) */
5227 ISPOPMAP(0x13, 0x05), /* 0x0f: MBOX_READ_RAM_WORD_EXTENDED */
5152 ISPOPMAP(0x1f, 0x11), /* 0x10: MBOX_INIT_REQ_QUEUE */
5153 ISPOPMAP(0x2f, 0x21), /* 0x11: MBOX_INIT_RES_QUEUE */
5154 ISPOPMAP(0x0f, 0x01), /* 0x12: MBOX_EXECUTE_IOCB */
5155 ISPOPMAP(0x03, 0x03), /* 0x13: MBOX_WAKE_UP */
5156 ISPOPMAP(0x01, 0xff), /* 0x14: MBOX_STOP_FIRMWARE */
5157 ISPOPMAP(0x4f, 0x01), /* 0x15: MBOX_ABORT */
5158 ISPOPMAP(0x07, 0x01), /* 0x16: MBOX_ABORT_DEVICE */
5159 ISPOPMAP(0x07, 0x01), /* 0x17: MBOX_ABORT_TARGET */

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

5261 ISPOPMAP(0xcf, 0x01), /* 0x7d: SEND LFA */
5262 ISPOPMAP(0x0f, 0x01) /* 0x7e: LUN RESET */
5263};
5264/*
5265 * Footnotes
5266 *
5267 * (1): this sets bits 21..16 in mailbox register #8, which we nominally
5268 * do not access at this time in the core driver. The caller is
5228 ISPOPMAP(0x1f, 0x11), /* 0x10: MBOX_INIT_REQ_QUEUE */
5229 ISPOPMAP(0x2f, 0x21), /* 0x11: MBOX_INIT_RES_QUEUE */
5230 ISPOPMAP(0x0f, 0x01), /* 0x12: MBOX_EXECUTE_IOCB */
5231 ISPOPMAP(0x03, 0x03), /* 0x13: MBOX_WAKE_UP */
5232 ISPOPMAP(0x01, 0xff), /* 0x14: MBOX_STOP_FIRMWARE */
5233 ISPOPMAP(0x4f, 0x01), /* 0x15: MBOX_ABORT */
5234 ISPOPMAP(0x07, 0x01), /* 0x16: MBOX_ABORT_DEVICE */
5235 ISPOPMAP(0x07, 0x01), /* 0x17: MBOX_ABORT_TARGET */

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

5337 ISPOPMAP(0xcf, 0x01), /* 0x7d: SEND LFA */
5338 ISPOPMAP(0x0f, 0x01) /* 0x7e: LUN RESET */
5339};
5340/*
5341 * Footnotes
5342 *
5343 * (1): this sets bits 21..16 in mailbox register #8, which we nominally
5344 * do not access at this time in the core driver. The caller is
5269 * responsible for setting this register first (Gross!).
5345 * responsible for setting this register first (Gross!). The assumption
5346 * is that we won't overflow.
5270 */
5271
5272#ifndef ISP_STRIPPED
5273static char *fc_mbcmd_names[] = {
5274 "NO-OP",
5275 "LOAD RAM",
5276 "EXEC FIRMWARE",
5277 "DUMP RAM",
5278 "WRITE RAM WORD",
5279 "READ RAM WORD",
5280 "MAILBOX REG TEST",
5281 "VERIFY CHECKSUM",
5282 "ABOUT FIRMWARE",
5283 "LOAD RAM",
5284 "DUMP RAM",
5347 */
5348
5349#ifndef ISP_STRIPPED
5350static char *fc_mbcmd_names[] = {
5351 "NO-OP",
5352 "LOAD RAM",
5353 "EXEC FIRMWARE",
5354 "DUMP RAM",
5355 "WRITE RAM WORD",
5356 "READ RAM WORD",
5357 "MAILBOX REG TEST",
5358 "VERIFY CHECKSUM",
5359 "ABOUT FIRMWARE",
5360 "LOAD RAM",
5361 "DUMP RAM",
5362 "WRITE RAM WORD EXTENDED",
5285 NULL,
5363 NULL,
5286 NULL,
5287 "READ RAM WORD EXTENDED",
5288 "CHECK FIRMWARE",
5289 NULL,
5290 "INIT REQUEST QUEUE",
5291 "INIT RESULT QUEUE",
5292 "EXECUTE IOCB",
5293 "WAKE UP",
5294 "STOP FIRMWARE",

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

5337 NULL,
5338 "LOOP PORT BYPASS",
5339 "LOOP PORT ENABLE",
5340 "GET RESOURCE COUNTS",
5341 "REQUEST NON PARTICIPATING MODE",
5342 NULL,
5343 NULL,
5344 NULL,
5364 "READ RAM WORD EXTENDED",
5365 "CHECK FIRMWARE",
5366 NULL,
5367 "INIT REQUEST QUEUE",
5368 "INIT RESULT QUEUE",
5369 "EXECUTE IOCB",
5370 "WAKE UP",
5371 "STOP FIRMWARE",

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

5414 NULL,
5415 "LOOP PORT BYPASS",
5416 "LOOP PORT ENABLE",
5417 "GET RESOURCE COUNTS",
5418 "REQUEST NON PARTICIPATING MODE",
5419 NULL,
5420 NULL,
5421 NULL,
5345 "GET PORT DATABASE,, ENHANCED",
5422 "GET PORT DATABASE ENHANCED",
5346 NULL,
5347 NULL,
5348 NULL,
5349 NULL,
5350 NULL,
5351 NULL,
5352 NULL,
5353 NULL,

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

5460 mbp->param[0] = MBOX_INVALID_COMMAND;
5461 isp_prt(isp, ISP_LOGERR, "Unknown Command 0x%x", opcode);
5462 return;
5463 }
5464
5465 ibits = HIWRD(mcp[opcode]) & NMBOX_BMASK(isp);
5466 obits = LOWRD(mcp[opcode]) & NMBOX_BMASK(isp);
5467
5423 NULL,
5424 NULL,
5425 NULL,
5426 NULL,
5427 NULL,
5428 NULL,
5429 NULL,
5430 NULL,

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

5537 mbp->param[0] = MBOX_INVALID_COMMAND;
5538 isp_prt(isp, ISP_LOGERR, "Unknown Command 0x%x", opcode);
5539 return;
5540 }
5541
5542 ibits = HIWRD(mcp[opcode]) & NMBOX_BMASK(isp);
5543 obits = LOWRD(mcp[opcode]) & NMBOX_BMASK(isp);
5544
5545 /*
5546 * Pick up any additional bits that the caller might have set.
5547 */
5468 ibits |= mbp->ibits;
5469 obits |= mbp->obits;
5470
5471 if (ibits == 0 && obits == 0) {
5472 mbp->param[0] = MBOX_COMMAND_PARAM_ERROR;
5473 isp_prt(isp, ISP_LOGERR, "no parameters for 0x%x", opcode);
5474 return;
5475 }

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

5499 */
5500 ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT);
5501
5502 /*
5503 * While we haven't finished the command, spin our wheels here.
5504 */
5505 MBOX_WAIT_COMPLETE(isp);
5506
5548 ibits |= mbp->ibits;
5549 obits |= mbp->obits;
5550
5551 if (ibits == 0 && obits == 0) {
5552 mbp->param[0] = MBOX_COMMAND_PARAM_ERROR;
5553 isp_prt(isp, ISP_LOGERR, "no parameters for 0x%x", opcode);
5554 return;
5555 }

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

5579 */
5580 ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT);
5581
5582 /*
5583 * While we haven't finished the command, spin our wheels here.
5584 */
5585 MBOX_WAIT_COMPLETE(isp);
5586
5587 /*
5588 * Did the command time out?
5589 */
5507 if (isp->isp_mboxbsy) {
5590 if (isp->isp_mboxbsy) {
5508 /*
5509 * Command timed out.
5510 */
5511 isp->isp_mboxbsy = 0;
5512 MBOX_RELEASE(isp);
5513 return;
5514 }
5515
5516 /*
5517 * Copy back output registers.
5518 */

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

5768 /* Platform specific.... */
5769 fcp->isp_loopid = DEFAULT_LOOPID(isp);
5770 fcp->isp_nodewwn = DEFAULT_NODEWWN(isp);
5771 fcp->isp_portwwn = DEFAULT_PORTWWN(isp);
5772 fcp->isp_fwoptions = 0;
5773 fcp->isp_fwoptions |= ICBOPT_FAIRNESS;
5774 fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
5775 fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS;
5591 isp->isp_mboxbsy = 0;
5592 MBOX_RELEASE(isp);
5593 return;
5594 }
5595
5596 /*
5597 * Copy back output registers.
5598 */

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

5848 /* Platform specific.... */
5849 fcp->isp_loopid = DEFAULT_LOOPID(isp);
5850 fcp->isp_nodewwn = DEFAULT_NODEWWN(isp);
5851 fcp->isp_portwwn = DEFAULT_PORTWWN(isp);
5852 fcp->isp_fwoptions = 0;
5853 fcp->isp_fwoptions |= ICBOPT_FAIRNESS;
5854 fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
5855 fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS;
5776#ifndef ISP_NO_FASTPOST_FC
5777 fcp->isp_fwoptions |= ICBOPT_FAST_POST;
5856 fcp->isp_fwoptions |= ICBOPT_FAST_POST;
5778#endif
5779 if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX)
5780 fcp->isp_fwoptions |= ICBOPT_FULL_DUPLEX;
5781
5782 /*
5783 * Make sure this is turned off now until we get
5784 * extended options from NVRAM
5785 */
5786 fcp->isp_fwoptions &= ~ICBOPT_EXTENDED;
5787
5788 /*
5789 * Now try and read NVRAM unless told to not do so.
5790 * This will set fcparam's isp_nodewwn && isp_portwwn.
5791 */
5792 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
5793 nvfail = isp_read_nvram(isp);
5857 if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX)
5858 fcp->isp_fwoptions |= ICBOPT_FULL_DUPLEX;
5859
5860 /*
5861 * Make sure this is turned off now until we get
5862 * extended options from NVRAM
5863 */
5864 fcp->isp_fwoptions &= ~ICBOPT_EXTENDED;
5865
5866 /*
5867 * Now try and read NVRAM unless told to not do so.
5868 * This will set fcparam's isp_nodewwn && isp_portwwn.
5869 */
5870 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
5871 nvfail = isp_read_nvram(isp);
5794 if (nvfail)
5872 if (nvfail) {
5795 isp->isp_confopts |= ISP_CFG_NONVRAM;
5873 isp->isp_confopts |= ISP_CFG_NONVRAM;
5874 }
5796 } else {
5797 nvfail = 1;
5798 }
5799 /*
5800 * Set node && port to override platform set defaults
5801 * unless the nvram read failed (or none was done),
5802 * or the platform code wants to use what had been
5803 * set in the defaults.

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

5811 (uint32_t) (DEFAULT_NODEWWN(isp) & 0xffffffff));
5812 ISP_NODEWWN(isp) = DEFAULT_NODEWWN(isp);
5813 } else {
5814 /*
5815 * We always start out with values derived
5816 * from NVRAM or our platform default.
5817 */
5818 ISP_NODEWWN(isp) = fcp->isp_nodewwn;
5875 } else {
5876 nvfail = 1;
5877 }
5878 /*
5879 * Set node && port to override platform set defaults
5880 * unless the nvram read failed (or none was done),
5881 * or the platform code wants to use what had been
5882 * set in the defaults.

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

5890 (uint32_t) (DEFAULT_NODEWWN(isp) & 0xffffffff));
5891 ISP_NODEWWN(isp) = DEFAULT_NODEWWN(isp);
5892 } else {
5893 /*
5894 * We always start out with values derived
5895 * from NVRAM or our platform default.
5896 */
5897 ISP_NODEWWN(isp) = fcp->isp_nodewwn;
5898 if (fcp->isp_nodewwn == 0) {
5899 isp_prt(isp, ISP_LOGCONFIG,
5900 "bad WWNN- using default\n");
5901 ISP_NODEWWN(isp) = DEFAULT_NODEWWN(isp);
5902 }
5819 }
5820 if (isp->isp_confopts & ISP_CFG_OWNWWPN) {
5821 isp_prt(isp, ISP_LOGCONFIG, "Using Port WWN 0x%08x%08x",
5822 (uint32_t) (DEFAULT_PORTWWN(isp) >> 32),
5823 (uint32_t) (DEFAULT_PORTWWN(isp) & 0xffffffff));
5824 ISP_PORTWWN(isp) = DEFAULT_PORTWWN(isp);
5825 } else {
5826 /*
5827 * We always start out with values derived
5828 * from NVRAM or our platform default.
5829 */
5830 ISP_PORTWWN(isp) = fcp->isp_portwwn;
5903 }
5904 if (isp->isp_confopts & ISP_CFG_OWNWWPN) {
5905 isp_prt(isp, ISP_LOGCONFIG, "Using Port WWN 0x%08x%08x",
5906 (uint32_t) (DEFAULT_PORTWWN(isp) >> 32),
5907 (uint32_t) (DEFAULT_PORTWWN(isp) & 0xffffffff));
5908 ISP_PORTWWN(isp) = DEFAULT_PORTWWN(isp);
5909 } else {
5910 /*
5911 * We always start out with values derived
5912 * from NVRAM or our platform default.
5913 */
5914 ISP_PORTWWN(isp) = fcp->isp_portwwn;
5915 if (fcp->isp_portwwn == 0) {
5916 isp_prt(isp, ISP_LOGCONFIG,
5917 "bad WWPN- using default\n");
5918 ISP_PORTWWN(isp) = DEFAULT_PORTWWN(isp);
5919 }
5831 }
5832 return;
5833 }
5834
5835 sdp = (sdparam *) isp->isp_param;
5836 sdp += channel;
5837
5838 /*

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

6014}
6015
6016/*
6017 * NVRAM Routines
6018 */
6019static int
6020isp_read_nvram(ispsoftc_t *isp)
6021{
5920 }
5921 return;
5922 }
5923
5924 sdp = (sdparam *) isp->isp_param;
5925 sdp += channel;
5926
5927 /*

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

6103}
6104
6105/*
6106 * NVRAM Routines
6107 */
6108static int
6109isp_read_nvram(ispsoftc_t *isp)
6110{
6022 int i, amt;
6111 int i, amt, retval;
6023 uint8_t csum, minversion;
6024 union {
6025 uint8_t _x[ISP2100_NVRAM_SIZE];
6026 uint16_t _s[ISP2100_NVRAM_SIZE>>1];
6027 } _n;
6028#define nvram_data _n._x
6029#define nvram_words _n._s
6030

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

6048 }
6049 if (nvram_data[0] != 'I' || nvram_data[1] != 'S' ||
6050 nvram_data[2] != 'P') {
6051 if (isp->isp_bustype != ISP_BT_SBUS) {
6052 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM header");
6053 isp_prt(isp, ISP_LOGDEBUG0, "%x %x %x",
6054 nvram_data[0], nvram_data[1], nvram_data[2]);
6055 }
6112 uint8_t csum, minversion;
6113 union {
6114 uint8_t _x[ISP2100_NVRAM_SIZE];
6115 uint16_t _s[ISP2100_NVRAM_SIZE>>1];
6116 } _n;
6117#define nvram_data _n._x
6118#define nvram_words _n._s
6119

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

6137 }
6138 if (nvram_data[0] != 'I' || nvram_data[1] != 'S' ||
6139 nvram_data[2] != 'P') {
6140 if (isp->isp_bustype != ISP_BT_SBUS) {
6141 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM header");
6142 isp_prt(isp, ISP_LOGDEBUG0, "%x %x %x",
6143 nvram_data[0], nvram_data[1], nvram_data[2]);
6144 }
6056 return (-1);
6145 retval = -1;
6146 goto out;
6057 }
6058 for (i = 2; i < amt>>1; i++) {
6059 isp_rdnvram_word(isp, i, &nvram_words[i]);
6060 }
6061 for (csum = 0, i = 0; i < amt; i++) {
6062 csum += nvram_data[i];
6063 }
6064 if (csum != 0) {
6065 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM checksum");
6147 }
6148 for (i = 2; i < amt>>1; i++) {
6149 isp_rdnvram_word(isp, i, &nvram_words[i]);
6150 }
6151 for (csum = 0, i = 0; i < amt; i++) {
6152 csum += nvram_data[i];
6153 }
6154 if (csum != 0) {
6155 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM checksum");
6066 return (-1);
6156 retval = -1;
6157 goto out;
6067 }
6068 if (ISP_NVRAM_VERSION(nvram_data) < minversion) {
6069 isp_prt(isp, ISP_LOGWARN, "version %d NVRAM not understood",
6070 ISP_NVRAM_VERSION(nvram_data));
6158 }
6159 if (ISP_NVRAM_VERSION(nvram_data) < minversion) {
6160 isp_prt(isp, ISP_LOGWARN, "version %d NVRAM not understood",
6161 ISP_NVRAM_VERSION(nvram_data));
6071 return (-1);
6162 retval = -1;
6163 goto out;
6072 }
6073
6074 if (IS_ULTRA3(isp)) {
6075 isp_parse_nvram_12160(isp, 0, nvram_data);
6076 if (IS_12160(isp))
6077 isp_parse_nvram_12160(isp, 1, nvram_data);
6078 } else if (IS_1080(isp)) {
6079 isp_parse_nvram_1080(isp, 0, nvram_data);
6080 } else if (IS_1280(isp) || IS_1240(isp)) {
6081 isp_parse_nvram_1080(isp, 0, nvram_data);
6082 isp_parse_nvram_1080(isp, 1, nvram_data);
6083 } else if (IS_SCSI(isp)) {
6084 isp_parse_nvram_1020(isp, nvram_data);
6085 } else {
6086 isp_parse_nvram_2100(isp, nvram_data);
6087 }
6164 }
6165
6166 if (IS_ULTRA3(isp)) {
6167 isp_parse_nvram_12160(isp, 0, nvram_data);
6168 if (IS_12160(isp))
6169 isp_parse_nvram_12160(isp, 1, nvram_data);
6170 } else if (IS_1080(isp)) {
6171 isp_parse_nvram_1080(isp, 0, nvram_data);
6172 } else if (IS_1280(isp) || IS_1240(isp)) {
6173 isp_parse_nvram_1080(isp, 0, nvram_data);
6174 isp_parse_nvram_1080(isp, 1, nvram_data);
6175 } else if (IS_SCSI(isp)) {
6176 isp_parse_nvram_1020(isp, nvram_data);
6177 } else {
6178 isp_parse_nvram_2100(isp, nvram_data);
6179 }
6088 return (0);
6180 retval = 0;
6181out:
6182 return (retval);
6089#undef nvram_data
6090#undef nvram_words
6091}
6092
6093static void
6094isp_rdnvram_word(ispsoftc_t *isp, int wo, uint16_t *rp)
6095{
6096 int i, cbits;
6183#undef nvram_data
6184#undef nvram_words
6185}
6186
6187static void
6188isp_rdnvram_word(ispsoftc_t *isp, int wo, uint16_t *rp)
6189{
6190 int i, cbits;
6097 uint16_t bit, rqst;
6191 uint16_t bit, rqst, junk;
6098
6099 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
6192
6193 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
6100 USEC_DELAY(2);
6194 USEC_DELAY(10);
6101 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
6195 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
6102 USEC_DELAY(2);
6196 USEC_DELAY(10);
6103
6104 if (IS_FC(isp)) {
6197
6198 if (IS_FC(isp)) {
6105 wo &= ((ISP2100_NVRAM_SIZE >> 1) - 1);
6199 wo &= ((ISP2100_NVRAM_SIZE >> 1) - 1);
6106 if (IS_2312(isp) && isp->isp_port) {
6107 wo += 128;
6108 }
6109 rqst = (ISP_NVRAM_READ << 8) | wo;
6110 cbits = 10;
6111 } else if (IS_ULTRA2(isp)) {
6112 wo &= ((ISP1080_NVRAM_SIZE >> 1) - 1);
6113 rqst = (ISP_NVRAM_READ << 8) | wo;

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

6123 */
6124 for (i = cbits; i >= 0; i--) {
6125 if ((rqst >> i) & 1) {
6126 bit = BIU_NVRAM_SELECT | BIU_NVRAM_DATAOUT;
6127 } else {
6128 bit = BIU_NVRAM_SELECT;
6129 }
6130 ISP_WRITE(isp, BIU_NVRAM, bit);
6200 if (IS_2312(isp) && isp->isp_port) {
6201 wo += 128;
6202 }
6203 rqst = (ISP_NVRAM_READ << 8) | wo;
6204 cbits = 10;
6205 } else if (IS_ULTRA2(isp)) {
6206 wo &= ((ISP1080_NVRAM_SIZE >> 1) - 1);
6207 rqst = (ISP_NVRAM_READ << 8) | wo;

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

6217 */
6218 for (i = cbits; i >= 0; i--) {
6219 if ((rqst >> i) & 1) {
6220 bit = BIU_NVRAM_SELECT | BIU_NVRAM_DATAOUT;
6221 } else {
6222 bit = BIU_NVRAM_SELECT;
6223 }
6224 ISP_WRITE(isp, BIU_NVRAM, bit);
6131 USEC_DELAY(2);
6225 USEC_DELAY(10);
6226 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
6132 ISP_WRITE(isp, BIU_NVRAM, bit | BIU_NVRAM_CLOCK);
6227 ISP_WRITE(isp, BIU_NVRAM, bit | BIU_NVRAM_CLOCK);
6133 USEC_DELAY(2);
6228 USEC_DELAY(10);
6229 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
6134 ISP_WRITE(isp, BIU_NVRAM, bit);
6230 ISP_WRITE(isp, BIU_NVRAM, bit);
6135 USEC_DELAY(2);
6231 USEC_DELAY(10);
6232 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
6136 }
6137 /*
6138 * Now read the result back in (bits come back in MSB format).
6139 */
6140 *rp = 0;
6141 for (i = 0; i < 16; i++) {
6142 uint16_t rv;
6143 *rp <<= 1;
6144 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
6233 }
6234 /*
6235 * Now read the result back in (bits come back in MSB format).
6236 */
6237 *rp = 0;
6238 for (i = 0; i < 16; i++) {
6239 uint16_t rv;
6240 *rp <<= 1;
6241 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
6145 USEC_DELAY(2);
6242 USEC_DELAY(10);
6146 rv = ISP_READ(isp, BIU_NVRAM);
6147 if (rv & BIU_NVRAM_DATAIN) {
6148 *rp |= 1;
6149 }
6243 rv = ISP_READ(isp, BIU_NVRAM);
6244 if (rv & BIU_NVRAM_DATAIN) {
6245 *rp |= 1;
6246 }
6150 USEC_DELAY(2);
6247 USEC_DELAY(10);
6151 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
6248 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
6152 USEC_DELAY(2);
6249 USEC_DELAY(10);
6250 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
6153 }
6154 ISP_WRITE(isp, BIU_NVRAM, 0);
6251 }
6252 ISP_WRITE(isp, BIU_NVRAM, 0);
6155 USEC_DELAY(2);
6253 USEC_DELAY(10);
6254 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
6156 ISP_SWIZZLE_NVRAM_WORD(isp, rp);
6157}
6158
6159static void
6160isp_parse_nvram_1020(ispsoftc_t *isp, uint8_t *nvram_data)
6161{
6162 sdparam *sdp = (sdparam *) isp->isp_param;
6163 int tgt;

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

6487 isp_prt(isp, ISP_LOGCONFIG, "NVRAM Port WWN 0x%08x%08x",
6488 (uint32_t) (wwn >> 32), (uint32_t) (wwn & 0xffffffff));
6489 if ((wwn >> 60) == 0) {
6490 wwn |= (((uint64_t) 2)<< 60);
6491 }
6492 }
6493 fcp->isp_portwwn = wwn;
6494 if (IS_2200(isp) || IS_23XX(isp)) {
6255 ISP_SWIZZLE_NVRAM_WORD(isp, rp);
6256}
6257
6258static void
6259isp_parse_nvram_1020(ispsoftc_t *isp, uint8_t *nvram_data)
6260{
6261 sdparam *sdp = (sdparam *) isp->isp_param;
6262 int tgt;

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

6586 isp_prt(isp, ISP_LOGCONFIG, "NVRAM Port WWN 0x%08x%08x",
6587 (uint32_t) (wwn >> 32), (uint32_t) (wwn & 0xffffffff));
6588 if ((wwn >> 60) == 0) {
6589 wwn |= (((uint64_t) 2)<< 60);
6590 }
6591 }
6592 fcp->isp_portwwn = wwn;
6593 if (IS_2200(isp) || IS_23XX(isp)) {
6495 wwn = ISP2200_NVRAM_NODE_NAME(nvram_data);
6594 wwn = ISP2100_NVRAM_NODE_NAME(nvram_data);
6496 if (wwn) {
6497 isp_prt(isp, ISP_LOGCONFIG, "NVRAM Node WWN 0x%08x%08x",
6498 (uint32_t) (wwn >> 32),
6499 (uint32_t) (wwn & 0xffffffff));
6500 if ((wwn >> 60) == 0) {
6501 wwn |= (((uint64_t) 2)<< 60);
6502 }
6503 }

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

6527 fcp->isp_nodewwn &= ~((uint64_t) 0xfff << 48);
6528 }
6529 if ((fcp->isp_portwwn & (((uint64_t) 0xfff) << 48)) == 0 &&
6530 (fcp->isp_portwwn >> 60) == 2) {
6531 fcp->isp_portwwn |= ((uint64_t) 1 << 56);
6532 }
6533 }
6534
6595 if (wwn) {
6596 isp_prt(isp, ISP_LOGCONFIG, "NVRAM Node WWN 0x%08x%08x",
6597 (uint32_t) (wwn >> 32),
6598 (uint32_t) (wwn & 0xffffffff));
6599 if ((wwn >> 60) == 0) {
6600 wwn |= (((uint64_t) 2)<< 60);
6601 }
6602 }

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

6626 fcp->isp_nodewwn &= ~((uint64_t) 0xfff << 48);
6627 }
6628 if ((fcp->isp_portwwn & (((uint64_t) 0xfff) << 48)) == 0 &&
6629 (fcp->isp_portwwn >> 60) == 2) {
6630 fcp->isp_portwwn |= ((uint64_t) 1 << 56);
6631 }
6632 }
6633
6535 isp_prt(isp, ISP_LOGDEBUG0,
6536 "NVRAM: maxfrmlen %d execthrottle %d fwoptions 0x%x loopid %x",
6537 ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data),
6538 ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data),
6539 ISP2100_NVRAM_OPTIONS(nvram_data),
6540 ISP2100_NVRAM_HARDLOOPID(nvram_data));
6541
6542 fcp->isp_maxalloc =
6543 ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data);
6544 if ((isp->isp_confopts & ISP_CFG_OWNFSZ) == 0)
6545 fcp->isp_maxfrmlen =
6546 ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data);
6547 fcp->isp_retry_delay =
6548 ISP2100_NVRAM_RETRY_DELAY(nvram_data);
6549 fcp->isp_retry_count =
6550 ISP2100_NVRAM_RETRY_COUNT(nvram_data);
6551 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0)
6552 fcp->isp_loopid =
6553 ISP2100_NVRAM_HARDLOOPID(nvram_data);
6554 if ((isp->isp_confopts & ISP_CFG_OWNEXCTHROTTLE) == 0)
6555 fcp->isp_execthrottle =
6556 ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data);
6557 fcp->isp_fwoptions = ISP2100_NVRAM_OPTIONS(nvram_data);
6634 fcp->isp_maxalloc =
6635 ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data);
6636 if ((isp->isp_confopts & ISP_CFG_OWNFSZ) == 0)
6637 fcp->isp_maxfrmlen =
6638 ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data);
6639 fcp->isp_retry_delay =
6640 ISP2100_NVRAM_RETRY_DELAY(nvram_data);
6641 fcp->isp_retry_count =
6642 ISP2100_NVRAM_RETRY_COUNT(nvram_data);
6643 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0)
6644 fcp->isp_loopid =
6645 ISP2100_NVRAM_HARDLOOPID(nvram_data);
6646 if ((isp->isp_confopts & ISP_CFG_OWNEXCTHROTTLE) == 0)
6647 fcp->isp_execthrottle =
6648 ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data);
6649 fcp->isp_fwoptions = ISP2100_NVRAM_OPTIONS(nvram_data);
6650 isp_prt(isp, ISP_LOGDEBUG0,
6651 "NVRAM 0x%08x%08x 0x%08x%08x maxalloc %d maxframelen %d",
6652 (uint32_t) (fcp->isp_nodewwn >> 32), (uint32_t) fcp->isp_nodewwn,
6653 (uint32_t) (fcp->isp_portwwn >> 32), (uint32_t) fcp->isp_portwwn,
6654 ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data),
6655 ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data));
6656 isp_prt(isp, ISP_LOGDEBUG0,
6657 "execthrottle %d fwoptions 0x%x hardloop %d tov %d",
6658 ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data),
6659 ISP2100_NVRAM_OPTIONS(nvram_data),
6660 ISP2100_NVRAM_HARDLOOPID(nvram_data),
6661 ISP2100_NVRAM_TOV(nvram_data));
6662 fcp->isp_xfwoptions = ISP2100_XFW_OPTIONS(nvram_data);
6663 fcp->isp_zfwoptions = ISP2100_ZFW_OPTIONS(nvram_data);
6664 isp_prt(isp, ISP_LOGDEBUG0,
6665 "xfwoptions 0x%x zfw options 0x%x",
6666 ISP2100_XFW_OPTIONS(nvram_data), ISP2100_ZFW_OPTIONS(nvram_data));
6558}
6559
6560#ifdef ISP_FW_CRASH_DUMP
6561static void isp2200_fw_dump(ispsoftc_t *);
6562static void isp2300_fw_dump(ispsoftc_t *);
6563
6564static void
6565isp2200_fw_dump(ispsoftc_t *isp)

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

6839 isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
6840 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
6841 isp_prt(isp, ISP_LOGWARN,
6842 "RAM DUMP FAILED @ WORD %x", isp->isp_mbxwrk1);
6843 return;
6844 }
6845 ptr = isp->isp_mbxworkp; /* finish fetch of final word */
6846 *ptr++ = isp->isp_mboxtmp[2];
6667}
6668
6669#ifdef ISP_FW_CRASH_DUMP
6670static void isp2200_fw_dump(ispsoftc_t *);
6671static void isp2300_fw_dump(ispsoftc_t *);
6672
6673static void
6674isp2200_fw_dump(ispsoftc_t *isp)

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

6948 isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
6949 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
6950 isp_prt(isp, ISP_LOGWARN,
6951 "RAM DUMP FAILED @ WORD %x", isp->isp_mbxwrk1);
6952 return;
6953 }
6954 ptr = isp->isp_mbxworkp; /* finish fetch of final word */
6955 *ptr++ = isp->isp_mboxtmp[2];
6847
6848 /*
6849 * We don't have access to mailbox registers 8.. onward
6850 * in our 'common' device model- so we have to set it
6851 * here and hope it stays the same!
6852 */
6853 ISP_WRITE(isp, PCI_MBOX_REGS2300_OFF + (8 << 1), 0x1);
6854
6855 mbs.param[0] = MBOX_READ_RAM_WORD_EXTENDED;
6856 mbs.param[1] = 0;
6956 mbs.param[0] = MBOX_READ_RAM_WORD_EXTENDED;
6957 mbs.param[1] = 0;
6958 mbs.param[8] = 1;
6857 isp->isp_mbxworkp = (void *) ptr;
6858 isp->isp_mbxwrk0 = 0xffff; /* continuation count */
6859 isp->isp_mbxwrk1 = 0x1; /* next SRAM address */
6959 isp->isp_mbxworkp = (void *) ptr;
6960 isp->isp_mbxwrk0 = 0xffff; /* continuation count */
6961 isp->isp_mbxwrk1 = 0x1; /* next SRAM address */
6962 isp->isp_mbxwrk8 = 0x1;
6860 isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
6861 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
6862 isp_prt(isp, ISP_LOGWARN,
6863 "RAM DUMP FAILED @ WORD %x", 0x10000 + isp->isp_mbxwrk1);
6864 return;
6865 }
6866 ptr = isp->isp_mbxworkp; /* finish final word */
6867 *ptr++ = mbs.param[2];

--- 14 unchanged lines hidden ---
6963 isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
6964 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
6965 isp_prt(isp, ISP_LOGWARN,
6966 "RAM DUMP FAILED @ WORD %x", 0x10000 + isp->isp_mbxwrk1);
6967 return;
6968 }
6969 ptr = isp->isp_mbxworkp; /* finish final word */
6970 *ptr++ = mbs.param[2];

--- 14 unchanged lines hidden ---