isp.c (81988) | isp.c (82689) |
---|---|
1/* $FreeBSD: head/sys/dev/isp/isp.c 81988 2001-08-20 17:28:32Z mjacob $ */ | 1/* $FreeBSD: head/sys/dev/isp/isp.c 82689 2001-08-31 21:39:04Z 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 * --- 135 unchanged lines hidden (view full) --- 145 146/* 147 * Reset Hardware. 148 * 149 * Hit the chip over the head, download new f/w if available and set it running. 150 * 151 * Locking done elsewhere. 152 */ | 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 * --- 135 unchanged lines hidden (view full) --- 145 146/* 147 * Reset Hardware. 148 * 149 * Hit the chip over the head, download new f/w if available and set it running. 150 * 151 * Locking done elsewhere. 152 */ |
153 |
|
153void 154isp_reset(struct ispsoftc *isp) 155{ 156 mbreg_t mbs; | 154void 155isp_reset(struct ispsoftc *isp) 156{ 157 mbreg_t mbs; |
158 u_int16_t code_org; |
|
157 int loops, i, touched, dodnld = 1; | 159 int loops, i, touched, dodnld = 1; |
158 char *revname = "????"; | 160 char *btype = "????"; |
159 160 isp->isp_state = ISP_NILSTATE; 161 162 163 /* 164 * Basic types (SCSI, FibreChannel and PCI or SBus) 165 * have been set in the MD code. We figure out more | 161 162 isp->isp_state = ISP_NILSTATE; 163 164 165 /* 166 * Basic types (SCSI, FibreChannel and PCI or SBus) 167 * have been set in the MD code. We figure out more |
166 * here. | 168 * here. Possibly more refined types based upon PCI 169 * identification. Chip revision has been gathered. |
167 * 168 * After we've fired this chip up, zero out the conf1 register 169 * for SCSI adapters and do other settings for the 2100. 170 */ 171 172 /* 173 * Get the current running firmware revision out of the 174 * chip before we hit it over the head (if this is our --- 25 unchanged lines hidden (view full) --- 200 isp->isp_romfw_rev[1] = mbs.param[2]; 201 isp->isp_romfw_rev[2] = mbs.param[3]; 202 } 203 } 204 isp->isp_touched = 1; 205 } 206 207 DISABLE_INTS(isp); | 170 * 171 * After we've fired this chip up, zero out the conf1 register 172 * for SCSI adapters and do other settings for the 2100. 173 */ 174 175 /* 176 * Get the current running firmware revision out of the 177 * chip before we hit it over the head (if this is our --- 25 unchanged lines hidden (view full) --- 203 isp->isp_romfw_rev[1] = mbs.param[2]; 204 isp->isp_romfw_rev[2] = mbs.param[3]; 205 } 206 } 207 isp->isp_touched = 1; 208 } 209 210 DISABLE_INTS(isp); |
211 /* 212 * Set up default request/response queue in-pointer/out-pointer 213 * register indices. 214 */ 215 isp->isp_rqstinrp = INMAILBOX4; 216 isp->isp_rqstoutrp = OUTMAILBOX4; 217 isp->isp_respinrp = OUTMAILBOX5; 218 isp->isp_respoutrp = INMAILBOX5; |
|
208 209 /* 210 * Put the board into PAUSE mode (so we can read the SXP registers 211 * or write FPM/FBM registers). 212 */ 213 ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); 214 215 if (IS_FC(isp)) { 216 switch (isp->isp_type) { 217 case ISP_HA_FC_2100: | 219 220 /* 221 * Put the board into PAUSE mode (so we can read the SXP registers 222 * or write FPM/FBM registers). 223 */ 224 ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); 225 226 if (IS_FC(isp)) { 227 switch (isp->isp_type) { 228 case ISP_HA_FC_2100: |
218 revname = "2100"; | 229 btype = "2100"; |
219 break; 220 case ISP_HA_FC_2200: | 230 break; 231 case ISP_HA_FC_2200: |
221 revname = "2200"; | 232 btype = "2200"; |
222 break; 223 case ISP_HA_FC_2300: | 233 break; 234 case ISP_HA_FC_2300: |
224 revname = "2300"; | 235 isp->isp_rqstinrp = BIU_REQINP; 236 isp->isp_rqstoutrp = BIU_REQOUTP; 237 isp->isp_respinrp = BIU_RSPINP; 238 isp->isp_respoutrp = BIU_RSPOUTP; 239 btype = "2300"; |
225 break; 226 default: 227 break; 228 } 229 /* 230 * While we're paused, reset the FPM module and FBM fifos. 231 */ 232 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS); 233 ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET); 234 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS); 235 ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL); 236 ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS); 237 } else if (IS_1240(isp)) { 238 sdparam *sdp = isp->isp_param; | 240 break; 241 default: 242 break; 243 } 244 /* 245 * While we're paused, reset the FPM module and FBM fifos. 246 */ 247 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS); 248 ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET); 249 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS); 250 ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL); 251 ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS); 252 } else if (IS_1240(isp)) { 253 sdparam *sdp = isp->isp_param; |
239 revname = "1240"; | 254 btype = "1240"; |
240 isp->isp_clock = 60; 241 sdp->isp_ultramode = 1; 242 sdp++; 243 sdp->isp_ultramode = 1; 244 /* 245 * XXX: Should probably do some bus sensing. 246 */ 247 } else if (IS_ULTRA2(isp)) { 248 static const char m[] = "bus %d is in %s Mode"; 249 u_int16_t l; 250 sdparam *sdp = isp->isp_param; 251 252 isp->isp_clock = 100; 253 254 if (IS_1280(isp)) | 255 isp->isp_clock = 60; 256 sdp->isp_ultramode = 1; 257 sdp++; 258 sdp->isp_ultramode = 1; 259 /* 260 * XXX: Should probably do some bus sensing. 261 */ 262 } else if (IS_ULTRA2(isp)) { 263 static const char m[] = "bus %d is in %s Mode"; 264 u_int16_t l; 265 sdparam *sdp = isp->isp_param; 266 267 isp->isp_clock = 100; 268 269 if (IS_1280(isp)) |
255 revname = "1280"; | 270 btype = "1280"; |
256 else if (IS_1080(isp)) | 271 else if (IS_1080(isp)) |
257 revname = "1080"; | 272 btype = "1080"; |
258 else if (IS_12160(isp)) | 273 else if (IS_12160(isp)) |
259 revname = "12160"; | 274 btype = "12160"; |
260 else | 275 else |
261 revname = "<UNKLVD>"; | 276 btype = "<UNKLVD>"; |
262 263 l = ISP_READ(isp, SXP_PINS_DIFF) & ISP1080_MODE_MASK; 264 switch (l) { 265 case ISP1080_LVD_MODE: 266 sdp->isp_lvdmode = 1; 267 isp_prt(isp, ISP_LOGCONFIG, m, 0, "LVD"); 268 break; 269 case ISP1080_HVD_MODE: --- 38 unchanged lines hidden (view full) --- 308 } else { 309 sdparam *sdp = isp->isp_param; 310 i = ISP_READ(isp, BIU_CONF0) & BIU_CONF0_HW_MASK; 311 switch (i) { 312 default: 313 isp_prt(isp, ISP_LOGALL, "Unknown Chip Type 0x%x", i); 314 /* FALLTHROUGH */ 315 case 1: | 277 278 l = ISP_READ(isp, SXP_PINS_DIFF) & ISP1080_MODE_MASK; 279 switch (l) { 280 case ISP1080_LVD_MODE: 281 sdp->isp_lvdmode = 1; 282 isp_prt(isp, ISP_LOGCONFIG, m, 0, "LVD"); 283 break; 284 case ISP1080_HVD_MODE: --- 38 unchanged lines hidden (view full) --- 323 } else { 324 sdparam *sdp = isp->isp_param; 325 i = ISP_READ(isp, BIU_CONF0) & BIU_CONF0_HW_MASK; 326 switch (i) { 327 default: 328 isp_prt(isp, ISP_LOGALL, "Unknown Chip Type 0x%x", i); 329 /* FALLTHROUGH */ 330 case 1: |
316 revname = "1020"; | 331 btype = "1020"; |
317 isp->isp_type = ISP_HA_SCSI_1020; 318 isp->isp_clock = 40; 319 break; 320 case 2: 321 /* 322 * Some 1020A chips are Ultra Capable, but don't 323 * run the clock rate up for that unless told to 324 * do so by the Ultra Capable bits being set. 325 */ | 332 isp->isp_type = ISP_HA_SCSI_1020; 333 isp->isp_clock = 40; 334 break; 335 case 2: 336 /* 337 * Some 1020A chips are Ultra Capable, but don't 338 * run the clock rate up for that unless told to 339 * do so by the Ultra Capable bits being set. 340 */ |
326 revname = "1020A"; | 341 btype = "1020A"; |
327 isp->isp_type = ISP_HA_SCSI_1020A; 328 isp->isp_clock = 40; 329 break; 330 case 3: | 342 isp->isp_type = ISP_HA_SCSI_1020A; 343 isp->isp_clock = 40; 344 break; 345 case 3: |
331 revname = "1040"; | 346 btype = "1040"; |
332 isp->isp_type = ISP_HA_SCSI_1040; 333 isp->isp_clock = 60; 334 break; 335 case 4: | 347 isp->isp_type = ISP_HA_SCSI_1040; 348 isp->isp_clock = 60; 349 break; 350 case 4: |
336 revname = "1040A"; | 351 btype = "1040A"; |
337 isp->isp_type = ISP_HA_SCSI_1040A; 338 isp->isp_clock = 60; 339 break; 340 case 5: | 352 isp->isp_type = ISP_HA_SCSI_1040A; 353 isp->isp_clock = 60; 354 break; 355 case 5: |
341 revname = "1040B"; | 356 btype = "1040B"; |
342 isp->isp_type = ISP_HA_SCSI_1040B; 343 isp->isp_clock = 60; 344 break; 345 case 6: | 357 isp->isp_type = ISP_HA_SCSI_1040B; 358 isp->isp_clock = 60; 359 break; 360 case 6: |
346 revname = "1040C"; | 361 btype = "1040C"; |
347 isp->isp_type = ISP_HA_SCSI_1040C; 348 isp->isp_clock = 60; 349 break; 350 } 351 /* 352 * Now, while we're at it, gather info about ultra 353 * and/or differential mode. 354 */ --- 233 unchanged lines hidden (view full) --- 588 * whether we have f/w at all and whether a config flag 589 * has disabled our download. 590 */ 591 if ((isp->isp_mdvec->dv_ispfw == NULL) || 592 (isp->isp_confopts & ISP_CFG_NORELOAD)) { 593 dodnld = 0; 594 } 595 | 362 isp->isp_type = ISP_HA_SCSI_1040C; 363 isp->isp_clock = 60; 364 break; 365 } 366 /* 367 * Now, while we're at it, gather info about ultra 368 * and/or differential mode. 369 */ --- 233 unchanged lines hidden (view full) --- 603 * whether we have f/w at all and whether a config flag 604 * has disabled our download. 605 */ 606 if ((isp->isp_mdvec->dv_ispfw == NULL) || 607 (isp->isp_confopts & ISP_CFG_NORELOAD)) { 608 dodnld = 0; 609 } 610 |
611 if (IS_2300(isp)) 612 code_org = ISP_CODE_ORG_2300; 613 else 614 code_org = ISP_CODE_ORG; 615 |
|
596 if (dodnld) { 597 u_int16_t fwlen = isp->isp_mdvec->dv_ispfw[3]; 598 for (i = 0; i < fwlen; i++) { 599 mbs.param[0] = MBOX_WRITE_RAM_WORD; | 616 if (dodnld) { 617 u_int16_t fwlen = isp->isp_mdvec->dv_ispfw[3]; 618 for (i = 0; i < fwlen; i++) { 619 mbs.param[0] = MBOX_WRITE_RAM_WORD; |
600 mbs.param[1] = ISP_CODE_ORG + i; | 620 mbs.param[1] = code_org + i; |
601 mbs.param[2] = isp->isp_mdvec->dv_ispfw[i]; 602 isp_mboxcmd(isp, &mbs, MBLOGNONE); 603 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 604 isp_prt(isp, ISP_LOGERR, 605 "F/W download failed at word %d", i); 606 dodnld = 0; 607 goto again; 608 } 609 } 610 611 /* 612 * Verify that it downloaded correctly. 613 */ 614 mbs.param[0] = MBOX_VERIFY_CHECKSUM; | 621 mbs.param[2] = isp->isp_mdvec->dv_ispfw[i]; 622 isp_mboxcmd(isp, &mbs, MBLOGNONE); 623 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 624 isp_prt(isp, ISP_LOGERR, 625 "F/W download failed at word %d", i); 626 dodnld = 0; 627 goto again; 628 } 629 } 630 631 /* 632 * Verify that it downloaded correctly. 633 */ 634 mbs.param[0] = MBOX_VERIFY_CHECKSUM; |
615 mbs.param[1] = ISP_CODE_ORG; | 635 mbs.param[1] = code_org; |
616 isp_mboxcmd(isp, &mbs, MBLOGNONE); 617 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 618 isp_prt(isp, ISP_LOGERR, "Ram Checksum Failure"); 619 return; 620 } 621 isp->isp_loaded_fw = 1; 622 } else { 623 isp->isp_loaded_fw = 0; 624 isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download"); 625 } 626 627 /* 628 * Now start it rolling. 629 * 630 * If we didn't actually download f/w, 631 * we still need to (re)start it. 632 */ 633 | 636 isp_mboxcmd(isp, &mbs, MBLOGNONE); 637 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 638 isp_prt(isp, ISP_LOGERR, "Ram Checksum Failure"); 639 return; 640 } 641 isp->isp_loaded_fw = 1; 642 } else { 643 isp->isp_loaded_fw = 0; 644 isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download"); 645 } 646 647 /* 648 * Now start it rolling. 649 * 650 * If we didn't actually download f/w, 651 * we still need to (re)start it. 652 */ 653 |
654 |
|
634 mbs.param[0] = MBOX_EXEC_FIRMWARE; | 655 mbs.param[0] = MBOX_EXEC_FIRMWARE; |
635 mbs.param[1] = ISP_CODE_ORG; | 656 mbs.param[1] = code_org; |
636 isp_mboxcmd(isp, &mbs, MBLOGNONE); 637 /* give it a chance to start */ 638 USEC_SLEEP(isp, 500); 639 640 if (IS_SCSI(isp)) { 641 /* 642 * Set CLOCK RATE, but only if asked to. 643 */ --- 6 unchanged lines hidden (view full) --- 650 } 651 652 mbs.param[0] = MBOX_ABOUT_FIRMWARE; 653 isp_mboxcmd(isp, &mbs, MBLOGALL); 654 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 655 return; 656 } 657 isp_prt(isp, ISP_LOGCONFIG, | 657 isp_mboxcmd(isp, &mbs, MBLOGNONE); 658 /* give it a chance to start */ 659 USEC_SLEEP(isp, 500); 660 661 if (IS_SCSI(isp)) { 662 /* 663 * Set CLOCK RATE, but only if asked to. 664 */ --- 6 unchanged lines hidden (view full) --- 671 } 672 673 mbs.param[0] = MBOX_ABOUT_FIRMWARE; 674 isp_mboxcmd(isp, &mbs, MBLOGALL); 675 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 676 return; 677 } 678 isp_prt(isp, ISP_LOGCONFIG, |
658 "Board Revision %s, %s F/W Revision %d.%d.%d", revname, 659 dodnld? "loaded" : "resident", mbs.param[1], mbs.param[2], 660 mbs.param[3]); | 679 "Board Type %s, Chip Revision 0x%x, %s F/W Revision %d.%d.%d", 680 btype, isp->isp_revision, dodnld? "loaded" : "resident", 681 mbs.param[1], mbs.param[2], mbs.param[3]); |
661 if (IS_FC(isp)) { 662 isp_prt(isp, ISP_LOGCONFIG, "Firmware Attributes = 0x%x", 663 mbs.param[6]); 664 if (ISP_READ(isp, BIU2100_CSR) & BIU2100_PCI64) { 665 isp_prt(isp, ISP_LOGCONFIG, 666 "Installed in 64-Bit PCI slot"); 667 } 668 } --- 197 unchanged lines hidden (view full) --- 866 isp_scsi_channel_init(isp, 1); 867 868 /* 869 * Now enable request/response queues 870 */ 871 872 mbs.param[0] = MBOX_INIT_RES_QUEUE; 873 mbs.param[1] = RESULT_QUEUE_LEN(isp); | 682 if (IS_FC(isp)) { 683 isp_prt(isp, ISP_LOGCONFIG, "Firmware Attributes = 0x%x", 684 mbs.param[6]); 685 if (ISP_READ(isp, BIU2100_CSR) & BIU2100_PCI64) { 686 isp_prt(isp, ISP_LOGCONFIG, 687 "Installed in 64-Bit PCI slot"); 688 } 689 } --- 197 unchanged lines hidden (view full) --- 887 isp_scsi_channel_init(isp, 1); 888 889 /* 890 * Now enable request/response queues 891 */ 892 893 mbs.param[0] = MBOX_INIT_RES_QUEUE; 894 mbs.param[1] = RESULT_QUEUE_LEN(isp); |
874 mbs.param[2] = DMA_MSW(isp->isp_result_dma); 875 mbs.param[3] = DMA_LSW(isp->isp_result_dma); | 895 mbs.param[2] = DMA_WD1(isp->isp_result_dma); 896 mbs.param[3] = DMA_WD0(isp->isp_result_dma); |
876 mbs.param[4] = 0; 877 mbs.param[5] = 0; 878 isp_mboxcmd(isp, &mbs, MBLOGALL); 879 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 880 return; 881 } 882 isp->isp_residx = mbs.param[5]; 883 884 mbs.param[0] = MBOX_INIT_REQ_QUEUE; 885 mbs.param[1] = RQUEST_QUEUE_LEN(isp); | 897 mbs.param[4] = 0; 898 mbs.param[5] = 0; 899 isp_mboxcmd(isp, &mbs, MBLOGALL); 900 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 901 return; 902 } 903 isp->isp_residx = mbs.param[5]; 904 905 mbs.param[0] = MBOX_INIT_REQ_QUEUE; 906 mbs.param[1] = RQUEST_QUEUE_LEN(isp); |
886 mbs.param[2] = DMA_MSW(isp->isp_rquest_dma); 887 mbs.param[3] = DMA_LSW(isp->isp_rquest_dma); | 907 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma); 908 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma); |
888 mbs.param[4] = 0; 889 isp_mboxcmd(isp, &mbs, MBLOGALL); 890 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 891 return; 892 } 893 isp->isp_reqidx = isp->isp_reqodx = mbs.param[4]; 894 895 /* --- 241 unchanged lines hidden (view full) --- 1137 icbp->icb_execthrottle = ICB_DFLT_THROTTLE; 1138 } 1139 icbp->icb_retry_delay = fcp->isp_retry_delay; 1140 icbp->icb_retry_count = fcp->isp_retry_count; 1141 icbp->icb_hardaddr = loopid; 1142 /* 1143 * Right now we just set extended options to prefer point-to-point 1144 * over loop based upon some soft config options. | 909 mbs.param[4] = 0; 910 isp_mboxcmd(isp, &mbs, MBLOGALL); 911 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 912 return; 913 } 914 isp->isp_reqidx = isp->isp_reqodx = mbs.param[4]; 915 916 /* --- 241 unchanged lines hidden (view full) --- 1158 icbp->icb_execthrottle = ICB_DFLT_THROTTLE; 1159 } 1160 icbp->icb_retry_delay = fcp->isp_retry_delay; 1161 icbp->icb_retry_count = fcp->isp_retry_count; 1162 icbp->icb_hardaddr = loopid; 1163 /* 1164 * Right now we just set extended options to prefer point-to-point 1165 * over loop based upon some soft config options. |
1166 * 1167 * NB: for the 2300, ICBOPT_EXTENDED is required. |
|
1145 */ 1146 if (IS_2200(isp) || IS_2300(isp)) { 1147 icbp->icb_fwoptions |= ICBOPT_EXTENDED; 1148 /* 1149 * Prefer or force Point-To-Point instead Loop? 1150 */ 1151 switch(isp->isp_confopts & ISP_CFG_PORT_PREF) { 1152 case ISP_CFG_NPORT: --- 4 unchanged lines hidden (view full) --- 1157 break; 1158 case ISP_CFG_LPORT_ONLY: 1159 icbp->icb_xfwoptions = ICBXOPT_LOOP_ONLY; 1160 break; 1161 default: 1162 icbp->icb_xfwoptions = ICBXOPT_LOOP_2_PTP; 1163 break; 1164 } | 1168 */ 1169 if (IS_2200(isp) || IS_2300(isp)) { 1170 icbp->icb_fwoptions |= ICBOPT_EXTENDED; 1171 /* 1172 * Prefer or force Point-To-Point instead Loop? 1173 */ 1174 switch(isp->isp_confopts & ISP_CFG_PORT_PREF) { 1175 case ISP_CFG_NPORT: --- 4 unchanged lines hidden (view full) --- 1180 break; 1181 case ISP_CFG_LPORT_ONLY: 1182 icbp->icb_xfwoptions = ICBXOPT_LOOP_ONLY; 1183 break; 1184 default: 1185 icbp->icb_xfwoptions = ICBXOPT_LOOP_2_PTP; 1186 break; 1187 } |
1188 if (IS_2300(isp)) { 1189 if (isp->isp_revision < 2) { 1190 icbp->icb_fwoptions &= ~ICBOPT_FAST_POST; 1191 } 1192 icbp->icb_xfwoptions |= ICBXOPT_RATE_AUTO; 1193 } 1194 } 1195 1196 if (IS_2200(isp) || IS_2300(isp)) { |
|
1165 /* 1166 * Turn on LIP F8 async event (1) 1167 * Turn on generate AE 8013 on all LIP Resets (2) 1168 * Disable LIP F7 switching (8) 1169 */ 1170 mbs.param[0] = MBOX_SET_FIRMWARE_OPTIONS; 1171 mbs.param[1] = 0xb; 1172 mbs.param[2] = 0; 1173 mbs.param[3] = 0; 1174 isp_mboxcmd(isp, &mbs, MBLOGALL); 1175 } | 1197 /* 1198 * Turn on LIP F8 async event (1) 1199 * Turn on generate AE 8013 on all LIP Resets (2) 1200 * Disable LIP F7 switching (8) 1201 */ 1202 mbs.param[0] = MBOX_SET_FIRMWARE_OPTIONS; 1203 mbs.param[1] = 0xb; 1204 mbs.param[2] = 0; 1205 mbs.param[3] = 0; 1206 isp_mboxcmd(isp, &mbs, MBLOGALL); 1207 } |
1176 icbp->icb_logintime = 60; /* 60 second login timeout */ | 1208 icbp->icb_logintime = 30; /* 30 second login timeout */ |
1177 | 1209 |
1210 if (IS_2300(isp)) { 1211 ISP_WRITE(isp, isp->isp_rqstinrp, 0); 1212 ISP_WRITE(isp, isp->isp_rqstoutrp, 0); 1213 ISP_WRITE(isp, isp->isp_respinrp, 0); 1214 ISP_WRITE(isp, isp->isp_respoutrp, 0); 1215 } 1216 |
|
1178 nwwn = ISP_NODEWWN(isp); 1179 pwwn = ISP_PORTWWN(isp); 1180 if (nwwn && pwwn) { 1181 icbp->icb_fwoptions |= ICBOPT_BOTH_WWNS; 1182 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, nwwn); 1183 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, pwwn); 1184 isp_prt(isp, ISP_LOGDEBUG1, 1185 "Setting ICB Node 0x%08x%08x Port 0x%08x%08x", 1186 ((u_int32_t) (nwwn >> 32)), 1187 ((u_int32_t) (nwwn & 0xffffffff)), 1188 ((u_int32_t) (pwwn >> 32)), 1189 ((u_int32_t) (pwwn & 0xffffffff))); 1190 } else { 1191 isp_prt(isp, ISP_LOGDEBUG1, "Not using any WWNs"); 1192 icbp->icb_fwoptions &= ~(ICBOPT_BOTH_WWNS|ICBOPT_FULL_LOGIN); 1193 } 1194 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp); 1195 icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp); | 1217 nwwn = ISP_NODEWWN(isp); 1218 pwwn = ISP_PORTWWN(isp); 1219 if (nwwn && pwwn) { 1220 icbp->icb_fwoptions |= ICBOPT_BOTH_WWNS; 1221 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, nwwn); 1222 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, pwwn); 1223 isp_prt(isp, ISP_LOGDEBUG1, 1224 "Setting ICB Node 0x%08x%08x Port 0x%08x%08x", 1225 ((u_int32_t) (nwwn >> 32)), 1226 ((u_int32_t) (nwwn & 0xffffffff)), 1227 ((u_int32_t) (pwwn >> 32)), 1228 ((u_int32_t) (pwwn & 0xffffffff))); 1229 } else { 1230 isp_prt(isp, ISP_LOGDEBUG1, "Not using any WWNs"); 1231 icbp->icb_fwoptions &= ~(ICBOPT_BOTH_WWNS|ICBOPT_FULL_LOGIN); 1232 } 1233 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp); 1234 icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp); |
1196 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_rquest_dma); 1197 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_rquest_dma); 1198 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_result_dma); 1199 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_result_dma); | 1235 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_rquest_dma); 1236 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_rquest_dma); 1237 icbp->icb_rqstaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_rquest_dma); 1238 icbp->icb_rqstaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_rquest_dma); 1239 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_result_dma); 1240 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_result_dma); 1241 icbp->icb_respaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_result_dma); 1242 icbp->icb_respaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_result_dma); |
1200 isp_prt(isp, ISP_LOGDEBUG1, 1201 "isp_fibre_init: fwoptions 0x%x", fcp->isp_fwoptions); 1202 ISP_SWIZZLE_ICB(isp, icbp); 1203 1204 1205 /* 1206 * Init the firmware 1207 */ 1208 mbs.param[0] = MBOX_INIT_FIRMWARE; 1209 mbs.param[1] = 0; | 1243 isp_prt(isp, ISP_LOGDEBUG1, 1244 "isp_fibre_init: fwoptions 0x%x", fcp->isp_fwoptions); 1245 ISP_SWIZZLE_ICB(isp, icbp); 1246 1247 1248 /* 1249 * Init the firmware 1250 */ 1251 mbs.param[0] = MBOX_INIT_FIRMWARE; 1252 mbs.param[1] = 0; |
1210 mbs.param[2] = DMA_MSW(fcp->isp_scdma); 1211 mbs.param[3] = DMA_LSW(fcp->isp_scdma); | 1253 mbs.param[2] = DMA_WD1(fcp->isp_scdma); 1254 mbs.param[3] = DMA_WD0(fcp->isp_scdma); |
1212 mbs.param[4] = 0; 1213 mbs.param[5] = 0; | 1255 mbs.param[4] = 0; 1256 mbs.param[5] = 0; |
1214 mbs.param[6] = 0; 1215 mbs.param[7] = 0; | 1257 mbs.param[6] = DMA_WD3(fcp->isp_scdma); 1258 mbs.param[7] = DMA_WD2(fcp->isp_scdma); |
1216 isp_mboxcmd(isp, &mbs, MBLOGALL); 1217 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 1218 return; 1219 } 1220 isp->isp_reqidx = isp->isp_reqodx = 0; 1221 isp->isp_residx = 0; 1222 isp->isp_sendmarker = 1; 1223 --- 13 unchanged lines hidden (view full) --- 1237static int 1238isp_getmap(struct ispsoftc *isp, fcpos_map_t *map) 1239{ 1240 fcparam *fcp = (fcparam *) isp->isp_param; 1241 mbreg_t mbs; 1242 1243 mbs.param[0] = MBOX_GET_FC_AL_POSITION_MAP; 1244 mbs.param[1] = 0; | 1259 isp_mboxcmd(isp, &mbs, MBLOGALL); 1260 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 1261 return; 1262 } 1263 isp->isp_reqidx = isp->isp_reqodx = 0; 1264 isp->isp_residx = 0; 1265 isp->isp_sendmarker = 1; 1266 --- 13 unchanged lines hidden (view full) --- 1280static int 1281isp_getmap(struct ispsoftc *isp, fcpos_map_t *map) 1282{ 1283 fcparam *fcp = (fcparam *) isp->isp_param; 1284 mbreg_t mbs; 1285 1286 mbs.param[0] = MBOX_GET_FC_AL_POSITION_MAP; 1287 mbs.param[1] = 0; |
1245 mbs.param[2] = DMA_MSW(fcp->isp_scdma); 1246 mbs.param[3] = DMA_LSW(fcp->isp_scdma); | 1288 mbs.param[2] = DMA_WD1(fcp->isp_scdma); 1289 mbs.param[3] = DMA_WD0(fcp->isp_scdma); |
1247 /* 1248 * Unneeded. For the 2100, except for initializing f/w, registers 1249 * 4/5 have to not be written to. 1250 * mbs.param[4] = 0; 1251 * mbs.param[5] = 0; 1252 * 1253 */ 1254 mbs.param[6] = 0; --- 20 unchanged lines hidden (view full) --- 1275static int 1276isp_getpdb(struct ispsoftc *isp, int id, isp_pdb_t *pdbp) 1277{ 1278 fcparam *fcp = (fcparam *) isp->isp_param; 1279 mbreg_t mbs; 1280 1281 mbs.param[0] = MBOX_GET_PORT_DB; 1282 mbs.param[1] = id << 8; | 1290 /* 1291 * Unneeded. For the 2100, except for initializing f/w, registers 1292 * 4/5 have to not be written to. 1293 * mbs.param[4] = 0; 1294 * mbs.param[5] = 0; 1295 * 1296 */ 1297 mbs.param[6] = 0; --- 20 unchanged lines hidden (view full) --- 1318static int 1319isp_getpdb(struct ispsoftc *isp, int id, isp_pdb_t *pdbp) 1320{ 1321 fcparam *fcp = (fcparam *) isp->isp_param; 1322 mbreg_t mbs; 1323 1324 mbs.param[0] = MBOX_GET_PORT_DB; 1325 mbs.param[1] = id << 8; |
1283 mbs.param[2] = DMA_MSW(fcp->isp_scdma); 1284 mbs.param[3] = DMA_LSW(fcp->isp_scdma); | 1326 mbs.param[2] = DMA_WD1(fcp->isp_scdma); 1327 mbs.param[3] = DMA_WD0(fcp->isp_scdma); |
1285 /* 1286 * Unneeded. For the 2100, except for initializing f/w, registers 1287 * 4/5 have to not be written to. 1288 * mbs.param[4] = 0; 1289 * mbs.param[5] = 0; 1290 * 1291 */ | 1328 /* 1329 * Unneeded. For the 2100, except for initializing f/w, registers 1330 * 4/5 have to not be written to. 1331 * mbs.param[4] = 0; 1332 * mbs.param[5] = 0; 1333 * 1334 */ |
1292 mbs.param[6] = 0; 1293 mbs.param[7] = 0; | 1335 mbs.param[6] = DMA_WD3(fcp->isp_scdma); 1336 mbs.param[7] = DMA_WD2(fcp->isp_scdma); |
1294 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR); 1295 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { 1296 ISP_UNSWIZZLE_AND_COPY_PDBP(isp, pdbp, fcp->isp_scratch); 1297 return (0); 1298 } 1299 return (-1); 1300} 1301 --- 876 unchanged lines hidden (view full) --- 2178 */ 2179 first_portid = portid = fcp->isp_portid; 2180 fcp->isp_loopstate = LOOP_SCANNING_FABRIC; 2181 2182 for (first_portid_seen = hicap = 0; hicap < 65535; hicap++) { 2183 MEMZERO((void *) reqp, SNS_GAN_REQ_SIZE); 2184 reqp->snscb_rblen = SNS_GAN_RESP_SIZE >> 1; 2185 reqp->snscb_addr[RQRSP_ADDR0015] = | 1337 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR); 1338 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { 1339 ISP_UNSWIZZLE_AND_COPY_PDBP(isp, pdbp, fcp->isp_scratch); 1340 return (0); 1341 } 1342 return (-1); 1343} 1344 --- 876 unchanged lines hidden (view full) --- 2221 */ 2222 first_portid = portid = fcp->isp_portid; 2223 fcp->isp_loopstate = LOOP_SCANNING_FABRIC; 2224 2225 for (first_portid_seen = hicap = 0; hicap < 65535; hicap++) { 2226 MEMZERO((void *) reqp, SNS_GAN_REQ_SIZE); 2227 reqp->snscb_rblen = SNS_GAN_RESP_SIZE >> 1; 2228 reqp->snscb_addr[RQRSP_ADDR0015] = |
2186 DMA_LSW(fcp->isp_scdma + 0x100); | 2229 DMA_WD0(fcp->isp_scdma + 0x100); |
2187 reqp->snscb_addr[RQRSP_ADDR1631] = | 2230 reqp->snscb_addr[RQRSP_ADDR1631] = |
2188 DMA_MSW(fcp->isp_scdma + 0x100); | 2231 DMA_WD1(fcp->isp_scdma + 0x100); 2232 reqp->snscb_addr[RQRSP_ADDR3247] = 2233 DMA_WD2(fcp->isp_scdma + 0x100); 2234 reqp->snscb_addr[RQRSP_ADDR4863] = 2235 DMA_WD3(fcp->isp_scdma + 0x100); |
2189 reqp->snscb_sblen = 6; 2190 reqp->snscb_data[0] = SNS_GAN; 2191 reqp->snscb_data[4] = portid & 0xffff; 2192 reqp->snscb_data[5] = (portid >> 16) & 0xff; 2193 ISP_SWIZZLE_SNS_REQ(isp, reqp); 2194 mbs.param[0] = MBOX_SEND_SNS; 2195 mbs.param[1] = SNS_GAN_REQ_SIZE >> 1; | 2236 reqp->snscb_sblen = 6; 2237 reqp->snscb_data[0] = SNS_GAN; 2238 reqp->snscb_data[4] = portid & 0xffff; 2239 reqp->snscb_data[5] = (portid >> 16) & 0xff; 2240 ISP_SWIZZLE_SNS_REQ(isp, reqp); 2241 mbs.param[0] = MBOX_SEND_SNS; 2242 mbs.param[1] = SNS_GAN_REQ_SIZE >> 1; |
2196 mbs.param[2] = DMA_MSW(fcp->isp_scdma); 2197 mbs.param[3] = DMA_LSW(fcp->isp_scdma); 2198 mbs.param[6] = 0; 2199 mbs.param[7] = 0; | 2243 mbs.param[2] = DMA_WD1(fcp->isp_scdma); 2244 mbs.param[3] = DMA_WD0(fcp->isp_scdma); 2245 /* 2246 * Leave 4 and 5 alone 2247 */ 2248 mbs.param[6] = DMA_WD3(fcp->isp_scdma); 2249 mbs.param[7] = DMA_WD2(fcp->isp_scdma); |
2200 isp_mboxcmd(isp, &mbs, MBLOGNONE); 2201 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 2202 if (fcp->isp_loopstate == LOOP_SCANNING_FABRIC) { 2203 fcp->isp_loopstate = LOOP_PDB_RCVD; 2204 } 2205 if (mbs.param[0] == MBOX_COMMAND_ERROR) { 2206 char tbuf[16]; 2207 char *m; --- 55 unchanged lines hidden (view full) --- 2263{ 2264 fcparam *fcp = isp->isp_param; 2265 sns_screq_t *reqp; 2266 mbreg_t mbs; 2267 2268 reqp = (sns_screq_t *) fcp->isp_scratch; 2269 MEMZERO((void *) reqp, SNS_RFT_REQ_SIZE); 2270 reqp->snscb_rblen = SNS_RFT_RESP_SIZE >> 1; | 2250 isp_mboxcmd(isp, &mbs, MBLOGNONE); 2251 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 2252 if (fcp->isp_loopstate == LOOP_SCANNING_FABRIC) { 2253 fcp->isp_loopstate = LOOP_PDB_RCVD; 2254 } 2255 if (mbs.param[0] == MBOX_COMMAND_ERROR) { 2256 char tbuf[16]; 2257 char *m; --- 55 unchanged lines hidden (view full) --- 2313{ 2314 fcparam *fcp = isp->isp_param; 2315 sns_screq_t *reqp; 2316 mbreg_t mbs; 2317 2318 reqp = (sns_screq_t *) fcp->isp_scratch; 2319 MEMZERO((void *) reqp, SNS_RFT_REQ_SIZE); 2320 reqp->snscb_rblen = SNS_RFT_RESP_SIZE >> 1; |
2271 reqp->snscb_addr[RQRSP_ADDR0015] = DMA_LSW(fcp->isp_scdma + 0x100); 2272 reqp->snscb_addr[RQRSP_ADDR1631] = DMA_MSW(fcp->isp_scdma + 0x100); | 2321 reqp->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma + 0x100); 2322 reqp->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma + 0x100); 2323 reqp->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma + 0x100); 2324 reqp->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma + 0x100); |
2273 reqp->snscb_sblen = 22; 2274 reqp->snscb_data[0] = SNS_RFT; 2275 reqp->snscb_data[4] = fcp->isp_portid & 0xffff; 2276 reqp->snscb_data[5] = (fcp->isp_portid >> 16) & 0xff; 2277 reqp->snscb_data[6] = 0x100; /* SCS - FCP */ 2278#if 0 2279 reqp->snscb_data[6] |= 20; /* ISO/IEC 8802-2 LLC/SNAP */ 2280#endif 2281 ISP_SWIZZLE_SNS_REQ(isp, reqp); 2282 mbs.param[0] = MBOX_SEND_SNS; 2283 mbs.param[1] = SNS_RFT_REQ_SIZE >> 1; | 2325 reqp->snscb_sblen = 22; 2326 reqp->snscb_data[0] = SNS_RFT; 2327 reqp->snscb_data[4] = fcp->isp_portid & 0xffff; 2328 reqp->snscb_data[5] = (fcp->isp_portid >> 16) & 0xff; 2329 reqp->snscb_data[6] = 0x100; /* SCS - FCP */ 2330#if 0 2331 reqp->snscb_data[6] |= 20; /* ISO/IEC 8802-2 LLC/SNAP */ 2332#endif 2333 ISP_SWIZZLE_SNS_REQ(isp, reqp); 2334 mbs.param[0] = MBOX_SEND_SNS; 2335 mbs.param[1] = SNS_RFT_REQ_SIZE >> 1; |
2284 mbs.param[2] = DMA_MSW(fcp->isp_scdma); 2285 mbs.param[3] = DMA_LSW(fcp->isp_scdma); 2286 mbs.param[6] = 0; 2287 mbs.param[7] = 0; | 2336 mbs.param[2] = DMA_WD1(fcp->isp_scdma); 2337 mbs.param[3] = DMA_WD0(fcp->isp_scdma); 2338 /* 2339 * Leave 4 and 5 alone 2340 */ 2341 mbs.param[6] = DMA_WD3(fcp->isp_scdma); 2342 mbs.param[7] = DMA_WD2(fcp->isp_scdma); |
2288 isp_mboxcmd(isp, &mbs, MBLOGALL); 2289 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { 2290 isp_prt(isp, ISP_LOGDEBUG0, "Register FC4 types succeeded"); 2291 } 2292} 2293 2294/* 2295 * Start a command. Locking is assumed done in the caller. --- 302 unchanged lines hidden (view full) --- 2598 * The Qlogic drivers seem be happy not to use a tag, 2599 * but this breaks for some devices (IBM drives). 2600 */ 2601 if (XS_TAG_P(xs)) { 2602 t2reqp->req_flags = XS_TAG_TYPE(xs); 2603 } else { 2604 /* 2605 * If we don't know what tag to use, use HEAD OF QUEUE | 2343 isp_mboxcmd(isp, &mbs, MBLOGALL); 2344 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { 2345 isp_prt(isp, ISP_LOGDEBUG0, "Register FC4 types succeeded"); 2346 } 2347} 2348 2349/* 2350 * Start a command. Locking is assumed done in the caller. --- 302 unchanged lines hidden (view full) --- 2653 * The Qlogic drivers seem be happy not to use a tag, 2654 * but this breaks for some devices (IBM drives). 2655 */ 2656 if (XS_TAG_P(xs)) { 2657 t2reqp->req_flags = XS_TAG_TYPE(xs); 2658 } else { 2659 /* 2660 * If we don't know what tag to use, use HEAD OF QUEUE |
2606 * for Request Sense or Ordered (for safety's sake). | 2661 * for Request Sense or Simple. |
2607 */ 2608 if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */ 2609 t2reqp->req_flags = REQFLAG_HTAG; 2610 else | 2662 */ 2663 if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */ 2664 t2reqp->req_flags = REQFLAG_HTAG; 2665 else |
2611 t2reqp->req_flags = REQFLAG_OTAG; | 2666 t2reqp->req_flags = REQFLAG_STAG; |
2612 } 2613 } else { 2614 sdparam *sdp = (sdparam *)isp->isp_param; 2615 sdp += XS_CHANNEL(xs); 2616 if ((sdp->isp_devparam[target].actv_flags & DPARM_TQING) && 2617 XS_TAG_P(xs)) { 2618 reqp->req_flags = XS_TAG_TYPE(xs); 2619 } --- 240 unchanged lines hidden (view full) --- 2860 */ 2861 2862/* 2863 * Limit our stack depth by sticking with the max likely number 2864 * of completions on a request queue at any one time. 2865 */ 2866#define MAX_REQUESTQ_COMPLETIONS 32 2867 | 2667 } 2668 } else { 2669 sdparam *sdp = (sdparam *)isp->isp_param; 2670 sdp += XS_CHANNEL(xs); 2671 if ((sdp->isp_devparam[target].actv_flags & DPARM_TQING) && 2672 XS_TAG_P(xs)) { 2673 reqp->req_flags = XS_TAG_TYPE(xs); 2674 } --- 240 unchanged lines hidden (view full) --- 2915 */ 2916 2917/* 2918 * Limit our stack depth by sticking with the max likely number 2919 * of completions on a request queue at any one time. 2920 */ 2921#define MAX_REQUESTQ_COMPLETIONS 32 2922 |
2868int 2869isp_intr(void *arg) | 2923void 2924isp_intr(struct ispsoftc *isp, u_int16_t isr, u_int16_t sema, u_int16_t mbox) |
2870{ | 2925{ |
2871 struct ispsoftc *isp = arg; | |
2872 XS_T *complist[MAX_REQUESTQ_COMPLETIONS], *xs; | 2926 XS_T *complist[MAX_REQUESTQ_COMPLETIONS], *xs; |
2873 u_int16_t iptr, optr, isr, sema, junk; | 2927 u_int16_t iptr, optr, junk; |
2874 int i, nlooked = 0, ndone = 0; 2875 | 2928 int i, nlooked = 0, ndone = 0; 2929 |
2876 if (IS_2100(isp)) { 2877 i = 0; 2878 do { 2879 isr = ISP_READ(isp, BIU_ISR); 2880 junk = ISP_READ(isp, BIU_ISR); 2881 } while (isr != junk && ++i < 1000); 2882 if (isr != junk) { 2883 isp_prt(isp, ISP_LOGWARN, 2884 "isr unsteady (%x, %x)", isr, junk); 2885 } 2886 i = 0; 2887 do { 2888 sema = ISP_READ(isp, BIU_SEMA); 2889 junk = ISP_READ(isp, BIU_SEMA); 2890 } while (sema != junk && ++i < 1000); 2891 if (sema != junk) { 2892 isp_prt(isp, ISP_LOGWARN, 2893 "sema unsteady (%x, %x)", sema, junk); 2894 } 2895 } else { 2896 isr = ISP_READ(isp, BIU_ISR); 2897 sema = ISP_READ(isp, BIU_SEMA); 2898 } 2899 isp_prt(isp, ISP_LOGDEBUG3, "isp_intr isr %x sem %x", isr, sema); 2900 isr &= INT_PENDING_MASK(isp); 2901 sema &= BIU_SEMA_LOCK; 2902 isp->isp_intcnt++; 2903 if (isr == 0 && sema == 0) { 2904 isp->isp_intbogus++; 2905 return (0); 2906 } 2907 | 2930 /* 2931 * Is this a mailbox related interrupt? 2932 * The mailbox semaphore will be nonzero if so. 2933 */ |
2908 if (sema) { | 2934 if (sema) { |
2909 u_int16_t mbox; 2910 2911 if (IS_2100(isp)) { 2912 i = 0; 2913 do { 2914 mbox = ISP_READ(isp, OUTMAILBOX0); 2915 junk = ISP_READ(isp, OUTMAILBOX0);; 2916 } while (junk != mbox && ++i < 1000); 2917 if (mbox != junk) { 2918 isp_prt(isp, ISP_LOGWARN, 2919 "mailbox0 unsteady (%x, %x)", mbox, junk); 2920 ISP_WRITE(isp, BIU_SEMA, 0); 2921 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 2922 return (1); 2923 } 2924 } else { 2925 mbox = ISP_READ(isp, OUTMAILBOX0); 2926 } | |
2927 if (mbox & 0x4000) { 2928 int obits, i = 0; 2929 if ((obits = isp->isp_mboxbsy) != 0) { 2930 isp->isp_mboxtmp[i++] = mbox; 2931 for (i = 1; i < MAX_MAILBOX; i++) { 2932 if ((obits & (1 << i)) == 0) { 2933 continue; 2934 } --- 9 unchanged lines hidden (view full) --- 2944 } else { 2945 int fhandle = isp_parse_async(isp, (int) mbox); 2946 isp_prt(isp, ISP_LOGDEBUG2, "Async Mbox 0x%x", mbox); 2947 if (fhandle > 0) { 2948 isp_fastpost_complete(isp, (u_int16_t) fhandle); 2949 } 2950 } 2951 if (IS_FC(isp) || isp->isp_state != ISP_RUNSTATE) { | 2935 if (mbox & 0x4000) { 2936 int obits, i = 0; 2937 if ((obits = isp->isp_mboxbsy) != 0) { 2938 isp->isp_mboxtmp[i++] = mbox; 2939 for (i = 1; i < MAX_MAILBOX; i++) { 2940 if ((obits & (1 << i)) == 0) { 2941 continue; 2942 } --- 9 unchanged lines hidden (view full) --- 2952 } else { 2953 int fhandle = isp_parse_async(isp, (int) mbox); 2954 isp_prt(isp, ISP_LOGDEBUG2, "Async Mbox 0x%x", mbox); 2955 if (fhandle > 0) { 2956 isp_fastpost_complete(isp, (u_int16_t) fhandle); 2957 } 2958 } 2959 if (IS_FC(isp) || isp->isp_state != ISP_RUNSTATE) { |
2952 ISP_WRITE(isp, BIU_SEMA, 0); | |
2953 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); | 2960 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); |
2954 return (1); | 2961 ISP_WRITE(isp, BIU_SEMA, 0); 2962 return; |
2955 } 2956 } 2957 2958 /* 2959 * We can't be getting this now. 2960 */ 2961 if (isp->isp_state != ISP_RUNSTATE) { 2962 isp_prt(isp, ISP_LOGWARN, | 2963 } 2964 } 2965 2966 /* 2967 * We can't be getting this now. 2968 */ 2969 if (isp->isp_state != ISP_RUNSTATE) { 2970 isp_prt(isp, ISP_LOGWARN, |
2963 "interrupt (isr=%x, sema=%x) when not ready", isr, sema); 2964 WRITE_RESPONSE_QUEUE_IN_POINTER(isp, 2965 READ_RESPONSE_QUEUE_OUT_POINTER(isp)); | 2971 "interrupt (ISR=%x SEMA=%x) when not ready", isr, sema); 2972 /* 2973 * Thank you very much! *Burrrp*! 2974 */ 2975 WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, 2976 READ_RESPONSE_QUEUE_IN_POINTER(isp)); 2977 |
2966 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 2967 ISP_WRITE(isp, BIU_SEMA, 0); | 2978 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 2979 ISP_WRITE(isp, BIU_SEMA, 0); |
2968 return (1); | 2980 return; |
2969 } 2970 2971 /* | 2981 } 2982 2983 /* |
2972 * You *must* read the Response Queue Out Pointer 2973 * prior to clearing the RISC interrupt. | 2984 * Get the current Response Queue Out Pointer. 2985 * 2986 * If we're a 2300, we can ask what hardware what it thinks. |
2974 */ | 2987 */ |
2975 optr = isp->isp_residx; | 2988 if (IS_2300(isp)) { 2989 optr = ISP_READ(isp, isp->isp_respoutrp); 2990 if (isp->isp_residx != optr) { 2991 isp_prt(isp, ISP_LOGWARN, "optr %x soft optr %x", 2992 optr, isp->isp_residx); 2993 } 2994 } else { 2995 optr = isp->isp_residx; 2996 } |
2976 | 2997 |
2977 if (IS_2100(isp)) { | 2998 /* 2999 * You *must* read the Response Queue In Pointer 3000 * prior to clearing the RISC interrupt. 3001 */ 3002 if (IS_2100(isp) || IS_2300(isp)) { |
2978 i = 0; 2979 do { | 3003 i = 0; 3004 do { |
2980 iptr = READ_RESPONSE_QUEUE_OUT_POINTER(isp); 2981 junk = READ_RESPONSE_QUEUE_OUT_POINTER(isp); | 3005 iptr = READ_RESPONSE_QUEUE_IN_POINTER(isp); 3006 junk = READ_RESPONSE_QUEUE_IN_POINTER(isp); |
2982 } while (junk != iptr && ++i < 1000); 2983 2984 if (iptr != junk) { 2985 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 2986 isp_prt(isp, ISP_LOGWARN, | 3007 } while (junk != iptr && ++i < 1000); 3008 3009 if (iptr != junk) { 3010 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 3011 isp_prt(isp, ISP_LOGWARN, |
2987 "mailbox5 unsteady (%x, %x)", iptr, junk); 2988 return (1); | 3012 "Response Queue Out Pointer Unstable (%x, %x)", 3013 iptr, junk); 3014 return; |
2989 } 2990 } else { | 3015 } 3016 } else { |
2991 iptr = READ_RESPONSE_QUEUE_OUT_POINTER(isp); | 3017 iptr = READ_RESPONSE_QUEUE_IN_POINTER(isp); |
2992 } 2993 | 3018 } 3019 |
2994 if (sema) { 2995 ISP_WRITE(isp, BIU_SEMA, 0); 2996 } 2997 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); | |
2998 2999 if (optr == iptr && sema == 0) { 3000 /* 3001 * There are a lot of these- reasons unknown- mostly on 3002 * faster Alpha machines. 3003 * 3004 * I tried delaying after writing HCCR_CMD_CLEAR_RISC_INT to 3005 * make sure the old interrupt went away (to avoid 'ringing' 3006 * effects), but that didn't stop this from occurring. 3007 */ | 3020 3021 if (optr == iptr && sema == 0) { 3022 /* 3023 * There are a lot of these- reasons unknown- mostly on 3024 * faster Alpha machines. 3025 * 3026 * I tried delaying after writing HCCR_CMD_CLEAR_RISC_INT to 3027 * make sure the old interrupt went away (to avoid 'ringing' 3028 * effects), but that didn't stop this from occurring. 3029 */ |
3008 junk = ISP_READ(isp, BIU_ISR); 3009 isp_prt(isp, ISP_LOGDEBUG2, 3010 "bogus intr- isr %x (%x) iptr %x optr %x", 3011 isr, junk, iptr, optr); 3012 isp->isp_intbogus++; | 3030 if (IS_2300(isp)) { 3031 USEC_DELAY(100); 3032 iptr = READ_RESPONSE_QUEUE_IN_POINTER(isp); 3033 junk = ISP_READ(isp, BIU_R2HSTSLO); 3034 } else { 3035 junk = ISP_READ(isp, BIU_ISR); 3036 } 3037 if (optr == iptr) { 3038 isp_prt(isp, ISP_LOGDEBUG0, 3039 "bogus intr- isr %x (%x) iptr %x optr %x", 3040 isr, junk, iptr, optr); 3041 isp->isp_intbogus++; 3042 } |
3013 } | 3043 } |
3044 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 3045 ISP_WRITE(isp, BIU_SEMA, 0); |
|
3014 3015 while (optr != iptr) { 3016 ispstatusreq_t *sp; 3017 u_int16_t oop; 3018 int buddaboom = 0; 3019 3020 sp = (ispstatusreq_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr); 3021 oop = optr; --- 30 unchanged lines hidden (view full) --- 3052 } 3053 3054 if (sp->req_header.rqs_flags & 0xf) { 3055#define _RQS_OFLAGS \ 3056 ~(RQSFLAG_CONTINUATION|RQSFLAG_FULL|RQSFLAG_BADHEADER|RQSFLAG_BADPACKET) 3057 if (sp->req_header.rqs_flags & RQSFLAG_CONTINUATION) { 3058 isp_prt(isp, ISP_LOGWARN, 3059 "continuation segment"); | 3046 3047 while (optr != iptr) { 3048 ispstatusreq_t *sp; 3049 u_int16_t oop; 3050 int buddaboom = 0; 3051 3052 sp = (ispstatusreq_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr); 3053 oop = optr; --- 30 unchanged lines hidden (view full) --- 3084 } 3085 3086 if (sp->req_header.rqs_flags & 0xf) { 3087#define _RQS_OFLAGS \ 3088 ~(RQSFLAG_CONTINUATION|RQSFLAG_FULL|RQSFLAG_BADHEADER|RQSFLAG_BADPACKET) 3089 if (sp->req_header.rqs_flags & RQSFLAG_CONTINUATION) { 3090 isp_prt(isp, ISP_LOGWARN, 3091 "continuation segment"); |
3060 WRITE_RESPONSE_QUEUE_IN_POINTER(isp, optr); | 3092 WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, optr); |
3061 continue; 3062 } 3063 if (sp->req_header.rqs_flags & RQSFLAG_FULL) { 3064 isp_prt(isp, ISP_LOGDEBUG1, 3065 "internal queues full"); 3066 /* 3067 * We'll synthesize a QUEUE FULL message below. 3068 */ --- 15 unchanged lines hidden (view full) --- 3084#undef _RQS_OFLAGS 3085 } 3086 if (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1) { 3087 MEMZERO(sp, sizeof (isphdr_t)); 3088 isp_prt(isp, ISP_LOGERR, 3089 "bad request handle %d (type 0x%x, flags 0x%x)", 3090 sp->req_handle, sp->req_header.rqs_entry_type, 3091 sp->req_header.rqs_flags); | 3093 continue; 3094 } 3095 if (sp->req_header.rqs_flags & RQSFLAG_FULL) { 3096 isp_prt(isp, ISP_LOGDEBUG1, 3097 "internal queues full"); 3098 /* 3099 * We'll synthesize a QUEUE FULL message below. 3100 */ --- 15 unchanged lines hidden (view full) --- 3116#undef _RQS_OFLAGS 3117 } 3118 if (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1) { 3119 MEMZERO(sp, sizeof (isphdr_t)); 3120 isp_prt(isp, ISP_LOGERR, 3121 "bad request handle %d (type 0x%x, flags 0x%x)", 3122 sp->req_handle, sp->req_header.rqs_entry_type, 3123 sp->req_header.rqs_flags); |
3092 WRITE_RESPONSE_QUEUE_IN_POINTER(isp, optr); | 3124 WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, optr); |
3093 continue; 3094 } 3095 xs = isp_find_xs(isp, sp->req_handle); 3096 if (xs == NULL) { 3097 MEMZERO(sp, sizeof (isphdr_t)); 3098 isp_prt(isp, ISP_LOGERR, 3099 "cannot find handle 0x%x in xflist", 3100 sp->req_handle); | 3125 continue; 3126 } 3127 xs = isp_find_xs(isp, sp->req_handle); 3128 if (xs == NULL) { 3129 MEMZERO(sp, sizeof (isphdr_t)); 3130 isp_prt(isp, ISP_LOGERR, 3131 "cannot find handle 0x%x in xflist", 3132 sp->req_handle); |
3101 WRITE_RESPONSE_QUEUE_IN_POINTER(isp, optr); | 3133 WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, optr); |
3102 continue; 3103 } 3104 isp_destroy_handle(isp, sp->req_handle); 3105 if (sp->req_status_flags & RQSTF_BUS_RESET) { 3106 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs)); 3107 } 3108 if (buddaboom) { 3109 XS_SETERR(xs, HBA_BOTCH); --- 118 unchanged lines hidden (view full) --- 3228 } 3229 3230 /* 3231 * If we looked at any commands, then it's valid to find out 3232 * what the outpointer is. It also is a trigger to update the 3233 * ISP's notion of what we've seen so far. 3234 */ 3235 if (nlooked) { | 3134 continue; 3135 } 3136 isp_destroy_handle(isp, sp->req_handle); 3137 if (sp->req_status_flags & RQSTF_BUS_RESET) { 3138 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs)); 3139 } 3140 if (buddaboom) { 3141 XS_SETERR(xs, HBA_BOTCH); --- 118 unchanged lines hidden (view full) --- 3260 } 3261 3262 /* 3263 * If we looked at any commands, then it's valid to find out 3264 * what the outpointer is. It also is a trigger to update the 3265 * ISP's notion of what we've seen so far. 3266 */ 3267 if (nlooked) { |
3236 WRITE_RESPONSE_QUEUE_IN_POINTER(isp, optr); | 3268 WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, optr); 3269 /* 3270 * While we're at it, reqad the requst queue out pointer. 3271 */ |
3237 isp->isp_reqodx = READ_REQUEST_QUEUE_OUT_POINTER(isp); 3238 } 3239 3240 isp->isp_residx = optr; 3241 for (i = 0; i < ndone; i++) { 3242 xs = complist[i]; 3243 if (xs) { 3244 isp_done(xs); 3245 } 3246 } | 3272 isp->isp_reqodx = READ_REQUEST_QUEUE_OUT_POINTER(isp); 3273 } 3274 3275 isp->isp_residx = optr; 3276 for (i = 0; i < ndone; i++) { 3277 xs = complist[i]; 3278 if (xs) { 3279 isp_done(xs); 3280 } 3281 } |
3247 return (1); | |
3248} 3249 3250/* 3251 * Support routines. 3252 */ 3253 3254static int 3255isp_parse_async(struct ispsoftc *isp, int mbox) --- 2204 unchanged lines hidden --- | 3282} 3283 3284/* 3285 * Support routines. 3286 */ 3287 3288static int 3289isp_parse_async(struct ispsoftc *isp, int mbox) --- 2204 unchanged lines hidden --- |