isp_netbsd.h revision 1.42 1 /* $NetBSD: isp_netbsd.h,v 1.42 2001/05/16 21:41:52 mjacob Exp $ */
2 /*
3 * This driver, which is contained in NetBSD in the files:
4 *
5 * sys/dev/ic/isp.c
6 * sys/dev/ic/isp_inline.h
7 * sys/dev/ic/isp_netbsd.c
8 * sys/dev/ic/isp_netbsd.h
9 * sys/dev/ic/isp_target.c
10 * sys/dev/ic/isp_target.h
11 * sys/dev/ic/isp_tpublic.h
12 * sys/dev/ic/ispmbox.h
13 * sys/dev/ic/ispreg.h
14 * sys/dev/ic/ispvar.h
15 * sys/microcode/isp/asm_sbus.h
16 * sys/microcode/isp/asm_1040.h
17 * sys/microcode/isp/asm_1080.h
18 * sys/microcode/isp/asm_12160.h
19 * sys/microcode/isp/asm_2100.h
20 * sys/microcode/isp/asm_2200.h
21 * sys/pci/isp_pci.c
22 * sys/sbus/isp_sbus.c
23 *
24 * Is being actively maintained by Matthew Jacob (mjacob (at) netbsd.org).
25 * This driver also is shared source with FreeBSD, OpenBSD, Linux, Solaris,
26 * Linux versions. This tends to be an interesting maintenance problem.
27 *
28 * Please coordinate with Matthew Jacob on changes you wish to make here.
29 */
30 /*
31 * NetBSD Specific definitions for the Qlogic ISP Host Adapter
32 * Matthew Jacob <mjacob (at) nas.nasa.gov>
33 */
34 /*
35 * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
36 * All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. The name of the author may not be used to endorse or promote products
47 * derived from this software without specific prior written permission
48 *
49 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
50 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
51 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
52 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
53 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
54 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
55 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
56 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
58 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 */
60 #ifndef _ISP_NETBSD_H
61 #define _ISP_NETBSD_H
62
63 #include <sys/types.h>
64 #include <sys/param.h>
65 #include <sys/systm.h>
66 #include <sys/kernel.h>
67 #include <sys/errno.h>
68 #include <sys/ioctl.h>
69 #include <sys/device.h>
70 #include <sys/malloc.h>
71 #include <sys/buf.h>
72 #include <sys/proc.h>
73 #include <sys/user.h>
74
75
76 #include <dev/scsipi/scsi_all.h>
77 #include <dev/scsipi/scsipi_all.h>
78 #include <dev/scsipi/scsiconf.h>
79
80 #include <dev/scsipi/scsi_message.h>
81 #include <dev/scsipi/scsipi_debug.h>
82
83 #include "opt_isp.h"
84
85
86 #define ISP_PLATFORM_VERSION_MAJOR 1
87 #define ISP_PLATFORM_VERSION_MINOR 1
88
89 struct isposinfo {
90 struct device _dev;
91 struct scsipi_channel _chan;
92 struct scsipi_channel _chan_b;
93 struct scsipi_adapter _adapter;
94 int splsaved;
95 int mboxwaiting;
96 u_int32_t islocked;
97 u_int32_t onintstack;
98 unsigned int : 28,
99 mbox_wanted : 1,
100 mbox_locked : 1,
101 no_mbox_ints : 1,
102 blocked : 1;
103 union {
104 u_int64_t _wwn;
105 u_int16_t _discovered[2];
106 #define wwn_seed un._wwn
107 #define discovered un._discovered
108 } un;
109 TAILQ_HEAD(, scsipi_xfer) waitq;
110 struct callout _restart;
111 };
112 #define ISP_MUSTPOLL(isp) \
113 (isp->isp_osinfo.onintstack || isp->isp_osinfo.no_mbox_ints)
114
115 /*
116 * Required Macros/Defines
117 */
118
119 #define INLINE __inline
120
121 #define ISP2100_SCRLEN 0x400
122
123 #define MEMZERO bzero
124 #define MEMCPY(dst, src, amt) bcopy((src), (dst), (amt))
125 #define SNPRINTF snprintf
126 #define STRNCAT strncat
127 #define USEC_DELAY DELAY
128 #define USEC_SLEEP(isp, x) \
129 if (!ISP_MUSTPOLL(isp)) \
130 ISP_UNLOCK(isp); \
131 DELAY(x); \
132 if (!ISP_MUSTPOLL(isp)) \
133 ISP_LOCK(isp)
134
135 #define NANOTIME_T struct timeval
136 #define GET_NANOTIME microtime
137 #define GET_NANOSEC(x) (((x)->tv_sec * 1000000 + (x)->tv_usec) * 1000)
138 #define NANOTIME_SUB isp_microtime_sub
139
140 #define MAXISPREQUEST(isp) 256
141
142 #ifdef __alpha__
143 #define MEMORYBARRIER(isp, type, offset, size) alpha_mb()
144 #else
145 #define MEMORYBARRIER(isp, type, offset, size)
146 #endif
147
148 #define MBOX_ACQUIRE(isp) \
149 if (isp->isp_osinfo.onintstack) { \
150 if (isp->isp_osinfo.mbox_locked) { \
151 mbp->param[0] = MBOX_HOST_INTERFACE_ERROR; \
152 isp_prt(isp, ISP_LOGERR, "cannot acquire MBOX lock"); \
153 return; \
154 } \
155 } else { \
156 while (isp->isp_osinfo.mbox_locked) { \
157 isp->isp_osinfo.mbox_wanted = 1; \
158 (void) tsleep(&isp->isp_osinfo.mboxwaiting+1, \
159 PRIBIO, "mbox_acquire", 0); \
160 } \
161 } \
162 isp->isp_osinfo.mbox_locked = 1
163
164 #define MBOX_WAIT_COMPLETE isp_wait_complete
165
166 #define MBOX_NOTIFY_COMPLETE(isp) \
167 if (isp->isp_osinfo.mboxwaiting) { \
168 isp->isp_osinfo.mboxwaiting = 0; \
169 wakeup(&isp->isp_osinfo.mboxwaiting); \
170 } \
171 isp->isp_mboxbsy = 0
172
173 #define MBOX_RELEASE(isp) \
174 if (isp->isp_osinfo.mbox_wanted) { \
175 isp->isp_osinfo.mbox_wanted = 0; \
176 wakeup(&isp->isp_osinfo.mboxwaiting+1); \
177 } \
178 isp->isp_osinfo.mbox_locked = 0
179
180 #ifndef SCSI_GOOD
181 #define SCSI_GOOD 0x0
182 #endif
183 #ifndef SCSI_CHECK
184 #define SCSI_CHECK 0x2
185 #endif
186 #ifndef SCSI_BUSY
187 #define SCSI_BUSY 0x8
188 #endif
189 #ifndef SCSI_QFULL
190 #define SCSI_QFULL 0x28
191 #endif
192
193 #define XS_T struct scsipi_xfer
194 #define XS_CHANNEL(xs) ((int) (xs)->xs_periph->periph_channel->chan_channel)
195 #define XS_ISP(xs) \
196 ((void *)(xs)->xs_periph->periph_channel->chan_adapter->adapt_dev)
197 #define XS_LUN(xs) ((int) (xs)->xs_periph->periph_lun)
198 #define XS_TGT(xs) ((int) (xs)->xs_periph->periph_target)
199 #define XS_CDBP(xs) ((caddr_t) (xs)->cmd)
200 #define XS_CDBLEN(xs) (xs)->cmdlen
201 #define XS_XFRLEN(xs) (xs)->datalen
202 #define XS_TIME(xs) (xs)->timeout
203 #define XS_RESID(xs) (xs)->resid
204 #define XS_STSP(xs) (&(xs)->status)
205 #define XS_SNSP(xs) (&(xs)->sense.scsi_sense)
206 #define XS_SNSLEN(xs) (sizeof (xs)->sense)
207 #define XS_SNSKEY(xs) ((xs)->sense.scsi_sense.flags)
208 #define XS_TAG_P(ccb) (((xs)->xs_control & XS_CTL_POLL) != 0)
209 #define XS_TAG_TYPE(xs) \
210 (((xs)->xs_control & XS_CTL_URGENT) ? REQFLAG_HTAG : \
211 ((xs)->bp && xs->bp->b_flags & B_ASYNC) ? REQFLAG_STAG : REQFLAG_OTAG)
212
213 #define XS_SETERR(xs, v) (xs)->error = v
214
215 # define HBA_NOERROR XS_NOERROR
216 # define HBA_BOTCH XS_DRIVER_STUFFUP
217 # define HBA_CMDTIMEOUT XS_TIMEOUT
218 # define HBA_SELTIMEOUT XS_SELTIMEOUT
219 # define HBA_TGTBSY XS_BUSY
220 # define HBA_BUSRESET XS_RESET
221 # define HBA_ABORTED XS_DRIVER_STUFFUP
222 # define HBA_DATAOVR XS_DRIVER_STUFFUP
223 # define HBA_ARQFAIL XS_DRIVER_STUFFUP
224
225 #define XS_ERR(xs) (xs)->error
226
227 #define XS_NOERR(xs) (xs)->error == XS_NOERROR
228
229 #define XS_INITERR(xs) (xs)->error = 0, XS_CMD_S_CLEAR(xs)
230
231 #define XS_SAVE_SENSE(xs, sp) \
232 if (xs->error == XS_NOERROR) { \
233 xs->error = XS_SENSE; \
234 } \
235 bcopy(sp->req_sense_data, &(xs)->sense, \
236 imin(XS_SNSLEN(xs), sp->req_sense_len))
237
238 #define XS_SET_STATE_STAT(a, b, c)
239
240 #define DEFAULT_IID(x) 7
241 #define DEFAULT_LOOPID(x) 108
242 #define DEFAULT_NODEWWN(isp) (isp)->isp_osinfo.un._wwn
243 #define DEFAULT_PORTWWN(isp) (isp)->isp_osinfo.un._wwn
244 #define ISP_NODEWWN(isp) FCPARAM(isp)->isp_nodewwn
245 #define ISP_PORTWWN(isp) FCPARAM(isp)->isp_portwwn
246
247 #if _BYTE_ORDER == _BIG_ENDIAN
248 #define ISP_SWIZZLE_REQUEST isp_swizzle_request
249 #define ISP_UNSWIZZLE_RESPONSE isp_unswizzle_response
250 #define ISP_SWIZZLE_ICB isp_swizzle_icb
251 #define ISP_UNSWIZZLE_AND_COPY_PDBP isp_unswizzle_and_copy_pdbp
252 #define ISP_SWIZZLE_SNS_REQ isp_swizzle_sns_req
253 #define ISP_UNSWIZZLE_SNS_RSP isp_unswizzle_sns_rsp
254 #define ISP_SWIZZLE_NVRAM_WORD(isp, rp) *rp = bswap16(*rp)
255 #else
256 #define ISP_SWIZZLE_REQUEST(a, b)
257 #define ISP_UNSWIZZLE_RESPONSE(a, b, c)
258 #define ISP_SWIZZLE_ICB(a, b)
259 #define ISP_UNSWIZZLE_AND_COPY_PDBP(isp, dest, src) \
260 if((void *)src != (void *)dest) bcopy(src, dest, sizeof (isp_pdb_t))
261 #define ISP_SWIZZLE_SNS_REQ(a, b)
262 #define ISP_UNSWIZZLE_SNS_RSP(a, b, c)
263 #define ISP_SWIZZLE_NVRAM_WORD(isp, rp)
264 #endif
265
266 /*
267 * Includes of common header files
268 */
269
270 #include <dev/ic/ispreg.h>
271 #include <dev/ic/ispvar.h>
272 #include <dev/ic/ispmbox.h>
273 #include <dev/ic/isp_ioctl.h>
274
275 /*
276 * isp_osinfo definitions, extensions and shorthand.
277 */
278 #define isp_name isp_osinfo._dev.dv_xname
279 #define isp_unit isp_osinfo._dev.dv_unit
280
281 /*
282 * Driver prototypes..
283 */
284 void isp_attach(struct ispsoftc *);
285 void isp_uninit(struct ispsoftc *);
286
287 static INLINE void isp_lock(struct ispsoftc *);
288 static INLINE void isp_unlock(struct ispsoftc *);
289 static INLINE char *strncat(char *, const char *, size_t);
290 static INLINE u_int64_t
291 isp_microtime_sub(struct timeval *, struct timeval *);
292 static void isp_wait_complete(struct ispsoftc *);
293 #if _BYTE_ORDER == _BIG_ENDIAN
294 static INLINE void isp_swizzle_request(struct ispsoftc *, ispreq_t *);
295 static INLINE void isp_unswizzle_response(struct ispsoftc *, void *, u_int16_t);
296 static INLINE void isp_swizzle_icb(struct ispsoftc *, isp_icb_t *);
297 static INLINE void
298 isp_unswizzle_and_copy_pdbp(struct ispsoftc *, isp_pdb_t *, void *);
299 static INLINE void isp_swizzle_sns_req(struct ispsoftc *, sns_screq_t *);
300 static INLINE void isp_unswizzle_sns_rsp(struct ispsoftc *, sns_scrsp_t *, int);
301 #endif
302
303 /*
304 * Driver wide data...
305 */
306
307 /*
308 * Locking macros...
309 */
310 #define ISP_LOCK isp_lock
311 #define ISP_UNLOCK isp_unlock
312 #define ISP_ILOCK(x) isp_lock(x); isp->isp_osinfo.onintstack++
313 #define ISP_IUNLOCK(x) isp->isp_osinfo.onintstack--; isp_unlock(x)
314
315 /*
316 * Platform private flags
317 */
318
319 #define XS_PSTS_INWDOG 0x10000000
320 #define XS_PSTS_GRACE 0x20000000
321 #define XS_PSTS_ALL 0x30000000
322
323 #define XS_CMD_S_WDOG(xs) (xs)->xs_status |= XS_PSTS_INWDOG
324 #define XS_CMD_C_WDOG(xs) (xs)->xs_status &= ~XS_PSTS_INWDOG
325 #define XS_CMD_WDOG_P(xs) (((xs)->xs_status & XS_PSTS_INWDOG) != 0)
326
327 #define XS_CMD_S_GRACE(xs) (xs)->xs_status |= XS_PSTS_GRACE
328 #define XS_CMD_C_GRACE(xs) (xs)->xs_status &= ~XS_PSTS_GRACE
329 #define XS_CMD_GRACE_P(xs) (((xs)->xs_status & XS_PSTS_GRACE) != 0)
330
331 #define XS_CMD_S_DONE(xs) (xs)->xs_status |= XS_STS_DONE
332 #define XS_CMD_C_DONE(xs) (xs)->xs_status &= ~XS_STS_DONE
333 #define XS_CMD_DONE_P(xs) (((xs)->xs_status & XS_STS_DONE) != 0)
334
335 #define XS_CMD_S_CLEAR(xs) (xs)->xs_status &= ~XS_PSTS_ALL
336
337 /*
338 * Platform specific 'inline' or support functions
339 */
340 static INLINE void
341 isp_lock(struct ispsoftc *isp)
342 {
343 int s = splbio();
344 if (isp->isp_osinfo.islocked++ == 0) {
345 isp->isp_osinfo.splsaved = s;
346 } else {
347 splx(s);
348 }
349 }
350
351 static INLINE void
352 isp_unlock(struct ispsoftc *isp)
353 {
354 if (isp->isp_osinfo.islocked-- <= 1) {
355 isp->isp_osinfo.islocked = 0;
356 splx(isp->isp_osinfo.splsaved);
357 }
358 }
359
360 static INLINE char *
361 strncat(char *d, const char *s, size_t c)
362 {
363 char *t = d;
364
365 if (c) {
366 while (*d)
367 d++;
368 while ((*d++ = *s++)) {
369 if (--c == 0) {
370 *d = '\0';
371 break;
372 }
373 }
374 }
375 return (t);
376 }
377
378 static INLINE u_int64_t
379 isp_microtime_sub(struct timeval *b, struct timeval *a)
380 {
381 struct timeval x;
382 u_int64_t elapsed;
383 timersub(b, a, &x);
384 elapsed = GET_NANOSEC(&x);
385 if (elapsed == 0)
386 elapsed++;
387 return (elapsed);
388 }
389
390 static INLINE void
391 isp_wait_complete(struct ispsoftc *isp)
392 {
393 if (isp->isp_osinfo.onintstack || isp->isp_osinfo.no_mbox_ints) {
394 int usecs = 0;
395 /*
396 * For sanity's sake, we don't delay longer
397 * than 5 seconds for polled commands.
398 */
399 while (usecs < 5 * 1000000) {
400 (void) isp_intr(isp);
401 if (isp->isp_mboxbsy == 0) {
402 break;
403 }
404 USEC_DELAY(500);
405 usecs += 500;
406 }
407 if (isp->isp_mboxbsy != 0) {
408 isp_prt(isp, ISP_LOGWARN,
409 "Polled Mailbox Command (0x%x) Timeout",
410 isp->isp_lastmbxcmd);
411 }
412 } else {
413 int rv = 0;
414 isp->isp_osinfo.mboxwaiting = 1;
415 while (isp->isp_osinfo.mboxwaiting && rv == 0) {
416 static const struct timeval dtime = { 5, 0 };
417 int timo;
418 struct timeval tv;
419 microtime(&tv);
420 timeradd(&tv, &dtime, &tv);
421 if ((timo = hzto(&tv)) == 0) {
422 timo = 1;
423 }
424 rv = tsleep(&isp->isp_osinfo.mboxwaiting,
425 PRIBIO, "isp_mboxcmd", timo);
426 }
427 if (rv == EWOULDBLOCK) {
428 isp->isp_mboxbsy = 0;
429 isp->isp_osinfo.mboxwaiting = 0;
430 isp_prt(isp, ISP_LOGWARN,
431 "Interrupting Mailbox Command (0x%x) Timeout",
432 isp->isp_lastmbxcmd);
433 }
434 }
435 }
436
437 #if _BYTE_ORDER == _BIG_ENDIAN
438 static INLINE void
439 isp_swizzle_request(struct ispsoftc *isp, ispreq_t *rq)
440 {
441 if (IS_FC(isp)) {
442 ispreqt2_t *tq = (ispreqt2_t *) rq;
443 tq->req_handle = bswap32(tq->req_handle);
444 tq->req_scclun = bswap16(tq->req_scclun);
445 tq->req_flags = bswap16(tq->req_flags);
446 tq->req_time = bswap16(tq->req_time);
447 tq->req_totalcnt = bswap32(tq->req_totalcnt);
448 } else if (isp->isp_bustype == ISP_BT_SBUS) {
449 _ISP_SWAP8(rq->req_header.rqs_entry_count,
450 rq->req_header.rqs_entry_type);
451 _ISP_SWAP8(rq->req_header.rqs_flags, rq->req_header.rqs_seqno);
452 _ISP_SWAP8(rq->req_target, rq->req_lun_trn);
453 } else {
454 rq->req_handle = bswap32(rq->req_handle);
455 rq->req_cdblen = bswap16(rq->req_cdblen);
456 rq->req_flags = bswap16(rq->req_flags);
457 rq->req_time = bswap16(rq->req_time);
458 }
459 }
460
461 static INLINE void
462 isp_unswizzle_response(struct ispsoftc *isp, void *rp, u_int16_t optr)
463 {
464 ispstatusreq_t *sp = rp;
465 MEMORYBARRIER(isp, SYNC_RESPONSE, optr * QENTRY_LEN, QENTRY_LEN);
466 if (isp->isp_bustype == ISP_BT_SBUS) {
467 _ISP_SWAP8(sp->req_header.rqs_entry_count,
468 sp->req_header.rqs_entry_type);
469 _ISP_SWAP8(sp->req_header.rqs_flags, sp->req_header.rqs_seqno);
470 } else switch (sp->req_header.rqs_entry_type) {
471 case RQSTYPE_RESPONSE:
472 sp->req_handle = bswap32(sp->req_handle);
473 sp->req_scsi_status = bswap16(sp->req_scsi_status);
474 sp->req_completion_status = bswap16(sp->req_completion_status);
475 sp->req_state_flags = bswap16(sp->req_state_flags);
476 sp->req_status_flags = bswap16(sp->req_status_flags);
477 sp->req_time = bswap16(sp->req_time);
478 sp->req_sense_len = bswap16(sp->req_sense_len);
479 sp->req_resid = bswap32(sp->req_resid);
480 break;
481 default:
482 break;
483 }
484 }
485
486 static INLINE void
487 isp_swizzle_icb(struct ispsoftc *isp, isp_icb_t *icbp)
488 {
489 _ISP_SWAP8(icbp->icb_version, icbp->_reserved0);
490 _ISP_SWAP8(icbp->icb_retry_count, icbp->icb_retry_delay);
491 _ISP_SWAP8(icbp->icb_iqdevtype, icbp->icb_logintime);
492 _ISP_SWAP8(icbp->icb_ccnt, icbp->icb_icnt);
493 _ISP_SWAP8(icbp->icb_racctimer, icbp->icb_idelaytimer);
494 icbp->icb_fwoptions = bswap16(icbp->icb_fwoptions);
495 icbp->icb_maxfrmlen = bswap16(icbp->icb_maxfrmlen);
496 icbp->icb_maxalloc = bswap16(icbp->icb_maxalloc);
497 icbp->icb_execthrottle = bswap16(icbp->icb_execthrottle);
498 icbp->icb_hardaddr = bswap16(icbp->icb_hardaddr);
499 icbp->icb_rqstout = bswap16(icbp->icb_rqstout);
500 icbp->icb_rspnsin = bswap16(icbp->icb_rspnsin);
501 icbp->icb_rqstqlen = bswap16(icbp->icb_rqstqlen);
502 icbp->icb_rsltqlen = bswap16(icbp->icb_rsltqlen);
503 icbp->icb_lunenables = bswap16(icbp->icb_lunenables);
504 icbp->icb_lunetimeout = bswap16(icbp->icb_lunetimeout);
505 icbp->icb_xfwoptions = bswap16(icbp->icb_xfwoptions);
506 icbp->icb_zfwoptions = bswap16(icbp->icb_zfwoptions);
507 icbp->icb_rqstaddr[0] = bswap16(icbp->icb_rqstaddr[0]);
508 icbp->icb_rqstaddr[1] = bswap16(icbp->icb_rqstaddr[1]);
509 icbp->icb_rqstaddr[2] = bswap16(icbp->icb_rqstaddr[2]);
510 icbp->icb_rqstaddr[3] = bswap16(icbp->icb_rqstaddr[3]);
511 icbp->icb_respaddr[0] = bswap16(icbp->icb_respaddr[0]);
512 icbp->icb_respaddr[1] = bswap16(icbp->icb_respaddr[1]);
513 icbp->icb_respaddr[2] = bswap16(icbp->icb_respaddr[2]);
514 icbp->icb_respaddr[3] = bswap16(icbp->icb_respaddr[3]);
515 }
516
517 static INLINE void
518 isp_unswizzle_and_copy_pdbp(struct ispsoftc *isp, isp_pdb_t *dst, void *src)
519 {
520 isp_pdb_t *pdbp = src;
521 dst->pdb_options = bswap16(pdbp->pdb_options);
522 dst->pdb_mstate = pdbp->pdb_sstate;
523 dst->pdb_sstate = pdbp->pdb_mstate;
524 dst->pdb_hardaddr_bits[0] = pdbp->pdb_hardaddr_bits[0];
525 dst->pdb_hardaddr_bits[1] = pdbp->pdb_hardaddr_bits[1];
526 dst->pdb_hardaddr_bits[2] = pdbp->pdb_hardaddr_bits[2];
527 dst->pdb_hardaddr_bits[3] = pdbp->pdb_hardaddr_bits[3];
528 dst->pdb_portid_bits[0] = pdbp->pdb_portid_bits[0];
529 dst->pdb_portid_bits[1] = pdbp->pdb_portid_bits[1];
530 dst->pdb_portid_bits[2] = pdbp->pdb_portid_bits[2];
531 dst->pdb_portid_bits[3] = pdbp->pdb_portid_bits[3];
532 dst->pdb_nodename[0] = pdbp->pdb_nodename[0];
533 dst->pdb_nodename[1] = pdbp->pdb_nodename[1];
534 dst->pdb_nodename[2] = pdbp->pdb_nodename[2];
535 dst->pdb_nodename[3] = pdbp->pdb_nodename[3];
536 dst->pdb_nodename[4] = pdbp->pdb_nodename[4];
537 dst->pdb_nodename[5] = pdbp->pdb_nodename[5];
538 dst->pdb_nodename[6] = pdbp->pdb_nodename[6];
539 dst->pdb_nodename[7] = pdbp->pdb_nodename[7];
540 dst->pdb_portname[0] = pdbp->pdb_portname[0];
541 dst->pdb_portname[1] = pdbp->pdb_portname[1];
542 dst->pdb_portname[2] = pdbp->pdb_portname[2];
543 dst->pdb_portname[3] = pdbp->pdb_portname[3];
544 dst->pdb_portname[4] = pdbp->pdb_portname[4];
545 dst->pdb_portname[5] = pdbp->pdb_portname[5];
546 dst->pdb_portname[6] = pdbp->pdb_portname[6];
547 dst->pdb_portname[7] = pdbp->pdb_portname[7];
548 dst->pdb_execthrottle = bswap16(pdbp->pdb_execthrottle);
549 dst->pdb_exec_count = bswap16(pdbp->pdb_exec_count);
550 dst->pdb_resalloc = bswap16(pdbp->pdb_resalloc);
551 dst->pdb_curalloc = bswap16(pdbp->pdb_curalloc);
552 dst->pdb_qhead = bswap16(pdbp->pdb_qhead);
553 dst->pdb_qtail = bswap16(pdbp->pdb_qtail);
554 dst->pdb_tl_next = bswap16(pdbp->pdb_tl_next);
555 dst->pdb_tl_last = bswap16(pdbp->pdb_tl_last);
556 dst->pdb_features = bswap16(pdbp->pdb_features);
557 dst->pdb_pconcurrnt = bswap16(pdbp->pdb_pconcurrnt);
558 dst->pdb_roi = bswap16(pdbp->pdb_roi);
559 dst->pdb_rdsiz = bswap16(pdbp->pdb_rdsiz);
560 dst->pdb_ncseq = bswap16(pdbp->pdb_ncseq);
561 dst->pdb_noseq = bswap16(pdbp->pdb_noseq);
562 dst->pdb_labrtflg = bswap16(pdbp->pdb_labrtflg);
563 dst->pdb_lstopflg = bswap16(pdbp->pdb_lstopflg);
564 dst->pdb_sqhead = bswap16(pdbp->pdb_sqhead);
565 dst->pdb_sqtail = bswap16(pdbp->pdb_sqtail);
566 dst->pdb_ptimer = bswap16(pdbp->pdb_ptimer);
567 dst->pdb_nxt_seqid = bswap16(pdbp->pdb_nxt_seqid);
568 dst->pdb_fcount = bswap16(pdbp->pdb_fcount);
569 dst->pdb_prli_len = bswap16(pdbp->pdb_prli_len);
570 dst->pdb_prli_svc0 = bswap16(pdbp->pdb_prli_svc0);
571 dst->pdb_prli_svc3 = bswap16(pdbp->pdb_prli_svc3);
572 dst->pdb_loopid = bswap16(pdbp->pdb_loopid);
573 dst->pdb_il_ptr = bswap16(pdbp->pdb_il_ptr);
574 dst->pdb_sl_ptr = bswap16(pdbp->pdb_sl_ptr);
575 dst->pdb_retry_count = pdbp->pdb_retry_delay;
576 dst->pdb_retry_delay = pdbp->pdb_retry_count;
577 dst->pdb_target = pdbp->pdb_initiator;
578 dst->pdb_initiator = pdbp->pdb_target;
579 }
580
581 static INLINE void
582 isp_swizzle_sns_req(struct ispsoftc *isp, sns_screq_t *reqp)
583 {
584 u_int16_t index, nwords = reqp->snscb_sblen;
585 reqp->snscb_rblen = bswap16(reqp->snscb_rblen);
586 reqp->snscb_addr[0] = bswap16(reqp->snscb_addr[0]);
587 reqp->snscb_addr[1] = bswap16(reqp->snscb_addr[1]);
588 reqp->snscb_addr[2] = bswap16(reqp->snscb_addr[2]);
589 reqp->snscb_addr[3] = bswap16(reqp->snscb_addr[3]);
590 reqp->snscb_sblen = bswap16(reqp->snscb_sblen);
591 for (index = 0; index < nwords; index++) {
592 reqp->snscb_data[index] = bswap16(reqp->snscb_data[index]);
593 }
594 }
595
596 static INLINE void
597 isp_unswizzle_sns_rsp(struct ispsoftc *isp, sns_scrsp_t *resp, int nwords)
598 {
599 int index;
600 /*
601 * Don't even think about asking. This. Is. So. Lame.
602 */
603 if (IS_2200(isp) &&
604 ISP_FW_REVX(isp->isp_fwrev) == ISP_FW_REV(2, 1, 26)) {
605 nwords = 128;
606 }
607 for (index = 0; index < nwords; index++) {
608 resp->snscb_data[index] = bswap16(resp->snscb_data[index]);
609 }
610 }
611 #endif
612
613 /*
614 * Common inline functions
615 */
616 #include <dev/ic/isp_inline.h>
617
618 #if !defined(ISP_DISABLE_FW) && !defined(ISP_COMPILE_FW)
619 #define ISP_COMPILE_FW 1
620 #endif
621 #endif /* _ISP_NETBSD_H */
622