isp.c (43789) | isp.c (44819) |
---|---|
1/* $Id: isp.c,v 1.12 1999/01/30 07:28:59 mjacob Exp $ */ 2/* release_02_05_99 */ | 1/* $Id: isp.c,v 1.13 1999/02/09 01:07:06 mjacob Exp $ */ 2/* release_03_16_99 */ |
3/* 4 * Machine and OS Independent (well, as best as possible) 5 * code for the Qlogic ISP SCSI adapters. 6 * 7 *--------------------------------------- 8 * Copyright (c) 1997, 1998 by Matthew Jacob 9 * NASA/Ames Research Center 10 * All rights reserved. --- 35 unchanged lines hidden (view full) --- 46 */ 47 48#ifdef __NetBSD__ 49#include <dev/ic/isp_netbsd.h> 50#endif 51#ifdef __FreeBSD__ 52#include <dev/isp/isp_freebsd.h> 53#endif | 3/* 4 * Machine and OS Independent (well, as best as possible) 5 * code for the Qlogic ISP SCSI adapters. 6 * 7 *--------------------------------------- 8 * Copyright (c) 1997, 1998 by Matthew Jacob 9 * NASA/Ames Research Center 10 * All rights reserved. --- 35 unchanged lines hidden (view full) --- 46 */ 47 48#ifdef __NetBSD__ 49#include <dev/ic/isp_netbsd.h> 50#endif 51#ifdef __FreeBSD__ 52#include <dev/isp/isp_freebsd.h> 53#endif |
54#ifdef __OpenBSD__ 55#include <dev/ic/isp_openbsd.h> 56#endif |
|
54#ifdef __linux__ 55#include "isp_linux.h" 56#endif 57 58/* 59 * General defines 60 */ 61 --- 7 unchanged lines hidden (view full) --- 69 0x03, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 70 0x51, 0x4C, 0x4F, 0x47, 0x49, 0x43, 0x20, 0x20, 71#ifdef __NetBSD__ 72 0x4E, 0x45, 0x54, 0x42, 0x53, 0x44, 0x20, 0x20, 73#else 74# ifdef __FreeBSD__ 75 0x46, 0x52, 0x45, 0x45, 0x42, 0x52, 0x44, 0x20, 76# else | 57#ifdef __linux__ 58#include "isp_linux.h" 59#endif 60 61/* 62 * General defines 63 */ 64 --- 7 unchanged lines hidden (view full) --- 72 0x03, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 73 0x51, 0x4C, 0x4F, 0x47, 0x49, 0x43, 0x20, 0x20, 74#ifdef __NetBSD__ 75 0x4E, 0x45, 0x54, 0x42, 0x53, 0x44, 0x20, 0x20, 76#else 77# ifdef __FreeBSD__ 78 0x46, 0x52, 0x45, 0x45, 0x42, 0x52, 0x44, 0x20, 79# else |
77# ifdef linux 78 0x4C, 0x49, 0x4E, 0x55, 0x58, 0x20, 0x20, 0x20, | 80# ifdef __OpenBSD__ 81 0x4F, 0x50, 0x45, 0x4E, 0x42, 0x52, 0x44, 0x20, |
79# else | 82# else |
83# ifdef linux 84 0x4C, 0x49, 0x4E, 0x55, 0x58, 0x20, 0x20, 0x20, 85# else 86# endif |
|
80# endif 81# endif 82#endif 83 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x20, 0x20, 84 0x20, 0x20, 0x20, 0x31 85}; 86#endif 87 --- 9 unchanged lines hidden (view full) --- 97static void isp_notify_ack __P((struct ispsoftc *, void *)); 98static void isp_handle_atio __P((struct ispsoftc *, void *)); 99static void isp_handle_atio2 __P((struct ispsoftc *, void *)); 100static void isp_handle_ctio __P((struct ispsoftc *, void *)); 101static void isp_handle_ctio2 __P((struct ispsoftc *, void *)); 102#endif 103static void isp_parse_status 104__P((struct ispsoftc *, ispstatusreq_t *, ISP_SCSI_XFER_T *)); | 87# endif 88# endif 89#endif 90 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x20, 0x20, 91 0x20, 0x20, 0x20, 0x31 92}; 93#endif 94 --- 9 unchanged lines hidden (view full) --- 104static void isp_notify_ack __P((struct ispsoftc *, void *)); 105static void isp_handle_atio __P((struct ispsoftc *, void *)); 106static void isp_handle_atio2 __P((struct ispsoftc *, void *)); 107static void isp_handle_ctio __P((struct ispsoftc *, void *)); 108static void isp_handle_ctio2 __P((struct ispsoftc *, void *)); 109#endif 110static void isp_parse_status 111__P((struct ispsoftc *, ispstatusreq_t *, ISP_SCSI_XFER_T *)); |
112static void isp_fastpost_complete __P((struct ispsoftc *, int)); |
|
105static void isp_fibre_init __P((struct ispsoftc *)); | 113static void isp_fibre_init __P((struct ispsoftc *)); |
114static void isp_mark_getpdb_all __P((struct ispsoftc *)); 115static int isp_getpdb __P((struct ispsoftc *, int, isp_pdb_t *)); 116static int isp_fclink_test __P((struct ispsoftc *)); |
|
106static void isp_fw_state __P((struct ispsoftc *)); 107static void isp_dumpregs __P((struct ispsoftc *, const char *)); 108static void isp_dumpxflist __P((struct ispsoftc *)); | 117static void isp_fw_state __P((struct ispsoftc *)); 118static void isp_dumpregs __P((struct ispsoftc *, const char *)); 119static void isp_dumpxflist __P((struct ispsoftc *)); |
109static void isp_prtstst __P((ispstatusreq_t *)); 110static char *isp2100_fw_statename __P((int)); | |
111static void isp_mboxcmd __P((struct ispsoftc *, mbreg_t *)); 112 113static void isp_update __P((struct ispsoftc *)); 114static void isp_setdfltparm __P((struct ispsoftc *)); 115static int isp_read_nvram __P((struct ispsoftc *)); 116static void isp_rdnvram_word __P((struct ispsoftc *, int, u_int16_t *)); 117 118/* 119 * Reset Hardware. 120 * 121 * Hit the chip over the head, download new f/w and set it running. 122 * 123 * Locking done elsewhere. 124 */ 125void 126isp_reset(isp) 127 struct ispsoftc *isp; 128{ | 120static void isp_mboxcmd __P((struct ispsoftc *, mbreg_t *)); 121 122static void isp_update __P((struct ispsoftc *)); 123static void isp_setdfltparm __P((struct ispsoftc *)); 124static int isp_read_nvram __P((struct ispsoftc *)); 125static void isp_rdnvram_word __P((struct ispsoftc *, int, u_int16_t *)); 126 127/* 128 * Reset Hardware. 129 * 130 * Hit the chip over the head, download new f/w and set it running. 131 * 132 * Locking done elsewhere. 133 */ 134void 135isp_reset(isp) 136 struct ispsoftc *isp; 137{ |
129 static char once = 1; | |
130 mbreg_t mbs; 131 int loops, i, dodnld = 1; 132 char *revname; 133 134 isp->isp_state = ISP_NILSTATE; 135 136 /* 137 * Basic types (SCSI, FibreChannel and PCI or SBus) --- 10 unchanged lines hidden (view full) --- 148 /* 149 * Get the current running firmware revision out of the 150 * chip before we hit it over the head (if this is our 151 * first time through). Note that we store this as the 152 * 'ROM' firmware revision- which it may not be. In any 153 * case, we don't really use this yet, but we may in 154 * the future. 155 */ | 138 mbreg_t mbs; 139 int loops, i, dodnld = 1; 140 char *revname; 141 142 isp->isp_state = ISP_NILSTATE; 143 144 /* 145 * Basic types (SCSI, FibreChannel and PCI or SBus) --- 10 unchanged lines hidden (view full) --- 156 /* 157 * Get the current running firmware revision out of the 158 * chip before we hit it over the head (if this is our 159 * first time through). Note that we store this as the 160 * 'ROM' firmware revision- which it may not be. In any 161 * case, we don't really use this yet, but we may in 162 * the future. 163 */ |
156 if (once == 1) { | 164 if (isp->isp_used == 0) { |
157 /* 158 * Just in case it was paused... 159 */ 160 ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE); | 165 /* 166 * Just in case it was paused... 167 */ 168 ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE); |
161 once = 0; | |
162 mbs.param[0] = MBOX_ABOUT_FIRMWARE; 163 isp_mboxcmd(isp, &mbs); 164 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 165 /* 166 * If this fails, it probably means we're running 167 * an old prom, if anything at all... 168 */ 169 isp->isp_romfw_rev = 0; 170 } else { 171 isp->isp_romfw_rev = 172 (((u_int16_t) mbs.param[1]) << 10) + mbs.param[2]; 173 } | 169 mbs.param[0] = MBOX_ABOUT_FIRMWARE; 170 isp_mboxcmd(isp, &mbs); 171 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 172 /* 173 * If this fails, it probably means we're running 174 * an old prom, if anything at all... 175 */ 176 isp->isp_romfw_rev = 0; 177 } else { 178 isp->isp_romfw_rev = 179 (((u_int16_t) mbs.param[1]) << 10) + mbs.param[2]; 180 } |
181 isp->isp_used = 1; |
|
174 } 175 176 /* 177 * Put it into PAUSE mode. 178 */ 179 ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); 180 | 182 } 183 184 /* 185 * Put it into PAUSE mode. 186 */ 187 ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); 188 |
181 if (isp->isp_type & ISP_HA_FC) { | 189 if (IS_FC(isp)) { |
182 revname = "2100"; | 190 revname = "2100"; |
191 } else if (IS_1080(isp)) { 192 sdparam *sdp = isp->isp_param; 193 revname = "1080"; 194 sdp->isp_clock = 0; /* don't set clock */ 195 sdp->isp_diffmode = 1; 196 sdp->isp_ultramode = 1; |
|
183 } else { 184 sdparam *sdp = isp->isp_param; 185 i = ISP_READ(isp, BIU_CONF0) & BIU_CONF0_HW_MASK; 186 switch (i) { 187 default: 188 PRINTF("%s: unknown chip rev. 0x%x- assuming a 1020\n", 189 isp->isp_name, i); 190 /* FALLTHROUGH */ --- 27 unchanged lines hidden (view full) --- 218 isp->isp_type = ISP_HA_SCSI_1040B; 219 sdp->isp_clock = 60; 220 break; 221 } 222 /* 223 * Now, while we're at it, gather info about ultra 224 * and/or differential mode. 225 */ | 197 } else { 198 sdparam *sdp = isp->isp_param; 199 i = ISP_READ(isp, BIU_CONF0) & BIU_CONF0_HW_MASK; 200 switch (i) { 201 default: 202 PRINTF("%s: unknown chip rev. 0x%x- assuming a 1020\n", 203 isp->isp_name, i); 204 /* FALLTHROUGH */ --- 27 unchanged lines hidden (view full) --- 232 isp->isp_type = ISP_HA_SCSI_1040B; 233 sdp->isp_clock = 60; 234 break; 235 } 236 /* 237 * Now, while we're at it, gather info about ultra 238 * and/or differential mode. 239 */ |
226 if (isp->isp_bustype != ISP_BT_SBUS) { 227 ISP_SETBITS(isp, BIU_CONF1, BIU_PCI_CONF1_SXP); 228 } | |
229 if (ISP_READ(isp, SXP_PINS_DIFF) & SXP_PINS_DIFF_MODE) { 230 PRINTF("%s: Differential Mode\n", isp->isp_name); 231 sdp->isp_diffmode = 1; 232 } else { 233 sdp->isp_diffmode = 0; 234 } 235 i = ISP_READ(isp, RISC_PSR); 236 if (isp->isp_bustype == ISP_BT_SBUS) { 237 i &= RISC_PSR_SBUS_ULTRA; 238 } else { 239 i &= RISC_PSR_PCI_ULTRA; 240 } | 240 if (ISP_READ(isp, SXP_PINS_DIFF) & SXP_PINS_DIFF_MODE) { 241 PRINTF("%s: Differential Mode\n", isp->isp_name); 242 sdp->isp_diffmode = 1; 243 } else { 244 sdp->isp_diffmode = 0; 245 } 246 i = ISP_READ(isp, RISC_PSR); 247 if (isp->isp_bustype == ISP_BT_SBUS) { 248 i &= RISC_PSR_SBUS_ULTRA; 249 } else { 250 i &= RISC_PSR_PCI_ULTRA; 251 } |
241 if (isp->isp_bustype != ISP_BT_SBUS) { 242 ISP_CLRBITS(isp, BIU_CONF1, BIU_PCI_CONF1_SXP); 243 } | |
244 if (i != 0) { 245 PRINTF("%s: Ultra Mode Capable\n", isp->isp_name); 246 sdp->isp_ultramode = 1; | 252 if (i != 0) { 253 PRINTF("%s: Ultra Mode Capable\n", isp->isp_name); 254 sdp->isp_ultramode = 1; |
255 /* 256 * If we're in Ultra Mode, we have to be 60Mhz clock- 257 * even for the SBus version. 258 */ |
|
247 sdp->isp_clock = 60; 248 } else { 249 sdp->isp_ultramode = 0; | 259 sdp->isp_clock = 60; 260 } else { 261 sdp->isp_ultramode = 0; |
250 sdp->isp_clock = 40; | 262 /* 263 * Clock is known. Gronk. 264 */ |
251 } 252 253 /* 254 * Machine dependent clock (if set) overrides 255 * our generic determinations. 256 */ 257 if (isp->isp_mdvec->dv_clock) { 258 if (isp->isp_mdvec->dv_clock < sdp->isp_clock) { --- 10 unchanged lines hidden (view full) --- 269 270again: 271 272 /* 273 * Hit the chip over the head with hammer, 274 * and give the ISP a chance to recover. 275 */ 276 | 265 } 266 267 /* 268 * Machine dependent clock (if set) overrides 269 * our generic determinations. 270 */ 271 if (isp->isp_mdvec->dv_clock) { 272 if (isp->isp_mdvec->dv_clock < sdp->isp_clock) { --- 10 unchanged lines hidden (view full) --- 283 284again: 285 286 /* 287 * Hit the chip over the head with hammer, 288 * and give the ISP a chance to recover. 289 */ 290 |
277 if (isp->isp_type & ISP_HA_SCSI) { | 291 if (IS_SCSI(isp)) { |
278 ISP_WRITE(isp, BIU_ICR, BIU_ICR_SOFT_RESET); 279 /* 280 * A slight delay... 281 */ 282 SYS_DELAY(100); 283 | 292 ISP_WRITE(isp, BIU_ICR, BIU_ICR_SOFT_RESET); 293 /* 294 * A slight delay... 295 */ 296 SYS_DELAY(100); 297 |
298#if 0 299 PRINTF("%s: mbox0-5: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", 300 isp->isp_name, ISP_READ(isp, OUTMAILBOX0), 301 ISP_READ(isp, OUTMAILBOX1), ISP_READ(isp, OUTMAILBOX2), 302 ISP_READ(isp, OUTMAILBOX3), ISP_READ(isp, OUTMAILBOX4), 303 ISP_READ(isp, OUTMAILBOX5)); 304#endif 305 |
|
284 /* 285 * Clear data && control DMA engines. 286 */ 287 ISP_WRITE(isp, CDMA_CONTROL, 288 DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT); 289 ISP_WRITE(isp, DDMA_CONTROL, 290 DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT); | 306 /* 307 * Clear data && control DMA engines. 308 */ 309 ISP_WRITE(isp, CDMA_CONTROL, 310 DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT); 311 ISP_WRITE(isp, DDMA_CONTROL, 312 DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT); |
313 314 |
|
291 } else { 292 ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET); 293 /* 294 * A slight delay... 295 */ 296 SYS_DELAY(100); 297 298 /* --- 26 unchanged lines hidden (view full) --- 325 } 326 } 327 328 /* 329 * After we've fired this chip up, zero out the conf1 register 330 * for SCSI adapters and other settings for the 2100. 331 */ 332 | 315 } else { 316 ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET); 317 /* 318 * A slight delay... 319 */ 320 SYS_DELAY(100); 321 322 /* --- 26 unchanged lines hidden (view full) --- 349 } 350 } 351 352 /* 353 * After we've fired this chip up, zero out the conf1 register 354 * for SCSI adapters and other settings for the 2100. 355 */ 356 |
333 if (isp->isp_type & ISP_HA_SCSI) { | 357 if (IS_SCSI(isp)) { |
334 ISP_WRITE(isp, BIU_CONF1, 0); 335 } else { 336 ISP_WRITE(isp, BIU2100_CSR, 0); 337 } 338 339 /* 340 * Reset RISC Processor 341 */ 342 ISP_WRITE(isp, HCCR, HCCR_CMD_RESET); 343 SYS_DELAY(100); 344 345 /* 346 * Establish some initial burst rate stuff. 347 * (only for the 1XX0 boards). This really should 348 * be done later after fetching from NVRAM. 349 */ | 358 ISP_WRITE(isp, BIU_CONF1, 0); 359 } else { 360 ISP_WRITE(isp, BIU2100_CSR, 0); 361 } 362 363 /* 364 * Reset RISC Processor 365 */ 366 ISP_WRITE(isp, HCCR, HCCR_CMD_RESET); 367 SYS_DELAY(100); 368 369 /* 370 * Establish some initial burst rate stuff. 371 * (only for the 1XX0 boards). This really should 372 * be done later after fetching from NVRAM. 373 */ |
350 if (isp->isp_type & ISP_HA_SCSI) { | 374 if (IS_SCSI(isp)) { |
351 u_int16_t tmp = isp->isp_mdvec->dv_conf1; 352 /* 353 * Busted FIFO. Turn off all but burst enables. 354 */ 355 if (isp->isp_type == ISP_HA_SCSI_1040A) { 356 tmp &= BIU_BURST_ENABLE; 357 } 358 ISP_SETBITS(isp, BIU_CONF1, tmp); --- 196 unchanged lines hidden (view full) --- 555 int tgt; 556 557 /* 558 * Must do first. 559 */ 560 isp_setdfltparm(isp); 561 562 /* | 375 u_int16_t tmp = isp->isp_mdvec->dv_conf1; 376 /* 377 * Busted FIFO. Turn off all but burst enables. 378 */ 379 if (isp->isp_type == ISP_HA_SCSI_1040A) { 380 tmp &= BIU_BURST_ENABLE; 381 } 382 ISP_SETBITS(isp, BIU_CONF1, tmp); --- 196 unchanged lines hidden (view full) --- 579 int tgt; 580 581 /* 582 * Must do first. 583 */ 584 isp_setdfltparm(isp); 585 586 /* |
587 * Set up DMA for the request and result mailboxes. 588 */ 589 if (ISP_MBOXDMASETUP(isp) != 0) { 590 PRINTF("%s: can't setup dma mailboxes\n", isp->isp_name); 591 return; 592 } 593 594 /* |
|
563 * If we're fibre, we have a completely different 564 * initialization method. 565 */ | 595 * If we're fibre, we have a completely different 596 * initialization method. 597 */ |
566 567 if (isp->isp_type & ISP_HA_FC) { | 598 if (IS_FC(isp)) { |
568 isp_fibre_init(isp); 569 return; 570 } 571 sdp = isp->isp_param; 572 573 /* 574 * If we have fast memory timing enabled, turn it on. 575 */ --- 131 unchanged lines hidden (view full) --- 707 } 708 } 709 /* 710 * And mark this as an unannounced device 711 */ 712 sdp->isp_devparam[tgt].dev_announced = 0; 713 } 714 | 599 isp_fibre_init(isp); 600 return; 601 } 602 sdp = isp->isp_param; 603 604 /* 605 * If we have fast memory timing enabled, turn it on. 606 */ --- 131 unchanged lines hidden (view full) --- 738 } 739 } 740 /* 741 * And mark this as an unannounced device 742 */ 743 sdp->isp_devparam[tgt].dev_announced = 0; 744 } 745 |
715 /* 716 * Set up DMA for the request and result mailboxes. 717 */ 718 if (ISP_MBOXDMASETUP(isp) != 0) { 719 PRINTF("%s: can't setup dma mailboxes\n", isp->isp_name); 720 return; 721 } 722 | |
723 mbs.param[0] = MBOX_INIT_RES_QUEUE; 724 mbs.param[1] = RESULT_QUEUE_LEN; 725 mbs.param[2] = (u_int16_t) (isp->isp_result_dma >> 16); 726 mbs.param[3] = (u_int16_t) (isp->isp_result_dma & 0xffff); 727 mbs.param[4] = 0; 728 mbs.param[5] = 0; 729 isp_mboxcmd(isp, &mbs); 730 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { --- 61 unchanged lines hidden (view full) --- 792static void 793isp_fibre_init(isp) 794 struct ispsoftc *isp; 795{ 796 fcparam *fcp; 797 isp_icb_t *icbp; 798 mbreg_t mbs; 799 int count, loopid; | 746 mbs.param[0] = MBOX_INIT_RES_QUEUE; 747 mbs.param[1] = RESULT_QUEUE_LEN; 748 mbs.param[2] = (u_int16_t) (isp->isp_result_dma >> 16); 749 mbs.param[3] = (u_int16_t) (isp->isp_result_dma & 0xffff); 750 mbs.param[4] = 0; 751 mbs.param[5] = 0; 752 isp_mboxcmd(isp, &mbs); 753 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { --- 61 unchanged lines hidden (view full) --- 815static void 816isp_fibre_init(isp) 817 struct ispsoftc *isp; 818{ 819 fcparam *fcp; 820 isp_icb_t *icbp; 821 mbreg_t mbs; 822 int count, loopid; |
800 u_int8_t lwfs; | |
801 802 fcp = isp->isp_param; 803 | 823 824 fcp = isp->isp_param; 825 |
804 if (ISP_MBOXDMASETUP(isp) != 0) { 805 PRINTF("%s: can't setup DMA for mailboxes\n", isp->isp_name); 806 return; 807 } | |
808 /* 809 * For systems that don't have BIOS methods for which 810 * we can easily change the NVRAM based loopid, we'll 811 * override that here. Note that when we initialize 812 * the firmware we may get back a different loopid than 813 * we asked for anyway. XXX This is probably not the 814 * best way to figure this out XXX 815 */ --- 26 unchanged lines hidden (view full) --- 842 fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE; 843 fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS; 844#ifndef ISP_NO_FASTPOST_FC 845 fcp->isp_fwoptions |= ICBOPT_FAST_POST; 846#endif 847#ifdef CHECKME 848 fcp->isp_fwoptions |= ICBOPT_USE_PORTNAME; 849#endif | 826 /* 827 * For systems that don't have BIOS methods for which 828 * we can easily change the NVRAM based loopid, we'll 829 * override that here. Note that when we initialize 830 * the firmware we may get back a different loopid than 831 * we asked for anyway. XXX This is probably not the 832 * best way to figure this out XXX 833 */ --- 26 unchanged lines hidden (view full) --- 860 fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE; 861 fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS; 862#ifndef ISP_NO_FASTPOST_FC 863 fcp->isp_fwoptions |= ICBOPT_FAST_POST; 864#endif 865#ifdef CHECKME 866 fcp->isp_fwoptions |= ICBOPT_USE_PORTNAME; 867#endif |
850#ifdef THIS_WORKED 851 /* 852 * This has unhappiness in target mode 853 */ | 868#ifdef ISP2100_FABRIC |
854 fcp->isp_fwoptions |= ICBOPT_FULL_LOGIN; 855#endif 856 857 icbp->icb_fwoptions = fcp->isp_fwoptions; 858 icbp->icb_maxfrmlen = fcp->isp_maxfrmlen; 859 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN || 860 icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) { 861 PRINTF("%s: bad frame length (%d) from NVRAM- using %d\n", --- 15 unchanged lines hidden (view full) --- 877 icbp->icb_rqstaddr[RQRSP_ADDR0015] = 878 (u_int16_t) (isp->isp_rquest_dma & 0xffff); 879 icbp->icb_rqstaddr[RQRSP_ADDR1631] = 880 (u_int16_t) (isp->isp_rquest_dma >> 16); 881 icbp->icb_respaddr[RQRSP_ADDR0015] = 882 (u_int16_t) (isp->isp_result_dma & 0xffff); 883 icbp->icb_respaddr[RQRSP_ADDR1631] = 884 (u_int16_t) (isp->isp_result_dma >> 16); | 869 fcp->isp_fwoptions |= ICBOPT_FULL_LOGIN; 870#endif 871 872 icbp->icb_fwoptions = fcp->isp_fwoptions; 873 icbp->icb_maxfrmlen = fcp->isp_maxfrmlen; 874 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN || 875 icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) { 876 PRINTF("%s: bad frame length (%d) from NVRAM- using %d\n", --- 15 unchanged lines hidden (view full) --- 892 icbp->icb_rqstaddr[RQRSP_ADDR0015] = 893 (u_int16_t) (isp->isp_rquest_dma & 0xffff); 894 icbp->icb_rqstaddr[RQRSP_ADDR1631] = 895 (u_int16_t) (isp->isp_rquest_dma >> 16); 896 icbp->icb_respaddr[RQRSP_ADDR0015] = 897 (u_int16_t) (isp->isp_result_dma & 0xffff); 898 icbp->icb_respaddr[RQRSP_ADDR1631] = 899 (u_int16_t) (isp->isp_result_dma >> 16); |
900 MemoryBarrier(); |
|
885 886 for (count = 0; count < 10; count++) { 887 mbs.param[0] = MBOX_INIT_FIRMWARE; 888 mbs.param[1] = 0; 889 mbs.param[2] = (u_int16_t) (fcp->isp_scdma >> 16); 890 mbs.param[3] = (u_int16_t) (fcp->isp_scdma & 0xffff); 891 mbs.param[4] = 0; 892 mbs.param[5] = 0; 893 mbs.param[6] = 0; 894 mbs.param[7] = 0; 895 896 isp_mboxcmd(isp, &mbs); 897 898 switch (mbs.param[0]) { 899 case MBOX_COMMAND_COMPLETE: 900 count = 10; 901 break; | 901 902 for (count = 0; count < 10; count++) { 903 mbs.param[0] = MBOX_INIT_FIRMWARE; 904 mbs.param[1] = 0; 905 mbs.param[2] = (u_int16_t) (fcp->isp_scdma >> 16); 906 mbs.param[3] = (u_int16_t) (fcp->isp_scdma & 0xffff); 907 mbs.param[4] = 0; 908 mbs.param[5] = 0; 909 mbs.param[6] = 0; 910 mbs.param[7] = 0; 911 912 isp_mboxcmd(isp, &mbs); 913 914 switch (mbs.param[0]) { 915 case MBOX_COMMAND_COMPLETE: 916 count = 10; 917 break; |
918 case ASYNC_PDB_CHANGED: 919 isp_mark_getpdb_all(isp); 920 /* FALL THROUGH */ |
|
902 case ASYNC_LIP_OCCURRED: 903 case ASYNC_LOOP_UP: 904 case ASYNC_LOOP_DOWN: 905 case ASYNC_LOOP_RESET: | 921 case ASYNC_LIP_OCCURRED: 922 case ASYNC_LOOP_UP: 923 case ASYNC_LOOP_DOWN: 924 case ASYNC_LOOP_RESET: |
906 case ASYNC_PDB_CHANGED: | |
907 case ASYNC_CHANGE_NOTIFY: 908 if (count > 9) { 909 PRINTF("%s: too many retries to get going- " 910 "giving up\n", isp->isp_name); 911 return; 912 } 913 break; 914 default: 915 isp_dumpregs(isp, "INIT FIRMWARE failed"); 916 return; 917 } 918 } 919 isp->isp_reqidx = isp->isp_reqodx = 0; 920 isp->isp_residx = 0; | 925 case ASYNC_CHANGE_NOTIFY: 926 if (count > 9) { 927 PRINTF("%s: too many retries to get going- " 928 "giving up\n", isp->isp_name); 929 return; 930 } 931 break; 932 default: 933 isp_dumpregs(isp, "INIT FIRMWARE failed"); 934 return; 935 } 936 } 937 isp->isp_reqidx = isp->isp_reqodx = 0; 938 isp->isp_residx = 0; |
939 isp->isp_sendmarker = 1; |
|
921 922 /* | 940 941 /* |
923 * Wait up to 5 seconds for FW to go to READY state. | 942 * Whatever happens, we're now committed to being here. |
924 */ | 943 */ |
944 isp->isp_state = ISP_INITSTATE; 945 fcp->isp_fwstate = FW_CONFIG_WAIT; 946 947#ifdef ISP_TARGET_MODE 948 if (isp_modify_lun(isp, 0, 1, 1)) { 949 PRINTF("%s: failed to enable target mode\n", isp->isp_name); 950 } 951#endif 952} 953 954/* 955 * Fibre Channel Support- get the port database for the id. 956 * 957 * Locks are held before coming here. Return 0 if success, 958 * else failure. 959 */ 960 961static void 962isp_mark_getpdb_all(isp) 963 struct ispsoftc *isp; 964{ 965 isp_pdb_t *p; 966 fcparam *fcp = (fcparam *) isp->isp_param; 967 for (p = &fcp->isp_pdb[0]; p < &fcp->isp_pdb[MAX_FC_TARG]; p++) { 968 p->pdb_options = INVALID_PDB_OPTIONS; 969 } 970} 971 972static int 973isp_getpdb(isp, id, pdbp) 974 struct ispsoftc *isp; 975 int id; 976 isp_pdb_t *pdbp; 977{ 978#ifdef GETPDB_WORKING_YET 979 fcparam *fcp = (fcparam *) isp->isp_param; 980 mbreg_t mbs; 981 982 /* 983 * Get Port Queue Parameters first- this is 984 * a Q&D way to see whether we're logged into 985 * this port. 986 */ 987 mbs.param[0] = MBOX_GET_DEV_QUEUE_PARAMS; 988 mbs.param[1] = id << 8; 989 mbs.param[2] = 0; 990#ifdef ISP2100_SCCLUN 991 mbs.param[3] = 0; 992#endif 993 isp_mboxcmd(isp, &mbs); 994 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) 995 return (-1); 996 997 mbs.param[0] = MBOX_GET_PORT_DB; 998 mbs.param[1] = id << 8; 999 mbs.param[2] = (u_int16_t) (fcp->isp_scdma >> 16); 1000 mbs.param[3] = (u_int16_t) (fcp->isp_scdma & 0xffff); 1001 mbs.param[4] = 0; 1002 mbs.param[5] = 0; 1003 mbs.param[6] = 0; 1004 mbs.param[7] = 0; 1005 isp_mboxcmd(isp, &mbs); 1006 switch (mbs.param[0]) { 1007 case MBOX_COMMAND_COMPLETE: 1008 MemoryBarrier(); 1009 MEMCPY(pdbp, fcp->isp_scratch, sizeof (isp_pdb_t)); 1010 break; 1011 case MBOX_HOST_INTERFACE_ERROR: 1012 PRINTF("%s: DMA error getting port database\n", isp->isp_name); 1013 return (-1); 1014 case MBOX_COMMAND_PARAM_ERROR: 1015 /* Not Logged In */ 1016 IDPRINTF(3, ("%s: Comand Param Error on Get Port Database\n", 1017 isp->isp_name)); 1018 return (-1); 1019 default: 1020 PRINTF("%s: error 0x%x getting port database for ID %d\n", 1021 isp->isp_name, mbs.param[0], id); 1022 return (-1); 1023 } 1024#else 1025 pdbp->pdb_options = 1; 1026#endif 1027 return (0); 1028} 1029 1030/* 1031 * Make sure we have good FC link and know our Loop ID. 1032 */ 1033 1034static int 1035isp_fclink_test(isp) 1036 struct ispsoftc *isp; 1037{ 1038 mbreg_t mbs; 1039 int count; 1040 u_int8_t lwfs; 1041 fcparam *fcp; 1042 1043 fcp = isp->isp_param; 1044 1045 /* 1046 * Wait up to N microseconds for F/W to go to a ready state. 1047 * This is a platform specific 1048 */ |
|
925 lwfs = FW_CONFIG_WAIT; | 1049 lwfs = FW_CONFIG_WAIT; |
926 for (count = 0; count < 12000; count++) { | 1050 for (count = 0; count < FC_FW_READY_DELAY; count += 100) { |
927 isp_fw_state(isp); 928 if (lwfs != fcp->isp_fwstate) { 929 PRINTF("%s: Firmware State %s -> %s\n", 930 isp->isp_name, isp2100_fw_statename((int)lwfs), 931 isp2100_fw_statename((int)fcp->isp_fwstate)); 932 lwfs = fcp->isp_fwstate; 933 } 934 if (fcp->isp_fwstate == FW_READY) { 935 break; 936 } | 1051 isp_fw_state(isp); 1052 if (lwfs != fcp->isp_fwstate) { 1053 PRINTF("%s: Firmware State %s -> %s\n", 1054 isp->isp_name, isp2100_fw_statename((int)lwfs), 1055 isp2100_fw_statename((int)fcp->isp_fwstate)); 1056 lwfs = fcp->isp_fwstate; 1057 } 1058 if (fcp->isp_fwstate == FW_READY) { 1059 break; 1060 } |
937 SYS_DELAY(1000); /* wait one millisecond */ | 1061 SYS_DELAY(100); /* wait 100 microseconds */ |
938 } | 1062 } |
939 isp->isp_sendmarker = 1; | |
940 941 /* | 1063 1064 /* |
942 * Get our Loop ID 943 * (if possible) | 1065 * If we haven't gone to 'ready' state, return. |
944 */ | 1066 */ |
945 if (fcp->isp_fwstate == FW_READY) { 946 mbs.param[0] = MBOX_GET_LOOP_ID; 947 isp_mboxcmd(isp, &mbs); 948 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 949 isp_dumpregs(isp, "GET LOOP ID failed"); 950 return; 951 } 952 fcp->isp_loopid = mbs.param[1]; 953 fcp->isp_alpa = mbs.param[2]; 954 PRINTF("%s: Loop ID %d, ALPA 0x%x\n", isp->isp_name, 955 fcp->isp_loopid, fcp->isp_alpa); 956 isp->isp_state = ISP_INITSTATE; 957#ifdef ISP_TARGET_MODE 958 DISABLE_INTS(isp); 959 if (isp_modify_lun(isp, 0, 1, 1)) { 960 PRINTF("%s: failed to enable target mode\n", 961 isp->isp_name); 962 } 963 ENABLE_INTS(isp); 964#endif 965 } else { 966 PRINTF("%s: failed to go to FW READY state- will not attach\n", 967 isp->isp_name); | 1067 if (fcp->isp_fwstate != FW_READY) { 1068 return (-1); |
968 } | 1069 } |
1070 /* 1071 * Get our Loop ID (if possible). We really need to have it. 1072 */ 1073 mbs.param[0] = MBOX_GET_LOOP_ID; 1074 isp_mboxcmd(isp, &mbs); 1075 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 1076 PRINTF("%s: GET LOOP ID failed\n", isp->isp_name); 1077 return (-1); 1078 } 1079 fcp->isp_loopid = mbs.param[1]; 1080 fcp->isp_alpa = mbs.param[2]; 1081 PRINTF("%s: Loop ID %d, ALPA 0x%x\n", isp->isp_name, 1082 fcp->isp_loopid, fcp->isp_alpa); 1083 return (0); 1084 |
|
969} 970 971/* 972 * Start a command. Locking is assumed done in the caller. 973 */ 974 975int32_t 976ispscsicmd(xs) 977 ISP_SCSI_XFER_T *xs; 978{ 979 struct ispsoftc *isp; 980 u_int8_t iptr, optr; 981 union { 982 ispreq_t *_reqp; 983 ispreqt2_t *_t2reqp; 984 } _u; 985#define reqp _u._reqp 986#define t2reqp _u._t2reqp 987#define UZSIZE max(sizeof (ispreq_t), sizeof (ispreqt2_t)) | 1085} 1086 1087/* 1088 * Start a command. Locking is assumed done in the caller. 1089 */ 1090 1091int32_t 1092ispscsicmd(xs) 1093 ISP_SCSI_XFER_T *xs; 1094{ 1095 struct ispsoftc *isp; 1096 u_int8_t iptr, optr; 1097 union { 1098 ispreq_t *_reqp; 1099 ispreqt2_t *_t2reqp; 1100 } _u; 1101#define reqp _u._reqp 1102#define t2reqp _u._t2reqp 1103#define UZSIZE max(sizeof (ispreq_t), sizeof (ispreqt2_t)) |
988 int i; | 1104 int i, rqidx; |
989 990 XS_INITERR(xs); 991 isp = XS_ISP(xs); 992 993 if (isp->isp_state != ISP_RUNSTATE) { 994 PRINTF("%s: adapter not ready\n", isp->isp_name); 995 XS_SETERR(xs, HBA_BOTCH); 996 return (CMD_COMPLETE); 997 } 998 999 /* | 1105 1106 XS_INITERR(xs); 1107 isp = XS_ISP(xs); 1108 1109 if (isp->isp_state != ISP_RUNSTATE) { 1110 PRINTF("%s: adapter not ready\n", isp->isp_name); 1111 XS_SETERR(xs, HBA_BOTCH); 1112 return (CMD_COMPLETE); 1113 } 1114 1115 /* |
1000 * We *could* do the different sequence type that has clos 1001 * to the whole Queue Entry for the command,. | 1116 * We *could* do the different sequence type that has close 1117 * to the whole Queue Entry for the command,... |
1002 */ | 1118 */ |
1119 |
|
1003 if (XS_CDBLEN(xs) > ((isp->isp_type & ISP_HA_FC)? 16 : 12)) { 1004 PRINTF("%s: unsupported cdb length (%d)\n", 1005 isp->isp_name, XS_CDBLEN(xs)); 1006 XS_SETERR(xs, HBA_BOTCH); 1007 return (CMD_COMPLETE); 1008 } 1009 1010 /* | 1120 if (XS_CDBLEN(xs) > ((isp->isp_type & ISP_HA_FC)? 16 : 12)) { 1121 PRINTF("%s: unsupported cdb length (%d)\n", 1122 isp->isp_name, XS_CDBLEN(xs)); 1123 XS_SETERR(xs, HBA_BOTCH); 1124 return (CMD_COMPLETE); 1125 } 1126 1127 /* |
1011 * First check to see if any HBA or Device | 1128 * Check to see whether we have good firmware state still or 1129 * need to refresh our port database for this target. 1130 */ 1131 if (IS_FC(isp)) { 1132 fcparam *fcp = isp->isp_param; 1133 isp_pdb_t *pdbp = &fcp->isp_pdb[XS_TGT(xs)]; 1134 1135 /* 1136 * Check for f/w being in ready state. Well, okay, 1137 * our cached copy of it... 1138 */ 1139 if (fcp->isp_fwstate != FW_READY) { 1140 if (isp_fclink_test(isp)) { 1141 XS_SETERR(xs, HBA_SELTIMEOUT); 1142 return (CMD_COMPLETE); 1143 } 1144 } 1145 /* 1146 * Here's the spot we would need to find out whether 1147 * the port names have changed, whether it's still 1148 * a target role, etc.. 1149 */ 1150 if (pdbp->pdb_options == INVALID_PDB_OPTIONS) { 1151 /* 1152 * If we don't know what it is- don't talk to it. 1153 * This also handles cases where it's not logged 1154 * into this port/target. 1155 */ 1156 if (isp_getpdb(isp, XS_TGT(xs), pdbp)) { 1157 XS_SETERR(xs, HBA_SELTIMEOUT); 1158 return (CMD_COMPLETE); 1159#ifdef GETPDB_WORKING_YET 1160 } else { 1161 isp_async(isp, ISPASYNC_PDB_CHANGE_COMPLETE, 1162 (void *) (long) XS_TGT(xs)); 1163#endif 1164 } 1165 } 1166 } 1167 1168 /* 1169 * Next check to see if any HBA or Device |
1012 * parameters need to be updated. 1013 */ 1014 if (isp->isp_update) { 1015 isp_update(isp); 1016 } 1017 1018 optr = isp->isp_reqodx = ISP_READ(isp, OUTMAILBOX4); 1019 iptr = isp->isp_reqidx; 1020 1021 reqp = (ispreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, iptr); 1022 iptr = ISP_NXT_QENTRY(iptr, RQUEST_QUEUE_LEN); 1023 if (iptr == optr) { 1024 IDPRINTF(2, ("%s: Request Queue Overflow\n", isp->isp_name)); 1025 XS_SETERR(xs, HBA_BOTCH); 1026 return (CMD_EAGAIN); 1027 } | 1170 * parameters need to be updated. 1171 */ 1172 if (isp->isp_update) { 1173 isp_update(isp); 1174 } 1175 1176 optr = isp->isp_reqodx = ISP_READ(isp, OUTMAILBOX4); 1177 iptr = isp->isp_reqidx; 1178 1179 reqp = (ispreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, iptr); 1180 iptr = ISP_NXT_QENTRY(iptr, RQUEST_QUEUE_LEN); 1181 if (iptr == optr) { 1182 IDPRINTF(2, ("%s: Request Queue Overflow\n", isp->isp_name)); 1183 XS_SETERR(xs, HBA_BOTCH); 1184 return (CMD_EAGAIN); 1185 } |
1028 if (isp->isp_type & ISP_HA_FC) { 1029 DISABLE_INTS(isp); 1030 } | |
1031 1032 if (isp->isp_sendmarker) { 1033 u_int8_t niptr; 1034 ispmarkreq_t *marker = (ispmarkreq_t *) reqp; 1035 1036 MEMZERO((void *) marker, sizeof (*marker)); 1037 marker->req_header.rqs_entry_count = 1; 1038 marker->req_header.rqs_entry_type = RQSTYPE_MARKER; 1039 marker->req_modifier = SYNC_ALL; 1040 | 1186 1187 if (isp->isp_sendmarker) { 1188 u_int8_t niptr; 1189 ispmarkreq_t *marker = (ispmarkreq_t *) reqp; 1190 1191 MEMZERO((void *) marker, sizeof (*marker)); 1192 marker->req_header.rqs_entry_count = 1; 1193 marker->req_header.rqs_entry_type = RQSTYPE_MARKER; 1194 marker->req_modifier = SYNC_ALL; 1195 |
1041 isp->isp_sendmarker = 0; 1042 | |
1043 /* 1044 * Unconditionally update the input pointer anyway. 1045 */ 1046 ISP_WRITE(isp, INMAILBOX4, iptr); 1047 isp->isp_reqidx = iptr; 1048 1049 niptr = ISP_NXT_QENTRY(iptr, RQUEST_QUEUE_LEN); 1050 if (niptr == optr) { | 1196 /* 1197 * Unconditionally update the input pointer anyway. 1198 */ 1199 ISP_WRITE(isp, INMAILBOX4, iptr); 1200 isp->isp_reqidx = iptr; 1201 1202 niptr = ISP_NXT_QENTRY(iptr, RQUEST_QUEUE_LEN); 1203 if (niptr == optr) { |
1051 if (isp->isp_type & ISP_HA_FC) { 1052 ENABLE_INTS(isp); 1053 } | |
1054 IDPRINTF(2, ("%s: Request Queue Overflow+\n", 1055 isp->isp_name)); 1056 XS_SETERR(xs, HBA_BOTCH); 1057 return (CMD_EAGAIN); 1058 } 1059 reqp = (ispreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, iptr); 1060 iptr = niptr; 1061 } 1062 1063 MEMZERO((void *) reqp, UZSIZE); 1064 reqp->req_header.rqs_entry_count = 1; 1065 if (isp->isp_type & ISP_HA_FC) { 1066 reqp->req_header.rqs_entry_type = RQSTYPE_T2RQS; 1067 } else { 1068 reqp->req_header.rqs_entry_type = RQSTYPE_REQUEST; 1069 } 1070 reqp->req_header.rqs_flags = 0; 1071 reqp->req_header.rqs_seqno = isp->isp_seqno++; 1072 | 1204 IDPRINTF(2, ("%s: Request Queue Overflow+\n", 1205 isp->isp_name)); 1206 XS_SETERR(xs, HBA_BOTCH); 1207 return (CMD_EAGAIN); 1208 } 1209 reqp = (ispreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, iptr); 1210 iptr = niptr; 1211 } 1212 1213 MEMZERO((void *) reqp, UZSIZE); 1214 reqp->req_header.rqs_entry_count = 1; 1215 if (isp->isp_type & ISP_HA_FC) { 1216 reqp->req_header.rqs_entry_type = RQSTYPE_T2RQS; 1217 } else { 1218 reqp->req_header.rqs_entry_type = RQSTYPE_REQUEST; 1219 } 1220 reqp->req_header.rqs_flags = 0; 1221 reqp->req_header.rqs_seqno = isp->isp_seqno++; 1222 |
1073 for (i = 0; i < RQUEST_QUEUE_LEN; i++) { 1074 if (isp->isp_xflist[i] == NULL) | 1223 for (rqidx = 0; rqidx < RQUEST_QUEUE_LEN; rqidx++) { 1224 if (isp->isp_xflist[rqidx] == NULL) |
1075 break; 1076 } | 1225 break; 1226 } |
1077 if (i == RQUEST_QUEUE_LEN) { 1078 if (isp->isp_type & ISP_HA_FC) 1079 ENABLE_INTS(isp); | 1227 if (rqidx == RQUEST_QUEUE_LEN) { |
1080 IDPRINTF(2, ("%s: out of xflist pointers\n", isp->isp_name)); 1081 XS_SETERR(xs, HBA_BOTCH); 1082 return (CMD_EAGAIN); 1083 } else { 1084 /* 1085 * Never have a handle that is zero, so 1086 * set req_handle off by one. 1087 */ | 1228 IDPRINTF(2, ("%s: out of xflist pointers\n", isp->isp_name)); 1229 XS_SETERR(xs, HBA_BOTCH); 1230 return (CMD_EAGAIN); 1231 } else { 1232 /* 1233 * Never have a handle that is zero, so 1234 * set req_handle off by one. 1235 */ |
1088 isp->isp_xflist[i] = xs; 1089 reqp->req_handle = i+1; | 1236 isp->isp_xflist[rqidx] = xs; 1237 reqp->req_handle = rqidx+1; |
1090 } 1091 1092 if (isp->isp_type & ISP_HA_FC) { 1093 /* 1094 * See comment in isp_intr 1095 */ 1096 XS_RESID(xs) = 0; 1097 /* --- 17 unchanged lines hidden (view full) --- 1115 reqp->req_flags = 0; 1116 } 1117 } 1118 reqp->req_target = XS_TGT(xs); 1119 if (isp->isp_type & ISP_HA_SCSI) { 1120 reqp->req_lun_trn = XS_LUN(xs); 1121 reqp->req_cdblen = XS_CDBLEN(xs); 1122 } else { | 1238 } 1239 1240 if (isp->isp_type & ISP_HA_FC) { 1241 /* 1242 * See comment in isp_intr 1243 */ 1244 XS_RESID(xs) = 0; 1245 /* --- 17 unchanged lines hidden (view full) --- 1263 reqp->req_flags = 0; 1264 } 1265 } 1266 reqp->req_target = XS_TGT(xs); 1267 if (isp->isp_type & ISP_HA_SCSI) { 1268 reqp->req_lun_trn = XS_LUN(xs); 1269 reqp->req_cdblen = XS_CDBLEN(xs); 1270 } else { |
1123#ifdef SCCLUN | 1271#ifdef ISP2100_SCCLUN |
1124 reqp->req_scclun = XS_LUN(xs); 1125#else 1126 reqp->req_lun_trn = XS_LUN(xs); 1127#endif 1128 1129 } 1130 MEMCPY(reqp->req_cdb, XS_CDBP(xs), XS_CDBLEN(xs)); 1131 1132 IDPRINTF(5, ("%s(%d.%d): START%d cmd 0x%x datalen %d\n", isp->isp_name, 1133 XS_TGT(xs), XS_LUN(xs), reqp->req_header.rqs_seqno, 1134 reqp->req_cdb[0], XS_XFRLEN(xs))); 1135 1136 reqp->req_time = XS_TIME(xs) / 1000; 1137 if (reqp->req_time == 0 && XS_TIME(xs)) 1138 reqp->req_time = 1; | 1272 reqp->req_scclun = XS_LUN(xs); 1273#else 1274 reqp->req_lun_trn = XS_LUN(xs); 1275#endif 1276 1277 } 1278 MEMCPY(reqp->req_cdb, XS_CDBP(xs), XS_CDBLEN(xs)); 1279 1280 IDPRINTF(5, ("%s(%d.%d): START%d cmd 0x%x datalen %d\n", isp->isp_name, 1281 XS_TGT(xs), XS_LUN(xs), reqp->req_header.rqs_seqno, 1282 reqp->req_cdb[0], XS_XFRLEN(xs))); 1283 1284 reqp->req_time = XS_TIME(xs) / 1000; 1285 if (reqp->req_time == 0 && XS_TIME(xs)) 1286 reqp->req_time = 1; |
1287 1288 /* 1289 * Always give a bit more leeway to commands after a bus reset. 1290 */ 1291 if (isp->isp_sendmarker && reqp->req_time < 5) 1292 reqp->req_time = 5; 1293 |
|
1139 i = ISP_DMASETUP(isp, xs, reqp, &iptr, optr); 1140 if (i != CMD_QUEUED) { | 1294 i = ISP_DMASETUP(isp, xs, reqp, &iptr, optr); 1295 if (i != CMD_QUEUED) { |
1141 if (isp->isp_type & ISP_HA_FC) 1142 ENABLE_INTS(isp); | |
1143 /* | 1296 /* |
1297 * Take memory of it away... 1298 */ 1299 isp->isp_xflist[rqidx] = NULL; 1300 /* |
|
1144 * dmasetup sets actual error in packet, and 1145 * return what we were given to return. 1146 */ 1147 return (i); 1148 } 1149 XS_SETERR(xs, HBA_NOERROR); | 1301 * dmasetup sets actual error in packet, and 1302 * return what we were given to return. 1303 */ 1304 return (i); 1305 } 1306 XS_SETERR(xs, HBA_NOERROR); |
1307 MemoryBarrier(); |
|
1150 ISP_WRITE(isp, INMAILBOX4, iptr); 1151 isp->isp_reqidx = iptr; | 1308 ISP_WRITE(isp, INMAILBOX4, iptr); 1309 isp->isp_reqidx = iptr; |
1152 if (isp->isp_type & ISP_HA_FC) { 1153 ENABLE_INTS(isp); 1154 } | |
1155 isp->isp_nactive++; | 1310 isp->isp_nactive++; |
1311 if (isp->isp_sendmarker) 1312 isp->isp_sendmarker = 0; |
|
1156 return (CMD_QUEUED); 1157#undef reqp 1158#undef t2reqp 1159} 1160 1161/* 1162 * isp control 1163 * Locks (ints blocked) assumed held. --- 11 unchanged lines hidden (view full) --- 1175 1176 switch (ctl) { 1177 default: 1178 PRINTF("%s: isp_control unknown control op %x\n", 1179 isp->isp_name, ctl); 1180 break; 1181 1182 case ISPCTL_RESET_BUS: | 1313 return (CMD_QUEUED); 1314#undef reqp 1315#undef t2reqp 1316} 1317 1318/* 1319 * isp control 1320 * Locks (ints blocked) assumed held. --- 11 unchanged lines hidden (view full) --- 1332 1333 switch (ctl) { 1334 default: 1335 PRINTF("%s: isp_control unknown control op %x\n", 1336 isp->isp_name, ctl); 1337 break; 1338 1339 case ISPCTL_RESET_BUS: |
1340 /* 1341 * This is really important to have set after a bus reset. 1342 */ 1343 isp->isp_sendmarker = 1; 1344 1345 /* 1346 * Issue a bus reset. 1347 */ |
|
1183 mbs.param[0] = MBOX_BUS_RESET; 1184 if (isp->isp_type & ISP_HA_SCSI) { 1185 mbs.param[1] = 1186 ((sdparam *) isp->isp_param)->isp_bus_reset_delay; | 1348 mbs.param[0] = MBOX_BUS_RESET; 1349 if (isp->isp_type & ISP_HA_SCSI) { 1350 mbs.param[1] = 1351 ((sdparam *) isp->isp_param)->isp_bus_reset_delay; |
1352 if (mbs.param[1] < 2) 1353 mbs.param[1] = 2; |
|
1187 } else { 1188 /* 1189 * Unparameterized. 1190 */ 1191 mbs.param[1] = 5; 1192 } 1193 isp_mboxcmd(isp, &mbs); 1194 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 1195 isp_dumpregs(isp, "isp_control SCSI bus reset failed"); 1196 break; 1197 } | 1354 } else { 1355 /* 1356 * Unparameterized. 1357 */ 1358 mbs.param[1] = 5; 1359 } 1360 isp_mboxcmd(isp, &mbs); 1361 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 1362 isp_dumpregs(isp, "isp_control SCSI bus reset failed"); 1363 break; 1364 } |
1198 /* 1199 * This is really important to have set after a bus reset. 1200 */ 1201 isp->isp_sendmarker = 1; | |
1202 PRINTF("%s: driver initiated bus reset\n", isp->isp_name); 1203 return (0); 1204 1205 case ISPCTL_RESET_DEV: 1206 mbs.param[0] = MBOX_ABORT_TARGET; 1207 mbs.param[1] = ((long)arg) << 8; 1208 mbs.param[2] = 3; /* 'delay', in seconds */ 1209 isp_mboxcmd(isp, &mbs); --- 14 unchanged lines hidden (view full) --- 1224 } 1225 } 1226 if (i == RQUEST_QUEUE_LEN) { 1227 PRINTF("%s: isp_control- cannot find command to abort " 1228 "in active list\n", isp->isp_name); 1229 break; 1230 } 1231 mbs.param[0] = MBOX_ABORT; | 1365 PRINTF("%s: driver initiated bus reset\n", isp->isp_name); 1366 return (0); 1367 1368 case ISPCTL_RESET_DEV: 1369 mbs.param[0] = MBOX_ABORT_TARGET; 1370 mbs.param[1] = ((long)arg) << 8; 1371 mbs.param[2] = 3; /* 'delay', in seconds */ 1372 isp_mboxcmd(isp, &mbs); --- 14 unchanged lines hidden (view full) --- 1387 } 1388 } 1389 if (i == RQUEST_QUEUE_LEN) { 1390 PRINTF("%s: isp_control- cannot find command to abort " 1391 "in active list\n", isp->isp_name); 1392 break; 1393 } 1394 mbs.param[0] = MBOX_ABORT; |
1232#ifdef SCCLUN | 1395#ifdef ISP2100_SCCLUN |
1233 if (isp->isp_type & ISP_HA_FC) { 1234 mbs.param[1] = XS_TGT(xs) << 8; 1235 mbs.param[4] = 0; 1236 mbs.param[5] = 0; 1237 mbs.param[6] = XS_LUN(xs); 1238 } else { 1239 mbs.param[1] = XS_TGT(xs) << 8 | XS_LUN(xs); 1240 } --- 10 unchanged lines hidden (view full) --- 1251 } 1252 PRINTF("%s: command for target %d lun %d was aborted\n", 1253 isp->isp_name, XS_TGT(xs), XS_LUN(xs)); 1254 return (0); 1255 1256 case ISPCTL_UPDATE_PARAMS: 1257 isp_update(isp); 1258 return(0); | 1396 if (isp->isp_type & ISP_HA_FC) { 1397 mbs.param[1] = XS_TGT(xs) << 8; 1398 mbs.param[4] = 0; 1399 mbs.param[5] = 0; 1400 mbs.param[6] = XS_LUN(xs); 1401 } else { 1402 mbs.param[1] = XS_TGT(xs) << 8 | XS_LUN(xs); 1403 } --- 10 unchanged lines hidden (view full) --- 1414 } 1415 PRINTF("%s: command for target %d lun %d was aborted\n", 1416 isp->isp_name, XS_TGT(xs), XS_LUN(xs)); 1417 return (0); 1418 1419 case ISPCTL_UPDATE_PARAMS: 1420 isp_update(isp); 1421 return(0); |
1422 1423 case ISPCTL_FCLINK_TEST: 1424 return (isp_fclink_test(isp)); |
|
1259 } 1260 return (-1); 1261} 1262 1263/* 1264 * Interrupt Service Routine(s). 1265 * 1266 * External (OS) framework has done the appropriate locking, --- 26 unchanged lines hidden (view full) --- 1293 isp->isp_name, isr)); 1294 } 1295 return (0); 1296 } 1297 } 1298 1299 if (ISP_READ(isp, BIU_SEMA) & 1) { 1300 u_int16_t mbox = ISP_READ(isp, OUTMAILBOX0); | 1425 } 1426 return (-1); 1427} 1428 1429/* 1430 * Interrupt Service Routine(s). 1431 * 1432 * External (OS) framework has done the appropriate locking, --- 26 unchanged lines hidden (view full) --- 1459 isp->isp_name, isr)); 1460 } 1461 return (0); 1462 } 1463 } 1464 1465 if (ISP_READ(isp, BIU_SEMA) & 1) { 1466 u_int16_t mbox = ISP_READ(isp, OUTMAILBOX0); |
1301 u_int32_t fast_post_handle = isp_parse_async(isp, (int) mbox); 1302 ISP_WRITE(isp, BIU_SEMA, 0); 1303 if (fast_post_handle < 0) { 1304 return (1); 1305 } else if (fast_post_handle > 0) { 1306 xs = (ISP_SCSI_XFER_T *) 1307 isp->isp_xflist[fast_post_handle - 1]; 1308 isp->isp_xflist[fast_post_handle - 1] = NULL; 1309 /* 1310 * Since we don't have a result queue entry item, 1311 * we must believe that SCSI status is zero and 1312 * that all data transferred. 1313 */ 1314 XS_RESID(xs) = 0; 1315 XS_STS(xs) = 0; 1316 if (XS_XFRLEN(xs)) { 1317 ISP_DMAFREE(isp, xs, fast_post_handle - 1); | 1467 if (mbox & 0x4000) { 1468 if (mbox != MBOX_COMMAND_COMPLETE) { 1469 PRINTF("%s: isp_intr sees 0x%x\n", 1470 isp->isp_name,mbox); |
1318 } | 1471 } |
1319 if (isp->isp_nactive > 0) 1320 isp->isp_nactive--; 1321 complist[ndone++] = xs; | 1472 ISP_WRITE(isp, BIU_SEMA, 0); 1473 } else { 1474 u_int32_t fhandle = isp_parse_async(isp, (int) mbox); 1475 ISP_WRITE(isp, BIU_SEMA, 0); 1476 if (fhandle < 0) { 1477 return (1); 1478 } else if (fhandle > 0) { 1479 xs = (ISP_SCSI_XFER_T *) 1480 isp->isp_xflist[fhandle - 1]; 1481 isp->isp_xflist[fhandle - 1] = NULL; 1482 /* 1483 * Since we don't have a result queue entry 1484 * item, we must believe that SCSI status is 1485 * zero and that all data transferred. 1486 */ 1487 XS_RESID(xs) = 0; 1488 XS_STS(xs) = 0; 1489 if (XS_XFRLEN(xs)) { 1490 ISP_DMAFREE(isp, xs, fhandle - 1); 1491 } 1492 if (isp->isp_nactive > 0) 1493 isp->isp_nactive--; 1494 complist[ndone++] = xs; 1495 } |
1322 } 1323 } | 1496 } 1497 } |
1324 | |
1325 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 1326 1327 optr = isp->isp_residx; 1328 iptr = ISP_READ(isp, OUTMAILBOX5); 1329 1330 if (optr == iptr) { 1331 IDPRINTF(4, ("why intr? isr %x iptr %x optr %x\n", 1332 isr, optr, iptr)); --- 4 unchanged lines hidden (view full) --- 1337 ispstatusreq_t *sp; 1338 u_int8_t oop; 1339 int buddaboom = 0; 1340 1341 sp = (ispstatusreq_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr); 1342 oop = optr; 1343 optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN); 1344 nlooked++; | 1498 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 1499 1500 optr = isp->isp_residx; 1501 iptr = ISP_READ(isp, OUTMAILBOX5); 1502 1503 if (optr == iptr) { 1504 IDPRINTF(4, ("why intr? isr %x iptr %x optr %x\n", 1505 isr, optr, iptr)); --- 4 unchanged lines hidden (view full) --- 1510 ispstatusreq_t *sp; 1511 u_int8_t oop; 1512 int buddaboom = 0; 1513 1514 sp = (ispstatusreq_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr); 1515 oop = optr; 1516 optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN); 1517 nlooked++; |
1345 | 1518 MemoryBarrier(); |
1346 if (sp->req_header.rqs_entry_type != RQSTYPE_RESPONSE) { 1347 if (isp_handle_other_response(isp, sp, &optr) == 0) { 1348 ISP_WRITE(isp, INMAILBOX5, optr); 1349 continue; 1350 } 1351 /* 1352 * It really has to be a bounced request just copied 1353 * from the request queue to the response queue. --- 140 unchanged lines hidden (view full) --- 1494 complist[ndone++] = xs; /* defer completion call until later */ 1495 } 1496 1497 /* 1498 * If we looked at any commands, then it's valid to find out 1499 * what the outpointer is. It also is a trigger to update the 1500 * ISP's notion of what we've seen so far. 1501 */ | 1519 if (sp->req_header.rqs_entry_type != RQSTYPE_RESPONSE) { 1520 if (isp_handle_other_response(isp, sp, &optr) == 0) { 1521 ISP_WRITE(isp, INMAILBOX5, optr); 1522 continue; 1523 } 1524 /* 1525 * It really has to be a bounced request just copied 1526 * from the request queue to the response queue. --- 140 unchanged lines hidden (view full) --- 1667 complist[ndone++] = xs; /* defer completion call until later */ 1668 } 1669 1670 /* 1671 * If we looked at any commands, then it's valid to find out 1672 * what the outpointer is. It also is a trigger to update the 1673 * ISP's notion of what we've seen so far. 1674 */ |
1502 if (ndone) { | 1675 if (nlooked) { |
1503 ISP_WRITE(isp, INMAILBOX5, optr); 1504 isp->isp_reqodx = ISP_READ(isp, OUTMAILBOX4); 1505 } 1506 isp->isp_residx = optr; 1507 for (i = 0; i < ndone; i++) { 1508 xs = complist[i]; 1509 if (xs) { 1510 XS_CMD_DONE(xs); --- 9 unchanged lines hidden (view full) --- 1520static int 1521isp_parse_async(isp, mbox) 1522 struct ispsoftc *isp; 1523 int mbox; 1524{ 1525 u_int32_t fast_post_handle = 0; 1526 1527 switch (mbox) { | 1676 ISP_WRITE(isp, INMAILBOX5, optr); 1677 isp->isp_reqodx = ISP_READ(isp, OUTMAILBOX4); 1678 } 1679 isp->isp_residx = optr; 1680 for (i = 0; i < ndone; i++) { 1681 xs = complist[i]; 1682 if (xs) { 1683 XS_CMD_DONE(xs); --- 9 unchanged lines hidden (view full) --- 1693static int 1694isp_parse_async(isp, mbox) 1695 struct ispsoftc *isp; 1696 int mbox; 1697{ 1698 u_int32_t fast_post_handle = 0; 1699 1700 switch (mbox) { |
1701 case MBOX_COMMAND_COMPLETE: /* sometimes these show up */ 1702 break; |
|
1528 case ASYNC_BUS_RESET: | 1703 case ASYNC_BUS_RESET: |
1529 PRINTF("%s: SCSI bus reset detected\n", isp->isp_name); | 1704 isp_async(isp, ISPASYNC_BUS_RESET, NULL); |
1530 isp->isp_sendmarker = 1; 1531#ifdef ISP_TARGET_MODE 1532 isp_notify_ack(isp, NULL); 1533#endif 1534 break; 1535 1536 case ASYNC_SYSTEM_ERROR: 1537 mbox = ISP_READ(isp, OUTMAILBOX1); --- 20 unchanged lines hidden (view full) --- 1558 PRINTF("%s: timeout initiated SCSI bus reset\n", isp->isp_name); 1559 isp->isp_sendmarker = 1; 1560#ifdef ISP_TARGET_MODE 1561 isp_notify_ack(isp, NULL); 1562#endif 1563 break; 1564 1565 case ASYNC_DEVICE_RESET: | 1705 isp->isp_sendmarker = 1; 1706#ifdef ISP_TARGET_MODE 1707 isp_notify_ack(isp, NULL); 1708#endif 1709 break; 1710 1711 case ASYNC_SYSTEM_ERROR: 1712 mbox = ISP_READ(isp, OUTMAILBOX1); --- 20 unchanged lines hidden (view full) --- 1733 PRINTF("%s: timeout initiated SCSI bus reset\n", isp->isp_name); 1734 isp->isp_sendmarker = 1; 1735#ifdef ISP_TARGET_MODE 1736 isp_notify_ack(isp, NULL); 1737#endif 1738 break; 1739 1740 case ASYNC_DEVICE_RESET: |
1741 isp->isp_sendmarker = 1; |
|
1566 PRINTF("%s: device reset\n", isp->isp_name); 1567#ifdef ISP_TARGET_MODE 1568 isp_notify_ack(isp, NULL); 1569#endif 1570 break; 1571 1572 case ASYNC_EXTMSG_UNDERRUN: 1573 PRINTF("%s: extended message underrun\n", isp->isp_name); --- 27 unchanged lines hidden (view full) --- 1601 break; 1602 1603 case ASYNC_CTIO_DONE: 1604 /* Should only occur when Fast Posting Set for 2100s */ 1605 PRINTF("%s: CTIO done\n", isp->isp_name); 1606 break; 1607 1608 case ASYNC_LIP_OCCURRED: | 1742 PRINTF("%s: device reset\n", isp->isp_name); 1743#ifdef ISP_TARGET_MODE 1744 isp_notify_ack(isp, NULL); 1745#endif 1746 break; 1747 1748 case ASYNC_EXTMSG_UNDERRUN: 1749 PRINTF("%s: extended message underrun\n", isp->isp_name); --- 27 unchanged lines hidden (view full) --- 1777 break; 1778 1779 case ASYNC_CTIO_DONE: 1780 /* Should only occur when Fast Posting Set for 2100s */ 1781 PRINTF("%s: CTIO done\n", isp->isp_name); 1782 break; 1783 1784 case ASYNC_LIP_OCCURRED: |
1785 isp->isp_sendmarker = 1; |
|
1609 PRINTF("%s: LIP occurred\n", isp->isp_name); 1610 break; 1611 1612 case ASYNC_LOOP_UP: | 1786 PRINTF("%s: LIP occurred\n", isp->isp_name); 1787 break; 1788 1789 case ASYNC_LOOP_UP: |
1613 PRINTF("%s: Loop UP\n", isp->isp_name); | 1790 isp->isp_sendmarker = 1; |
1614 isp_async(isp, ISPASYNC_LOOP_UP, NULL); 1615 break; 1616 1617 case ASYNC_LOOP_DOWN: | 1791 isp_async(isp, ISPASYNC_LOOP_UP, NULL); 1792 break; 1793 1794 case ASYNC_LOOP_DOWN: |
1618 PRINTF("%s: Loop DOWN\n", isp->isp_name); | |
1619 isp_async(isp, ISPASYNC_LOOP_DOWN, NULL); 1620 break; 1621 1622 case ASYNC_LOOP_RESET: | 1795 isp_async(isp, ISPASYNC_LOOP_DOWN, NULL); 1796 break; 1797 1798 case ASYNC_LOOP_RESET: |
1799 isp->isp_sendmarker = 1; |
|
1623 PRINTF("%s: Loop RESET\n", isp->isp_name); 1624#ifdef ISP_TARGET_MODE 1625 isp_notify_ack(isp, NULL); 1626#endif 1627 break; 1628 1629 case ASYNC_PDB_CHANGED: | 1800 PRINTF("%s: Loop RESET\n", isp->isp_name); 1801#ifdef ISP_TARGET_MODE 1802 isp_notify_ack(isp, NULL); 1803#endif 1804 break; 1805 1806 case ASYNC_PDB_CHANGED: |
1807 isp->isp_sendmarker = 1; 1808 isp_mark_getpdb_all(isp); |
|
1630 PRINTF("%s: Port Database Changed\n", isp->isp_name); 1631 break; 1632 1633 case ASYNC_CHANGE_NOTIFY: | 1809 PRINTF("%s: Port Database Changed\n", isp->isp_name); 1810 break; 1811 1812 case ASYNC_CHANGE_NOTIFY: |
1634 PRINTF("%s: Name Server Database Changed\n", isp->isp_name); | |
1635 break; 1636 1637 default: | 1813 break; 1814 1815 default: |
1638 PRINTF("%s: async %x\n", isp->isp_name, mbox); | 1816 PRINTF("%s: unknown async code 0x%x\n", isp->isp_name, mbox); |
1639 break; 1640 } 1641 return (fast_post_handle); 1642} 1643 1644static int 1645isp_handle_other_response(isp, sp, optrp) 1646 struct ispsoftc *isp; --- 104 unchanged lines hidden (view full) --- 1751 break; 1752 case RQSTYPE_ATIO2: 1753 { 1754 fcparam *fcp = isp->isp_param; 1755 ispctiot2_t local, *ct2 = NULL; 1756 ispatiot2_t *at2 = (ispatiot2_t *) sp; 1757 int s, lun; 1758 | 1817 break; 1818 } 1819 return (fast_post_handle); 1820} 1821 1822static int 1823isp_handle_other_response(isp, sp, optrp) 1824 struct ispsoftc *isp; --- 104 unchanged lines hidden (view full) --- 1929 break; 1930 case RQSTYPE_ATIO2: 1931 { 1932 fcparam *fcp = isp->isp_param; 1933 ispctiot2_t local, *ct2 = NULL; 1934 ispatiot2_t *at2 = (ispatiot2_t *) sp; 1935 int s, lun; 1936 |
1759#ifdef SCCLUN | 1937#ifdef ISP2100_SCCLUN |
1760 lun = at2->req_scclun; 1761#else 1762 lun = at2->req_lun; 1763#endif 1764 PRINTF("%s: atio2 loopid %d for lun %d rxid 0x%x flags0x%x " 1765 "tflags0x%x ecodes0x%x rqstatus0x%x\n", isp->isp_name, 1766 at2->req_initiator, lun, at2->req_rxid, 1767 at2->req_flags, at2->req_taskflags, at2->req_execodes, --- 31 unchanged lines hidden (view full) --- 1799 PRINTF("%s: datalen %d cdb0=0x%x\n", isp->isp_name, 1800 at2->req_datalen, at2->req_cdb[0]); 1801 MEMZERO((void *) ct2, sizeof (*ct2)); 1802 ct2->req_header.rqs_entry_type = RQSTYPE_CTIO2; 1803 ct2->req_header.rqs_entry_count = 1; 1804 ct2->req_header.rqs_flags = 0; 1805 ct2->req_header.rqs_seqno = isp->isp_seqno++; 1806 ct2->req_handle = (at2->req_initiator << 16) | lun; | 1938 lun = at2->req_scclun; 1939#else 1940 lun = at2->req_lun; 1941#endif 1942 PRINTF("%s: atio2 loopid %d for lun %d rxid 0x%x flags0x%x " 1943 "tflags0x%x ecodes0x%x rqstatus0x%x\n", isp->isp_name, 1944 at2->req_initiator, lun, at2->req_rxid, 1945 at2->req_flags, at2->req_taskflags, at2->req_execodes, --- 31 unchanged lines hidden (view full) --- 1977 PRINTF("%s: datalen %d cdb0=0x%x\n", isp->isp_name, 1978 at2->req_datalen, at2->req_cdb[0]); 1979 MEMZERO((void *) ct2, sizeof (*ct2)); 1980 ct2->req_header.rqs_entry_type = RQSTYPE_CTIO2; 1981 ct2->req_header.rqs_entry_count = 1; 1982 ct2->req_header.rqs_flags = 0; 1983 ct2->req_header.rqs_seqno = isp->isp_seqno++; 1984 ct2->req_handle = (at2->req_initiator << 16) | lun; |
1807#ifndef SCCLUN | 1985#ifndef ISP2100_SCCLUN |
1808 ct2->req_lun = lun; 1809#endif 1810 ct2->req_initiator = at2->req_initiator; 1811 ct2->req_rxid = at2->req_rxid; 1812 1813 ct2->req_flags = CTIO_SEND_STATUS; 1814 switch (at2->req_cdb[0]) { 1815 case 0x0: /* TUR */ --- 698 unchanged lines hidden (view full) --- 2514 default: 2515 PRINTF("%s: comp status %x\n", isp->isp_name, 2516 sp->req_completion_status); 2517 break; 2518 } 2519 XS_SETERR(xs, HBA_BOTCH); 2520} 2521 | 1986 ct2->req_lun = lun; 1987#endif 1988 ct2->req_initiator = at2->req_initiator; 1989 ct2->req_rxid = at2->req_rxid; 1990 1991 ct2->req_flags = CTIO_SEND_STATUS; 1992 switch (at2->req_cdb[0]) { 1993 case 0x0: /* TUR */ --- 698 unchanged lines hidden (view full) --- 2692 default: 2693 PRINTF("%s: comp status %x\n", isp->isp_name, 2694 sp->req_completion_status); 2695 break; 2696 } 2697 XS_SETERR(xs, HBA_BOTCH); 2698} 2699 |
2700static void 2701isp_fastpost_complete(isp, fph) 2702 struct ispsoftc *isp; 2703 int fph; 2704{ 2705 ISP_SCSI_XFER_T *xs; 2706 2707 if (fph < 1) 2708 return; 2709 xs = (ISP_SCSI_XFER_T *) isp->isp_xflist[fph - 1]; 2710 isp->isp_xflist[fph - 1] = NULL; 2711 if (xs == NULL) { 2712 PRINTF("%s: fast posting handle 0x%x not found\n", 2713 isp->isp_name, fph - 1); 2714 return; 2715 } 2716 /* 2717 * Since we don't have a result queue entry item, 2718 * we must believe that SCSI status is zero and 2719 * that all data transferred. 2720 */ 2721 XS_RESID(xs) = 0; 2722 XS_STS(xs) = 0; 2723 if (XS_XFRLEN(xs)) { 2724 ISP_DMAFREE(isp, xs, fph - 1); 2725 } 2726 XS_CMD_DONE(xs); 2727} 2728 |
|
2522#define HINIB(x) ((x) >> 0x4) 2523#define LONIB(x) ((x) & 0xf) 2524#define MAKNIB(a, b) (((a) << 4) | (b)) 2525static u_int8_t mbpcnt[] = { 2526 MAKNIB(1, 1), /* 0x00: MBOX_NO_OP */ 2527 MAKNIB(5, 5), /* 0x01: MBOX_LOAD_RAM */ 2528 MAKNIB(2, 0), /* 0x02: MBOX_EXEC_FIRMWARE */ 2529 MAKNIB(5, 5), /* 0x03: MBOX_DUMP_RAM */ --- 92 unchanged lines hidden (view full) --- 2622 MAKNIB(8, 6), /* 0x60: MBOX_INIT_FIRMWARE */ 2623 MAKNIB(0, 0), /* 0x60: MBOX_GET_INIT_CONTROL_BLOCK (FORMAT?) */ 2624 MAKNIB(2, 1), /* 0x62: MBOX_INIT_LIP */ 2625 MAKNIB(8, 1), /* 0x63: MBOX_GET_FC_AL_POSITION_MAP */ 2626 MAKNIB(8, 1), /* 0x64: MBOX_GET_PORT_DB */ 2627 MAKNIB(3, 1), /* 0x65: MBOX_CLEAR_ACA */ 2628 MAKNIB(3, 1), /* 0x66: MBOX_TARGET_RESET */ 2629 MAKNIB(3, 1), /* 0x67: MBOX_CLEAR_TASK_SET */ | 2729#define HINIB(x) ((x) >> 0x4) 2730#define LONIB(x) ((x) & 0xf) 2731#define MAKNIB(a, b) (((a) << 4) | (b)) 2732static u_int8_t mbpcnt[] = { 2733 MAKNIB(1, 1), /* 0x00: MBOX_NO_OP */ 2734 MAKNIB(5, 5), /* 0x01: MBOX_LOAD_RAM */ 2735 MAKNIB(2, 0), /* 0x02: MBOX_EXEC_FIRMWARE */ 2736 MAKNIB(5, 5), /* 0x03: MBOX_DUMP_RAM */ --- 92 unchanged lines hidden (view full) --- 2829 MAKNIB(8, 6), /* 0x60: MBOX_INIT_FIRMWARE */ 2830 MAKNIB(0, 0), /* 0x60: MBOX_GET_INIT_CONTROL_BLOCK (FORMAT?) */ 2831 MAKNIB(2, 1), /* 0x62: MBOX_INIT_LIP */ 2832 MAKNIB(8, 1), /* 0x63: MBOX_GET_FC_AL_POSITION_MAP */ 2833 MAKNIB(8, 1), /* 0x64: MBOX_GET_PORT_DB */ 2834 MAKNIB(3, 1), /* 0x65: MBOX_CLEAR_ACA */ 2835 MAKNIB(3, 1), /* 0x66: MBOX_TARGET_RESET */ 2836 MAKNIB(3, 1), /* 0x67: MBOX_CLEAR_TASK_SET */ |
2630 MAKNIB(3, 1), /* 0x69: MBOX_ABORT_TASK_SET */ 2631 MAKNIB(1, 2) /* 0x69: MBOX_GET_FW_STATE */ | 2837 MAKNIB(3, 1), /* 0x68: MBOX_ABORT_TASK_SET */ 2838 MAKNIB(1, 2), /* 0x69: MBOX_GET_FW_STATE */ 2839 MAKNIB(2, 8), /* 0x6a: MBOX_GET_PORT_NAME */ 2840 MAKNIB(8, 1), /* 0x6b: MBOX_GET_LINK_STATUS */ 2841 MAKNIB(4, 4), /* 0x6c: MBOX_INIT_LIP_RESET */ 2842 MAKNIB(0, 0), /* 0x6d: */ 2843 MAKNIB(0, 0), /* 0x6e: */ 2844 MAKNIB(0, 0), /* 0x6f: */ 2845 MAKNIB(0, 0), /* 0x70: */ 2846 MAKNIB(0, 0), /* 0x71: */ 2847 MAKNIB(4, 1) /* 0x72: MBOX_INIT_LIP_LOGIN */ |
2632}; 2633#define NMBCOM (sizeof (mbpcnt) / sizeof (mbpcnt[0])) 2634 2635static void 2636isp_mboxcmd(isp, mbp) 2637 struct ispsoftc *isp; 2638 mbreg_t *mbp; 2639{ --- 20 unchanged lines hidden (view full) --- 2660 mbp->param[0]); 2661 return; 2662 } 2663 2664 2665 /* 2666 * Check for variants 2667 */ | 2848}; 2849#define NMBCOM (sizeof (mbpcnt) / sizeof (mbpcnt[0])) 2850 2851static void 2852isp_mboxcmd(isp, mbp) 2853 struct ispsoftc *isp; 2854 mbreg_t *mbp; 2855{ --- 20 unchanged lines hidden (view full) --- 2876 mbp->param[0]); 2877 return; 2878 } 2879 2880 2881 /* 2882 * Check for variants 2883 */ |
2668#ifdef SCCLUN | 2884#ifdef ISP2100_SCCLUN |
2669 if (isp->isp_type & ISP_HA_FC) { 2670 switch (mbp->param[0]) { 2671 case MBOX_ABORT: 2672 inparam = 7; 2673 break; 2674 case MBOX_ABORT_DEVICE: 2675 case MBOX_START_QUEUE: 2676 case MBOX_STOP_QUEUE: --- 5 unchanged lines hidden (view full) --- 2682 default: 2683 break; 2684 } 2685 } 2686#endif 2687 2688command_known: 2689 | 2885 if (isp->isp_type & ISP_HA_FC) { 2886 switch (mbp->param[0]) { 2887 case MBOX_ABORT: 2888 inparam = 7; 2889 break; 2890 case MBOX_ABORT_DEVICE: 2891 case MBOX_START_QUEUE: 2892 case MBOX_STOP_QUEUE: --- 5 unchanged lines hidden (view full) --- 2898 default: 2899 break; 2900 } 2901 } 2902#endif 2903 2904command_known: 2905 |
2906#define NEW_MB_WAY 1 2907#ifdef NEW_MB_WAY |
|
2690 /* | 2908 /* |
2691 * Make sure we can send some words.. | 2909 * Set semaphore on mailbox registers to win any races to acquire them. |
2692 */ | 2910 */ |
2911 ISP_WRITE(isp, BIU_SEMA, 1); 2912#endif |
|
2693 | 2913 |
2914 2915 /* 2916 * Make sure we can send some words. Check to see id there's 2917 * an async mbox event pending. 2918 */ 2919 |
|
2694 loops = MBOX_DELAY_COUNT; 2695 while ((ISP_READ(isp, HCCR) & HCCR_HOST_INT) != 0) { 2696 SYS_DELAY(100); | 2920 loops = MBOX_DELAY_COUNT; 2921 while ((ISP_READ(isp, HCCR) & HCCR_HOST_INT) != 0) { 2922 SYS_DELAY(100); |
2697 if (--loops < 0) { 2698 PRINTF("%s: isp_mboxcmd timeout #1\n", isp->isp_name); 2699 if (dld++) { 2700 return; 2701 } 2702 PRINTF("%s: but we'll try again, isr=%x\n", 2703 isp->isp_name, ISP_READ(isp, BIU_ISR)); 2704 if (ISP_READ(isp, BIU_SEMA) & 1) { 2705 u_int16_t mbox = ISP_READ(isp, OUTMAILBOX0); 2706 if (isp_parse_async(isp, (int) mbox)) | 2923 if (ISP_READ(isp, BIU_SEMA) & 1) { 2924 int fph; 2925 u_int16_t mbox = ISP_READ(isp, OUTMAILBOX0); 2926 /* 2927 * We have a pending MBOX async event. 2928 */ 2929 if (mbox & 0x8000) { 2930 fph = isp_parse_async(isp, (int) mbox); 2931 ISP_WRITE(isp, BIU_SEMA, 0); 2932 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 2933 if (fph < 0) { |
2707 return; | 2934 return; |
2935 } else if (fph > 0) { 2936 isp_fastpost_complete(isp, fph); 2937 } 2938 SYS_DELAY(100); 2939 goto command_known; 2940 } 2941 /* 2942 * We have a pending MBOX completion? Might be 2943 * from a previous command. We can't (sometimes) 2944 * just clear HOST INTERRUPT, so we'll just silently 2945 * eat this here. 2946 */ 2947 if (mbox == MBOX_COMMAND_COMPLETE) { |
|
2708 ISP_WRITE(isp, BIU_SEMA, 0); | 2948 ISP_WRITE(isp, BIU_SEMA, 0); |
2949 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 2950 SYS_DELAY(100); 2951 goto command_known; |
|
2709 } | 2952 } |
2953 } 2954 if (--loops < 0) { 2955 if (dld++ > 10) { 2956 PRINTF("%s: isp_mboxcmd could not get command " 2957 "started\n", isp->isp_name); 2958 return; 2959 } 2960 ISP_WRITE(isp, BIU_SEMA, 0); |
|
2710 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 2711 goto command_known; 2712 } 2713 } 2714 2715 /* | 2961 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 2962 goto command_known; 2963 } 2964 } 2965 2966 /* |
2716 * Write input parameters | 2967 * Write input parameters. |
2717 */ 2718 switch (inparam) { 2719 case 8: ISP_WRITE(isp, INMAILBOX7, mbp->param[7]); mbp->param[7] = 0; 2720 case 7: ISP_WRITE(isp, INMAILBOX6, mbp->param[6]); mbp->param[6] = 0; 2721 case 6: ISP_WRITE(isp, INMAILBOX5, mbp->param[5]); mbp->param[5] = 0; 2722 case 5: ISP_WRITE(isp, INMAILBOX4, mbp->param[4]); mbp->param[4] = 0; 2723 case 4: ISP_WRITE(isp, INMAILBOX3, mbp->param[3]); mbp->param[3] = 0; 2724 case 3: ISP_WRITE(isp, INMAILBOX2, mbp->param[2]); mbp->param[2] = 0; 2725 case 2: ISP_WRITE(isp, INMAILBOX1, mbp->param[1]); mbp->param[1] = 0; 2726 case 1: ISP_WRITE(isp, INMAILBOX0, mbp->param[0]); mbp->param[0] = 0; 2727 } 2728 2729 /* | 2968 */ 2969 switch (inparam) { 2970 case 8: ISP_WRITE(isp, INMAILBOX7, mbp->param[7]); mbp->param[7] = 0; 2971 case 7: ISP_WRITE(isp, INMAILBOX6, mbp->param[6]); mbp->param[6] = 0; 2972 case 6: ISP_WRITE(isp, INMAILBOX5, mbp->param[5]); mbp->param[5] = 0; 2973 case 5: ISP_WRITE(isp, INMAILBOX4, mbp->param[4]); mbp->param[4] = 0; 2974 case 4: ISP_WRITE(isp, INMAILBOX3, mbp->param[3]); mbp->param[3] = 0; 2975 case 3: ISP_WRITE(isp, INMAILBOX2, mbp->param[2]); mbp->param[2] = 0; 2976 case 2: ISP_WRITE(isp, INMAILBOX1, mbp->param[1]); mbp->param[1] = 0; 2977 case 1: ISP_WRITE(isp, INMAILBOX0, mbp->param[0]); mbp->param[0] = 0; 2978 } 2979 2980 /* |
2730 * Clear semaphore on mailbox registers | 2981 * Clear RISC int condition. |
2731 */ | 2982 */ |
2732 ISP_WRITE(isp, BIU_SEMA, 0); | 2983 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); |
2733 2734 /* | 2984 2985 /* |
2735 * Clear RISC int condition. | 2986 * Clear semaphore on mailbox registers so that the Qlogic 2987 * may update outgoing registers. |
2736 */ | 2988 */ |
2737 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); | 2989 ISP_WRITE(isp, BIU_SEMA, 0); |
2738 | 2990 |
2991 ENABLE_INTS(isp); |
|
2739 /* 2740 * Set Host Interrupt condition so that RISC will pick up mailbox regs. 2741 */ 2742 ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT); 2743 | 2992 /* 2993 * Set Host Interrupt condition so that RISC will pick up mailbox regs. 2994 */ 2995 ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT); 2996 |
2997#ifndef NEW_MB_WAY |
|
2744 /* 2745 * Wait until RISC int is set, except 2100 2746 */ 2747 if ((isp->isp_type & ISP_HA_FC) == 0) { 2748 loops = MBOX_DELAY_COUNT; 2749 while ((ISP_READ(isp, BIU_ISR) & BIU_ISR_RISC_INT) == 0) { 2750 SYS_DELAY(100); 2751 if (--loops < 0) { --- 5 unchanged lines hidden (view full) --- 2757 } 2758 2759 /* 2760 * Check to make sure that the semaphore has been set. 2761 */ 2762 loops = MBOX_DELAY_COUNT; 2763 while ((ISP_READ(isp, BIU_SEMA) & 1) == 0) { 2764 SYS_DELAY(100); | 2998 /* 2999 * Wait until RISC int is set, except 2100 3000 */ 3001 if ((isp->isp_type & ISP_HA_FC) == 0) { 3002 loops = MBOX_DELAY_COUNT; 3003 while ((ISP_READ(isp, BIU_ISR) & BIU_ISR_RISC_INT) == 0) { 3004 SYS_DELAY(100); 3005 if (--loops < 0) { --- 5 unchanged lines hidden (view full) --- 3011 } 3012 3013 /* 3014 * Check to make sure that the semaphore has been set. 3015 */ 3016 loops = MBOX_DELAY_COUNT; 3017 while ((ISP_READ(isp, BIU_SEMA) & 1) == 0) { 3018 SYS_DELAY(100); |
3019 /* 3020 * Wierd- I've seen the case where the semaphore register 3021 * isn't getting set- sort of a violation of the protocol.. 3022 */ 3023 if (ISP_READ(isp, OUTMAILBOX0) & 0x4000) 3024 break; |
|
2765 if (--loops < 0) { 2766 PRINTF("%s: isp_mboxcmd timeout #3\n", isp->isp_name); 2767 return; 2768 } 2769 } | 3025 if (--loops < 0) { 3026 PRINTF("%s: isp_mboxcmd timeout #3\n", isp->isp_name); 3027 return; 3028 } 3029 } |
3030#else 3031 /* 3032 * Wait until HOST INT has gone away (meaning that the Qlogic 3033 * has picked up the mailbox command. Wait a long time. 3034 */ 3035 loops = MBOX_DELAY_COUNT * 5; 3036 while ((ISP_READ(isp, HCCR) & HCCR_CMD_CLEAR_RISC_INT) != 0) { 3037 SYS_DELAY(100); 3038 if (--loops < 0) { 3039 PRINTF("%s: isp_mboxcmd timeout #2\n", isp->isp_name); 3040 return; 3041 } 3042 } |
|
2770 2771 /* | 3043 3044 /* |
2772 * Make sure that the MBOX_BUSY has gone away | 3045 * While the Semaphore registers isn't set, wait for the Qlogic 3046 * to process the mailbox command. Again- wait a long time. |
2773 */ | 3047 */ |
2774 loops = MBOX_DELAY_COUNT; 2775 while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) { | 3048 loops = MBOX_DELAY_COUNT * 5; 3049 while ((ISP_READ(isp, BIU_SEMA) & 1) == 0) { |
2776 SYS_DELAY(100); | 3050 SYS_DELAY(100); |
3051 /* 3052 * Wierd- I've seen the case where the semaphore register 3053 * isn't getting set- sort of a violation of the protocol.. 3054 */ 3055 if (ISP_READ(isp, OUTMAILBOX0) & 0x4000) 3056 break; |
|
2777 if (--loops < 0) { | 3057 if (--loops < 0) { |
2778 PRINTF("%s: isp_mboxcmd timeout #4\n", isp->isp_name); | 3058 PRINTF("%s: isp_mboxcmd timeout #3\n", isp->isp_name); |
2779 return; 2780 } 2781 } | 3059 return; 3060 } 3061 } |
3062#endif |
|
2782 | 3063 |
3064 /* 3065 * Make sure that the MBOX_BUSY has gone away 3066 */ 3067 loops = MBOX_DELAY_COUNT; 3068 for (;;) { 3069 u_int16_t mbox = ISP_READ(isp, OUTMAILBOX0); 3070 if (mbox == MBOX_BUSY) { 3071 if (--loops < 0) { 3072 PRINTF("%s: isp_mboxcmd timeout #4\n", 3073 isp->isp_name); 3074 return; 3075 } 3076 SYS_DELAY(100); 3077 continue; 3078 } 3079 /* 3080 * We have a pending MBOX async event. 3081 */ 3082 if (mbox & 0x8000) { 3083 int fph = isp_parse_async(isp, (int) mbox); 3084 ISP_WRITE(isp, BIU_SEMA, 0); 3085 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); 3086 if (fph < 0) { 3087 return; 3088 } else if (fph > 0) { 3089 isp_fastpost_complete(isp, fph); 3090 } 3091 SYS_DELAY(100); 3092 continue; 3093 } 3094 break; 3095 } |
|
2783 2784 /* 2785 * Pick up output parameters. 2786 */ 2787 switch (outparam) { 2788 case 8: mbp->param[7] = ISP_READ(isp, OUTMAILBOX7); 2789 case 7: mbp->param[6] = ISP_READ(isp, OUTMAILBOX6); 2790 case 6: mbp->param[5] = ISP_READ(isp, OUTMAILBOX5); --- 32 unchanged lines hidden (view full) --- 2823 PRINTF("%s: mbox cmd %x failed with TEST_FAILED\n", 2824 isp->isp_name, opcode); 2825 break; 2826 case MBOX_COMMAND_ERROR: 2827 PRINTF("%s: mbox cmd %x failed with COMMAND_ERROR\n", 2828 isp->isp_name, opcode); 2829 break; 2830 case MBOX_COMMAND_PARAM_ERROR: | 3096 3097 /* 3098 * Pick up output parameters. 3099 */ 3100 switch (outparam) { 3101 case 8: mbp->param[7] = ISP_READ(isp, OUTMAILBOX7); 3102 case 7: mbp->param[6] = ISP_READ(isp, OUTMAILBOX6); 3103 case 6: mbp->param[5] = ISP_READ(isp, OUTMAILBOX5); --- 32 unchanged lines hidden (view full) --- 3136 PRINTF("%s: mbox cmd %x failed with TEST_FAILED\n", 3137 isp->isp_name, opcode); 3138 break; 3139 case MBOX_COMMAND_ERROR: 3140 PRINTF("%s: mbox cmd %x failed with COMMAND_ERROR\n", 3141 isp->isp_name, opcode); 3142 break; 3143 case MBOX_COMMAND_PARAM_ERROR: |
2831 PRINTF("%s: mbox cmd %x failed with COMMAND_PARAM_ERROR\n", 2832 isp->isp_name, opcode); | 3144 switch (opcode) { 3145 case MBOX_GET_PORT_DB: 3146 case MBOX_GET_PORT_NAME: 3147 case MBOX_GET_DEV_QUEUE_PARAMS: 3148 break; 3149 default: 3150 PRINTF("%s: mbox cmd %x failed with " 3151 "COMMAND_PARAM_ERROR\n", isp->isp_name, opcode); 3152 } |
2833 break; 2834 2835 /* 2836 * Be silent about these... 2837 */ 2838 | 3153 break; 3154 3155 /* 3156 * Be silent about these... 3157 */ 3158 |
2839 case ASYNC_LOOP_UP: | |
2840 case ASYNC_LIP_OCCURRED: | 3159 case ASYNC_LIP_OCCURRED: |
3160 case ASYNC_LOOP_UP: 3161 case ASYNC_LOOP_DOWN: 3162 case ASYNC_LOOP_RESET: 3163 case ASYNC_CHANGE_NOTIFY: 3164 break; |
|
2841 case ASYNC_PDB_CHANGED: | 3165 case ASYNC_PDB_CHANGED: |
3166 isp_mark_getpdb_all(isp); |
|
2842 break; 2843 2844 default: 2845 /* 2846 * The expected return of EXEC_FIRMWARE is zero. 2847 */ 2848 if ((opcode == MBOX_EXEC_FIRMWARE && mbp->param[0] != 0) || 2849 (opcode != MBOX_EXEC_FIRMWARE)) { --- 105 unchanged lines hidden (view full) --- 2955 mbreg_t mbs; 2956 if (isp->isp_type & ISP_HA_FC) { 2957 int once = 0; 2958 fcparam *fcp = isp->isp_param; 2959again: 2960 mbs.param[0] = MBOX_GET_FW_STATE; 2961 isp_mboxcmd(isp, &mbs); 2962 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { | 3167 break; 3168 3169 default: 3170 /* 3171 * The expected return of EXEC_FIRMWARE is zero. 3172 */ 3173 if ((opcode == MBOX_EXEC_FIRMWARE && mbp->param[0] != 0) || 3174 (opcode != MBOX_EXEC_FIRMWARE)) { --- 105 unchanged lines hidden (view full) --- 3280 mbreg_t mbs; 3281 if (isp->isp_type & ISP_HA_FC) { 3282 int once = 0; 3283 fcparam *fcp = isp->isp_param; 3284again: 3285 mbs.param[0] = MBOX_GET_FW_STATE; 3286 isp_mboxcmd(isp, &mbs); 3287 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { |
2963 if (mbs.param[0] == ASYNC_LIP_OCCURRED || 2964 mbs.param[0] == ASYNC_PDB_CHANGED || 2965 mbs.param[0] == ASYNC_LOOP_UP) { | 3288 switch (mbs.param[0]) { 3289 case ASYNC_PDB_CHANGED: 3290 isp_mark_getpdb_all(isp); 3291 /* FALL THROUGH */ 3292 case ASYNC_LIP_OCCURRED: 3293 case ASYNC_LOOP_UP: 3294 case ASYNC_LOOP_DOWN: 3295 case ASYNC_LOOP_RESET: 3296 case ASYNC_CHANGE_NOTIFY: |
2966 if (once++ < 2) { 2967 goto again; 2968 } | 3297 if (once++ < 2) { 3298 goto again; 3299 } |
3300 break; |
|
2969 } 2970 isp_dumpregs(isp, "GET FIRMWARE STATE failed"); 2971 return; 2972 } 2973 fcp->isp_fwstate = mbs.param[1]; 2974 } 2975} 2976 --- 42 unchanged lines hidden (view full) --- 3019 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 3020 PRINTF("%s: failed to %cet SCSI parameters for " 3021 "target %d\n", isp->isp_name, (get)? 'g' : 's', 3022 tgt); 3023 continue; 3024 } 3025 3026 if (get == 0) { | 3301 } 3302 isp_dumpregs(isp, "GET FIRMWARE STATE failed"); 3303 return; 3304 } 3305 fcp->isp_fwstate = mbs.param[1]; 3306 } 3307} 3308 --- 42 unchanged lines hidden (view full) --- 3351 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 3352 PRINTF("%s: failed to %cet SCSI parameters for " 3353 "target %d\n", isp->isp_name, (get)? 'g' : 's', 3354 tgt); 3355 continue; 3356 } 3357 3358 if (get == 0) { |
3359 /* 3360 * XXX: Need a SYNC_TARGET for efficiency... 3361 */ 3362 isp->isp_sendmarker = 1; |
|
3027 sdp->isp_devparam[tgt].cur_dflags = 3028 sdp->isp_devparam[tgt].dev_flags; 3029 continue; 3030 } 3031 flags = mbs.param[2]; 3032 period = mbs.param[3] & 0xff; 3033 offset = mbs.param[3] >> 8; 3034 if (sdp->isp_devparam[tgt].cur_dflags != flags || --- 36 unchanged lines hidden (view full) --- 3071 return; 3072 } 3073 isp->isp_gotdparms = 1; 3074 3075 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0 && 3076 (isp_read_nvram(isp) == 0)) { 3077 return; 3078 } | 3363 sdp->isp_devparam[tgt].cur_dflags = 3364 sdp->isp_devparam[tgt].dev_flags; 3365 continue; 3366 } 3367 flags = mbs.param[2]; 3368 period = mbs.param[3] & 0xff; 3369 offset = mbs.param[3] >> 8; 3370 if (sdp->isp_devparam[tgt].cur_dflags != flags || --- 36 unchanged lines hidden (view full) --- 3407 return; 3408 } 3409 isp->isp_gotdparms = 1; 3410 3411 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0 && 3412 (isp_read_nvram(isp) == 0)) { 3413 return; 3414 } |
3079 if (isp->isp_type & ISP_HA_FC) { | 3415 if (IS_FC(isp)) { |
3080 fcparam *fcp = (fcparam *) isp->isp_param; 3081 fcp->isp_maxfrmlen = ICB_DFLT_FRMLEN; 3082 fcp->isp_maxalloc = 256; 3083 fcp->isp_execthrottle = 16; 3084 fcp->isp_retry_delay = 5; 3085 fcp->isp_retry_count = 0; 3086 /* 3087 * It would be nice to fake up a WWN in case we don't --- 139 unchanged lines hidden (view full) --- 3227 isp->isp_nactive--; 3228 XS_RESID(xs) = XS_XFRLEN(xs); 3229 XS_SETERR(xs, HBA_BUSRESET); 3230 XS_CMD_DONE(xs); 3231 } 3232} 3233 3234/* | 3416 fcparam *fcp = (fcparam *) isp->isp_param; 3417 fcp->isp_maxfrmlen = ICB_DFLT_FRMLEN; 3418 fcp->isp_maxalloc = 256; 3419 fcp->isp_execthrottle = 16; 3420 fcp->isp_retry_delay = 5; 3421 fcp->isp_retry_count = 0; 3422 /* 3423 * It would be nice to fake up a WWN in case we don't --- 139 unchanged lines hidden (view full) --- 3563 isp->isp_nactive--; 3564 XS_RESID(xs) = XS_XFRLEN(xs); 3565 XS_SETERR(xs, HBA_BUSRESET); 3566 XS_CMD_DONE(xs); 3567 } 3568} 3569 3570/* |
3235 * Miscellaneous debug statements. 3236 */ 3237static void 3238isp_prtstst(sp) 3239 ispstatusreq_t *sp; 3240{ 3241 PRINTF("states->"); 3242 if (sp->req_state_flags & RQSF_GOT_BUS) 3243 PRINTF("GOT_BUS "); 3244 if (sp->req_state_flags & RQSF_GOT_TARGET) 3245 PRINTF("GOT_TGT "); 3246 if (sp->req_state_flags & RQSF_SENT_CDB) 3247 PRINTF("SENT_CDB "); 3248 if (sp->req_state_flags & RQSF_XFRD_DATA) 3249 PRINTF("XFRD_DATA "); 3250 if (sp->req_state_flags & RQSF_GOT_STATUS) 3251 PRINTF("GOT_STS "); 3252 if (sp->req_state_flags & RQSF_GOT_SENSE) 3253 PRINTF("GOT_SNS "); 3254 if (sp->req_state_flags & RQSF_XFER_COMPLETE) 3255 PRINTF("XFR_CMPLT "); 3256 PRINTF("\n"); 3257 PRINTF("status->"); 3258 if (sp->req_status_flags & RQSTF_DISCONNECT) 3259 PRINTF("Disconnect "); 3260 if (sp->req_status_flags & RQSTF_SYNCHRONOUS) 3261 PRINTF("Sync_xfr "); 3262 if (sp->req_status_flags & RQSTF_PARITY_ERROR) 3263 PRINTF("Parity "); 3264 if (sp->req_status_flags & RQSTF_BUS_RESET) 3265 PRINTF("Bus_Reset "); 3266 if (sp->req_status_flags & RQSTF_DEVICE_RESET) 3267 PRINTF("Device_Reset "); 3268 if (sp->req_status_flags & RQSTF_ABORTED) 3269 PRINTF("Aborted "); 3270 if (sp->req_status_flags & RQSTF_TIMEOUT) 3271 PRINTF("Timeout "); 3272 if (sp->req_status_flags & RQSTF_NEGOTIATION) 3273 PRINTF("Negotiation "); 3274 PRINTF("\n"); 3275} 3276 3277static char * 3278isp2100_fw_statename(state) 3279 int state; 3280{ 3281 switch(state) { 3282 case FW_CONFIG_WAIT: return "Config Wait"; 3283 case FW_WAIT_AL_PA: return "Waiting for AL/PA"; 3284 case FW_WAIT_LOGIN: return "Wait Login"; 3285 case FW_READY: return "Ready"; 3286 case FW_LOSS_OF_SYNC: return "Loss Of Sync"; 3287 case FW_ERROR: return "Error"; 3288 case FW_REINIT: return "Re-Init"; 3289 case FW_NON_PART: return "Nonparticipating"; 3290 default: return "eh?"; 3291 } 3292} 3293 3294/* | |
3295 * NVRAM Routines 3296 */ 3297 3298static int 3299isp_read_nvram(isp) 3300 struct ispsoftc *isp; 3301{ 3302 int i, amt; 3303 u_int8_t csum, minversion; 3304 union { 3305 u_int8_t _x[ISP2100_NVRAM_SIZE]; 3306 u_int16_t _s[ISP2100_NVRAM_SIZE>>1]; 3307 } _n; 3308#define nvram_data _n._x 3309#define nvram_words _n._s 3310 | 3571 * NVRAM Routines 3572 */ 3573 3574static int 3575isp_read_nvram(isp) 3576 struct ispsoftc *isp; 3577{ 3578 int i, amt; 3579 u_int8_t csum, minversion; 3580 union { 3581 u_int8_t _x[ISP2100_NVRAM_SIZE]; 3582 u_int16_t _s[ISP2100_NVRAM_SIZE>>1]; 3583 } _n; 3584#define nvram_data _n._x 3585#define nvram_words _n._s 3586 |
3311 if (isp->isp_type & ISP_HA_FC) { | 3587 if (IS_FC(isp)) { |
3312 amt = ISP2100_NVRAM_SIZE; 3313 minversion = 1; 3314 } else { 3315 amt = ISP_NVRAM_SIZE; 3316 minversion = 2; 3317 } 3318 3319 /* --- 299 unchanged lines hidden --- | 3588 amt = ISP2100_NVRAM_SIZE; 3589 minversion = 1; 3590 } else { 3591 amt = ISP_NVRAM_SIZE; 3592 minversion = 2; 3593 } 3594 3595 /* --- 299 unchanged lines hidden --- |