isp_netbsd.h revision 1.18.2.13 1 /* $NetBSD: isp_netbsd.h,v 1.18.2.13 2001/03/27 15:52:51 bouyer 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 : 30,
99 no_mbox_ints : 1;
100 union {
101 u_int64_t _wwn;
102 u_int16_t _discovered[2];
103 #define wwn_seed un._wwn
104 #define discovered un._discovered
105 } un;
106 TAILQ_HEAD(, scsipi_xfer) waitq;
107 struct callout _restart;
108 };
109 #define ISP_MUSTPOLL(isp) \
110 (isp->isp_osinfo.onintstack || isp->isp_osinfo.no_mbox_ints)
111
112 /*
113 * Required Macros/Defines
114 */
115
116 #define INLINE inline
117
118 #define ISP2100_SCRLEN 0x400
119
120 #define MEMZERO bzero
121 #define MEMCPY(dst, src, amt) bcopy((src), (dst), (amt))
122 #define SNPRINTF snprintf
123 #define STRNCAT strncat
124 #define USEC_DELAY DELAY
125 #define USEC_SLEEP(isp, x) \
126 if (!ISP_MUSTPOLL(isp)) \
127 ISP_UNLOCK(isp); \
128 DELAY(x); \
129 if (!ISP_MUSTPOLL(isp)) \
130 ISP_LOCK(isp)
131
132 #define NANOTIME_T struct timeval
133 #define GET_NANOTIME microtime
134 #define GET_NANOSEC(x) (((x)->tv_sec * 1000000 + (x)->tv_usec) * 1000)
135 #define NANOTIME_SUB isp_microtime_sub
136
137 #define MAXISPREQUEST(isp) 256
138
139 #ifdef __alpha__
140 #define MEMORYBARRIER(isp, type, offset, size) alpha_mb()
141 #else
142 #define MEMORYBARRIER(isp, type, offset, size)
143 #endif
144
145 #define MBOX_ACQUIRE(isp)
146 #define MBOX_WAIT_COMPLETE isp_wait_complete
147
148 #define MBOX_NOTIFY_COMPLETE(isp) \
149 if (isp->isp_osinfo.mboxwaiting) { \
150 isp->isp_osinfo.mboxwaiting = 0; \
151 wakeup(&isp->isp_osinfo.mboxwaiting); \
152 } \
153 isp->isp_mboxbsy = 0
154
155 #define MBOX_RELEASE(isp)
156
157 #ifndef SCSI_GOOD
158 #define SCSI_GOOD 0x0
159 #endif
160 #ifndef SCSI_CHECK
161 #define SCSI_CHECK 0x2
162 #endif
163 #ifndef SCSI_BUSY
164 #define SCSI_BUSY 0x8
165 #endif
166 #ifndef SCSI_QFULL
167 #define SCSI_QFULL 0x28
168 #endif
169
170 #define XS_T struct scsipi_xfer
171 #define XS_CHANNEL(xs) ((int) (xs)->xs_periph->periph_channel->chan_channel)
172 #define XS_ISP(xs) \
173 ((void *)(xs)->xs_periph->periph_channel->chan_adapter->adapt_dev)
174 #define XS_LUN(xs) ((int) (xs)->xs_periph->periph_lun)
175 #define XS_TGT(xs) ((int) (xs)->xs_periph->periph_target)
176 #define XS_CDBP(xs) ((caddr_t) (xs)->cmd)
177 #define XS_CDBLEN(xs) (xs)->cmdlen
178 #define XS_XFRLEN(xs) (xs)->datalen
179 #define XS_TIME(xs) (xs)->timeout
180 #define XS_RESID(xs) (xs)->resid
181 #define XS_STSP(xs) (&(xs)->status)
182 #define XS_SNSP(xs) (&(xs)->sense.scsi_sense)
183 #define XS_SNSLEN(xs) (sizeof (xs)->sense)
184 #define XS_SNSKEY(xs) ((xs)->sense.scsi_sense.flags)
185 #define XS_TAG_P(ccb) (((xs)->xs_control & XS_CTL_POLL) != 0)
186 #define XS_TAG_TYPE(xs) \
187 (((xs)->xs_control & XS_CTL_URGENT) ? REQFLAG_HTAG : \
188 ((xs)->bp && xs->bp->b_flags & B_ASYNC) ? REQFLAG_STAG : REQFLAG_OTAG)
189
190 #define XS_SETERR(xs, v) (xs)->error = v
191
192 # define HBA_NOERROR XS_NOERROR
193 # define HBA_BOTCH XS_DRIVER_STUFFUP
194 # define HBA_CMDTIMEOUT XS_TIMEOUT
195 # define HBA_SELTIMEOUT XS_SELTIMEOUT
196 # define HBA_TGTBSY XS_BUSY
197 # define HBA_BUSRESET XS_RESET
198 # define HBA_ABORTED XS_DRIVER_STUFFUP
199 # define HBA_DATAOVR XS_DRIVER_STUFFUP
200 # define HBA_ARQFAIL XS_DRIVER_STUFFUP
201
202 #define XS_ERR(xs) (xs)->error
203
204 #define XS_NOERR(xs) (xs)->error == XS_NOERROR
205
206 #define XS_INITERR(xs) (xs)->error = 0, XS_CMD_S_CLEAR(xs)
207
208 #define XS_SAVE_SENSE(xs, sp) \
209 if (xs->error == XS_NOERROR) { \
210 xs->error = XS_SENSE; \
211 } \
212 bcopy(sp->req_sense_data, &(xs)->sense, \
213 imin(XS_SNSLEN(xs), sp->req_sense_len))
214
215 #define XS_SET_STATE_STAT(a, b, c)
216
217 #define DEFAULT_IID(x) 7
218 #define DEFAULT_LOOPID(x) 108
219 #define DEFAULT_NODEWWN(isp) (isp)->isp_osinfo.un._wwn
220 #define DEFAULT_PORTWWN(isp) (isp)->isp_osinfo.un._wwn
221 #define ISP_NODEWWN(isp) FCPARAM(isp)->isp_nodewwn
222 #define ISP_PORTWWN(isp) FCPARAM(isp)->isp_portwwn
223
224 #if _BYTE_ORDER == _BIG_ENDIAN
225 #define ISP_SWIZZLE_REQUEST isp_swizzle_request
226 #define ISP_UNSWIZZLE_RESPONSE isp_unswizzle_response
227 #define ISP_SWIZZLE_ICB isp_swizzle_icb
228 #define ISP_UNSWIZZLE_AND_COPY_PDBP isp_unswizzle_and_copy_pdbp
229 #define ISP_SWIZZLE_SNS_REQ isp_swizzle_sns_req
230 #define ISP_UNSWIZZLE_SNS_RSP isp_unswizzle_sns_rsp
231 #define ISP_SWIZZLE_NVRAM_WORD(isp, rp) *rp = bswap16(*rp)
232 #else
233 #define ISP_SWIZZLE_REQUEST(a, b)
234 #define ISP_UNSWIZZLE_RESPONSE(a, b, c)
235 #define ISP_SWIZZLE_ICB(a, b)
236 #define ISP_UNSWIZZLE_AND_COPY_PDBP(isp, dest, src) \
237 if((void *)src != (void *)dest) bcopy(src, dest, sizeof (isp_pdb_t))
238 #define ISP_SWIZZLE_SNS_REQ(a, b)
239 #define ISP_UNSWIZZLE_SNS_RSP(a, b, c)
240 #define ISP_SWIZZLE_NVRAM_WORD(isp, rp)
241 #endif
242
243 /*
244 * Includes of common header files
245 */
246
247 #include <dev/ic/ispreg.h>
248 #include <dev/ic/ispvar.h>
249 #include <dev/ic/ispmbox.h>
250
251 /*
252 * isp_osinfo definitions, extensions and shorthand.
253 */
254 #define isp_name isp_osinfo._dev.dv_xname
255 #define isp_unit isp_osinfo._dev.dv_unit
256
257 /*
258 * Driver prototypes..
259 */
260 void isp_attach(struct ispsoftc *);
261 void isp_uninit(struct ispsoftc *);
262
263 static inline void isp_lock(struct ispsoftc *);
264 static inline void isp_unlock(struct ispsoftc *);
265 static inline char *strncat(char *, const char *, size_t);
266 static inline u_int64_t
267 isp_microtime_sub(struct timeval *, struct timeval *);
268 static void isp_wait_complete(struct ispsoftc *);
269 #if _BYTE_ORDER == _BIG_ENDIAN
270 static inline void isp_swizzle_request(struct ispsoftc *, ispreq_t *);
271 static inline void isp_unswizzle_response(struct ispsoftc *, void *, u_int16_t);
272 static inline void isp_swizzle_icb(struct ispsoftc *, isp_icb_t *);
273 static inline void
274 isp_unswizzle_and_copy_pdbp(struct ispsoftc *, isp_pdb_t *, void *);
275 static inline void isp_swizzle_sns_req(struct ispsoftc *, sns_screq_t *);
276 static inline void isp_unswizzle_sns_rsp(struct ispsoftc *, sns_scrsp_t *, int);
277 #endif
278
279 /*
280 * Driver wide data...
281 */
282
283 /*
284 * Locking macros...
285 */
286 #define ISP_LOCK isp_lock
287 #define ISP_UNLOCK isp_unlock
288 #define ISP_ILOCK(x) isp_lock(x); isp->isp_osinfo.onintstack++
289 #define ISP_IUNLOCK(x) isp->isp_osinfo.onintstack--; isp_unlock(x)
290
291 /*
292 * Platform private flags
293 */
294
295 #define XS_PSTS_INWDOG 0x10000000
296 #define XS_PSTS_GRACE 0x20000000
297 #define XS_PSTS_ALL 0x30000000
298
299 #define XS_CMD_S_WDOG(xs) (xs)->xs_status |= XS_PSTS_INWDOG
300 #define XS_CMD_C_WDOG(xs) (xs)->xs_status &= ~XS_PSTS_INWDOG
301 #define XS_CMD_WDOG_P(xs) (((xs)->xs_status & XS_PSTS_INWDOG) != 0)
302
303 #define XS_CMD_S_GRACE(xs) (xs)->xs_status |= XS_PSTS_GRACE
304 #define XS_CMD_C_GRACE(xs) (xs)->xs_status &= ~XS_PSTS_GRACE
305 #define XS_CMD_GRACE_P(xs) (((xs)->xs_status & XS_PSTS_GRACE) != 0)
306
307 #define XS_CMD_S_DONE(xs) (xs)->xs_status |= XS_STS_DONE
308 #define XS_CMD_C_DONE(xs) (xs)->xs_status &= ~XS_STS_DONE
309 #define XS_CMD_DONE_P(xs) (((xs)->xs_status & XS_STS_DONE) != 0)
310
311 #define XS_CMD_S_CLEAR(xs) (xs)->xs_status &= ~XS_PSTS_ALL
312
313 /*
314 * Platform specific 'inline' or support functions
315 */
316 static inline void
317 isp_lock(struct ispsoftc *isp)
318 {
319 int s = splbio();
320 if (isp->isp_osinfo.islocked++ == 0) {
321 isp->isp_osinfo.splsaved = s;
322 } else {
323 splx(s);
324 }
325 }
326
327 static inline void
328 isp_unlock(struct ispsoftc *isp)
329 {
330 if (isp->isp_osinfo.islocked-- <= 1) {
331 isp->isp_osinfo.islocked = 0;
332 splx(isp->isp_osinfo.splsaved);
333 }
334 }
335
336 static inline char *
337 strncat(char *d, const char *s, size_t c)
338 {
339 char *t = d;
340
341 if (c) {
342 while (*d)
343 d++;
344 while ((*d++ = *s++)) {
345 if (--c == 0) {
346 *d = '\0';
347 break;
348 }
349 }
350 }
351 return (t);
352 }
353
354 static inline u_int64_t
355 isp_microtime_sub(struct timeval *b, struct timeval *a)
356 {
357 struct timeval x;
358 u_int64_t elapsed;
359 timersub(b, a, &x);
360 elapsed = GET_NANOSEC(&x);
361 if (elapsed == 0)
362 elapsed++;
363 return (elapsed);
364 }
365
366 static inline void
367 isp_wait_complete(struct ispsoftc *isp)
368 {
369 if (isp->isp_osinfo.onintstack || isp->isp_osinfo.no_mbox_ints) {
370 int usecs = 0;
371 /*
372 * For sanity's sake, we don't delay longer
373 * than 5 seconds for polled commands.
374 */
375 while (usecs < 5 * 1000000) {
376 (void) isp_intr(isp);
377 if (isp->isp_mboxbsy == 0) {
378 break;
379 }
380 USEC_DELAY(500);
381 usecs += 500;
382 }
383 if (isp->isp_mboxbsy != 0) {
384 isp_prt(isp, ISP_LOGWARN,
385 "Polled Mailbox Command (0x%x) Timeout",
386 isp->isp_lastmbxcmd);
387 }
388 } else {
389 int rv = 0;
390 isp->isp_osinfo.mboxwaiting = 1;
391 while (isp->isp_osinfo.mboxwaiting && rv == 0) {
392 static const struct timeval dtime = { 5, 0 };
393 int timo;
394 struct timeval tv;
395 microtime(&tv);
396 timeradd(&tv, &dtime, &tv);
397 if ((timo = hzto(&tv)) == 0) {
398 timo = 1;
399 }
400 rv = tsleep(&isp->isp_osinfo.mboxwaiting,
401 PRIBIO, "isp_mboxcmd", timo);
402 }
403 if (rv == EWOULDBLOCK) {
404 isp->isp_mboxbsy = 0;
405 isp->isp_osinfo.mboxwaiting = 0;
406 isp_prt(isp, ISP_LOGWARN,
407 "Interrupting Mailbox Command (0x%x) Timeout",
408 isp->isp_lastmbxcmd);
409 }
410 }
411 }
412
413 #if _BYTE_ORDER == _BIG_ENDIAN
414 static inline void
415 isp_swizzle_request(struct ispsoftc *isp, ispreq_t *rq)
416 {
417 if (IS_FC(isp)) {
418 ispreqt2_t *tq = (ispreqt2_t *) rq;
419 tq->req_handle = bswap32(tq->req_handle);
420 tq->req_scclun = bswap16(tq->req_scclun);
421 tq->req_flags = bswap16(tq->req_flags);
422 tq->req_time = bswap16(tq->req_time);
423 tq->req_totalcnt = bswap32(tq->req_totalcnt);
424 } else if (isp->isp_bustype == ISP_BT_SBUS) {
425 _ISP_SWAP8(rq->req_header.rqs_entry_count,
426 rq->req_header.rqs_entry_type);
427 _ISP_SWAP8(rq->req_header.rqs_flags, rq->req_header.rqs_seqno);
428 _ISP_SWAP8(rq->req_target, rq->req_lun_trn);
429 } else {
430 rq->req_handle = bswap32(rq->req_handle);
431 rq->req_cdblen = bswap16(rq->req_cdblen);
432 rq->req_flags = bswap16(rq->req_flags);
433 rq->req_time = bswap16(rq->req_time);
434 }
435 }
436
437 static inline void
438 isp_unswizzle_response(struct ispsoftc *isp, void *rp, u_int16_t optr)
439 {
440 ispstatusreq_t *sp = rp;
441 MEMORYBARRIER(isp, SYNC_RESPONSE, optr * QENTRY_LEN, QENTRY_LEN);
442 if (isp->isp_bustype == ISP_BT_SBUS) {
443 _ISP_SWAP8(sp->req_header.rqs_entry_count,
444 sp->req_header.rqs_entry_type);
445 _ISP_SWAP8(sp->req_header.rqs_flags, sp->req_header.rqs_seqno);
446 } else switch (sp->req_header.rqs_entry_type) {
447 case RQSTYPE_RESPONSE:
448 sp->req_handle = bswap32(sp->req_handle);
449 sp->req_scsi_status = bswap16(sp->req_scsi_status);
450 sp->req_completion_status = bswap16(sp->req_completion_status);
451 sp->req_state_flags = bswap16(sp->req_state_flags);
452 sp->req_status_flags = bswap16(sp->req_status_flags);
453 sp->req_time = bswap16(sp->req_time);
454 sp->req_sense_len = bswap16(sp->req_sense_len);
455 sp->req_resid = bswap32(sp->req_resid);
456 break;
457 default:
458 break;
459 }
460 }
461
462 static inline void
463 isp_swizzle_icb(struct ispsoftc *isp, isp_icb_t *icbp)
464 {
465 _ISP_SWAP8(icbp->icb_version, icbp->_reserved0);
466 _ISP_SWAP8(icbp->icb_retry_count, icbp->icb_retry_delay);
467 _ISP_SWAP8(icbp->icb_iqdevtype, icbp->icb_logintime);
468 _ISP_SWAP8(icbp->icb_ccnt, icbp->icb_icnt);
469 _ISP_SWAP8(icbp->icb_racctimer, icbp->icb_idelaytimer);
470 icbp->icb_fwoptions = bswap16(icbp->icb_fwoptions);
471 icbp->icb_maxfrmlen = bswap16(icbp->icb_maxfrmlen);
472 icbp->icb_maxalloc = bswap16(icbp->icb_maxalloc);
473 icbp->icb_execthrottle = bswap16(icbp->icb_execthrottle);
474 icbp->icb_hardaddr = bswap16(icbp->icb_hardaddr);
475 icbp->icb_rqstout = bswap16(icbp->icb_rqstout);
476 icbp->icb_rspnsin = bswap16(icbp->icb_rspnsin);
477 icbp->icb_rqstqlen = bswap16(icbp->icb_rqstqlen);
478 icbp->icb_rsltqlen = bswap16(icbp->icb_rsltqlen);
479 icbp->icb_lunenables = bswap16(icbp->icb_lunenables);
480 icbp->icb_lunetimeout = bswap16(icbp->icb_lunetimeout);
481 icbp->icb_xfwoptions = bswap16(icbp->icb_xfwoptions);
482 icbp->icb_zfwoptions = bswap16(icbp->icb_zfwoptions);
483 icbp->icb_rqstaddr[0] = bswap16(icbp->icb_rqstaddr[0]);
484 icbp->icb_rqstaddr[1] = bswap16(icbp->icb_rqstaddr[1]);
485 icbp->icb_rqstaddr[2] = bswap16(icbp->icb_rqstaddr[2]);
486 icbp->icb_rqstaddr[3] = bswap16(icbp->icb_rqstaddr[3]);
487 icbp->icb_respaddr[0] = bswap16(icbp->icb_respaddr[0]);
488 icbp->icb_respaddr[1] = bswap16(icbp->icb_respaddr[1]);
489 icbp->icb_respaddr[2] = bswap16(icbp->icb_respaddr[2]);
490 icbp->icb_respaddr[3] = bswap16(icbp->icb_respaddr[3]);
491 }
492
493 static inline void
494 isp_unswizzle_and_copy_pdbp(struct ispsoftc *isp, isp_pdb_t *dst, void *src)
495 {
496 isp_pdb_t *pdbp = src;
497 dst->pdb_options = bswap16(pdbp->pdb_options);
498 dst->pdb_mstate = pdbp->pdb_sstate;
499 dst->pdb_sstate = pdbp->pdb_mstate;
500 dst->pdb_hardaddr_bits[0] = pdbp->pdb_hardaddr_bits[0];
501 dst->pdb_hardaddr_bits[1] = pdbp->pdb_hardaddr_bits[1];
502 dst->pdb_hardaddr_bits[2] = pdbp->pdb_hardaddr_bits[2];
503 dst->pdb_hardaddr_bits[3] = pdbp->pdb_hardaddr_bits[3];
504 dst->pdb_portid_bits[0] = pdbp->pdb_portid_bits[0];
505 dst->pdb_portid_bits[1] = pdbp->pdb_portid_bits[1];
506 dst->pdb_portid_bits[2] = pdbp->pdb_portid_bits[2];
507 dst->pdb_portid_bits[3] = pdbp->pdb_portid_bits[3];
508 dst->pdb_nodename[0] = pdbp->pdb_nodename[0];
509 dst->pdb_nodename[1] = pdbp->pdb_nodename[1];
510 dst->pdb_nodename[2] = pdbp->pdb_nodename[2];
511 dst->pdb_nodename[3] = pdbp->pdb_nodename[3];
512 dst->pdb_nodename[4] = pdbp->pdb_nodename[4];
513 dst->pdb_nodename[5] = pdbp->pdb_nodename[5];
514 dst->pdb_nodename[6] = pdbp->pdb_nodename[6];
515 dst->pdb_nodename[7] = pdbp->pdb_nodename[7];
516 dst->pdb_portname[0] = pdbp->pdb_portname[0];
517 dst->pdb_portname[1] = pdbp->pdb_portname[1];
518 dst->pdb_portname[2] = pdbp->pdb_portname[2];
519 dst->pdb_portname[3] = pdbp->pdb_portname[3];
520 dst->pdb_portname[4] = pdbp->pdb_portname[4];
521 dst->pdb_portname[5] = pdbp->pdb_portname[5];
522 dst->pdb_portname[6] = pdbp->pdb_portname[6];
523 dst->pdb_portname[7] = pdbp->pdb_portname[7];
524 dst->pdb_execthrottle = bswap16(pdbp->pdb_execthrottle);
525 dst->pdb_exec_count = bswap16(pdbp->pdb_exec_count);
526 dst->pdb_resalloc = bswap16(pdbp->pdb_resalloc);
527 dst->pdb_curalloc = bswap16(pdbp->pdb_curalloc);
528 dst->pdb_qhead = bswap16(pdbp->pdb_qhead);
529 dst->pdb_qtail = bswap16(pdbp->pdb_qtail);
530 dst->pdb_tl_next = bswap16(pdbp->pdb_tl_next);
531 dst->pdb_tl_last = bswap16(pdbp->pdb_tl_last);
532 dst->pdb_features = bswap16(pdbp->pdb_features);
533 dst->pdb_pconcurrnt = bswap16(pdbp->pdb_pconcurrnt);
534 dst->pdb_roi = bswap16(pdbp->pdb_roi);
535 dst->pdb_rdsiz = bswap16(pdbp->pdb_rdsiz);
536 dst->pdb_ncseq = bswap16(pdbp->pdb_ncseq);
537 dst->pdb_noseq = bswap16(pdbp->pdb_noseq);
538 dst->pdb_labrtflg = bswap16(pdbp->pdb_labrtflg);
539 dst->pdb_lstopflg = bswap16(pdbp->pdb_lstopflg);
540 dst->pdb_sqhead = bswap16(pdbp->pdb_sqhead);
541 dst->pdb_sqtail = bswap16(pdbp->pdb_sqtail);
542 dst->pdb_ptimer = bswap16(pdbp->pdb_ptimer);
543 dst->pdb_nxt_seqid = bswap16(pdbp->pdb_nxt_seqid);
544 dst->pdb_fcount = bswap16(pdbp->pdb_fcount);
545 dst->pdb_prli_len = bswap16(pdbp->pdb_prli_len);
546 dst->pdb_prli_svc0 = bswap16(pdbp->pdb_prli_svc0);
547 dst->pdb_prli_svc3 = bswap16(pdbp->pdb_prli_svc3);
548 dst->pdb_loopid = bswap16(pdbp->pdb_loopid);
549 dst->pdb_il_ptr = bswap16(pdbp->pdb_il_ptr);
550 dst->pdb_sl_ptr = bswap16(pdbp->pdb_sl_ptr);
551 dst->pdb_retry_count = pdbp->pdb_retry_delay;
552 dst->pdb_retry_delay = pdbp->pdb_retry_count;
553 dst->pdb_target = pdbp->pdb_initiator;
554 dst->pdb_initiator = pdbp->pdb_target;
555 }
556
557 static inline void
558 isp_swizzle_sns_req(struct ispsoftc *isp, sns_screq_t *reqp)
559 {
560 u_int16_t index, nwords = reqp->snscb_sblen;
561 reqp->snscb_rblen = bswap16(reqp->snscb_rblen);
562 reqp->snscb_addr[0] = bswap16(reqp->snscb_addr[0]);
563 reqp->snscb_addr[1] = bswap16(reqp->snscb_addr[1]);
564 reqp->snscb_addr[2] = bswap16(reqp->snscb_addr[2]);
565 reqp->snscb_addr[3] = bswap16(reqp->snscb_addr[3]);
566 reqp->snscb_sblen = bswap16(reqp->snscb_sblen);
567 for (index = 0; index < nwords; index++) {
568 reqp->snscb_data[index] = bswap16(reqp->snscb_data[index]);
569 }
570 }
571
572 static inline void
573 isp_unswizzle_sns_rsp(struct ispsoftc *isp, sns_scrsp_t *resp, int nwords)
574 {
575 int index;
576 /*
577 * Don't even think about asking. This. Is. So. Lame.
578 */
579 if (IS_2200(isp) &&
580 ISP_FW_REVX(isp->isp_fwrev) == ISP_FW_REV(2, 1, 26)) {
581 nwords = 128;
582 }
583 for (index = 0; index < nwords; index++) {
584 resp->snscb_data[index] = bswap16(resp->snscb_data[index]);
585 }
586 }
587 #endif
588
589 /*
590 * Common inline functions
591 */
592 #define INLINE inline
593 #include <dev/ic/isp_inline.h>
594
595 #if !defined(ISP_DISABLE_FW) && !defined(ISP_COMPILE_FW)
596 #define ISP_COMPILE_FW 1
597 #endif
598 #endif /* _ISP_NETBSD_H */
599