Deleted Added
full compact
isp.c (63383) isp.c (64095)
1/* $FreeBSD: head/sys/dev/isp/isp.c 63383 2000-07-18 06:46:48Z mjacob $ */
1/* $FreeBSD: head/sys/dev/isp/isp.c 64095 2000-08-01 06:51:05Z 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 by Matthew Jacob
7 * NASA/Ames Research Center
8 * All rights reserved.
9 *

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

49#include <dev/isp/isp_freebsd.h>
50#endif
51#ifdef __OpenBSD__
52#include <dev/ic/isp_openbsd.h>
53#endif
54#ifdef __linux__
55#include "isp_linux.h"
56#endif
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 by Matthew Jacob
7 * NASA/Ames Research Center
8 * All rights reserved.
9 *

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

49#include <dev/isp/isp_freebsd.h>
50#endif
51#ifdef __OpenBSD__
52#include <dev/ic/isp_openbsd.h>
53#endif
54#ifdef __linux__
55#include "isp_linux.h"
56#endif
57#ifdef __svr4__
58#include "isp_solaris.h"
59#endif
57
58/*
59 * General defines
60 */
61
62#define MBOX_DELAY_COUNT 1000000 / 100
63
64/*
65 * Local static data
66 */
60
61/*
62 * General defines
63 */
64
65#define MBOX_DELAY_COUNT 1000000 / 100
66
67/*
68 * Local static data
69 */
67
70static char *warnlun =
71 "WARNING- cannot determine Expanded LUN capability- limiting to one LUN";
72static char *portshift =
73 "Target %d Loop ID 0x%x (Port 0x%x) => Loop 0x%x (Port 0x%x)";
74static char *portdup =
75 "Target %d duplicates Target %d- killing off both";
76static char *retained =
77 "Retaining Loop ID 0x%x for Target %d (Port 0x%x)";
78#ifdef ISP2100_FABRIC
79static char *lretained =
80 "Retained login of Target %d (Loop ID 0x%x) Port 0x%x";
81static char *plogout =
82 "Logging out Target %d at Loop ID 0x%x (Port 0x%x)";
83static char *plogierr =
84 "Command Error in PLOGI for Port 0x%x (0x%x)";
85static char *nopdb =
86 "Could not get PDB for Device @ Port 0x%x";
87static char *pdbmfail1 =
88 "PDB Loop ID info for Device @ Port 0x%x does not match up (0x%x)";
89static char *pdbmfail2 =
90 "PDB Port info for Device @ Port 0x%x does not match up (0x%x)";
91static char *ldumped =
92 "Target %d (Loop ID 0x%x) Port 0x%x dumped after login info mismatch";
93#endif
94static char *notresp =
95 "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d)";
96static char *xact1 =
97 "HBA attempted queued transaction with disconnect not set for %d.%d.%d";
98static char *xact2 =
99 "HBA attempted queued transaction to target routine %d on target %d bus %d";
100static char *xact3 =
101 "HBA attempted queued cmd for %d.%d.%d when queueing disabled";
102static char *pskip =
103 "SCSI phase skipped for target %d.%d.%d";
104static char *topology =
105 "Loop ID %d, AL_PA 0x%x, Port ID 0x%x, Loop State 0x%x, Topology '%s'";
106static char *finmsg =
107 "(%d.%d.%d): FIN dl%d resid%d STS 0x%x SKEY %c XS_ERR=0x%x";
68/*
69 * Local function prototypes.
70 */
71static int isp_parse_async __P((struct ispsoftc *, int));
72static int isp_handle_other_response
73__P((struct ispsoftc *, ispstatusreq_t *, u_int16_t *));
74static void isp_parse_status
108/*
109 * Local function prototypes.
110 */
111static int isp_parse_async __P((struct ispsoftc *, int));
112static int isp_handle_other_response
113__P((struct ispsoftc *, ispstatusreq_t *, u_int16_t *));
114static void isp_parse_status
75__P((struct ispsoftc *, ispstatusreq_t *, ISP_SCSI_XFER_T *));
115__P((struct ispsoftc *, ispstatusreq_t *, XS_T *));
76static void isp_fastpost_complete __P((struct ispsoftc *, u_int32_t));
77static void isp_scsi_init __P((struct ispsoftc *));
78static void isp_scsi_channel_init __P((struct ispsoftc *, int));
79static void isp_fibre_init __P((struct ispsoftc *));
80static void isp_mark_getpdb_all __P((struct ispsoftc *));
81static int isp_getpdb __P((struct ispsoftc *, int, isp_pdb_t *));
82static u_int64_t isp_get_portname __P((struct ispsoftc *, int, int));
83static int isp_fclink_test __P((struct ispsoftc *, int));
116static void isp_fastpost_complete __P((struct ispsoftc *, u_int32_t));
117static void isp_scsi_init __P((struct ispsoftc *));
118static void isp_scsi_channel_init __P((struct ispsoftc *, int));
119static void isp_fibre_init __P((struct ispsoftc *));
120static void isp_mark_getpdb_all __P((struct ispsoftc *));
121static int isp_getpdb __P((struct ispsoftc *, int, isp_pdb_t *));
122static u_int64_t isp_get_portname __P((struct ispsoftc *, int, int));
123static int isp_fclink_test __P((struct ispsoftc *, int));
124static char *isp2100_fw_statename __P((int));
84static int isp_same_lportdb __P((struct lportdb *, struct lportdb *));
85static int isp_pdb_sync __P((struct ispsoftc *, int));
86#ifdef ISP2100_FABRIC
87static int isp_scan_fabric __P((struct ispsoftc *));
88#endif
89static void isp_fw_state __P((struct ispsoftc *));
125static int isp_same_lportdb __P((struct lportdb *, struct lportdb *));
126static int isp_pdb_sync __P((struct ispsoftc *, int));
127#ifdef ISP2100_FABRIC
128static int isp_scan_fabric __P((struct ispsoftc *));
129#endif
130static void isp_fw_state __P((struct ispsoftc *));
90static void isp_dumpregs __P((struct ispsoftc *, const char *));
91static void isp_mboxcmd __P((struct ispsoftc *, mbreg_t *));
131static void isp_mboxcmd __P((struct ispsoftc *, mbreg_t *, int));
92
93static void isp_update __P((struct ispsoftc *));
94static void isp_update_bus __P((struct ispsoftc *, int));
95static void isp_setdfltparm __P((struct ispsoftc *, int));
96static int isp_read_nvram __P((struct ispsoftc *));
97static void isp_rdnvram_word __P((struct ispsoftc *, int, u_int16_t *));
98static void isp_parse_nvram_1020 __P((struct ispsoftc *, u_int8_t *));
99static void isp_parse_nvram_1080 __P((struct ispsoftc *, int, u_int8_t *));
100static void isp_parse_nvram_12160 __P((struct ispsoftc *, int, u_int8_t *));
101static void isp_parse_nvram_2100 __P((struct ispsoftc *, u_int8_t *));
102
132
133static void isp_update __P((struct ispsoftc *));
134static void isp_update_bus __P((struct ispsoftc *, int));
135static void isp_setdfltparm __P((struct ispsoftc *, int));
136static int isp_read_nvram __P((struct ispsoftc *));
137static void isp_rdnvram_word __P((struct ispsoftc *, int, u_int16_t *));
138static void isp_parse_nvram_1020 __P((struct ispsoftc *, u_int8_t *));
139static void isp_parse_nvram_1080 __P((struct ispsoftc *, int, u_int8_t *));
140static void isp_parse_nvram_12160 __P((struct ispsoftc *, int, u_int8_t *));
141static void isp_parse_nvram_2100 __P((struct ispsoftc *, u_int8_t *));
142
103
104/*
105 * Reset Hardware.
106 *
107 * Hit the chip over the head, download new f/w if available and set it running.
108 *
109 * Locking done elsewhere.
110 */
111void
112isp_reset(isp)
113 struct ispsoftc *isp;
114{
115 mbreg_t mbs;
116 int loops, i, touched, dodnld = 1;
117 char *revname;
118
119 isp->isp_state = ISP_NILSTATE;
120
143/*
144 * Reset Hardware.
145 *
146 * Hit the chip over the head, download new f/w if available and set it running.
147 *
148 * Locking done elsewhere.
149 */
150void
151isp_reset(isp)
152 struct ispsoftc *isp;
153{
154 mbreg_t mbs;
155 int loops, i, touched, dodnld = 1;
156 char *revname;
157
158 isp->isp_state = ISP_NILSTATE;
159
160
121 /*
122 * Basic types (SCSI, FibreChannel and PCI or SBus)
123 * have been set in the MD code. We figure out more
124 * here.
161 /*
162 * Basic types (SCSI, FibreChannel and PCI or SBus)
163 * have been set in the MD code. We figure out more
164 * here.
125 */
126 isp->isp_dblev = DFLT_DBLEVEL;
127
128 /*
165 *
129 * After we've fired this chip up, zero out the conf1 register
166 * After we've fired this chip up, zero out the conf1 register
130 * for SCSI adapters and other settings for the 2100.
167 * for SCSI adapters and do other settings for the 2100.
131 */
132
133 /*
134 * Get the current running firmware revision out of the
135 * chip before we hit it over the head (if this is our
136 * first time through). Note that we store this as the
137 * 'ROM' firmware revision- which it may not be. In any
138 * case, we don't really use this yet, but we may in
139 * the future.
140 */
141 if ((touched = isp->isp_touched) == 0) {
142 /*
168 */
169
170 /*
171 * Get the current running firmware revision out of the
172 * chip before we hit it over the head (if this is our
173 * first time through). Note that we store this as the
174 * 'ROM' firmware revision- which it may not be. In any
175 * case, we don't really use this yet, but we may in
176 * the future.
177 */
178 if ((touched = isp->isp_touched) == 0) {
179 /*
143 * Just in case it was paused...
180 * First see whether or not we're sitting in the ISP PROM.
181 * If we've just been reset, we'll have the string "ISP "
182 * spread through outgoing mailbox registers 1-3.
144 */
183 */
145 ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
146 mbs.param[0] = MBOX_ABOUT_FIRMWARE;
147 isp_mboxcmd(isp, &mbs);
148 /*
149 * If this fails, it probably means we're running
150 * an old prom, if anything at all...
151 */
152 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
153 isp->isp_romfw_rev[0] = mbs.param[1];
154 isp->isp_romfw_rev[1] = mbs.param[2];
155 isp->isp_romfw_rev[2] = mbs.param[3];
184 if (ISP_READ(isp, OUTMAILBOX1) != 0x4953 ||
185 ISP_READ(isp, OUTMAILBOX2) != 0x5020 ||
186 ISP_READ(isp, OUTMAILBOX3) != 0x2020) {
187 /*
188 * Just in case it was paused...
189 */
190 ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
191 mbs.param[0] = MBOX_ABOUT_FIRMWARE;
192 isp_mboxcmd(isp, &mbs, MBLOGNONE);
193 /*
194 * This *shouldn't* fail.....
195 */
196 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
197 isp->isp_romfw_rev[0] = mbs.param[1];
198 isp->isp_romfw_rev[1] = mbs.param[2];
199 isp->isp_romfw_rev[2] = mbs.param[3];
200 }
156 }
157 isp->isp_touched = 1;
158 }
159
160 DISABLE_INTS(isp);
161
162 /*
163 * Put the board into PAUSE mode (so we can read the SXP registers).

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

182 isp->isp_clock = 60;
183 sdp->isp_ultramode = 1;
184 sdp++;
185 sdp->isp_ultramode = 1;
186 /*
187 * XXX: Should probably do some bus sensing.
188 */
189 } else if (IS_ULTRA2(isp)) {
201 }
202 isp->isp_touched = 1;
203 }
204
205 DISABLE_INTS(isp);
206
207 /*
208 * Put the board into PAUSE mode (so we can read the SXP registers).

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

227 isp->isp_clock = 60;
228 sdp->isp_ultramode = 1;
229 sdp++;
230 sdp->isp_ultramode = 1;
231 /*
232 * XXX: Should probably do some bus sensing.
233 */
234 } else if (IS_ULTRA2(isp)) {
190 static char *m = "%s: bus %d is in %s Mode\n";
235 static char *m = "bus %d is in %s Mode";
191 u_int16_t l;
192 sdparam *sdp = isp->isp_param;
193
194 isp->isp_clock = 100;
195
196 if (IS_1280(isp))
197 revname = "1280";
198 else if (IS_1080(isp))
199 revname = "1080";
200 else if (IS_12160(isp))
201 revname = "12160";
202 else
203 revname = "<UNKLVD>";
204
205 l = ISP_READ(isp, SXP_PINS_DIFF) & ISP1080_MODE_MASK;
206 switch (l) {
207 case ISP1080_LVD_MODE:
208 sdp->isp_lvdmode = 1;
236 u_int16_t l;
237 sdparam *sdp = isp->isp_param;
238
239 isp->isp_clock = 100;
240
241 if (IS_1280(isp))
242 revname = "1280";
243 else if (IS_1080(isp))
244 revname = "1080";
245 else if (IS_12160(isp))
246 revname = "12160";
247 else
248 revname = "<UNKLVD>";
249
250 l = ISP_READ(isp, SXP_PINS_DIFF) & ISP1080_MODE_MASK;
251 switch (l) {
252 case ISP1080_LVD_MODE:
253 sdp->isp_lvdmode = 1;
209 CFGPRINTF(m, isp->isp_name, 0, "LVD");
254 isp_prt(isp, ISP_LOGCONFIG, m, 0, "LVD");
210 break;
211 case ISP1080_HVD_MODE:
212 sdp->isp_diffmode = 1;
255 break;
256 case ISP1080_HVD_MODE:
257 sdp->isp_diffmode = 1;
213 CFGPRINTF(m, isp->isp_name, 0, "Differential");
258 isp_prt(isp, ISP_LOGCONFIG, m, 0, "Differential");
214 break;
215 case ISP1080_SE_MODE:
216 sdp->isp_ultramode = 1;
259 break;
260 case ISP1080_SE_MODE:
261 sdp->isp_ultramode = 1;
217 CFGPRINTF(m, isp->isp_name, 0, "Single-Ended");
262 isp_prt(isp, ISP_LOGCONFIG, m, 0, "Single-Ended");
218 break;
219 default:
263 break;
264 default:
220 CFGPRINTF("%s: unknown mode on bus %d (0x%x)\n",
221 isp->isp_name, 0, l);
265 isp_prt(isp, ISP_LOGERR,
266 "unknown mode on bus %d (0x%x)", 0, l);
222 break;
223 }
224
225 if (IS_DUALBUS(isp)) {
226 sdp++;
227 l = ISP_READ(isp, SXP_PINS_DIFF|SXP_BANK1_SELECT);
228 l &= ISP1080_MODE_MASK;
229 switch(l) {
230 case ISP1080_LVD_MODE:
231 sdp->isp_lvdmode = 1;
267 break;
268 }
269
270 if (IS_DUALBUS(isp)) {
271 sdp++;
272 l = ISP_READ(isp, SXP_PINS_DIFF|SXP_BANK1_SELECT);
273 l &= ISP1080_MODE_MASK;
274 switch(l) {
275 case ISP1080_LVD_MODE:
276 sdp->isp_lvdmode = 1;
232 CFGPRINTF(m, isp->isp_name, 1, "LVD");
277 isp_prt(isp, ISP_LOGCONFIG, m, 1, "LVD");
233 break;
234 case ISP1080_HVD_MODE:
235 sdp->isp_diffmode = 1;
278 break;
279 case ISP1080_HVD_MODE:
280 sdp->isp_diffmode = 1;
236 CFGPRINTF(m, isp->isp_name, 1, "Differential");
281 isp_prt(isp, ISP_LOGCONFIG,
282 m, 1, "Differential");
237 break;
238 case ISP1080_SE_MODE:
239 sdp->isp_ultramode = 1;
283 break;
284 case ISP1080_SE_MODE:
285 sdp->isp_ultramode = 1;
240 CFGPRINTF(m, isp->isp_name, 1, "Single-Ended");
286 isp_prt(isp, ISP_LOGCONFIG,
287 m, 1, "Single-Ended");
241 break;
242 default:
288 break;
289 default:
243 CFGPRINTF("%s: unknown mode on bus %d (0x%x)\n",
244 isp->isp_name, 1, l);
290 isp_prt(isp, ISP_LOGERR,
291 "unknown mode on bus %d (0x%x)", 1, l);
245 break;
246 }
247 }
248 } else {
249 sdparam *sdp = isp->isp_param;
250 i = ISP_READ(isp, BIU_CONF0) & BIU_CONF0_HW_MASK;
251 switch (i) {
252 default:
292 break;
293 }
294 }
295 } else {
296 sdparam *sdp = isp->isp_param;
297 i = ISP_READ(isp, BIU_CONF0) & BIU_CONF0_HW_MASK;
298 switch (i) {
299 default:
253 PRINTF("%s: unknown chip rev. 0x%x- assuming a 1020\n",
254 isp->isp_name, i);
300 isp_prt(isp, ISP_LOGALL, "Unknown Chip Type 0x%x", i);
255 /* FALLTHROUGH */
256 case 1:
257 revname = "1020";
258 isp->isp_type = ISP_HA_SCSI_1020;
259 isp->isp_clock = 40;
260 break;
261 case 2:
262 /*

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

289 isp->isp_clock = 60;
290 break;
291 }
292 /*
293 * Now, while we're at it, gather info about ultra
294 * and/or differential mode.
295 */
296 if (ISP_READ(isp, SXP_PINS_DIFF) & SXP_PINS_DIFF_MODE) {
301 /* FALLTHROUGH */
302 case 1:
303 revname = "1020";
304 isp->isp_type = ISP_HA_SCSI_1020;
305 isp->isp_clock = 40;
306 break;
307 case 2:
308 /*

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

335 isp->isp_clock = 60;
336 break;
337 }
338 /*
339 * Now, while we're at it, gather info about ultra
340 * and/or differential mode.
341 */
342 if (ISP_READ(isp, SXP_PINS_DIFF) & SXP_PINS_DIFF_MODE) {
297 CFGPRINTF("%s: Differential Mode\n", isp->isp_name);
343 isp_prt(isp, ISP_LOGCONFIG, "Differential Mode");
298 sdp->isp_diffmode = 1;
299 } else {
300 sdp->isp_diffmode = 0;
301 }
302 i = ISP_READ(isp, RISC_PSR);
303 if (isp->isp_bustype == ISP_BT_SBUS) {
304 i &= RISC_PSR_SBUS_ULTRA;
305 } else {
306 i &= RISC_PSR_PCI_ULTRA;
307 }
308 if (i != 0) {
344 sdp->isp_diffmode = 1;
345 } else {
346 sdp->isp_diffmode = 0;
347 }
348 i = ISP_READ(isp, RISC_PSR);
349 if (isp->isp_bustype == ISP_BT_SBUS) {
350 i &= RISC_PSR_SBUS_ULTRA;
351 } else {
352 i &= RISC_PSR_PCI_ULTRA;
353 }
354 if (i != 0) {
309 CFGPRINTF("%s: Ultra Mode Capable\n", isp->isp_name);
355 isp_prt(isp, ISP_LOGCONFIG, "Ultra Mode Capable");
310 sdp->isp_ultramode = 1;
311 /*
312 * If we're in Ultra Mode, we have to be 60Mhz clock-
313 * even for the SBus version.
314 */
315 isp->isp_clock = 60;
316 } else {
317 sdp->isp_ultramode = 0;

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

344 * and give the ISP a chance to recover.
345 */
346
347 if (IS_SCSI(isp)) {
348 ISP_WRITE(isp, BIU_ICR, BIU_ICR_SOFT_RESET);
349 /*
350 * A slight delay...
351 */
356 sdp->isp_ultramode = 1;
357 /*
358 * If we're in Ultra Mode, we have to be 60Mhz clock-
359 * even for the SBus version.
360 */
361 isp->isp_clock = 60;
362 } else {
363 sdp->isp_ultramode = 0;

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

390 * and give the ISP a chance to recover.
391 */
392
393 if (IS_SCSI(isp)) {
394 ISP_WRITE(isp, BIU_ICR, BIU_ICR_SOFT_RESET);
395 /*
396 * A slight delay...
397 */
352 SYS_DELAY(100);
398 USEC_DELAY(100);
353
399
354#if 0
355 PRINTF("%s: mbox0-5: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
356 isp->isp_name, ISP_READ(isp, OUTMAILBOX0),
357 ISP_READ(isp, OUTMAILBOX1), ISP_READ(isp, OUTMAILBOX2),
358 ISP_READ(isp, OUTMAILBOX3), ISP_READ(isp, OUTMAILBOX4),
359 ISP_READ(isp, OUTMAILBOX5));
360#endif
361
362 /*
363 * Clear data && control DMA engines.
364 */
365 ISP_WRITE(isp, CDMA_CONTROL,
366 DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT);
367 ISP_WRITE(isp, DDMA_CONTROL,
368 DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT);
369
370
371 } else {
372 ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET);
373 /*
374 * A slight delay...
375 */
400 /*
401 * Clear data && control DMA engines.
402 */
403 ISP_WRITE(isp, CDMA_CONTROL,
404 DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT);
405 ISP_WRITE(isp, DDMA_CONTROL,
406 DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT);
407
408
409 } else {
410 ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET);
411 /*
412 * A slight delay...
413 */
376 SYS_DELAY(100);
414 USEC_DELAY(100);
377
378 /*
379 * Clear data && control DMA engines.
380 */
381 ISP_WRITE(isp, CDMA2100_CONTROL,
382 DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
383 ISP_WRITE(isp, TDMA2100_CONTROL,
384 DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);

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

393 for (;;) {
394 if (IS_SCSI(isp)) {
395 if (!(ISP_READ(isp, BIU_ICR) & BIU_ICR_SOFT_RESET))
396 break;
397 } else {
398 if (!(ISP_READ(isp, BIU2100_CSR) & BIU2100_SOFT_RESET))
399 break;
400 }
415
416 /*
417 * Clear data && control DMA engines.
418 */
419 ISP_WRITE(isp, CDMA2100_CONTROL,
420 DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
421 ISP_WRITE(isp, TDMA2100_CONTROL,
422 DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);

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

431 for (;;) {
432 if (IS_SCSI(isp)) {
433 if (!(ISP_READ(isp, BIU_ICR) & BIU_ICR_SOFT_RESET))
434 break;
435 } else {
436 if (!(ISP_READ(isp, BIU2100_CSR) & BIU2100_SOFT_RESET))
437 break;
438 }
401 SYS_DELAY(100);
439 USEC_DELAY(100);
402 if (--loops < 0) {
440 if (--loops < 0) {
403 isp_dumpregs(isp, "chip reset timed out");
441 ISP_DUMPREGS(isp, "chip reset timed out");
404 return;
405 }
406 }
407
408 /*
409 * After we've fired this chip up, zero out the conf1 register
410 * for SCSI adapters and other settings for the 2100.
411 */
412
413 if (IS_SCSI(isp)) {
414 ISP_WRITE(isp, BIU_CONF1, 0);
415 } else {
416 ISP_WRITE(isp, BIU2100_CSR, 0);
417 }
418
419 /*
420 * Reset RISC Processor
421 */
422 ISP_WRITE(isp, HCCR, HCCR_CMD_RESET);
442 return;
443 }
444 }
445
446 /*
447 * After we've fired this chip up, zero out the conf1 register
448 * for SCSI adapters and other settings for the 2100.
449 */
450
451 if (IS_SCSI(isp)) {
452 ISP_WRITE(isp, BIU_CONF1, 0);
453 } else {
454 ISP_WRITE(isp, BIU2100_CSR, 0);
455 }
456
457 /*
458 * Reset RISC Processor
459 */
460 ISP_WRITE(isp, HCCR, HCCR_CMD_RESET);
423 SYS_DELAY(100);
461 USEC_DELAY(100);
424
425 /*
426 * Establish some initial burst rate stuff.
427 * (only for the 1XX0 boards). This really should
428 * be done later after fetching from NVRAM.
429 */
430 if (IS_SCSI(isp)) {
431 u_int16_t tmp = isp->isp_mdvec->dv_conf1;

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

467 */
468 ISP_RESET1(isp);
469
470 /*
471 * Wait for everything to finish firing up...
472 */
473 loops = MBOX_DELAY_COUNT;
474 while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) {
462
463 /*
464 * Establish some initial burst rate stuff.
465 * (only for the 1XX0 boards). This really should
466 * be done later after fetching from NVRAM.
467 */
468 if (IS_SCSI(isp)) {
469 u_int16_t tmp = isp->isp_mdvec->dv_conf1;

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

505 */
506 ISP_RESET1(isp);
507
508 /*
509 * Wait for everything to finish firing up...
510 */
511 loops = MBOX_DELAY_COUNT;
512 while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) {
475 SYS_DELAY(100);
513 USEC_DELAY(100);
476 if (--loops < 0) {
514 if (--loops < 0) {
477 PRINTF("%s: MBOX_BUSY never cleared on reset\n",
478 isp->isp_name);
515 isp_prt(isp, ISP_LOGERR,
516 "MBOX_BUSY never cleared on reset");
479 return;
480 }
481 }
482
483 /*
484 * Up until this point we've done everything by just reading or
485 * setting registers. From this point on we rely on at least *some*
486 * kind of firmware running in the card.
487 */
488
489 /*
490 * Do some sanity checking.
491 */
492 mbs.param[0] = MBOX_NO_OP;
517 return;
518 }
519 }
520
521 /*
522 * Up until this point we've done everything by just reading or
523 * setting registers. From this point on we rely on at least *some*
524 * kind of firmware running in the card.
525 */
526
527 /*
528 * Do some sanity checking.
529 */
530 mbs.param[0] = MBOX_NO_OP;
493 isp_mboxcmd(isp, &mbs);
531 isp_mboxcmd(isp, &mbs, MBLOGALL);
494 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
532 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
495 isp_dumpregs(isp, "NOP test failed");
496 return;
497 }
498
499 if (IS_SCSI(isp)) {
500 mbs.param[0] = MBOX_MAILBOX_REG_TEST;
501 mbs.param[1] = 0xdead;
502 mbs.param[2] = 0xbeef;
503 mbs.param[3] = 0xffff;
504 mbs.param[4] = 0x1111;
505 mbs.param[5] = 0xa5a5;
533 return;
534 }
535
536 if (IS_SCSI(isp)) {
537 mbs.param[0] = MBOX_MAILBOX_REG_TEST;
538 mbs.param[1] = 0xdead;
539 mbs.param[2] = 0xbeef;
540 mbs.param[3] = 0xffff;
541 mbs.param[4] = 0x1111;
542 mbs.param[5] = 0xa5a5;
506 isp_mboxcmd(isp, &mbs);
543 isp_mboxcmd(isp, &mbs, MBLOGALL);
507 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
544 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
508 isp_dumpregs(isp,
509 "Mailbox Register test didn't complete");
510 return;
511 }
512 if (mbs.param[1] != 0xdead || mbs.param[2] != 0xbeef ||
513 mbs.param[3] != 0xffff || mbs.param[4] != 0x1111 ||
514 mbs.param[5] != 0xa5a5) {
545 return;
546 }
547 if (mbs.param[1] != 0xdead || mbs.param[2] != 0xbeef ||
548 mbs.param[3] != 0xffff || mbs.param[4] != 0x1111 ||
549 mbs.param[5] != 0xa5a5) {
515 isp_dumpregs(isp, "Register Test Failed");
550 isp_prt(isp, ISP_LOGERR,
551 "Register Test Failed (0x%x 0x%x 0x%x 0x%x 0x%x)",
552 mbs.param[1], mbs.param[2], mbs.param[3],
553 mbs.param[4], mbs.param[5]);
516 return;
517 }
518
519 }
520
521 /*
522 * Download new Firmware, unless requested not to do so.
523 * This is made slightly trickier in some cases where the

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

528 * has disabled our download.
529 */
530 if ((isp->isp_mdvec->dv_ispfw == NULL) ||
531 (isp->isp_confopts & ISP_CFG_NORELOAD)) {
532 dodnld = 0;
533 }
534
535 if (dodnld) {
554 return;
555 }
556
557 }
558
559 /*
560 * Download new Firmware, unless requested not to do so.
561 * This is made slightly trickier in some cases where the

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

566 * has disabled our download.
567 */
568 if ((isp->isp_mdvec->dv_ispfw == NULL) ||
569 (isp->isp_confopts & ISP_CFG_NORELOAD)) {
570 dodnld = 0;
571 }
572
573 if (dodnld) {
536 u_int16_t fwlen = isp->isp_mdvec->dv_fwlen;
537 if (fwlen == 0)
538 fwlen = isp->isp_mdvec->dv_ispfw[3]; /* usually here */
574 u_int16_t fwlen = isp->isp_mdvec->dv_ispfw[3];
539 for (i = 0; i < fwlen; i++) {
540 mbs.param[0] = MBOX_WRITE_RAM_WORD;
575 for (i = 0; i < fwlen; i++) {
576 mbs.param[0] = MBOX_WRITE_RAM_WORD;
541 mbs.param[1] = isp->isp_mdvec->dv_codeorg + i;
577 mbs.param[1] = ISP_CODE_ORG + i;
542 mbs.param[2] = isp->isp_mdvec->dv_ispfw[i];
578 mbs.param[2] = isp->isp_mdvec->dv_ispfw[i];
543 isp_mboxcmd(isp, &mbs);
579 isp_mboxcmd(isp, &mbs, MBLOGNONE);
544 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
580 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
545 PRINTF("%s: F/W download failed at word %d\n",
546 isp->isp_name, i);
581 isp_prt(isp, ISP_LOGERR,
582 "F/W download failed at word %d", i);
547 dodnld = 0;
548 goto again;
549 }
550 }
551
552 /*
553 * Verify that it downloaded correctly.
554 */
555 mbs.param[0] = MBOX_VERIFY_CHECKSUM;
583 dodnld = 0;
584 goto again;
585 }
586 }
587
588 /*
589 * Verify that it downloaded correctly.
590 */
591 mbs.param[0] = MBOX_VERIFY_CHECKSUM;
556 mbs.param[1] = isp->isp_mdvec->dv_codeorg;
557 isp_mboxcmd(isp, &mbs);
592 mbs.param[1] = ISP_CODE_ORG;
593 isp_mboxcmd(isp, &mbs, MBLOGNONE);
558 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
594 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
559 isp_dumpregs(isp, "ram checksum failure");
595 isp_prt(isp, ISP_LOGERR, "Ram Checksum Failure");
560 return;
561 }
562 } else {
596 return;
597 }
598 } else {
563 IDPRINTF(3, ("%s: skipping f/w download\n", isp->isp_name));
599 isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download");
564 }
565
566 /*
567 * Now start it rolling.
568 *
569 * If we didn't actually download f/w,
570 * we still need to (re)start it.
571 */
572
573 mbs.param[0] = MBOX_EXEC_FIRMWARE;
600 }
601
602 /*
603 * Now start it rolling.
604 *
605 * If we didn't actually download f/w,
606 * we still need to (re)start it.
607 */
608
609 mbs.param[0] = MBOX_EXEC_FIRMWARE;
574 if (isp->isp_mdvec->dv_codeorg)
575 mbs.param[1] = isp->isp_mdvec->dv_codeorg;
576 else
577 mbs.param[1] = 0x1000;
578 isp_mboxcmd(isp, &mbs);
610 mbs.param[1] = ISP_CODE_ORG;
611 isp_mboxcmd(isp, &mbs, MBLOGNONE);
579 /* give it a chance to start */
612 /* give it a chance to start */
580 SYS_DELAY(500);
613 USEC_DELAY(500);
581
582 if (IS_SCSI(isp)) {
583 /*
584 * Set CLOCK RATE, but only if asked to.
585 */
586 if (isp->isp_clock) {
587 mbs.param[0] = MBOX_SET_CLOCK_RATE;
588 mbs.param[1] = isp->isp_clock;
614
615 if (IS_SCSI(isp)) {
616 /*
617 * Set CLOCK RATE, but only if asked to.
618 */
619 if (isp->isp_clock) {
620 mbs.param[0] = MBOX_SET_CLOCK_RATE;
621 mbs.param[1] = isp->isp_clock;
589 isp_mboxcmd(isp, &mbs);
590 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
591 PRINTF("failed to set clockrate (0x%x)\n",
592 mbs.param[0]);
593 /* but continue */
594 }
622 isp_mboxcmd(isp, &mbs, MBLOGALL);
623 /* we will try not to care if this fails */
595 }
596 }
624 }
625 }
626
597 mbs.param[0] = MBOX_ABOUT_FIRMWARE;
627 mbs.param[0] = MBOX_ABOUT_FIRMWARE;
598 isp_mboxcmd(isp, &mbs);
628 isp_mboxcmd(isp, &mbs, MBLOGALL);
599 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
629 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
600 PRINTF("could not get f/w started (0x%x)\n", mbs.param[0]);
601 return;
602 }
630 return;
631 }
603 CFGPRINTF("%s: Board Revision %s, %s F/W Revision %d.%d.%d\n",
604 isp->isp_name, revname, dodnld? "loaded" : "resident",
605 mbs.param[1], mbs.param[2], mbs.param[3]);
632 isp_prt(isp, ISP_LOGCONFIG,
633 "Board Revision %s, %s F/W Revision %d.%d.%d", revname,
634 dodnld? "loaded" : "resident", mbs.param[1], mbs.param[2],
635 mbs.param[3]);
606 if (IS_FC(isp)) {
607 if (ISP_READ(isp, BIU2100_CSR) & BIU2100_PCI64) {
636 if (IS_FC(isp)) {
637 if (ISP_READ(isp, BIU2100_CSR) & BIU2100_PCI64) {
608 CFGPRINTF("%s: in 64-Bit PCI slot\n", isp->isp_name);
638 isp_prt(isp, ISP_LOGCONFIG,
639 "Installed in 64-Bit PCI slot");
609 }
610 }
611
612 isp->isp_fwrev[0] = mbs.param[1];
613 isp->isp_fwrev[1] = mbs.param[2];
614 isp->isp_fwrev[2] = mbs.param[3];
615 if (isp->isp_romfw_rev[0] || isp->isp_romfw_rev[1] ||
616 isp->isp_romfw_rev[2]) {
640 }
641 }
642
643 isp->isp_fwrev[0] = mbs.param[1];
644 isp->isp_fwrev[1] = mbs.param[2];
645 isp->isp_fwrev[2] = mbs.param[3];
646 if (isp->isp_romfw_rev[0] || isp->isp_romfw_rev[1] ||
647 isp->isp_romfw_rev[2]) {
617 CFGPRINTF("%s: Last F/W revision was %d.%d.%d\n", isp->isp_name,
648 isp_prt(isp, ISP_LOGCONFIG, "Last F/W revision was %d.%d.%d",
618 isp->isp_romfw_rev[0], isp->isp_romfw_rev[1],
619 isp->isp_romfw_rev[2]);
620 }
621
622 mbs.param[0] = MBOX_GET_FIRMWARE_STATUS;
649 isp->isp_romfw_rev[0], isp->isp_romfw_rev[1],
650 isp->isp_romfw_rev[2]);
651 }
652
653 mbs.param[0] = MBOX_GET_FIRMWARE_STATUS;
623 isp_mboxcmd(isp, &mbs);
654 isp_mboxcmd(isp, &mbs, MBLOGALL);
624 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
655 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
625 PRINTF("%s: could not GET FIRMWARE STATUS\n", isp->isp_name);
626 return;
627 }
628 isp->isp_maxcmds = mbs.param[2];
656 return;
657 }
658 isp->isp_maxcmds = mbs.param[2];
629 CFGPRINTF("%s: %d max I/O commands supported\n",
630 isp->isp_name, mbs.param[2]);
659 isp_prt(isp, ISP_LOGINFO,
660 "%d max I/O commands supported", mbs.param[2]);
631 isp_fw_state(isp);
632
633 /*
634 * Set up DMA for the request and result mailboxes.
635 */
636 if (ISP_MBOXDMASETUP(isp) != 0) {
661 isp_fw_state(isp);
662
663 /*
664 * Set up DMA for the request and result mailboxes.
665 */
666 if (ISP_MBOXDMASETUP(isp) != 0) {
637 PRINTF("%s: can't setup dma mailboxes\n", isp->isp_name);
667 isp_prt(isp, ISP_LOGERR, "Cannot setup DMA");
638 return;
639 }
640 isp->isp_state = ISP_RESETSTATE;
641
642 /*
643 * Okay- now that we have new firmware running, we now (re)set our
644 * notion of how many luns we support. This is somewhat tricky because
645 * if we haven't loaded firmware, we don't have an easy way of telling

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

666 isp->isp_maxluns = 32;
667 } else {
668 isp->isp_maxluns = 65536;
669 }
670 } else {
671 if (IS_SCSI(isp)) {
672 isp->isp_maxluns = 8;
673 } else {
668 return;
669 }
670 isp->isp_state = ISP_RESETSTATE;
671
672 /*
673 * Okay- now that we have new firmware running, we now (re)set our
674 * notion of how many luns we support. This is somewhat tricky because
675 * if we haven't loaded firmware, we don't have an easy way of telling

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

696 isp->isp_maxluns = 32;
697 } else {
698 isp->isp_maxluns = 65536;
699 }
700 } else {
701 if (IS_SCSI(isp)) {
702 isp->isp_maxluns = 8;
703 } else {
674 PRINTF("%s: WARNING- cannot determine Expanded "
675 "LUN capability- limiting to one LUN\n",
676 isp->isp_name);
704 isp_prt(isp, ISP_LOGALL, warnlun);
677 isp->isp_maxluns = 1;
678 }
679 }
680 }
681}
682
683/*
684 * Initialize Parameters of Hardware to a known state.

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

692{
693 /*
694 * Must do this first to get defaults established.
695 */
696 isp_setdfltparm(isp, 0);
697 if (IS_DUALBUS(isp)) {
698 isp_setdfltparm(isp, 1);
699 }
705 isp->isp_maxluns = 1;
706 }
707 }
708 }
709}
710
711/*
712 * Initialize Parameters of Hardware to a known state.

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

720{
721 /*
722 * Must do this first to get defaults established.
723 */
724 isp_setdfltparm(isp, 0);
725 if (IS_DUALBUS(isp)) {
726 isp_setdfltparm(isp, 1);
727 }
700
701 if (IS_FC(isp)) {
702 isp_fibre_init(isp);
703 } else {
704 isp_scsi_init(isp);
705 }
706}
707
708static void

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

732 * You set both channels at the same time.
733 */
734 mbs.param[0] = MBOX_SET_RETRY_COUNT;
735 mbs.param[1] = sdp_chan0->isp_retry_count;
736 mbs.param[2] = sdp_chan0->isp_retry_delay;
737 mbs.param[6] = sdp_chan1->isp_retry_count;
738 mbs.param[7] = sdp_chan1->isp_retry_delay;
739
728 if (IS_FC(isp)) {
729 isp_fibre_init(isp);
730 } else {
731 isp_scsi_init(isp);
732 }
733}
734
735static void

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

759 * You set both channels at the same time.
760 */
761 mbs.param[0] = MBOX_SET_RETRY_COUNT;
762 mbs.param[1] = sdp_chan0->isp_retry_count;
763 mbs.param[2] = sdp_chan0->isp_retry_delay;
764 mbs.param[6] = sdp_chan1->isp_retry_count;
765 mbs.param[7] = sdp_chan1->isp_retry_delay;
766
740 isp_mboxcmd(isp, &mbs);
767 isp_mboxcmd(isp, &mbs, MBLOGALL);
741 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
768 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
742 PRINTF("%s: failed to set retry count and retry delay\n",
743 isp->isp_name);
744 return;
745 }
746
747 /*
748 * Set ASYNC DATA SETUP time. This is very important.
749 */
750 mbs.param[0] = MBOX_SET_ASYNC_DATA_SETUP_TIME;
751 mbs.param[1] = sdp_chan0->isp_async_data_setup;
752 mbs.param[2] = sdp_chan1->isp_async_data_setup;
769 return;
770 }
771
772 /*
773 * Set ASYNC DATA SETUP time. This is very important.
774 */
775 mbs.param[0] = MBOX_SET_ASYNC_DATA_SETUP_TIME;
776 mbs.param[1] = sdp_chan0->isp_async_data_setup;
777 mbs.param[2] = sdp_chan1->isp_async_data_setup;
753 isp_mboxcmd(isp, &mbs);
778 isp_mboxcmd(isp, &mbs, MBLOGALL);
754 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
779 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
755 PRINTF("%s: failed to set asynchronous data setup time\n",
756 isp->isp_name);
757 return;
758 }
759
760 /*
761 * Set ACTIVE Negation State.
762 */
763 mbs.param[0] = MBOX_SET_ACT_NEG_STATE;
764 mbs.param[1] =
765 (sdp_chan0->isp_req_ack_active_neg << 4) |
766 (sdp_chan0->isp_data_line_active_neg << 5);
767 mbs.param[2] =
768 (sdp_chan1->isp_req_ack_active_neg << 4) |
769 (sdp_chan1->isp_data_line_active_neg << 5);
770
780 return;
781 }
782
783 /*
784 * Set ACTIVE Negation State.
785 */
786 mbs.param[0] = MBOX_SET_ACT_NEG_STATE;
787 mbs.param[1] =
788 (sdp_chan0->isp_req_ack_active_neg << 4) |
789 (sdp_chan0->isp_data_line_active_neg << 5);
790 mbs.param[2] =
791 (sdp_chan1->isp_req_ack_active_neg << 4) |
792 (sdp_chan1->isp_data_line_active_neg << 5);
793
771 isp_mboxcmd(isp, &mbs);
794 isp_mboxcmd(isp, &mbs, MBLOGNONE);
772 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
795 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
773 PRINTF("%s: failed to set active negation state "
774 "(%d,%d),(%d,%d)\n", isp->isp_name,
796 isp_prt(isp, ISP_LOGERR,
797 "failed to set active negation state (%d,%d), (%d,%d)",
775 sdp_chan0->isp_req_ack_active_neg,
776 sdp_chan0->isp_data_line_active_neg,
777 sdp_chan1->isp_req_ack_active_neg,
778 sdp_chan1->isp_data_line_active_neg);
779 /*
780 * But don't return.
781 */
782 }
783
784 /*
785 * Set the Tag Aging limit
786 */
787 mbs.param[0] = MBOX_SET_TAG_AGE_LIMIT;
788 mbs.param[1] = sdp_chan0->isp_tag_aging;
789 mbs.param[2] = sdp_chan1->isp_tag_aging;
798 sdp_chan0->isp_req_ack_active_neg,
799 sdp_chan0->isp_data_line_active_neg,
800 sdp_chan1->isp_req_ack_active_neg,
801 sdp_chan1->isp_data_line_active_neg);
802 /*
803 * But don't return.
804 */
805 }
806
807 /*
808 * Set the Tag Aging limit
809 */
810 mbs.param[0] = MBOX_SET_TAG_AGE_LIMIT;
811 mbs.param[1] = sdp_chan0->isp_tag_aging;
812 mbs.param[2] = sdp_chan1->isp_tag_aging;
790 isp_mboxcmd(isp, &mbs);
813 isp_mboxcmd(isp, &mbs, MBLOGALL);
791 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
814 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
792 PRINTF("%s: failed to set tag age limit (%d,%d)\n",
793 isp->isp_name, sdp_chan0->isp_tag_aging,
794 sdp_chan1->isp_tag_aging);
815 isp_prt(isp, ISP_LOGERR, "failed to set tag age limit (%d,%d)",
816 sdp_chan0->isp_tag_aging, sdp_chan1->isp_tag_aging);
795 return;
796 }
797
798 /*
799 * Set selection timeout.
800 */
801 mbs.param[0] = MBOX_SET_SELECT_TIMEOUT;
802 mbs.param[1] = sdp_chan0->isp_selection_timeout;
803 mbs.param[2] = sdp_chan1->isp_selection_timeout;
817 return;
818 }
819
820 /*
821 * Set selection timeout.
822 */
823 mbs.param[0] = MBOX_SET_SELECT_TIMEOUT;
824 mbs.param[1] = sdp_chan0->isp_selection_timeout;
825 mbs.param[2] = sdp_chan1->isp_selection_timeout;
804 isp_mboxcmd(isp, &mbs);
826 isp_mboxcmd(isp, &mbs, MBLOGALL);
805 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
827 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
806 PRINTF("%s: failed to set selection timeout\n", isp->isp_name);
807 return;
808 }
809
810 /* now do per-channel settings */
811 isp_scsi_channel_init(isp, 0);
812 if (IS_DUALBUS(isp))
813 isp_scsi_channel_init(isp, 1);
814
815 /*
816 * Now enable request/response queues
817 */
818
819 mbs.param[0] = MBOX_INIT_RES_QUEUE;
828 return;
829 }
830
831 /* now do per-channel settings */
832 isp_scsi_channel_init(isp, 0);
833 if (IS_DUALBUS(isp))
834 isp_scsi_channel_init(isp, 1);
835
836 /*
837 * Now enable request/response queues
838 */
839
840 mbs.param[0] = MBOX_INIT_RES_QUEUE;
820 mbs.param[1] = RESULT_QUEUE_LEN;
841 mbs.param[1] = RESULT_QUEUE_LEN(isp);
821 mbs.param[2] = DMA_MSW(isp->isp_result_dma);
822 mbs.param[3] = DMA_LSW(isp->isp_result_dma);
823 mbs.param[4] = 0;
824 mbs.param[5] = 0;
842 mbs.param[2] = DMA_MSW(isp->isp_result_dma);
843 mbs.param[3] = DMA_LSW(isp->isp_result_dma);
844 mbs.param[4] = 0;
845 mbs.param[5] = 0;
825 isp_mboxcmd(isp, &mbs);
846 isp_mboxcmd(isp, &mbs, MBLOGALL);
826 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
847 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
827 PRINTF("%s: set of response queue failed\n", isp->isp_name);
828 return;
829 }
830 isp->isp_residx = 0;
831
832 mbs.param[0] = MBOX_INIT_REQ_QUEUE;
848 return;
849 }
850 isp->isp_residx = 0;
851
852 mbs.param[0] = MBOX_INIT_REQ_QUEUE;
833 mbs.param[1] = RQUEST_QUEUE_LEN;
853 mbs.param[1] = RQUEST_QUEUE_LEN(isp);
834 mbs.param[2] = DMA_MSW(isp->isp_rquest_dma);
835 mbs.param[3] = DMA_LSW(isp->isp_rquest_dma);
836 mbs.param[4] = 0;
837 mbs.param[5] = 0;
854 mbs.param[2] = DMA_MSW(isp->isp_rquest_dma);
855 mbs.param[3] = DMA_LSW(isp->isp_rquest_dma);
856 mbs.param[4] = 0;
857 mbs.param[5] = 0;
838 isp_mboxcmd(isp, &mbs);
858 isp_mboxcmd(isp, &mbs, MBLOGALL);
839 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
859 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
840 PRINTF("%s: set of request queue failed\n", isp->isp_name);
841 return;
842 }
843 isp->isp_reqidx = isp->isp_reqodx = 0;
844
845 /*
846 * Turn on Fast Posting, LVD transitions
847 *
848 * Ultra2 F/W always has had fast posting (and LVD transitions)

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

854 mbs.param[0] = MBOX_SET_FW_FEATURES;
855 mbs.param[1] = 0;
856 if (IS_ULTRA2(isp))
857 mbs.param[1] |= FW_FEATURE_LVD_NOTIFY;
858 if (IS_ULTRA2(isp) || IS_1240(isp))
859 mbs.param[1] |= FW_FEATURE_FAST_POST;
860 if (mbs.param[1] != 0) {
861 u_int16_t sfeat = mbs.param[1];
860 return;
861 }
862 isp->isp_reqidx = isp->isp_reqodx = 0;
863
864 /*
865 * Turn on Fast Posting, LVD transitions
866 *
867 * Ultra2 F/W always has had fast posting (and LVD transitions)

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

873 mbs.param[0] = MBOX_SET_FW_FEATURES;
874 mbs.param[1] = 0;
875 if (IS_ULTRA2(isp))
876 mbs.param[1] |= FW_FEATURE_LVD_NOTIFY;
877 if (IS_ULTRA2(isp) || IS_1240(isp))
878 mbs.param[1] |= FW_FEATURE_FAST_POST;
879 if (mbs.param[1] != 0) {
880 u_int16_t sfeat = mbs.param[1];
862 isp_mboxcmd(isp, &mbs);
863 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
864 PRINTF("%s: cannot enable FW features (0x%x)\n",
865 isp->isp_name, sfeat);
866 } else {
867 CFGPRINTF("%s: enabled FW features (0x%x)\n",
868 isp->isp_name, sfeat);
881 isp_mboxcmd(isp, &mbs, MBLOGALL);
882 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
883 isp_prt(isp, ISP_LOGINFO,
884 "Enabled FW features (0x%x)", sfeat);
869 }
870 }
871
872 /*
873 * Let the outer layers decide whether to issue a SCSI bus reset.
874 */
875 isp->isp_state = ISP_INITSTATE;
876}

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

887 sdp = isp->isp_param;
888 sdp += channel;
889
890 /*
891 * Set (possibly new) Initiator ID.
892 */
893 mbs.param[0] = MBOX_SET_INIT_SCSI_ID;
894 mbs.param[1] = (channel << 7) | sdp->isp_initiator_id;
885 }
886 }
887
888 /*
889 * Let the outer layers decide whether to issue a SCSI bus reset.
890 */
891 isp->isp_state = ISP_INITSTATE;
892}

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

903 sdp = isp->isp_param;
904 sdp += channel;
905
906 /*
907 * Set (possibly new) Initiator ID.
908 */
909 mbs.param[0] = MBOX_SET_INIT_SCSI_ID;
910 mbs.param[1] = (channel << 7) | sdp->isp_initiator_id;
895 isp_mboxcmd(isp, &mbs);
911 isp_mboxcmd(isp, &mbs, MBLOGALL);
896 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
912 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
897 PRINTF("%s: cannot set initiator id on bus %d to %d\n",
898 isp->isp_name, channel, sdp->isp_initiator_id);
899 return;
900 }
901
902 /*
903 * Set current per-target parameters to a safe minimum.
904 */
905 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
906 int lun;
907 u_int16_t sdf;
908
909 if (sdp->isp_devparam[tgt].dev_enable == 0) {
913 return;
914 }
915
916 /*
917 * Set current per-target parameters to a safe minimum.
918 */
919 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
920 int lun;
921 u_int16_t sdf;
922
923 if (sdp->isp_devparam[tgt].dev_enable == 0) {
910 IDPRINTF(2, ("%s: skipping target %d bus %d settings\n",
911 isp->isp_name, tgt, channel));
912 continue;
913 }
914
915 /*
916 * If we're in LVD mode, then we pretty much should
917 * only disable tagged queuing.
918 */
919 if (IS_ULTRA2(isp) && sdp->isp_lvdmode) {

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

934 }
935 }
936 mbs.param[0] = MBOX_SET_TARGET_PARAMS;
937 mbs.param[1] = (tgt << 8) | (channel << 15);
938 mbs.param[2] = sdf;
939 mbs.param[3] =
940 (sdp->isp_devparam[tgt].sync_offset << 8) |
941 (sdp->isp_devparam[tgt].sync_period);
924 continue;
925 }
926
927 /*
928 * If we're in LVD mode, then we pretty much should
929 * only disable tagged queuing.
930 */
931 if (IS_ULTRA2(isp) && sdp->isp_lvdmode) {

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

946 }
947 }
948 mbs.param[0] = MBOX_SET_TARGET_PARAMS;
949 mbs.param[1] = (tgt << 8) | (channel << 15);
950 mbs.param[2] = sdf;
951 mbs.param[3] =
952 (sdp->isp_devparam[tgt].sync_offset << 8) |
953 (sdp->isp_devparam[tgt].sync_period);
942 isp_mboxcmd(isp, &mbs);
954 isp_mboxcmd(isp, &mbs, MBLOGALL);
943 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
944 sdf = DPARM_SAFE_DFLT;
945 mbs.param[0] = MBOX_SET_TARGET_PARAMS;
946 mbs.param[1] = (tgt << 8) | (channel << 15);
947 mbs.param[2] = sdf;
948 mbs.param[3] =
949 (sdp->isp_devparam[tgt].sync_offset << 8) |
950 (sdp->isp_devparam[tgt].sync_period);
955 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
956 sdf = DPARM_SAFE_DFLT;
957 mbs.param[0] = MBOX_SET_TARGET_PARAMS;
958 mbs.param[1] = (tgt << 8) | (channel << 15);
959 mbs.param[2] = sdf;
960 mbs.param[3] =
961 (sdp->isp_devparam[tgt].sync_offset << 8) |
962 (sdp->isp_devparam[tgt].sync_period);
951 isp_mboxcmd(isp, &mbs);
963 isp_mboxcmd(isp, &mbs, MBLOGALL);
952 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
964 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
953 PRINTF("%s: failed even to set defaults for "
954 "target %d\n", isp->isp_name, tgt);
955 continue;
956 }
957 }
958#if 0
959 /*
960 * We don't update dev_flags with what we've set
961 * because that's not the ultimate goal setting.
962 * If we succeed with the command, we *do* update
963 * cur_dflags by getting target parameters.
964 */
965 mbs.param[0] = MBOX_GET_TARGET_PARAMS;
966 mbs.param[1] = (tgt << 8) | (channel << 15);
965 continue;
966 }
967 }
968#if 0
969 /*
970 * We don't update dev_flags with what we've set
971 * because that's not the ultimate goal setting.
972 * If we succeed with the command, we *do* update
973 * cur_dflags by getting target parameters.
974 */
975 mbs.param[0] = MBOX_GET_TARGET_PARAMS;
976 mbs.param[1] = (tgt << 8) | (channel << 15);
967 isp_mboxcmd(isp, &mbs);
977 isp_mboxcmd(isp, &mbs, MBLOGALL);
968 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
969 /*
970 * Urrr.... We'll set cur_dflags to DPARM_SAFE_DFLT so
971 * we don't try and do tags if tags aren't enabled.
972 */
973 sdp->isp_devparam[tgt].cur_dflags = DPARM_SAFE_DFLT;
974 } else {
975 sdp->isp_devparam[tgt].cur_dflags = mbs.param[2];
976 sdp->isp_devparam[tgt].cur_offset = mbs.param[3] >> 8;
977 sdp->isp_devparam[tgt].cur_period = mbs.param[3] & 0xff;
978 }
978 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
979 /*
980 * Urrr.... We'll set cur_dflags to DPARM_SAFE_DFLT so
981 * we don't try and do tags if tags aren't enabled.
982 */
983 sdp->isp_devparam[tgt].cur_dflags = DPARM_SAFE_DFLT;
984 } else {
985 sdp->isp_devparam[tgt].cur_dflags = mbs.param[2];
986 sdp->isp_devparam[tgt].cur_offset = mbs.param[3] >> 8;
987 sdp->isp_devparam[tgt].cur_period = mbs.param[3] & 0xff;
988 }
979 IDPRINTF(3, ("%s: set flags 0x%x got 0x%x back for target %d\n",
980 isp->isp_name, sdf, mbs.param[2], tgt));
989 isp_prt(isp, ISP_LOGTDEBUG0,
990 "set flags 0x%x got 0x%x back for target %d",
991 sdf, mbs.param[2], tgt);
981
982#else
983 /*
984 * We don't update any information because we need to run
985 * at least one command per target to cause a new state
986 * to be latched.
987 */
988#endif
989 /*
990 * Ensure that we don't believe tagged queuing is enabled yet.
991 * It turns out that sometimes the ISP just ignores our
992 * attempts to set parameters for devices that it hasn't
993 * seen yet.
994 */
995 sdp->isp_devparam[tgt].cur_dflags &= ~DPARM_TQING;
992
993#else
994 /*
995 * We don't update any information because we need to run
996 * at least one command per target to cause a new state
997 * to be latched.
998 */
999#endif
1000 /*
1001 * Ensure that we don't believe tagged queuing is enabled yet.
1002 * It turns out that sometimes the ISP just ignores our
1003 * attempts to set parameters for devices that it hasn't
1004 * seen yet.
1005 */
1006 sdp->isp_devparam[tgt].cur_dflags &= ~DPARM_TQING;
996 for (lun = 0; lun < isp->isp_maxluns; lun++) {
1007 for (lun = 0; lun < (int) isp->isp_maxluns; lun++) {
997 mbs.param[0] = MBOX_SET_DEV_QUEUE_PARAMS;
998 mbs.param[1] = (channel << 15) | (tgt << 8) | lun;
999 mbs.param[2] = sdp->isp_max_queue_depth;
1000 mbs.param[3] = sdp->isp_devparam[tgt].exc_throttle;
1008 mbs.param[0] = MBOX_SET_DEV_QUEUE_PARAMS;
1009 mbs.param[1] = (channel << 15) | (tgt << 8) | lun;
1010 mbs.param[2] = sdp->isp_max_queue_depth;
1011 mbs.param[3] = sdp->isp_devparam[tgt].exc_throttle;
1001 isp_mboxcmd(isp, &mbs);
1012 isp_mboxcmd(isp, &mbs, MBLOGALL);
1002 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1013 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1003 PRINTF("%s: failed to set device queue "
1004 "parameters for target %d, lun %d\n",
1005 isp->isp_name, tgt, lun);
1006 break;
1007 }
1008 }
1009 }
1010}
1011
1012/*
1013 * Fibre Channel specific initialization.

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

1020{
1021 fcparam *fcp;
1022 isp_icb_t *icbp;
1023 mbreg_t mbs;
1024 int loopid;
1025
1026 fcp = isp->isp_param;
1027
1014 break;
1015 }
1016 }
1017 }
1018}
1019
1020/*
1021 * Fibre Channel specific initialization.

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

1028{
1029 fcparam *fcp;
1030 isp_icb_t *icbp;
1031 mbreg_t mbs;
1032 int loopid;
1033
1034 fcp = isp->isp_param;
1035
1028 /*
1029 * For systems that don't have BIOS methods for which
1030 * we can easily change the NVRAM based loopid, we'll
1031 * override that here. Note that when we initialize
1032 * the firmware we may get back a different loopid than
1033 * we asked for anyway. XXX This is probably not the
1034 * best way to figure this out XXX
1035 */
1036#ifndef __i386__
1037 loopid = DEFAULT_LOOPID(isp);
1036 loopid = DEFAULT_LOOPID(isp);
1038#else
1039 loopid = fcp->isp_loopid;
1040#endif
1041
1042 icbp = (isp_icb_t *) fcp->isp_scratch;
1043 MEMZERO(icbp, sizeof (*icbp));
1044
1045 icbp->icb_version = ICB_VERSION1;
1046#ifdef ISP_TARGET_MODE
1047 fcp->isp_fwoptions = ICBOPT_TGT_ENABLE;
1048#else
1049 fcp->isp_fwoptions = 0;

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

1075 * We don't set ICBOPT_PORTNAME because we want our
1076 * Node Name && Port Names to be distinct.
1077 */
1078
1079 icbp->icb_fwoptions = fcp->isp_fwoptions;
1080 icbp->icb_maxfrmlen = fcp->isp_maxfrmlen;
1081 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN ||
1082 icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) {
1037 icbp = (isp_icb_t *) fcp->isp_scratch;
1038 MEMZERO(icbp, sizeof (*icbp));
1039
1040 icbp->icb_version = ICB_VERSION1;
1041#ifdef ISP_TARGET_MODE
1042 fcp->isp_fwoptions = ICBOPT_TGT_ENABLE;
1043#else
1044 fcp->isp_fwoptions = 0;

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

1070 * We don't set ICBOPT_PORTNAME because we want our
1071 * Node Name && Port Names to be distinct.
1072 */
1073
1074 icbp->icb_fwoptions = fcp->isp_fwoptions;
1075 icbp->icb_maxfrmlen = fcp->isp_maxfrmlen;
1076 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN ||
1077 icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) {
1083 PRINTF("%s: bad frame length (%d) from NVRAM- using %d\n",
1084 isp->isp_name, fcp->isp_maxfrmlen, ICB_DFLT_FRMLEN);
1078 isp_prt(isp, ISP_LOGERR,
1079 "bad frame length (%d) from NVRAM- using %d",
1080 fcp->isp_maxfrmlen, ICB_DFLT_FRMLEN);
1085 icbp->icb_maxfrmlen = ICB_DFLT_FRMLEN;
1086 }
1087 icbp->icb_maxalloc = fcp->isp_maxalloc;
1088 if (icbp->icb_maxalloc < 1) {
1081 icbp->icb_maxfrmlen = ICB_DFLT_FRMLEN;
1082 }
1083 icbp->icb_maxalloc = fcp->isp_maxalloc;
1084 if (icbp->icb_maxalloc < 1) {
1089 PRINTF("%s: bad maximum allocation (%d)- using 16\n",
1090 isp->isp_name, fcp->isp_maxalloc);
1085 isp_prt(isp, ISP_LOGERR,
1086 "bad maximum allocation (%d)- using 16", fcp->isp_maxalloc);
1091 icbp->icb_maxalloc = 16;
1092 }
1093 icbp->icb_execthrottle = fcp->isp_execthrottle;
1094 if (icbp->icb_execthrottle < 1) {
1087 icbp->icb_maxalloc = 16;
1088 }
1089 icbp->icb_execthrottle = fcp->isp_execthrottle;
1090 if (icbp->icb_execthrottle < 1) {
1095 PRINTF("%s: bad execution throttle of %d- using 16\n",
1096 isp->isp_name, fcp->isp_execthrottle);
1091 isp_prt(isp, ISP_LOGERR,
1092 "bad execution throttle of %d- using 16",
1093 fcp->isp_execthrottle);
1097 icbp->icb_execthrottle = ICB_DFLT_THROTTLE;
1098 }
1099 icbp->icb_retry_delay = fcp->isp_retry_delay;
1100 icbp->icb_retry_count = fcp->isp_retry_count;
1101 icbp->icb_hardaddr = loopid;
1102#ifdef PRET_A_PORTE
1103 if (IS_2200(isp)) {
1104 icbp->icb_fwoptions |= ICBOPT_EXTENDED;

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

1114 icbp->icb_logintime = 60; /* 60 second login timeout */
1115
1116 if (fcp->isp_nodewwn) {
1117 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_nodewwn);
1118 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_portwwn);
1119 } else {
1120 fcp->isp_fwoptions &= ~(ICBOPT_USE_PORTNAME|ICBOPT_FULL_LOGIN);
1121 }
1094 icbp->icb_execthrottle = ICB_DFLT_THROTTLE;
1095 }
1096 icbp->icb_retry_delay = fcp->isp_retry_delay;
1097 icbp->icb_retry_count = fcp->isp_retry_count;
1098 icbp->icb_hardaddr = loopid;
1099#ifdef PRET_A_PORTE
1100 if (IS_2200(isp)) {
1101 icbp->icb_fwoptions |= ICBOPT_EXTENDED;

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

1111 icbp->icb_logintime = 60; /* 60 second login timeout */
1112
1113 if (fcp->isp_nodewwn) {
1114 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_nodewwn);
1115 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_portwwn);
1116 } else {
1117 fcp->isp_fwoptions &= ~(ICBOPT_USE_PORTNAME|ICBOPT_FULL_LOGIN);
1118 }
1122 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN;
1123 icbp->icb_rsltqlen = RESULT_QUEUE_LEN;
1119 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp);
1120 icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp);
1124 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_rquest_dma);
1125 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_rquest_dma);
1126 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_result_dma);
1127 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_result_dma);
1128 ISP_SWIZZLE_ICB(isp, icbp);
1129
1130 /*
1131 * Do this *before* initializing the firmware.
1132 */
1133 isp_mark_getpdb_all(isp);
1134 fcp->isp_fwstate = FW_CONFIG_WAIT;
1135 fcp->isp_loopstate = LOOP_NIL;
1136
1121 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_rquest_dma);
1122 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_rquest_dma);
1123 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_result_dma);
1124 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_result_dma);
1125 ISP_SWIZZLE_ICB(isp, icbp);
1126
1127 /*
1128 * Do this *before* initializing the firmware.
1129 */
1130 isp_mark_getpdb_all(isp);
1131 fcp->isp_fwstate = FW_CONFIG_WAIT;
1132 fcp->isp_loopstate = LOOP_NIL;
1133
1137 MemoryBarrier();
1138 for (;;) {
1139 mbs.param[0] = MBOX_INIT_FIRMWARE;
1140 mbs.param[1] = 0;
1141 mbs.param[2] = DMA_MSW(fcp->isp_scdma);
1142 mbs.param[3] = DMA_LSW(fcp->isp_scdma);
1143 mbs.param[4] = 0;
1144 mbs.param[5] = 0;
1145 mbs.param[6] = 0;
1146 mbs.param[7] = 0;
1147 isp_mboxcmd(isp, &mbs);
1148 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1149 PRINTF("%s: INIT FIRMWARE failed (code 0x%x)\n",
1150 isp->isp_name, mbs.param[0]);
1151 if (mbs.param[0] & 0x8000) {
1152 SYS_DELAY(1000);
1153 continue;
1154 }
1155 return;
1156 }
1157 break;
1134 mbs.param[0] = MBOX_INIT_FIRMWARE;
1135 mbs.param[1] = 0;
1136 mbs.param[2] = DMA_MSW(fcp->isp_scdma);
1137 mbs.param[3] = DMA_LSW(fcp->isp_scdma);
1138 mbs.param[4] = 0;
1139 mbs.param[5] = 0;
1140 mbs.param[6] = 0;
1141 mbs.param[7] = 0;
1142 isp_mboxcmd(isp, &mbs, MBLOGALL);
1143 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1144 return;
1158 }
1145 }
1159
1160 isp->isp_reqidx = isp->isp_reqodx = 0;
1161 isp->isp_residx = 0;
1162 isp->isp_sendmarker = 1;
1163
1164 /*
1165 * Whatever happens, we're now committed to being here.
1166 */
1167 isp->isp_state = ISP_INITSTATE;

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

1202 * Unneeded. For the 2100, except for initializing f/w, registers
1203 * 4/5 have to not be written to.
1204 * mbs.param[4] = 0;
1205 * mbs.param[5] = 0;
1206 *
1207 */
1208 mbs.param[6] = 0;
1209 mbs.param[7] = 0;
1146 isp->isp_reqidx = isp->isp_reqodx = 0;
1147 isp->isp_residx = 0;
1148 isp->isp_sendmarker = 1;
1149
1150 /*
1151 * Whatever happens, we're now committed to being here.
1152 */
1153 isp->isp_state = ISP_INITSTATE;

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

1188 * Unneeded. For the 2100, except for initializing f/w, registers
1189 * 4/5 have to not be written to.
1190 * mbs.param[4] = 0;
1191 * mbs.param[5] = 0;
1192 *
1193 */
1194 mbs.param[6] = 0;
1195 mbs.param[7] = 0;
1210 isp_mboxcmd(isp, &mbs);
1211 switch (mbs.param[0]) {
1212 case MBOX_COMMAND_COMPLETE:
1213 MemoryBarrier();
1196 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR);
1197 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1214 ISP_UNSWIZZLE_AND_COPY_PDBP(isp, pdbp, fcp->isp_scratch);
1198 ISP_UNSWIZZLE_AND_COPY_PDBP(isp, pdbp, fcp->isp_scratch);
1215 break;
1216 case MBOX_HOST_INTERFACE_ERROR:
1217 PRINTF("%s: DMA error getting port database\n", isp->isp_name);
1218 return (-1);
1219 case MBOX_COMMAND_PARAM_ERROR:
1220 /* Not Logged In */
1221 IDPRINTF(3, ("%s: Param Error on Get Port Database for id %d\n",
1222 isp->isp_name, id));
1223 return (-1);
1224 default:
1225 PRINTF("%s: error 0x%x getting port database for ID %d\n",
1226 isp->isp_name, mbs.param[0], id);
1227 return (-1);
1199 return (0);
1228 }
1200 }
1229 return (0);
1201 return (-1);
1230}
1231
1232static u_int64_t
1233isp_get_portname(isp, loopid, nodename)
1234 struct ispsoftc *isp;
1235 int loopid;
1236 int nodename;
1237{
1238 u_int64_t wwn = 0;
1239 mbreg_t mbs;
1240
1241 mbs.param[0] = MBOX_GET_PORT_NAME;
1242 mbs.param[1] = loopid << 8;
1243 if (nodename)
1244 mbs.param[1] |= 1;
1202}
1203
1204static u_int64_t
1205isp_get_portname(isp, loopid, nodename)
1206 struct ispsoftc *isp;
1207 int loopid;
1208 int nodename;
1209{
1210 u_int64_t wwn = 0;
1211 mbreg_t mbs;
1212
1213 mbs.param[0] = MBOX_GET_PORT_NAME;
1214 mbs.param[1] = loopid << 8;
1215 if (nodename)
1216 mbs.param[1] |= 1;
1245 isp_mboxcmd(isp, &mbs);
1217 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR);
1246 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1247 wwn =
1248 (((u_int64_t)(mbs.param[2] & 0xff)) << 56) |
1249 (((u_int64_t)(mbs.param[2] >> 8)) << 48) |
1250 (((u_int64_t)(mbs.param[3] & 0xff)) << 40) |
1251 (((u_int64_t)(mbs.param[3] >> 8)) << 32) |
1252 (((u_int64_t)(mbs.param[6] & 0xff)) << 24) |
1253 (((u_int64_t)(mbs.param[6] >> 8)) << 16) |
1254 (((u_int64_t)(mbs.param[7] & 0xff)) << 8) |
1255 (((u_int64_t)(mbs.param[7] >> 8)));
1256 }
1257 return (wwn);
1258}
1259
1260/*
1261 * Make sure we have good FC link and know our Loop ID.
1262 */
1263
1264static int
1218 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1219 wwn =
1220 (((u_int64_t)(mbs.param[2] & 0xff)) << 56) |
1221 (((u_int64_t)(mbs.param[2] >> 8)) << 48) |
1222 (((u_int64_t)(mbs.param[3] & 0xff)) << 40) |
1223 (((u_int64_t)(mbs.param[3] >> 8)) << 32) |
1224 (((u_int64_t)(mbs.param[6] & 0xff)) << 24) |
1225 (((u_int64_t)(mbs.param[6] >> 8)) << 16) |
1226 (((u_int64_t)(mbs.param[7] & 0xff)) << 8) |
1227 (((u_int64_t)(mbs.param[7] >> 8)));
1228 }
1229 return (wwn);
1230}
1231
1232/*
1233 * Make sure we have good FC link and know our Loop ID.
1234 */
1235
1236static int
1265isp_fclink_test(isp, waitdelay)
1237isp_fclink_test(isp, usdelay)
1266 struct ispsoftc *isp;
1238 struct ispsoftc *isp;
1267 int waitdelay;
1239 int usdelay;
1268{
1269 static char *toponames[] = {
1270 "Private Loop",
1271 "FL Port",
1272 "N-Port to N-Port",
1273 "F Port",
1274 "F Port (no FLOGI_ACC response)"
1275 };
1276 mbreg_t mbs;
1277 int count;
1278 u_int8_t lwfs;
1279 fcparam *fcp;
1280#if defined(ISP2100_FABRIC)
1281 isp_pdb_t pdb;
1282#endif
1283 fcp = isp->isp_param;
1284
1285 /*
1240{
1241 static char *toponames[] = {
1242 "Private Loop",
1243 "FL Port",
1244 "N-Port to N-Port",
1245 "F Port",
1246 "F Port (no FLOGI_ACC response)"
1247 };
1248 mbreg_t mbs;
1249 int count;
1250 u_int8_t lwfs;
1251 fcparam *fcp;
1252#if defined(ISP2100_FABRIC)
1253 isp_pdb_t pdb;
1254#endif
1255 fcp = isp->isp_param;
1256
1257 /*
1258 * XXX: Here is where we would start a 'loop dead' timeout
1259 */
1260
1261 /*
1286 * Wait up to N microseconds for F/W to go to a ready state.
1287 */
1288 lwfs = FW_CONFIG_WAIT;
1262 * Wait up to N microseconds for F/W to go to a ready state.
1263 */
1264 lwfs = FW_CONFIG_WAIT;
1289 for (count = 0; count < waitdelay; count += 100) {
1265 count = 0;
1266 while (count < usdelay) {
1267 u_int64_t enano;
1268 u_int32_t wrk;
1269 NANOTIME_T hra, hrb;
1270
1271 GET_NANOTIME(&hra);
1290 isp_fw_state(isp);
1291 if (lwfs != fcp->isp_fwstate) {
1272 isp_fw_state(isp);
1273 if (lwfs != fcp->isp_fwstate) {
1292 PRINTF("%s: Firmware State %s -> %s\n",
1293 isp->isp_name, isp2100_fw_statename((int)lwfs),
1274 isp_prt(isp, ISP_LOGINFO, "Firmware State <%s->%s>",
1275 isp2100_fw_statename((int)lwfs),
1294 isp2100_fw_statename((int)fcp->isp_fwstate));
1295 lwfs = fcp->isp_fwstate;
1296 }
1297 if (fcp->isp_fwstate == FW_READY) {
1298 break;
1299 }
1276 isp2100_fw_statename((int)fcp->isp_fwstate));
1277 lwfs = fcp->isp_fwstate;
1278 }
1279 if (fcp->isp_fwstate == FW_READY) {
1280 break;
1281 }
1300 SYS_DELAY(100); /* wait 100 microseconds */
1282 GET_NANOTIME(&hrb);
1283
1284 /*
1285 * Get the elapsed time in nanoseconds.
1286 * Always guaranteed to be non-zero.
1287 */
1288 enano = NANOTIME_SUB(&hrb, &hra);
1289
1290 /*
1291 * If the elapsed time is less than 1 millisecond,
1292 * delay a period of time up to that millisecond of
1293 * waiting.
1294 */
1295 isp_prt(isp, ISP_LOGDEBUG3, "usec%d: 0x%lx->0x%lx enano %u",
1296 count, GET_NANOSEC(&hra), GET_NANOSEC(&hrb), enano);
1297
1298 /*
1299 * This peculiar code is an attempt to try and avoid
1300 * invoking u_int64_t math support functions for some
1301 * platforms where linkage is a problem.
1302 */
1303 if (enano < (1000 * 1000)) {
1304 count += 1000;
1305 enano = (1000 * 1000) - enano;
1306 while (enano > (u_int64_t) 4000000000U) {
1307 USEC_DELAY(4000000);
1308 enano -= (u_int64_t) 4000000000U;
1309 }
1310 wrk = enano;
1311 USEC_DELAY(wrk/1000);
1312 } else {
1313 while (enano > (u_int64_t) 4000000000U) {
1314 count += 4000000;
1315 enano -= (u_int64_t) 4000000000U;
1316 }
1317 wrk = enano;
1318 count += (wrk / 1000);
1319 }
1301 }
1302
1303 /*
1304 * If we haven't gone to 'ready' state, return.
1305 */
1306 if (fcp->isp_fwstate != FW_READY) {
1307 return (-1);
1308 }
1309
1310 /*
1311 * Get our Loop ID (if possible). We really need to have it.
1312 */
1313 mbs.param[0] = MBOX_GET_LOOP_ID;
1320 }
1321
1322 /*
1323 * If we haven't gone to 'ready' state, return.
1324 */
1325 if (fcp->isp_fwstate != FW_READY) {
1326 return (-1);
1327 }
1328
1329 /*
1330 * Get our Loop ID (if possible). We really need to have it.
1331 */
1332 mbs.param[0] = MBOX_GET_LOOP_ID;
1314 isp_mboxcmd(isp, &mbs);
1333 isp_mboxcmd(isp, &mbs, MBLOGALL);
1315 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1334 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1316 PRINTF("%s: GET LOOP ID failed\n", isp->isp_name);
1317 return (-1);
1318 }
1319 fcp->isp_loopid = mbs.param[1];
1320 if (IS_2200(isp)) {
1321 int topo = (int) mbs.param[6];
1322 if (topo < TOPO_NL_PORT || topo > TOPO_PTP_STUB)
1323 topo = TOPO_PTP_STUB;
1324 fcp->isp_topo = topo;

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

1376 fcp->isp_portid = mbs.param[2];
1377 fcp->isp_onfabric = 0;
1378#if 0
1379 isp->isp_rfabric = 0;
1380#endif
1381 fcp->portdb[FL_PORT_ID].valid = 0;
1382 }
1383
1335 return (-1);
1336 }
1337 fcp->isp_loopid = mbs.param[1];
1338 if (IS_2200(isp)) {
1339 int topo = (int) mbs.param[6];
1340 if (topo < TOPO_NL_PORT || topo > TOPO_PTP_STUB)
1341 topo = TOPO_PTP_STUB;
1342 fcp->isp_topo = topo;

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

1394 fcp->isp_portid = mbs.param[2];
1395 fcp->isp_onfabric = 0;
1396#if 0
1397 isp->isp_rfabric = 0;
1398#endif
1399 fcp->portdb[FL_PORT_ID].valid = 0;
1400 }
1401
1384 CFGPRINTF("%s: Loop ID %d, AL_PA 0x%x, Port ID 0x%x Loop State "
1385 "0x%x topology '%s'\n", isp->isp_name, fcp->isp_loopid,
1386 fcp->isp_alpa, fcp->isp_portid, fcp->isp_loopstate,
1387 toponames[fcp->isp_topo]);
1402 isp_prt(isp, ISP_LOGINFO, topology, fcp->isp_loopid, fcp->isp_alpa,
1403 fcp->isp_portid, fcp->isp_loopstate, toponames[fcp->isp_topo]);
1388
1389 return (0);
1390}
1391
1404
1405 return (0);
1406}
1407
1392/*
1393 * Compare two local port db entities and return 1 if they're the same, else 0.
1394 */
1408static char *
1409isp2100_fw_statename(state)
1410 int state;
1411{
1412 switch(state) {
1413 case FW_CONFIG_WAIT: return "Config Wait";
1414 case FW_WAIT_AL_PA: return "Waiting for AL_PA";
1415 case FW_WAIT_LOGIN: return "Wait Login";
1416 case FW_READY: return "Ready";
1417 case FW_LOSS_OF_SYNC: return "Loss Of Sync";
1418 case FW_ERROR: return "Error";
1419 case FW_REINIT: return "Re-Init";
1420 case FW_NON_PART: return "Nonparticipating";
1421 default: return "?????";
1422 }
1423}
1395
1396static int
1397isp_same_lportdb(a, b)
1398 struct lportdb *a, *b;
1399{
1400 /*
1401 * We decide two lports are the same if they have non-zero and
1402 * identical port WWNs and identical loop IDs.

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

1497 * If the returned database element doesn't match what we
1498 * asked for, restart the process entirely (up to a point...).
1499 */
1500 if (pdb.pdb_loopid != loopid) {
1501 loopid = 0;
1502 if (lim++ < FL_PORT_ID) {
1503 continue;
1504 }
1424
1425static int
1426isp_same_lportdb(a, b)
1427 struct lportdb *a, *b;
1428{
1429 /*
1430 * We decide two lports are the same if they have non-zero and
1431 * identical port WWNs and identical loop IDs.

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

1526 * If the returned database element doesn't match what we
1527 * asked for, restart the process entirely (up to a point...).
1528 */
1529 if (pdb.pdb_loopid != loopid) {
1530 loopid = 0;
1531 if (lim++ < FL_PORT_ID) {
1532 continue;
1533 }
1505 PRINTF("%s: giving up on synchronizing the port "
1506 "database\n", isp->isp_name);
1534 isp_prt(isp, ISP_LOGWARN,
1535 "giving up on synchronizing the port database");
1507 return (-1);
1508 }
1509
1510 /*
1511 * Save the pertinent info locally.
1512 */
1513 lp->node_wwn =
1514 (((u_int64_t)pdb.pdb_nodename[0]) << 56) |

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

1602 continue;
1603 /*
1604 * We found this WWN elsewhere- it's changed
1605 * loopids then. We don't change it's actual
1606 * position in our cached port database- we
1607 * just change the actual loop ID we'd use.
1608 */
1609 if (fcp->portdb[i].loopid != loopid) {
1536 return (-1);
1537 }
1538
1539 /*
1540 * Save the pertinent info locally.
1541 */
1542 lp->node_wwn =
1543 (((u_int64_t)pdb.pdb_nodename[0]) << 56) |

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

1631 continue;
1632 /*
1633 * We found this WWN elsewhere- it's changed
1634 * loopids then. We don't change it's actual
1635 * position in our cached port database- we
1636 * just change the actual loop ID we'd use.
1637 */
1638 if (fcp->portdb[i].loopid != loopid) {
1610 PRINTF("%s: Target ID %d Loop 0x%x (Port 0x%x) "
1611 "=> Loop 0x%x (Port 0x%x) \n",
1612 isp->isp_name, i, fcp->portdb[i].loopid,
1639 isp_prt(isp, ISP_LOGINFO, portshift, i,
1640 fcp->portdb[i].loopid,
1613 fcp->portdb[i].portid, loopid,
1614 tport[loopid].portid);
1615 }
1616 fcp->portdb[i].portid = tport[loopid].portid;
1617 fcp->portdb[i].loopid = loopid;
1618 fcp->portdb[i].valid = 1;
1619 fcp->portdb[i].roles = tport[loopid].roles;
1620
1621 /*
1622 * Now make sure this Port WWN doesn't exist elsewhere
1623 * in the port database.
1624 */
1625 for (j = i+1; j < FL_PORT_ID; j++) {
1626 if (fcp->portdb[i].port_wwn !=
1627 fcp->portdb[j].port_wwn) {
1628 continue;
1629 }
1641 fcp->portdb[i].portid, loopid,
1642 tport[loopid].portid);
1643 }
1644 fcp->portdb[i].portid = tport[loopid].portid;
1645 fcp->portdb[i].loopid = loopid;
1646 fcp->portdb[i].valid = 1;
1647 fcp->portdb[i].roles = tport[loopid].roles;
1648
1649 /*
1650 * Now make sure this Port WWN doesn't exist elsewhere
1651 * in the port database.
1652 */
1653 for (j = i+1; j < FL_PORT_ID; j++) {
1654 if (fcp->portdb[i].port_wwn !=
1655 fcp->portdb[j].port_wwn) {
1656 continue;
1657 }
1630 PRINTF("%s: Target ID %d Duplicates Target ID "
1631 "%d- killing off both\n",
1632 isp->isp_name, j, i);
1658 isp_prt(isp, ISP_LOGWARN, portdup, j, i);
1633 /*
1634 * Invalidate the 'old' *and* 'new' ones.
1635 * This is really harsh and not quite right,
1636 * but if this happens, we really don't know
1637 * who is what at this point.
1638 */
1639 fcp->portdb[i].valid = 0;
1640 fcp->portdb[j].valid = 0;

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

1657 */
1658 if (fcp->portdb[loopid].port_wwn != 0) {
1659 for (lim = 0; lim < FL_PORT_ID; lim++) {
1660 if (fcp->portdb[lim].port_wwn == 0)
1661 break;
1662 }
1663 /* "Cannot Happen" */
1664 if (lim == FL_PORT_ID) {
1659 /*
1660 * Invalidate the 'old' *and* 'new' ones.
1661 * This is really harsh and not quite right,
1662 * but if this happens, we really don't know
1663 * who is what at this point.
1664 */
1665 fcp->portdb[i].valid = 0;
1666 fcp->portdb[j].valid = 0;

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

1683 */
1684 if (fcp->portdb[loopid].port_wwn != 0) {
1685 for (lim = 0; lim < FL_PORT_ID; lim++) {
1686 if (fcp->portdb[lim].port_wwn == 0)
1687 break;
1688 }
1689 /* "Cannot Happen" */
1690 if (lim == FL_PORT_ID) {
1665 PRINTF("%s: remap overflow?\n", isp->isp_name);
1691 isp_prt(isp, ISP_LOGWARN, "Remap Overflow");
1666 continue;
1667 }
1668 i = lim;
1669 } else {
1670 i = loopid;
1671 }
1672
1673 /*

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

1753 (((u_int64_t)pdb.pdb_portname[7]));
1754 nrole = (pdb.pdb_prli_svc3 & SVC3_ROLE_MASK) >>
1755 SVC3_ROLE_SHIFT;
1756 if (pdb.pdb_loopid == lp->loopid && lp->portid ==
1757 (u_int32_t) BITS2WORD(pdb.pdb_portid_bits) &&
1758 nwwnn == lp->node_wwn && nwwpn == lp->port_wwn &&
1759 lp->roles == nrole) {
1760 lp->loggedin = lp->valid = 1;
1692 continue;
1693 }
1694 i = lim;
1695 } else {
1696 i = loopid;
1697 }
1698
1699 /*

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

1779 (((u_int64_t)pdb.pdb_portname[7]));
1780 nrole = (pdb.pdb_prli_svc3 & SVC3_ROLE_MASK) >>
1781 SVC3_ROLE_SHIFT;
1782 if (pdb.pdb_loopid == lp->loopid && lp->portid ==
1783 (u_int32_t) BITS2WORD(pdb.pdb_portid_bits) &&
1784 nwwnn == lp->node_wwn && nwwpn == lp->port_wwn &&
1785 lp->roles == nrole) {
1786 lp->loggedin = lp->valid = 1;
1761 IDPRINTF(1, ("%s: retained login of Target %d "
1762 "(Loop 0x%x) Port ID 0x%x\n",
1763 isp->isp_name, (int) (lp - fcp->portdb),
1764 (int) lp->loopid, lp->portid));
1787 isp_prt(isp, ISP_LOGINFO, lretained,
1788 (int) (lp - fcp->portdb),
1789 (int) lp->loopid, lp->portid);
1765 continue;
1766 }
1767 }
1768
1769 /*
1770 * Force a logout if we were logged in.
1771 */
1772 if (lp->loggedin) {
1773 mbs.param[0] = MBOX_FABRIC_LOGOUT;
1774 mbs.param[1] = lp->loopid << 8;
1775 mbs.param[2] = 0;
1776 mbs.param[3] = 0;
1790 continue;
1791 }
1792 }
1793
1794 /*
1795 * Force a logout if we were logged in.
1796 */
1797 if (lp->loggedin) {
1798 mbs.param[0] = MBOX_FABRIC_LOGOUT;
1799 mbs.param[1] = lp->loopid << 8;
1800 mbs.param[2] = 0;
1801 mbs.param[3] = 0;
1777 isp_mboxcmd(isp, &mbs);
1802 isp_mboxcmd(isp, &mbs, MBLOGNONE);
1778 lp->loggedin = 0;
1803 lp->loggedin = 0;
1779 IDPRINTF(1, ("%s: Logging out target %d at Loop ID %d "
1780 "(port id 0x%x)\n", isp->isp_name,
1781 (int) (lp - fcp->portdb), lp->loopid, lp->portid));
1804 isp_prt(isp, ISP_LOGINFO, plogout,
1805 (int) (lp - fcp->portdb), lp->loopid, lp->portid);
1782 }
1783
1784 /*
1785 * And log in....
1786 */
1787 loopid = lp - fcp->portdb;
1788 lp->loopid = 0;
1789 do {
1790 mbs.param[0] = MBOX_FABRIC_LOGIN;
1791 mbs.param[1] = loopid << 8;
1792 mbs.param[2] = portid >> 16;
1793 mbs.param[3] = portid & 0xffff;
1794 if (IS_2200(isp)) {
1795 /* only issue a PLOGI if not logged in */
1796 mbs.param[1] |= 0x1;
1797 }
1806 }
1807
1808 /*
1809 * And log in....
1810 */
1811 loopid = lp - fcp->portdb;
1812 lp->loopid = 0;
1813 do {
1814 mbs.param[0] = MBOX_FABRIC_LOGIN;
1815 mbs.param[1] = loopid << 8;
1816 mbs.param[2] = portid >> 16;
1817 mbs.param[3] = portid & 0xffff;
1818 if (IS_2200(isp)) {
1819 /* only issue a PLOGI if not logged in */
1820 mbs.param[1] |= 0x1;
1821 }
1798 isp_mboxcmd(isp, &mbs);
1822 isp_mboxcmd(isp, &mbs, MBLOGALL & ~(MBOX_LOOP_ID_USED |
1823 MBOX_PORT_ID_USED | MBOX_COMMAND_ERROR));
1799 switch (mbs.param[0]) {
1800 case MBOX_LOOP_ID_USED:
1801 /*
1802 * Try the next available loop id.
1803 */
1804 loopid++;
1805 break;
1806 case MBOX_PORT_ID_USED:
1807 /*
1808 * This port is already logged in.
1809 * Snaffle the loop id it's using if it's
1810 * nonzero, otherwise we're hosed.
1811 */
1812 if (mbs.param[1] != 0) {
1813 loopid = mbs.param[1];
1824 switch (mbs.param[0]) {
1825 case MBOX_LOOP_ID_USED:
1826 /*
1827 * Try the next available loop id.
1828 */
1829 loopid++;
1830 break;
1831 case MBOX_PORT_ID_USED:
1832 /*
1833 * This port is already logged in.
1834 * Snaffle the loop id it's using if it's
1835 * nonzero, otherwise we're hosed.
1836 */
1837 if (mbs.param[1] != 0) {
1838 loopid = mbs.param[1];
1814 IDPRINTF(1, ("%s: Retaining loopid 0x%x"
1815 " for Target %d (port id 0x%x)\n",
1816 isp->isp_name, loopid,
1817 (int) (lp - fcp->portdb),
1818 lp->portid));
1839 isp_prt(isp, ISP_LOGINFO, retained,
1840 loopid, (int) (lp - fcp->portdb),
1841 lp->portid);
1819 } else {
1820 loopid = MAX_FC_TARG;
1821 break;
1822 }
1823 /* FALLTHROUGH */
1824 case MBOX_COMMAND_COMPLETE:
1825 lp->loggedin = 1;
1826 lp->loopid = loopid;
1827 break;
1828 case MBOX_COMMAND_ERROR:
1842 } else {
1843 loopid = MAX_FC_TARG;
1844 break;
1845 }
1846 /* FALLTHROUGH */
1847 case MBOX_COMMAND_COMPLETE:
1848 lp->loggedin = 1;
1849 lp->loopid = loopid;
1850 break;
1851 case MBOX_COMMAND_ERROR:
1829 PRINTF("%s: command error in PLOGI for port "
1830 " 0x%x (0x%x)\n", isp->isp_name, portid,
1831 mbs.param[1]);
1852 isp_prt(isp, ISP_LOGINFO, plogierr,
1853 portid, mbs.param[1]);
1832 /* FALLTHROUGH */
1833 case MBOX_ALL_IDS_USED: /* We're outta IDs */
1834 default:
1835 loopid = MAX_FC_TARG;
1836 break;
1837 }
1838 } while (lp->loopid == 0 && loopid < MAX_FC_TARG);
1839

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

1845 if (lp->loopid == 0) {
1846 continue;
1847 }
1848
1849 /*
1850 * Make sure we can get the approriate port information.
1851 */
1852 if (isp_getpdb(isp, lp->loopid, &pdb) != 0) {
1854 /* FALLTHROUGH */
1855 case MBOX_ALL_IDS_USED: /* We're outta IDs */
1856 default:
1857 loopid = MAX_FC_TARG;
1858 break;
1859 }
1860 } while (lp->loopid == 0 && loopid < MAX_FC_TARG);
1861

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

1867 if (lp->loopid == 0) {
1868 continue;
1869 }
1870
1871 /*
1872 * Make sure we can get the approriate port information.
1873 */
1874 if (isp_getpdb(isp, lp->loopid, &pdb) != 0) {
1853 PRINTF("%s: could not get PDB for device@port 0x%x\n",
1854 isp->isp_name, lp->portid);
1875 isp_prt(isp, ISP_LOGWARN, nopdb, lp->portid);
1855 goto dump_em;
1856 }
1857
1858 if (pdb.pdb_loopid != lp->loopid) {
1876 goto dump_em;
1877 }
1878
1879 if (pdb.pdb_loopid != lp->loopid) {
1859 PRINTF("%s: PDB loopid info for device@port 0x%x does "
1860 "not match up (0x%x)\n", isp->isp_name, lp->portid,
1861 pdb.pdb_loopid);
1880 isp_prt(isp, ISP_LOGWARN, pdbmfail1,
1881 lp->portid, pdb.pdb_loopid);
1862 goto dump_em;
1863 }
1864
1865 if (lp->portid != (u_int32_t) BITS2WORD(pdb.pdb_portid_bits)) {
1882 goto dump_em;
1883 }
1884
1885 if (lp->portid != (u_int32_t) BITS2WORD(pdb.pdb_portid_bits)) {
1866 PRINTF("%s: PDB port info for device@port 0x%x does "
1867 "not match up (0x%x)\n", isp->isp_name, lp->portid,
1868 BITS2WORD(pdb.pdb_portid_bits));
1886 isp_prt(isp, ISP_LOGWARN, pdbmfail2,
1887 lp->portid, BITS2WORD(pdb.pdb_portid_bits));
1869 goto dump_em;
1870 }
1871
1872 lp->roles =
1873 (pdb.pdb_prli_svc3 & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT;
1874 lp->node_wwn =
1875 (((u_int64_t)pdb.pdb_nodename[0]) << 56) |
1876 (((u_int64_t)pdb.pdb_nodename[1]) << 48) |

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

1895 if (lp->node_wwn && lp->port_wwn) {
1896 lp->valid = 1;
1897 loopid = lp - fcp->portdb;
1898 (void) isp_async(isp, ISPASYNC_PDB_CHANGED, &loopid);
1899 continue;
1900 }
1901dump_em:
1902 lp->valid = 0;
1888 goto dump_em;
1889 }
1890
1891 lp->roles =
1892 (pdb.pdb_prli_svc3 & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT;
1893 lp->node_wwn =
1894 (((u_int64_t)pdb.pdb_nodename[0]) << 56) |
1895 (((u_int64_t)pdb.pdb_nodename[1]) << 48) |

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

1914 if (lp->node_wwn && lp->port_wwn) {
1915 lp->valid = 1;
1916 loopid = lp - fcp->portdb;
1917 (void) isp_async(isp, ISPASYNC_PDB_CHANGED, &loopid);
1918 continue;
1919 }
1920dump_em:
1921 lp->valid = 0;
1903 PRINTF("%s: Target %d (Loop 0x%x) Port ID 0x%x dumped after "
1904 "login\n", isp->isp_name, loopid, lp->loopid, lp->portid);
1922 isp_prt(isp, ISP_LOGINFO,
1923 ldumped, loopid, lp->loopid, lp->portid);
1905 mbs.param[0] = MBOX_FABRIC_LOGOUT;
1906 mbs.param[1] = lp->loopid << 8;
1907 mbs.param[2] = 0;
1908 mbs.param[3] = 0;
1924 mbs.param[0] = MBOX_FABRIC_LOGOUT;
1925 mbs.param[1] = lp->loopid << 8;
1926 mbs.param[2] = 0;
1927 mbs.param[3] = 0;
1909 isp_mboxcmd(isp, &mbs);
1928 isp_mboxcmd(isp, &mbs, MBLOGNONE);
1910 }
1911#endif
1912 /*
1913 * If we get here, we've for sure seen not only a valid loop
1914 * but know what is or isn't on it, so mark this for usage
1929 }
1930#endif
1931 /*
1932 * If we get here, we've for sure seen not only a valid loop
1933 * but know what is or isn't on it, so mark this for usage
1915 * in ispscsicmd.
1934 * in isp_start.
1916 */
1917 fcp->loop_seen_once = 1;
1918 return (0);
1919}
1920
1921#ifdef ISP2100_FABRIC
1922static int
1923isp_scan_fabric(isp)

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

1947 reqp->snscb_data[5] = (portid >> 16) & 0xff;
1948 ISP_SWIZZLE_SNS_REQ(isp, reqp);
1949 mbs.param[0] = MBOX_SEND_SNS;
1950 mbs.param[1] = SNS_GAN_REQ_SIZE >> 1;
1951 mbs.param[2] = DMA_MSW(fcp->isp_scdma);
1952 mbs.param[3] = DMA_LSW(fcp->isp_scdma);
1953 mbs.param[6] = 0;
1954 mbs.param[7] = 0;
1935 */
1936 fcp->loop_seen_once = 1;
1937 return (0);
1938}
1939
1940#ifdef ISP2100_FABRIC
1941static int
1942isp_scan_fabric(isp)

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

1966 reqp->snscb_data[5] = (portid >> 16) & 0xff;
1967 ISP_SWIZZLE_SNS_REQ(isp, reqp);
1968 mbs.param[0] = MBOX_SEND_SNS;
1969 mbs.param[1] = SNS_GAN_REQ_SIZE >> 1;
1970 mbs.param[2] = DMA_MSW(fcp->isp_scdma);
1971 mbs.param[3] = DMA_LSW(fcp->isp_scdma);
1972 mbs.param[6] = 0;
1973 mbs.param[7] = 0;
1955 MemoryBarrier();
1956 isp_mboxcmd(isp, &mbs);
1974 isp_mboxcmd(isp, &mbs, MBLOGALL);
1957 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1975 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1958 IDPRINTF(1, ("%s: SNS failed (0x%x)\n", isp->isp_name,
1959 mbs.param[0]));
1960 return (-1);
1961 }
1962 ISP_UNSWIZZLE_SNS_RSP(isp, resp, SNS_GAN_RESP_SIZE >> 1);
1963 portid = (((u_int32_t) resp->snscb_port_id[0]) << 16) |
1964 (((u_int32_t) resp->snscb_port_id[1]) << 8) |
1965 (((u_int32_t) resp->snscb_port_id[2]));
1966 if (isp_async(isp, ISPASYNC_FABRIC_DEV, resp)) {
1967 return (-1);

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

1978 */
1979 return (0);
1980}
1981#endif
1982/*
1983 * Start a command. Locking is assumed done in the caller.
1984 */
1985
1976 return (-1);
1977 }
1978 ISP_UNSWIZZLE_SNS_RSP(isp, resp, SNS_GAN_RESP_SIZE >> 1);
1979 portid = (((u_int32_t) resp->snscb_port_id[0]) << 16) |
1980 (((u_int32_t) resp->snscb_port_id[1]) << 8) |
1981 (((u_int32_t) resp->snscb_port_id[2]));
1982 if (isp_async(isp, ISPASYNC_FABRIC_DEV, resp)) {
1983 return (-1);

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

1994 */
1995 return (0);
1996}
1997#endif
1998/*
1999 * Start a command. Locking is assumed done in the caller.
2000 */
2001
1986int32_t
1987ispscsicmd(xs)
1988 ISP_SCSI_XFER_T *xs;
2002int
2003isp_start(xs)
2004 XS_T *xs;
1989{
1990 struct ispsoftc *isp;
1991 u_int16_t iptr, optr;
1992 union {
1993 ispreq_t *_reqp;
1994 ispreqt2_t *_t2reqp;
1995 } _u;
1996#define reqp _u._reqp
1997#define t2reqp _u._t2reqp
1998#define UZSIZE max(sizeof (ispreq_t), sizeof (ispreqt2_t))
1999 int target, i;
2000
2001 XS_INITERR(xs);
2002 isp = XS_ISP(xs);
2003
2004 if (isp->isp_state != ISP_RUNSTATE) {
2005{
2006 struct ispsoftc *isp;
2007 u_int16_t iptr, optr;
2008 union {
2009 ispreq_t *_reqp;
2010 ispreqt2_t *_t2reqp;
2011 } _u;
2012#define reqp _u._reqp
2013#define t2reqp _u._t2reqp
2014#define UZSIZE max(sizeof (ispreq_t), sizeof (ispreqt2_t))
2015 int target, i;
2016
2017 XS_INITERR(xs);
2018 isp = XS_ISP(xs);
2019
2020 if (isp->isp_state != ISP_RUNSTATE) {
2005 PRINTF("%s: adapter not ready\n", isp->isp_name);
2021 isp_prt(isp, ISP_LOGERR, "Adapter not at RUNSTATE");
2006 XS_SETERR(xs, HBA_BOTCH);
2007 return (CMD_COMPLETE);
2008 }
2009
2010 /*
2011 * Check command CDB length, etc.. We really are limited to 16 bytes
2012 * for Fibre Channel, but can do up to 44 bytes in parallel SCSI,
2013 * but probably only if we're running fairly new firmware (we'll
2014 * let the old f/w choke on an extended command queue entry).
2015 */
2016
2017 if (XS_CDBLEN(xs) > (IS_FC(isp)? 16 : 44) || XS_CDBLEN(xs) == 0) {
2022 XS_SETERR(xs, HBA_BOTCH);
2023 return (CMD_COMPLETE);
2024 }
2025
2026 /*
2027 * Check command CDB length, etc.. We really are limited to 16 bytes
2028 * for Fibre Channel, but can do up to 44 bytes in parallel SCSI,
2029 * but probably only if we're running fairly new firmware (we'll
2030 * let the old f/w choke on an extended command queue entry).
2031 */
2032
2033 if (XS_CDBLEN(xs) > (IS_FC(isp)? 16 : 44) || XS_CDBLEN(xs) == 0) {
2018 PRINTF("%s: unsupported cdb length (%d, CDB[0]=0x%x)\n",
2019 isp->isp_name, XS_CDBLEN(xs), XS_CDBP(xs)[0] & 0xff);
2034 isp_prt(isp, ISP_LOGERR,
2035 "unsupported cdb length (%d, CDB[0]=0x%x)",
2036 XS_CDBLEN(xs), XS_CDBP(xs)[0] & 0xff);
2020 XS_SETERR(xs, HBA_BOTCH);
2021 return (CMD_COMPLETE);
2022 }
2023
2024 /*
2025 * Check to see whether we have good firmware state still or
2026 * need to refresh our port database for this target.
2027 */

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

2061 * case, then bounce the command. We pretend this is
2062 * a SELECTION TIMEOUT error if we've never gone to
2063 * FW_READY state at all- in this case we may not
2064 * be hooked to a loop at all and we shouldn't hang
2065 * the machine for this. Otherwise, defer this command
2066 * until later.
2067 */
2068 if (fcp->isp_fwstate != FW_READY) {
2037 XS_SETERR(xs, HBA_BOTCH);
2038 return (CMD_COMPLETE);
2039 }
2040
2041 /*
2042 * Check to see whether we have good firmware state still or
2043 * need to refresh our port database for this target.
2044 */

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

2078 * case, then bounce the command. We pretend this is
2079 * a SELECTION TIMEOUT error if we've never gone to
2080 * FW_READY state at all- in this case we may not
2081 * be hooked to a loop at all and we shouldn't hang
2082 * the machine for this. Otherwise, defer this command
2083 * until later.
2084 */
2085 if (fcp->isp_fwstate != FW_READY) {
2069 if (isp_fclink_test(isp, FC_FW_READY_DELAY)) {
2086 /*
2087 * Give ourselves at most a 250ms delay.
2088 */
2089 if (isp_fclink_test(isp, 250000)) {
2070 XS_SETERR(xs, HBA_SELTIMEOUT);
2071 if (fcp->loop_seen_once) {
2072 return (CMD_RQLATER);
2073 } else {
2074 return (CMD_COMPLETE);
2075 }
2076 }
2077 }

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

2102 if (fcp->isp_loopstate == LOOP_PDB_RCVD) {
2103 if (isp_pdb_sync(isp, target)) {
2104 XS_SETERR(xs, HBA_SELTIMEOUT);
2105 return (CMD_COMPLETE);
2106 }
2107 }
2108
2109 /*
2090 XS_SETERR(xs, HBA_SELTIMEOUT);
2091 if (fcp->loop_seen_once) {
2092 return (CMD_RQLATER);
2093 } else {
2094 return (CMD_COMPLETE);
2095 }
2096 }
2097 }

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

2122 if (fcp->isp_loopstate == LOOP_PDB_RCVD) {
2123 if (isp_pdb_sync(isp, target)) {
2124 XS_SETERR(xs, HBA_SELTIMEOUT);
2125 return (CMD_COMPLETE);
2126 }
2127 }
2128
2129 /*
2130 * XXX: Here's were we would cancel any loop_dead flag
2131 * XXX: also cancel in dead_loop timeout that's running
2132 */
2133
2134 /*
2110 * Now check whether we should even think about pursuing this.
2111 */
2112 lp = &fcp->portdb[target];
2113 if (lp->valid == 0) {
2114 XS_SETERR(xs, HBA_SELTIMEOUT);
2115 return (CMD_COMPLETE);
2116 }
2117 if ((lp->roles & (SVC3_TGT_ROLE >> SVC3_ROLE_SHIFT)) == 0) {
2135 * Now check whether we should even think about pursuing this.
2136 */
2137 lp = &fcp->portdb[target];
2138 if (lp->valid == 0) {
2139 XS_SETERR(xs, HBA_SELTIMEOUT);
2140 return (CMD_COMPLETE);
2141 }
2142 if ((lp->roles & (SVC3_TGT_ROLE >> SVC3_ROLE_SHIFT)) == 0) {
2118 IDPRINTF(3, ("%s: target %d is not a target\n",
2119 isp->isp_name, target));
2143 isp_prt(isp, ISP_LOGDEBUG2,
2144 "Target %d does not have target service", target);
2120 XS_SETERR(xs, HBA_SELTIMEOUT);
2121 return (CMD_COMPLETE);
2122 }
2123 /*
2124 * Now turn target into what the actual loop ID is.
2125 */
2126 target = lp->loopid;
2127 }
2128
2129 /*
2130 * Next check to see if any HBA or Device
2131 * parameters need to be updated.
2132 */
2133 if (isp->isp_update != 0) {
2134 isp_update(isp);
2135 }
2136
2137 if (isp_getrqentry(isp, &iptr, &optr, (void **) &reqp)) {
2145 XS_SETERR(xs, HBA_SELTIMEOUT);
2146 return (CMD_COMPLETE);
2147 }
2148 /*
2149 * Now turn target into what the actual loop ID is.
2150 */
2151 target = lp->loopid;
2152 }
2153
2154 /*
2155 * Next check to see if any HBA or Device
2156 * parameters need to be updated.
2157 */
2158 if (isp->isp_update != 0) {
2159 isp_update(isp);
2160 }
2161
2162 if (isp_getrqentry(isp, &iptr, &optr, (void **) &reqp)) {
2138 IDPRINTF(2, ("%s: Request Queue Overflow\n", isp->isp_name));
2163 isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow");
2139 XS_SETERR(xs, HBA_BOTCH);
2140 return (CMD_EAGAIN);
2141 }
2142
2143 /*
2144 * Now see if we need to synchronize the ISP with respect to anything.
2145 * We do dual duty here (cough) for synchronizing for busses other
2146 * than which we got here to send a command to.

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

2155 continue;
2156 }
2157 MEMZERO((void *) reqp, sizeof (*reqp));
2158 reqp->req_header.rqs_entry_count = 1;
2159 reqp->req_header.rqs_entry_type = RQSTYPE_MARKER;
2160 reqp->req_modifier = SYNC_ALL;
2161 reqp->req_target = i << 7; /* insert bus number */
2162 ISP_SWIZZLE_REQUEST(isp, reqp);
2164 XS_SETERR(xs, HBA_BOTCH);
2165 return (CMD_EAGAIN);
2166 }
2167
2168 /*
2169 * Now see if we need to synchronize the ISP with respect to anything.
2170 * We do dual duty here (cough) for synchronizing for busses other
2171 * than which we got here to send a command to.

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

2180 continue;
2181 }
2182 MEMZERO((void *) reqp, sizeof (*reqp));
2183 reqp->req_header.rqs_entry_count = 1;
2184 reqp->req_header.rqs_entry_type = RQSTYPE_MARKER;
2185 reqp->req_modifier = SYNC_ALL;
2186 reqp->req_target = i << 7; /* insert bus number */
2187 ISP_SWIZZLE_REQUEST(isp, reqp);
2163 MemoryBarrier();
2164 ISP_ADD_REQUEST(isp, iptr);
2165
2166 if (isp_getrqentry(isp, &iptr, &optr, (void **)&reqp)) {
2188 ISP_ADD_REQUEST(isp, iptr);
2189
2190 if (isp_getrqentry(isp, &iptr, &optr, (void **)&reqp)) {
2167 IDPRINTF(2, ("%s: Request Queue Overflow+\n",
2168 isp->isp_name));
2191 isp_prt(isp, ISP_LOGDEBUG0,
2192 "Request Queue Overflow+");
2169 XS_SETERR(xs, HBA_BOTCH);
2170 return (CMD_EAGAIN);
2171 }
2172 }
2173 }
2174
2175 MEMZERO((void *) reqp, UZSIZE);
2176 reqp->req_header.rqs_entry_count = 1;

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

2190 */
2191 XS_RESID(xs) = 0;
2192
2193 /*
2194 * Fibre Channel always requires some kind of tag.
2195 * The Qlogic drivers seem be happy not to use a tag,
2196 * but this breaks for some devices (IBM drives).
2197 */
2193 XS_SETERR(xs, HBA_BOTCH);
2194 return (CMD_EAGAIN);
2195 }
2196 }
2197 }
2198
2199 MEMZERO((void *) reqp, UZSIZE);
2200 reqp->req_header.rqs_entry_count = 1;

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

2214 */
2215 XS_RESID(xs) = 0;
2216
2217 /*
2218 * Fibre Channel always requires some kind of tag.
2219 * The Qlogic drivers seem be happy not to use a tag,
2220 * but this breaks for some devices (IBM drives).
2221 */
2198 if (XS_CANTAG(xs)) {
2199 t2reqp->req_flags = XS_KINDOF_TAG(xs);
2222 if (XS_TAG_P(xs)) {
2223 t2reqp->req_flags = XS_TAG_TYPE(xs);
2200 } else {
2201 if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */
2202 t2reqp->req_flags = REQFLAG_HTAG;
2203 else
2204 t2reqp->req_flags = REQFLAG_OTAG;
2205 }
2206 } else {
2207 sdparam *sdp = (sdparam *)isp->isp_param;
2208 if ((sdp->isp_devparam[target].cur_dflags & DPARM_TQING) &&
2224 } else {
2225 if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */
2226 t2reqp->req_flags = REQFLAG_HTAG;
2227 else
2228 t2reqp->req_flags = REQFLAG_OTAG;
2229 }
2230 } else {
2231 sdparam *sdp = (sdparam *)isp->isp_param;
2232 if ((sdp->isp_devparam[target].cur_dflags & DPARM_TQING) &&
2209 XS_CANTAG(xs)) {
2210 reqp->req_flags = XS_KINDOF_TAG(xs);
2233 XS_TAG_P(xs)) {
2234 reqp->req_flags = XS_TAG_TYPE(xs);
2211 }
2212 }
2213 reqp->req_target = target | (XS_CHANNEL(xs) << 7);
2214 if (IS_SCSI(isp)) {
2215 reqp->req_lun_trn = XS_LUN(xs);
2216 reqp->req_cdblen = XS_CDBLEN(xs);
2217 } else {
2218 if (isp->isp_maxluns > 16)

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

2229 /*
2230 * Always give a bit more leeway to commands after a bus reset.
2231 * XXX: DOES NOT DISTINGUISH WHICH PORT MAY HAVE BEEN SYNCED
2232 */
2233 if (isp->isp_sendmarker && reqp->req_time < 5) {
2234 reqp->req_time = 5;
2235 }
2236 if (isp_save_xs(isp, xs, &reqp->req_handle)) {
2235 }
2236 }
2237 reqp->req_target = target | (XS_CHANNEL(xs) << 7);
2238 if (IS_SCSI(isp)) {
2239 reqp->req_lun_trn = XS_LUN(xs);
2240 reqp->req_cdblen = XS_CDBLEN(xs);
2241 } else {
2242 if (isp->isp_maxluns > 16)

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

2253 /*
2254 * Always give a bit more leeway to commands after a bus reset.
2255 * XXX: DOES NOT DISTINGUISH WHICH PORT MAY HAVE BEEN SYNCED
2256 */
2257 if (isp->isp_sendmarker && reqp->req_time < 5) {
2258 reqp->req_time = 5;
2259 }
2260 if (isp_save_xs(isp, xs, &reqp->req_handle)) {
2237 IDPRINTF(2, ("%s: out of xflist pointers\n", isp->isp_name));
2261 isp_prt(isp, ISP_LOGDEBUG1, "out of xflist pointers");
2238 XS_SETERR(xs, HBA_BOTCH);
2239 return (CMD_EAGAIN);
2240 }
2241 /*
2242 * Set up DMA and/or do any bus swizzling of the request entry
2243 * so that the Qlogic F/W understands what is being asked of it.
2244 */
2245 i = ISP_DMASETUP(isp, xs, reqp, &iptr, optr);
2246 if (i != CMD_QUEUED) {
2247 isp_destroy_handle(isp, reqp->req_handle);
2248 /*
2249 * dmasetup sets actual error in packet, and
2250 * return what we were given to return.
2251 */
2252 return (i);
2253 }
2254 XS_SETERR(xs, HBA_NOERROR);
2262 XS_SETERR(xs, HBA_BOTCH);
2263 return (CMD_EAGAIN);
2264 }
2265 /*
2266 * Set up DMA and/or do any bus swizzling of the request entry
2267 * so that the Qlogic F/W understands what is being asked of it.
2268 */
2269 i = ISP_DMASETUP(isp, xs, reqp, &iptr, optr);
2270 if (i != CMD_QUEUED) {
2271 isp_destroy_handle(isp, reqp->req_handle);
2272 /*
2273 * dmasetup sets actual error in packet, and
2274 * return what we were given to return.
2275 */
2276 return (i);
2277 }
2278 XS_SETERR(xs, HBA_NOERROR);
2255 IDPRINTF(5, ("%s(%d.%d.%d): START cmd 0x%x datalen %d\n",
2256 isp->isp_name, XS_CHANNEL(xs), target, XS_LUN(xs),
2257 reqp->req_cdb[0], XS_XFRLEN(xs)));
2258 MemoryBarrier();
2279 isp_prt(isp, ISP_LOGDEBUG2,
2280 "START cmd for %d.%d.%d cmd 0x%x datalen %d",
2281 XS_CHANNEL(xs), target, XS_LUN(xs), XS_CDBP(xs)[0], XS_XFRLEN(xs));
2259 ISP_ADD_REQUEST(isp, iptr);
2260 isp->isp_nactive++;
2261 if (isp->isp_sendmarker)
2262 isp->isp_sendmarker = 0;
2263 return (CMD_QUEUED);
2264#undef reqp
2265#undef t2reqp
2266}

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

2271 */
2272
2273int
2274isp_control(isp, ctl, arg)
2275 struct ispsoftc *isp;
2276 ispctl_t ctl;
2277 void *arg;
2278{
2282 ISP_ADD_REQUEST(isp, iptr);
2283 isp->isp_nactive++;
2284 if (isp->isp_sendmarker)
2285 isp->isp_sendmarker = 0;
2286 return (CMD_QUEUED);
2287#undef reqp
2288#undef t2reqp
2289}

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

2294 */
2295
2296int
2297isp_control(isp, ctl, arg)
2298 struct ispsoftc *isp;
2299 ispctl_t ctl;
2300 void *arg;
2301{
2279 ISP_SCSI_XFER_T *xs;
2302 XS_T *xs;
2280 mbreg_t mbs;
2281 int bus, tgt;
2282 u_int32_t handle;
2283
2284 switch (ctl) {
2285 default:
2303 mbreg_t mbs;
2304 int bus, tgt;
2305 u_int32_t handle;
2306
2307 switch (ctl) {
2308 default:
2286 PRINTF("%s: isp_control unknown control op %x\n",
2287 isp->isp_name, ctl);
2309 isp_prt(isp, ISP_LOGERR, "Unknown Control Opcode 0x%x", ctl);
2288 break;
2289
2290 case ISPCTL_RESET_BUS:
2291 /*
2292 * Issue a bus reset.
2293 */
2294 mbs.param[0] = MBOX_BUS_RESET;
2295 mbs.param[2] = 0;

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

2301 bus = *((int *) arg);
2302 if (IS_DUALBUS(isp))
2303 mbs.param[2] = bus;
2304 } else {
2305 mbs.param[1] = 10;
2306 bus = 0;
2307 }
2308 isp->isp_sendmarker |= (1 << bus);
2310 break;
2311
2312 case ISPCTL_RESET_BUS:
2313 /*
2314 * Issue a bus reset.
2315 */
2316 mbs.param[0] = MBOX_BUS_RESET;
2317 mbs.param[2] = 0;

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

2323 bus = *((int *) arg);
2324 if (IS_DUALBUS(isp))
2325 mbs.param[2] = bus;
2326 } else {
2327 mbs.param[1] = 10;
2328 bus = 0;
2329 }
2330 isp->isp_sendmarker |= (1 << bus);
2309 isp_mboxcmd(isp, &mbs);
2331 isp_mboxcmd(isp, &mbs, MBLOGALL);
2310 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2332 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2311 isp_dumpregs(isp, "isp_control SCSI bus reset failed");
2312 break;
2313 }
2333 break;
2334 }
2314 CFGPRINTF("%s: driver initiated bus reset of bus %d\n",
2315 isp->isp_name, bus);
2335 isp_prt(isp, ISP_LOGINFO,
2336 "driver initiated bus reset of bus %d", bus);
2316 return (0);
2317
2318 case ISPCTL_RESET_DEV:
2319 tgt = (*((int *) arg)) & 0xffff;
2320 bus = (*((int *) arg)) >> 16;
2321 mbs.param[0] = MBOX_ABORT_TARGET;
2322 mbs.param[1] = (tgt << 8) | (bus << 15);
2323 mbs.param[2] = 3; /* 'delay', in seconds */
2337 return (0);
2338
2339 case ISPCTL_RESET_DEV:
2340 tgt = (*((int *) arg)) & 0xffff;
2341 bus = (*((int *) arg)) >> 16;
2342 mbs.param[0] = MBOX_ABORT_TARGET;
2343 mbs.param[1] = (tgt << 8) | (bus << 15);
2344 mbs.param[2] = 3; /* 'delay', in seconds */
2324 isp_mboxcmd(isp, &mbs);
2345 isp_mboxcmd(isp, &mbs, MBLOGALL);
2325 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2346 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2326 PRINTF("%s: isp_control MBOX_RESET_DEV failure (code "
2327 "%x)\n", isp->isp_name, mbs.param[0]);
2328 break;
2329 }
2347 break;
2348 }
2330 PRINTF("%s: Target %d on Bus %d Reset Succeeded\n",
2331 isp->isp_name, tgt, bus);
2349 isp_prt(isp, ISP_LOGINFO,
2350 "Target %d on Bus %d Reset Succeeded", tgt, bus);
2332 isp->isp_sendmarker |= (1 << bus);
2333 return (0);
2334
2335 case ISPCTL_ABORT_CMD:
2351 isp->isp_sendmarker |= (1 << bus);
2352 return (0);
2353
2354 case ISPCTL_ABORT_CMD:
2336 xs = (ISP_SCSI_XFER_T *) arg;
2355 xs = (XS_T *) arg;
2337 tgt = XS_TGT(xs);
2338 handle = isp_find_handle(isp, xs);
2339 if (handle == 0) {
2356 tgt = XS_TGT(xs);
2357 handle = isp_find_handle(isp, xs);
2358 if (handle == 0) {
2340 PRINTF("%s: isp_control- cannot find command to abort "
2341 "in active list\n", isp->isp_name);
2359 isp_prt(isp, ISP_LOGWARN,
2360 "cannot find handle for command to abort");
2342 break;
2343 }
2344 bus = XS_CHANNEL(xs);
2345 mbs.param[0] = MBOX_ABORT;
2346 if (IS_FC(isp)) {
2347 if (isp->isp_maxluns > 16) {
2348 mbs.param[1] = tgt << 8;
2349 mbs.param[4] = 0;
2350 mbs.param[5] = 0;
2351 mbs.param[6] = XS_LUN(xs);
2352 } else {
2353 mbs.param[1] = tgt << 8 | XS_LUN(xs);
2354 }
2355 } else {
2356 mbs.param[1] =
2357 (bus << 15) | (XS_TGT(xs) << 8) | XS_LUN(xs);
2358 }
2359 mbs.param[3] = handle >> 16;
2360 mbs.param[2] = handle & 0xffff;
2361 break;
2362 }
2363 bus = XS_CHANNEL(xs);
2364 mbs.param[0] = MBOX_ABORT;
2365 if (IS_FC(isp)) {
2366 if (isp->isp_maxluns > 16) {
2367 mbs.param[1] = tgt << 8;
2368 mbs.param[4] = 0;
2369 mbs.param[5] = 0;
2370 mbs.param[6] = XS_LUN(xs);
2371 } else {
2372 mbs.param[1] = tgt << 8 | XS_LUN(xs);
2373 }
2374 } else {
2375 mbs.param[1] =
2376 (bus << 15) | (XS_TGT(xs) << 8) | XS_LUN(xs);
2377 }
2378 mbs.param[3] = handle >> 16;
2379 mbs.param[2] = handle & 0xffff;
2361 isp_mboxcmd(isp, &mbs);
2362 switch (mbs.param[0]) {
2363 case MBOX_COMMAND_COMPLETE:
2364 IDPRINTF(1,
2365 ("%s: command (handle 0x%x) for %d.%d.%d aborted\n",
2366 isp->isp_name, handle, bus, tgt, XS_LUN(xs)));
2367 /* FALLTHROUGH */
2368 case MBOX_COMMAND_ERROR:
2369 break;
2370 default:
2371 PRINTF("%s: command (handle 0x%x) abort failed (%x)\n",
2372 isp->isp_name, handle, mbs.param[0]);
2373 break;
2380 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_ERROR);
2381 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
2382 return (0);
2374 }
2383 }
2375 return (0);
2384 break;
2376
2377 case ISPCTL_UPDATE_PARAMS:
2378 isp_update(isp);
2379 return (0);
2380
2381 case ISPCTL_FCLINK_TEST:
2382 if (IS_FC(isp)) {
2385
2386 case ISPCTL_UPDATE_PARAMS:
2387 isp_update(isp);
2388 return (0);
2389
2390 case ISPCTL_FCLINK_TEST:
2391 if (IS_FC(isp)) {
2383 return (isp_fclink_test(isp, FC_FW_READY_DELAY));
2392 int usdelay = (arg)? *((int *) arg) : 250000;
2393 return (isp_fclink_test(isp, usdelay));
2384 }
2385 break;
2386
2387 case ISPCTL_PDB_SYNC:
2388 if (IS_FC(isp)) {
2389 return (isp_pdb_sync(isp, -1));
2390 }
2391 break;
2392
2393#ifdef ISP_TARGET_MODE
2394 case ISPCTL_TOGGLE_TMODE:
2395 if (IS_SCSI(isp)) {
2396 int ena = *(int *)arg;
2397 mbs.param[0] = MBOX_ENABLE_TARGET_MODE;
2398 mbs.param[1] = (ena)? ENABLE_TARGET_FLAG : 0;
2394 }
2395 break;
2396
2397 case ISPCTL_PDB_SYNC:
2398 if (IS_FC(isp)) {
2399 return (isp_pdb_sync(isp, -1));
2400 }
2401 break;
2402
2403#ifdef ISP_TARGET_MODE
2404 case ISPCTL_TOGGLE_TMODE:
2405 if (IS_SCSI(isp)) {
2406 int ena = *(int *)arg;
2407 mbs.param[0] = MBOX_ENABLE_TARGET_MODE;
2408 mbs.param[1] = (ena)? ENABLE_TARGET_FLAG : 0;
2399 isp_mboxcmd(isp, &mbs);
2409 isp_mboxcmd(isp, &mbs, MBLOGALL);
2400 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2410 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2401 PRINTF("%s: cannot %sable target mode (0x%x)\n",
2402 isp->isp_name, ena? "en" : "dis",
2403 mbs.param[0]);
2404 break;
2405 }
2406 }
2407 return (0);
2408#endif
2409 }
2410 return (-1);
2411}
2412
2413/*
2414 * Interrupt Service Routine(s).
2415 *
2416 * External (OS) framework has done the appropriate locking,
2417 * and the locking will be held throughout this function.
2418 */
2419
2411 break;
2412 }
2413 }
2414 return (0);
2415#endif
2416 }
2417 return (-1);
2418}
2419
2420/*
2421 * Interrupt Service Routine(s).
2422 *
2423 * External (OS) framework has done the appropriate locking,
2424 * and the locking will be held throughout this function.
2425 */
2426
2427/*
2428 * Limit our stack depth by sticking with the max likely number
2429 * of completions on a request queue at any one time.
2430 */
2431#define MAX_REQUESTQ_COMPLETIONS 32
2432
2420int
2421isp_intr(arg)
2422 void *arg;
2423{
2433int
2434isp_intr(arg)
2435 void *arg;
2436{
2424 ISP_SCSI_XFER_T *complist[RESULT_QUEUE_LEN], *xs;
2425 struct ispsoftc *isp = arg;
2437 struct ispsoftc *isp = arg;
2438 XS_T *complist[MAX_REQUESTQ_COMPLETIONS], *xs;
2426 u_int16_t iptr, optr, isr, sema, junk;
2427 int i, nlooked = 0, ndone = 0;
2428
2429 if (IS_2100(isp)) {
2430 i = 0;
2431 do {
2432 isr = ISP_READ(isp, BIU_ISR);
2433 junk = ISP_READ(isp, BIU_ISR);
2434 } while (isr != junk && ++i < 1000);
2435 if (isr != junk) {
2439 u_int16_t iptr, optr, isr, sema, junk;
2440 int i, nlooked = 0, ndone = 0;
2441
2442 if (IS_2100(isp)) {
2443 i = 0;
2444 do {
2445 isr = ISP_READ(isp, BIU_ISR);
2446 junk = ISP_READ(isp, BIU_ISR);
2447 } while (isr != junk && ++i < 1000);
2448 if (isr != junk) {
2436 PRINTF("%s: isr unsteady (%x, %x)\n",
2437 isp->isp_name, isr, junk);
2449 isp_prt(isp, ISP_LOGWARN,
2450 "isr unsteady (%x, %x)", isr, junk);
2438 }
2439 i = 0;
2440 do {
2441 sema = ISP_READ(isp, BIU_SEMA);
2442 junk = ISP_READ(isp, BIU_SEMA);
2443 } while (sema != junk && ++i < 1000);
2444 if (sema != junk) {
2451 }
2452 i = 0;
2453 do {
2454 sema = ISP_READ(isp, BIU_SEMA);
2455 junk = ISP_READ(isp, BIU_SEMA);
2456 } while (sema != junk && ++i < 1000);
2457 if (sema != junk) {
2445 PRINTF("%s: sema unsteady (%x, %x)\n",
2446 isp->isp_name, sema, junk);
2458 isp_prt(isp, ISP_LOGWARN,
2459 "sema unsteady (%x, %x)", sema, junk);
2447 }
2448 } else {
2449 isr = ISP_READ(isp, BIU_ISR);
2450 sema = ISP_READ(isp, BIU_SEMA);
2451 }
2460 }
2461 } else {
2462 isr = ISP_READ(isp, BIU_ISR);
2463 sema = ISP_READ(isp, BIU_SEMA);
2464 }
2452 IDPRINTF(5, ("%s: isp_intr isr %x sem %x\n", isp->isp_name, isr, sema));
2465 isp_prt(isp, ISP_LOGDEBUG3, "isp_intr isr %x sem %x", isr, sema);
2453 isr &= INT_PENDING_MASK(isp);
2454 sema &= BIU_SEMA_LOCK;
2455 if (isr == 0 && sema == 0) {
2456 return (0);
2457 }
2458
2459 if (sema) {
2460 u_int16_t mbox;
2461
2462 if (IS_2100(isp)) {
2463 i = 0;
2464 do {
2465 mbox = ISP_READ(isp, OUTMAILBOX0);
2466 junk = ISP_READ(isp, OUTMAILBOX0);;
2467 } while (junk != mbox && ++i < 1000);
2468 if (mbox != junk) {
2466 isr &= INT_PENDING_MASK(isp);
2467 sema &= BIU_SEMA_LOCK;
2468 if (isr == 0 && sema == 0) {
2469 return (0);
2470 }
2471
2472 if (sema) {
2473 u_int16_t mbox;
2474
2475 if (IS_2100(isp)) {
2476 i = 0;
2477 do {
2478 mbox = ISP_READ(isp, OUTMAILBOX0);
2479 junk = ISP_READ(isp, OUTMAILBOX0);;
2480 } while (junk != mbox && ++i < 1000);
2481 if (mbox != junk) {
2469 PRINTF("%s: mailbox0 unsteady (%x, %x)\n",
2470 isp->isp_name, mbox, junk);
2482 isp_prt(isp, ISP_LOGWARN,
2483 "mailbox0 unsteady (%x, %x)", mbox, junk);
2471 ISP_WRITE(isp, BIU_SEMA, 0);
2472 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
2473 return (1);
2474 }
2475 } else {
2476 mbox = ISP_READ(isp, OUTMAILBOX0);
2477 }
2478 if (mbox & 0x4000) {

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

2483 if ((obits & (1 << i)) == 0) {
2484 continue;
2485 }
2486 isp->isp_mboxtmp[i] =
2487 ISP_READ(isp, MBOX_OFF(i));
2488 }
2489 MBOX_NOTIFY_COMPLETE(isp);
2490 } else {
2484 ISP_WRITE(isp, BIU_SEMA, 0);
2485 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
2486 return (1);
2487 }
2488 } else {
2489 mbox = ISP_READ(isp, OUTMAILBOX0);
2490 }
2491 if (mbox & 0x4000) {

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

2496 if ((obits & (1 << i)) == 0) {
2497 continue;
2498 }
2499 isp->isp_mboxtmp[i] =
2500 ISP_READ(isp, MBOX_OFF(i));
2501 }
2502 MBOX_NOTIFY_COMPLETE(isp);
2503 } else {
2491 PRINTF("%s: Command Mbox 0x%x\n",
2492 isp->isp_name, mbox);
2504 isp_prt(isp, ISP_LOGWARN,
2505 "Mbox Command Async (0x%x) with no waiters",
2506 mbox);
2493 }
2494 } else {
2495 u_int32_t fhandle = isp_parse_async(isp, (int) mbox);
2507 }
2508 } else {
2509 u_int32_t fhandle = isp_parse_async(isp, (int) mbox);
2496 IDPRINTF(4, ("%s: Async Mbox 0x%x\n",
2497 isp->isp_name, mbox));
2510 isp_prt(isp, ISP_LOGDEBUG2, "Async Mbox 0x%x", mbox);
2498 if (fhandle > 0) {
2499 isp_fastpost_complete(isp, fhandle);
2500 }
2501 }
2502 if (IS_FC(isp) || isp->isp_state != ISP_RUNSTATE) {
2503 ISP_WRITE(isp, BIU_SEMA, 0);
2504 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
2505 return (1);
2506 }
2507 }
2508
2509 /*
2510 * We can't be getting this now.
2511 */
2512 if (isp->isp_state != ISP_RUNSTATE) {
2511 if (fhandle > 0) {
2512 isp_fastpost_complete(isp, fhandle);
2513 }
2514 }
2515 if (IS_FC(isp) || isp->isp_state != ISP_RUNSTATE) {
2516 ISP_WRITE(isp, BIU_SEMA, 0);
2517 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
2518 return (1);
2519 }
2520 }
2521
2522 /*
2523 * We can't be getting this now.
2524 */
2525 if (isp->isp_state != ISP_RUNSTATE) {
2513 PRINTF("%s: interrupt (isr=%x, sema=%x) when not ready\n",
2514 isp->isp_name, isr, sema);
2526 isp_prt(isp, ISP_LOGWARN,
2527 "interrupt (isr=%x, sema=%x) when not ready", isr, sema);
2515 ISP_WRITE(isp, INMAILBOX5, ISP_READ(isp, OUTMAILBOX5));
2516 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
2517 ISP_WRITE(isp, BIU_SEMA, 0);
2518 return (1);
2519 }
2520
2521 /*
2522 * You *must* read OUTMAILBOX5 prior to clearing the RISC interrupt.

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

2527 i = 0;
2528 do {
2529 iptr = ISP_READ(isp, OUTMAILBOX5);
2530 junk = ISP_READ(isp, OUTMAILBOX5);
2531 } while (junk != iptr && ++i < 1000);
2532
2533 if (iptr != junk) {
2534 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
2528 ISP_WRITE(isp, INMAILBOX5, ISP_READ(isp, OUTMAILBOX5));
2529 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
2530 ISP_WRITE(isp, BIU_SEMA, 0);
2531 return (1);
2532 }
2533
2534 /*
2535 * You *must* read OUTMAILBOX5 prior to clearing the RISC interrupt.

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

2540 i = 0;
2541 do {
2542 iptr = ISP_READ(isp, OUTMAILBOX5);
2543 junk = ISP_READ(isp, OUTMAILBOX5);
2544 } while (junk != iptr && ++i < 1000);
2545
2546 if (iptr != junk) {
2547 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
2535 PRINTF("%s: mailbox5 unsteady (%x, %x)\n",
2536 isp->isp_name, iptr, junk);
2548 isp_prt(isp, ISP_LOGWARN,
2549 "mailbox5 unsteady (%x, %x)", iptr, junk);
2537 return (1);
2538 }
2539 } else {
2540 iptr = ISP_READ(isp, OUTMAILBOX5);
2541 }
2542
2543 if (sema) {
2544 ISP_WRITE(isp, BIU_SEMA, 0);

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

2550 * There are a lot of these- reasons unknown- mostly on
2551 * faster Alpha machines.
2552 *
2553 * I tried delaying after writing HCCR_CMD_CLEAR_RISC_INT to
2554 * make sure the old interrupt went away (to avoid 'ringing'
2555 * effects), but that didn't stop this from occurring.
2556 */
2557 junk = ISP_READ(isp, BIU_ISR);
2550 return (1);
2551 }
2552 } else {
2553 iptr = ISP_READ(isp, OUTMAILBOX5);
2554 }
2555
2556 if (sema) {
2557 ISP_WRITE(isp, BIU_SEMA, 0);

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

2563 * There are a lot of these- reasons unknown- mostly on
2564 * faster Alpha machines.
2565 *
2566 * I tried delaying after writing HCCR_CMD_CLEAR_RISC_INT to
2567 * make sure the old interrupt went away (to avoid 'ringing'
2568 * effects), but that didn't stop this from occurring.
2569 */
2570 junk = ISP_READ(isp, BIU_ISR);
2558 IDPRINTF(2, ("%s: null intr- isr %x (%x) iptr %x optr %x\n",
2559 isp->isp_name, isr, junk, iptr, optr));
2571 isp_prt(isp, ISP_LOGDEBUG2,
2572 "bogus intr- isr %x (%x) iptr %x optr %x",
2573 isr, junk, iptr, optr);
2560 }
2561
2562 while (optr != iptr) {
2563 ispstatusreq_t *sp;
2564 u_int16_t oop;
2565 int buddaboom = 0;
2566
2567 sp = (ispstatusreq_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr);
2568 oop = optr;
2574 }
2575
2576 while (optr != iptr) {
2577 ispstatusreq_t *sp;
2578 u_int16_t oop;
2579 int buddaboom = 0;
2580
2581 sp = (ispstatusreq_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr);
2582 oop = optr;
2569 optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN);
2583 optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN(isp));
2570 nlooked++;
2584 nlooked++;
2571 MemoryBarrier();
2572 /*
2573 * Do any appropriate unswizzling of what the Qlogic f/w has
2574 * written into memory so it makes sense to us. This is a
2585 /*
2586 * Do any appropriate unswizzling of what the Qlogic f/w has
2587 * written into memory so it makes sense to us. This is a
2575 * per-platform thing.
2588 * per-platform thing. Also includes any memory barriers.
2576 */
2589 */
2577 ISP_UNSWIZZLE_RESPONSE(isp, sp);
2590 ISP_UNSWIZZLE_RESPONSE(isp, sp, oop);
2578 if (sp->req_header.rqs_entry_type != RQSTYPE_RESPONSE) {
2579 if (isp_handle_other_response(isp, sp, &optr) == 0) {
2580 continue;
2581 }
2582 /*
2583 * It really has to be a bounced request just copied
2584 * from the request queue to the response queue. If
2585 * not, something bad has happened.
2586 */
2587 if (sp->req_header.rqs_entry_type != RQSTYPE_REQUEST) {
2591 if (sp->req_header.rqs_entry_type != RQSTYPE_RESPONSE) {
2592 if (isp_handle_other_response(isp, sp, &optr) == 0) {
2593 continue;
2594 }
2595 /*
2596 * It really has to be a bounced request just copied
2597 * from the request queue to the response queue. If
2598 * not, something bad has happened.
2599 */
2600 if (sp->req_header.rqs_entry_type != RQSTYPE_REQUEST) {
2588 PRINTF("%s: not RESPONSE in RESPONSE Queue "
2589 "(type 0x%x) @ idx %d (next %d)\n",
2590 isp->isp_name,
2601 isp_prt(isp, ISP_LOGERR, notresp,
2591 sp->req_header.rqs_entry_type, oop, optr);
2592 continue;
2593 }
2594 buddaboom = 1;
2595 }
2596
2597 if (sp->req_header.rqs_flags & 0xf) {
2598#define _RQS_OFLAGS \
2599 ~(RQSFLAG_CONTINUATION|RQSFLAG_FULL|RQSFLAG_BADHEADER|RQSFLAG_BADPACKET)
2600 if (sp->req_header.rqs_flags & RQSFLAG_CONTINUATION) {
2602 sp->req_header.rqs_entry_type, oop, optr);
2603 continue;
2604 }
2605 buddaboom = 1;
2606 }
2607
2608 if (sp->req_header.rqs_flags & 0xf) {
2609#define _RQS_OFLAGS \
2610 ~(RQSFLAG_CONTINUATION|RQSFLAG_FULL|RQSFLAG_BADHEADER|RQSFLAG_BADPACKET)
2611 if (sp->req_header.rqs_flags & RQSFLAG_CONTINUATION) {
2601 IDPRINTF(4, ("%s: continuation segment\n",
2602 isp->isp_name));
2612 isp_prt(isp, ISP_LOGWARN,
2613 "continuation segment");
2603 ISP_WRITE(isp, INMAILBOX5, optr);
2604 continue;
2605 }
2606 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
2614 ISP_WRITE(isp, INMAILBOX5, optr);
2615 continue;
2616 }
2617 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
2607 IDPRINTF(2, ("%s: internal queues full\n",
2608 isp->isp_name));
2618 isp_prt(isp, ISP_LOGDEBUG1,
2619 "internal queues full");
2609 /*
2610 * We'll synthesize a QUEUE FULL message below.
2611 */
2612 }
2613 if (sp->req_header.rqs_flags & RQSFLAG_BADHEADER) {
2620 /*
2621 * We'll synthesize a QUEUE FULL message below.
2622 */
2623 }
2624 if (sp->req_header.rqs_flags & RQSFLAG_BADHEADER) {
2614 PRINTF("%s: bad header\n", isp->isp_name);
2625 isp_prt(isp, ISP_LOGERR, "bad header flag");
2615 buddaboom++;
2616 }
2617 if (sp->req_header.rqs_flags & RQSFLAG_BADPACKET) {
2626 buddaboom++;
2627 }
2628 if (sp->req_header.rqs_flags & RQSFLAG_BADPACKET) {
2618 PRINTF("%s: bad request packet\n",
2619 isp->isp_name);
2629 isp_prt(isp, ISP_LOGERR, "bad request packet");
2620 buddaboom++;
2621 }
2622 if (sp->req_header.rqs_flags & _RQS_OFLAGS) {
2630 buddaboom++;
2631 }
2632 if (sp->req_header.rqs_flags & _RQS_OFLAGS) {
2623 PRINTF("%s: unknown flags in response (0x%x)\n",
2624 isp->isp_name, sp->req_header.rqs_flags);
2633 isp_prt(isp, ISP_LOGERR,
2634 "unknown flags (0x%x) in response",
2635 sp->req_header.rqs_flags);
2625 buddaboom++;
2626 }
2627#undef _RQS_OFLAGS
2628 }
2629 if (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1) {
2636 buddaboom++;
2637 }
2638#undef _RQS_OFLAGS
2639 }
2640 if (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1) {
2630 PRINTF("%s: bad request handle %d\n", isp->isp_name,
2631 sp->req_handle);
2641 isp_prt(isp, ISP_LOGERR,
2642 "bad request handle %d", sp->req_handle);
2632 ISP_WRITE(isp, INMAILBOX5, optr);
2633 continue;
2634 }
2635 xs = isp_find_xs(isp, sp->req_handle);
2636 if (xs == NULL) {
2643 ISP_WRITE(isp, INMAILBOX5, optr);
2644 continue;
2645 }
2646 xs = isp_find_xs(isp, sp->req_handle);
2647 if (xs == NULL) {
2637 PRINTF("%s: NULL xs in xflist (handle 0x%x)\n",
2638 isp->isp_name, sp->req_handle);
2648 isp_prt(isp, ISP_LOGERR,
2649 "cannot find handle 0x%x in xflist",
2650 sp->req_handle);
2639 ISP_WRITE(isp, INMAILBOX5, optr);
2640 continue;
2641 }
2642 isp_destroy_handle(isp, sp->req_handle);
2643 if (sp->req_status_flags & RQSTF_BUS_RESET) {
2644 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
2645 }
2646 if (buddaboom) {
2647 XS_SETERR(xs, HBA_BOTCH);
2648 }
2651 ISP_WRITE(isp, INMAILBOX5, optr);
2652 continue;
2653 }
2654 isp_destroy_handle(isp, sp->req_handle);
2655 if (sp->req_status_flags & RQSTF_BUS_RESET) {
2656 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
2657 }
2658 if (buddaboom) {
2659 XS_SETERR(xs, HBA_BOTCH);
2660 }
2649 XS_STS(xs) = sp->req_scsi_status & 0xff;
2661 *XS_STSP(xs) = sp->req_scsi_status & 0xff;
2650 if (IS_SCSI(isp)) {
2651 if (sp->req_state_flags & RQSF_GOT_SENSE) {
2662 if (IS_SCSI(isp)) {
2663 if (sp->req_state_flags & RQSF_GOT_SENSE) {
2652 MEMCPY(XS_SNSP(xs), sp->req_sense_data,
2653 XS_SNSLEN(xs));
2654 XS_SNS_IS_VALID(xs);
2664 XS_SAVE_SENSE(xs, sp);
2655 }
2656 /*
2657 * A new synchronous rate was negotiated for this
2658 * target. Mark state such that we'll go look up
2659 * that which has changed later.
2660 */
2661 if (sp->req_status_flags & RQSTF_NEGOTIATION) {
2662 sdparam *sdp = isp->isp_param;
2663 sdp += XS_CHANNEL(xs);
2664 sdp->isp_devparam[XS_TGT(xs)].dev_refresh = 1;
2665 isp->isp_update |= (1 << XS_CHANNEL(xs));
2666 }
2667 } else {
2668 if (sp->req_scsi_status & RQCS_SV) {
2665 }
2666 /*
2667 * A new synchronous rate was negotiated for this
2668 * target. Mark state such that we'll go look up
2669 * that which has changed later.
2670 */
2671 if (sp->req_status_flags & RQSTF_NEGOTIATION) {
2672 sdparam *sdp = isp->isp_param;
2673 sdp += XS_CHANNEL(xs);
2674 sdp->isp_devparam[XS_TGT(xs)].dev_refresh = 1;
2675 isp->isp_update |= (1 << XS_CHANNEL(xs));
2676 }
2677 } else {
2678 if (sp->req_scsi_status & RQCS_SV) {
2669 int amt = min(XS_SNSLEN(xs), sp->req_sense_len);
2670 MEMCPY(XS_SNSP(xs), sp->req_sense_data, amt);
2671 XS_SNS_IS_VALID(xs);
2679 XS_SAVE_SENSE(xs, sp);
2680 /* force that we 'got' sense */
2672 sp->req_state_flags |= RQSF_GOT_SENSE;
2681 sp->req_state_flags |= RQSF_GOT_SENSE;
2673 } else if (XS_STS(xs) == SCSI_CHECK) {
2674 IDPRINTF(2,
2675 ("%s: check condition with no sense data\n",
2676 isp->isp_name));
2677 }
2678 }
2682 }
2683 }
2679 if (XS_NOERR(xs) && XS_STS(xs) == SCSI_BUSY) {
2680 XS_SETERR(xs, HBA_TGTBSY);
2681 }
2682
2683 if (sp->req_header.rqs_entry_type == RQSTYPE_RESPONSE) {
2684
2685 if (sp->req_header.rqs_entry_type == RQSTYPE_RESPONSE) {
2684 if (XS_NOERR(xs)) {
2685 if (sp->req_completion_status != RQCS_COMPLETE) {
2686 isp_parse_status(isp, sp, xs);
2687 } else {
2688 XS_SETERR(xs, HBA_NOERROR);
2689 }
2686 XS_SET_STATE_STAT(isp, xs, sp);
2687 isp_parse_status(isp, sp, xs);
2688 if ((XS_NOERR(xs) || XS_ERR(xs) == HBA_NOERROR) &&
2689 (*XS_STSP(xs) == SCSI_BUSY)) {
2690 XS_SETERR(xs, HBA_TGTBSY);
2690 }
2691 } else if (sp->req_header.rqs_entry_type == RQSTYPE_REQUEST) {
2692 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
2693 /*
2694 * Force Queue Full status.
2695 */
2691 }
2692 } else if (sp->req_header.rqs_entry_type == RQSTYPE_REQUEST) {
2693 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
2694 /*
2695 * Force Queue Full status.
2696 */
2696 XS_STS(xs) = SCSI_QFULL;
2697 *XS_STSP(xs) = SCSI_QFULL;
2697 XS_SETERR(xs, HBA_NOERROR);
2698 } else if (XS_NOERR(xs)) {
2699 XS_SETERR(xs, HBA_BOTCH);
2700 }
2701 } else {
2698 XS_SETERR(xs, HBA_NOERROR);
2699 } else if (XS_NOERR(xs)) {
2700 XS_SETERR(xs, HBA_BOTCH);
2701 }
2702 } else {
2702 PRINTF("%s: unhandled respose queue type 0x%x\n",
2703 isp->isp_name, sp->req_header.rqs_entry_type);
2703 isp_prt(isp, ISP_LOGWARN,
2704 "unhandled respose queue type 0x%x",
2705 sp->req_header.rqs_entry_type);
2704 if (XS_NOERR(xs)) {
2705 XS_SETERR(xs, HBA_BOTCH);
2706 }
2707 }
2708 if (IS_SCSI(isp)) {
2709 XS_RESID(xs) = sp->req_resid;
2706 if (XS_NOERR(xs)) {
2707 XS_SETERR(xs, HBA_BOTCH);
2708 }
2709 }
2710 if (IS_SCSI(isp)) {
2711 XS_RESID(xs) = sp->req_resid;
2710 } else if (sp->req_scsi_status & RQCS_RU) {
2712 } else if (sp->req_scsi_status & RQCS_RV) {
2711 XS_RESID(xs) = sp->req_resid;
2713 XS_RESID(xs) = sp->req_resid;
2712 IDPRINTF(4, ("%s: cnt %d rsd %d\n", isp->isp_name,
2713 XS_XFRLEN(xs), sp->req_resid));
2714 isp_prt(isp, ISP_LOGDEBUG2, "cnt %d rsd %d",
2715 XS_XFRLEN(xs), sp->req_resid);
2714 }
2715 if (XS_XFRLEN(xs)) {
2716 ISP_DMAFREE(isp, xs, sp->req_handle);
2717 }
2716 }
2717 if (XS_XFRLEN(xs)) {
2718 ISP_DMAFREE(isp, xs, sp->req_handle);
2719 }
2718 if ((isp->isp_dblev >= 5) ||
2719 (isp->isp_dblev > 2 && !XS_NOERR(xs))) {
2720 PRINTF("%s(%d.%d): FIN dl%d resid%d STS %x",
2721 isp->isp_name, XS_TGT(xs), XS_LUN(xs),
2722 XS_XFRLEN(xs), XS_RESID(xs), XS_STS(xs));
2720 if (((isp->isp_dblev & (ISP_LOGDEBUG2|ISP_LOGDEBUG3))) ||
2721 ((isp->isp_dblev & ISP_LOGDEBUG1) && !XS_NOERR(xs))) {
2722 char skey;
2723 if (sp->req_state_flags & RQSF_GOT_SENSE) {
2723 if (sp->req_state_flags & RQSF_GOT_SENSE) {
2724 PRINTF(" Skey: %x", XS_SNSKEY(xs));
2725 if (!(XS_IS_SNS_VALID(xs))) {
2726 PRINTF(" BUT NOT SET");
2727 }
2724 skey = XS_SNSKEY(xs) & 0xf;
2725 if (skey < 10)
2726 skey += '0';
2727 else
2728 skey += 'a';
2729 } else if (*XS_STSP(xs) == SCSI_CHECK) {
2730 skey = '?';
2731 } else {
2732 skey = '.';
2728 }
2733 }
2729 PRINTF(" XS_ERR=0x%x\n", (unsigned int) XS_ERR(xs));
2734 isp_prt(isp, ISP_LOGALL, finmsg, XS_CHANNEL(xs),
2735 XS_TGT(xs), XS_LUN(xs), XS_XFRLEN(xs), XS_RESID(xs),
2736 *XS_STSP(xs), skey, XS_ERR(xs));
2730 }
2731
2732 if (isp->isp_nactive > 0)
2733 isp->isp_nactive--;
2734 complist[ndone++] = xs; /* defer completion call until later */
2737 }
2738
2739 if (isp->isp_nactive > 0)
2740 isp->isp_nactive--;
2741 complist[ndone++] = xs; /* defer completion call until later */
2742 if (ndone == MAX_REQUESTQ_COMPLETIONS) {
2743 break;
2744 }
2735 }
2736
2737 /*
2738 * If we looked at any commands, then it's valid to find out
2739 * what the outpointer is. It also is a trigger to update the
2740 * ISP's notion of what we've seen so far.
2741 */
2742 if (nlooked) {
2743 ISP_WRITE(isp, INMAILBOX5, optr);
2744 isp->isp_reqodx = ISP_READ(isp, OUTMAILBOX4);
2745 }
2746
2747 isp->isp_residx = optr;
2748 for (i = 0; i < ndone; i++) {
2749 xs = complist[i];
2750 if (xs) {
2745 }
2746
2747 /*
2748 * If we looked at any commands, then it's valid to find out
2749 * what the outpointer is. It also is a trigger to update the
2750 * ISP's notion of what we've seen so far.
2751 */
2752 if (nlooked) {
2753 ISP_WRITE(isp, INMAILBOX5, optr);
2754 isp->isp_reqodx = ISP_READ(isp, OUTMAILBOX4);
2755 }
2756
2757 isp->isp_residx = optr;
2758 for (i = 0; i < ndone; i++) {
2759 xs = complist[i];
2760 if (xs) {
2751 XS_CMD_DONE(xs);
2761 isp_done(xs);
2752 }
2753 }
2754 return (1);
2755}
2756
2757/*
2758 * Support routines.
2759 */

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

2779 isp->isp_sendmarker |= (1 << bus);
2780#ifdef ISP_TARGET_MODE
2781 isp_target_async(isp, bus, mbox);
2782#endif
2783 isp_async(isp, ISPASYNC_BUS_RESET, &bus);
2784 break;
2785 case ASYNC_SYSTEM_ERROR:
2786 mbox = ISP_READ(isp, OUTMAILBOX1);
2762 }
2763 }
2764 return (1);
2765}
2766
2767/*
2768 * Support routines.
2769 */

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

2789 isp->isp_sendmarker |= (1 << bus);
2790#ifdef ISP_TARGET_MODE
2791 isp_target_async(isp, bus, mbox);
2792#endif
2793 isp_async(isp, ISPASYNC_BUS_RESET, &bus);
2794 break;
2795 case ASYNC_SYSTEM_ERROR:
2796 mbox = ISP_READ(isp, OUTMAILBOX1);
2787 PRINTF("%s: Internal FW Error @ RISC Addr 0x%x\n",
2788 isp->isp_name, mbox);
2789 isp_restart(isp);
2797 isp_prt(isp, ISP_LOGERR,
2798 "Internal FW Error @ RISC Addr 0x%x", mbox);
2799 isp_reinit(isp);
2790 /* no point continuing after this */
2791 return (-1);
2792
2793 case ASYNC_RQS_XFER_ERR:
2800 /* no point continuing after this */
2801 return (-1);
2802
2803 case ASYNC_RQS_XFER_ERR:
2794 PRINTF("%s: Request Queue Transfer Error\n", isp->isp_name);
2804 isp_prt(isp, ISP_LOGERR, "Request Queue Transfer Error");
2795 break;
2796
2797 case ASYNC_RSP_XFER_ERR:
2805 break;
2806
2807 case ASYNC_RSP_XFER_ERR:
2798 PRINTF("%s: Response Queue Transfer Error\n", isp->isp_name);
2808 isp_prt(isp, ISP_LOGERR, "Response Queue Transfer Error");
2799 break;
2800
2801 case ASYNC_QWAKEUP:
2802 /*
2803 * We've just been notified that the Queue has woken up.
2804 * We don't need to be chatty about this- just unlatch things
2805 * and move on.
2806 */
2807 mbox = ISP_READ(isp, OUTMAILBOX4);
2808 break;
2809
2810 case ASYNC_TIMEOUT_RESET:
2809 break;
2810
2811 case ASYNC_QWAKEUP:
2812 /*
2813 * We've just been notified that the Queue has woken up.
2814 * We don't need to be chatty about this- just unlatch things
2815 * and move on.
2816 */
2817 mbox = ISP_READ(isp, OUTMAILBOX4);
2818 break;
2819
2820 case ASYNC_TIMEOUT_RESET:
2811 PRINTF("%s: timeout initiated SCSI bus reset of bus %d\n",
2812 isp->isp_name, bus);
2821 isp_prt(isp, ISP_LOGWARN,
2822 "timeout initiated SCSI bus reset of bus %d\n", bus);
2813 isp->isp_sendmarker |= (1 << bus);
2814#ifdef ISP_TARGET_MODE
2815 isp_target_async(isp, bus, mbox);
2816#endif
2817 break;
2818
2819 case ASYNC_DEVICE_RESET:
2823 isp->isp_sendmarker |= (1 << bus);
2824#ifdef ISP_TARGET_MODE
2825 isp_target_async(isp, bus, mbox);
2826#endif
2827 break;
2828
2829 case ASYNC_DEVICE_RESET:
2820 PRINTF("%s: device reset on bus %d\n", isp->isp_name, bus);
2830 isp_prt(isp, ISP_LOGINFO, "device reset on bus %d", bus);
2821 isp->isp_sendmarker |= (1 << bus);
2822#ifdef ISP_TARGET_MODE
2823 isp_target_async(isp, bus, mbox);
2824#endif
2825 break;
2826
2827 case ASYNC_EXTMSG_UNDERRUN:
2831 isp->isp_sendmarker |= (1 << bus);
2832#ifdef ISP_TARGET_MODE
2833 isp_target_async(isp, bus, mbox);
2834#endif
2835 break;
2836
2837 case ASYNC_EXTMSG_UNDERRUN:
2828 PRINTF("%s: extended message underrun\n", isp->isp_name);
2838 isp_prt(isp, ISP_LOGWARN, "extended message underrun");
2829 break;
2830
2831 case ASYNC_SCAM_INT:
2839 break;
2840
2841 case ASYNC_SCAM_INT:
2832 PRINTF("%s: SCAM interrupt\n", isp->isp_name);
2842 isp_prt(isp, ISP_LOGINFO, "SCAM interrupt");
2833 break;
2834
2835 case ASYNC_HUNG_SCSI:
2843 break;
2844
2845 case ASYNC_HUNG_SCSI:
2836 PRINTF("%s: stalled SCSI Bus after DATA Overrun\n",
2837 isp->isp_name);
2846 isp_prt(isp, ISP_LOGERR,
2847 "stalled SCSI Bus after DATA Overrun");
2838 /* XXX: Need to issue SCSI reset at this point */
2839 break;
2840
2841 case ASYNC_KILLED_BUS:
2848 /* XXX: Need to issue SCSI reset at this point */
2849 break;
2850
2851 case ASYNC_KILLED_BUS:
2842 PRINTF("%s: SCSI Bus reset after DATA Overrun\n",
2843 isp->isp_name);
2852 isp_prt(isp, ISP_LOGERR, "SCSI Bus reset after DATA Overrun");
2844 break;
2845
2846 case ASYNC_BUS_TRANSIT:
2847 mbox = ISP_READ(isp, OUTMAILBOX2);
2848 switch (mbox & 0x1c00) {
2849 case SXP_PINS_LVD_MODE:
2853 break;
2854
2855 case ASYNC_BUS_TRANSIT:
2856 mbox = ISP_READ(isp, OUTMAILBOX2);
2857 switch (mbox & 0x1c00) {
2858 case SXP_PINS_LVD_MODE:
2850 PRINTF("%s: Transition to LVD mode\n", isp->isp_name);
2859 isp_prt(isp, ISP_LOGINFO, "Transition to LVD mode");
2851 ((sdparam *)isp->isp_param)->isp_diffmode = 0;
2852 ((sdparam *)isp->isp_param)->isp_ultramode = 0;
2853 ((sdparam *)isp->isp_param)->isp_lvdmode = 1;
2854 break;
2855 case SXP_PINS_HVD_MODE:
2860 ((sdparam *)isp->isp_param)->isp_diffmode = 0;
2861 ((sdparam *)isp->isp_param)->isp_ultramode = 0;
2862 ((sdparam *)isp->isp_param)->isp_lvdmode = 1;
2863 break;
2864 case SXP_PINS_HVD_MODE:
2856 PRINTF("%s: Transition to Differential mode\n",
2857 isp->isp_name);
2865 isp_prt(isp, ISP_LOGINFO,
2866 "Transition to Differential mode");
2858 ((sdparam *)isp->isp_param)->isp_diffmode = 1;
2859 ((sdparam *)isp->isp_param)->isp_ultramode = 0;
2860 ((sdparam *)isp->isp_param)->isp_lvdmode = 0;
2861 break;
2862 case SXP_PINS_SE_MODE:
2867 ((sdparam *)isp->isp_param)->isp_diffmode = 1;
2868 ((sdparam *)isp->isp_param)->isp_ultramode = 0;
2869 ((sdparam *)isp->isp_param)->isp_lvdmode = 0;
2870 break;
2871 case SXP_PINS_SE_MODE:
2863 PRINTF("%s: Transition to Single Ended mode\n",
2864 isp->isp_name);
2872 isp_prt(isp, ISP_LOGINFO,
2873 "Transition to Single Ended mode");
2865 ((sdparam *)isp->isp_param)->isp_diffmode = 0;
2866 ((sdparam *)isp->isp_param)->isp_ultramode = 1;
2867 ((sdparam *)isp->isp_param)->isp_lvdmode = 0;
2868 break;
2869 default:
2874 ((sdparam *)isp->isp_param)->isp_diffmode = 0;
2875 ((sdparam *)isp->isp_param)->isp_ultramode = 1;
2876 ((sdparam *)isp->isp_param)->isp_lvdmode = 0;
2877 break;
2878 default:
2870 PRINTF("%s: Transition to unknown mode 0x%x\n",
2871 isp->isp_name, mbox);
2879 isp_prt(isp, ISP_LOGWARN,
2880 "Transition to Unknown Mode 0x%x", mbox);
2872 break;
2873 }
2874 /*
2875 * XXX: Set up to renegotiate again!
2876 */
2877 /* Can only be for a 1080... */
2878 isp->isp_sendmarker |= (1 << bus);
2879 break;
2880
2881 case ASYNC_CMD_CMPLT:
2882 fast_post_handle = (ISP_READ(isp, OUTMAILBOX2) << 16) |
2883 ISP_READ(isp, OUTMAILBOX1);
2881 break;
2882 }
2883 /*
2884 * XXX: Set up to renegotiate again!
2885 */
2886 /* Can only be for a 1080... */
2887 isp->isp_sendmarker |= (1 << bus);
2888 break;
2889
2890 case ASYNC_CMD_CMPLT:
2891 fast_post_handle = (ISP_READ(isp, OUTMAILBOX2) << 16) |
2892 ISP_READ(isp, OUTMAILBOX1);
2884 IDPRINTF(4, ("%s: fast post completion of %u\n", isp->isp_name,
2885 fast_post_handle));
2893 isp_prt(isp, ISP_LOGDEBUG3, "fast post completion of %u",
2894 fast_post_handle);
2886 break;
2887
2888 case ASYNC_CTIO_DONE:
2889 /* Should only occur when Fast Posting Set for 2100s */
2895 break;
2896
2897 case ASYNC_CTIO_DONE:
2898 /* Should only occur when Fast Posting Set for 2100s */
2890 PRINTF("%s: CTIO done\n", isp->isp_name);
2899 isp_prt(isp, ISP_LOGDEBUG3, "Fast Posting CTIO done");
2891 break;
2892
2893 case ASYNC_LIP_OCCURRED:
2894 ((fcparam *) isp->isp_param)->isp_lipseq =
2895 ISP_READ(isp, OUTMAILBOX1);
2896 ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
2897 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_LIP_RCVD;
2898 isp->isp_sendmarker = 1;
2899 isp_mark_getpdb_all(isp);
2900 break;
2901
2902 case ASYNC_LIP_OCCURRED:
2903 ((fcparam *) isp->isp_param)->isp_lipseq =
2904 ISP_READ(isp, OUTMAILBOX1);
2905 ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
2906 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_LIP_RCVD;
2907 isp->isp_sendmarker = 1;
2908 isp_mark_getpdb_all(isp);
2900 IDPRINTF(1, ("%s: LIP occurred\n", isp->isp_name));
2909 isp_prt(isp, ISP_LOGINFO, "LIP occurred");
2901#ifdef ISP_TARGET_MODE
2902 isp_target_async(isp, bus, mbox);
2903#endif
2904 break;
2905
2906 case ASYNC_LOOP_UP:
2907 isp->isp_sendmarker = 1;
2908 ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;

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

2925#endif
2926 break;
2927
2928 case ASYNC_LOOP_RESET:
2929 isp->isp_sendmarker = 1;
2930 ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
2931 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_NIL;
2932 isp_mark_getpdb_all(isp);
2910#ifdef ISP_TARGET_MODE
2911 isp_target_async(isp, bus, mbox);
2912#endif
2913 break;
2914
2915 case ASYNC_LOOP_UP:
2916 isp->isp_sendmarker = 1;
2917 ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;

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

2934#endif
2935 break;
2936
2937 case ASYNC_LOOP_RESET:
2938 isp->isp_sendmarker = 1;
2939 ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
2940 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_NIL;
2941 isp_mark_getpdb_all(isp);
2933 PRINTF("%s: Loop RESET\n", isp->isp_name);
2942 isp_prt(isp, ISP_LOGINFO, "Loop RESET");
2934#ifdef ISP_TARGET_MODE
2935 isp_target_async(isp, bus, mbox);
2936#endif
2937 break;
2938
2939 case ASYNC_PDB_CHANGED:
2940 isp->isp_sendmarker = 1;
2941 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_PDB_RCVD;
2942 isp_mark_getpdb_all(isp);
2943#ifdef ISP_TARGET_MODE
2944 isp_target_async(isp, bus, mbox);
2945#endif
2946 break;
2947
2948 case ASYNC_PDB_CHANGED:
2949 isp->isp_sendmarker = 1;
2950 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_PDB_RCVD;
2951 isp_mark_getpdb_all(isp);
2943 IDPRINTF(1, ("%s: Port Database Changed\n", isp->isp_name));
2952 isp_prt(isp, ISP_LOGINFO, "Port Database Changed");
2944 break;
2945
2946 case ASYNC_CHANGE_NOTIFY:
2947 isp_mark_getpdb_all(isp);
2948 /*
2949 * Not correct, but it will force us to rescan the loop.
2950 */
2951 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_PDB_RCVD;

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

2959 ((fcparam *) isp->isp_param)->isp_topo = TOPO_F_PORT;
2960 isp_mark_getpdb_all(isp);
2961 isp->isp_sendmarker = 1;
2962 ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
2963 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_LIP_RCVD;
2964#ifdef ISP_TARGET_MODE
2965 isp_target_async(isp, bus, mbox);
2966#endif
2953 break;
2954
2955 case ASYNC_CHANGE_NOTIFY:
2956 isp_mark_getpdb_all(isp);
2957 /*
2958 * Not correct, but it will force us to rescan the loop.
2959 */
2960 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_PDB_RCVD;

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

2968 ((fcparam *) isp->isp_param)->isp_topo = TOPO_F_PORT;
2969 isp_mark_getpdb_all(isp);
2970 isp->isp_sendmarker = 1;
2971 ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT;
2972 ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_LIP_RCVD;
2973#ifdef ISP_TARGET_MODE
2974 isp_target_async(isp, bus, mbox);
2975#endif
2967 PRINTF("%s: Point-to-Point mode\n", isp->isp_name);
2976 isp_prt(isp, ISP_LOGINFO, "Point-to-Point mode");
2968 break;
2969
2970 case ASYNC_CONNMODE:
2971 mbox = ISP_READ(isp, OUTMAILBOX1);
2972 switch (mbox) {
2973 case ISP_CONN_LOOP:
2977 break;
2978
2979 case ASYNC_CONNMODE:
2980 mbox = ISP_READ(isp, OUTMAILBOX1);
2981 switch (mbox) {
2982 case ISP_CONN_LOOP:
2974 PRINTF("%s: Point-to-Point -> Loop mode\n",
2975 isp->isp_name);
2983 isp_prt(isp, ISP_LOGINFO, "Point-to-Point->Loop mode");
2976 break;
2977 case ISP_CONN_PTP:
2984 break;
2985 case ISP_CONN_PTP:
2978 PRINTF("%s: Loop -> Point-to-Point mode\n",
2979 isp->isp_name);
2986 isp_prt(isp, ISP_LOGINFO, "Loop->Point-to-Point mode");
2980 break;
2981 case ISP_CONN_BADLIP:
2987 break;
2988 case ISP_CONN_BADLIP:
2982 PRINTF("%s: Point-to-Point -> Loop mode (1)\n",
2983 isp->isp_name);
2989 isp_prt(isp, ISP_LOGWARN,
2990 "Point-to-Point->Loop mode (1)");
2984 break;
2985 case ISP_CONN_FATAL:
2991 break;
2992 case ISP_CONN_FATAL:
2986 PRINTF("%s: FATAL CONNECTION ERROR\n", isp->isp_name);
2987 isp_restart(isp);
2993 isp_prt(isp, ISP_LOGERR, "FATAL CONNECTION ERROR");
2994 isp_reinit(isp);
2988 /* no point continuing after this */
2989 return (-1);
2990
2991 case ISP_CONN_LOOPBACK:
2995 /* no point continuing after this */
2996 return (-1);
2997
2998 case ISP_CONN_LOOPBACK:
2992 PRINTF("%s: Looped Back in Point-to-Point mode\n",
2993 isp->isp_name);
2999 isp_prt(isp, ISP_LOGWARN,
3000 "Looped Back in Point-to-Point mode");
2994 }
2995 break;
2996
2997 default:
3001 }
3002 break;
3003
3004 default:
2998 PRINTF("%s: unknown async code 0x%x\n", isp->isp_name, mbox);
3005 isp_prt(isp, ISP_LOGWARN, "Unknown Async Code 0x%x", mbox);
2999 break;
3000 }
3001 return (fast_post_handle);
3002}
3003
3004/*
3005 * Handle other response entries. A pointer to the request queue output
3006 * index is here in case we want to eat several entries at once, although

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

3022 case RQSTYPE_NOTIFY_ACK:
3023 case RQSTYPE_CTIO1:
3024 case RQSTYPE_ATIO2:
3025 case RQSTYPE_CTIO2:
3026 case RQSTYPE_CTIO3:
3027#ifdef ISP_TARGET_MODE
3028 return (isp_target_notify(isp, sp, optrp));
3029#else
3006 break;
3007 }
3008 return (fast_post_handle);
3009}
3010
3011/*
3012 * Handle other response entries. A pointer to the request queue output
3013 * index is here in case we want to eat several entries at once, although

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

3029 case RQSTYPE_NOTIFY_ACK:
3030 case RQSTYPE_CTIO1:
3031 case RQSTYPE_ATIO2:
3032 case RQSTYPE_CTIO2:
3033 case RQSTYPE_CTIO3:
3034#ifdef ISP_TARGET_MODE
3035 return (isp_target_notify(isp, sp, optrp));
3036#else
3037 optrp = optrp;
3030 /* FALLTHROUGH */
3031#endif
3032 case RQSTYPE_REQUEST:
3033 default:
3038 /* FALLTHROUGH */
3039#endif
3040 case RQSTYPE_REQUEST:
3041 default:
3034 PRINTF("%s: unhandled response type 0x%x\n", isp->isp_name,
3042 isp_prt(isp, ISP_LOGWARN, "Unhandled Response Type 0x%x",
3035 sp->req_header.rqs_entry_type);
3036 return (-1);
3037 }
3038}
3039
3040static void
3041isp_parse_status(isp, sp, xs)
3042 struct ispsoftc *isp;
3043 ispstatusreq_t *sp;
3043 sp->req_header.rqs_entry_type);
3044 return (-1);
3045 }
3046}
3047
3048static void
3049isp_parse_status(isp, sp, xs)
3050 struct ispsoftc *isp;
3051 ispstatusreq_t *sp;
3044 ISP_SCSI_XFER_T *xs;
3052 XS_T *xs;
3045{
3053{
3046 switch (sp->req_completion_status) {
3054 switch (sp->req_completion_status & 0xff) {
3047 case RQCS_COMPLETE:
3055 case RQCS_COMPLETE:
3048 XS_SETERR(xs, HBA_NOERROR);
3056 if (XS_NOERR(xs)) {
3057 XS_SETERR(xs, HBA_NOERROR);
3058 }
3049 return;
3050
3051 case RQCS_INCOMPLETE:
3052 if ((sp->req_state_flags & RQSF_GOT_TARGET) == 0) {
3059 return;
3060
3061 case RQCS_INCOMPLETE:
3062 if ((sp->req_state_flags & RQSF_GOT_TARGET) == 0) {
3053 IDPRINTF(3, ("%s: Selection Timeout for %d.%d.%d\n",
3054 isp->isp_name, XS_TGT(xs), XS_LUN(xs),
3055 XS_CHANNEL(xs)));
3056 XS_SETERR(xs, HBA_SELTIMEOUT);
3063 isp_prt(isp, ISP_LOGDEBUG0,
3064 "Selection Timeout for %d.%d.%d",
3065 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
3066 if (XS_NOERR(xs)) {
3067 XS_SETERR(xs, HBA_SELTIMEOUT);
3068 }
3057 return;
3058 }
3069 return;
3070 }
3059 PRINTF("%s: command incomplete for %d.%d.%d, state 0x%x\n",
3060 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs),
3071 isp_prt(isp, ISP_LOGERR,
3072 "command incomplete for %d.%d.%d, state 0x%x",
3073 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs),
3061 sp->req_state_flags);
3062 break;
3063
3064 case RQCS_DMA_ERROR:
3074 sp->req_state_flags);
3075 break;
3076
3077 case RQCS_DMA_ERROR:
3065 PRINTF("%s: DMA error for command on %d.%d.%d\n",
3066 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3078 isp_prt(isp, ISP_LOGERR, "DMA error for command on %d.%d.%d",
3079 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3067 break;
3068
3069 case RQCS_TRANSPORT_ERROR:
3080 break;
3081
3082 case RQCS_TRANSPORT_ERROR:
3070 PRINTF("%s: transport error for %d.%d.%d\n",
3071 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3072 isp_prtstst(sp);
3083 {
3084 char buf[172];
3085 buf[0] = 0;
3086 STRNCAT(buf, "states=>", sizeof buf);
3087 if (sp->req_state_flags & RQSF_GOT_BUS) {
3088 STRNCAT(buf, " GOT_BUS", sizeof buf);
3089 }
3090 if (sp->req_state_flags & RQSF_GOT_TARGET) {
3091 STRNCAT(buf, " GOT_TGT", sizeof buf);
3092 }
3093 if (sp->req_state_flags & RQSF_SENT_CDB) {
3094 STRNCAT(buf, " SENT_CDB", sizeof buf);
3095 }
3096 if (sp->req_state_flags & RQSF_XFRD_DATA) {
3097 STRNCAT(buf, " XFRD_DATA", sizeof buf);
3098 }
3099 if (sp->req_state_flags & RQSF_GOT_STATUS) {
3100 STRNCAT(buf, " GOT_STS", sizeof buf);
3101 }
3102 if (sp->req_state_flags & RQSF_GOT_SENSE) {
3103 STRNCAT(buf, " GOT_SNS", sizeof buf);
3104 }
3105 if (sp->req_state_flags & RQSF_XFER_COMPLETE) {
3106 STRNCAT(buf, " XFR_CMPLT", sizeof buf);
3107 }
3108 STRNCAT(buf, "\nstatus=>", sizeof buf);
3109 if (sp->req_status_flags & RQSTF_DISCONNECT) {
3110 STRNCAT(buf, " Disconnect", sizeof buf);
3111 }
3112 if (sp->req_status_flags & RQSTF_SYNCHRONOUS) {
3113 STRNCAT(buf, " Sync_xfr", sizeof buf);
3114 }
3115 if (sp->req_status_flags & RQSTF_PARITY_ERROR) {
3116 STRNCAT(buf, " Parity", sizeof buf);
3117 }
3118 if (sp->req_status_flags & RQSTF_BUS_RESET) {
3119 STRNCAT(buf, " Bus_Reset", sizeof buf);
3120 }
3121 if (sp->req_status_flags & RQSTF_DEVICE_RESET) {
3122 STRNCAT(buf, " Device_Reset", sizeof buf);
3123 }
3124 if (sp->req_status_flags & RQSTF_ABORTED) {
3125 STRNCAT(buf, " Aborted", sizeof buf);
3126 }
3127 if (sp->req_status_flags & RQSTF_TIMEOUT) {
3128 STRNCAT(buf, " Timeout", sizeof buf);
3129 }
3130 if (sp->req_status_flags & RQSTF_NEGOTIATION) {
3131 STRNCAT(buf, " Negotiation", sizeof buf);
3132 }
3133 isp_prt(isp, ISP_LOGERR, "%s", buf);
3134 isp_prt(isp, ISP_LOGERR, "transport error for %d.%d.%d:\n%s",
3135 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), buf);
3073 break;
3136 break;
3074
3137 }
3075 case RQCS_RESET_OCCURRED:
3138 case RQCS_RESET_OCCURRED:
3076 IDPRINTF(1, ("%s: bus reset destroyed command for %d.%d.%d\n",
3077 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)));
3139 isp_prt(isp, ISP_LOGWARN,
3140 "bus reset destroyed command for %d.%d.%d",
3141 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3078 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
3142 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
3079 XS_SETERR(xs, HBA_BUSRESET);
3143 if (XS_NOERR(xs)) {
3144 XS_SETERR(xs, HBA_BUSRESET);
3145 }
3080 return;
3081
3082 case RQCS_ABORTED:
3146 return;
3147
3148 case RQCS_ABORTED:
3083 PRINTF("%s: command aborted for %d.%d.%d\n",
3084 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3149 isp_prt(isp, ISP_LOGERR, "command aborted for %d.%d.%d",
3150 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3085 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
3151 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
3086 XS_SETERR(xs, HBA_ABORTED);
3152 if (XS_NOERR(xs)) {
3153 XS_SETERR(xs, HBA_ABORTED);
3154 }
3087 return;
3088
3089 case RQCS_TIMEOUT:
3155 return;
3156
3157 case RQCS_TIMEOUT:
3090 IDPRINTF(2, ("%s: command timed out for %d.%d.%d\n",
3091 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)));
3092 XS_SETERR(xs, HBA_CMDTIMEOUT);
3158 isp_prt(isp, ISP_LOGWARN, "command timed out for %d.%d.%d",
3159 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3160 if (XS_NOERR(xs)) {
3161 XS_SETERR(xs, HBA_CMDTIMEOUT);
3162 }
3093 return;
3094
3095 case RQCS_DATA_OVERRUN:
3096 if (IS_FC(isp)) {
3097 XS_RESID(xs) = sp->req_resid;
3098 break;
3099 }
3163 return;
3164
3165 case RQCS_DATA_OVERRUN:
3166 if (IS_FC(isp)) {
3167 XS_RESID(xs) = sp->req_resid;
3168 break;
3169 }
3100 PRINTF("%s: data overrun for command on %d.%d.%d\n",
3101 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3102 XS_SETERR(xs, HBA_DATAOVR);
3170 isp_prt(isp, ISP_LOGERR, "data overrun for command on %d.%d.%d",
3171 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3172 if (XS_NOERR(xs)) {
3173 XS_SETERR(xs, HBA_DATAOVR);
3174 }
3103 return;
3104
3105 case RQCS_COMMAND_OVERRUN:
3175 return;
3176
3177 case RQCS_COMMAND_OVERRUN:
3106 PRINTF("%s: command overrun for command on %d.%d.%d\n",
3107 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3178 isp_prt(isp, ISP_LOGERR,
3179 "command overrun for command on %d.%d.%d",
3180 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3108 break;
3109
3110 case RQCS_STATUS_OVERRUN:
3181 break;
3182
3183 case RQCS_STATUS_OVERRUN:
3111 PRINTF("%s: status overrun for command on %d.%d.%d\n",
3112 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3184 isp_prt(isp, ISP_LOGERR,
3185 "status overrun for command on %d.%d.%d",
3186 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3113 break;
3114
3115 case RQCS_BAD_MESSAGE:
3187 break;
3188
3189 case RQCS_BAD_MESSAGE:
3116 PRINTF("%s: msg not COMMAND COMPLETE after status %d.%d.%d\n",
3117 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3190 isp_prt(isp, ISP_LOGERR,
3191 "msg not COMMAND COMPLETE after status %d.%d.%d",
3192 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3118 break;
3119
3120 case RQCS_NO_MESSAGE_OUT:
3193 break;
3194
3195 case RQCS_NO_MESSAGE_OUT:
3121 PRINTF("%s: No MESSAGE OUT phase after selection on %d.%d.%d\n",
3122 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3196 isp_prt(isp, ISP_LOGERR,
3197 "No MESSAGE OUT phase after selection on %d.%d.%d",
3198 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3123 break;
3124
3125 case RQCS_EXT_ID_FAILED:
3199 break;
3200
3201 case RQCS_EXT_ID_FAILED:
3126 PRINTF("%s: EXTENDED IDENTIFY failed %d.%d.%d\n",
3127 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3202 isp_prt(isp, ISP_LOGERR, "EXTENDED IDENTIFY failed %d.%d.%d",
3203 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3128 break;
3129
3130 case RQCS_IDE_MSG_FAILED:
3204 break;
3205
3206 case RQCS_IDE_MSG_FAILED:
3131 PRINTF("%s: INITIATOR DETECTED ERROR rejected by %d.%d.%d\n",
3132 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3207 isp_prt(isp, ISP_LOGERR,
3208 "INITIATOR DETECTED ERROR rejected by %d.%d.%d",
3209 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3133 break;
3134
3135 case RQCS_ABORT_MSG_FAILED:
3210 break;
3211
3212 case RQCS_ABORT_MSG_FAILED:
3136 PRINTF("%s: ABORT OPERATION rejected by %d.%d.%d\n",
3137 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3213 isp_prt(isp, ISP_LOGERR, "ABORT OPERATION rejected by %d.%d.%d",
3214 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3138 break;
3139
3140 case RQCS_REJECT_MSG_FAILED:
3215 break;
3216
3217 case RQCS_REJECT_MSG_FAILED:
3141 PRINTF("%s: MESSAGE REJECT rejected by %d.%d.%d\n",
3142 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3218 isp_prt(isp, ISP_LOGERR, "MESSAGE REJECT rejected by %d.%d.%d",
3219 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3143 break;
3144
3145 case RQCS_NOP_MSG_FAILED:
3220 break;
3221
3222 case RQCS_NOP_MSG_FAILED:
3146 PRINTF("%s: NOP rejected by %d.%d.%d\n",
3147 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3223 isp_prt(isp, ISP_LOGERR, "NOP rejected by %d.%d.%d",
3224 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3148 break;
3149
3150 case RQCS_PARITY_ERROR_MSG_FAILED:
3225 break;
3226
3227 case RQCS_PARITY_ERROR_MSG_FAILED:
3151 PRINTF("%s: MESSAGE PARITY ERROR rejected by %d.%d.%d\n",
3152 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3228 isp_prt(isp, ISP_LOGERR,
3229 "MESSAGE PARITY ERROR rejected by %d.%d.%d",
3230 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3153 break;
3154
3155 case RQCS_DEVICE_RESET_MSG_FAILED:
3231 break;
3232
3233 case RQCS_DEVICE_RESET_MSG_FAILED:
3156 PRINTF("%s: BUS DEVICE RESET rejected by %d.%d.%d\n",
3157 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3234 isp_prt(isp, ISP_LOGWARN,
3235 "BUS DEVICE RESET rejected by %d.%d.%d",
3236 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3158 break;
3159
3160 case RQCS_ID_MSG_FAILED:
3237 break;
3238
3239 case RQCS_ID_MSG_FAILED:
3161 PRINTF("%s: IDENTIFY rejected by %d.%d.%d\n",
3162 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3240 isp_prt(isp, ISP_LOGERR, "IDENTIFY rejected by %d.%d.%d",
3241 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3163 break;
3164
3165 case RQCS_UNEXP_BUS_FREE:
3242 break;
3243
3244 case RQCS_UNEXP_BUS_FREE:
3166 PRINTF("%s: %d.%d.%d had an unexpected bus free\n",
3167 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3245 isp_prt(isp, ISP_LOGERR, "%d.%d.%d had an unexpected bus free",
3246 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3168 break;
3169
3170 case RQCS_DATA_UNDERRUN:
3171 if (IS_FC(isp)) {
3172 XS_RESID(xs) = sp->req_resid;
3173 }
3247 break;
3248
3249 case RQCS_DATA_UNDERRUN:
3250 if (IS_FC(isp)) {
3251 XS_RESID(xs) = sp->req_resid;
3252 }
3174 XS_SETERR(xs, HBA_NOERROR);
3253 if (XS_NOERR(xs)) {
3254 XS_SETERR(xs, HBA_NOERROR);
3255 }
3175 return;
3176
3177 case RQCS_XACT_ERR1:
3256 return;
3257
3258 case RQCS_XACT_ERR1:
3178 PRINTF("%s: HBA attempted queued transaction with disconnect "
3179 "not set for %d.%d.%d\n", isp->isp_name, XS_CHANNEL(xs),
3259 isp_prt(isp, ISP_LOGERR, xact1, XS_CHANNEL(xs),
3180 XS_TGT(xs), XS_LUN(xs));
3181 break;
3182
3183 case RQCS_XACT_ERR2:
3260 XS_TGT(xs), XS_LUN(xs));
3261 break;
3262
3263 case RQCS_XACT_ERR2:
3184 PRINTF("%s: HBA attempted queued transaction to target "
3185 "routine %d on target %d, bus %d\n", isp->isp_name,
3264 isp_prt(isp, ISP_LOGERR, xact2,
3186 XS_LUN(xs), XS_TGT(xs), XS_CHANNEL(xs));
3187 break;
3188
3189 case RQCS_XACT_ERR3:
3265 XS_LUN(xs), XS_TGT(xs), XS_CHANNEL(xs));
3266 break;
3267
3268 case RQCS_XACT_ERR3:
3190 PRINTF("%s: HBA attempted queued transaction for target %d lun "
3191 "%d on bus %d when queueing disabled\n", isp->isp_name,
3192 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
3269 isp_prt(isp, ISP_LOGERR, xact3, XS_TGT(xs),
3270 XS_LUN(xs), XS_CHANNEL(xs));
3193 break;
3194
3195 case RQCS_BAD_ENTRY:
3271 break;
3272
3273 case RQCS_BAD_ENTRY:
3196 PRINTF("%s: invalid IOCB entry type detected\n", isp->isp_name);
3274 isp_prt(isp, ISP_LOGERR, "Invalid IOCB entry type detected");
3197 break;
3198
3199 case RQCS_QUEUE_FULL:
3275 break;
3276
3277 case RQCS_QUEUE_FULL:
3200 IDPRINTF(3, ("%s: internal queues full for target %d lun %d "
3201 "bus %d, status 0x%x\n", isp->isp_name, XS_TGT(xs),
3202 XS_LUN(xs), XS_CHANNEL(xs), XS_STS(xs)));
3278 isp_prt(isp, ISP_LOGDEBUG1,
3279 "internal queues full for %d.%d.%d status 0x%x", XS_TGT(xs),
3280 XS_LUN(xs), XS_CHANNEL(xs), *XS_STSP(xs));
3203 /*
3204 * If QFULL or some other status byte is set, then this
3205 * isn't an error, per se.
3206 */
3281 /*
3282 * If QFULL or some other status byte is set, then this
3283 * isn't an error, per se.
3284 */
3207 if (XS_STS(xs) != 0) {
3285 if (*XS_STSP(xs) != SCSI_GOOD && XS_NOERR(xs)) {
3208 XS_SETERR(xs, HBA_NOERROR);
3209 return;
3210 }
3211 break;
3212
3213 case RQCS_PHASE_SKIPPED:
3286 XS_SETERR(xs, HBA_NOERROR);
3287 return;
3288 }
3289 break;
3290
3291 case RQCS_PHASE_SKIPPED:
3214 PRINTF("%s: SCSI phase skipped (e.g., COMMAND COMPLETE w/o "
3215 "STATUS phase) for target %d lun %d bus %d\n",
3216 isp->isp_name, XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
3292 isp_prt(isp, ISP_LOGERR, pskip,
3293 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
3217 break;
3218
3219 case RQCS_ARQS_FAILED:
3294 break;
3295
3296 case RQCS_ARQS_FAILED:
3220 PRINTF("%s: Auto Request Sense failed for %d.%d.%d\n",
3221 isp->isp_name, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3297 isp_prt(isp, ISP_LOGERR,
3298 "Auto Request Sense failed for %d.%d.%d",
3299 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
3300 if (XS_NOERR(xs)) {
3301 XS_SETERR(xs, HBA_ARQFAIL);
3302 }
3222 return;
3223
3224 case RQCS_WIDE_FAILED:
3303 return;
3304
3305 case RQCS_WIDE_FAILED:
3225 PRINTF("%s: Wide Negotiation failed for %d.%d.%d\n",
3226 isp->isp_name, XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
3306 isp_prt(isp, ISP_LOGERR,
3307 "Wide Negotiation failed for %d.%d.%d",
3308 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
3227 if (IS_SCSI(isp)) {
3228 sdparam *sdp = isp->isp_param;
3229 sdp += XS_CHANNEL(xs);
3230 sdp->isp_devparam[XS_TGT(xs)].dev_flags &= ~DPARM_WIDE;
3231 sdp->isp_devparam[XS_TGT(xs)].dev_update = 1;
3232 isp->isp_update |= (1 << XS_CHANNEL(xs));
3233 }
3309 if (IS_SCSI(isp)) {
3310 sdparam *sdp = isp->isp_param;
3311 sdp += XS_CHANNEL(xs);
3312 sdp->isp_devparam[XS_TGT(xs)].dev_flags &= ~DPARM_WIDE;
3313 sdp->isp_devparam[XS_TGT(xs)].dev_update = 1;
3314 isp->isp_update |= (1 << XS_CHANNEL(xs));
3315 }
3234 XS_SETERR(xs, HBA_NOERROR);
3316 if (XS_NOERR(xs)) {
3317 XS_SETERR(xs, HBA_NOERROR);
3318 }
3235 return;
3236
3237 case RQCS_SYNCXFER_FAILED:
3319 return;
3320
3321 case RQCS_SYNCXFER_FAILED:
3238 PRINTF("%s: SDTR Message failed for target %d.%d.%d\n",
3239 isp->isp_name, XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
3322 isp_prt(isp, ISP_LOGERR,
3323 "SDTR Message failed for target %d.%d.%d",
3324 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
3240 if (IS_SCSI(isp)) {
3241 sdparam *sdp = isp->isp_param;
3242 sdp += XS_CHANNEL(xs);
3243 sdp->isp_devparam[XS_TGT(xs)].dev_flags &= ~DPARM_SYNC;
3244 sdp->isp_devparam[XS_TGT(xs)].dev_update = 1;
3245 isp->isp_update |= (1 << XS_CHANNEL(xs));
3246 }
3247 break;
3248
3249 case RQCS_LVD_BUSERR:
3325 if (IS_SCSI(isp)) {
3326 sdparam *sdp = isp->isp_param;
3327 sdp += XS_CHANNEL(xs);
3328 sdp->isp_devparam[XS_TGT(xs)].dev_flags &= ~DPARM_SYNC;
3329 sdp->isp_devparam[XS_TGT(xs)].dev_update = 1;
3330 isp->isp_update |= (1 << XS_CHANNEL(xs));
3331 }
3332 break;
3333
3334 case RQCS_LVD_BUSERR:
3250 PRINTF("%s: Bad LVD condition while talking to %d.%d.%d\n",
3251 isp->isp_name, XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
3335 isp_prt(isp, ISP_LOGERR,
3336 "Bad LVD condition while talking to %d.%d.%d",
3337 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
3252 break;
3253
3254 case RQCS_PORT_UNAVAILABLE:
3255 /*
3256 * No such port on the loop. Moral equivalent of SELTIMEO
3257 */
3338 break;
3339
3340 case RQCS_PORT_UNAVAILABLE:
3341 /*
3342 * No such port on the loop. Moral equivalent of SELTIMEO
3343 */
3258 IDPRINTF(3, ("%s: Port Unavailable for target %d\n",
3259 isp->isp_name, XS_TGT(xs)));
3260 XS_SETERR(xs, HBA_SELTIMEOUT);
3344 isp_prt(isp, ISP_LOGINFO,
3345 "Port Unavailable for target %d", XS_TGT(xs));
3346 if (XS_NOERR(xs)) {
3347 XS_SETERR(xs, HBA_SELTIMEOUT);
3348 }
3261 return;
3262
3263 case RQCS_PORT_LOGGED_OUT:
3264 /*
3265 * It was there (maybe)- treat as a selection timeout.
3266 */
3349 return;
3350
3351 case RQCS_PORT_LOGGED_OUT:
3352 /*
3353 * It was there (maybe)- treat as a selection timeout.
3354 */
3267 IDPRINTF(2, ("%s: port logout for target %d\n",
3268 isp->isp_name, XS_TGT(xs)));
3269 XS_SETERR(xs, HBA_SELTIMEOUT);
3355 isp_prt(isp, ISP_LOGINFO,
3356 "port logout for target %d", XS_TGT(xs));
3357 if (XS_NOERR(xs)) {
3358 XS_SETERR(xs, HBA_SELTIMEOUT);
3359 }
3270 return;
3271
3272 case RQCS_PORT_CHANGED:
3360 return;
3361
3362 case RQCS_PORT_CHANGED:
3273 PRINTF("%s: port changed for target %d\n",
3274 isp->isp_name, XS_TGT(xs));
3275 XS_SETERR(xs, HBA_SELTIMEOUT);
3363 isp_prt(isp, ISP_LOGWARN,
3364 "port changed for target %d", XS_TGT(xs));
3365 if (XS_NOERR(xs)) {
3366 XS_SETERR(xs, HBA_SELTIMEOUT);
3367 }
3276 return;
3277
3278 case RQCS_PORT_BUSY:
3368 return;
3369
3370 case RQCS_PORT_BUSY:
3279 PRINTF("%s: port busy for target %d\n",
3280 isp->isp_name, XS_TGT(xs));
3281 XS_SETERR(xs, HBA_TGTBSY);
3371 isp_prt(isp, ISP_LOGWARN,
3372 "port busy for target %d", XS_TGT(xs));
3373 if (XS_NOERR(xs)) {
3374 XS_SETERR(xs, HBA_TGTBSY);
3375 }
3282 return;
3283
3284 default:
3376 return;
3377
3378 default:
3285 PRINTF("%s: completion status 0x%x\n",
3286 isp->isp_name, sp->req_completion_status);
3379 isp_prt(isp, ISP_LOGERR, "Unknown Completion Status 0x%x",
3380 sp->req_completion_status);
3287 break;
3288 }
3381 break;
3382 }
3289 XS_SETERR(xs, HBA_BOTCH);
3383 if (XS_NOERR(xs)) {
3384 XS_SETERR(xs, HBA_BOTCH);
3385 }
3290}
3291
3292static void
3293isp_fastpost_complete(isp, fph)
3294 struct ispsoftc *isp;
3295 u_int32_t fph;
3296{
3386}
3387
3388static void
3389isp_fastpost_complete(isp, fph)
3390 struct ispsoftc *isp;
3391 u_int32_t fph;
3392{
3297 ISP_SCSI_XFER_T *xs;
3393 XS_T *xs;
3298
3299 if (fph < 1) {
3300 return;
3301 }
3302 xs = isp_find_xs(isp, fph);
3303 if (xs == NULL) {
3394
3395 if (fph < 1) {
3396 return;
3397 }
3398 xs = isp_find_xs(isp, fph);
3399 if (xs == NULL) {
3304 PRINTF("%s: command for fast posting handle 0x%x not found\n",
3305 isp->isp_name, fph);
3400 isp_prt(isp, ISP_LOGWARN,
3401 "Command for fast post handle 0x%x not found", fph);
3306 return;
3307 }
3308 isp_destroy_handle(isp, fph);
3309
3310 /*
3311 * Since we don't have a result queue entry item,
3312 * we must believe that SCSI status is zero and
3313 * that all data transferred.
3314 */
3402 return;
3403 }
3404 isp_destroy_handle(isp, fph);
3405
3406 /*
3407 * Since we don't have a result queue entry item,
3408 * we must believe that SCSI status is zero and
3409 * that all data transferred.
3410 */
3411 XS_SET_STATE_STAT(isp, xs, NULL);
3315 XS_RESID(xs) = 0;
3412 XS_RESID(xs) = 0;
3316 XS_STS(xs) = 0;
3413 *XS_STSP(xs) = SCSI_GOOD;
3317 if (XS_XFRLEN(xs)) {
3318 ISP_DMAFREE(isp, xs, fph);
3319 }
3414 if (XS_XFRLEN(xs)) {
3415 ISP_DMAFREE(isp, xs, fph);
3416 }
3320 XS_CMD_DONE(xs);
3417 isp_done(xs);
3321 if (isp->isp_nactive)
3322 isp->isp_nactive--;
3323}
3324
3325#define HIBYT(x) ((x) >> 0x8)
3326#define LOBYT(x) ((x) & 0xff)
3327#define ISPOPMAP(a, b) (((a) << 8) | (b))
3328static u_int16_t mbpscsi[] = {

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

3417 ISPOPMAP(0x00, 0x00), /* 0x58: */
3418 ISPOPMAP(0x00, 0x00), /* 0x59: */
3419 ISPOPMAP(0x03, 0x03), /* 0x5a: SET DATA OVERRUN RECOVERY MODE */
3420 ISPOPMAP(0x01, 0x03), /* 0x5b: GET DATA OVERRUN RECOVERY MODE */
3421 ISPOPMAP(0x0f, 0x0f), /* 0x5c: SET HOST DATA */
3422 ISPOPMAP(0x01, 0x01) /* 0x5d: GET NOST DATA */
3423};
3424
3418 if (isp->isp_nactive)
3419 isp->isp_nactive--;
3420}
3421
3422#define HIBYT(x) ((x) >> 0x8)
3423#define LOBYT(x) ((x) & 0xff)
3424#define ISPOPMAP(a, b) (((a) << 8) | (b))
3425static u_int16_t mbpscsi[] = {

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

3514 ISPOPMAP(0x00, 0x00), /* 0x58: */
3515 ISPOPMAP(0x00, 0x00), /* 0x59: */
3516 ISPOPMAP(0x03, 0x03), /* 0x5a: SET DATA OVERRUN RECOVERY MODE */
3517 ISPOPMAP(0x01, 0x03), /* 0x5b: GET DATA OVERRUN RECOVERY MODE */
3518 ISPOPMAP(0x0f, 0x0f), /* 0x5c: SET HOST DATA */
3519 ISPOPMAP(0x01, 0x01) /* 0x5d: GET NOST DATA */
3520};
3521
3522#ifndef ISP_STRIPEED
3523static char *scsi_mbcmd_names[] = {
3524 "NO-OP",
3525 "LOAD RAM",
3526 "EXEC FIRMWARE",
3527 "DUMP RAM",
3528 "WRITE RAM WORD",
3529 "READ RAM WORD",
3530 "MAILBOX REG TEST",
3531 "VERIFY CHECKSUM",
3532 "ABOUT FIRMWARE",
3533 NULL,
3534 NULL,
3535 NULL,
3536 NULL,
3537 NULL,
3538 "CHECK FIRMWARE",
3539 NULL,
3540 "INIT REQUEST QUEUE",
3541 "INIT RESULT QUEUE",
3542 "EXECUTE IOCB",
3543 "WAKE UP",
3544 "STOP FIRMWARE",
3545 "ABORT",
3546 "ABORT DEVICE",
3547 "ABORT TARGET",
3548 "BUS RESET",
3549 "STOP QUEUE",
3550 "START QUEUE",
3551 "SINGLE STEP QUEUE",
3552 "ABORT QUEUE",
3553 "GET DEV QUEUE STATUS",
3554 NULL,
3555 "GET FIRMWARE STATUS",
3556 "GET INIT SCSI ID",
3557 "GET SELECT TIMEOUT",
3558 "GET RETRY COUNT",
3559 "GET TAG AGE LIMIT",
3560 "GET CLOCK RATE",
3561 "GET ACT NEG STATE",
3562 "GET ASYNC DATA SETUP TIME",
3563 "GET PCI PARAMS",
3564 "GET TARGET PARAMS",
3565 "GET DEV QUEUE PARAMS",
3566 "GET RESET DELAY PARAMS",
3567 NULL,
3568 NULL,
3569 NULL,
3570 NULL,
3571 NULL,
3572 "SET INIT SCSI ID",
3573 "SET SELECT TIMEOUT",
3574 "SET RETRY COUNT",
3575 "SET TAG AGE LIMIT",
3576 "SET CLOCK RATE",
3577 "SET ACT NEG STATE",
3578 "SET ASYNC DATA SETUP TIME",
3579 "SET PCI CONTROL PARAMS",
3580 "SET TARGET PARAMS",
3581 "SET DEV QUEUE PARAMS",
3582 "SET RESET DELAY PARAMS",
3583 NULL,
3584 NULL,
3585 NULL,
3586 NULL,
3587 NULL,
3588 "RETURN BIOS BLOCK ADDR",
3589 "WRITE FOUR RAM WORDS",
3590 "EXEC BIOS IOCB",
3591 NULL,
3592 NULL,
3593 "SET SYSTEM PARAMETER",
3594 "GET SYSTEM PARAMETER",
3595 NULL,
3596 "GET SCAM CONFIGURATION",
3597 "SET SCAM CONFIGURATION",
3598 "SET FIRMWARE FEATURES",
3599 "GET FIRMWARE FEATURES",
3600 NULL,
3601 NULL,
3602 NULL,
3603 NULL,
3604 "LOAD RAM A64",
3605 "DUMP RAM A64",
3606 "INITIALIZE REQUEST QUEUE A64",
3607 "INITIALIZE RESPONSE QUEUE A64",
3608 "EXECUTE IOCB A64",
3609 "ENABLE TARGET MODE",
3610 NULL,
3611 NULL,
3612 NULL,
3613 NULL,
3614 "SET DATA OVERRUN RECOVERY MODE",
3615 "GET DATA OVERRUN RECOVERY MODE",
3616 "SET HOST DATA",
3617 "GET NOST DATA",
3618};
3619#endif
3620
3425static u_int16_t mbpfc[] = {
3426 ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */
3427 ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */
3428 ISPOPMAP(0x03, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */
3429 ISPOPMAP(0x1f, 0x01), /* 0x03: MBOX_DUMP_RAM */
3430 ISPOPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */
3431 ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */
3432 ISPOPMAP(0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */

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

3547 ISPOPMAP(0x00, 0x00), /* 0x79: */
3548 ISPOPMAP(0x00, 0x00), /* 0x7a: */
3549 ISPOPMAP(0x00, 0x00), /* 0x7b: */
3550 ISPOPMAP(0x4f, 0x03), /* 0x7c: Get ID List */
3551 ISPOPMAP(0xcf, 0x01), /* 0x7d: SEND LFA */
3552 ISPOPMAP(0x07, 0x01) /* 0x7e: Lun RESET */
3553};
3554
3621static u_int16_t mbpfc[] = {
3622 ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */
3623 ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */
3624 ISPOPMAP(0x03, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */
3625 ISPOPMAP(0x1f, 0x01), /* 0x03: MBOX_DUMP_RAM */
3626 ISPOPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */
3627 ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */
3628 ISPOPMAP(0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */

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

3743 ISPOPMAP(0x00, 0x00), /* 0x79: */
3744 ISPOPMAP(0x00, 0x00), /* 0x7a: */
3745 ISPOPMAP(0x00, 0x00), /* 0x7b: */
3746 ISPOPMAP(0x4f, 0x03), /* 0x7c: Get ID List */
3747 ISPOPMAP(0xcf, 0x01), /* 0x7d: SEND LFA */
3748 ISPOPMAP(0x07, 0x01) /* 0x7e: Lun RESET */
3749};
3750
3751#ifndef ISP_STRIPPED
3752static char *fc_mbcmd_names[] = {
3753 "NO-OP",
3754 "LOAD RAM",
3755 "EXEC FIRMWARE",
3756 "DUMP RAM",
3757 "WRITE RAM WORD",
3758 "READ RAM WORD",
3759 "MAILBOX REG TEST",
3760 "VERIFY CHECKSUM",
3761 "ABOUT FIRMWARE",
3762 "LOAD RAM",
3763 "DUMP RAM",
3764 NULL,
3765 NULL,
3766 NULL,
3767 "CHECK FIRMWARE",
3768 NULL,
3769 "INIT REQUEST QUEUE",
3770 "INIT RESULT QUEUE",
3771 "EXECUTE IOCB",
3772 "WAKE UP",
3773 "STOP FIRMWARE",
3774 "ABORT",
3775 "ABORT DEVICE",
3776 "ABORT TARGET",
3777 "BUS RESET",
3778 "STOP QUEUE",
3779 "START QUEUE",
3780 "SINGLE STEP QUEUE",
3781 "ABORT QUEUE",
3782 "GET DEV QUEUE STATUS",
3783 NULL,
3784 "GET FIRMWARE STATUS",
3785 "GET LOOP ID",
3786 NULL,
3787 "GET RETRY COUNT",
3788 NULL,
3789 NULL,
3790 NULL,
3791 NULL,
3792 NULL,
3793 "GET FIRMWARE OPTIONS",
3794 "GET PORT QUEUE PARAMS",
3795 NULL,
3796 NULL,
3797 NULL,
3798 NULL,
3799 NULL,
3800 NULL,
3801 NULL,
3802 NULL,
3803 "SET RETRY COUNT",
3804 NULL,
3805 NULL,
3806 NULL,
3807 NULL,
3808 NULL,
3809 "SET FIRMWARE OPTIONS",
3810 "SET PORT QUEUE PARAMS",
3811 NULL,
3812 NULL,
3813 NULL,
3814 NULL,
3815 NULL,
3816 NULL,
3817 "LOOP PORT BYPASS",
3818 "LOOP PORT ENABLE",
3819 "GET RESOURCE COUNTS",
3820 "REQUEST NON PARTICIPATING MODE",
3821 NULL,
3822 NULL,
3823 NULL,
3824 "GET PORT DATABASE,, ENHANCED",
3825 NULL,
3826 NULL,
3827 NULL,
3828 NULL,
3829 NULL,
3830 NULL,
3831 NULL,
3832 NULL,
3833 NULL,
3834 NULL,
3835 NULL,
3836 NULL,
3837 "EXECUTE IOCB A64",
3838 NULL,
3839 NULL,
3840 NULL,
3841 NULL,
3842 NULL,
3843 NULL,
3844 NULL,
3845 NULL,
3846 NULL,
3847 NULL,
3848 NULL,
3849 "INIT FIRMWARE",
3850 NULL,
3851 "INIT LIP",
3852 "GET FC-AL POSITION MAP",
3853 "GET PORT DATABASE",
3854 "CLEAR ACA",
3855 "TARGET RESET",
3856 "CLEAR TASK SET",
3857 "ABORT TASK SET",
3858 "GET FW STATE",
3859 "GET PORT NAME",
3860 "GET LINK STATUS",
3861 "INIT LIP RESET",
3862 NULL,
3863 "SEND SNS",
3864 "FABRIC LOGIN",
3865 "SEND CHANGE REQUEST",
3866 "FABRIC LOGOUT",
3867 "INIT LIP LOGIN",
3868 NULL,
3869 "LOGIN LOOP PORT",
3870 "GET PORT/NODE NAME LIST",
3871 "SET VENDOR ID",
3872 "INITIALIZE IP MAILBOX",
3873 NULL,
3874 NULL,
3875 NULL,
3876 NULL,
3877 "Get ID List",
3878 "SEND LFA",
3879 "Lun RESET"
3880};
3881#endif
3882
3555static void
3883static void
3556isp_mboxcmd(isp, mbp)
3884isp_mboxcmd(isp, mbp, logmask)
3557 struct ispsoftc *isp;
3558 mbreg_t *mbp;
3885 struct ispsoftc *isp;
3886 mbreg_t *mbp;
3887 int logmask;
3559{
3888{
3889 char *cname, *xname, tname[16], mname[16];
3560 unsigned int lim, ibits, obits, box, opcode;
3561 u_int16_t *mcp;
3562
3563 if (IS_FC(isp)) {
3564 mcp = mbpfc;
3565 lim = (sizeof (mbpfc) / sizeof (mbpfc[0]));
3566 } else {
3567 mcp = mbpscsi;
3568 lim = (sizeof (mbpscsi) / sizeof (mbpscsi[0]));
3569 }
3570
3571 if ((opcode = mbp->param[0]) >= lim) {
3572 mbp->param[0] = MBOX_INVALID_COMMAND;
3890 unsigned int lim, ibits, obits, box, opcode;
3891 u_int16_t *mcp;
3892
3893 if (IS_FC(isp)) {
3894 mcp = mbpfc;
3895 lim = (sizeof (mbpfc) / sizeof (mbpfc[0]));
3896 } else {
3897 mcp = mbpscsi;
3898 lim = (sizeof (mbpscsi) / sizeof (mbpscsi[0]));
3899 }
3900
3901 if ((opcode = mbp->param[0]) >= lim) {
3902 mbp->param[0] = MBOX_INVALID_COMMAND;
3573 PRINTF("%s: unknown command 0x%x\n", isp->isp_name, opcode);
3903 isp_prt(isp, ISP_LOGERR, "Unknown Command 0x%x", opcode);
3574 return;
3575 }
3576
3577 ibits = HIBYT(mcp[opcode]) & NMBOX_BMASK(isp);
3578 obits = LOBYT(mcp[opcode]) & NMBOX_BMASK(isp);
3579
3580 if (ibits == 0 && obits == 0) {
3581 mbp->param[0] = MBOX_COMMAND_PARAM_ERROR;
3904 return;
3905 }
3906
3907 ibits = HIBYT(mcp[opcode]) & NMBOX_BMASK(isp);
3908 obits = LOBYT(mcp[opcode]) & NMBOX_BMASK(isp);
3909
3910 if (ibits == 0 && obits == 0) {
3911 mbp->param[0] = MBOX_COMMAND_PARAM_ERROR;
3582 PRINTF("%s: no parameters for opcode 0x%x\n", isp->isp_name,
3583 opcode);
3912 isp_prt(isp, ISP_LOGERR, "no parameters for 0x%x", opcode);
3584 return;
3585 }
3586
3913 return;
3914 }
3915
3916 /*
3917 * Get exclusive usage of mailbox registers.
3918 */
3919 MBOX_ACQUIRE(isp);
3920
3587 for (box = 0; box < MAX_MAILBOX; box++) {
3588 if (ibits & (1 << box)) {
3589 ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]);
3590 }
3591 isp->isp_mboxtmp[box] = mbp->param[box] = 0;
3592 }
3593
3594 /*

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

3599 /*
3600 * Set Host Interrupt condition so that RISC will pick up mailbox regs.
3601 */
3602 ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT);
3603
3604 /*
3605 * Give the f/w a chance to pick this up.
3606 */
3921 for (box = 0; box < MAX_MAILBOX; box++) {
3922 if (ibits & (1 << box)) {
3923 ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]);
3924 }
3925 isp->isp_mboxtmp[box] = mbp->param[box] = 0;
3926 }
3927
3928 /*

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

3933 /*
3934 * Set Host Interrupt condition so that RISC will pick up mailbox regs.
3935 */
3936 ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT);
3937
3938 /*
3939 * Give the f/w a chance to pick this up.
3940 */
3607 SYS_DELAY(250);
3941 USEC_DELAY(250);
3608
3609
3610 /*
3611 * While we haven't finished the command, spin our wheels here.
3612 */
3613 MBOX_WAIT_COMPLETE(isp);
3614
3615 /*
3616 * Copy back output registers.
3617 */
3618 for (box = 0; box < MAX_MAILBOX; box++) {
3619 if (obits & (1 << box)) {
3620 mbp->param[box] = isp->isp_mboxtmp[box];
3621 }
3622 }
3623
3942
3943
3944 /*
3945 * While we haven't finished the command, spin our wheels here.
3946 */
3947 MBOX_WAIT_COMPLETE(isp);
3948
3949 /*
3950 * Copy back output registers.
3951 */
3952 for (box = 0; box < MAX_MAILBOX; box++) {
3953 if (obits & (1 << box)) {
3954 mbp->param[box] = isp->isp_mboxtmp[box];
3955 }
3956 }
3957
3958 MBOX_RELEASE(isp);
3959
3960 if (logmask == 0 || opcode == MBOX_EXEC_FIRMWARE) {
3961 return;
3962 }
3963#ifdef ISP_STRIPPED
3964 cname = NULL;
3965#else
3966 cname = (IS_FC(isp))? fc_mbcmd_names[opcode] : scsi_mbcmd_names[opcode];
3967#endif
3968 if (cname == NULL) {
3969 SNPRINTF(cname, sizeof tname, "opcode %x", opcode);
3970 }
3971
3624 /*
3625 * Just to be chatty here...
3626 */
3972 /*
3973 * Just to be chatty here...
3974 */
3975 xname = NULL;
3627 switch (mbp->param[0]) {
3628 case MBOX_COMMAND_COMPLETE:
3629 break;
3630 case MBOX_INVALID_COMMAND:
3976 switch (mbp->param[0]) {
3977 case MBOX_COMMAND_COMPLETE:
3978 break;
3979 case MBOX_INVALID_COMMAND:
3631 IDPRINTF(2, ("%s: mbox cmd %x failed with INVALID_COMMAND\n",
3632 isp->isp_name, opcode));
3980 if (logmask & MBLOGMASK(MBOX_COMMAND_COMPLETE))
3981 xname = "INVALID COMMAND";
3633 break;
3634 case MBOX_HOST_INTERFACE_ERROR:
3982 break;
3983 case MBOX_HOST_INTERFACE_ERROR:
3635 PRINTF("%s: mbox cmd %x failed with HOST_INTERFACE_ERROR\n",
3636 isp->isp_name, opcode);
3984 if (logmask & MBLOGMASK(MBOX_HOST_INTERFACE_ERROR))
3985 xname = "HOST INTERFACE ERROR";
3637 break;
3638 case MBOX_TEST_FAILED:
3986 break;
3987 case MBOX_TEST_FAILED:
3639 PRINTF("%s: mbox cmd %x failed with TEST_FAILED\n",
3640 isp->isp_name, opcode);
3988 if (logmask & MBLOGMASK(MBOX_TEST_FAILED))
3989 xname = "TEST FAILED";
3641 break;
3642 case MBOX_COMMAND_ERROR:
3990 break;
3991 case MBOX_COMMAND_ERROR:
3643 if (opcode != MBOX_ABOUT_FIRMWARE)
3644 PRINTF("%s: mbox cmd %x failed with COMMAND_ERROR\n",
3645 isp->isp_name, opcode);
3992 if (logmask & MBLOGMASK(MBOX_COMMAND_ERROR))
3993 xname = "COMMAND ERROR";
3646 break;
3647 case MBOX_COMMAND_PARAM_ERROR:
3994 break;
3995 case MBOX_COMMAND_PARAM_ERROR:
3648 switch (opcode) {
3649 case MBOX_GET_PORT_DB:
3650 case MBOX_GET_PORT_NAME:
3651 case MBOX_GET_DEV_QUEUE_PARAMS:
3652 break;
3653 default:
3654 PRINTF("%s: mbox cmd %x failed with "
3655 "COMMAND_PARAM_ERROR\n", isp->isp_name, opcode);
3656 }
3996 if (logmask & MBLOGMASK(MBOX_COMMAND_PARAM_ERROR))
3997 xname = "COMMAND PARAMETER ERROR";
3657 break;
3998 break;
3658
3659 case MBOX_LOOP_ID_USED:
3999 case MBOX_LOOP_ID_USED:
4000 if (logmask & MBLOGMASK(MBOX_LOOP_ID_USED))
4001 xname = "LOOP ID ALREADY IN USE";
4002 break;
3660 case MBOX_PORT_ID_USED:
4003 case MBOX_PORT_ID_USED:
4004 if (logmask & MBLOGMASK(MBOX_PORT_ID_USED))
4005 xname = "PORT ID ALREADY IN USE";
4006 break;
3661 case MBOX_ALL_IDS_USED:
4007 case MBOX_ALL_IDS_USED:
4008 if (logmask & MBLOGMASK(MBOX_ALL_IDS_USED))
4009 xname = "ALL LOOP IDS IN USE";
3662 break;
4010 break;
3663
4011 case 0: /* special case */
4012 xname = "TIMEOUT";
4013 break;
3664 default:
4014 default:
3665 /*
3666 * The expected return of EXEC_FIRMWARE is zero.
3667 */
3668 if ((opcode == MBOX_EXEC_FIRMWARE && mbp->param[0] != 0) ||
3669 (opcode != MBOX_EXEC_FIRMWARE)) {
3670 PRINTF("%s: mbox cmd %x failed with error %x\n",
3671 isp->isp_name, opcode, mbp->param[0]);
3672 }
4015 SNPRINTF(mname, sizeof mname, "error 0x%x", mbp->param[0]);
4016 xname = mname;
3673 break;
3674 }
4017 break;
4018 }
4019 if (xname)
4020 isp_prt(isp, ISP_LOGALL, "Mailbox Command '%s' failed (%s)",
4021 cname, xname);
3675}
3676
4022}
4023
3677void
3678isp_lostcmd(isp, xs)
3679 struct ispsoftc *isp;
3680 ISP_SCSI_XFER_T *xs;
3681{
3682 mbreg_t mbs;
3683
3684 mbs.param[0] = MBOX_GET_FIRMWARE_STATUS;
3685 isp_mboxcmd(isp, &mbs);
3686 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3687 isp_dumpregs(isp, "couldn't GET FIRMWARE STATUS");
3688 return;
3689 }
3690 if (mbs.param[1]) {
3691 PRINTF("%s: %d commands on completion queue\n",
3692 isp->isp_name, mbs.param[1]);
3693 }
3694 if (XS_NULL(xs))
3695 return;
3696
3697 mbs.param[0] = MBOX_GET_DEV_QUEUE_STATUS;
3698 mbs.param[1] = (XS_TGT(xs) << 8) | XS_LUN(xs); /* XXX: WHICH BUS? */
3699 isp_mboxcmd(isp, &mbs);
3700 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3701 isp_dumpregs(isp, "couldn't GET DEVICE QUEUE STATUS");
3702 return;
3703 }
3704 PRINTF("%s: lost command for target %d lun %d, %d active of %d, "
3705 "Queue State: %x\n", isp->isp_name, XS_TGT(xs),
3706 XS_LUN(xs), mbs.param[2], mbs.param[3], mbs.param[1]);
3707
3708 isp_dumpregs(isp, "lost command");
3709 /*
3710 * XXX: Need to try and do something to recover.
3711 */
3712}
3713
3714static void
4024static void
3715isp_dumpregs(isp, msg)
3716 struct ispsoftc *isp;
3717 const char *msg;
3718{
3719 PRINTF("%s: %s\n", isp->isp_name, msg);
3720 if (IS_SCSI(isp))
3721 PRINTF(" biu_conf1=%x", ISP_READ(isp, BIU_CONF1));
3722 else
3723 PRINTF(" biu_csr=%x", ISP_READ(isp, BIU2100_CSR));
3724 PRINTF(" biu_icr=%x biu_isr=%x biu_sema=%x ", ISP_READ(isp, BIU_ICR),
3725 ISP_READ(isp, BIU_ISR), ISP_READ(isp, BIU_SEMA));
3726 PRINTF("risc_hccr=%x\n", ISP_READ(isp, HCCR));
3727
3728
3729 if (IS_SCSI(isp)) {
3730 ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE);
3731 PRINTF(" cdma_conf=%x cdma_sts=%x cdma_fifostat=%x\n",
3732 ISP_READ(isp, CDMA_CONF), ISP_READ(isp, CDMA_STATUS),
3733 ISP_READ(isp, CDMA_FIFO_STS));
3734 PRINTF(" ddma_conf=%x ddma_sts=%x ddma_fifostat=%x\n",
3735 ISP_READ(isp, DDMA_CONF), ISP_READ(isp, DDMA_STATUS),
3736 ISP_READ(isp, DDMA_FIFO_STS));
3737 PRINTF(" sxp_int=%x sxp_gross=%x sxp(scsi_ctrl)=%x\n",
3738 ISP_READ(isp, SXP_INTERRUPT),
3739 ISP_READ(isp, SXP_GROSS_ERR),
3740 ISP_READ(isp, SXP_PINS_CTRL));
3741 ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
3742 }
3743 PRINTF(" mbox regs: %x %x %x %x %x\n",
3744 ISP_READ(isp, OUTMAILBOX0), ISP_READ(isp, OUTMAILBOX1),
3745 ISP_READ(isp, OUTMAILBOX2), ISP_READ(isp, OUTMAILBOX3),
3746 ISP_READ(isp, OUTMAILBOX4));
3747 ISP_DUMPREGS(isp);
3748}
3749
3750static void
3751isp_fw_state(isp)
3752 struct ispsoftc *isp;
3753{
4025isp_fw_state(isp)
4026 struct ispsoftc *isp;
4027{
3754 mbreg_t mbs;
3755 if (IS_FC(isp)) {
4028 if (IS_FC(isp)) {
3756 int once = 0;
4029 mbreg_t mbs;
3757 fcparam *fcp = isp->isp_param;
4030 fcparam *fcp = isp->isp_param;
3758again:
4031
3759 mbs.param[0] = MBOX_GET_FW_STATE;
4032 mbs.param[0] = MBOX_GET_FW_STATE;
3760 isp_mboxcmd(isp, &mbs);
3761 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3762 IDPRINTF(1, ("%s: isp_fw_state 0x%x\n", isp->isp_name,
3763 mbs.param[0]));
3764 switch (mbs.param[0]) {
3765 case ASYNC_PDB_CHANGED:
3766 if (once++ < 10) {
3767 goto again;
3768 }
3769 fcp->isp_fwstate = FW_CONFIG_WAIT;
3770 fcp->isp_loopstate = LOOP_PDB_RCVD;
3771 goto again;
3772 case ASYNC_LIP_OCCURRED:
3773 fcp->isp_lipseq = mbs.param[1];
3774 /* FALLTHROUGH */
3775 case ASYNC_LOOP_UP:
3776 fcp->isp_fwstate = FW_CONFIG_WAIT;
3777 fcp->isp_loopstate = LOOP_LIP_RCVD;
3778 if (once++ < 10) {
3779 goto again;
3780 }
3781 break;
3782 case ASYNC_LOOP_RESET:
3783 case ASYNC_LOOP_DOWN:
3784 fcp->isp_fwstate = FW_CONFIG_WAIT;
3785 fcp->isp_loopstate = LOOP_NIL;
3786 /* FALLTHROUGH */
3787 case ASYNC_CHANGE_NOTIFY:
3788 if (once++ < 10) {
3789 goto again;
3790 }
3791 break;
3792 }
3793 PRINTF("%s: GET FIRMWARE STATE failed (0x%x)\n",
3794 isp->isp_name, mbs.param[0]);
3795 return;
3796 }
3797 fcp->isp_fwstate = mbs.param[1];
4033 isp_mboxcmd(isp, &mbs, MBLOGALL);
4034 if (mbs.param[0] == MBOX_COMMAND_COMPLETE)
4035 fcp->isp_fwstate = mbs.param[1];
3798 }
3799}
3800
3801static void
3802isp_update(isp)
3803 struct ispsoftc *isp;
3804{
3805 int bus;

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

3828 sdp = isp->isp_param;
3829 sdp += bus;
3830
3831 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
3832 u_int16_t flags, period, offset;
3833 int get;
3834
3835 if (sdp->isp_devparam[tgt].dev_enable == 0) {
4036 }
4037}
4038
4039static void
4040isp_update(isp)
4041 struct ispsoftc *isp;
4042{
4043 int bus;

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

4066 sdp = isp->isp_param;
4067 sdp += bus;
4068
4069 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
4070 u_int16_t flags, period, offset;
4071 int get;
4072
4073 if (sdp->isp_devparam[tgt].dev_enable == 0) {
3836 IDPRINTF(2, ("%s: skipping target %d bus %d update\n",
3837 isp->isp_name, tgt, bus));
4074 isp_prt(isp, ISP_LOGDEBUG1,
4075 "skipping target %d bus %d update", tgt, bus);
3838 continue;
3839 }
3840
3841 /*
3842 * If the goal is to update the status of the device,
3843 * take what's in dev_flags and try and set the device
3844 * toward that. Otherwise, if we're just refreshing the
3845 * current device state, get the current parameters.

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

3868 * otherwise we might try and send a tagged command
3869 * when we have it all turned off. So change it here
3870 * to say that current already matches goal.
3871 */
3872 sdp->isp_devparam[tgt].cur_dflags &= ~DPARM_TQING;
3873 sdp->isp_devparam[tgt].cur_dflags |=
3874 (sdp->isp_devparam[tgt].dev_flags & DPARM_TQING);
3875 sdp->isp_devparam[tgt].dev_refresh = 1;
4076 continue;
4077 }
4078
4079 /*
4080 * If the goal is to update the status of the device,
4081 * take what's in dev_flags and try and set the device
4082 * toward that. Otherwise, if we're just refreshing the
4083 * current device state, get the current parameters.

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

4106 * otherwise we might try and send a tagged command
4107 * when we have it all turned off. So change it here
4108 * to say that current already matches goal.
4109 */
4110 sdp->isp_devparam[tgt].cur_dflags &= ~DPARM_TQING;
4111 sdp->isp_devparam[tgt].cur_dflags |=
4112 (sdp->isp_devparam[tgt].dev_flags & DPARM_TQING);
4113 sdp->isp_devparam[tgt].dev_refresh = 1;
3876 IDPRINTF(3, ("%s: bus %d set tgt %d flags 0x%x off 0x%x"
3877 " period 0x%x\n", isp->isp_name, bus, tgt,
3878 mbs.param[2], mbs.param[3] >> 8,
3879 mbs.param[3] & 0xff));
4114 isp_prt(isp, ISP_LOGDEBUG2,
4115 "bus %d set tgt %d flags 0x%x off 0x%x period 0x%x",
4116 bus, tgt, mbs.param[2], mbs.param[3] >> 8,
4117 mbs.param[3] & 0xff);
3880 get = 0;
3881 } else if (sdp->isp_devparam[tgt].dev_refresh) {
3882 mbs.param[0] = MBOX_GET_TARGET_PARAMS;
3883 sdp->isp_devparam[tgt].dev_refresh = 0;
3884 get = 1;
3885 } else {
3886 continue;
3887 }
3888 mbs.param[1] = (bus << 15) | (tgt << 8) ;
4118 get = 0;
4119 } else if (sdp->isp_devparam[tgt].dev_refresh) {
4120 mbs.param[0] = MBOX_GET_TARGET_PARAMS;
4121 sdp->isp_devparam[tgt].dev_refresh = 0;
4122 get = 1;
4123 } else {
4124 continue;
4125 }
4126 mbs.param[1] = (bus << 15) | (tgt << 8) ;
3889 isp_mboxcmd(isp, &mbs);
3890 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3891 PRINTF("%s: failed to %cet SCSI parameters for "
3892 "target %d\n", isp->isp_name, (get)? 'g' : 's',
3893 tgt);
3894 continue;
3895 }
4127 isp_mboxcmd(isp, &mbs, MBLOGALL);
3896 if (get == 0) {
3897 isp->isp_sendmarker |= (1 << bus);
3898 continue;
3899 }
3900 flags = mbs.param[2];
3901 period = mbs.param[3] & 0xff;
3902 offset = mbs.param[3] >> 8;
3903 sdp->isp_devparam[tgt].cur_dflags = flags;

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

3926 fcp->isp_gotdparms = 1;
3927 fcp->isp_maxfrmlen = ICB_DFLT_FRMLEN;
3928 fcp->isp_maxalloc = ICB_DFLT_ALLOC;
3929 fcp->isp_execthrottle = ICB_DFLT_THROTTLE;
3930 fcp->isp_retry_delay = ICB_DFLT_RDELAY;
3931 fcp->isp_retry_count = ICB_DFLT_RCOUNT;
3932 /* Platform specific.... */
3933 fcp->isp_loopid = DEFAULT_LOOPID(isp);
4128 if (get == 0) {
4129 isp->isp_sendmarker |= (1 << bus);
4130 continue;
4131 }
4132 flags = mbs.param[2];
4133 period = mbs.param[3] & 0xff;
4134 offset = mbs.param[3] >> 8;
4135 sdp->isp_devparam[tgt].cur_dflags = flags;

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

4158 fcp->isp_gotdparms = 1;
4159 fcp->isp_maxfrmlen = ICB_DFLT_FRMLEN;
4160 fcp->isp_maxalloc = ICB_DFLT_ALLOC;
4161 fcp->isp_execthrottle = ICB_DFLT_THROTTLE;
4162 fcp->isp_retry_delay = ICB_DFLT_RDELAY;
4163 fcp->isp_retry_count = ICB_DFLT_RCOUNT;
4164 /* Platform specific.... */
4165 fcp->isp_loopid = DEFAULT_LOOPID(isp);
3934 fcp->isp_nodewwn = DEFAULT_WWN(isp);
3935 if ((fcp->isp_nodewwn >> 60) == 2) {
3936 fcp->isp_nodewwn &= ~((u_int64_t) 0xfff << 48);
3937 fcp->isp_portwwn = fcp->isp_nodewwn |
3938 (((u_int64_t)(isp->isp_unit+1)) << 48);
3939 } else {
3940 fcp->isp_portwwn = fcp->isp_nodewwn;
3941 }
4166 fcp->isp_nodewwn = DEFAULT_NODEWWN(isp);
4167 fcp->isp_portwwn = DEFAULT_PORTWWN(isp);
4168
3942 /*
3943 * Now try and read NVRAM
3944 */
3945 if ((isp->isp_confopts & (ISP_CFG_NONVRAM|ISP_CFG_OWNWWN)) ||
3946 (isp_read_nvram(isp))) {
4169 /*
4170 * Now try and read NVRAM
4171 */
4172 if ((isp->isp_confopts & (ISP_CFG_NONVRAM|ISP_CFG_OWNWWN)) ||
4173 (isp_read_nvram(isp))) {
3947 PRINTF("%s: Node WWN 0x%08x%08x, Port WWN 0x%08x%08x\n",
3948 isp->isp_name, (u_int32_t) (fcp->isp_nodewwn >> 32),
4174 isp_prt(isp, ISP_LOGINFO,
4175 "Node WWN 0x%08x%08x, Port WWN 0x%08x%08x",
4176 (u_int32_t) (fcp->isp_nodewwn >> 32),
3949 (u_int32_t) (fcp->isp_nodewwn & 0xffffffff),
3950 (u_int32_t) (fcp->isp_portwwn >> 32),
3951 (u_int32_t) (fcp->isp_portwwn & 0xffffffff));
3952 }
3953 return;
3954 }
3955
3956 sdp = (sdparam *) isp->isp_param;

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

3976 }
3977 }
3978
3979 /*
3980 * Now try and see whether we have specific values for them.
3981 */
3982 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
3983 mbs.param[0] = MBOX_GET_ACT_NEG_STATE;
4177 (u_int32_t) (fcp->isp_nodewwn & 0xffffffff),
4178 (u_int32_t) (fcp->isp_portwwn >> 32),
4179 (u_int32_t) (fcp->isp_portwwn & 0xffffffff));
4180 }
4181 return;
4182 }
4183
4184 sdp = (sdparam *) isp->isp_param;

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

4204 }
4205 }
4206
4207 /*
4208 * Now try and see whether we have specific values for them.
4209 */
4210 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
4211 mbs.param[0] = MBOX_GET_ACT_NEG_STATE;
3984 isp_mboxcmd(isp, &mbs);
4212 isp_mboxcmd(isp, &mbs, MBLOGALL);
3985 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4213 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3986 IDPRINTF(2, ("could not GET ACT NEG STATE\n"));
3987 sdp->isp_req_ack_active_neg = 1;
3988 sdp->isp_data_line_active_neg = 1;
3989 } else {
3990 sdp->isp_req_ack_active_neg =
3991 (mbs.param[1+channel] >> 4) & 0x1;
3992 sdp->isp_data_line_active_neg =
3993 (mbs.param[1+channel] >> 5) & 0x1;
3994 }
3995 } else {
3996 sdp->isp_req_ack_active_neg = 1;
3997 sdp->isp_data_line_active_neg = 1;
3998 }
3999
4214 sdp->isp_req_ack_active_neg = 1;
4215 sdp->isp_data_line_active_neg = 1;
4216 } else {
4217 sdp->isp_req_ack_active_neg =
4218 (mbs.param[1+channel] >> 4) & 0x1;
4219 sdp->isp_data_line_active_neg =
4220 (mbs.param[1+channel] >> 5) & 0x1;
4221 }
4222 } else {
4223 sdp->isp_req_ack_active_neg = 1;
4224 sdp->isp_data_line_active_neg = 1;
4225 }
4226
4000 IDPRINTF(3, ("%s: defaulting bus %d REQ/ACK Active Negation is %d\n",
4001 isp->isp_name, channel, sdp->isp_req_ack_active_neg));
4002 IDPRINTF(3, ("%s: defaulting bus %d DATA Active Negation is %d\n",
4003 isp->isp_name, channel, sdp->isp_data_line_active_neg));
4227 isp_prt(isp, ISP_LOGDEBUG1,
4228 "defaulting bus %d REQ/ACK Active Negation is %d",
4229 channel, sdp->isp_req_ack_active_neg);
4230 isp_prt(isp, ISP_LOGDEBUG1,
4231 "defaulting bus %d DATA Active Negation is %d",
4232 channel, sdp->isp_data_line_active_neg);
4004
4005 /*
4006 * The trick here is to establish a default for the default (honk!)
4007 * state (dev_flags). Then try and get the current status from
4008 * the card to fill in the current state. We don't, in fact, set
4009 * the default to the SAFE default state- that's not the goal state.
4010 */
4011 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {

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

4042 /*
4043 * Don't get current target parameters if we've been
4044 * told not to use NVRAM- it's really the same thing.
4045 */
4046 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
4047
4048 mbs.param[0] = MBOX_GET_TARGET_PARAMS;
4049 mbs.param[1] = tgt << 8;
4233
4234 /*
4235 * The trick here is to establish a default for the default (honk!)
4236 * state (dev_flags). Then try and get the current status from
4237 * the card to fill in the current state. We don't, in fact, set
4238 * the default to the SAFE default state- that's not the goal state.
4239 */
4240 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {

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

4271 /*
4272 * Don't get current target parameters if we've been
4273 * told not to use NVRAM- it's really the same thing.
4274 */
4275 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
4276
4277 mbs.param[0] = MBOX_GET_TARGET_PARAMS;
4278 mbs.param[1] = tgt << 8;
4050 isp_mboxcmd(isp, &mbs);
4279 isp_mboxcmd(isp, &mbs, MBLOGALL);
4051 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4052 continue;
4053 }
4054 sdp->isp_devparam[tgt].cur_dflags = mbs.param[2];
4055 sdp->isp_devparam[tgt].dev_flags = mbs.param[2];
4056 sdp->isp_devparam[tgt].cur_period = mbs.param[3] & 0xff;
4057 sdp->isp_devparam[tgt].cur_offset = mbs.param[3] >> 8;
4058

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

4078 (sdp->isp_devparam[tgt].sync_period <=
4079 (ISP_20M_SYNCPARMS & 0xff))) {
4080 sdp->isp_devparam[tgt].sync_offset =
4081 ISP_10M_SYNCPARMS >> 8;
4082 sdp->isp_devparam[tgt].sync_period =
4083 ISP_10M_SYNCPARMS & 0xff;
4084 }
4085 }
4280 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4281 continue;
4282 }
4283 sdp->isp_devparam[tgt].cur_dflags = mbs.param[2];
4284 sdp->isp_devparam[tgt].dev_flags = mbs.param[2];
4285 sdp->isp_devparam[tgt].cur_period = mbs.param[3] & 0xff;
4286 sdp->isp_devparam[tgt].cur_offset = mbs.param[3] >> 8;
4287

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

4307 (sdp->isp_devparam[tgt].sync_period <=
4308 (ISP_20M_SYNCPARMS & 0xff))) {
4309 sdp->isp_devparam[tgt].sync_offset =
4310 ISP_10M_SYNCPARMS >> 8;
4311 sdp->isp_devparam[tgt].sync_period =
4312 ISP_10M_SYNCPARMS & 0xff;
4313 }
4314 }
4086 IDPRINTF(3, ("%s: bus %d tgt %d flags %x offset %x period %x\n",
4087 isp->isp_name, channel, tgt,
4088 sdp->isp_devparam[tgt].dev_flags,
4315 isp_prt(isp, ISP_LOGDEBUG1,
4316 "bus %d tgt %d flags %x offset %x period %x",
4317 channel, tgt, sdp->isp_devparam[tgt].dev_flags,
4089 sdp->isp_devparam[tgt].sync_offset,
4318 sdp->isp_devparam[tgt].sync_offset,
4090 sdp->isp_devparam[tgt].sync_period));
4319 sdp->isp_devparam[tgt].sync_period);
4091 }
4092
4093 /*
4094 * Establish default some more default parameters.
4095 */
4096 sdp->isp_cmd_dma_burst_enable = 1;
4097 sdp->isp_data_dma_burst_enabl = 1;
4098 sdp->isp_fifo_threshold = 0;
4320 }
4321
4322 /*
4323 * Establish default some more default parameters.
4324 */
4325 sdp->isp_cmd_dma_burst_enable = 1;
4326 sdp->isp_data_dma_burst_enabl = 1;
4327 sdp->isp_fifo_threshold = 0;
4099 sdp->isp_initiator_id = 7;
4100 /* XXXX This is probably based upon clock XXXX */
4328 sdp->isp_initiator_id = DEFAULT_IID(isp);
4101 if (isp->isp_type >= ISP_HA_SCSI_1040) {
4102 sdp->isp_async_data_setup = 9;
4103 } else {
4104 sdp->isp_async_data_setup = 6;
4105 }
4106 sdp->isp_selection_timeout = 250;
4329 if (isp->isp_type >= ISP_HA_SCSI_1040) {
4330 sdp->isp_async_data_setup = 9;
4331 } else {
4332 sdp->isp_async_data_setup = 6;
4333 }
4334 sdp->isp_selection_timeout = 250;
4107 sdp->isp_max_queue_depth = MAXISPREQUEST;
4335 sdp->isp_max_queue_depth = MAXISPREQUEST(isp);
4108 sdp->isp_tag_aging = 8;
4109 sdp->isp_bus_reset_delay = 3;
4110 sdp->isp_retry_count = 2;
4111 sdp->isp_retry_delay = 2;
4112
4113 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
4114 sdp->isp_devparam[tgt].exc_throttle = 16;
4115 sdp->isp_devparam[tgt].dev_enable = 1;

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

4120 * Re-initialize the ISP and complete all orphaned commands
4121 * with a 'botched' notice. The reset/init routines should
4122 * not disturb an already active list of commands.
4123 *
4124 * Locks held prior to coming here.
4125 */
4126
4127void
4336 sdp->isp_tag_aging = 8;
4337 sdp->isp_bus_reset_delay = 3;
4338 sdp->isp_retry_count = 2;
4339 sdp->isp_retry_delay = 2;
4340
4341 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
4342 sdp->isp_devparam[tgt].exc_throttle = 16;
4343 sdp->isp_devparam[tgt].dev_enable = 1;

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

4348 * Re-initialize the ISP and complete all orphaned commands
4349 * with a 'botched' notice. The reset/init routines should
4350 * not disturb an already active list of commands.
4351 *
4352 * Locks held prior to coming here.
4353 */
4354
4355void
4128isp_restart(isp)
4356isp_reinit(isp)
4129 struct ispsoftc *isp;
4130{
4357 struct ispsoftc *isp;
4358{
4131 ISP_SCSI_XFER_T *xs;
4359 XS_T *xs;
4132 u_int32_t handle;
4133
4134 isp_reset(isp);
4135 if (isp->isp_state == ISP_RESETSTATE) {
4136 isp_init(isp);
4137 if (isp->isp_state == ISP_INITSTATE) {
4138 isp->isp_state = ISP_RUNSTATE;
4139 }
4140 }
4141 if (isp->isp_state != ISP_RUNSTATE) {
4360 u_int32_t handle;
4361
4362 isp_reset(isp);
4363 if (isp->isp_state == ISP_RESETSTATE) {
4364 isp_init(isp);
4365 if (isp->isp_state == ISP_INITSTATE) {
4366 isp->isp_state = ISP_RUNSTATE;
4367 }
4368 }
4369 if (isp->isp_state != ISP_RUNSTATE) {
4142 PRINTF("%s: isp_restart cannot restart ISP\n", isp->isp_name);
4370 isp_prt(isp, ISP_LOGERR, "isp_reinit cannot restart ISP");
4143 }
4144 isp->isp_nactive = 0;
4145
4371 }
4372 isp->isp_nactive = 0;
4373
4146 for (handle = 1; handle <= (int) isp->isp_maxcmds; handle++) {
4374 for (handle = 1; (int) handle <= isp->isp_maxcmds; handle++) {
4147 xs = isp_find_xs(isp, handle);
4148 if (xs == NULL) {
4149 continue;
4150 }
4151 isp_destroy_handle(isp, handle);
4152 if (XS_XFRLEN(xs)) {
4153 ISP_DMAFREE(isp, xs, handle);
4154 XS_RESID(xs) = XS_XFRLEN(xs);
4155 } else {
4156 XS_RESID(xs) = 0;
4157 }
4158 XS_SETERR(xs, HBA_BUSRESET);
4375 xs = isp_find_xs(isp, handle);
4376 if (xs == NULL) {
4377 continue;
4378 }
4379 isp_destroy_handle(isp, handle);
4380 if (XS_XFRLEN(xs)) {
4381 ISP_DMAFREE(isp, xs, handle);
4382 XS_RESID(xs) = XS_XFRLEN(xs);
4383 } else {
4384 XS_RESID(xs) = 0;
4385 }
4386 XS_SETERR(xs, HBA_BUSRESET);
4159 XS_CMD_DONE(xs);
4387 isp_done(xs);
4160 }
4161}
4162
4163/*
4164 * NVRAM Routines
4165 */
4166static int
4167isp_read_nvram(isp)

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

4192 * NVRAM to continue reading the rest with.
4193 */
4194 for (i = 0; i < 2; i++) {
4195 isp_rdnvram_word(isp, i, &nvram_words[i]);
4196 }
4197 if (nvram_data[0] != 'I' || nvram_data[1] != 'S' ||
4198 nvram_data[2] != 'P') {
4199 if (isp->isp_bustype != ISP_BT_SBUS) {
4388 }
4389}
4390
4391/*
4392 * NVRAM Routines
4393 */
4394static int
4395isp_read_nvram(isp)

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

4420 * NVRAM to continue reading the rest with.
4421 */
4422 for (i = 0; i < 2; i++) {
4423 isp_rdnvram_word(isp, i, &nvram_words[i]);
4424 }
4425 if (nvram_data[0] != 'I' || nvram_data[1] != 'S' ||
4426 nvram_data[2] != 'P') {
4427 if (isp->isp_bustype != ISP_BT_SBUS) {
4200 PRINTF("%s: invalid NVRAM header (%x,%x,%x,%x)\n",
4201 isp->isp_name, nvram_data[0], nvram_data[1],
4202 nvram_data[2], nvram_data[3]);
4428 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM header");
4429 isp_prt(isp, ISP_LOGDEBUG0, "%x %x %x",
4430 nvram_data[0], nvram_data[1], nvram_data[2]);
4203 }
4204 return (-1);
4205 }
4206 for (i = 2; i < amt>>1; i++) {
4207 isp_rdnvram_word(isp, i, &nvram_words[i]);
4208 }
4209 for (csum = 0, i = 0; i < amt; i++) {
4210 csum += nvram_data[i];
4211 }
4212 if (csum != 0) {
4431 }
4432 return (-1);
4433 }
4434 for (i = 2; i < amt>>1; i++) {
4435 isp_rdnvram_word(isp, i, &nvram_words[i]);
4436 }
4437 for (csum = 0, i = 0; i < amt; i++) {
4438 csum += nvram_data[i];
4439 }
4440 if (csum != 0) {
4213 PRINTF("%s: invalid NVRAM checksum\n", isp->isp_name);
4441 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM checksum");
4214 return (-1);
4215 }
4216 if (ISP_NVRAM_VERSION(nvram_data) < minversion) {
4442 return (-1);
4443 }
4444 if (ISP_NVRAM_VERSION(nvram_data) < minversion) {
4217 PRINTF("%s: version %d NVRAM not understood\n", isp->isp_name,
4445 isp_prt(isp, ISP_LOGWARN, "version %d NVRAM not understood",
4218 ISP_NVRAM_VERSION(nvram_data));
4219 return (-1);
4220 }
4221
4222 if (IS_ULTRA3(isp)) {
4223 isp_parse_nvram_12160(isp, 0, nvram_data);
4224 isp_parse_nvram_12160(isp, 1, nvram_data);
4225 } else if (IS_1080(isp)) {
4226 isp_parse_nvram_1080(isp, 0, nvram_data);
4227 } else if (IS_1280(isp) || IS_1240(isp)) {
4228 isp_parse_nvram_1080(isp, 0, nvram_data);
4229 isp_parse_nvram_1080(isp, 1, nvram_data);
4230 } else if (IS_SCSI(isp)) {
4231 isp_parse_nvram_1020(isp, nvram_data);
4232 } else {
4233 isp_parse_nvram_2100(isp, nvram_data);
4234 }
4446 ISP_NVRAM_VERSION(nvram_data));
4447 return (-1);
4448 }
4449
4450 if (IS_ULTRA3(isp)) {
4451 isp_parse_nvram_12160(isp, 0, nvram_data);
4452 isp_parse_nvram_12160(isp, 1, nvram_data);
4453 } else if (IS_1080(isp)) {
4454 isp_parse_nvram_1080(isp, 0, nvram_data);
4455 } else if (IS_1280(isp) || IS_1240(isp)) {
4456 isp_parse_nvram_1080(isp, 0, nvram_data);
4457 isp_parse_nvram_1080(isp, 1, nvram_data);
4458 } else if (IS_SCSI(isp)) {
4459 isp_parse_nvram_1020(isp, nvram_data);
4460 } else {
4461 isp_parse_nvram_2100(isp, nvram_data);
4462 }
4235 IDPRINTF(3, ("%s: NVRAM is valid\n", isp->isp_name));
4236 return (0);
4237#undef nvram_data
4238#undef nvram_words
4239}
4240
4241static void
4242isp_rdnvram_word(isp, wo, rp)
4243 struct ispsoftc *isp;
4244 int wo;
4245 u_int16_t *rp;
4246{
4247 int i, cbits;
4248 u_int16_t bit, rqst;
4249
4250 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
4463 return (0);
4464#undef nvram_data
4465#undef nvram_words
4466}
4467
4468static void
4469isp_rdnvram_word(isp, wo, rp)
4470 struct ispsoftc *isp;
4471 int wo;
4472 u_int16_t *rp;
4473{
4474 int i, cbits;
4475 u_int16_t bit, rqst;
4476
4477 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
4251 SYS_DELAY(2);
4478 USEC_DELAY(2);
4252 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
4479 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
4253 SYS_DELAY(2);
4480 USEC_DELAY(2);
4254
4255 if (IS_FC(isp)) {
4256 wo &= ((ISP2100_NVRAM_SIZE >> 1) - 1);
4257 rqst = (ISP_NVRAM_READ << 8) | wo;
4258 cbits = 10;
4259 } else if (IS_ULTRA2(isp)) {
4260 wo &= ((ISP1080_NVRAM_SIZE >> 1) - 1);
4261 rqst = (ISP_NVRAM_READ << 8) | wo;

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

4271 */
4272 for (i = cbits; i >= 0; i--) {
4273 if ((rqst >> i) & 1) {
4274 bit = BIU_NVRAM_SELECT | BIU_NVRAM_DATAOUT;
4275 } else {
4276 bit = BIU_NVRAM_SELECT;
4277 }
4278 ISP_WRITE(isp, BIU_NVRAM, bit);
4481
4482 if (IS_FC(isp)) {
4483 wo &= ((ISP2100_NVRAM_SIZE >> 1) - 1);
4484 rqst = (ISP_NVRAM_READ << 8) | wo;
4485 cbits = 10;
4486 } else if (IS_ULTRA2(isp)) {
4487 wo &= ((ISP1080_NVRAM_SIZE >> 1) - 1);
4488 rqst = (ISP_NVRAM_READ << 8) | wo;

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

4498 */
4499 for (i = cbits; i >= 0; i--) {
4500 if ((rqst >> i) & 1) {
4501 bit = BIU_NVRAM_SELECT | BIU_NVRAM_DATAOUT;
4502 } else {
4503 bit = BIU_NVRAM_SELECT;
4504 }
4505 ISP_WRITE(isp, BIU_NVRAM, bit);
4279 SYS_DELAY(2);
4506 USEC_DELAY(2);
4280 ISP_WRITE(isp, BIU_NVRAM, bit | BIU_NVRAM_CLOCK);
4507 ISP_WRITE(isp, BIU_NVRAM, bit | BIU_NVRAM_CLOCK);
4281 SYS_DELAY(2);
4508 USEC_DELAY(2);
4282 ISP_WRITE(isp, BIU_NVRAM, bit);
4509 ISP_WRITE(isp, BIU_NVRAM, bit);
4283 SYS_DELAY(2);
4510 USEC_DELAY(2);
4284 }
4285 /*
4286 * Now read the result back in (bits come back in MSB format).
4287 */
4288 *rp = 0;
4289 for (i = 0; i < 16; i++) {
4290 u_int16_t rv;
4291 *rp <<= 1;
4292 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
4511 }
4512 /*
4513 * Now read the result back in (bits come back in MSB format).
4514 */
4515 *rp = 0;
4516 for (i = 0; i < 16; i++) {
4517 u_int16_t rv;
4518 *rp <<= 1;
4519 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
4293 SYS_DELAY(2);
4520 USEC_DELAY(2);
4294 rv = ISP_READ(isp, BIU_NVRAM);
4295 if (rv & BIU_NVRAM_DATAIN) {
4296 *rp |= 1;
4297 }
4521 rv = ISP_READ(isp, BIU_NVRAM);
4522 if (rv & BIU_NVRAM_DATAIN) {
4523 *rp |= 1;
4524 }
4298 SYS_DELAY(2);
4525 USEC_DELAY(2);
4299 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
4526 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
4300 SYS_DELAY(2);
4527 USEC_DELAY(2);
4301 }
4302 ISP_WRITE(isp, BIU_NVRAM, 0);
4528 }
4529 ISP_WRITE(isp, BIU_NVRAM, 0);
4303 SYS_DELAY(2);
4304#if BYTE_ORDER == BIG_ENDIAN
4305 *rp = ((*rp >> 8) | ((*rp & 0xff) << 8));
4306#endif
4530 USEC_DELAY(2);
4531 ISP_SWIZZLE_NVRAM_WORD(isp, rp);
4307}
4308
4309static void
4310isp_parse_nvram_1020(isp, nvram_data)
4311 struct ispsoftc *isp;
4312 u_int8_t *nvram_data;
4313{
4314 int i;
4532}
4533
4534static void
4535isp_parse_nvram_1020(isp, nvram_data)
4536 struct ispsoftc *isp;
4537 u_int8_t *nvram_data;
4538{
4539 int i;
4315 static char *tru = "true";
4316 static char *not = "false";
4317 sdparam *sdp = (sdparam *) isp->isp_param;
4318
4319 sdp->isp_fifo_threshold =
4320 ISP_NVRAM_FIFO_THRESHOLD(nvram_data) |
4321 (ISP_NVRAM_FIFO_THRESHOLD_128(nvram_data) << 2);
4322
4323 sdp->isp_initiator_id =
4324 ISP_NVRAM_INITIATOR_ID(nvram_data);

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

4362
4363 sdp->isp_selection_timeout =
4364 ISP_NVRAM_SELECTION_TIMEOUT(nvram_data);
4365
4366 sdp->isp_max_queue_depth =
4367 ISP_NVRAM_MAX_QUEUE_DEPTH(nvram_data);
4368
4369 isp->isp_fast_mttr = ISP_NVRAM_FAST_MTTR_ENABLE(nvram_data);
4540 sdparam *sdp = (sdparam *) isp->isp_param;
4541
4542 sdp->isp_fifo_threshold =
4543 ISP_NVRAM_FIFO_THRESHOLD(nvram_data) |
4544 (ISP_NVRAM_FIFO_THRESHOLD_128(nvram_data) << 2);
4545
4546 sdp->isp_initiator_id =
4547 ISP_NVRAM_INITIATOR_ID(nvram_data);

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

4585
4586 sdp->isp_selection_timeout =
4587 ISP_NVRAM_SELECTION_TIMEOUT(nvram_data);
4588
4589 sdp->isp_max_queue_depth =
4590 ISP_NVRAM_MAX_QUEUE_DEPTH(nvram_data);
4591
4592 isp->isp_fast_mttr = ISP_NVRAM_FAST_MTTR_ENABLE(nvram_data);
4370 if (isp->isp_dblev > 2) {
4371 PRINTF("%s: NVRAM values:\n", isp->isp_name);
4372 PRINTF(" Fifo Threshold = 0x%x\n",
4373 sdp->isp_fifo_threshold);
4374 PRINTF(" Bus Reset Delay = %d\n",
4375 sdp->isp_bus_reset_delay);
4376 PRINTF(" Retry Count = %d\n",
4377 sdp->isp_retry_count);
4378 PRINTF(" Retry Delay = %d\n",
4379 sdp->isp_retry_delay);
4380 PRINTF(" Tag Age Limit = %d\n",
4381 sdp->isp_tag_aging);
4382 PRINTF(" Selection Timeout = %d\n",
4383 sdp->isp_selection_timeout);
4384 PRINTF(" Max Queue Depth = %d\n",
4385 sdp->isp_max_queue_depth);
4386 PRINTF(" Async Data Setup = 0x%x\n",
4387 sdp->isp_async_data_setup);
4388 PRINTF(" REQ/ACK Active Negation = %s\n",
4389 sdp->isp_req_ack_active_neg? tru : not);
4390 PRINTF(" Data Line Active Negation = %s\n",
4391 sdp->isp_data_line_active_neg? tru : not);
4392 PRINTF(" Data DMA Burst Enable = %s\n",
4393 sdp->isp_data_dma_burst_enabl? tru : not);
4394 PRINTF(" Cmd DMA Burst Enable = %s\n",
4395 sdp->isp_cmd_dma_burst_enable? tru : not);
4396 PRINTF(" Fast MTTR = %s\n",
4397 isp->isp_fast_mttr? tru : not);
4398 }
4399 for (i = 0; i < MAX_TARGETS; i++) {
4400 sdp->isp_devparam[i].dev_enable =
4401 ISP_NVRAM_TGT_DEVICE_ENABLE(nvram_data, i);
4402 sdp->isp_devparam[i].exc_throttle =
4403 ISP_NVRAM_TGT_EXEC_THROTTLE(nvram_data, i);
4404 sdp->isp_devparam[i].sync_offset =
4405 ISP_NVRAM_TGT_SYNC_OFFSET(nvram_data, i);
4406 sdp->isp_devparam[i].sync_period =
4407 ISP_NVRAM_TGT_SYNC_PERIOD(nvram_data, i);
4408
4409 if (isp->isp_type < ISP_HA_SCSI_1040) {
4410 /*
4411 * If we're not ultra, we can't possibly
4412 * be a shorter period than this.
4413 */
4414 if (sdp->isp_devparam[i].sync_period < 0x19) {
4593 for (i = 0; i < MAX_TARGETS; i++) {
4594 sdp->isp_devparam[i].dev_enable =
4595 ISP_NVRAM_TGT_DEVICE_ENABLE(nvram_data, i);
4596 sdp->isp_devparam[i].exc_throttle =
4597 ISP_NVRAM_TGT_EXEC_THROTTLE(nvram_data, i);
4598 sdp->isp_devparam[i].sync_offset =
4599 ISP_NVRAM_TGT_SYNC_OFFSET(nvram_data, i);
4600 sdp->isp_devparam[i].sync_period =
4601 ISP_NVRAM_TGT_SYNC_PERIOD(nvram_data, i);
4602
4603 if (isp->isp_type < ISP_HA_SCSI_1040) {
4604 /*
4605 * If we're not ultra, we can't possibly
4606 * be a shorter period than this.
4607 */
4608 if (sdp->isp_devparam[i].sync_period < 0x19) {
4415 sdp->isp_devparam[i].sync_period =
4416 0x19;
4609 sdp->isp_devparam[i].sync_period = 0x19;
4417 }
4418 if (sdp->isp_devparam[i].sync_offset > 0xc) {
4610 }
4611 if (sdp->isp_devparam[i].sync_offset > 0xc) {
4419 sdp->isp_devparam[i].sync_offset =
4420 0x0c;
4612 sdp->isp_devparam[i].sync_offset = 0x0c;
4421 }
4422 } else {
4423 if (sdp->isp_devparam[i].sync_offset > 0x8) {
4424 sdp->isp_devparam[i].sync_offset = 0x8;
4425 }
4426 }
4427 sdp->isp_devparam[i].dev_flags = 0;
4428 if (ISP_NVRAM_TGT_RENEG(nvram_data, i))
4429 sdp->isp_devparam[i].dev_flags |= DPARM_RENEG;
4613 }
4614 } else {
4615 if (sdp->isp_devparam[i].sync_offset > 0x8) {
4616 sdp->isp_devparam[i].sync_offset = 0x8;
4617 }
4618 }
4619 sdp->isp_devparam[i].dev_flags = 0;
4620 if (ISP_NVRAM_TGT_RENEG(nvram_data, i))
4621 sdp->isp_devparam[i].dev_flags |= DPARM_RENEG;
4430 if (ISP_NVRAM_TGT_QFRZ(nvram_data, i)) {
4431 PRINTF("%s: not supporting QFRZ option for "
4432 "target %d\n", isp->isp_name, i);
4433 }
4434 sdp->isp_devparam[i].dev_flags |= DPARM_ARQ;
4622 sdp->isp_devparam[i].dev_flags |= DPARM_ARQ;
4435 if (ISP_NVRAM_TGT_ARQ(nvram_data, i) == 0) {
4436 PRINTF("%s: not disabling ARQ option for "
4437 "target %d\n", isp->isp_name, i);
4438 }
4439 if (ISP_NVRAM_TGT_TQING(nvram_data, i))
4440 sdp->isp_devparam[i].dev_flags |= DPARM_TQING;
4441 if (ISP_NVRAM_TGT_SYNC(nvram_data, i))
4442 sdp->isp_devparam[i].dev_flags |= DPARM_SYNC;
4443 if (ISP_NVRAM_TGT_WIDE(nvram_data, i))
4444 sdp->isp_devparam[i].dev_flags |= DPARM_WIDE;
4445 if (ISP_NVRAM_TGT_PARITY(nvram_data, i))
4446 sdp->isp_devparam[i].dev_flags |= DPARM_PARITY;
4447 if (ISP_NVRAM_TGT_DISC(nvram_data, i))
4448 sdp->isp_devparam[i].dev_flags |= DPARM_DISC;
4449 sdp->isp_devparam[i].cur_dflags = 0; /* we don't know */
4623 if (ISP_NVRAM_TGT_TQING(nvram_data, i))
4624 sdp->isp_devparam[i].dev_flags |= DPARM_TQING;
4625 if (ISP_NVRAM_TGT_SYNC(nvram_data, i))
4626 sdp->isp_devparam[i].dev_flags |= DPARM_SYNC;
4627 if (ISP_NVRAM_TGT_WIDE(nvram_data, i))
4628 sdp->isp_devparam[i].dev_flags |= DPARM_WIDE;
4629 if (ISP_NVRAM_TGT_PARITY(nvram_data, i))
4630 sdp->isp_devparam[i].dev_flags |= DPARM_PARITY;
4631 if (ISP_NVRAM_TGT_DISC(nvram_data, i))
4632 sdp->isp_devparam[i].dev_flags |= DPARM_DISC;
4633 sdp->isp_devparam[i].cur_dflags = 0; /* we don't know */
4450 if (isp->isp_dblev > 2) {
4451 PRINTF(" Target %d: Enabled %d Throttle %d "
4452 "Offset %d Period %d Flags 0x%x\n", i,
4453 sdp->isp_devparam[i].dev_enable,
4454 sdp->isp_devparam[i].exc_throttle,
4455 sdp->isp_devparam[i].sync_offset,
4456 sdp->isp_devparam[i].sync_period,
4457 sdp->isp_devparam[i].dev_flags);
4458 }
4459 }
4460}
4461
4462static void
4463isp_parse_nvram_1080(isp, bus, nvram_data)
4464 struct ispsoftc *isp;
4465 int bus;
4466 u_int8_t *nvram_data;
4467{
4634 }
4635}
4636
4637static void
4638isp_parse_nvram_1080(isp, bus, nvram_data)
4639 struct ispsoftc *isp;
4640 int bus;
4641 u_int8_t *nvram_data;
4642{
4468 static char *tru = "true";
4469 static char *not = "false";
4470 int i;
4471 sdparam *sdp = (sdparam *) isp->isp_param;
4472 sdp += bus;
4473
4474 sdp->isp_fifo_threshold =
4475 ISP1080_NVRAM_FIFO_THRESHOLD(nvram_data);
4476
4477 sdp->isp_initiator_id =

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

4505 ISP1080_NVRAM_BURST_ENABLE(nvram_data);
4506
4507 sdp->isp_selection_timeout =
4508 ISP1080_NVRAM_SELECTION_TIMEOUT(nvram_data, bus);
4509
4510 sdp->isp_max_queue_depth =
4511 ISP1080_NVRAM_MAX_QUEUE_DEPTH(nvram_data, bus);
4512
4643 int i;
4644 sdparam *sdp = (sdparam *) isp->isp_param;
4645 sdp += bus;
4646
4647 sdp->isp_fifo_threshold =
4648 ISP1080_NVRAM_FIFO_THRESHOLD(nvram_data);
4649
4650 sdp->isp_initiator_id =

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

4678 ISP1080_NVRAM_BURST_ENABLE(nvram_data);
4679
4680 sdp->isp_selection_timeout =
4681 ISP1080_NVRAM_SELECTION_TIMEOUT(nvram_data, bus);
4682
4683 sdp->isp_max_queue_depth =
4684 ISP1080_NVRAM_MAX_QUEUE_DEPTH(nvram_data, bus);
4685
4513 if (isp->isp_dblev >= 3) {
4514 PRINTF("%s: ISP1080 bus %d NVRAM values:\n",
4515 isp->isp_name, bus);
4516 PRINTF(" Initiator ID = %d\n",
4517 sdp->isp_initiator_id);
4518 PRINTF(" Fifo Threshold = 0x%x\n",
4519 sdp->isp_fifo_threshold);
4520 PRINTF(" Bus Reset Delay = %d\n",
4521 sdp->isp_bus_reset_delay);
4522 PRINTF(" Retry Count = %d\n",
4523 sdp->isp_retry_count);
4524 PRINTF(" Retry Delay = %d\n",
4525 sdp->isp_retry_delay);
4526 PRINTF(" Tag Age Limit = %d\n",
4527 sdp->isp_tag_aging);
4528 PRINTF(" Selection Timeout = %d\n",
4529 sdp->isp_selection_timeout);
4530 PRINTF(" Max Queue Depth = %d\n",
4531 sdp->isp_max_queue_depth);
4532 PRINTF(" Async Data Setup = 0x%x\n",
4533 sdp->isp_async_data_setup);
4534 PRINTF(" REQ/ACK Active Negation = %s\n",
4535 sdp->isp_req_ack_active_neg? tru : not);
4536 PRINTF(" Data Line Active Negation = %s\n",
4537 sdp->isp_data_line_active_neg? tru : not);
4538 PRINTF(" Cmd DMA Burst Enable = %s\n",
4539 sdp->isp_cmd_dma_burst_enable? tru : not);
4540 }
4541 for (i = 0; i < MAX_TARGETS; i++) {
4542 sdp->isp_devparam[i].dev_enable =
4543 ISP1080_NVRAM_TGT_DEVICE_ENABLE(nvram_data, i, bus);
4544 sdp->isp_devparam[i].exc_throttle =
4545 ISP1080_NVRAM_TGT_EXEC_THROTTLE(nvram_data, i, bus);
4546 sdp->isp_devparam[i].sync_offset =
4547 ISP1080_NVRAM_TGT_SYNC_OFFSET(nvram_data, i, bus);
4548 sdp->isp_devparam[i].sync_period =
4549 ISP1080_NVRAM_TGT_SYNC_PERIOD(nvram_data, i, bus);
4550 sdp->isp_devparam[i].dev_flags = 0;
4551 if (ISP1080_NVRAM_TGT_RENEG(nvram_data, i, bus))
4552 sdp->isp_devparam[i].dev_flags |= DPARM_RENEG;
4686 for (i = 0; i < MAX_TARGETS; i++) {
4687 sdp->isp_devparam[i].dev_enable =
4688 ISP1080_NVRAM_TGT_DEVICE_ENABLE(nvram_data, i, bus);
4689 sdp->isp_devparam[i].exc_throttle =
4690 ISP1080_NVRAM_TGT_EXEC_THROTTLE(nvram_data, i, bus);
4691 sdp->isp_devparam[i].sync_offset =
4692 ISP1080_NVRAM_TGT_SYNC_OFFSET(nvram_data, i, bus);
4693 sdp->isp_devparam[i].sync_period =
4694 ISP1080_NVRAM_TGT_SYNC_PERIOD(nvram_data, i, bus);
4695 sdp->isp_devparam[i].dev_flags = 0;
4696 if (ISP1080_NVRAM_TGT_RENEG(nvram_data, i, bus))
4697 sdp->isp_devparam[i].dev_flags |= DPARM_RENEG;
4553 if (ISP1080_NVRAM_TGT_QFRZ(nvram_data, i, bus)) {
4554 PRINTF("%s: not supporting QFRZ option "
4555 "for target %d bus %d\n",
4556 isp->isp_name, i, bus);
4557 }
4558 sdp->isp_devparam[i].dev_flags |= DPARM_ARQ;
4698 sdp->isp_devparam[i].dev_flags |= DPARM_ARQ;
4559 if (ISP1080_NVRAM_TGT_ARQ(nvram_data, i, bus) == 0) {
4560 PRINTF("%s: not disabling ARQ option "
4561 "for target %d bus %d\n",
4562 isp->isp_name, i, bus);
4563 }
4564 if (ISP1080_NVRAM_TGT_TQING(nvram_data, i, bus))
4565 sdp->isp_devparam[i].dev_flags |= DPARM_TQING;
4566 if (ISP1080_NVRAM_TGT_SYNC(nvram_data, i, bus))
4567 sdp->isp_devparam[i].dev_flags |= DPARM_SYNC;
4568 if (ISP1080_NVRAM_TGT_WIDE(nvram_data, i, bus))
4569 sdp->isp_devparam[i].dev_flags |= DPARM_WIDE;
4570 if (ISP1080_NVRAM_TGT_PARITY(nvram_data, i, bus))
4571 sdp->isp_devparam[i].dev_flags |= DPARM_PARITY;
4572 if (ISP1080_NVRAM_TGT_DISC(nvram_data, i, bus))
4573 sdp->isp_devparam[i].dev_flags |= DPARM_DISC;
4574 sdp->isp_devparam[i].cur_dflags = 0;
4699 if (ISP1080_NVRAM_TGT_TQING(nvram_data, i, bus))
4700 sdp->isp_devparam[i].dev_flags |= DPARM_TQING;
4701 if (ISP1080_NVRAM_TGT_SYNC(nvram_data, i, bus))
4702 sdp->isp_devparam[i].dev_flags |= DPARM_SYNC;
4703 if (ISP1080_NVRAM_TGT_WIDE(nvram_data, i, bus))
4704 sdp->isp_devparam[i].dev_flags |= DPARM_WIDE;
4705 if (ISP1080_NVRAM_TGT_PARITY(nvram_data, i, bus))
4706 sdp->isp_devparam[i].dev_flags |= DPARM_PARITY;
4707 if (ISP1080_NVRAM_TGT_DISC(nvram_data, i, bus))
4708 sdp->isp_devparam[i].dev_flags |= DPARM_DISC;
4709 sdp->isp_devparam[i].cur_dflags = 0;
4575 if (isp->isp_dblev >= 3) {
4576 PRINTF(" Target %d: Ena %d Throttle "
4577 "%d Offset %d Period %d Flags "
4578 "0x%x\n", i,
4579 sdp->isp_devparam[i].dev_enable,
4580 sdp->isp_devparam[i].exc_throttle,
4581 sdp->isp_devparam[i].sync_offset,
4582 sdp->isp_devparam[i].sync_period,
4583 sdp->isp_devparam[i].dev_flags);
4584 }
4585 }
4586}
4587
4588static void
4589isp_parse_nvram_12160(isp, bus, nvram_data)
4590 struct ispsoftc *isp;
4591 int bus;
4592 u_int8_t *nvram_data;
4593{
4710 }
4711}
4712
4713static void
4714isp_parse_nvram_12160(isp, bus, nvram_data)
4715 struct ispsoftc *isp;
4716 int bus;
4717 u_int8_t *nvram_data;
4718{
4594 static char *tru = "true";
4595 static char *not = "false";
4596 sdparam *sdp = (sdparam *) isp->isp_param;
4597 int i;
4598
4599 sdp += bus;
4600
4601 sdp->isp_fifo_threshold =
4602 ISP12160_NVRAM_FIFO_THRESHOLD(nvram_data);
4603

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

4632 ISP12160_NVRAM_BURST_ENABLE(nvram_data);
4633
4634 sdp->isp_selection_timeout =
4635 ISP12160_NVRAM_SELECTION_TIMEOUT(nvram_data, bus);
4636
4637 sdp->isp_max_queue_depth =
4638 ISP12160_NVRAM_MAX_QUEUE_DEPTH(nvram_data, bus);
4639
4719 sdparam *sdp = (sdparam *) isp->isp_param;
4720 int i;
4721
4722 sdp += bus;
4723
4724 sdp->isp_fifo_threshold =
4725 ISP12160_NVRAM_FIFO_THRESHOLD(nvram_data);
4726

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

4755 ISP12160_NVRAM_BURST_ENABLE(nvram_data);
4756
4757 sdp->isp_selection_timeout =
4758 ISP12160_NVRAM_SELECTION_TIMEOUT(nvram_data, bus);
4759
4760 sdp->isp_max_queue_depth =
4761 ISP12160_NVRAM_MAX_QUEUE_DEPTH(nvram_data, bus);
4762
4640 if (isp->isp_dblev >= 3) {
4641 PRINTF("%s: ISP12160 bus %d NVRAM values:\n",
4642 isp->isp_name, bus);
4643 PRINTF(" Initiator ID = %d\n",
4644 sdp->isp_initiator_id);
4645 PRINTF(" Fifo Threshold = 0x%x\n",
4646 sdp->isp_fifo_threshold);
4647 PRINTF(" Bus Reset Delay = %d\n",
4648 sdp->isp_bus_reset_delay);
4649 PRINTF(" Retry Count = %d\n",
4650 sdp->isp_retry_count);
4651 PRINTF(" Retry Delay = %d\n",
4652 sdp->isp_retry_delay);
4653 PRINTF(" Tag Age Limit = %d\n",
4654 sdp->isp_tag_aging);
4655 PRINTF(" Selection Timeout = %d\n",
4656 sdp->isp_selection_timeout);
4657 PRINTF(" Max Queue Depth = %d\n",
4658 sdp->isp_max_queue_depth);
4659 PRINTF(" Async Data Setup = 0x%x\n",
4660 sdp->isp_async_data_setup);
4661 PRINTF(" REQ/ACK Active Negation = %s\n",
4662 sdp->isp_req_ack_active_neg? tru : not);
4663 PRINTF(" Data Line Active Negation = %s\n",
4664 sdp->isp_data_line_active_neg? tru : not);
4665 PRINTF(" Cmd DMA Burst Enable = %s\n",
4666 sdp->isp_cmd_dma_burst_enable? tru : not);
4667 }
4668
4669 for (i = 0; i < MAX_TARGETS; i++) {
4670 sdp->isp_devparam[i].dev_enable =
4671 ISP12160_NVRAM_TGT_DEVICE_ENABLE(nvram_data, i, bus);
4672 sdp->isp_devparam[i].exc_throttle =
4673 ISP12160_NVRAM_TGT_EXEC_THROTTLE(nvram_data, i, bus);
4674 sdp->isp_devparam[i].sync_offset =
4675 ISP12160_NVRAM_TGT_SYNC_OFFSET(nvram_data, i, bus);
4676 sdp->isp_devparam[i].sync_period =
4677 ISP12160_NVRAM_TGT_SYNC_PERIOD(nvram_data, i, bus);
4678 sdp->isp_devparam[i].dev_flags = 0;
4679 if (ISP12160_NVRAM_TGT_RENEG(nvram_data, i, bus))
4680 sdp->isp_devparam[i].dev_flags |= DPARM_RENEG;
4763 for (i = 0; i < MAX_TARGETS; i++) {
4764 sdp->isp_devparam[i].dev_enable =
4765 ISP12160_NVRAM_TGT_DEVICE_ENABLE(nvram_data, i, bus);
4766 sdp->isp_devparam[i].exc_throttle =
4767 ISP12160_NVRAM_TGT_EXEC_THROTTLE(nvram_data, i, bus);
4768 sdp->isp_devparam[i].sync_offset =
4769 ISP12160_NVRAM_TGT_SYNC_OFFSET(nvram_data, i, bus);
4770 sdp->isp_devparam[i].sync_period =
4771 ISP12160_NVRAM_TGT_SYNC_PERIOD(nvram_data, i, bus);
4772 sdp->isp_devparam[i].dev_flags = 0;
4773 if (ISP12160_NVRAM_TGT_RENEG(nvram_data, i, bus))
4774 sdp->isp_devparam[i].dev_flags |= DPARM_RENEG;
4681 if (ISP12160_NVRAM_TGT_QFRZ(nvram_data, i, bus)) {
4682 PRINTF("%s: not supporting QFRZ option "
4683 "for target %d bus %d\n", isp->isp_name, i, bus);
4684 }
4685 sdp->isp_devparam[i].dev_flags |= DPARM_ARQ;
4775 sdp->isp_devparam[i].dev_flags |= DPARM_ARQ;
4686 if (ISP12160_NVRAM_TGT_ARQ(nvram_data, i, bus) == 0) {
4687 PRINTF("%s: not disabling ARQ option "
4688 "for target %d bus %d\n", isp->isp_name, i, bus);
4689 }
4690 if (ISP12160_NVRAM_TGT_TQING(nvram_data, i, bus))
4691 sdp->isp_devparam[i].dev_flags |= DPARM_TQING;
4692 if (ISP12160_NVRAM_TGT_SYNC(nvram_data, i, bus))
4693 sdp->isp_devparam[i].dev_flags |= DPARM_SYNC;
4694 if (ISP12160_NVRAM_TGT_WIDE(nvram_data, i, bus))
4695 sdp->isp_devparam[i].dev_flags |= DPARM_WIDE;
4696 if (ISP12160_NVRAM_TGT_PARITY(nvram_data, i, bus))
4697 sdp->isp_devparam[i].dev_flags |= DPARM_PARITY;
4698 if (ISP12160_NVRAM_TGT_DISC(nvram_data, i, bus))
4699 sdp->isp_devparam[i].dev_flags |= DPARM_DISC;
4700 sdp->isp_devparam[i].cur_dflags = 0;
4776 if (ISP12160_NVRAM_TGT_TQING(nvram_data, i, bus))
4777 sdp->isp_devparam[i].dev_flags |= DPARM_TQING;
4778 if (ISP12160_NVRAM_TGT_SYNC(nvram_data, i, bus))
4779 sdp->isp_devparam[i].dev_flags |= DPARM_SYNC;
4780 if (ISP12160_NVRAM_TGT_WIDE(nvram_data, i, bus))
4781 sdp->isp_devparam[i].dev_flags |= DPARM_WIDE;
4782 if (ISP12160_NVRAM_TGT_PARITY(nvram_data, i, bus))
4783 sdp->isp_devparam[i].dev_flags |= DPARM_PARITY;
4784 if (ISP12160_NVRAM_TGT_DISC(nvram_data, i, bus))
4785 sdp->isp_devparam[i].dev_flags |= DPARM_DISC;
4786 sdp->isp_devparam[i].cur_dflags = 0;
4701 if (isp->isp_dblev >= 3) {
4702 PRINTF(" Target %d: Ena %d Throttle %d Offset %d "
4703 "Period %d Flags 0x%x\n", i,
4704 sdp->isp_devparam[i].dev_enable,
4705 sdp->isp_devparam[i].exc_throttle,
4706 sdp->isp_devparam[i].sync_offset,
4707 sdp->isp_devparam[i].sync_period,
4708 sdp->isp_devparam[i].dev_flags);
4709 }
4710 }
4711}
4712
4713static void
4714isp_parse_nvram_2100(isp, nvram_data)
4715 struct ispsoftc *isp;
4716 u_int8_t *nvram_data;
4717{
4718 fcparam *fcp = (fcparam *) isp->isp_param;
4787 }
4788}
4789
4790static void
4791isp_parse_nvram_2100(isp, nvram_data)
4792 struct ispsoftc *isp;
4793 u_int8_t *nvram_data;
4794{
4795 fcparam *fcp = (fcparam *) isp->isp_param;
4719 union {
4720 struct {
4721#if BYTE_ORDER == BIG_ENDIAN
4722 u_int32_t hi32;
4723 u_int32_t lo32;
4724#else
4725 u_int32_t lo32;
4726 u_int32_t hi32;
4727#endif
4728 } wd;
4729 u_int64_t full64;
4730 } wwnstore;
4796 u_int64_t wwn;
4731
4732 /*
4733 * There is supposed to be WWNN storage as distinct
4734 * from WWPN storage in NVRAM, but it doesn't appear
4797
4798 /*
4799 * There is supposed to be WWNN storage as distinct
4800 * from WWPN storage in NVRAM, but it doesn't appear
4735 * to be used sanely.
4801 * to be used sanely across all cards.
4736 */
4737
4802 */
4803
4738 wwnstore.full64 = ISP2100_NVRAM_PORT_NAME(nvram_data);
4739 if (wwnstore.full64 != 0LL) {
4740 switch ((int) (wwnstore.full64 >> 60)) {
4804 wwn = ISP2100_NVRAM_PORT_NAME(nvram_data);
4805 if (wwn != 0LL) {
4806 switch ((int) (wwn >> 60)) {
4741 case 0:
4742 /*
4807 case 0:
4808 /*
4743 * Broken cards with nothing in the top nibble.
4744 * Pah.
4809 * Broken PTI cards with nothing in the top nibble. Pah.
4745 */
4810 */
4746 wwnstore.full64 |= (2LL << 60);
4811 wwn |= (2LL << 60);
4747 /* FALLTHROUGH */
4748 case 2:
4812 /* FALLTHROUGH */
4813 case 2:
4749 fcp->isp_portwwn = wwnstore.full64;
4750 fcp->isp_nodewwn = wwnstore.full64;
4814 fcp->isp_nodewwn = wwn;
4751 fcp->isp_nodewwn &= ~((0xfffLL) << 48);
4815 fcp->isp_nodewwn &= ~((0xfffLL) << 48);
4752 if (fcp->isp_nodewwn == fcp->isp_portwwn) {
4753 fcp->isp_portwwn |=
4754 (((u_int64_t)(isp->isp_unit+1)) << 48);
4755 }
4816 fcp->isp_portwwn =
4817 PORT_FROM_NODE_WWN(isp, fcp->isp_nodewwn);
4756 break;
4757 default:
4818 break;
4819 default:
4758 fcp->isp_portwwn = wwnstore.full64;
4759 fcp->isp_nodewwn = wwnstore.full64;
4820 fcp->isp_portwwn = fcp->isp_nodewwn = wwn;
4760 }
4761 }
4821 }
4822 }
4762 CFGPRINTF("%s: Node WWN 0x%08x%08x, Port WWN 0x%08x%08x\n",
4763 isp->isp_name, (u_int32_t) (fcp->isp_nodewwn >> 32),
4764 (u_int32_t) (fcp->isp_nodewwn & 0xffffffff),
4823 isp_prt(isp, ISP_LOGCONFIG, "NVRAM Derived Node WWN 0x%08x%08x",
4824 (u_int32_t) (fcp->isp_nodewwn >> 32),
4825 (u_int32_t) (fcp->isp_nodewwn & 0xffffffff));
4826 isp_prt(isp, ISP_LOGCONFIG, "NVRAM Derived Port WWN 0x%08x%08x",
4765 (u_int32_t) (fcp->isp_portwwn >> 32),
4766 (u_int32_t) (fcp->isp_portwwn & 0xffffffff));
4827 (u_int32_t) (fcp->isp_portwwn >> 32),
4828 (u_int32_t) (fcp->isp_portwwn & 0xffffffff));
4767
4768 fcp->isp_maxalloc =
4769 ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data);
4770 fcp->isp_maxfrmlen =
4771 ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data);
4772 fcp->isp_retry_delay =
4773 ISP2100_NVRAM_RETRY_DELAY(nvram_data);
4774 fcp->isp_retry_count =
4775 ISP2100_NVRAM_RETRY_COUNT(nvram_data);
4776 fcp->isp_loopid =
4777 ISP2100_NVRAM_HARDLOOPID(nvram_data);
4778 fcp->isp_execthrottle =
4779 ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data);
4780 fcp->isp_fwoptions = ISP2100_NVRAM_OPTIONS(nvram_data);
4829 fcp->isp_maxalloc =
4830 ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data);
4831 fcp->isp_maxfrmlen =
4832 ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data);
4833 fcp->isp_retry_delay =
4834 ISP2100_NVRAM_RETRY_DELAY(nvram_data);
4835 fcp->isp_retry_count =
4836 ISP2100_NVRAM_RETRY_COUNT(nvram_data);
4837 fcp->isp_loopid =
4838 ISP2100_NVRAM_HARDLOOPID(nvram_data);
4839 fcp->isp_execthrottle =
4840 ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data);
4841 fcp->isp_fwoptions = ISP2100_NVRAM_OPTIONS(nvram_data);
4781 if (isp->isp_dblev > 2) {
4782 PRINTF("%s: NVRAM values:\n", isp->isp_name);
4783 PRINTF(" Max IOCB Allocation = %d\n",
4784 fcp->isp_maxalloc);
4785 PRINTF(" Max Frame Length = %d\n",
4786 fcp->isp_maxfrmlen);
4787 PRINTF(" Execution Throttle = %d\n",
4788 fcp->isp_execthrottle);
4789 PRINTF(" Retry Count = %d\n",
4790 fcp->isp_retry_count);
4791 PRINTF(" Retry Delay = %d\n",
4792 fcp->isp_retry_delay);
4793 PRINTF(" Hard Loop ID = %d\n",
4794 fcp->isp_loopid);
4795 PRINTF(" Options = 0x%x\n",
4796 fcp->isp_fwoptions);
4797 PRINTF(" HBA Options = 0x%x\n",
4798 ISP2100_NVRAM_HBA_OPTIONS(nvram_data));
4799 }
4800}
4842}