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 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice immediately at the beginning of the file, without modification, 13 * this list of conditions, and the following disclaimer. --- 22 unchanged lines hidden (view full) --- 36/* 37 * Include header file appropriate for platform we're building on. 38 */ 39 40#ifdef __NetBSD__ 41#include <dev/ic/isp_netbsd.h> 42#endif 43#ifdef __FreeBSD__ |
44#include <sys/cdefs.h> 45__FBSDID("$FreeBSD: head/sys/dev/isp/isp.c 154704 2006-01-23 06:23:37Z mjacob $"); |
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, 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 MEMZERO(&mbs, sizeof (mbs)); |
169 170 /* 171 * Basic types (SCSI, FibreChannel and PCI or SBus) 172 * have been set in the MD code. We figure out more 173 * here. Possibly more refined types based upon PCI 174 * identification. Chip revision has been gathered. 175 * 176 * After we've fired this chip up, zero out the conf1 register --- 71 unchanged lines hidden (view full) --- 248 btype = "2200"; 249 break; 250 case ISP_HA_FC_2300: 251 btype = "2300"; 252 break; 253 case ISP_HA_FC_2312: 254 btype = "2312"; 255 break; |
256 case ISP_HA_FC_2322: 257 btype = "2322"; 258 break; 259 case ISP_HA_FC_2422: 260 btype = "2422"; 261 break; |
262 default: 263 break; 264 } 265 /* 266 * While we're paused, reset the FPM module and FBM fifos. 267 */ 268 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS); 269 ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET); --- 409 unchanged lines hidden (view full) --- 679 * 680 * If we didn't actually download f/w, 681 * we still need to (re)start it. 682 */ 683 684 685 mbs.param[0] = MBOX_EXEC_FIRMWARE; 686 mbs.param[1] = code_org; |
687 if (IS_2322(isp) || IS_24XX(isp)) { 688 if (isp->isp_loaded_fw) { 689 mbs.param[2] = 1; 690 } else { 691 mbs.param[2] = 0; 692 } 693 mbs.obits |= 2; 694 } 695 |
696 isp_mboxcmd(isp, &mbs, MBLOGNONE); 697 /* 698 * Give it a chance to start. 699 */ 700 USEC_DELAY(500); 701 702 if (IS_SCSI(isp)) { 703 /* --- 53 unchanged lines hidden (view full) --- 757#else 758 FCPARAM(isp)->isp_fwattr = 0; 759#endif 760 } else { 761 FCPARAM(isp)->isp_fwattr = mbs.param[6]; 762 isp_prt(isp, ISP_LOGDEBUG0, 763 "Firmware Attributes = 0x%x", mbs.param[6]); 764 } |
765 if (IS_2KLOGIN(isp)) { 766 isp_prt(isp, ISP_LOGCONFIG, "2K Logins Supported"); |
767 } 768 } 769 770 if (isp->isp_romfw_rev[0] || isp->isp_romfw_rev[1] || 771 isp->isp_romfw_rev[2]) { 772 isp_prt(isp, ISP_LOGCONFIG, "Last F/W revision was %d.%d.%d", 773 isp->isp_romfw_rev[0], isp->isp_romfw_rev[1], 774 isp->isp_romfw_rev[2]); --- 104 unchanged lines hidden (view full) --- 879 if (sdp_chan0->isp_fast_mttr) { 880 ISP_WRITE(isp, RISC_MTR, 0x1313); 881 } 882 883 /* 884 * Set Retry Delay and Count. 885 * You set both channels at the same time. 886 */ |
887 MEMZERO(&mbs, sizeof (mbs)); |
888 mbs.param[0] = MBOX_SET_RETRY_COUNT; 889 mbs.param[1] = sdp_chan0->isp_retry_count; 890 mbs.param[2] = sdp_chan0->isp_retry_delay; 891 mbs.param[6] = sdp_chan1->isp_retry_count; 892 mbs.param[7] = sdp_chan1->isp_retry_delay; 893 894 isp_mboxcmd(isp, &mbs, MBLOGALL); 895 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { --- 163 unchanged lines hidden (view full) --- 1059 int tgt; 1060 1061 sdp = isp->isp_param; 1062 sdp += channel; 1063 1064 /* 1065 * Set (possibly new) Initiator ID. 1066 */ |
1067 MEMZERO(&mbs, sizeof (mbs)); |
1068 mbs.param[0] = MBOX_SET_INIT_SCSI_ID; 1069 mbs.param[1] = (channel << 7) | sdp->isp_initiator_id; 1070 isp_mboxcmd(isp, &mbs, MBLOGALL); 1071 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 1072 return; 1073 } 1074 isp_prt(isp, ISP_LOGINFO, "Initiator ID is %d on Channel %d", 1075 sdp->isp_initiator_id, channel); --- 193 unchanged lines hidden (view full) --- 1269 fcp->isp_execthrottle); 1270 icbp->icb_execthrottle = ICB_DFLT_THROTTLE; 1271 } 1272 icbp->icb_retry_delay = fcp->isp_retry_delay; 1273 icbp->icb_retry_count = fcp->isp_retry_count; 1274 icbp->icb_hardaddr = loopid; 1275 if (icbp->icb_hardaddr >= 125) { 1276 /* |
1277 * We end up with these Loop IDs for F-Port topologies |
1278 */ |
1279 if (icbp->icb_hardaddr != 0xff || icbp->icb_hardaddr != 0x800) { |
1280 isp_prt(isp, ISP_LOGERR, 1281 "bad hard address %u- resetting to zero", 1282 icbp->icb_hardaddr); 1283 } 1284 icbp->icb_hardaddr = 0; 1285 } 1286 /* 1287 * Right now we just set extended options to prefer point-to-point --- 78 unchanged lines hidden (view full) --- 1366 if (!IS_23XX(isp) && ISP_FW_NEWER_THAN(isp, 1, 17, 0)) { 1367 icbp->icb_xfwoptions |= ICBXOPT_RIO_16BIT; 1368 icbp->icb_racctimer = 4; 1369 icbp->icb_idelaytimer = 8; 1370 } 1371#endif 1372#endif 1373 |
1374 MEMZERO(&mbs, sizeof (mbs)); 1375 |
1376 /* |
1377 * For 22XX > 2.1.26 && 23XX, set some options. |
1378 * XXX: Probably okay for newer 2100 f/w too. 1379 */ 1380 if (ISP_FW_NEWER_THAN(isp, 2, 26, 0)) { 1381 /* 1382 * Turn on LIP F8 async event (1) 1383 * Turn on generate AE 8013 on all LIP Resets (2) 1384 * Disable LIP F7 switching (8) 1385 */ --- 85 unchanged lines hidden (view full) --- 1471 */ 1472 1473static int 1474isp_getmap(struct ispsoftc *isp, fcpos_map_t *map) 1475{ 1476 fcparam *fcp = (fcparam *) isp->isp_param; 1477 mbreg_t mbs; 1478 |
1479 MEMZERO(&mbs, sizeof (mbs)); |
1480 mbs.param[0] = MBOX_GET_FC_AL_POSITION_MAP; 1481 mbs.param[1] = 0; 1482 mbs.param[2] = DMA_WD1(fcp->isp_scdma); 1483 mbs.param[3] = DMA_WD0(fcp->isp_scdma); 1484 /* 1485 * Unneeded. For the 2100, except for initializing f/w, registers 1486 * 4/5 have to not be written to. 1487 * mbs.param[4] = 0; --- 25 unchanged lines hidden (view full) --- 1513} 1514 1515static int 1516isp_getpdb(struct ispsoftc *isp, int id, isp_pdb_t *pdbp) 1517{ 1518 fcparam *fcp = (fcparam *) isp->isp_param; 1519 mbreg_t mbs; 1520 |
1521 MEMZERO(&mbs, sizeof (mbs)); |
1522 mbs.param[0] = MBOX_GET_PORT_DB; |
1523 if (IS_2KLOGIN(isp)) { 1524 mbs.param[1] = id; 1525 mbs.obits |= (1 << 10); 1526 } else { 1527 mbs.param[1] = id << 8; 1528 } |
1529 mbs.param[2] = DMA_WD1(fcp->isp_scdma); 1530 mbs.param[3] = DMA_WD0(fcp->isp_scdma); 1531 /* 1532 * Unneeded. For the 2100, except for initializing f/w, registers 1533 * 4/5 have to not be written to. 1534 * mbs.param[4] = 0; 1535 * mbs.param[5] = 0; 1536 * --- 12 unchanged lines hidden (view full) --- 1549} 1550 1551static u_int64_t 1552isp_get_portname(struct ispsoftc *isp, int loopid, int nodename) 1553{ 1554 u_int64_t wwn = 0; 1555 mbreg_t mbs; 1556 |
1557 MEMZERO(&mbs, sizeof (mbs)); |
1558 mbs.param[0] = MBOX_GET_PORT_NAME; |
1559 if (IS_2KLOGIN(isp)) { 1560 mbs.param[1] = loopid; 1561 if (nodename) 1562 mbs.param[10] = 1; 1563 mbs.obits |= (1 << 10); 1564 } else { 1565 mbs.param[1] = loopid << 8; 1566 if (nodename) 1567 mbs.param[1] |= 1; 1568 } |
1569 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR); 1570 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { 1571 wwn = 1572 (((u_int64_t)(mbs.param[2] & 0xff)) << 56) | 1573 (((u_int64_t)(mbs.param[2] >> 8)) << 48) | 1574 (((u_int64_t)(mbs.param[3] & 0xff)) << 40) | 1575 (((u_int64_t)(mbs.param[3] >> 8)) << 32) | 1576 (((u_int64_t)(mbs.param[6] & 0xff)) << 24) | --- 99 unchanged lines hidden (view full) --- 1676 */ 1677 if (fcp->isp_fwstate != FW_READY) { 1678 return (-1); 1679 } 1680 1681 /* 1682 * Get our Loop ID (if possible). We really need to have it. 1683 */ |
1684 MEMZERO(&mbs, sizeof (mbs)); |
1685 mbs.param[0] = MBOX_GET_LOOP_ID; 1686 isp_mboxcmd(isp, &mbs, MBLOGALL); 1687 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 1688 return (-1); 1689 } 1690 fcp->isp_loopid = mbs.param[1]; 1691 if (IS_2200(isp) || IS_23XX(isp)) { 1692 int topo = (int) mbs.param[6]; 1693 if (topo < TOPO_NL_PORT || topo > TOPO_PTP_STUB) 1694 topo = TOPO_PTP_STUB; 1695 fcp->isp_topo = topo; 1696 } else { 1697 fcp->isp_topo = TOPO_NL_PORT; 1698 } |
1699 /* 1700 * XXX: We can get the AL_PA (low 8 bits) from here. 1701 * XXX: Where do we get the upper 16 bits? 1702 */ 1703 fcp->isp_portid = mbs.param[2] & 0xff; |
1704 1705 /* 1706 * Check to see if we're on a fabric by trying to see if we 1707 * can talk to the fabric name server. This can be a bit 1708 * tricky because if we're a 2100, we should check always 1709 * (in case we're connected to a server doing aliasing). 1710 */ 1711 fcp->isp_onfabric = 0; --- 74 unchanged lines hidden (view full) --- 1786 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { 1787 if (mbs.param[1] == MBGSD_TWOGB) { 1788 isp_prt(isp, ISP_LOGINFO, "2Gb link speed/s"); 1789 fcp->isp_gbspeed = 2; 1790 } 1791 } 1792 } 1793 |
1794 isp_prt(isp, ISP_LOGCONFIG, topology, fcp->isp_loopid, |
1795 fcp->isp_portid, fcp->isp_loopstate, toponames[fcp->isp_topo]); 1796 1797 /* 1798 * Announce ourselves, too. This involves synthesizing an entry. 1799 */ 1800 if (fcp->isp_iid_set == 0) { 1801 fcp->isp_iid_set = 1; 1802 fcp->isp_iid = fcp->isp_loopid; --- 197 unchanged lines hidden (view full) --- 2000 } 2001 2002 /* 2003 * Force a logout if we were logged in. 2004 */ 2005 if (lp->loggedin) { 2006 if (lp->force_logout || 2007 isp_getpdb(isp, lp->loopid, &pdb) == 0) { |
2008 MEMZERO(&mbs, sizeof (mbs)); |
2009 mbs.param[0] = MBOX_FABRIC_LOGOUT; |
2010 if (IS_2KLOGIN(isp)) { 2011 mbs.param[1] = lp->loopid; 2012 mbs.obits |= (1 << 10); 2013 } else { 2014 mbs.param[1] = lp->loopid << 8; 2015 } |
2016 mbs.param[2] = 0; 2017 mbs.param[3] = 0; 2018 isp_mboxcmd(isp, &mbs, MBLOGNONE); 2019 isp_prt(isp, ISP_LOGINFO, plogout, 2020 (int) (lp - fcp->portdb), lp->loopid, 2021 lp->portid); 2022 } 2023 lp->force_logout = lp->loggedin = 0; --- 4 unchanged lines hidden (view full) --- 2028 } 2029 2030 /* 2031 * And log in.... 2032 */ 2033 loopid = lp - fcp->portdb; 2034 lp->loopid = FL_PORT_ID; 2035 do { |
2036 MEMZERO(&mbs, sizeof (mbs)); |
2037 mbs.param[0] = MBOX_FABRIC_LOGIN; |
2038 if (IS_2KLOGIN(isp)) { 2039 mbs.param[1] = loopid; 2040 mbs.obits |= (1 << 10); 2041 } else { 2042 mbs.param[1] = loopid << 8; 2043 } |
2044 mbs.param[2] = portid >> 16; 2045 mbs.param[3] = portid & 0xffff; 2046 isp_mboxcmd(isp, &mbs, MBLOGALL & ~(MBOX_LOOP_ID_USED | 2047 MBOX_PORT_ID_USED | MBOX_COMMAND_ERROR)); 2048 if (fcp->isp_fwstate != FW_READY || 2049 fcp->isp_loopstate != LOOP_SYNCING_PDB) { 2050 return (-1); 2051 } --- 98 unchanged lines hidden (view full) --- 2150 loopid = lp - fcp->portdb; 2151 (void) isp_async(isp, ISPASYNC_PROMENADE, &loopid); 2152 continue; 2153 } 2154dump_em: 2155 lp->valid = 0; 2156 isp_prt(isp, ISP_LOGINFO, 2157 ldumped, loopid, lp->loopid, lp->portid); |
2158 MEMZERO(&mbs, sizeof (mbs)); |
2159 mbs.param[0] = MBOX_FABRIC_LOGOUT; |
2160 if (IS_2KLOGIN(isp)) { 2161 mbs.param[1] = lp->loopid; 2162 mbs.obits |= (1 << 10); 2163 } else { 2164 mbs.param[1] = lp->loopid << 8; 2165 } |
2166 isp_mboxcmd(isp, &mbs, MBLOGNONE); 2167 if (fcp->isp_fwstate != FW_READY || 2168 fcp->isp_loopstate != LOOP_SYNCING_PDB) { 2169 return (-1); 2170 } 2171 } 2172 /* 2173 * If we get here, we've for sure seen not only a valid loop --- 364 unchanged lines hidden (view full) --- 2538 rq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+0x100); 2539 rq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+0x100); 2540 rq->snscb_sblen = 6; 2541 rq->snscb_data[0] = SNS_GA_NXT; 2542 rq->snscb_data[4] = portid & 0xffff; 2543 rq->snscb_data[5] = (portid >> 16) & 0xff; 2544 isp_put_sns_request(isp, rq, (sns_screq_t *) fcp->isp_scratch); 2545 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GA_NXT_REQ_SIZE); |
2546 MEMZERO(&mbs, sizeof (mbs)); |
2547 mbs.param[0] = MBOX_SEND_SNS; 2548 mbs.param[1] = SNS_GA_NXT_REQ_SIZE >> 1; 2549 mbs.param[2] = DMA_WD1(fcp->isp_scdma); 2550 mbs.param[3] = DMA_WD0(fcp->isp_scdma); 2551 /* 2552 * Leave 4 and 5 alone 2553 */ 2554 mbs.param[6] = DMA_WD3(fcp->isp_scdma); --- 134 unchanged lines hidden (view full) --- 2689 rq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+IGPOFF); 2690 rq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+IGPOFF); 2691 rq->snscb_sblen = 6; 2692 rq->snscb_cmd = SNS_GID_FT; 2693 rq->snscb_mword_div_2 = NGENT; 2694 rq->snscb_fc4_type = ftype; 2695 isp_put_gid_ft_request(isp, rq, (sns_gid_ft_req_t *) fcp->isp_scratch); 2696 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GID_FT_REQ_SIZE); |
2697 MEMZERO(&mbs, sizeof (mbs)); |
2698 mbs.param[0] = MBOX_SEND_SNS; 2699 mbs.param[1] = SNS_GID_FT_REQ_SIZE >> 1; 2700 mbs.param[2] = DMA_WD1(fcp->isp_scdma); 2701 mbs.param[3] = DMA_WD0(fcp->isp_scdma); 2702 2703 /* 2704 * Leave 4 and 5 alone 2705 */ --- 61 unchanged lines hidden (view full) --- 2767 gq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+GXOFF); 2768 gq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+GXOFF); 2769 gq->snscb_sblen = 6; 2770 gq->snscb_cmd = SNS_GPN_ID; 2771 gq->snscb_portid = lcl.portid; 2772 isp_put_gxn_id_request(isp, gq, 2773 (sns_gxn_id_req_t *) fcp->isp_scratch); 2774 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GXN_ID_REQ_SIZE); |
2775 MEMZERO(&mbs, sizeof (mbs)); |
2776 mbs.param[0] = MBOX_SEND_SNS; 2777 mbs.param[1] = SNS_GXN_ID_REQ_SIZE >> 1; 2778 mbs.param[2] = DMA_WD1(fcp->isp_scdma); 2779 mbs.param[3] = DMA_WD0(fcp->isp_scdma); 2780 /* 2781 * Leave 4 and 5 alone 2782 */ 2783 mbs.param[6] = DMA_WD3(fcp->isp_scdma); --- 39 unchanged lines hidden (view full) --- 2823 gq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+GXOFF); 2824 gq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+GXOFF); 2825 gq->snscb_sblen = 6; 2826 gq->snscb_cmd = SNS_GNN_ID; 2827 gq->snscb_portid = lcl.portid; 2828 isp_put_gxn_id_request(isp, gq, 2829 (sns_gxn_id_req_t *) fcp->isp_scratch); 2830 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GXN_ID_REQ_SIZE); |
2831 MEMZERO(&mbs, sizeof (mbs)); |
2832 mbs.param[0] = MBOX_SEND_SNS; 2833 mbs.param[1] = SNS_GXN_ID_REQ_SIZE >> 1; 2834 mbs.param[2] = DMA_WD1(fcp->isp_scdma); 2835 mbs.param[3] = DMA_WD0(fcp->isp_scdma); 2836 /* 2837 * Leave 4 and 5 alone 2838 */ 2839 mbs.param[6] = DMA_WD3(fcp->isp_scdma); --- 47 unchanged lines hidden (view full) --- 2887 gq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+GXOFF); 2888 gq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+GXOFF); 2889 gq->snscb_sblen = 6; 2890 gq->snscb_cmd = SNS_GFF_ID; 2891 gq->snscb_portid = lcl.portid; 2892 isp_put_gxn_id_request(isp, gq, 2893 (sns_gxn_id_req_t *) fcp->isp_scratch); 2894 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GXN_ID_REQ_SIZE); |
2895 MEMZERO(&mbs, sizeof (mbs)); |
2896 mbs.param[0] = MBOX_SEND_SNS; 2897 mbs.param[1] = SNS_GXN_ID_REQ_SIZE >> 1; 2898 mbs.param[2] = DMA_WD1(fcp->isp_scdma); 2899 mbs.param[3] = DMA_WD0(fcp->isp_scdma); 2900 /* 2901 * Leave 4 and 5 alone 2902 */ 2903 mbs.param[6] = DMA_WD3(fcp->isp_scdma); --- 85 unchanged lines hidden (view full) --- 2989 reqp->snscb_data[4] = fcp->isp_portid & 0xffff; 2990 reqp->snscb_data[5] = (fcp->isp_portid >> 16) & 0xff; 2991 reqp->snscb_data[6] = (1 << FC4_SCSI); 2992#if 0 2993 reqp->snscb_data[6] |= (1 << FC4_IP); /* ISO/IEC 8802-2 LLC/SNAP */ 2994#endif 2995 FC_SCRATCH_ACQUIRE(isp); 2996 isp_put_sns_request(isp, reqp, (sns_screq_t *) fcp->isp_scratch); |
2997 MEMZERO(&mbs, sizeof (mbs)); |
2998 mbs.param[0] = MBOX_SEND_SNS; 2999 mbs.param[1] = SNS_RFT_ID_REQ_SIZE >> 1; 3000 mbs.param[2] = DMA_WD1(fcp->isp_scdma); 3001 mbs.param[3] = DMA_WD0(fcp->isp_scdma); 3002 /* 3003 * Leave 4 and 5 alone 3004 */ 3005 mbs.param[6] = DMA_WD3(fcp->isp_scdma); --- 323 unchanged lines hidden (view full) --- 3329 } else { 3330 sdparam *sdp = (sdparam *)isp->isp_param; 3331 sdp += XS_CHANNEL(xs); 3332 if ((sdp->isp_devparam[target].actv_flags & DPARM_TQING) && 3333 XS_TAG_P(xs)) { 3334 reqp->req_flags = XS_TAG_TYPE(xs); 3335 } 3336 } |
3337 if (IS_SCSI(isp)) { |
3338 reqp->req_target = target | (XS_CHANNEL(xs) << 7); |
3339 reqp->req_lun_trn = XS_LUN(xs); 3340 reqp->req_cdblen = XS_CDBLEN(xs); |
3341 } else if (IS_2KLOGIN(isp)) { 3342 ((ispreqt2e_t *)reqp)->req_target = target; 3343 ((ispreqt2e_t *)reqp)->req_scclun = XS_LUN(xs); 3344 } else if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { 3345 ((ispreqt2_t *)reqp)->req_target = target; 3346 ((ispreqt2_t *)reqp)->req_scclun = XS_LUN(xs); |
3347 } else { |
3348 ((ispreqt2_t *)reqp)->req_target = target; 3349 ((ispreqt2_t *)reqp)->req_lun_trn = XS_LUN(xs); |
3350 } 3351 MEMCPY(reqp->req_cdb, XS_CDBP(xs), XS_CDBLEN(xs)); 3352 3353 reqp->req_time = XS_TIME(xs) / 1000; 3354 if (reqp->req_time == 0 && XS_TIME(xs)) { 3355 reqp->req_time = 1; 3356 } 3357 --- 35 unchanged lines hidden (view full) --- 3393int 3394isp_control(struct ispsoftc *isp, ispctl_t ctl, void *arg) 3395{ 3396 XS_T *xs; 3397 mbreg_t mbs; 3398 int bus, tgt; 3399 u_int16_t handle; 3400 |
3401 MEMZERO(&mbs, sizeof (mbs)); 3402 |
3403 switch (ctl) { 3404 default: 3405 isp_prt(isp, ISP_LOGERR, "Unknown Control Opcode 0x%x", ctl); 3406 break; 3407 3408 case ISPCTL_RESET_BUS: 3409 /* 3410 * Issue a bus reset. --- 20 unchanged lines hidden (view full) --- 3431 isp_prt(isp, ISP_LOGINFO, 3432 "driver initiated bus reset of bus %d", bus); 3433 return (0); 3434 3435 case ISPCTL_RESET_DEV: 3436 tgt = (*((int *) arg)) & 0xffff; 3437 bus = (*((int *) arg)) >> 16; 3438 mbs.param[0] = MBOX_ABORT_TARGET; |
3439 if (IS_SCSI(isp)) { 3440 mbs.param[1] = (tgt << 8) | (bus << 15); 3441 } else { 3442 if (IS_2KLOGIN(isp)) { 3443 mbs.param[1] = tgt; 3444 mbs.obits |= (1 << 10); 3445 } else { 3446 mbs.param[1] = (tgt << 8); 3447 } 3448 } |
3449 mbs.param[2] = 3; /* 'delay', in seconds */ 3450 isp_mboxcmd(isp, &mbs, MBLOGALL); 3451 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 3452 break; 3453 } 3454 isp_prt(isp, ISP_LOGINFO, 3455 "Target %d on Bus %d Reset Succeeded", tgt, bus); 3456 isp->isp_sendmarker |= (1 << bus); --- 7 unchanged lines hidden (view full) --- 3464 isp_prt(isp, ISP_LOGWARN, 3465 "cannot find handle for command to abort"); 3466 break; 3467 } 3468 bus = XS_CHANNEL(xs); 3469 mbs.param[0] = MBOX_ABORT; 3470 if (IS_FC(isp)) { 3471 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { |
3472 if (IS_2KLOGIN(isp)) { 3473 mbs.param[1] = tgt; 3474 } else { 3475 mbs.param[1] = tgt << 8; 3476 } |
3477 mbs.param[4] = 0; 3478 mbs.param[5] = 0; 3479 mbs.param[6] = XS_LUN(xs); 3480 } else { 3481 mbs.param[1] = tgt << 8 | XS_LUN(xs); 3482 } 3483 } else { 3484 mbs.param[1] = --- 131 unchanged lines hidden (view full) --- 3616 * The mailbox semaphore will be nonzero if so. 3617 */ 3618 if (sema) { 3619 if (mbox & 0x4000) { 3620 isp->isp_intmboxc++; 3621 if (isp->isp_mboxbsy) { 3622 int i = 0, obits = isp->isp_obits; 3623 isp->isp_mboxtmp[i++] = mbox; |
3624 for (i = 1; i < MAX_MAILBOX(isp); i++) { |
3625 if ((obits & (1 << i)) == 0) { 3626 continue; 3627 } 3628 isp->isp_mboxtmp[i] = 3629 ISP_READ(isp, MBOX_OFF(i)); 3630 } 3631 if (isp->isp_mbxwrk0) { 3632 if (isp_mbox_continue(isp) == 0) { --- 587 unchanged lines hidden (view full) --- 4220#else 4221 isp_prt(isp, ISP_LOGINFO, "Fast Posting CTIO done"); 4222 isp->isp_fphccmplt++; /* count it as a fast posting intr */ 4223#endif 4224 break; 4225 } 4226 case ASYNC_LIP_F8: 4227 case ASYNC_LIP_OCCURRED: |
4228 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 4229 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; 4230 isp->isp_sendmarker = 1; 4231 isp_mark_getpdb_all(isp); 4232 isp_async(isp, ISPASYNC_LIP, NULL); 4233#ifdef ISP_TARGET_MODE 4234 if (isp_target_async(isp, bus, mbox)) 4235 rval = -1; --- 137 unchanged lines hidden (view full) --- 4373 isp_prt(isp, ISP_LOGWARN, "Unknown Async Code 0x%x", mbox); 4374 break; 4375 } 4376 4377 if (bus & 0x100) { 4378 int i, nh; 4379 u_int16_t handles[16]; 4380 |
4381 for (nh = 0, i = 1; i < MAX_MAILBOX(isp); i++) { |
4382 if ((bus & (1 << i)) == 0) { 4383 continue; 4384 } 4385 handles[nh++] = ISP_READ(isp, MBOX_OFF(i)); 4386 } 4387 for (i = 0; i < nh; i++) { 4388 isp_fastpost_complete(isp, handles[i]); 4389 isp_prt(isp, ISP_LOGDEBUG3, --- 399 unchanged lines hidden (view full) --- 4789 /* 4790 * If we're on a local loop, force a LIP (which is overkill) 4791 * to force a re-login of this unit. If we're on fabric, 4792 * then we'll have to relogin as a matter of course. 4793 */ 4794 if (FCPARAM(isp)->isp_topo == TOPO_NL_PORT || 4795 FCPARAM(isp)->isp_topo == TOPO_FL_PORT) { 4796 mbreg_t mbs; |
4797 MEMZERO(&mbs, sizeof (mbs)); |
4798 mbs.param[0] = MBOX_INIT_LIP; 4799 isp_mboxcmd_qnw(isp, &mbs, 1); 4800 } 4801 4802 /* 4803 * Probably overkill. 4804 */ 4805 isp->isp_sendmarker = 1; --- 78 unchanged lines hidden (view full) --- 4884 default: 4885 return (1); 4886 } 4887 if (isp->isp_mboxtmp[0] != MBOX_COMMAND_COMPLETE) { 4888 isp->isp_mbxwrk0 = 0; 4889 return (-1); 4890 } 4891 |
4892 /* 4893 * Clear the previous interrupt. 4894 */ 4895 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 4896 ISP_WRITE(isp, BIU_SEMA, 0); 4897 4898 /* 4899 * Continue with next word. 4900 */ |
4901 MEMZERO(&mbs, sizeof (mbs)); |
4902 ptr = isp->isp_mbxworkp; 4903 switch (isp->isp_lastmbxcmd) { 4904 case MBOX_WRITE_RAM_WORD: 4905 mbs.param[2] = *ptr++; 4906 mbs.param[1] = isp->isp_mbxwrk1++; 4907 break; 4908 case MBOX_READ_RAM_WORD: 4909 case MBOX_READ_RAM_WORD_EXTENDED: --- 4 unchanged lines hidden (view full) --- 4914 isp->isp_mbxworkp = ptr; 4915 mbs.param[0] = isp->isp_lastmbxcmd; 4916 isp->isp_mbxwrk0 -= 1; 4917 isp_mboxcmd_qnw(isp, &mbs, 0); 4918 return (0); 4919} 4920 4921 |
4922#define HIWRD(x) ((x) >> 16) 4923#define LOWRD(x) ((x) & 0xffff) 4924#define ISPOPMAP(a, b) (((a) << 16) | (b)) 4925static const u_int32_t mbpscsi[] = { |
4926 ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */ 4927 ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */ 4928 ISPOPMAP(0x03, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */ 4929 ISPOPMAP(0x1f, 0x01), /* 0x03: MBOX_DUMP_RAM */ 4930 ISPOPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */ 4931 ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */ 4932 ISPOPMAP(0x3f, 0x3f), /* 0x06: MBOX_MAILBOX_REG_TEST */ 4933 ISPOPMAP(0x03, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */ --- 179 unchanged lines hidden (view full) --- 5113 NULL, 5114 "SET DATA OVERRUN RECOVERY MODE", 5115 "GET DATA OVERRUN RECOVERY MODE", 5116 "SET HOST DATA", 5117 "GET NOST DATA", 5118}; 5119#endif 5120 |
5121static const u_int32_t mbpfc[] = { |
5122 ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */ 5123 ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */ 5124 ISPOPMAP(0x03, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */ 5125 ISPOPMAP(0xdf, 0x01), /* 0x03: MBOX_DUMP_RAM */ 5126 ISPOPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */ 5127 ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */ 5128 ISPOPMAP(0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */ 5129 ISPOPMAP(0x03, 0x05), /* 0x07: MBOX_VERIFY_CHECKSUM */ --- 256 unchanged lines hidden (view full) --- 5386 "Lun RESET" 5387}; 5388#endif 5389 5390static void 5391isp_mboxcmd_qnw(struct ispsoftc *isp, mbreg_t *mbp, int nodelay) 5392{ 5393 unsigned int ibits, obits, box, opcode; |
5394 const u_int32_t *mcp; |
5395 5396 if (IS_FC(isp)) { 5397 mcp = mbpfc; 5398 } else { 5399 mcp = mbpscsi; 5400 } 5401 opcode = mbp->param[0]; |
5402 ibits = HIWRD(mcp[opcode]) & NMBOX_BMASK(isp); 5403 obits = LOWRD(mcp[opcode]) & NMBOX_BMASK(isp); 5404 ibits |= mbp->ibits; 5405 obits |= mbp->obits; 5406 for (box = 0; box < MAX_MAILBOX(isp); box++) { |
5407 if (ibits & (1 << box)) { 5408 ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]); 5409 } 5410 if (nodelay == 0) { 5411 isp->isp_mboxtmp[box] = mbp->param[box] = 0; 5412 } 5413 } 5414 if (nodelay == 0) { --- 12 unchanged lines hidden (view full) --- 5427 } 5428} 5429 5430static void 5431isp_mboxcmd(struct ispsoftc *isp, mbreg_t *mbp, int logmask) 5432{ 5433 char *cname, *xname, tname[16], mname[16]; 5434 unsigned int lim, ibits, obits, box, opcode; |
5435 const u_int32_t *mcp; |
5436 5437 if (IS_FC(isp)) { 5438 mcp = mbpfc; 5439 lim = (sizeof (mbpfc) / sizeof (mbpfc[0])); 5440 } else { 5441 mcp = mbpscsi; 5442 lim = (sizeof (mbpscsi) / sizeof (mbpscsi[0])); 5443 } 5444 5445 if ((opcode = mbp->param[0]) >= lim) { 5446 mbp->param[0] = MBOX_INVALID_COMMAND; 5447 isp_prt(isp, ISP_LOGERR, "Unknown Command 0x%x", opcode); 5448 return; 5449 } 5450 |
5451 ibits = HIWRD(mcp[opcode]) & NMBOX_BMASK(isp); 5452 obits = LOWRD(mcp[opcode]) & NMBOX_BMASK(isp); |
5453 |
5454 ibits |= mbp->ibits; 5455 obits |= mbp->obits; 5456 |
5457 if (ibits == 0 && obits == 0) { 5458 mbp->param[0] = MBOX_COMMAND_PARAM_ERROR; 5459 isp_prt(isp, ISP_LOGERR, "no parameters for 0x%x", opcode); 5460 return; 5461 } 5462 5463 /* 5464 * Get exclusive usage of mailbox registers. 5465 */ 5466 MBOX_ACQUIRE(isp); 5467 |
5468 for (box = 0; box < MAX_MAILBOX(isp); box++) { |
5469 if (ibits & (1 << box)) { 5470 ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]); 5471 } 5472 isp->isp_mboxtmp[box] = mbp->param[box] = 0; 5473 } 5474 5475 isp->isp_lastmbxcmd = opcode; 5476 --- 20 unchanged lines hidden (view full) --- 5497 isp->isp_mboxbsy = 0; 5498 MBOX_RELEASE(isp); 5499 return; 5500 } 5501 5502 /* 5503 * Copy back output registers. 5504 */ |
5505 for (box = 0; box < MAX_MAILBOX(isp); box++) { |
5506 if (obits & (1 << box)) { 5507 mbp->param[box] = isp->isp_mboxtmp[box]; 5508 } 5509 } 5510 5511 MBOX_RELEASE(isp); 5512 5513 if (logmask == 0 || opcode == MBOX_EXEC_FIRMWARE) { --- 63 unchanged lines hidden (view full) --- 5577 5578static void 5579isp_fw_state(struct ispsoftc *isp) 5580{ 5581 if (IS_FC(isp)) { 5582 mbreg_t mbs; 5583 fcparam *fcp = isp->isp_param; 5584 |
5585 MEMZERO(&mbs, sizeof (mbs)); |
5586 mbs.param[0] = MBOX_GET_FW_STATE; 5587 isp_mboxcmd(isp, &mbs, MBLOGALL); 5588 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { 5589 fcp->isp_fwstate = mbs.param[1]; 5590 } 5591 } 5592} 5593 --- 21 unchanged lines hidden (view full) --- 5615 if (IS_FC(isp)) { 5616 /* 5617 * There are no 'per-bus' settings for Fibre Channel. 5618 */ 5619 return; 5620 } 5621 sdp = isp->isp_param; 5622 sdp += bus; |
5623 MEMZERO(&mbs, sizeof (mbs)); |
5624 5625 for (tgt = 0; tgt < MAX_TARGETS; tgt++) { 5626 u_int16_t flags, period, offset; 5627 int get; 5628 5629 if (sdp->isp_devparam[tgt].dev_enable == 0) { 5630 sdp->isp_devparam[tgt].dev_update = 0; 5631 sdp->isp_devparam[tgt].dev_refresh = 0; --- 99 unchanged lines hidden (view full) --- 5731 5732static void 5733isp_setdfltparm(struct ispsoftc *isp, int channel) 5734{ 5735 int tgt; 5736 mbreg_t mbs; 5737 sdparam *sdp; 5738 |
5739 MEMZERO(&mbs, sizeof (mbs)); |
5740 if (IS_FC(isp)) { 5741 fcparam *fcp = (fcparam *) isp->isp_param; 5742 int nvfail; 5743 5744 fcp += channel; 5745 if (fcp->isp_gotdparms) { 5746 return; 5747 } --- 801 unchanged lines hidden (view full) --- 6549 6550static void 6551isp2200_fw_dump(struct ispsoftc *isp) 6552{ 6553 int i, j; 6554 mbreg_t mbs; 6555 u_int16_t *ptr; 6556 |
6557 MEMZERO(&mbs, sizeof (mbs)); |
6558 ptr = FCPARAM(isp)->isp_dump_data; 6559 if (ptr == NULL) { 6560 isp_prt(isp, ISP_LOGERR, 6561 "No place to dump RISC registers and SRAM"); 6562 return; 6563 } 6564 if (*ptr++) { 6565 isp_prt(isp, ISP_LOGERR, --- 128 unchanged lines hidden (view full) --- 6694 6695static void 6696isp2300_fw_dump(struct ispsoftc *isp) 6697{ 6698 int i, j; 6699 mbreg_t mbs; 6700 u_int16_t *ptr; 6701 |
6702 MEMZERO(&mbs, sizeof (mbs)); |
6703 ptr = FCPARAM(isp)->isp_dump_data; 6704 if (ptr == NULL) { 6705 isp_prt(isp, ISP_LOGERR, 6706 "No place to dump RISC registers and SRAM"); 6707 return; 6708 } 6709 if (*ptr++) { 6710 isp_prt(isp, ISP_LOGERR, --- 157 unchanged lines hidden --- |