Deleted Added
sdiff udiff text old ( 151834 ) new ( 154704 )
full compact
1/* $FreeBSD: head/sys/dev/isp/isp.c 151834 2005-10-29 02:46:59Z mjacob $ */
2/*-
3 * Machine and OS Independent (well, as best as possible)
4 * code for the Qlogic ISP SCSI adapters.
5 *
6 * Copyright (c) 1997, 1998, 1999, 2000, 2001 by Matthew Jacob
7 * Feral Software
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice immediately at the beginning of the file, without modification,
15 * this list of conditions, and the following disclaimer.

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

38/*
39 * Include header file appropriate for platform we're building on.
40 */
41
42#ifdef __NetBSD__
43#include <dev/ic/isp_netbsd.h>
44#endif
45#ifdef __FreeBSD__
46#include <dev/isp/isp_freebsd.h>
47#endif
48#ifdef __OpenBSD__
49#include <dev/ic/isp_openbsd.h>
50#endif
51#ifdef __linux__
52#include "isp_linux.h"
53#endif

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

90 "HBA attempted queued transaction with disconnect not set for %d.%d.%d";
91static const char xact2[] =
92 "HBA attempted queued transaction to target routine %d on target %d bus %d";
93static const char xact3[] =
94 "HBA attempted queued cmd for %d.%d.%d when queueing disabled";
95static const char pskip[] =
96 "SCSI phase skipped for target %d.%d.%d";
97static const char topology[] =
98 "Loop ID %d, AL_PA 0x%x, Port ID 0x%x, Loop State 0x%x, Topology '%s'";
99static const char swrej[] =
100 "Fabric Nameserver rejected %s (Reason=0x%x Expl=0x%x) for Port ID 0x%x";
101static const char finmsg[] =
102 "(%d.%d.%d): FIN dl%d resid %d STS 0x%x SKEY %c XS_ERR=0x%x";
103static const char sc0[] =
104 "%s CHAN %d FTHRSH %d IID %d RESETD %d RETRYC %d RETRYD %d ASD 0x%x";
105static const char sc1[] =
106 "%s RAAN 0x%x DLAN 0x%x DDMAB 0x%x CDMAB 0x%x SELTIME %d MQD %d";

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

160isp_reset(struct ispsoftc *isp)
161{
162 mbreg_t mbs;
163 u_int16_t code_org;
164 int loops, i, dodnld = 1;
165 char *btype = "????";
166
167 isp->isp_state = ISP_NILSTATE;
168
169 /*
170 * Basic types (SCSI, FibreChannel and PCI or SBus)
171 * have been set in the MD code. We figure out more
172 * here. Possibly more refined types based upon PCI
173 * identification. Chip revision has been gathered.
174 *
175 * After we've fired this chip up, zero out the conf1 register

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

247 btype = "2200";
248 break;
249 case ISP_HA_FC_2300:
250 btype = "2300";
251 break;
252 case ISP_HA_FC_2312:
253 btype = "2312";
254 break;
255 default:
256 break;
257 }
258 /*
259 * While we're paused, reset the FPM module and FBM fifos.
260 */
261 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS);
262 ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET);

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

672 *
673 * If we didn't actually download f/w,
674 * we still need to (re)start it.
675 */
676
677
678 mbs.param[0] = MBOX_EXEC_FIRMWARE;
679 mbs.param[1] = code_org;
680 isp_mboxcmd(isp, &mbs, MBLOGNONE);
681 /*
682 * Give it a chance to start.
683 */
684 USEC_DELAY(500);
685
686 if (IS_SCSI(isp)) {
687 /*

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

741#else
742 FCPARAM(isp)->isp_fwattr = 0;
743#endif
744 } else {
745 FCPARAM(isp)->isp_fwattr = mbs.param[6];
746 isp_prt(isp, ISP_LOGDEBUG0,
747 "Firmware Attributes = 0x%x", mbs.param[6]);
748 }
749 if (ISP_READ(isp, BIU2100_CSR) & BIU2100_PCI64) {
750 isp_prt(isp, ISP_LOGCONFIG,
751 "Installed in 64-Bit PCI slot");
752 }
753 }
754
755 if (isp->isp_romfw_rev[0] || isp->isp_romfw_rev[1] ||
756 isp->isp_romfw_rev[2]) {
757 isp_prt(isp, ISP_LOGCONFIG, "Last F/W revision was %d.%d.%d",
758 isp->isp_romfw_rev[0], isp->isp_romfw_rev[1],
759 isp->isp_romfw_rev[2]);

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

864 if (sdp_chan0->isp_fast_mttr) {
865 ISP_WRITE(isp, RISC_MTR, 0x1313);
866 }
867
868 /*
869 * Set Retry Delay and Count.
870 * You set both channels at the same time.
871 */
872 mbs.param[0] = MBOX_SET_RETRY_COUNT;
873 mbs.param[1] = sdp_chan0->isp_retry_count;
874 mbs.param[2] = sdp_chan0->isp_retry_delay;
875 mbs.param[6] = sdp_chan1->isp_retry_count;
876 mbs.param[7] = sdp_chan1->isp_retry_delay;
877
878 isp_mboxcmd(isp, &mbs, MBLOGALL);
879 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {

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

1043 int tgt;
1044
1045 sdp = isp->isp_param;
1046 sdp += channel;
1047
1048 /*
1049 * Set (possibly new) Initiator ID.
1050 */
1051 mbs.param[0] = MBOX_SET_INIT_SCSI_ID;
1052 mbs.param[1] = (channel << 7) | sdp->isp_initiator_id;
1053 isp_mboxcmd(isp, &mbs, MBLOGALL);
1054 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1055 return;
1056 }
1057 isp_prt(isp, ISP_LOGINFO, "Initiator ID is %d on Channel %d",
1058 sdp->isp_initiator_id, channel);

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

1252 fcp->isp_execthrottle);
1253 icbp->icb_execthrottle = ICB_DFLT_THROTTLE;
1254 }
1255 icbp->icb_retry_delay = fcp->isp_retry_delay;
1256 icbp->icb_retry_count = fcp->isp_retry_count;
1257 icbp->icb_hardaddr = loopid;
1258 if (icbp->icb_hardaddr >= 125) {
1259 /*
1260 * We end up with a Loop ID of 255 for F-Port topologies
1261 */
1262 if (icbp->icb_hardaddr != 255) {
1263 isp_prt(isp, ISP_LOGERR,
1264 "bad hard address %u- resetting to zero",
1265 icbp->icb_hardaddr);
1266 }
1267 icbp->icb_hardaddr = 0;
1268 }
1269 /*
1270 * Right now we just set extended options to prefer point-to-point

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

1349 if (!IS_23XX(isp) && ISP_FW_NEWER_THAN(isp, 1, 17, 0)) {
1350 icbp->icb_xfwoptions |= ICBXOPT_RIO_16BIT;
1351 icbp->icb_racctimer = 4;
1352 icbp->icb_idelaytimer = 8;
1353 }
1354#endif
1355#endif
1356
1357 /*
1358 * For 22XX > 2.1.26 && 23XX, set someoptions.
1359 * XXX: Probably okay for newer 2100 f/w too.
1360 */
1361 if (ISP_FW_NEWER_THAN(isp, 2, 26, 0)) {
1362 /*
1363 * Turn on LIP F8 async event (1)
1364 * Turn on generate AE 8013 on all LIP Resets (2)
1365 * Disable LIP F7 switching (8)
1366 */

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

1452 */
1453
1454static int
1455isp_getmap(struct ispsoftc *isp, fcpos_map_t *map)
1456{
1457 fcparam *fcp = (fcparam *) isp->isp_param;
1458 mbreg_t mbs;
1459
1460 mbs.param[0] = MBOX_GET_FC_AL_POSITION_MAP;
1461 mbs.param[1] = 0;
1462 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
1463 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
1464 /*
1465 * Unneeded. For the 2100, except for initializing f/w, registers
1466 * 4/5 have to not be written to.
1467 * mbs.param[4] = 0;

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

1493}
1494
1495static int
1496isp_getpdb(struct ispsoftc *isp, int id, isp_pdb_t *pdbp)
1497{
1498 fcparam *fcp = (fcparam *) isp->isp_param;
1499 mbreg_t mbs;
1500
1501 mbs.param[0] = MBOX_GET_PORT_DB;
1502 mbs.param[1] = id << 8;
1503 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
1504 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
1505 /*
1506 * Unneeded. For the 2100, except for initializing f/w, registers
1507 * 4/5 have to not be written to.
1508 * mbs.param[4] = 0;
1509 * mbs.param[5] = 0;
1510 *

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

1523}
1524
1525static u_int64_t
1526isp_get_portname(struct ispsoftc *isp, int loopid, int nodename)
1527{
1528 u_int64_t wwn = 0;
1529 mbreg_t mbs;
1530
1531 mbs.param[0] = MBOX_GET_PORT_NAME;
1532 mbs.param[1] = loopid << 8;
1533 if (nodename)
1534 mbs.param[1] |= 1;
1535 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR);
1536 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1537 wwn =
1538 (((u_int64_t)(mbs.param[2] & 0xff)) << 56) |
1539 (((u_int64_t)(mbs.param[2] >> 8)) << 48) |
1540 (((u_int64_t)(mbs.param[3] & 0xff)) << 40) |
1541 (((u_int64_t)(mbs.param[3] >> 8)) << 32) |
1542 (((u_int64_t)(mbs.param[6] & 0xff)) << 24) |

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

1642 */
1643 if (fcp->isp_fwstate != FW_READY) {
1644 return (-1);
1645 }
1646
1647 /*
1648 * Get our Loop ID (if possible). We really need to have it.
1649 */
1650 mbs.param[0] = MBOX_GET_LOOP_ID;
1651 isp_mboxcmd(isp, &mbs, MBLOGALL);
1652 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1653 return (-1);
1654 }
1655 fcp->isp_loopid = mbs.param[1];
1656 if (IS_2200(isp) || IS_23XX(isp)) {
1657 int topo = (int) mbs.param[6];
1658 if (topo < TOPO_NL_PORT || topo > TOPO_PTP_STUB)
1659 topo = TOPO_PTP_STUB;
1660 fcp->isp_topo = topo;
1661 } else {
1662 fcp->isp_topo = TOPO_NL_PORT;
1663 }
1664 fcp->isp_portid = fcp->isp_alpa = mbs.param[2] & 0xff;
1665
1666 /*
1667 * Check to see if we're on a fabric by trying to see if we
1668 * can talk to the fabric name server. This can be a bit
1669 * tricky because if we're a 2100, we should check always
1670 * (in case we're connected to a server doing aliasing).
1671 */
1672 fcp->isp_onfabric = 0;

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

1747 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1748 if (mbs.param[1] == MBGSD_TWOGB) {
1749 isp_prt(isp, ISP_LOGINFO, "2Gb link speed/s");
1750 fcp->isp_gbspeed = 2;
1751 }
1752 }
1753 }
1754
1755 isp_prt(isp, ISP_LOGCONFIG, topology, fcp->isp_loopid, fcp->isp_alpa,
1756 fcp->isp_portid, fcp->isp_loopstate, toponames[fcp->isp_topo]);
1757
1758 /*
1759 * Announce ourselves, too. This involves synthesizing an entry.
1760 */
1761 if (fcp->isp_iid_set == 0) {
1762 fcp->isp_iid_set = 1;
1763 fcp->isp_iid = fcp->isp_loopid;

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

1961 }
1962
1963 /*
1964 * Force a logout if we were logged in.
1965 */
1966 if (lp->loggedin) {
1967 if (lp->force_logout ||
1968 isp_getpdb(isp, lp->loopid, &pdb) == 0) {
1969 mbs.param[0] = MBOX_FABRIC_LOGOUT;
1970 mbs.param[1] = lp->loopid << 8;
1971 mbs.param[2] = 0;
1972 mbs.param[3] = 0;
1973 isp_mboxcmd(isp, &mbs, MBLOGNONE);
1974 isp_prt(isp, ISP_LOGINFO, plogout,
1975 (int) (lp - fcp->portdb), lp->loopid,
1976 lp->portid);
1977 }
1978 lp->force_logout = lp->loggedin = 0;

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

1983 }
1984
1985 /*
1986 * And log in....
1987 */
1988 loopid = lp - fcp->portdb;
1989 lp->loopid = FL_PORT_ID;
1990 do {
1991 mbs.param[0] = MBOX_FABRIC_LOGIN;
1992 mbs.param[1] = loopid << 8;
1993 mbs.param[2] = portid >> 16;
1994 mbs.param[3] = portid & 0xffff;
1995 isp_mboxcmd(isp, &mbs, MBLOGALL & ~(MBOX_LOOP_ID_USED |
1996 MBOX_PORT_ID_USED | MBOX_COMMAND_ERROR));
1997 if (fcp->isp_fwstate != FW_READY ||
1998 fcp->isp_loopstate != LOOP_SYNCING_PDB) {
1999 return (-1);
2000 }

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

2099 loopid = lp - fcp->portdb;
2100 (void) isp_async(isp, ISPASYNC_PROMENADE, &loopid);
2101 continue;
2102 }
2103dump_em:
2104 lp->valid = 0;
2105 isp_prt(isp, ISP_LOGINFO,
2106 ldumped, loopid, lp->loopid, lp->portid);
2107 mbs.param[0] = MBOX_FABRIC_LOGOUT;
2108 mbs.param[1] = lp->loopid << 8;
2109 mbs.param[2] = 0;
2110 mbs.param[3] = 0;
2111 isp_mboxcmd(isp, &mbs, MBLOGNONE);
2112 if (fcp->isp_fwstate != FW_READY ||
2113 fcp->isp_loopstate != LOOP_SYNCING_PDB) {
2114 return (-1);
2115 }
2116 }
2117 /*
2118 * If we get here, we've for sure seen not only a valid loop

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

2483 rq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+0x100);
2484 rq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+0x100);
2485 rq->snscb_sblen = 6;
2486 rq->snscb_data[0] = SNS_GA_NXT;
2487 rq->snscb_data[4] = portid & 0xffff;
2488 rq->snscb_data[5] = (portid >> 16) & 0xff;
2489 isp_put_sns_request(isp, rq, (sns_screq_t *) fcp->isp_scratch);
2490 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GA_NXT_REQ_SIZE);
2491 mbs.param[0] = MBOX_SEND_SNS;
2492 mbs.param[1] = SNS_GA_NXT_REQ_SIZE >> 1;
2493 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2494 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2495 /*
2496 * Leave 4 and 5 alone
2497 */
2498 mbs.param[6] = DMA_WD3(fcp->isp_scdma);

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

2633 rq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+IGPOFF);
2634 rq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+IGPOFF);
2635 rq->snscb_sblen = 6;
2636 rq->snscb_cmd = SNS_GID_FT;
2637 rq->snscb_mword_div_2 = NGENT;
2638 rq->snscb_fc4_type = ftype;
2639 isp_put_gid_ft_request(isp, rq, (sns_gid_ft_req_t *) fcp->isp_scratch);
2640 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GID_FT_REQ_SIZE);
2641 mbs.param[0] = MBOX_SEND_SNS;
2642 mbs.param[1] = SNS_GID_FT_REQ_SIZE >> 1;
2643 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2644 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2645
2646 /*
2647 * Leave 4 and 5 alone
2648 */

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

2710 gq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+GXOFF);
2711 gq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+GXOFF);
2712 gq->snscb_sblen = 6;
2713 gq->snscb_cmd = SNS_GPN_ID;
2714 gq->snscb_portid = lcl.portid;
2715 isp_put_gxn_id_request(isp, gq,
2716 (sns_gxn_id_req_t *) fcp->isp_scratch);
2717 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GXN_ID_REQ_SIZE);
2718 mbs.param[0] = MBOX_SEND_SNS;
2719 mbs.param[1] = SNS_GXN_ID_REQ_SIZE >> 1;
2720 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2721 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2722 /*
2723 * Leave 4 and 5 alone
2724 */
2725 mbs.param[6] = DMA_WD3(fcp->isp_scdma);

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

2765 gq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+GXOFF);
2766 gq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+GXOFF);
2767 gq->snscb_sblen = 6;
2768 gq->snscb_cmd = SNS_GNN_ID;
2769 gq->snscb_portid = lcl.portid;
2770 isp_put_gxn_id_request(isp, gq,
2771 (sns_gxn_id_req_t *) fcp->isp_scratch);
2772 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GXN_ID_REQ_SIZE);
2773 mbs.param[0] = MBOX_SEND_SNS;
2774 mbs.param[1] = SNS_GXN_ID_REQ_SIZE >> 1;
2775 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2776 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2777 /*
2778 * Leave 4 and 5 alone
2779 */
2780 mbs.param[6] = DMA_WD3(fcp->isp_scdma);

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

2828 gq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+GXOFF);
2829 gq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+GXOFF);
2830 gq->snscb_sblen = 6;
2831 gq->snscb_cmd = SNS_GFF_ID;
2832 gq->snscb_portid = lcl.portid;
2833 isp_put_gxn_id_request(isp, gq,
2834 (sns_gxn_id_req_t *) fcp->isp_scratch);
2835 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GXN_ID_REQ_SIZE);
2836 mbs.param[0] = MBOX_SEND_SNS;
2837 mbs.param[1] = SNS_GXN_ID_REQ_SIZE >> 1;
2838 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2839 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2840 /*
2841 * Leave 4 and 5 alone
2842 */
2843 mbs.param[6] = DMA_WD3(fcp->isp_scdma);

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

2929 reqp->snscb_data[4] = fcp->isp_portid & 0xffff;
2930 reqp->snscb_data[5] = (fcp->isp_portid >> 16) & 0xff;
2931 reqp->snscb_data[6] = (1 << FC4_SCSI);
2932#if 0
2933 reqp->snscb_data[6] |= (1 << FC4_IP); /* ISO/IEC 8802-2 LLC/SNAP */
2934#endif
2935 FC_SCRATCH_ACQUIRE(isp);
2936 isp_put_sns_request(isp, reqp, (sns_screq_t *) fcp->isp_scratch);
2937 mbs.param[0] = MBOX_SEND_SNS;
2938 mbs.param[1] = SNS_RFT_ID_REQ_SIZE >> 1;
2939 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2940 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2941 /*
2942 * Leave 4 and 5 alone
2943 */
2944 mbs.param[6] = DMA_WD3(fcp->isp_scdma);

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

3268 } else {
3269 sdparam *sdp = (sdparam *)isp->isp_param;
3270 sdp += XS_CHANNEL(xs);
3271 if ((sdp->isp_devparam[target].actv_flags & DPARM_TQING) &&
3272 XS_TAG_P(xs)) {
3273 reqp->req_flags = XS_TAG_TYPE(xs);
3274 }
3275 }
3276 reqp->req_target = target | (XS_CHANNEL(xs) << 7);
3277 if (IS_SCSI(isp)) {
3278 reqp->req_lun_trn = XS_LUN(xs);
3279 reqp->req_cdblen = XS_CDBLEN(xs);
3280 } else {
3281 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN)
3282 ((ispreqt2_t *)reqp)->req_scclun = XS_LUN(xs);
3283 else
3284 ((ispreqt2_t *)reqp)->req_lun_trn = XS_LUN(xs);
3285 }
3286 MEMCPY(reqp->req_cdb, XS_CDBP(xs), XS_CDBLEN(xs));
3287
3288 reqp->req_time = XS_TIME(xs) / 1000;
3289 if (reqp->req_time == 0 && XS_TIME(xs)) {
3290 reqp->req_time = 1;
3291 }
3292

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

3328int
3329isp_control(struct ispsoftc *isp, ispctl_t ctl, void *arg)
3330{
3331 XS_T *xs;
3332 mbreg_t mbs;
3333 int bus, tgt;
3334 u_int16_t handle;
3335
3336 switch (ctl) {
3337 default:
3338 isp_prt(isp, ISP_LOGERR, "Unknown Control Opcode 0x%x", ctl);
3339 break;
3340
3341 case ISPCTL_RESET_BUS:
3342 /*
3343 * Issue a bus reset.

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

3364 isp_prt(isp, ISP_LOGINFO,
3365 "driver initiated bus reset of bus %d", bus);
3366 return (0);
3367
3368 case ISPCTL_RESET_DEV:
3369 tgt = (*((int *) arg)) & 0xffff;
3370 bus = (*((int *) arg)) >> 16;
3371 mbs.param[0] = MBOX_ABORT_TARGET;
3372 mbs.param[1] = (tgt << 8) | (bus << 15);
3373 mbs.param[2] = 3; /* 'delay', in seconds */
3374 isp_mboxcmd(isp, &mbs, MBLOGALL);
3375 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3376 break;
3377 }
3378 isp_prt(isp, ISP_LOGINFO,
3379 "Target %d on Bus %d Reset Succeeded", tgt, bus);
3380 isp->isp_sendmarker |= (1 << bus);

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

3388 isp_prt(isp, ISP_LOGWARN,
3389 "cannot find handle for command to abort");
3390 break;
3391 }
3392 bus = XS_CHANNEL(xs);
3393 mbs.param[0] = MBOX_ABORT;
3394 if (IS_FC(isp)) {
3395 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) {
3396 mbs.param[1] = tgt << 8;
3397 mbs.param[4] = 0;
3398 mbs.param[5] = 0;
3399 mbs.param[6] = XS_LUN(xs);
3400 } else {
3401 mbs.param[1] = tgt << 8 | XS_LUN(xs);
3402 }
3403 } else {
3404 mbs.param[1] =

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

3536 * The mailbox semaphore will be nonzero if so.
3537 */
3538 if (sema) {
3539 if (mbox & 0x4000) {
3540 isp->isp_intmboxc++;
3541 if (isp->isp_mboxbsy) {
3542 int i = 0, obits = isp->isp_obits;
3543 isp->isp_mboxtmp[i++] = mbox;
3544 for (i = 1; i < MAX_MAILBOX; i++) {
3545 if ((obits & (1 << i)) == 0) {
3546 continue;
3547 }
3548 isp->isp_mboxtmp[i] =
3549 ISP_READ(isp, MBOX_OFF(i));
3550 }
3551 if (isp->isp_mbxwrk0) {
3552 if (isp_mbox_continue(isp) == 0) {

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

4140#else
4141 isp_prt(isp, ISP_LOGINFO, "Fast Posting CTIO done");
4142 isp->isp_fphccmplt++; /* count it as a fast posting intr */
4143#endif
4144 break;
4145 }
4146 case ASYNC_LIP_F8:
4147 case ASYNC_LIP_OCCURRED:
4148 FCPARAM(isp)->isp_lipseq =
4149 ISP_READ(isp, OUTMAILBOX1);
4150 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
4151 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD;
4152 isp->isp_sendmarker = 1;
4153 isp_mark_getpdb_all(isp);
4154 isp_async(isp, ISPASYNC_LIP, NULL);
4155#ifdef ISP_TARGET_MODE
4156 if (isp_target_async(isp, bus, mbox))
4157 rval = -1;

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

4295 isp_prt(isp, ISP_LOGWARN, "Unknown Async Code 0x%x", mbox);
4296 break;
4297 }
4298
4299 if (bus & 0x100) {
4300 int i, nh;
4301 u_int16_t handles[16];
4302
4303 for (nh = 0, i = 1; i < MAX_MAILBOX; i++) {
4304 if ((bus & (1 << i)) == 0) {
4305 continue;
4306 }
4307 handles[nh++] = ISP_READ(isp, MBOX_OFF(i));
4308 }
4309 for (i = 0; i < nh; i++) {
4310 isp_fastpost_complete(isp, handles[i]);
4311 isp_prt(isp, ISP_LOGDEBUG3,

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

4711 /*
4712 * If we're on a local loop, force a LIP (which is overkill)
4713 * to force a re-login of this unit. If we're on fabric,
4714 * then we'll have to relogin as a matter of course.
4715 */
4716 if (FCPARAM(isp)->isp_topo == TOPO_NL_PORT ||
4717 FCPARAM(isp)->isp_topo == TOPO_FL_PORT) {
4718 mbreg_t mbs;
4719 mbs.param[0] = MBOX_INIT_LIP;
4720 isp_mboxcmd_qnw(isp, &mbs, 1);
4721 }
4722
4723 /*
4724 * Probably overkill.
4725 */
4726 isp->isp_sendmarker = 1;

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

4805 default:
4806 return (1);
4807 }
4808 if (isp->isp_mboxtmp[0] != MBOX_COMMAND_COMPLETE) {
4809 isp->isp_mbxwrk0 = 0;
4810 return (-1);
4811 }
4812
4813
4814 /*
4815 * Clear the previous interrupt.
4816 */
4817 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
4818 ISP_WRITE(isp, BIU_SEMA, 0);
4819
4820 /*
4821 * Continue with next word.
4822 */
4823 ptr = isp->isp_mbxworkp;
4824 switch (isp->isp_lastmbxcmd) {
4825 case MBOX_WRITE_RAM_WORD:
4826 mbs.param[2] = *ptr++;
4827 mbs.param[1] = isp->isp_mbxwrk1++;
4828 break;
4829 case MBOX_READ_RAM_WORD:
4830 case MBOX_READ_RAM_WORD_EXTENDED:

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

4835 isp->isp_mbxworkp = ptr;
4836 mbs.param[0] = isp->isp_lastmbxcmd;
4837 isp->isp_mbxwrk0 -= 1;
4838 isp_mboxcmd_qnw(isp, &mbs, 0);
4839 return (0);
4840}
4841
4842
4843#define HIBYT(x) ((x) >> 0x8)
4844#define LOBYT(x) ((x) & 0xff)
4845#define ISPOPMAP(a, b) (((a) << 8) | (b))
4846static const u_int16_t mbpscsi[] = {
4847 ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */
4848 ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */
4849 ISPOPMAP(0x03, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */
4850 ISPOPMAP(0x1f, 0x01), /* 0x03: MBOX_DUMP_RAM */
4851 ISPOPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */
4852 ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */
4853 ISPOPMAP(0x3f, 0x3f), /* 0x06: MBOX_MAILBOX_REG_TEST */
4854 ISPOPMAP(0x03, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */

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

5034 NULL,
5035 "SET DATA OVERRUN RECOVERY MODE",
5036 "GET DATA OVERRUN RECOVERY MODE",
5037 "SET HOST DATA",
5038 "GET NOST DATA",
5039};
5040#endif
5041
5042static const u_int16_t mbpfc[] = {
5043 ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */
5044 ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */
5045 ISPOPMAP(0x03, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */
5046 ISPOPMAP(0xdf, 0x01), /* 0x03: MBOX_DUMP_RAM */
5047 ISPOPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */
5048 ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */
5049 ISPOPMAP(0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */
5050 ISPOPMAP(0x03, 0x05), /* 0x07: MBOX_VERIFY_CHECKSUM */

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

5307 "Lun RESET"
5308};
5309#endif
5310
5311static void
5312isp_mboxcmd_qnw(struct ispsoftc *isp, mbreg_t *mbp, int nodelay)
5313{
5314 unsigned int ibits, obits, box, opcode;
5315 const u_int16_t *mcp;
5316
5317 if (IS_FC(isp)) {
5318 mcp = mbpfc;
5319 } else {
5320 mcp = mbpscsi;
5321 }
5322 opcode = mbp->param[0];
5323 ibits = HIBYT(mcp[opcode]) & NMBOX_BMASK(isp);
5324 obits = LOBYT(mcp[opcode]) & NMBOX_BMASK(isp);
5325 for (box = 0; box < MAX_MAILBOX; box++) {
5326 if (ibits & (1 << box)) {
5327 ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]);
5328 }
5329 if (nodelay == 0) {
5330 isp->isp_mboxtmp[box] = mbp->param[box] = 0;
5331 }
5332 }
5333 if (nodelay == 0) {

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

5346 }
5347}
5348
5349static void
5350isp_mboxcmd(struct ispsoftc *isp, mbreg_t *mbp, int logmask)
5351{
5352 char *cname, *xname, tname[16], mname[16];
5353 unsigned int lim, ibits, obits, box, opcode;
5354 const u_int16_t *mcp;
5355
5356 if (IS_FC(isp)) {
5357 mcp = mbpfc;
5358 lim = (sizeof (mbpfc) / sizeof (mbpfc[0]));
5359 } else {
5360 mcp = mbpscsi;
5361 lim = (sizeof (mbpscsi) / sizeof (mbpscsi[0]));
5362 }
5363
5364 if ((opcode = mbp->param[0]) >= lim) {
5365 mbp->param[0] = MBOX_INVALID_COMMAND;
5366 isp_prt(isp, ISP_LOGERR, "Unknown Command 0x%x", opcode);
5367 return;
5368 }
5369
5370 ibits = HIBYT(mcp[opcode]) & NMBOX_BMASK(isp);
5371 obits = LOBYT(mcp[opcode]) & NMBOX_BMASK(isp);
5372
5373 if (ibits == 0 && obits == 0) {
5374 mbp->param[0] = MBOX_COMMAND_PARAM_ERROR;
5375 isp_prt(isp, ISP_LOGERR, "no parameters for 0x%x", opcode);
5376 return;
5377 }
5378
5379 /*
5380 * Get exclusive usage of mailbox registers.
5381 */
5382 MBOX_ACQUIRE(isp);
5383
5384 for (box = 0; box < MAX_MAILBOX; box++) {
5385 if (ibits & (1 << box)) {
5386 ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]);
5387 }
5388 isp->isp_mboxtmp[box] = mbp->param[box] = 0;
5389 }
5390
5391 isp->isp_lastmbxcmd = opcode;
5392

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

5413 isp->isp_mboxbsy = 0;
5414 MBOX_RELEASE(isp);
5415 return;
5416 }
5417
5418 /*
5419 * Copy back output registers.
5420 */
5421 for (box = 0; box < MAX_MAILBOX; box++) {
5422 if (obits & (1 << box)) {
5423 mbp->param[box] = isp->isp_mboxtmp[box];
5424 }
5425 }
5426
5427 MBOX_RELEASE(isp);
5428
5429 if (logmask == 0 || opcode == MBOX_EXEC_FIRMWARE) {

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

5493
5494static void
5495isp_fw_state(struct ispsoftc *isp)
5496{
5497 if (IS_FC(isp)) {
5498 mbreg_t mbs;
5499 fcparam *fcp = isp->isp_param;
5500
5501 mbs.param[0] = MBOX_GET_FW_STATE;
5502 isp_mboxcmd(isp, &mbs, MBLOGALL);
5503 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
5504 fcp->isp_fwstate = mbs.param[1];
5505 }
5506 }
5507}
5508

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

5530 if (IS_FC(isp)) {
5531 /*
5532 * There are no 'per-bus' settings for Fibre Channel.
5533 */
5534 return;
5535 }
5536 sdp = isp->isp_param;
5537 sdp += bus;
5538
5539 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
5540 u_int16_t flags, period, offset;
5541 int get;
5542
5543 if (sdp->isp_devparam[tgt].dev_enable == 0) {
5544 sdp->isp_devparam[tgt].dev_update = 0;
5545 sdp->isp_devparam[tgt].dev_refresh = 0;

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

5645
5646static void
5647isp_setdfltparm(struct ispsoftc *isp, int channel)
5648{
5649 int tgt;
5650 mbreg_t mbs;
5651 sdparam *sdp;
5652
5653 if (IS_FC(isp)) {
5654 fcparam *fcp = (fcparam *) isp->isp_param;
5655 int nvfail;
5656
5657 fcp += channel;
5658 if (fcp->isp_gotdparms) {
5659 return;
5660 }

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

6462
6463static void
6464isp2200_fw_dump(struct ispsoftc *isp)
6465{
6466 int i, j;
6467 mbreg_t mbs;
6468 u_int16_t *ptr;
6469
6470 ptr = FCPARAM(isp)->isp_dump_data;
6471 if (ptr == NULL) {
6472 isp_prt(isp, ISP_LOGERR,
6473 "No place to dump RISC registers and SRAM");
6474 return;
6475 }
6476 if (*ptr++) {
6477 isp_prt(isp, ISP_LOGERR,

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

6606
6607static void
6608isp2300_fw_dump(struct ispsoftc *isp)
6609{
6610 int i, j;
6611 mbreg_t mbs;
6612 u_int16_t *ptr;
6613
6614 ptr = FCPARAM(isp)->isp_dump_data;
6615 if (ptr == NULL) {
6616 isp_prt(isp, ISP_LOGERR,
6617 "No place to dump RISC registers and SRAM");
6618 return;
6619 }
6620 if (*ptr++) {
6621 isp_prt(isp, ISP_LOGERR,

--- 157 unchanged lines hidden ---