xref: /freebsd/sys/dev/isp/isp_library.c (revision 87569f75a91f298c52a71823c04d41cf53c88889)
1 /*-
2  * Qlogic Host Adapter Internal Library Functions
3  *
4  * Copyright (c) 1999-2006 by Matthew Jacob
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice immediately at the beginning of the file, without modification,
12  *    this list of conditions, and the following disclaimer.
13  * 2. The name of the author may not be used to endorse or promote products
14  *    derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  */
29 #ifdef	__FreeBSD__
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
32 #endif
33 
34 #ifdef	__NetBSD__
35 #include <dev/ic/isp_netbsd.h>
36 #endif
37 #ifdef	__FreeBSD__
38 #include <dev/isp/isp_freebsd.h>
39 #endif
40 #ifdef	__OpenBSD__
41 #include <dev/ic/isp_openbsd.h>
42 #endif
43 #ifdef	__linux__
44 #include "isp_linux.h"
45 #endif
46 #ifdef	__svr4__
47 #include "isp_solaris.h"
48 #endif
49 
50 int
51 isp_save_xs(ispsoftc_t *isp, XS_T *xs, uint16_t *handlep)
52 {
53 	int i, j;
54 
55 	for (j = isp->isp_lasthdls, i = 0; i < (int) isp->isp_maxcmds; i++) {
56 		if (isp->isp_xflist[j] == NULL) {
57 			break;
58 		}
59 		if (++j == isp->isp_maxcmds) {
60 			j = 0;
61 		}
62 	}
63 	if (i == isp->isp_maxcmds) {
64 		return (-1);
65 	}
66 	isp->isp_xflist[j] = xs;
67 	*handlep = j+1;
68 	if (++j == isp->isp_maxcmds)
69 		j = 0;
70 	isp->isp_lasthdls = (uint16_t)j;
71 	return (0);
72 }
73 
74 XS_T *
75 isp_find_xs(ispsoftc_t *isp, uint16_t handle)
76 {
77 	if (handle < 1 || handle > (uint16_t) isp->isp_maxcmds) {
78 		return (NULL);
79 	} else {
80 		return (isp->isp_xflist[handle - 1]);
81 	}
82 }
83 
84 uint16_t
85 isp_find_handle(ispsoftc_t *isp, XS_T *xs)
86 {
87 	int i;
88 	if (xs != NULL) {
89 		for (i = 0; i < isp->isp_maxcmds; i++) {
90 			if (isp->isp_xflist[i] == xs) {
91 				return ((uint16_t) i+1);
92 			}
93 		}
94 	}
95 	return (0);
96 }
97 
98 int
99 isp_handle_index(uint16_t handle)
100 {
101 	return (handle-1);
102 }
103 
104 uint16_t
105 isp_index_handle(int index)
106 {
107 	return (index+1);
108 }
109 
110 void
111 isp_destroy_handle(ispsoftc_t *isp, uint16_t handle)
112 {
113 	if (handle > 0 && handle <= (uint16_t) isp->isp_maxcmds) {
114 		isp->isp_xflist[handle - 1] = NULL;
115 	}
116 }
117 
118 int
119 isp_getrqentry(ispsoftc_t *isp, uint16_t *iptrp,
120     uint16_t *optrp, void **resultp)
121 {
122 	volatile uint16_t iptr, optr;
123 
124 	optr = isp->isp_reqodx = READ_REQUEST_QUEUE_OUT_POINTER(isp);
125 	iptr = isp->isp_reqidx;
126 	*resultp = ISP_QUEUE_ENTRY(isp->isp_rquest, iptr);
127 	iptr = ISP_NXT_QENTRY(iptr, RQUEST_QUEUE_LEN(isp));
128 	if (iptr == optr) {
129 		return (1);
130 	}
131 	if (optrp)
132 		*optrp = optr;
133 	if (iptrp)
134 		*iptrp = iptr;
135 	return (0);
136 }
137 
138 #define	TBA	(4 * (((QENTRY_LEN >> 2) * 3) + 1) + 1)
139 void
140 isp_print_qentry(ispsoftc_t *isp, char *msg, int idx, void *arg)
141 {
142 	char buf[TBA];
143 	int amt, i, j;
144 	uint8_t *ptr = arg;
145 
146 	isp_prt(isp, ISP_LOGALL, "%s index %d=>", msg, idx);
147 	for (buf[0] = 0, amt = i = 0; i < 4; i++) {
148 		buf[0] = 0;
149 		SNPRINTF(buf, TBA, "  ");
150 		for (j = 0; j < (QENTRY_LEN >> 2); j++) {
151 			SNPRINTF(buf, TBA, "%s %02x", buf, ptr[amt++] & 0xff);
152 		}
153 		isp_prt(isp, ISP_LOGALL, buf);
154 	}
155 }
156 
157 void
158 isp_print_bytes(ispsoftc_t *isp, char *msg, int amt, void *arg)
159 {
160 	char buf[128];
161 	uint8_t *ptr = arg;
162 	int off;
163 
164 	if (msg)
165 		isp_prt(isp, ISP_LOGALL, "%s:", msg);
166 	off = 0;
167 	buf[0] = 0;
168 	while (off < amt) {
169 		int j, to;
170 		to = off;
171 		for (j = 0; j < 16; j++) {
172 			SNPRINTF(buf, 128, "%s %02x", buf, ptr[off++] & 0xff);
173 			if (off == amt)
174 				break;
175 		}
176 		isp_prt(isp, ISP_LOGALL, "0x%08x:%s", to, buf);
177 		buf[0] = 0;
178 	}
179 }
180 
181 /*
182  * Do the common path to try and ensure that link is up, we've scanned
183  * the fabric (if we're on a fabric), and that we've synchronized this
184  * all with our own database and done the appropriate logins.
185  *
186  * We repeatedly check for firmware state and loop state after each
187  * action because things may have changed while we were doing this.
188  * Any failure or change of state causes us to return a nonzero value.
189  *
190  * We honor HBA roles in that if we're not in Initiator mode, we don't
191  * attempt to sync up the database (that's for somebody else to do,
192  * if ever).
193  *
194  * We assume we enter here with any locks held.
195  */
196 
197 int
198 isp_fc_runstate(ispsoftc_t *isp, int tval)
199 {
200 	fcparam *fcp;
201 	int *tptr;
202 
203 	if (IS_SCSI(isp))
204 		return (0);
205 
206 	tptr = tval? &tval : NULL;
207 	if (isp_control(isp, ISPCTL_FCLINK_TEST, tptr) != 0) {
208 		return (-1);
209 	}
210 	fcp = FCPARAM(isp);
211 	if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate < LOOP_PDB_RCVD)
212 		return (-1);
213 	if (isp_control(isp, ISPCTL_SCAN_FABRIC, NULL) != 0) {
214 		return (-1);
215 	}
216 	if (isp_control(isp, ISPCTL_SCAN_LOOP, NULL) != 0) {
217 		return (-1);
218 	}
219 	if ((isp->isp_role & ISP_ROLE_INITIATOR) == 0) {
220 		return (0);
221 	}
222 	if (isp_control(isp, ISPCTL_PDB_SYNC, NULL) != 0) {
223 		return (-1);
224 	}
225 	if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate != LOOP_READY) {
226 		return (-1);
227 	}
228 	return (0);
229 }
230 
231 /*
232  * Functions to move stuff to a form that the QLogic RISC engine understands
233  * and functions to move stuff back to a form the processor understands.
234  *
235  * Each platform is required to provide the 8, 16 and 32 bit
236  * swizzle and unswizzle macros (ISP_IOX{PUT|GET}_{8,16,32})
237  *
238  * The assumption is that swizzling and unswizzling is mostly done 'in place'
239  * (with a few exceptions for efficiency).
240  */
241 
242 #define	ISP_IS_SBUS(isp)	\
243 	(ISP_SBUS_SUPPORTED && (isp)->isp_bustype == ISP_BT_SBUS)
244 
245 /*
246  * Swizzle/Copy Functions
247  */
248 void
249 isp_copy_out_hdr(ispsoftc_t *isp, isphdr_t *hpsrc, isphdr_t *hpdst)
250 {
251 	if (ISP_IS_SBUS(isp)) {
252 		ISP_IOXPUT_8(isp, hpsrc->rqs_entry_type,
253 		    &hpdst->rqs_entry_count);
254 		ISP_IOXPUT_8(isp, hpsrc->rqs_entry_count,
255 		    &hpdst->rqs_entry_type);
256 		ISP_IOXPUT_8(isp, hpsrc->rqs_seqno,
257 		    &hpdst->rqs_flags);
258 		ISP_IOXPUT_8(isp, hpsrc->rqs_flags,
259 		    &hpdst->rqs_seqno);
260 	} else {
261 		ISP_IOXPUT_8(isp, hpsrc->rqs_entry_type,
262 		    &hpdst->rqs_entry_type);
263 		ISP_IOXPUT_8(isp, hpsrc->rqs_entry_count,
264 		    &hpdst->rqs_entry_count);
265 		ISP_IOXPUT_8(isp, hpsrc->rqs_seqno,
266 		    &hpdst->rqs_seqno);
267 		ISP_IOXPUT_8(isp, hpsrc->rqs_flags,
268 		    &hpdst->rqs_flags);
269 	}
270 }
271 
272 void
273 isp_copy_in_hdr(ispsoftc_t *isp, isphdr_t *hpsrc, isphdr_t *hpdst)
274 {
275 	if (ISP_IS_SBUS(isp)) {
276 		ISP_IOXGET_8(isp, &hpsrc->rqs_entry_type,
277 		    hpdst->rqs_entry_count);
278 		ISP_IOXGET_8(isp, &hpsrc->rqs_entry_count,
279 		    hpdst->rqs_entry_type);
280 		ISP_IOXGET_8(isp, &hpsrc->rqs_seqno,
281 		    hpdst->rqs_flags);
282 		ISP_IOXGET_8(isp, &hpsrc->rqs_flags,
283 		    hpdst->rqs_seqno);
284 	} else {
285 		ISP_IOXGET_8(isp, &hpsrc->rqs_entry_type,
286 		    hpdst->rqs_entry_type);
287 		ISP_IOXGET_8(isp, &hpsrc->rqs_entry_count,
288 		    hpdst->rqs_entry_count);
289 		ISP_IOXGET_8(isp, &hpsrc->rqs_seqno,
290 		    hpdst->rqs_seqno);
291 		ISP_IOXGET_8(isp, &hpsrc->rqs_flags,
292 		    hpdst->rqs_flags);
293 	}
294 }
295 
296 int
297 isp_get_response_type(ispsoftc_t *isp, isphdr_t *hp)
298 {
299 	uint8_t type;
300 	if (ISP_IS_SBUS(isp)) {
301 		ISP_IOXGET_8(isp, &hp->rqs_entry_count, type);
302 	} else {
303 		ISP_IOXGET_8(isp, &hp->rqs_entry_type, type);
304 	}
305 	return ((int)type);
306 }
307 
308 void
309 isp_put_request(ispsoftc_t *isp, ispreq_t *rqsrc, ispreq_t *rqdst)
310 {
311 	int i;
312 	isp_copy_out_hdr(isp, &rqsrc->req_header, &rqdst->req_header);
313 	ISP_IOXPUT_32(isp, rqsrc->req_handle, &rqdst->req_handle);
314 	if (ISP_IS_SBUS(isp)) {
315 		ISP_IOXPUT_8(isp, rqsrc->req_lun_trn, &rqdst->req_target);
316 		ISP_IOXPUT_8(isp, rqsrc->req_target, &rqdst->req_lun_trn);
317 	} else {
318 		ISP_IOXPUT_8(isp, rqsrc->req_lun_trn, &rqdst->req_lun_trn);
319 		ISP_IOXPUT_8(isp, rqsrc->req_target, &rqdst->req_target);
320 	}
321 	ISP_IOXPUT_16(isp, rqsrc->req_cdblen, &rqdst->req_cdblen);
322 	ISP_IOXPUT_16(isp, rqsrc->req_flags, &rqdst->req_flags);
323 	ISP_IOXPUT_16(isp, rqsrc->req_time, &rqdst->req_time);
324 	ISP_IOXPUT_16(isp, rqsrc->req_seg_count, &rqdst->req_seg_count);
325 	for (i = 0; i < 12; i++) {
326 		ISP_IOXPUT_8(isp, rqsrc->req_cdb[i], &rqdst->req_cdb[i]);
327 	}
328 	for (i = 0; i < ISP_RQDSEG; i++) {
329 		ISP_IOXPUT_32(isp, rqsrc->req_dataseg[i].ds_base,
330 		    &rqdst->req_dataseg[i].ds_base);
331 		ISP_IOXPUT_32(isp, rqsrc->req_dataseg[i].ds_count,
332 		    &rqdst->req_dataseg[i].ds_count);
333 	}
334 }
335 
336 void
337 isp_put_request_t2(ispsoftc_t *isp, ispreqt2_t *tqsrc, ispreqt2_t *tqdst)
338 {
339 	int i;
340 	isp_copy_out_hdr(isp, &tqsrc->req_header, &tqdst->req_header);
341 	ISP_IOXPUT_32(isp, tqsrc->req_handle, &tqdst->req_handle);
342 	ISP_IOXPUT_8(isp, tqsrc->req_lun_trn, &tqdst->req_lun_trn);
343 	ISP_IOXPUT_8(isp, tqsrc->req_target, &tqdst->req_target);
344 	ISP_IOXPUT_16(isp, tqsrc->req_scclun, &tqdst->req_scclun);
345 	ISP_IOXPUT_16(isp, tqsrc->req_flags,  &tqdst->req_flags);
346 	ISP_IOXPUT_16(isp, tqsrc->_res2, &tqdst->_res2);
347 	ISP_IOXPUT_16(isp, tqsrc->req_time, &tqdst->req_time);
348 	ISP_IOXPUT_16(isp, tqsrc->req_seg_count, &tqdst->req_seg_count);
349 	for (i = 0; i < 16; i++) {
350 		ISP_IOXPUT_8(isp, tqsrc->req_cdb[i], &tqdst->req_cdb[i]);
351 	}
352 	ISP_IOXPUT_32(isp, tqsrc->req_totalcnt, &tqdst->req_totalcnt);
353 	for (i = 0; i < ISP_RQDSEG_T2; i++) {
354 		ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_base,
355 		    &tqdst->req_dataseg[i].ds_base);
356 		ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_count,
357 		    &tqdst->req_dataseg[i].ds_count);
358 	}
359 }
360 
361 void
362 isp_put_request_t2e(ispsoftc_t *isp, ispreqt2e_t *tqsrc, ispreqt2e_t *tqdst)
363 {
364 	int i;
365 	isp_copy_out_hdr(isp, &tqsrc->req_header, &tqdst->req_header);
366 	ISP_IOXPUT_32(isp, tqsrc->req_handle, &tqdst->req_handle);
367 	ISP_IOXPUT_16(isp, tqsrc->req_target, &tqdst->req_target);
368 	ISP_IOXPUT_16(isp, tqsrc->req_scclun, &tqdst->req_scclun);
369 	ISP_IOXPUT_16(isp, tqsrc->req_flags,  &tqdst->req_flags);
370 	ISP_IOXPUT_16(isp, tqsrc->_res2, &tqdst->_res2);
371 	ISP_IOXPUT_16(isp, tqsrc->req_time, &tqdst->req_time);
372 	ISP_IOXPUT_16(isp, tqsrc->req_seg_count, &tqdst->req_seg_count);
373 	for (i = 0; i < 16; i++) {
374 		ISP_IOXPUT_8(isp, tqsrc->req_cdb[i], &tqdst->req_cdb[i]);
375 	}
376 	ISP_IOXPUT_32(isp, tqsrc->req_totalcnt, &tqdst->req_totalcnt);
377 	for (i = 0; i < ISP_RQDSEG_T2; i++) {
378 		ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_base,
379 		    &tqdst->req_dataseg[i].ds_base);
380 		ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_count,
381 		    &tqdst->req_dataseg[i].ds_count);
382 	}
383 }
384 
385 void
386 isp_put_request_t3(ispsoftc_t *isp, ispreqt3_t *tqsrc, ispreqt3_t *tqdst)
387 {
388 	int i;
389 	isp_copy_out_hdr(isp, &tqsrc->req_header, &tqdst->req_header);
390 	ISP_IOXPUT_32(isp, tqsrc->req_handle, &tqdst->req_handle);
391 	ISP_IOXPUT_8(isp, tqsrc->req_lun_trn, &tqdst->req_lun_trn);
392 	ISP_IOXPUT_8(isp, tqsrc->req_target, &tqdst->req_target);
393 	ISP_IOXPUT_16(isp, tqsrc->req_scclun, &tqdst->req_scclun);
394 	ISP_IOXPUT_16(isp, tqsrc->req_flags,  &tqdst->req_flags);
395 	ISP_IOXPUT_16(isp, tqsrc->_res2, &tqdst->_res2);
396 	ISP_IOXPUT_16(isp, tqsrc->req_time, &tqdst->req_time);
397 	ISP_IOXPUT_16(isp, tqsrc->req_seg_count, &tqdst->req_seg_count);
398 	for (i = 0; i < 16; i++) {
399 		ISP_IOXPUT_8(isp, tqsrc->req_cdb[i], &tqdst->req_cdb[i]);
400 	}
401 	ISP_IOXPUT_32(isp, tqsrc->req_totalcnt, &tqdst->req_totalcnt);
402 	for (i = 0; i < ISP_RQDSEG_T3; i++) {
403 		ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_base,
404 		    &tqdst->req_dataseg[i].ds_base);
405 		ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_basehi,
406 		    &tqdst->req_dataseg[i].ds_basehi);
407 		ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_count,
408 		    &tqdst->req_dataseg[i].ds_count);
409 	}
410 }
411 
412 void
413 isp_put_request_t3e(ispsoftc_t *isp, ispreqt3e_t *tqsrc, ispreqt3e_t *tqdst)
414 {
415 	int i;
416 	isp_copy_out_hdr(isp, &tqsrc->req_header, &tqdst->req_header);
417 	ISP_IOXPUT_32(isp, tqsrc->req_handle, &tqdst->req_handle);
418 	ISP_IOXPUT_16(isp, tqsrc->req_target, &tqdst->req_target);
419 	ISP_IOXPUT_16(isp, tqsrc->req_scclun, &tqdst->req_scclun);
420 	ISP_IOXPUT_16(isp, tqsrc->req_flags,  &tqdst->req_flags);
421 	ISP_IOXPUT_16(isp, tqsrc->_res2, &tqdst->_res2);
422 	ISP_IOXPUT_16(isp, tqsrc->req_time, &tqdst->req_time);
423 	ISP_IOXPUT_16(isp, tqsrc->req_seg_count, &tqdst->req_seg_count);
424 	for (i = 0; i < 16; i++) {
425 		ISP_IOXPUT_8(isp, tqsrc->req_cdb[i], &tqdst->req_cdb[i]);
426 	}
427 	ISP_IOXPUT_32(isp, tqsrc->req_totalcnt, &tqdst->req_totalcnt);
428 	for (i = 0; i < ISP_RQDSEG_T3; i++) {
429 		ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_base,
430 		    &tqdst->req_dataseg[i].ds_base);
431 		ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_basehi,
432 		    &tqdst->req_dataseg[i].ds_basehi);
433 		ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_count,
434 		    &tqdst->req_dataseg[i].ds_count);
435 	}
436 }
437 
438 void
439 isp_put_extended_request(ispsoftc_t *isp, ispextreq_t *xqsrc,
440     ispextreq_t *xqdst)
441 {
442 	int i;
443 	isp_copy_out_hdr(isp, &xqsrc->req_header, &xqdst->req_header);
444 	ISP_IOXPUT_32(isp, xqsrc->req_handle, &xqdst->req_handle);
445 	if (ISP_IS_SBUS(isp)) {
446 		ISP_IOXPUT_8(isp, xqsrc->req_lun_trn, &xqdst->req_target);
447 		ISP_IOXPUT_8(isp, xqsrc->req_target, &xqdst->req_lun_trn);
448 	} else {
449 		ISP_IOXPUT_8(isp, xqsrc->req_lun_trn, &xqdst->req_lun_trn);
450 		ISP_IOXPUT_8(isp, xqsrc->req_target, &xqdst->req_target);
451 	}
452 	ISP_IOXPUT_16(isp, xqsrc->req_cdblen, &xqdst->req_cdblen);
453 	ISP_IOXPUT_16(isp, xqsrc->req_flags, &xqdst->req_flags);
454 	ISP_IOXPUT_16(isp, xqsrc->req_time, &xqdst->req_time);
455 	ISP_IOXPUT_16(isp, xqsrc->req_seg_count, &xqdst->req_seg_count);
456 	for (i = 0; i < 44; i++) {
457 		ISP_IOXPUT_8(isp, xqsrc->req_cdb[i], &xqdst->req_cdb[i]);
458 	}
459 }
460 
461 void
462 isp_put_cont_req(ispsoftc_t *isp, ispcontreq_t *cqsrc, ispcontreq_t *cqdst)
463 {
464 	int i;
465 	isp_copy_out_hdr(isp, &cqsrc->req_header, &cqdst->req_header);
466 	for (i = 0; i < ISP_CDSEG; i++) {
467 		ISP_IOXPUT_32(isp, cqsrc->req_dataseg[i].ds_base,
468 		    &cqdst->req_dataseg[i].ds_base);
469 		ISP_IOXPUT_32(isp, cqsrc->req_dataseg[i].ds_count,
470 		    &cqdst->req_dataseg[i].ds_count);
471 	}
472 }
473 
474 void
475 isp_put_cont64_req(ispsoftc_t *isp, ispcontreq64_t *cqsrc,
476     ispcontreq64_t *cqdst)
477 {
478 	int i;
479 	isp_copy_out_hdr(isp, &cqsrc->req_header, &cqdst->req_header);
480 	for (i = 0; i < ISP_CDSEG64; i++) {
481 		ISP_IOXPUT_32(isp, cqsrc->req_dataseg[i].ds_base,
482 		    &cqdst->req_dataseg[i].ds_base);
483 		ISP_IOXPUT_32(isp, cqsrc->req_dataseg[i].ds_basehi,
484 		    &cqdst->req_dataseg[i].ds_basehi);
485 		ISP_IOXPUT_32(isp, cqsrc->req_dataseg[i].ds_count,
486 		    &cqdst->req_dataseg[i].ds_count);
487 	}
488 }
489 
490 void
491 isp_get_response(ispsoftc_t *isp, ispstatusreq_t *spsrc,
492     ispstatusreq_t *spdst)
493 {
494 	int i;
495 	isp_copy_in_hdr(isp, &spsrc->req_header, &spdst->req_header);
496 	ISP_IOXGET_32(isp, &spsrc->req_handle, spdst->req_handle);
497 	ISP_IOXGET_16(isp, &spsrc->req_scsi_status, spdst->req_scsi_status);
498 	ISP_IOXGET_16(isp, &spsrc->req_completion_status,
499 	    spdst->req_completion_status);
500 	ISP_IOXGET_16(isp, &spsrc->req_state_flags, spdst->req_state_flags);
501 	ISP_IOXGET_16(isp, &spsrc->req_status_flags, spdst->req_status_flags);
502 	ISP_IOXGET_16(isp, &spsrc->req_time, spdst->req_time);
503 	ISP_IOXGET_16(isp, &spsrc->req_sense_len, spdst->req_sense_len);
504 	ISP_IOXGET_32(isp, &spsrc->req_resid, spdst->req_resid);
505 	for (i = 0; i < 8; i++) {
506 		ISP_IOXGET_8(isp, &spsrc->req_response[i],
507 		    spdst->req_response[i]);
508 	}
509 	for (i = 0; i < 32; i++) {
510 		ISP_IOXGET_8(isp, &spsrc->req_sense_data[i],
511 		    spdst->req_sense_data[i]);
512 	}
513 }
514 
515 void
516 isp_get_response_x(ispsoftc_t *isp, ispstatus_cont_t *cpsrc,
517     ispstatus_cont_t *cpdst)
518 {
519 	int i;
520 	isp_copy_in_hdr(isp, &cpsrc->req_header, &cpdst->req_header);
521 	for (i = 0; i < 60; i++) {
522 		ISP_IOXGET_8(isp, &cpsrc->req_sense_data[i],
523 		    cpdst->req_sense_data[i]);
524 	}
525 }
526 
527 void
528 isp_get_rio2(ispsoftc_t *isp, isp_rio2_t *r2src, isp_rio2_t *r2dst)
529 {
530 	int i;
531 	isp_copy_in_hdr(isp, &r2src->req_header, &r2dst->req_header);
532 	if (r2dst->req_header.rqs_seqno > 30)
533 		r2dst->req_header.rqs_seqno = 30;
534 	for (i = 0; i < r2dst->req_header.rqs_seqno; i++) {
535 		ISP_IOXGET_16(isp, &r2src->req_handles[i],
536 		    r2dst->req_handles[i]);
537 	}
538 	while (i < 30) {
539 		r2dst->req_handles[i++] = 0;
540 	}
541 }
542 
543 void
544 isp_put_icb(ispsoftc_t *isp, isp_icb_t *Is, isp_icb_t *Id)
545 {
546 	int i;
547 	if (ISP_IS_SBUS(isp)) {
548 		ISP_IOXPUT_8(isp, Is->icb_version, &Id->_reserved0);
549 		ISP_IOXPUT_8(isp, Is->_reserved0, &Id->icb_version);
550 	} else {
551 		ISP_IOXPUT_8(isp, Is->icb_version, &Id->icb_version);
552 		ISP_IOXPUT_8(isp, Is->_reserved0, &Id->_reserved0);
553 	}
554 	ISP_IOXPUT_16(isp, Is->icb_fwoptions, &Id->icb_fwoptions);
555 	ISP_IOXPUT_16(isp, Is->icb_maxfrmlen, &Id->icb_maxfrmlen);
556 	ISP_IOXPUT_16(isp, Is->icb_maxalloc, &Id->icb_maxalloc);
557 	ISP_IOXPUT_16(isp, Is->icb_execthrottle, &Id->icb_execthrottle);
558 	if (ISP_IS_SBUS(isp)) {
559 		ISP_IOXPUT_8(isp, Is->icb_retry_count, &Id->icb_retry_delay);
560 		ISP_IOXPUT_8(isp, Is->icb_retry_delay, &Id->icb_retry_count);
561 	} else {
562 		ISP_IOXPUT_8(isp, Is->icb_retry_count, &Id->icb_retry_count);
563 		ISP_IOXPUT_8(isp, Is->icb_retry_delay, &Id->icb_retry_delay);
564 	}
565 	for (i = 0; i < 8; i++) {
566 		ISP_IOXPUT_8(isp, Is->icb_portname[i], &Id->icb_portname[i]);
567 	}
568 	ISP_IOXPUT_16(isp, Is->icb_hardaddr, &Id->icb_hardaddr);
569 	if (ISP_IS_SBUS(isp)) {
570 		ISP_IOXPUT_8(isp, Is->icb_iqdevtype, &Id->icb_logintime);
571 		ISP_IOXPUT_8(isp, Is->icb_logintime, &Id->icb_iqdevtype);
572 	} else {
573 		ISP_IOXPUT_8(isp, Is->icb_iqdevtype, &Id->icb_iqdevtype);
574 		ISP_IOXPUT_8(isp, Is->icb_logintime, &Id->icb_logintime);
575 	}
576 	for (i = 0; i < 8; i++) {
577 		ISP_IOXPUT_8(isp, Is->icb_nodename[i], &Id->icb_nodename[i]);
578 	}
579 	ISP_IOXPUT_16(isp, Is->icb_rqstout, &Id->icb_rqstout);
580 	ISP_IOXPUT_16(isp, Is->icb_rspnsin, &Id->icb_rspnsin);
581 	ISP_IOXPUT_16(isp, Is->icb_rqstqlen, &Id->icb_rqstqlen);
582 	ISP_IOXPUT_16(isp, Is->icb_rsltqlen, &Id->icb_rsltqlen);
583 	for (i = 0; i < 4; i++) {
584 		ISP_IOXPUT_16(isp, Is->icb_rqstaddr[i], &Id->icb_rqstaddr[i]);
585 	}
586 	for (i = 0; i < 4; i++) {
587 		ISP_IOXPUT_16(isp, Is->icb_respaddr[i], &Id->icb_respaddr[i]);
588 	}
589 	ISP_IOXPUT_16(isp, Is->icb_lunenables, &Id->icb_lunenables);
590 	if (ISP_IS_SBUS(isp)) {
591 		ISP_IOXPUT_8(isp, Is->icb_ccnt, &Id->icb_icnt);
592 		ISP_IOXPUT_8(isp, Is->icb_icnt, &Id->icb_ccnt);
593 	} else {
594 		ISP_IOXPUT_8(isp, Is->icb_ccnt, &Id->icb_ccnt);
595 		ISP_IOXPUT_8(isp, Is->icb_icnt, &Id->icb_icnt);
596 	}
597 	ISP_IOXPUT_16(isp, Is->icb_lunetimeout, &Id->icb_lunetimeout);
598 	ISP_IOXPUT_16(isp, Is->icb_xfwoptions, &Id->icb_xfwoptions);
599 	if (ISP_IS_SBUS(isp)) {
600 		ISP_IOXPUT_8(isp, Is->icb_racctimer, &Id->icb_idelaytimer);
601 		ISP_IOXPUT_8(isp, Is->icb_idelaytimer, &Id->icb_racctimer);
602 	} else {
603 		ISP_IOXPUT_8(isp, Is->icb_racctimer, &Id->icb_racctimer);
604 		ISP_IOXPUT_8(isp, Is->icb_idelaytimer, &Id->icb_idelaytimer);
605 	}
606 	ISP_IOXPUT_16(isp, Is->icb_zfwoptions, &Id->icb_zfwoptions);
607 }
608 
609 void
610 isp_get_pdb(ispsoftc_t *isp, isp_pdb_t *src, isp_pdb_t *dst)
611 {
612 	int i;
613 	ISP_IOXGET_16(isp, &src->pdb_options, dst->pdb_options);
614         ISP_IOXGET_8(isp, &src->pdb_mstate, dst->pdb_mstate);
615         ISP_IOXGET_8(isp, &src->pdb_sstate, dst->pdb_sstate);
616 	for (i = 0; i < 4; i++) {
617 		ISP_IOXGET_8(isp, &src->pdb_hardaddr_bits[i],
618 		    dst->pdb_hardaddr_bits[i]);
619 	}
620 	for (i = 0; i < 4; i++) {
621 		ISP_IOXGET_8(isp, &src->pdb_portid_bits[i],
622 		    dst->pdb_portid_bits[i]);
623 	}
624 	for (i = 0; i < 8; i++) {
625 		ISP_IOXGET_8(isp, &src->pdb_nodename[i], dst->pdb_nodename[i]);
626 	}
627 	for (i = 0; i < 8; i++) {
628 		ISP_IOXGET_8(isp, &src->pdb_portname[i], dst->pdb_portname[i]);
629 	}
630 	ISP_IOXGET_16(isp, &src->pdb_execthrottle, dst->pdb_execthrottle);
631 	ISP_IOXGET_16(isp, &src->pdb_exec_count, dst->pdb_exec_count);
632 	ISP_IOXGET_8(isp, &src->pdb_retry_count, dst->pdb_retry_count);
633 	ISP_IOXGET_8(isp, &src->pdb_retry_delay, dst->pdb_retry_delay);
634 	ISP_IOXGET_16(isp, &src->pdb_resalloc, dst->pdb_resalloc);
635 	ISP_IOXGET_16(isp, &src->pdb_curalloc, dst->pdb_curalloc);
636 	ISP_IOXGET_16(isp, &src->pdb_qhead, dst->pdb_qhead);
637 	ISP_IOXGET_16(isp, &src->pdb_qtail, dst->pdb_qtail);
638 	ISP_IOXGET_16(isp, &src->pdb_tl_next, dst->pdb_tl_next);
639 	ISP_IOXGET_16(isp, &src->pdb_tl_last, dst->pdb_tl_last);
640 	ISP_IOXGET_16(isp, &src->pdb_features, dst->pdb_features);
641 	ISP_IOXGET_16(isp, &src->pdb_pconcurrnt, dst->pdb_pconcurrnt);
642 	ISP_IOXGET_16(isp, &src->pdb_roi, dst->pdb_roi);
643 	ISP_IOXGET_8(isp, &src->pdb_target, dst->pdb_target);
644 	ISP_IOXGET_8(isp, &src->pdb_initiator, dst->pdb_initiator);
645 	ISP_IOXGET_16(isp, &src->pdb_rdsiz, dst->pdb_rdsiz);
646 	ISP_IOXGET_16(isp, &src->pdb_ncseq, dst->pdb_ncseq);
647 	ISP_IOXGET_16(isp, &src->pdb_noseq, dst->pdb_noseq);
648 	ISP_IOXGET_16(isp, &src->pdb_labrtflg, dst->pdb_labrtflg);
649 	ISP_IOXGET_16(isp, &src->pdb_lstopflg, dst->pdb_lstopflg);
650 	ISP_IOXGET_16(isp, &src->pdb_sqhead, dst->pdb_sqhead);
651 	ISP_IOXGET_16(isp, &src->pdb_sqtail, dst->pdb_sqtail);
652 	ISP_IOXGET_16(isp, &src->pdb_ptimer, dst->pdb_ptimer);
653 	ISP_IOXGET_16(isp, &src->pdb_nxt_seqid, dst->pdb_nxt_seqid);
654 	ISP_IOXGET_16(isp, &src->pdb_fcount, dst->pdb_fcount);
655 	ISP_IOXGET_16(isp, &src->pdb_prli_len, dst->pdb_prli_len);
656 	ISP_IOXGET_16(isp, &src->pdb_prli_svc0, dst->pdb_prli_svc0);
657 	ISP_IOXGET_16(isp, &src->pdb_prli_svc3, dst->pdb_prli_svc3);
658 	ISP_IOXGET_16(isp, &src->pdb_loopid, dst->pdb_loopid);
659 	ISP_IOXGET_16(isp, &src->pdb_il_ptr, dst->pdb_il_ptr);
660 	ISP_IOXGET_16(isp, &src->pdb_sl_ptr, dst->pdb_sl_ptr);
661 }
662 
663 
664 /*
665  * CT_HDR canonicalization- only needed for SNS responses
666  */
667 void
668 isp_get_ct_hdr(ispsoftc_t *isp, ct_hdr_t *src, ct_hdr_t *dst)
669 {
670 	ISP_IOXGET_8(isp, &src->ct_revision, dst->ct_revision);
671 	ISP_IOXGET_8(isp, &src->ct_portid[0], dst->ct_portid[0]);
672 	ISP_IOXGET_8(isp, &src->ct_portid[1], dst->ct_portid[1]);
673 	ISP_IOXGET_8(isp, &src->ct_portid[2], dst->ct_portid[2]);
674 	ISP_IOXGET_8(isp, &src->ct_fcs_type, dst->ct_fcs_type);
675 	ISP_IOXGET_8(isp, &src->ct_fcs_subtype, dst->ct_fcs_subtype);
676 	ISP_IOXGET_8(isp, &src->ct_options, dst->ct_options);
677 	ISP_IOXGET_8(isp, &src->ct_res0, dst->ct_res0);
678 	ISP_IOXGET_16(isp, &src->ct_response, dst->ct_response);
679 	dst->ct_response = (dst->ct_response << 8) | (dst->ct_response >> 8);
680 	ISP_IOXGET_16(isp, &src->ct_resid, dst->ct_resid);
681 	dst->ct_resid = (dst->ct_resid << 8) | (dst->ct_resid >> 8);
682 	ISP_IOXGET_8(isp, &src->ct_res1, dst->ct_res1);
683 	ISP_IOXGET_8(isp, &src->ct_reason, dst->ct_reason);
684 	ISP_IOXGET_8(isp, &src->ct_explanation, dst->ct_explanation);
685 	ISP_IOXGET_8(isp, &src->ct_vunique, dst->ct_vunique);
686 }
687 
688 /*
689  * Generic SNS request - not particularly useful since the per-command data
690  * isn't always 16 bit words.
691  */
692 void
693 isp_put_sns_request(ispsoftc_t *isp, sns_screq_t *src, sns_screq_t *dst)
694 {
695 	int i, nw = (int) src->snscb_sblen;
696 	ISP_IOXPUT_16(isp, src->snscb_rblen, &dst->snscb_rblen);
697 	for (i = 0; i < 4; i++) {
698 		ISP_IOXPUT_16(isp, src->snscb_addr[i], &dst->snscb_addr[i]);
699 	}
700 	ISP_IOXPUT_16(isp, src->snscb_sblen, &dst->snscb_sblen);
701 	for (i = 0; i < nw; i++) {
702 		ISP_IOXPUT_16(isp, src->snscb_data[i], &dst->snscb_data[i]);
703 	}
704 
705 }
706 
707 void
708 isp_put_gid_ft_request(ispsoftc_t *isp, sns_gid_ft_req_t *src,
709     sns_gid_ft_req_t *dst)
710 {
711 	ISP_IOXPUT_16(isp, src->snscb_rblen, &dst->snscb_rblen);
712 	ISP_IOXPUT_16(isp, src->snscb_res0, &dst->snscb_res0);
713 	ISP_IOXPUT_16(isp, src->snscb_addr[0], &dst->snscb_addr[0]);
714 	ISP_IOXPUT_16(isp, src->snscb_addr[1], &dst->snscb_addr[1]);
715 	ISP_IOXPUT_16(isp, src->snscb_addr[2], &dst->snscb_addr[2]);
716 	ISP_IOXPUT_16(isp, src->snscb_addr[3], &dst->snscb_addr[3]);
717 	ISP_IOXPUT_16(isp, src->snscb_sblen, &dst->snscb_sblen);
718 	ISP_IOXPUT_16(isp, src->snscb_res1, &dst->snscb_res1);
719 	ISP_IOXPUT_16(isp, src->snscb_cmd, &dst->snscb_cmd);
720 	ISP_IOXPUT_16(isp, src->snscb_mword_div_2, &dst->snscb_mword_div_2);
721 	ISP_IOXPUT_32(isp, src->snscb_res3, &dst->snscb_res3);
722 	ISP_IOXPUT_32(isp, src->snscb_fc4_type, &dst->snscb_fc4_type);
723 }
724 
725 void
726 isp_put_gxn_id_request(ispsoftc_t *isp, sns_gxn_id_req_t *src,
727     sns_gxn_id_req_t *dst)
728 {
729 	ISP_IOXPUT_16(isp, src->snscb_rblen, &dst->snscb_rblen);
730 	ISP_IOXPUT_16(isp, src->snscb_res0, &dst->snscb_res0);
731 	ISP_IOXPUT_16(isp, src->snscb_addr[0], &dst->snscb_addr[0]);
732 	ISP_IOXPUT_16(isp, src->snscb_addr[1], &dst->snscb_addr[1]);
733 	ISP_IOXPUT_16(isp, src->snscb_addr[2], &dst->snscb_addr[2]);
734 	ISP_IOXPUT_16(isp, src->snscb_addr[3], &dst->snscb_addr[3]);
735 	ISP_IOXPUT_16(isp, src->snscb_sblen, &dst->snscb_sblen);
736 	ISP_IOXPUT_16(isp, src->snscb_res1, &dst->snscb_res1);
737 	ISP_IOXPUT_16(isp, src->snscb_cmd, &dst->snscb_cmd);
738 	ISP_IOXPUT_16(isp, src->snscb_res2, &dst->snscb_res2);
739 	ISP_IOXPUT_32(isp, src->snscb_res3, &dst->snscb_res3);
740 	ISP_IOXPUT_32(isp, src->snscb_portid, &dst->snscb_portid);
741 }
742 
743 /*
744  * Generic SNS response - not particularly useful since the per-command data
745  * isn't always 16 bit words.
746  */
747 void
748 isp_get_sns_response(ispsoftc_t *isp, sns_scrsp_t *src,
749     sns_scrsp_t *dst, int nwords)
750 {
751 	int i;
752 	isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
753 	ISP_IOXGET_8(isp, &src->snscb_port_type, dst->snscb_port_type);
754 	for (i = 0; i < 3; i++) {
755 		ISP_IOXGET_8(isp, &src->snscb_port_id[i],
756 		    dst->snscb_port_id[i]);
757 	}
758 	for (i = 0; i < 8; i++) {
759 		ISP_IOXGET_8(isp, &src->snscb_portname[i],
760 		    dst->snscb_portname[i]);
761 	}
762 	for (i = 0; i < nwords; i++) {
763 		ISP_IOXGET_16(isp, &src->snscb_data[i], dst->snscb_data[i]);
764 	}
765 }
766 
767 void
768 isp_get_gid_ft_response(ispsoftc_t *isp, sns_gid_ft_rsp_t *src,
769     sns_gid_ft_rsp_t *dst, int nwords)
770 {
771 	int i;
772 	isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
773 	for (i = 0; i < nwords; i++) {
774 		int j;
775 		ISP_IOXGET_8(isp,
776 		    &src->snscb_ports[i].control,
777 		    dst->snscb_ports[i].control);
778 		for (j = 0; j < 3; j++) {
779 			ISP_IOXGET_8(isp,
780 			    &src->snscb_ports[i].portid[j],
781 			    dst->snscb_ports[i].portid[j]);
782 		}
783 		if (dst->snscb_ports[i].control & 0x80) {
784 			break;
785 		}
786 	}
787 }
788 
789 void
790 isp_get_gxn_id_response(ispsoftc_t *isp, sns_gxn_id_rsp_t *src,
791     sns_gxn_id_rsp_t *dst)
792 {
793 	int i;
794 	isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
795 	for (i = 0; i < 8; i++)
796 		ISP_IOXGET_8(isp, &src->snscb_wwn[i], dst->snscb_wwn[i]);
797 }
798 
799 void
800 isp_get_gff_id_response(ispsoftc_t *isp, sns_gff_id_rsp_t *src,
801     sns_gff_id_rsp_t *dst)
802 {
803 	int i;
804 	isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
805 	for (i = 0; i < 32; i++) {
806 		ISP_IOXGET_32(isp, &src->snscb_fc4_features[i],
807 		    dst->snscb_fc4_features[i]);
808 	}
809 }
810 
811 void
812 isp_get_ga_nxt_response(ispsoftc_t *isp, sns_ga_nxt_rsp_t *src,
813     sns_ga_nxt_rsp_t *dst)
814 {
815 	int i;
816 	isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
817 	ISP_IOXGET_8(isp, &src->snscb_port_type, dst->snscb_port_type);
818 	for (i = 0; i < 3; i++) {
819 		ISP_IOXGET_8(isp, &src->snscb_port_id[i],
820 		    dst->snscb_port_id[i]);
821 	}
822 	for (i = 0; i < 8; i++) {
823 		ISP_IOXGET_8(isp, &src->snscb_portname[i],
824 		    dst->snscb_portname[i]);
825 	}
826 	ISP_IOXGET_8(isp, &src->snscb_pnlen, dst->snscb_pnlen);
827 	for (i = 0; i < 255; i++) {
828 		ISP_IOXGET_8(isp, &src->snscb_pname[i], dst->snscb_pname[i]);
829 	}
830 	for (i = 0; i < 8; i++) {
831 		ISP_IOXGET_8(isp, &src->snscb_nodename[i],
832 		    dst->snscb_nodename[i]);
833 	}
834 	ISP_IOXGET_8(isp, &src->snscb_nnlen, dst->snscb_nnlen);
835 	for (i = 0; i < 255; i++) {
836 		ISP_IOXGET_8(isp, &src->snscb_nname[i], dst->snscb_nname[i]);
837 	}
838 	for (i = 0; i < 8; i++) {
839 		ISP_IOXGET_8(isp, &src->snscb_ipassoc[i],
840 		    dst->snscb_ipassoc[i]);
841 	}
842 	for (i = 0; i < 16; i++) {
843 		ISP_IOXGET_8(isp, &src->snscb_ipaddr[i], dst->snscb_ipaddr[i]);
844 	}
845 	for (i = 0; i < 4; i++) {
846 		ISP_IOXGET_8(isp, &src->snscb_svc_class[i],
847 		    dst->snscb_svc_class[i]);
848 	}
849 	for (i = 0; i < 32; i++) {
850 		ISP_IOXGET_8(isp, &src->snscb_fc4_types[i],
851 		    dst->snscb_fc4_types[i]);
852 	}
853 	for (i = 0; i < 8; i++) {
854 		ISP_IOXGET_8(isp, &src->snscb_fpname[i], dst->snscb_fpname[i]);
855 	}
856 	ISP_IOXGET_8(isp, &src->snscb_reserved, dst->snscb_reserved);
857 	for (i = 0; i < 3; i++) {
858 		ISP_IOXGET_8(isp, &src->snscb_hardaddr[i],
859 		    dst->snscb_hardaddr[i]);
860 	}
861 }
862 
863 #ifdef	ISP_TARGET_MODE
864 
865 int
866 isp_save_xs_tgt(ispsoftc_t *isp, void *xs, uint16_t *handlep)
867 {
868 	int i;
869 
870 	for (i = 0; i < (int) isp->isp_maxcmds; i++) {
871 		if (isp->isp_tgtlist[i] == NULL) {
872 			break;
873 		}
874 	}
875 	if (i == isp->isp_maxcmds) {
876 		return (-1);
877 	}
878 	isp->isp_tgtlist[i] = xs;
879 	*handlep = i+1;
880 	return (0);
881 }
882 
883 void *
884 isp_find_xs_tgt(ispsoftc_t *isp, uint16_t handle)
885 {
886 	if (handle < 1 || handle > (uint16_t) isp->isp_maxcmds) {
887 		return (NULL);
888 	} else {
889 		return (isp->isp_tgtlist[handle - 1]);
890 	}
891 }
892 
893 uint16_t
894 isp_find_tgt_handle(ispsoftc_t *isp, void *xs)
895 {
896 	int i;
897 	if (xs != NULL) {
898 		for (i = 0; i < isp->isp_maxcmds; i++) {
899 			if (isp->isp_tgtlist[i] == xs) {
900 				return ((uint16_t) i+1);
901 			}
902 		}
903 	}
904 	return (0);
905 }
906 
907 void
908 isp_destroy_tgt_handle(ispsoftc_t *isp, uint16_t handle)
909 {
910 	if (handle > 0 && handle <= (uint16_t) isp->isp_maxcmds) {
911 		isp->isp_tgtlist[handle - 1] = NULL;
912 	}
913 }
914 void
915 isp_put_atio(ispsoftc_t *isp, at_entry_t *atsrc, at_entry_t *atdst)
916 {
917 	int i;
918 	isp_copy_out_hdr(isp, &atsrc->at_header, &atdst->at_header);
919 	ISP_IOXPUT_16(isp, atsrc->at_reserved, &atdst->at_reserved);
920 	ISP_IOXPUT_16(isp, atsrc->at_handle, &atdst->at_handle);
921 	if (ISP_IS_SBUS(isp)) {
922 		ISP_IOXPUT_8(isp, atsrc->at_lun, &atdst->at_iid);
923 		ISP_IOXPUT_8(isp, atsrc->at_iid, &atdst->at_lun);
924 		ISP_IOXPUT_8(isp, atsrc->at_cdblen, &atdst->at_tgt);
925 		ISP_IOXPUT_8(isp, atsrc->at_tgt, &atdst->at_cdblen);
926 		ISP_IOXPUT_8(isp, atsrc->at_status, &atdst->at_scsi_status);
927 		ISP_IOXPUT_8(isp, atsrc->at_scsi_status, &atdst->at_status);
928 		ISP_IOXPUT_8(isp, atsrc->at_tag_val, &atdst->at_tag_type);
929 		ISP_IOXPUT_8(isp, atsrc->at_tag_type, &atdst->at_tag_val);
930 	} else {
931 		ISP_IOXPUT_8(isp, atsrc->at_lun, &atdst->at_lun);
932 		ISP_IOXPUT_8(isp, atsrc->at_iid, &atdst->at_iid);
933 		ISP_IOXPUT_8(isp, atsrc->at_cdblen, &atdst->at_cdblen);
934 		ISP_IOXPUT_8(isp, atsrc->at_tgt, &atdst->at_tgt);
935 		ISP_IOXPUT_8(isp, atsrc->at_status, &atdst->at_status);
936 		ISP_IOXPUT_8(isp, atsrc->at_scsi_status,
937 		    &atdst->at_scsi_status);
938 		ISP_IOXPUT_8(isp, atsrc->at_tag_val, &atdst->at_tag_val);
939 		ISP_IOXPUT_8(isp, atsrc->at_tag_type, &atdst->at_tag_type);
940 	}
941 	ISP_IOXPUT_32(isp, atsrc->at_flags, &atdst->at_flags);
942 	for (i = 0; i < ATIO_CDBLEN; i++) {
943 		ISP_IOXPUT_8(isp, atsrc->at_cdb[i], &atdst->at_cdb[i]);
944 	}
945 	for (i = 0; i < QLTM_SENSELEN; i++) {
946 		ISP_IOXPUT_8(isp, atsrc->at_sense[i], &atdst->at_sense[i]);
947 	}
948 }
949 
950 void
951 isp_get_atio(ispsoftc_t *isp, at_entry_t *atsrc, at_entry_t *atdst)
952 {
953 	int i;
954 	isp_copy_in_hdr(isp, &atsrc->at_header, &atdst->at_header);
955 	ISP_IOXGET_16(isp, &atsrc->at_reserved, atdst->at_reserved);
956 	ISP_IOXGET_16(isp, &atsrc->at_handle, atdst->at_handle);
957 	if (ISP_IS_SBUS(isp)) {
958 		ISP_IOXGET_8(isp, &atsrc->at_lun, atdst->at_iid);
959 		ISP_IOXGET_8(isp, &atsrc->at_iid, atdst->at_lun);
960 		ISP_IOXGET_8(isp, &atsrc->at_cdblen, atdst->at_tgt);
961 		ISP_IOXGET_8(isp, &atsrc->at_tgt, atdst->at_cdblen);
962 		ISP_IOXGET_8(isp, &atsrc->at_status, atdst->at_scsi_status);
963 		ISP_IOXGET_8(isp, &atsrc->at_scsi_status, atdst->at_status);
964 		ISP_IOXGET_8(isp, &atsrc->at_tag_val, atdst->at_tag_type);
965 		ISP_IOXGET_8(isp, &atsrc->at_tag_type, atdst->at_tag_val);
966 	} else {
967 		ISP_IOXGET_8(isp, &atsrc->at_lun, atdst->at_lun);
968 		ISP_IOXGET_8(isp, &atsrc->at_iid, atdst->at_iid);
969 		ISP_IOXGET_8(isp, &atsrc->at_cdblen, atdst->at_cdblen);
970 		ISP_IOXGET_8(isp, &atsrc->at_tgt, atdst->at_tgt);
971 		ISP_IOXGET_8(isp, &atsrc->at_status, atdst->at_status);
972 		ISP_IOXGET_8(isp, &atsrc->at_scsi_status,
973 		    atdst->at_scsi_status);
974 		ISP_IOXGET_8(isp, &atsrc->at_tag_val, atdst->at_tag_val);
975 		ISP_IOXGET_8(isp, &atsrc->at_tag_type, atdst->at_tag_type);
976 	}
977 	ISP_IOXGET_32(isp, &atsrc->at_flags, atdst->at_flags);
978 	for (i = 0; i < ATIO_CDBLEN; i++) {
979 		ISP_IOXGET_8(isp, &atsrc->at_cdb[i], atdst->at_cdb[i]);
980 	}
981 	for (i = 0; i < QLTM_SENSELEN; i++) {
982 		ISP_IOXGET_8(isp, &atsrc->at_sense[i], atdst->at_sense[i]);
983 	}
984 }
985 
986 void
987 isp_put_atio2(ispsoftc_t *isp, at2_entry_t *atsrc, at2_entry_t *atdst)
988 {
989 	int i;
990 	isp_copy_out_hdr(isp, &atsrc->at_header, &atdst->at_header);
991 	ISP_IOXPUT_32(isp, atsrc->at_reserved, &atdst->at_reserved);
992 	ISP_IOXPUT_8(isp, atsrc->at_lun, &atdst->at_lun);
993 	ISP_IOXPUT_8(isp, atsrc->at_iid, &atdst->at_iid);
994 	ISP_IOXPUT_16(isp, atsrc->at_rxid, &atdst->at_rxid);
995 	ISP_IOXPUT_16(isp, atsrc->at_flags, &atdst->at_flags);
996 	ISP_IOXPUT_16(isp, atsrc->at_status, &atdst->at_status);
997 	ISP_IOXPUT_8(isp, atsrc->at_crn, &atdst->at_crn);
998 	ISP_IOXPUT_8(isp, atsrc->at_taskcodes, &atdst->at_taskcodes);
999 	ISP_IOXPUT_8(isp, atsrc->at_taskflags, &atdst->at_taskflags);
1000 	ISP_IOXPUT_8(isp, atsrc->at_execodes, &atdst->at_execodes);
1001 	for (i = 0; i < ATIO2_CDBLEN; i++) {
1002 		ISP_IOXPUT_8(isp, atsrc->at_cdb[i], &atdst->at_cdb[i]);
1003 	}
1004 	ISP_IOXPUT_32(isp, atsrc->at_datalen, &atdst->at_datalen);
1005 	ISP_IOXPUT_16(isp, atsrc->at_scclun, &atdst->at_scclun);
1006 	for (i = 0; i < 4; i++) {
1007 		ISP_IOXPUT_16(isp, atsrc->at_wwpn[i], &atdst->at_wwpn[i]);
1008 	}
1009 	for (i = 0; i < 6; i++) {
1010 		ISP_IOXPUT_16(isp, atsrc->at_reserved2[i],
1011 		    &atdst->at_reserved2[i]);
1012 	}
1013 	ISP_IOXPUT_16(isp, atsrc->at_oxid, &atdst->at_oxid);
1014 }
1015 
1016 void
1017 isp_put_atio2e(ispsoftc_t *isp, at2e_entry_t *atsrc, at2e_entry_t *atdst)
1018 {
1019 	int i;
1020 	isp_copy_out_hdr(isp, &atsrc->at_header, &atdst->at_header);
1021 	ISP_IOXPUT_32(isp, atsrc->at_reserved, &atdst->at_reserved);
1022 	ISP_IOXPUT_16(isp, atsrc->at_iid, &atdst->at_iid);
1023 	ISP_IOXPUT_16(isp, atsrc->at_rxid, &atdst->at_rxid);
1024 	ISP_IOXPUT_16(isp, atsrc->at_flags, &atdst->at_flags);
1025 	ISP_IOXPUT_16(isp, atsrc->at_status, &atdst->at_status);
1026 	ISP_IOXPUT_8(isp, atsrc->at_crn, &atdst->at_crn);
1027 	ISP_IOXPUT_8(isp, atsrc->at_taskcodes, &atdst->at_taskcodes);
1028 	ISP_IOXPUT_8(isp, atsrc->at_taskflags, &atdst->at_taskflags);
1029 	ISP_IOXPUT_8(isp, atsrc->at_execodes, &atdst->at_execodes);
1030 	for (i = 0; i < ATIO2_CDBLEN; i++) {
1031 		ISP_IOXPUT_8(isp, atsrc->at_cdb[i], &atdst->at_cdb[i]);
1032 	}
1033 	ISP_IOXPUT_32(isp, atsrc->at_datalen, &atdst->at_datalen);
1034 	ISP_IOXPUT_16(isp, atsrc->at_scclun, &atdst->at_scclun);
1035 	for (i = 0; i < 4; i++) {
1036 		ISP_IOXPUT_16(isp, atsrc->at_wwpn[i], &atdst->at_wwpn[i]);
1037 	}
1038 	for (i = 0; i < 6; i++) {
1039 		ISP_IOXPUT_16(isp, atsrc->at_reserved2[i],
1040 		    &atdst->at_reserved2[i]);
1041 	}
1042 	ISP_IOXPUT_16(isp, atsrc->at_oxid, &atdst->at_oxid);
1043 }
1044 
1045 void
1046 isp_get_atio2(ispsoftc_t *isp, at2_entry_t *atsrc, at2_entry_t *atdst)
1047 {
1048 	int i;
1049 	isp_copy_in_hdr(isp, &atsrc->at_header, &atdst->at_header);
1050 	ISP_IOXGET_32(isp, &atsrc->at_reserved, atdst->at_reserved);
1051 	ISP_IOXGET_8(isp, &atsrc->at_lun, atdst->at_lun);
1052 	ISP_IOXGET_8(isp, &atsrc->at_iid, atdst->at_iid);
1053 	ISP_IOXGET_16(isp, &atsrc->at_rxid, atdst->at_rxid);
1054 	ISP_IOXGET_16(isp, &atsrc->at_flags, atdst->at_flags);
1055 	ISP_IOXGET_16(isp, &atsrc->at_status, atdst->at_status);
1056 	ISP_IOXGET_8(isp, &atsrc->at_crn, atdst->at_crn);
1057 	ISP_IOXGET_8(isp, &atsrc->at_taskcodes, atdst->at_taskcodes);
1058 	ISP_IOXGET_8(isp, &atsrc->at_taskflags, atdst->at_taskflags);
1059 	ISP_IOXGET_8(isp, &atsrc->at_execodes, atdst->at_execodes);
1060 	for (i = 0; i < ATIO2_CDBLEN; i++) {
1061 		ISP_IOXGET_8(isp, &atsrc->at_cdb[i], atdst->at_cdb[i]);
1062 	}
1063 	ISP_IOXGET_32(isp, &atsrc->at_datalen, atdst->at_datalen);
1064 	ISP_IOXGET_16(isp, &atsrc->at_scclun, atdst->at_scclun);
1065 	for (i = 0; i < 4; i++) {
1066 		ISP_IOXGET_16(isp, &atsrc->at_wwpn[i], atdst->at_wwpn[i]);
1067 	}
1068 	for (i = 0; i < 6; i++) {
1069 		ISP_IOXGET_16(isp, &atsrc->at_reserved2[i],
1070 		    atdst->at_reserved2[i]);
1071 	}
1072 	ISP_IOXGET_16(isp, &atsrc->at_oxid, atdst->at_oxid);
1073 }
1074 
1075 void
1076 isp_get_atio2e(ispsoftc_t *isp, at2e_entry_t *atsrc, at2e_entry_t *atdst)
1077 {
1078 	int i;
1079 	isp_copy_in_hdr(isp, &atsrc->at_header, &atdst->at_header);
1080 	ISP_IOXGET_32(isp, &atsrc->at_reserved, atdst->at_reserved);
1081 	ISP_IOXGET_16(isp, &atsrc->at_iid, atdst->at_iid);
1082 	ISP_IOXGET_16(isp, &atsrc->at_rxid, atdst->at_rxid);
1083 	ISP_IOXGET_16(isp, &atsrc->at_flags, atdst->at_flags);
1084 	ISP_IOXGET_16(isp, &atsrc->at_status, atdst->at_status);
1085 	ISP_IOXGET_8(isp, &atsrc->at_crn, atdst->at_crn);
1086 	ISP_IOXGET_8(isp, &atsrc->at_taskcodes, atdst->at_taskcodes);
1087 	ISP_IOXGET_8(isp, &atsrc->at_taskflags, atdst->at_taskflags);
1088 	ISP_IOXGET_8(isp, &atsrc->at_execodes, atdst->at_execodes);
1089 	for (i = 0; i < ATIO2_CDBLEN; i++) {
1090 		ISP_IOXGET_8(isp, &atsrc->at_cdb[i], atdst->at_cdb[i]);
1091 	}
1092 	ISP_IOXGET_32(isp, &atsrc->at_datalen, atdst->at_datalen);
1093 	ISP_IOXGET_16(isp, &atsrc->at_scclun, atdst->at_scclun);
1094 	for (i = 0; i < 4; i++) {
1095 		ISP_IOXGET_16(isp, &atsrc->at_wwpn[i], atdst->at_wwpn[i]);
1096 	}
1097 	for (i = 0; i < 6; i++) {
1098 		ISP_IOXGET_16(isp, &atsrc->at_reserved2[i],
1099 		    atdst->at_reserved2[i]);
1100 	}
1101 	ISP_IOXGET_16(isp, &atsrc->at_oxid, atdst->at_oxid);
1102 }
1103 
1104 void
1105 isp_put_ctio(ispsoftc_t *isp, ct_entry_t *ctsrc, ct_entry_t *ctdst)
1106 {
1107 	int i;
1108 	isp_copy_out_hdr(isp, &ctsrc->ct_header, &ctdst->ct_header);
1109 	ISP_IOXPUT_16(isp, ctsrc->ct_reserved, &ctdst->ct_reserved);
1110 	ISP_IOXPUT_16(isp, ctsrc->ct_fwhandle, &ctdst->ct_fwhandle);
1111 	if (ISP_IS_SBUS(isp)) {
1112 		ISP_IOXPUT_8(isp, ctsrc->ct_iid, &ctdst->ct_lun);
1113 		ISP_IOXPUT_8(isp, ctsrc->ct_lun, &ctdst->ct_iid);
1114 		ISP_IOXPUT_8(isp, ctsrc->ct_tgt, &ctdst->ct_reserved2);
1115 		ISP_IOXPUT_8(isp, ctsrc->ct_reserved2, &ctdst->ct_tgt);
1116 		ISP_IOXPUT_8(isp, ctsrc->ct_status, &ctdst->ct_scsi_status);
1117 		ISP_IOXPUT_8(isp, ctsrc->ct_scsi_status, &ctdst->ct_status);
1118 		ISP_IOXPUT_8(isp, ctsrc->ct_tag_type, &ctdst->ct_tag_val);
1119 		ISP_IOXPUT_8(isp, ctsrc->ct_tag_val, &ctdst->ct_tag_type);
1120 	} else {
1121 		ISP_IOXPUT_8(isp, ctsrc->ct_iid, &ctdst->ct_iid);
1122 		ISP_IOXPUT_8(isp, ctsrc->ct_lun, &ctdst->ct_lun);
1123 		ISP_IOXPUT_8(isp, ctsrc->ct_tgt, &ctdst->ct_tgt);
1124 		ISP_IOXPUT_8(isp, ctsrc->ct_reserved2, &ctdst->ct_reserved2);
1125 		ISP_IOXPUT_8(isp, ctsrc->ct_scsi_status,
1126 		    &ctdst->ct_scsi_status);
1127 		ISP_IOXPUT_8(isp, ctsrc->ct_status, &ctdst->ct_status);
1128 		ISP_IOXPUT_8(isp, ctsrc->ct_tag_type, &ctdst->ct_tag_type);
1129 		ISP_IOXPUT_8(isp, ctsrc->ct_tag_val, &ctdst->ct_tag_val);
1130 	}
1131 	ISP_IOXPUT_32(isp, ctsrc->ct_flags, &ctdst->ct_flags);
1132 	ISP_IOXPUT_32(isp, ctsrc->ct_xfrlen, &ctdst->ct_xfrlen);
1133 	ISP_IOXPUT_32(isp, ctsrc->ct_resid, &ctdst->ct_resid);
1134 	ISP_IOXPUT_16(isp, ctsrc->ct_timeout, &ctdst->ct_timeout);
1135 	ISP_IOXPUT_16(isp, ctsrc->ct_seg_count, &ctdst->ct_seg_count);
1136 	for (i = 0; i < ISP_RQDSEG; i++) {
1137 		ISP_IOXPUT_32(isp, ctsrc->ct_dataseg[i].ds_base,
1138 		    &ctdst->ct_dataseg[i].ds_base);
1139 		ISP_IOXPUT_32(isp, ctsrc->ct_dataseg[i].ds_count,
1140 		    &ctdst->ct_dataseg[i].ds_count);
1141 	}
1142 }
1143 
1144 void
1145 isp_get_ctio(ispsoftc_t *isp, ct_entry_t *ctsrc, ct_entry_t *ctdst)
1146 {
1147 	int i;
1148 	isp_copy_in_hdr(isp, &ctsrc->ct_header, &ctdst->ct_header);
1149 	ISP_IOXGET_16(isp, &ctsrc->ct_reserved, ctdst->ct_reserved);
1150 	ISP_IOXGET_16(isp, &ctsrc->ct_fwhandle, ctdst->ct_fwhandle);
1151 	if (ISP_IS_SBUS(isp)) {
1152 		ISP_IOXGET_8(isp, &ctsrc->ct_lun, ctdst->ct_iid);
1153 		ISP_IOXGET_8(isp, &ctsrc->ct_iid, ctdst->ct_lun);
1154 		ISP_IOXGET_8(isp, &ctsrc->ct_reserved2, ctdst->ct_tgt);
1155 		ISP_IOXGET_8(isp, &ctsrc->ct_tgt, ctdst->ct_reserved2);
1156 		ISP_IOXGET_8(isp, &ctsrc->ct_status, ctdst->ct_scsi_status);
1157 		ISP_IOXGET_8(isp, &ctsrc->ct_scsi_status, ctdst->ct_status);
1158 		ISP_IOXGET_8(isp, &ctsrc->ct_tag_val, ctdst->ct_tag_type);
1159 		ISP_IOXGET_8(isp, &ctsrc->ct_tag_type, ctdst->ct_tag_val);
1160 	} else {
1161 		ISP_IOXGET_8(isp, &ctsrc->ct_lun, ctdst->ct_lun);
1162 		ISP_IOXGET_8(isp, &ctsrc->ct_iid, ctdst->ct_iid);
1163 		ISP_IOXGET_8(isp, &ctsrc->ct_reserved2, ctdst->ct_reserved2);
1164 		ISP_IOXGET_8(isp, &ctsrc->ct_tgt, ctdst->ct_tgt);
1165 		ISP_IOXGET_8(isp, &ctsrc->ct_status, ctdst->ct_status);
1166 		ISP_IOXGET_8(isp, &ctsrc->ct_scsi_status,
1167 		    ctdst->ct_scsi_status);
1168 		ISP_IOXGET_8(isp, &ctsrc->ct_tag_val, ctdst->ct_tag_val);
1169 		ISP_IOXGET_8(isp, &ctsrc->ct_tag_type, ctdst->ct_tag_type);
1170 	}
1171 	ISP_IOXGET_32(isp, &ctsrc->ct_flags, ctdst->ct_flags);
1172 	ISP_IOXGET_32(isp, &ctsrc->ct_xfrlen, ctdst->ct_xfrlen);
1173 	ISP_IOXGET_32(isp, &ctsrc->ct_resid, ctdst->ct_resid);
1174 	ISP_IOXGET_16(isp, &ctsrc->ct_timeout, ctdst->ct_timeout);
1175 	ISP_IOXGET_16(isp, &ctsrc->ct_seg_count, ctdst->ct_seg_count);
1176 	for (i = 0; i < ISP_RQDSEG; i++) {
1177 		ISP_IOXGET_32(isp,
1178 		    &ctsrc->ct_dataseg[i].ds_base,
1179 		    ctdst->ct_dataseg[i].ds_base);
1180 		ISP_IOXGET_32(isp,
1181 		    &ctsrc->ct_dataseg[i].ds_count,
1182 		    ctdst->ct_dataseg[i].ds_count);
1183 	}
1184 }
1185 
1186 void
1187 isp_put_ctio2(ispsoftc_t *isp, ct2_entry_t *ctsrc, ct2_entry_t *ctdst)
1188 {
1189 	int i;
1190 	isp_copy_out_hdr(isp, &ctsrc->ct_header, &ctdst->ct_header);
1191 	ISP_IOXPUT_16(isp, ctsrc->ct_reserved, &ctdst->ct_reserved);
1192 	ISP_IOXPUT_16(isp, ctsrc->ct_fwhandle, &ctdst->ct_fwhandle);
1193 	ISP_IOXPUT_8(isp, ctsrc->ct_lun, &ctdst->ct_lun);
1194 	ISP_IOXPUT_8(isp, ctsrc->ct_iid, &ctdst->ct_iid);
1195 	ISP_IOXPUT_16(isp, ctsrc->ct_rxid, &ctdst->ct_rxid);
1196 	ISP_IOXPUT_16(isp, ctsrc->ct_flags, &ctdst->ct_flags);
1197 	ISP_IOXPUT_16(isp, ctsrc->ct_timeout, &ctdst->ct_timeout);
1198 	ISP_IOXPUT_16(isp, ctsrc->ct_seg_count, &ctdst->ct_seg_count);
1199 	ISP_IOXPUT_32(isp, ctsrc->ct_resid, &ctdst->ct_resid);
1200 	ISP_IOXPUT_32(isp, ctsrc->ct_reloff, &ctdst->ct_reloff);
1201 	if ((ctsrc->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE0) {
1202 		ISP_IOXPUT_32(isp, ctsrc->rsp.m0._reserved,
1203 		    &ctdst->rsp.m0._reserved);
1204 		ISP_IOXPUT_16(isp, ctsrc->rsp.m0._reserved2,
1205 		    &ctdst->rsp.m0._reserved2);
1206 		ISP_IOXPUT_16(isp, ctsrc->rsp.m0.ct_scsi_status,
1207 		    &ctdst->rsp.m0.ct_scsi_status);
1208 		ISP_IOXPUT_32(isp, ctsrc->rsp.m0.ct_xfrlen,
1209 		    &ctdst->rsp.m0.ct_xfrlen);
1210 		if (ctsrc->ct_header.rqs_entry_type == RQSTYPE_CTIO2) {
1211 			for (i = 0; i < ISP_RQDSEG_T2; i++) {
1212 				ISP_IOXPUT_32(isp,
1213 				    ctsrc->rsp.m0.ct_dataseg[i].ds_base,
1214 				    &ctdst->rsp.m0.ct_dataseg[i].ds_base);
1215 				ISP_IOXPUT_32(isp,
1216 				    ctsrc->rsp.m0.ct_dataseg[i].ds_count,
1217 				    &ctdst->rsp.m0.ct_dataseg[i].ds_count);
1218 			}
1219 		} else if (ctsrc->ct_header.rqs_entry_type == RQSTYPE_CTIO3) {
1220 			for (i = 0; i < ISP_RQDSEG_T3; i++) {
1221 				ISP_IOXPUT_32(isp,
1222 				    ctsrc->rsp.m0.ct_dataseg64[i].ds_base,
1223 				    &ctdst->rsp.m0.ct_dataseg64[i].ds_base);
1224 				ISP_IOXPUT_32(isp,
1225 				    ctsrc->rsp.m0.ct_dataseg64[i].ds_basehi,
1226 				    &ctdst->rsp.m0.ct_dataseg64[i].ds_basehi);
1227 				ISP_IOXPUT_32(isp,
1228 				    ctsrc->rsp.m0.ct_dataseg64[i].ds_count,
1229 				    &ctdst->rsp.m0.ct_dataseg64[i].ds_count);
1230 			}
1231 		} else if (ctsrc->ct_header.rqs_entry_type == RQSTYPE_CTIO4) {
1232 			ISP_IOXPUT_16(isp, ctsrc->rsp.m0.ct_dslist.ds_type,
1233 			    &ctdst->rsp.m0.ct_dslist.ds_type);
1234 			ISP_IOXPUT_32(isp, ctsrc->rsp.m0.ct_dslist.ds_segment,
1235 			    &ctdst->rsp.m0.ct_dslist.ds_segment);
1236 			ISP_IOXPUT_32(isp, ctsrc->rsp.m0.ct_dslist.ds_base,
1237 			    &ctdst->rsp.m0.ct_dslist.ds_base);
1238 		}
1239 	} else if ((ctsrc->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE1) {
1240 		ISP_IOXPUT_16(isp, ctsrc->rsp.m1._reserved,
1241 		    &ctdst->rsp.m1._reserved);
1242 		ISP_IOXPUT_16(isp, ctsrc->rsp.m1._reserved2,
1243 		    &ctdst->rsp.m1._reserved2);
1244 		ISP_IOXPUT_16(isp, ctsrc->rsp.m1.ct_senselen,
1245 		    &ctdst->rsp.m1.ct_senselen);
1246 		ISP_IOXPUT_16(isp, ctsrc->rsp.m1.ct_scsi_status,
1247 		    &ctdst->rsp.m1.ct_scsi_status);
1248 		ISP_IOXPUT_16(isp, ctsrc->rsp.m1.ct_resplen,
1249 		    &ctdst->rsp.m1.ct_resplen);
1250 		for (i = 0; i < MAXRESPLEN; i++) {
1251 			ISP_IOXPUT_8(isp, ctsrc->rsp.m1.ct_resp[i],
1252 			    &ctdst->rsp.m1.ct_resp[i]);
1253 		}
1254 	} else {
1255 		ISP_IOXPUT_32(isp, ctsrc->rsp.m2._reserved,
1256 		    &ctdst->rsp.m2._reserved);
1257 		ISP_IOXPUT_16(isp, ctsrc->rsp.m2._reserved2,
1258 		    &ctdst->rsp.m2._reserved2);
1259 		ISP_IOXPUT_16(isp, ctsrc->rsp.m2._reserved3,
1260 		    &ctdst->rsp.m2._reserved3);
1261 		ISP_IOXPUT_32(isp, ctsrc->rsp.m2.ct_datalen,
1262 		    &ctdst->rsp.m2.ct_datalen);
1263 		ISP_IOXPUT_32(isp, ctsrc->rsp.m2.ct_fcp_rsp_iudata.ds_base,
1264 		    &ctdst->rsp.m2.ct_fcp_rsp_iudata.ds_base);
1265 		ISP_IOXPUT_32(isp, ctsrc->rsp.m2.ct_fcp_rsp_iudata.ds_count,
1266 		    &ctdst->rsp.m2.ct_fcp_rsp_iudata.ds_count);
1267 	}
1268 }
1269 
1270 void
1271 isp_put_ctio2e(ispsoftc_t *isp, ct2e_entry_t *ctsrc, ct2e_entry_t *ctdst)
1272 {
1273 	int i;
1274 	isp_copy_out_hdr(isp, &ctsrc->ct_header, &ctdst->ct_header);
1275 	ISP_IOXPUT_16(isp, ctsrc->ct_reserved, &ctdst->ct_reserved);
1276 	ISP_IOXPUT_16(isp, ctsrc->ct_fwhandle, &ctdst->ct_fwhandle);
1277 	ISP_IOXPUT_16(isp, ctsrc->ct_iid, &ctdst->ct_iid);
1278 	ISP_IOXPUT_16(isp, ctsrc->ct_rxid, &ctdst->ct_rxid);
1279 	ISP_IOXPUT_16(isp, ctsrc->ct_flags, &ctdst->ct_flags);
1280 	ISP_IOXPUT_16(isp, ctsrc->ct_timeout, &ctdst->ct_timeout);
1281 	ISP_IOXPUT_16(isp, ctsrc->ct_seg_count, &ctdst->ct_seg_count);
1282 	ISP_IOXPUT_32(isp, ctsrc->ct_resid, &ctdst->ct_resid);
1283 	ISP_IOXPUT_32(isp, ctsrc->ct_reloff, &ctdst->ct_reloff);
1284 	if ((ctsrc->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE0) {
1285 		ISP_IOXPUT_32(isp, ctsrc->rsp.m0._reserved,
1286 		    &ctdst->rsp.m0._reserved);
1287 		ISP_IOXPUT_16(isp, ctsrc->rsp.m0._reserved2,
1288 		    &ctdst->rsp.m0._reserved2);
1289 		ISP_IOXPUT_16(isp, ctsrc->rsp.m0.ct_scsi_status,
1290 		    &ctdst->rsp.m0.ct_scsi_status);
1291 		ISP_IOXPUT_32(isp, ctsrc->rsp.m0.ct_xfrlen,
1292 		    &ctdst->rsp.m0.ct_xfrlen);
1293 		if (ctsrc->ct_header.rqs_entry_type == RQSTYPE_CTIO2) {
1294 			for (i = 0; i < ISP_RQDSEG_T2; i++) {
1295 				ISP_IOXPUT_32(isp,
1296 				    ctsrc->rsp.m0.ct_dataseg[i].ds_base,
1297 				    &ctdst->rsp.m0.ct_dataseg[i].ds_base);
1298 				ISP_IOXPUT_32(isp,
1299 				    ctsrc->rsp.m0.ct_dataseg[i].ds_count,
1300 				    &ctdst->rsp.m0.ct_dataseg[i].ds_count);
1301 			}
1302 		} else if (ctsrc->ct_header.rqs_entry_type == RQSTYPE_CTIO3) {
1303 			for (i = 0; i < ISP_RQDSEG_T3; i++) {
1304 				ISP_IOXPUT_32(isp,
1305 				    ctsrc->rsp.m0.ct_dataseg64[i].ds_base,
1306 				    &ctdst->rsp.m0.ct_dataseg64[i].ds_base);
1307 				ISP_IOXPUT_32(isp,
1308 				    ctsrc->rsp.m0.ct_dataseg64[i].ds_basehi,
1309 				    &ctdst->rsp.m0.ct_dataseg64[i].ds_basehi);
1310 				ISP_IOXPUT_32(isp,
1311 				    ctsrc->rsp.m0.ct_dataseg64[i].ds_count,
1312 				    &ctdst->rsp.m0.ct_dataseg64[i].ds_count);
1313 			}
1314 		} else if (ctsrc->ct_header.rqs_entry_type == RQSTYPE_CTIO4) {
1315 			ISP_IOXPUT_16(isp, ctsrc->rsp.m0.ct_dslist.ds_type,
1316 			    &ctdst->rsp.m0.ct_dslist.ds_type);
1317 			ISP_IOXPUT_32(isp, ctsrc->rsp.m0.ct_dslist.ds_segment,
1318 			    &ctdst->rsp.m0.ct_dslist.ds_segment);
1319 			ISP_IOXPUT_32(isp, ctsrc->rsp.m0.ct_dslist.ds_base,
1320 			    &ctdst->rsp.m0.ct_dslist.ds_base);
1321 		}
1322 	} else if ((ctsrc->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE1) {
1323 		ISP_IOXPUT_16(isp, ctsrc->rsp.m1._reserved,
1324 		    &ctdst->rsp.m1._reserved);
1325 		ISP_IOXPUT_16(isp, ctsrc->rsp.m1._reserved2,
1326 		    &ctdst->rsp.m1._reserved2);
1327 		ISP_IOXPUT_16(isp, ctsrc->rsp.m1.ct_senselen,
1328 		    &ctdst->rsp.m1.ct_senselen);
1329 		ISP_IOXPUT_16(isp, ctsrc->rsp.m1.ct_scsi_status,
1330 		    &ctdst->rsp.m1.ct_scsi_status);
1331 		ISP_IOXPUT_16(isp, ctsrc->rsp.m1.ct_resplen,
1332 		    &ctdst->rsp.m1.ct_resplen);
1333 		for (i = 0; i < MAXRESPLEN; i++) {
1334 			ISP_IOXPUT_8(isp, ctsrc->rsp.m1.ct_resp[i],
1335 			    &ctdst->rsp.m1.ct_resp[i]);
1336 		}
1337 	} else {
1338 		ISP_IOXPUT_32(isp, ctsrc->rsp.m2._reserved,
1339 		    &ctdst->rsp.m2._reserved);
1340 		ISP_IOXPUT_16(isp, ctsrc->rsp.m2._reserved2,
1341 		    &ctdst->rsp.m2._reserved2);
1342 		ISP_IOXPUT_16(isp, ctsrc->rsp.m2._reserved3,
1343 		    &ctdst->rsp.m2._reserved3);
1344 		ISP_IOXPUT_32(isp, ctsrc->rsp.m2.ct_datalen,
1345 		    &ctdst->rsp.m2.ct_datalen);
1346 		ISP_IOXPUT_32(isp, ctsrc->rsp.m2.ct_fcp_rsp_iudata.ds_base,
1347 		    &ctdst->rsp.m2.ct_fcp_rsp_iudata.ds_base);
1348 		ISP_IOXPUT_32(isp, ctsrc->rsp.m2.ct_fcp_rsp_iudata.ds_count,
1349 		    &ctdst->rsp.m2.ct_fcp_rsp_iudata.ds_count);
1350 	}
1351 }
1352 
1353 void
1354 isp_get_ctio2(ispsoftc_t *isp, ct2_entry_t *ctsrc, ct2_entry_t *ctdst)
1355 {
1356 	isp_copy_in_hdr(isp, &ctsrc->ct_header, &ctdst->ct_header);
1357 	ISP_IOXGET_16(isp, &ctsrc->ct_reserved, ctdst->ct_reserved);
1358 	ISP_IOXGET_16(isp, &ctsrc->ct_fwhandle, ctdst->ct_fwhandle);
1359 	ISP_IOXGET_8(isp, &ctsrc->ct_lun, ctdst->ct_lun);
1360 	ISP_IOXGET_8(isp, &ctsrc->ct_iid, ctdst->ct_iid);
1361 	ISP_IOXGET_16(isp, &ctsrc->ct_rxid, ctdst->ct_rxid);
1362 	ISP_IOXGET_16(isp, &ctsrc->ct_flags, ctdst->ct_flags);
1363 	ISP_IOXGET_16(isp, &ctsrc->ct_status, ctdst->ct_status);
1364 	ISP_IOXGET_16(isp, &ctsrc->ct_timeout, ctdst->ct_timeout);
1365 	ISP_IOXGET_16(isp, &ctsrc->ct_seg_count, ctdst->ct_seg_count);
1366 	ISP_IOXGET_32(isp, &ctsrc->ct_reloff, ctdst->ct_reloff);
1367 	ISP_IOXGET_32(isp, &ctsrc->ct_resid, ctdst->ct_resid);
1368 }
1369 
1370 void
1371 isp_get_ctio2e(ispsoftc_t *isp, ct2e_entry_t *ctsrc, ct2e_entry_t *ctdst)
1372 {
1373 	isp_copy_in_hdr(isp, &ctsrc->ct_header, &ctdst->ct_header);
1374 	ISP_IOXGET_16(isp, &ctsrc->ct_reserved, ctdst->ct_reserved);
1375 	ISP_IOXGET_16(isp, &ctsrc->ct_fwhandle, ctdst->ct_fwhandle);
1376 	ISP_IOXGET_16(isp, &ctsrc->ct_iid, ctdst->ct_iid);
1377 	ISP_IOXGET_16(isp, &ctsrc->ct_rxid, ctdst->ct_rxid);
1378 	ISP_IOXGET_16(isp, &ctsrc->ct_flags, ctdst->ct_flags);
1379 	ISP_IOXGET_16(isp, &ctsrc->ct_status, ctdst->ct_status);
1380 	ISP_IOXGET_16(isp, &ctsrc->ct_timeout, ctdst->ct_timeout);
1381 	ISP_IOXGET_16(isp, &ctsrc->ct_seg_count, ctdst->ct_seg_count);
1382 	ISP_IOXGET_32(isp, &ctsrc->ct_reloff, ctdst->ct_reloff);
1383 	ISP_IOXGET_32(isp, &ctsrc->ct_resid, ctdst->ct_resid);
1384 }
1385 
1386 void
1387 isp_put_enable_lun(ispsoftc_t *isp, lun_entry_t *lesrc, lun_entry_t *ledst)
1388 {
1389 	int i;
1390 	isp_copy_out_hdr(isp, &lesrc->le_header, &ledst->le_header);
1391 	ISP_IOXPUT_32(isp, lesrc->le_reserved, &ledst->le_reserved);
1392 	if (ISP_IS_SBUS(isp)) {
1393 		ISP_IOXPUT_8(isp, lesrc->le_lun, &ledst->le_rsvd);
1394 		ISP_IOXPUT_8(isp, lesrc->le_rsvd, &ledst->le_lun);
1395 		ISP_IOXPUT_8(isp, lesrc->le_ops, &ledst->le_tgt);
1396 		ISP_IOXPUT_8(isp, lesrc->le_tgt, &ledst->le_ops);
1397 		ISP_IOXPUT_8(isp, lesrc->le_status, &ledst->le_reserved2);
1398 		ISP_IOXPUT_8(isp, lesrc->le_reserved2, &ledst->le_status);
1399 		ISP_IOXPUT_8(isp, lesrc->le_cmd_count, &ledst->le_in_count);
1400 		ISP_IOXPUT_8(isp, lesrc->le_in_count, &ledst->le_cmd_count);
1401 		ISP_IOXPUT_8(isp, lesrc->le_cdb6len, &ledst->le_cdb7len);
1402 		ISP_IOXPUT_8(isp, lesrc->le_cdb7len, &ledst->le_cdb6len);
1403 	} else {
1404 		ISP_IOXPUT_8(isp, lesrc->le_lun, &ledst->le_lun);
1405 		ISP_IOXPUT_8(isp, lesrc->le_rsvd, &ledst->le_rsvd);
1406 		ISP_IOXPUT_8(isp, lesrc->le_ops, &ledst->le_ops);
1407 		ISP_IOXPUT_8(isp, lesrc->le_tgt, &ledst->le_tgt);
1408 		ISP_IOXPUT_8(isp, lesrc->le_status, &ledst->le_status);
1409 		ISP_IOXPUT_8(isp, lesrc->le_reserved2, &ledst->le_reserved2);
1410 		ISP_IOXPUT_8(isp, lesrc->le_cmd_count, &ledst->le_cmd_count);
1411 		ISP_IOXPUT_8(isp, lesrc->le_in_count, &ledst->le_in_count);
1412 		ISP_IOXPUT_8(isp, lesrc->le_cdb6len, &ledst->le_cdb6len);
1413 		ISP_IOXPUT_8(isp, lesrc->le_cdb7len, &ledst->le_cdb7len);
1414 	}
1415 	ISP_IOXPUT_32(isp, lesrc->le_flags, &ledst->le_flags);
1416 	ISP_IOXPUT_16(isp, lesrc->le_timeout, &ledst->le_timeout);
1417 	for (i = 0; i < 20; i++) {
1418 		ISP_IOXPUT_8(isp, lesrc->le_reserved3[i],
1419 		    &ledst->le_reserved3[i]);
1420 	}
1421 }
1422 
1423 void
1424 isp_get_enable_lun(ispsoftc_t *isp, lun_entry_t *lesrc, lun_entry_t *ledst)
1425 {
1426 	int i;
1427 	isp_copy_in_hdr(isp, &lesrc->le_header, &ledst->le_header);
1428 	ISP_IOXGET_32(isp, &lesrc->le_reserved, ledst->le_reserved);
1429 	if (ISP_IS_SBUS(isp)) {
1430 		ISP_IOXGET_8(isp, &lesrc->le_lun, ledst->le_rsvd);
1431 		ISP_IOXGET_8(isp, &lesrc->le_rsvd, ledst->le_lun);
1432 		ISP_IOXGET_8(isp, &lesrc->le_ops, ledst->le_tgt);
1433 		ISP_IOXGET_8(isp, &lesrc->le_tgt, ledst->le_ops);
1434 		ISP_IOXGET_8(isp, &lesrc->le_status, ledst->le_reserved2);
1435 		ISP_IOXGET_8(isp, &lesrc->le_reserved2, ledst->le_status);
1436 		ISP_IOXGET_8(isp, &lesrc->le_cmd_count, ledst->le_in_count);
1437 		ISP_IOXGET_8(isp, &lesrc->le_in_count, ledst->le_cmd_count);
1438 		ISP_IOXGET_8(isp, &lesrc->le_cdb6len, ledst->le_cdb7len);
1439 		ISP_IOXGET_8(isp, &lesrc->le_cdb7len, ledst->le_cdb6len);
1440 	} else {
1441 		ISP_IOXGET_8(isp, &lesrc->le_lun, ledst->le_lun);
1442 		ISP_IOXGET_8(isp, &lesrc->le_rsvd, ledst->le_rsvd);
1443 		ISP_IOXGET_8(isp, &lesrc->le_ops, ledst->le_ops);
1444 		ISP_IOXGET_8(isp, &lesrc->le_tgt, ledst->le_tgt);
1445 		ISP_IOXGET_8(isp, &lesrc->le_status, ledst->le_status);
1446 		ISP_IOXGET_8(isp, &lesrc->le_reserved2, ledst->le_reserved2);
1447 		ISP_IOXGET_8(isp, &lesrc->le_cmd_count, ledst->le_cmd_count);
1448 		ISP_IOXGET_8(isp, &lesrc->le_in_count, ledst->le_in_count);
1449 		ISP_IOXGET_8(isp, &lesrc->le_cdb6len, ledst->le_cdb6len);
1450 		ISP_IOXGET_8(isp, &lesrc->le_cdb7len, ledst->le_cdb7len);
1451 	}
1452 	ISP_IOXGET_32(isp, &lesrc->le_flags, ledst->le_flags);
1453 	ISP_IOXGET_16(isp, &lesrc->le_timeout, ledst->le_timeout);
1454 	for (i = 0; i < 20; i++) {
1455 		ISP_IOXGET_8(isp, &lesrc->le_reserved3[i],
1456 		    ledst->le_reserved3[i]);
1457 	}
1458 }
1459 
1460 void
1461 isp_put_notify(ispsoftc_t *isp, in_entry_t *insrc, in_entry_t *indst)
1462 {
1463 	int i;
1464 	isp_copy_out_hdr(isp, &insrc->in_header, &indst->in_header);
1465 	ISP_IOXPUT_32(isp, insrc->in_reserved, &indst->in_reserved);
1466 	if (ISP_IS_SBUS(isp)) {
1467 		ISP_IOXPUT_8(isp, insrc->in_lun, &indst->in_iid);
1468 		ISP_IOXPUT_8(isp, insrc->in_iid, &indst->in_lun);
1469 		ISP_IOXPUT_8(isp, insrc->in_reserved2, &indst->in_tgt);
1470 		ISP_IOXPUT_8(isp, insrc->in_tgt, &indst->in_reserved2);
1471 		ISP_IOXPUT_8(isp, insrc->in_status, &indst->in_rsvd2);
1472 		ISP_IOXPUT_8(isp, insrc->in_rsvd2, &indst->in_status);
1473 		ISP_IOXPUT_8(isp, insrc->in_tag_val, &indst->in_tag_type);
1474 		ISP_IOXPUT_8(isp, insrc->in_tag_type, &indst->in_tag_val);
1475 	} else {
1476 		ISP_IOXPUT_8(isp, insrc->in_lun, &indst->in_lun);
1477 		ISP_IOXPUT_8(isp, insrc->in_iid, &indst->in_iid);
1478 		ISP_IOXPUT_8(isp, insrc->in_reserved2, &indst->in_reserved2);
1479 		ISP_IOXPUT_8(isp, insrc->in_tgt, &indst->in_tgt);
1480 		ISP_IOXPUT_8(isp, insrc->in_status, &indst->in_status);
1481 		ISP_IOXPUT_8(isp, insrc->in_rsvd2, &indst->in_rsvd2);
1482 		ISP_IOXPUT_8(isp, insrc->in_tag_val, &indst->in_tag_val);
1483 		ISP_IOXPUT_8(isp, insrc->in_tag_type, &indst->in_tag_type);
1484 	}
1485 	ISP_IOXPUT_32(isp, insrc->in_flags, &indst->in_flags);
1486 	ISP_IOXPUT_16(isp, insrc->in_seqid, &indst->in_seqid);
1487 	for (i = 0; i < IN_MSGLEN; i++) {
1488 		ISP_IOXPUT_8(isp, insrc->in_msg[i], &indst->in_msg[i]);
1489 	}
1490 	for (i = 0; i < IN_RSVDLEN; i++) {
1491 		ISP_IOXPUT_8(isp, insrc->in_reserved3[i],
1492 		    &indst->in_reserved3[i]);
1493 	}
1494 	for (i = 0; i < QLTM_SENSELEN; i++) {
1495 		ISP_IOXPUT_8(isp, insrc->in_sense[i],
1496 		    &indst->in_sense[i]);
1497 	}
1498 }
1499 
1500 void
1501 isp_get_notify(ispsoftc_t *isp, in_entry_t *insrc, in_entry_t *indst)
1502 {
1503 	int i;
1504 	isp_copy_in_hdr(isp, &insrc->in_header, &indst->in_header);
1505 	ISP_IOXGET_32(isp, &insrc->in_reserved, indst->in_reserved);
1506 	if (ISP_IS_SBUS(isp)) {
1507 		ISP_IOXGET_8(isp, &insrc->in_lun, indst->in_iid);
1508 		ISP_IOXGET_8(isp, &insrc->in_iid, indst->in_lun);
1509 		ISP_IOXGET_8(isp, &insrc->in_reserved2, indst->in_tgt);
1510 		ISP_IOXGET_8(isp, &insrc->in_tgt, indst->in_reserved2);
1511 		ISP_IOXGET_8(isp, &insrc->in_status, indst->in_rsvd2);
1512 		ISP_IOXGET_8(isp, &insrc->in_rsvd2, indst->in_status);
1513 		ISP_IOXGET_8(isp, &insrc->in_tag_val, indst->in_tag_type);
1514 		ISP_IOXGET_8(isp, &insrc->in_tag_type, indst->in_tag_val);
1515 	} else {
1516 		ISP_IOXGET_8(isp, &insrc->in_lun, indst->in_lun);
1517 		ISP_IOXGET_8(isp, &insrc->in_iid, indst->in_iid);
1518 		ISP_IOXGET_8(isp, &insrc->in_reserved2, indst->in_reserved2);
1519 		ISP_IOXGET_8(isp, &insrc->in_tgt, indst->in_tgt);
1520 		ISP_IOXGET_8(isp, &insrc->in_status, indst->in_status);
1521 		ISP_IOXGET_8(isp, &insrc->in_rsvd2, indst->in_rsvd2);
1522 		ISP_IOXGET_8(isp, &insrc->in_tag_val, indst->in_tag_val);
1523 		ISP_IOXGET_8(isp, &insrc->in_tag_type, indst->in_tag_type);
1524 	}
1525 	ISP_IOXGET_32(isp, &insrc->in_flags, indst->in_flags);
1526 	ISP_IOXGET_16(isp, &insrc->in_seqid, indst->in_seqid);
1527 	for (i = 0; i < IN_MSGLEN; i++) {
1528 		ISP_IOXGET_8(isp, &insrc->in_msg[i], indst->in_msg[i]);
1529 	}
1530 	for (i = 0; i < IN_RSVDLEN; i++) {
1531 		ISP_IOXGET_8(isp, &insrc->in_reserved3[i],
1532 		    indst->in_reserved3[i]);
1533 	}
1534 	for (i = 0; i < QLTM_SENSELEN; i++) {
1535 		ISP_IOXGET_8(isp, &insrc->in_sense[i],
1536 		    indst->in_sense[i]);
1537 	}
1538 }
1539 
1540 void
1541 isp_put_notify_fc(ispsoftc_t *isp, in_fcentry_t *insrc,
1542     in_fcentry_t *indst)
1543 {
1544 	isp_copy_out_hdr(isp, &insrc->in_header, &indst->in_header);
1545 	ISP_IOXPUT_32(isp, insrc->in_reserved, &indst->in_reserved);
1546 	ISP_IOXPUT_8(isp, insrc->in_lun, &indst->in_lun);
1547 	ISP_IOXPUT_8(isp, insrc->in_iid, &indst->in_iid);
1548 	ISP_IOXPUT_16(isp, insrc->in_scclun, &indst->in_scclun);
1549 	ISP_IOXPUT_32(isp, insrc->in_reserved2, &indst->in_reserved2);
1550 	ISP_IOXPUT_16(isp, insrc->in_status, &indst->in_status);
1551 	ISP_IOXPUT_16(isp, insrc->in_task_flags, &indst->in_task_flags);
1552 	ISP_IOXPUT_16(isp, insrc->in_seqid, &indst->in_seqid);
1553 }
1554 
1555 void
1556 isp_put_notify_fc_e(ispsoftc_t *isp, in_fcentry_e_t *insrc,
1557     in_fcentry_e_t *indst)
1558 {
1559 	isp_copy_out_hdr(isp, &insrc->in_header, &indst->in_header);
1560 	ISP_IOXPUT_32(isp, insrc->in_reserved, &indst->in_reserved);
1561 	ISP_IOXPUT_16(isp, insrc->in_iid, &indst->in_iid);
1562 	ISP_IOXPUT_16(isp, insrc->in_scclun, &indst->in_scclun);
1563 	ISP_IOXPUT_32(isp, insrc->in_reserved2, &indst->in_reserved2);
1564 	ISP_IOXPUT_16(isp, insrc->in_status, &indst->in_status);
1565 	ISP_IOXPUT_16(isp, insrc->in_task_flags, &indst->in_task_flags);
1566 	ISP_IOXPUT_16(isp, insrc->in_seqid, &indst->in_seqid);
1567 }
1568 
1569 void
1570 isp_get_notify_fc(ispsoftc_t *isp, in_fcentry_t *insrc,
1571     in_fcentry_t *indst)
1572 {
1573 	isp_copy_in_hdr(isp, &insrc->in_header, &indst->in_header);
1574 	ISP_IOXGET_32(isp, &insrc->in_reserved, indst->in_reserved);
1575 	ISP_IOXGET_8(isp, &insrc->in_lun, indst->in_lun);
1576 	ISP_IOXGET_8(isp, &insrc->in_iid, indst->in_iid);
1577 	ISP_IOXGET_16(isp, &insrc->in_scclun, indst->in_scclun);
1578 	ISP_IOXGET_32(isp, &insrc->in_reserved2, indst->in_reserved2);
1579 	ISP_IOXGET_16(isp, &insrc->in_status, indst->in_status);
1580 	ISP_IOXGET_16(isp, &insrc->in_task_flags, indst->in_task_flags);
1581 	ISP_IOXGET_16(isp, &insrc->in_seqid, indst->in_seqid);
1582 }
1583 
1584 void
1585 isp_get_notify_fc_e(ispsoftc_t *isp, in_fcentry_e_t *insrc,
1586     in_fcentry_e_t *indst)
1587 {
1588 	isp_copy_in_hdr(isp, &insrc->in_header, &indst->in_header);
1589 	ISP_IOXGET_32(isp, &insrc->in_reserved, indst->in_reserved);
1590 	ISP_IOXGET_16(isp, &insrc->in_iid, indst->in_iid);
1591 	ISP_IOXGET_16(isp, &insrc->in_scclun, indst->in_scclun);
1592 	ISP_IOXGET_32(isp, &insrc->in_reserved2, indst->in_reserved2);
1593 	ISP_IOXGET_16(isp, &insrc->in_status, indst->in_status);
1594 	ISP_IOXGET_16(isp, &insrc->in_task_flags, indst->in_task_flags);
1595 	ISP_IOXGET_16(isp, &insrc->in_seqid, indst->in_seqid);
1596 }
1597 
1598 void
1599 isp_put_notify_ack(ispsoftc_t *isp, na_entry_t *nasrc,  na_entry_t *nadst)
1600 {
1601 	int i;
1602 	isp_copy_out_hdr(isp, &nasrc->na_header, &nadst->na_header);
1603 	ISP_IOXPUT_32(isp, nasrc->na_reserved, &nadst->na_reserved);
1604 	if (ISP_IS_SBUS(isp)) {
1605 		ISP_IOXPUT_8(isp, nasrc->na_lun, &nadst->na_iid);
1606 		ISP_IOXPUT_8(isp, nasrc->na_iid, &nadst->na_lun);
1607 		ISP_IOXPUT_8(isp, nasrc->na_status, &nadst->na_event);
1608 		ISP_IOXPUT_8(isp, nasrc->na_event, &nadst->na_status);
1609 	} else {
1610 		ISP_IOXPUT_8(isp, nasrc->na_lun, &nadst->na_lun);
1611 		ISP_IOXPUT_8(isp, nasrc->na_iid, &nadst->na_iid);
1612 		ISP_IOXPUT_8(isp, nasrc->na_status, &nadst->na_status);
1613 		ISP_IOXPUT_8(isp, nasrc->na_event, &nadst->na_event);
1614 	}
1615 	ISP_IOXPUT_32(isp, nasrc->na_flags, &nadst->na_flags);
1616 	for (i = 0; i < NA_RSVDLEN; i++) {
1617 		ISP_IOXPUT_16(isp, nasrc->na_reserved3[i],
1618 		    &nadst->na_reserved3[i]);
1619 	}
1620 }
1621 
1622 void
1623 isp_get_notify_ack(ispsoftc_t *isp, na_entry_t *nasrc, na_entry_t *nadst)
1624 {
1625 	int i;
1626 	isp_copy_in_hdr(isp, &nasrc->na_header, &nadst->na_header);
1627 	ISP_IOXGET_32(isp, &nasrc->na_reserved, nadst->na_reserved);
1628 	if (ISP_IS_SBUS(isp)) {
1629 		ISP_IOXGET_8(isp, &nasrc->na_lun, nadst->na_iid);
1630 		ISP_IOXGET_8(isp, &nasrc->na_iid, nadst->na_lun);
1631 		ISP_IOXGET_8(isp, &nasrc->na_status, nadst->na_event);
1632 		ISP_IOXGET_8(isp, &nasrc->na_event, nadst->na_status);
1633 	} else {
1634 		ISP_IOXGET_8(isp, &nasrc->na_lun, nadst->na_lun);
1635 		ISP_IOXGET_8(isp, &nasrc->na_iid, nadst->na_iid);
1636 		ISP_IOXGET_8(isp, &nasrc->na_status, nadst->na_status);
1637 		ISP_IOXGET_8(isp, &nasrc->na_event, nadst->na_event);
1638 	}
1639 	ISP_IOXGET_32(isp, &nasrc->na_flags, nadst->na_flags);
1640 	for (i = 0; i < NA_RSVDLEN; i++) {
1641 		ISP_IOXGET_16(isp, &nasrc->na_reserved3[i],
1642 		    nadst->na_reserved3[i]);
1643 	}
1644 }
1645 
1646 void
1647 isp_put_notify_ack_fc(ispsoftc_t *isp, na_fcentry_t *nasrc,
1648     na_fcentry_t *nadst)
1649 {
1650 	int i;
1651 	isp_copy_out_hdr(isp, &nasrc->na_header, &nadst->na_header);
1652 	ISP_IOXPUT_32(isp, nasrc->na_reserved, &nadst->na_reserved);
1653 	ISP_IOXPUT_8(isp, nasrc->na_lun, &nadst->na_lun);
1654 	ISP_IOXPUT_8(isp, nasrc->na_iid, &nadst->na_iid);
1655 	ISP_IOXPUT_16(isp, nasrc->na_scclun, &nadst->na_scclun);
1656 	ISP_IOXPUT_16(isp, nasrc->na_flags, &nadst->na_flags);
1657 	ISP_IOXPUT_16(isp, nasrc->na_reserved2, &nadst->na_reserved2);
1658 	ISP_IOXPUT_16(isp, nasrc->na_status, &nadst->na_status);
1659 	ISP_IOXPUT_16(isp, nasrc->na_task_flags, &nadst->na_task_flags);
1660 	ISP_IOXPUT_16(isp, nasrc->na_seqid, &nadst->na_seqid);
1661 	for (i = 0; i < NA2_RSVDLEN; i++) {
1662 		ISP_IOXPUT_16(isp, nasrc->na_reserved3[i],
1663 		    &nadst->na_reserved3[i]);
1664 	}
1665 }
1666 
1667 void
1668 isp_put_notify_ack_fc_e(ispsoftc_t *isp, na_fcentry_e_t *nasrc,
1669     na_fcentry_e_t *nadst)
1670 {
1671 	int i;
1672 	isp_copy_out_hdr(isp, &nasrc->na_header, &nadst->na_header);
1673 	ISP_IOXPUT_32(isp, nasrc->na_reserved, &nadst->na_reserved);
1674 	ISP_IOXPUT_16(isp, nasrc->na_iid, &nadst->na_iid);
1675 	ISP_IOXPUT_16(isp, nasrc->na_scclun, &nadst->na_scclun);
1676 	ISP_IOXPUT_16(isp, nasrc->na_flags, &nadst->na_flags);
1677 	ISP_IOXPUT_16(isp, nasrc->na_reserved2, &nadst->na_reserved2);
1678 	ISP_IOXPUT_16(isp, nasrc->na_status, &nadst->na_status);
1679 	ISP_IOXPUT_16(isp, nasrc->na_task_flags, &nadst->na_task_flags);
1680 	ISP_IOXPUT_16(isp, nasrc->na_seqid, &nadst->na_seqid);
1681 	for (i = 0; i < NA2_RSVDLEN; i++) {
1682 		ISP_IOXPUT_16(isp, nasrc->na_reserved3[i],
1683 		    &nadst->na_reserved3[i]);
1684 	}
1685 }
1686 
1687 void
1688 isp_get_notify_ack_fc(ispsoftc_t *isp, na_fcentry_t *nasrc,
1689     na_fcentry_t *nadst)
1690 {
1691 	int i;
1692 	isp_copy_in_hdr(isp, &nasrc->na_header, &nadst->na_header);
1693 	ISP_IOXGET_32(isp, &nasrc->na_reserved, nadst->na_reserved);
1694 	ISP_IOXGET_8(isp, &nasrc->na_lun, nadst->na_lun);
1695 	ISP_IOXGET_8(isp, &nasrc->na_iid, nadst->na_iid);
1696 	ISP_IOXGET_16(isp, &nasrc->na_scclun, nadst->na_scclun);
1697 	ISP_IOXGET_16(isp, &nasrc->na_flags, nadst->na_flags);
1698 	ISP_IOXGET_16(isp, &nasrc->na_reserved2, nadst->na_reserved2);
1699 	ISP_IOXGET_16(isp, &nasrc->na_status, nadst->na_status);
1700 	ISP_IOXGET_16(isp, &nasrc->na_task_flags, nadst->na_task_flags);
1701 	ISP_IOXGET_16(isp, &nasrc->na_seqid, nadst->na_seqid);
1702 	for (i = 0; i < NA2_RSVDLEN; i++) {
1703 		ISP_IOXGET_16(isp, &nasrc->na_reserved3[i],
1704 		    nadst->na_reserved3[i]);
1705 	}
1706 }
1707 
1708 void
1709 isp_get_notify_ack_fc_e(ispsoftc_t *isp, na_fcentry_e_t *nasrc,
1710     na_fcentry_e_t *nadst)
1711 {
1712 	int i;
1713 	isp_copy_in_hdr(isp, &nasrc->na_header, &nadst->na_header);
1714 	ISP_IOXGET_32(isp, &nasrc->na_reserved, nadst->na_reserved);
1715 	ISP_IOXGET_16(isp, &nasrc->na_iid, nadst->na_iid);
1716 	ISP_IOXGET_16(isp, &nasrc->na_scclun, nadst->na_scclun);
1717 	ISP_IOXGET_16(isp, &nasrc->na_flags, nadst->na_flags);
1718 	ISP_IOXGET_16(isp, &nasrc->na_reserved2, nadst->na_reserved2);
1719 	ISP_IOXGET_16(isp, &nasrc->na_status, nadst->na_status);
1720 	ISP_IOXGET_16(isp, &nasrc->na_task_flags, nadst->na_task_flags);
1721 	ISP_IOXGET_16(isp, &nasrc->na_seqid, nadst->na_seqid);
1722 	for (i = 0; i < NA2_RSVDLEN; i++) {
1723 		ISP_IOXGET_16(isp, &nasrc->na_reserved3[i],
1724 		    nadst->na_reserved3[i]);
1725 	}
1726 }
1727 #endif	/* ISP_TARGET_MODE */
1728