xref: /freebsd/sys/dev/isp/isp_library.c (revision 7aa383846770374466b1dcb2cefd71bde9acf463)
1 /*-
2  *  Copyright (c) 1997-2009 by Matthew Jacob
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions
7  *  are met:
8  *
9  *  1. Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  *  2. Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  *
15  *  THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  *  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  *  ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
19  *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  *  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  *  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  *  SUCH DAMAGE.
26  *
27  */
28 /*
29  * Qlogic Host Adapter Internal Library Functions
30  */
31 #ifdef	__NetBSD__
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD$");
34 #include <dev/ic/isp_netbsd.h>
35 #endif
36 #ifdef	__FreeBSD__
37 #include <sys/cdefs.h>
38 __FBSDID("$FreeBSD$");
39 #include <dev/isp/isp_freebsd.h>
40 #endif
41 #ifdef	__OpenBSD__
42 #include <dev/ic/isp_openbsd.h>
43 #endif
44 #ifdef	__linux__
45 #include "isp_linux.h"
46 #endif
47 #ifdef	__svr4__
48 #include "isp_solaris.h"
49 #endif
50 
51 const char *isp_class3_roles[4] = {
52     "None", "Target", "Initiator", "Target/Initiator"
53 };
54 
55 /*
56  * Command shipping- finish off first queue entry and do dma mapping and additional segments as needed.
57  *
58  * Called with the first queue entry at least partially filled out.
59  */
60 int
61 isp_send_cmd(ispsoftc_t *isp, void *fqe, void *segp, uint32_t nsegs, uint32_t totalcnt, isp_ddir_t ddir)
62 {
63 	uint8_t storage[QENTRY_LEN];
64 	uint8_t type, nqe;
65 	uint32_t seg, curseg, seglim, nxt, nxtnxt, ddf;
66 	ispds_t *dsp = NULL;
67 	ispds64_t *dsp64 = NULL;
68 	void *qe0, *qe1;
69 
70 	qe0 = isp_getrqentry(isp);
71 	if (qe0 == NULL) {
72 		return (CMD_EAGAIN);
73 	}
74 	nxt = ISP_NXT_QENTRY(isp->isp_reqidx, RQUEST_QUEUE_LEN(isp));
75 
76 	type = ((isphdr_t *)fqe)->rqs_entry_type;
77 	nqe = 1;
78 
79 	/*
80 	 * If we have no data to transmit, just copy the first IOCB and start it up.
81 	 */
82 	if (ddir == ISP_NOXFR) {
83 		if (type == RQSTYPE_T2RQS || type == RQSTYPE_T3RQS) {
84 			ddf = CT2_NO_DATA;
85 		} else {
86 			ddf = 0;
87 		}
88 		goto copy_and_sync;
89 	}
90 
91 	/*
92 	 * First figure out how many pieces of data to transfer and what kind and how many we can put into the first queue entry.
93 	 */
94 	switch (type) {
95 	case RQSTYPE_REQUEST:
96 		ddf = (ddir == ISP_TO_DEVICE)? REQFLAG_DATA_OUT : REQFLAG_DATA_IN;
97 		dsp = ((ispreq_t *)fqe)->req_dataseg;
98 		seglim = ISP_RQDSEG;
99 		break;
100 	case RQSTYPE_CMDONLY:
101 		ddf = (ddir == ISP_TO_DEVICE)? REQFLAG_DATA_OUT : REQFLAG_DATA_IN;
102 		seglim = 0;
103 		break;
104 	case RQSTYPE_T2RQS:
105 		ddf = (ddir == ISP_TO_DEVICE)? REQFLAG_DATA_OUT : REQFLAG_DATA_IN;
106 		dsp = ((ispreqt2_t *)fqe)->req_dataseg;
107 		seglim = ISP_RQDSEG_T2;
108 		break;
109 	case RQSTYPE_A64:
110 		ddf = (ddir == ISP_TO_DEVICE)? REQFLAG_DATA_OUT : REQFLAG_DATA_IN;
111 		dsp64 = ((ispreqt3_t *)fqe)->req_dataseg;
112 		seglim = ISP_RQDSEG_T3;
113 		break;
114 	case RQSTYPE_T3RQS:
115 		ddf = (ddir == ISP_TO_DEVICE)? REQFLAG_DATA_OUT : REQFLAG_DATA_IN;
116 		dsp64 = ((ispreqt3_t *)fqe)->req_dataseg;
117 		seglim = ISP_RQDSEG_T3;
118 		break;
119 	case RQSTYPE_T7RQS:
120 		ddf = (ddir == ISP_TO_DEVICE)? FCP_CMND_DATA_WRITE : FCP_CMND_DATA_READ;
121 		dsp64 = &((ispreqt7_t *)fqe)->req_dataseg;
122 		seglim = 1;
123 		break;
124 	default:
125 		return (CMD_COMPLETE);
126 	}
127 
128 	if (seglim > nsegs) {
129 		seglim = nsegs;
130 	}
131 
132 	for (seg = curseg = 0; curseg < seglim; curseg++) {
133 		if (dsp64) {
134 			XS_GET_DMA64_SEG(dsp64++, segp, seg++);
135 		} else {
136 			XS_GET_DMA_SEG(dsp++, segp, seg++);
137 		}
138 	}
139 
140 
141 	/*
142 	 * Second, start building additional continuation segments as needed.
143 	 */
144 	while (seg < nsegs) {
145 		nxtnxt = ISP_NXT_QENTRY(nxt, RQUEST_QUEUE_LEN(isp));
146 		if (nxtnxt == isp->isp_reqodx) {
147 			return (CMD_EAGAIN);
148 		}
149 		ISP_MEMZERO(storage, QENTRY_LEN);
150 		qe1 = ISP_QUEUE_ENTRY(isp->isp_rquest, nxt);
151 		nxt = nxtnxt;
152 		if (dsp64) {
153 			ispcontreq64_t *crq = (ispcontreq64_t *) storage;
154 			seglim = ISP_CDSEG64;
155 			crq->req_header.rqs_entry_type = RQSTYPE_A64_CONT;
156 			crq->req_header.rqs_entry_count = 1;
157 			dsp64 = crq->req_dataseg;
158 		} else {
159 			ispcontreq_t *crq = (ispcontreq_t *) storage;
160 			seglim = ISP_CDSEG;
161 			crq->req_header.rqs_entry_type = RQSTYPE_DATASEG;
162 			crq->req_header.rqs_entry_count = 1;
163 			dsp = crq->req_dataseg;
164 		}
165 		if (seg + seglim > nsegs) {
166 			seglim = nsegs - seg;
167 		}
168 		for (curseg = 0; curseg < seglim; curseg++) {
169 			if (dsp64) {
170 				XS_GET_DMA64_SEG(dsp64++, segp, seg++);
171 			} else {
172 				XS_GET_DMA_SEG(dsp++, segp, seg++);
173 			}
174 		}
175 		if (dsp64) {
176 			isp_put_cont64_req(isp, (ispcontreq64_t *)storage, qe1);
177 		} else {
178 			isp_put_cont_req(isp, (ispcontreq_t *)storage, qe1);
179 		}
180 		if (isp->isp_dblev & ISP_LOGDEBUG1) {
181 			isp_print_bytes(isp, "additional queue entry", QENTRY_LEN, storage);
182 		}
183 		nqe++;
184         }
185 
186 copy_and_sync:
187 	((isphdr_t *)fqe)->rqs_entry_count = nqe;
188 	switch (type) {
189 	case RQSTYPE_REQUEST:
190 		((ispreq_t *)fqe)->req_flags |= ddf;
191 		/*
192 		 * This is historical and not clear whether really needed.
193 		 */
194 		if (nsegs == 0) {
195 			nsegs = 1;
196 		}
197 		((ispreq_t *)fqe)->req_seg_count = nsegs;
198 		isp_put_request(isp, fqe, qe0);
199 		break;
200 	case RQSTYPE_CMDONLY:
201 		((ispreq_t *)fqe)->req_flags |= ddf;
202 		/*
203 		 * This is historical and not clear whether really needed.
204 		 */
205 		if (nsegs == 0) {
206 			nsegs = 1;
207 		}
208 		((ispextreq_t *)fqe)->req_seg_count = nsegs;
209 		isp_put_extended_request(isp, fqe, qe0);
210 		break;
211 	case RQSTYPE_T2RQS:
212 		((ispreqt2_t *)fqe)->req_flags |= ddf;
213 		((ispreqt2_t *)fqe)->req_seg_count = nsegs;
214 		((ispreqt2_t *)fqe)->req_totalcnt = totalcnt;
215 		if (ISP_CAP_2KLOGIN(isp)) {
216 			isp_put_request_t2e(isp, fqe, qe0);
217 		} else {
218 			isp_put_request_t2(isp, fqe, qe0);
219 		}
220 		break;
221 	case RQSTYPE_A64:
222 	case RQSTYPE_T3RQS:
223 		((ispreqt3_t *)fqe)->req_flags |= ddf;
224 		((ispreqt3_t *)fqe)->req_seg_count = nsegs;
225 		((ispreqt3_t *)fqe)->req_totalcnt = totalcnt;
226 		if (ISP_CAP_2KLOGIN(isp)) {
227 			isp_put_request_t3e(isp, fqe, qe0);
228 		} else {
229 			isp_put_request_t3(isp, fqe, qe0);
230 		}
231 		break;
232 	case RQSTYPE_T7RQS:
233         	((ispreqt7_t *)fqe)->req_alen_datadir = ddf;
234 		((ispreqt7_t *)fqe)->req_seg_count = nsegs;
235 		((ispreqt7_t *)fqe)->req_dl = totalcnt;
236 		isp_put_request_t7(isp, fqe, qe0);
237 		break;
238 	default:
239 		return (CMD_COMPLETE);
240 	}
241 	if (isp->isp_dblev & ISP_LOGDEBUG1) {
242 		isp_print_bytes(isp, "first queue entry", QENTRY_LEN, fqe);
243 	}
244 	ISP_ADD_REQUEST(isp, nxt);
245 	return (CMD_QUEUED);
246 }
247 
248 int
249 isp_allocate_xs(ispsoftc_t *isp, XS_T *xs, uint32_t *handlep)
250 {
251 	isp_hdl_t *hdp;
252 
253 	hdp = isp->isp_xffree;
254 	if (hdp == NULL) {
255 		return (-1);
256 	}
257 	isp->isp_xffree = hdp->cmd;
258 	hdp->cmd = xs;
259 	hdp->handle = (hdp - isp->isp_xflist);
260 	hdp->handle |= (ISP_HANDLE_INITIATOR << ISP_HANDLE_USAGE_SHIFT);
261 	hdp->handle |= (isp->isp_seqno++ << ISP_HANDLE_SEQ_SHIFT);
262 	*handlep = hdp->handle;
263 	return (0);
264 }
265 
266 XS_T *
267 isp_find_xs(ispsoftc_t *isp, uint32_t handle)
268 {
269 	if (!ISP_VALID_INI_HANDLE(isp, handle)) {
270 		isp_prt(isp, ISP_LOGERR, "%s: bad handle 0x%x", __func__, handle);
271 		return (NULL);
272 	}
273 	return (isp->isp_xflist[(handle & ISP_HANDLE_CMD_MASK)].cmd);
274 }
275 
276 uint32_t
277 isp_find_handle(ispsoftc_t *isp, XS_T *xs)
278 {
279 	uint32_t i, foundhdl = ISP_HANDLE_FREE;
280 
281 	if (xs != NULL) {
282 		for (i = 0; i < isp->isp_maxcmds; i++) {
283 			if (isp->isp_xflist[i].cmd != xs) {
284 				continue;
285 			}
286 			foundhdl = isp->isp_xflist[i].handle;
287 			break;
288 		}
289 	}
290 	return (foundhdl);
291 }
292 
293 uint32_t
294 isp_handle_index(ispsoftc_t *isp, uint32_t handle)
295 {
296 	if (!ISP_VALID_HANDLE(isp, handle)) {
297 		isp_prt(isp, ISP_LOGERR, "%s: bad handle 0x%x", __func__, handle);
298 		return (ISP_BAD_HANDLE_INDEX);
299 	} else {
300 		return (handle & ISP_HANDLE_CMD_MASK);
301 	}
302 }
303 
304 void
305 isp_destroy_handle(ispsoftc_t *isp, uint32_t handle)
306 {
307 	if (!ISP_VALID_INI_HANDLE(isp, handle)) {
308 		isp_prt(isp, ISP_LOGERR, "%s: bad handle 0x%x", __func__, handle);
309 	} else {
310 		isp->isp_xflist[(handle & ISP_HANDLE_CMD_MASK)].handle = ISP_HANDLE_FREE;
311 		isp->isp_xflist[(handle & ISP_HANDLE_CMD_MASK)].cmd = isp->isp_xffree;
312 		isp->isp_xffree = &isp->isp_xflist[(handle & ISP_HANDLE_CMD_MASK)];
313 	}
314 }
315 
316 /*
317  * Make sure we have space to put something on the request queue.
318  * Return a pointer to that entry if we do. A side effect of this
319  * function is to update the output index. The input index
320  * stays the same.
321  */
322 void *
323 isp_getrqentry(ispsoftc_t *isp)
324 {
325 	isp->isp_reqodx = ISP_READ(isp, isp->isp_rqstoutrp);
326 	if (ISP_NXT_QENTRY(isp->isp_reqidx, RQUEST_QUEUE_LEN(isp)) == isp->isp_reqodx) {
327 		return (NULL);
328 	}
329 	return (ISP_QUEUE_ENTRY(isp->isp_rquest, isp->isp_reqidx));
330 }
331 
332 #define	TBA	(4 * (((QENTRY_LEN >> 2) * 3) + 1) + 1)
333 void
334 isp_print_qentry(ispsoftc_t *isp, const char *msg, int idx, void *arg)
335 {
336 	char buf[TBA];
337 	int amt, i, j;
338 	uint8_t *ptr = arg;
339 
340 	isp_prt(isp, ISP_LOGALL, "%s index %d=>", msg, idx);
341 	for (buf[0] = 0, amt = i = 0; i < 4; i++) {
342 		buf[0] = 0;
343 		ISP_SNPRINTF(buf, TBA, "  ");
344 		for (j = 0; j < (QENTRY_LEN >> 2); j++) {
345 			ISP_SNPRINTF(buf, TBA, "%s %02x", buf, ptr[amt++] & 0xff);
346 		}
347 		isp_prt(isp, ISP_LOGALL, "%s", buf);
348 	}
349 }
350 
351 void
352 isp_print_bytes(ispsoftc_t *isp, const char *msg, int amt, void *arg)
353 {
354 	char buf[128];
355 	uint8_t *ptr = arg;
356 	int off;
357 
358 	if (msg)
359 		isp_prt(isp, ISP_LOGALL, "%s:", msg);
360 	off = 0;
361 	buf[0] = 0;
362 	while (off < amt) {
363 		int j, to;
364 		to = off;
365 		for (j = 0; j < 16; j++) {
366 			ISP_SNPRINTF(buf, 128, "%s %02x", buf, ptr[off++] & 0xff);
367 			if (off == amt) {
368 				break;
369 			}
370 		}
371 		isp_prt(isp, ISP_LOGALL, "0x%08x:%s", to, buf);
372 		buf[0] = 0;
373 	}
374 }
375 
376 /*
377  * Do the common path to try and ensure that link is up, we've scanned
378  * the fabric (if we're on a fabric), and that we've synchronized this
379  * all with our own database and done the appropriate logins.
380  *
381  * We repeatedly check for firmware state and loop state after each
382  * action because things may have changed while we were doing this.
383  * Any failure or change of state causes us to return a nonzero value.
384  *
385  * We assume we enter here with any locks held.
386  */
387 
388 int
389 isp_fc_runstate(ispsoftc_t *isp, int chan, int tval)
390 {
391 	fcparam *fcp;
392 
393 	fcp = FCPARAM(isp, chan);
394         if (fcp->role == ISP_ROLE_NONE) {
395 		return (0);
396 	}
397 	if (fcp->isp_fwstate < FW_READY || fcp->isp_loopstate < LOOP_PDB_RCVD) {
398 		if (isp_control(isp, ISPCTL_FCLINK_TEST, chan, tval) != 0) {
399 			isp_prt(isp, ISP_LOGSANCFG, "isp_fc_runstate: linktest failed for channel %d", chan);
400 			return (-1);
401 		}
402 		if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate < LOOP_PDB_RCVD) {
403 			isp_prt(isp, ISP_LOGSANCFG, "isp_fc_runstate: f/w not ready for channel %d", chan);
404 			return (-1);
405 		}
406 	}
407 
408 	if ((fcp->role & ISP_ROLE_INITIATOR) == 0) {
409 		return (0);
410 	}
411 
412 	if (isp_control(isp, ISPCTL_SCAN_LOOP, chan) != 0) {
413 		isp_prt(isp, ISP_LOGSANCFG, "isp_fc_runstate: scan loop fails on channel %d", chan);
414 		return (LOOP_PDB_RCVD);
415 	}
416 	if (isp_control(isp, ISPCTL_SCAN_FABRIC, chan) != 0) {
417 		isp_prt(isp, ISP_LOGSANCFG, "isp_fc_runstate: scan fabric fails on channel %d", chan);
418 		return (LOOP_LSCAN_DONE);
419 	}
420 	if (isp_control(isp, ISPCTL_PDB_SYNC, chan) != 0) {
421 		isp_prt(isp, ISP_LOGSANCFG, "isp_fc_runstate: pdb_sync fails on channel %d", chan);
422 		return (LOOP_FSCAN_DONE);
423 	}
424 	if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate != LOOP_READY) {
425 		isp_prt(isp, ISP_LOGSANCFG, "isp_fc_runstate: f/w not ready again on channel %d", chan);
426 		return (-1);
427 	}
428 	return (0);
429 }
430 
431 /*
432  * Fibre Channel Support routines
433  */
434 void
435 isp_dump_portdb(ispsoftc_t *isp, int chan)
436 {
437 	fcparam *fcp = FCPARAM(isp, chan);
438 	int i;
439 
440 	for (i = 0; i < MAX_FC_TARG; i++) {
441 		char mb[4];
442 		const char *dbs[8] = {
443 			"NIL ",
444 			"PROB",
445 			"DEAD",
446 			"CHGD",
447 			"NEW ",
448 			"PVLD",
449 			"ZOMB",
450 			"VLD "
451 		};
452 		const char *roles[4] = {
453 			" UNK", " TGT", " INI", "TINI"
454 		};
455 		fcportdb_t *lp = &fcp->portdb[i];
456 
457 		if (lp->state == FC_PORTDB_STATE_NIL && lp->target_mode == 0) {
458 			continue;
459 		}
460 		if (lp->dev_map_idx) {
461 			ISP_SNPRINTF(mb, sizeof (mb), "%3d", ((int) lp->dev_map_idx) - 1);
462 		} else {
463 			ISP_SNPRINTF(mb, sizeof (mb), "---");
464 		}
465 		isp_prt(isp, ISP_LOGALL, "Chan %d [%d]: hdl 0x%x %s al%d tgt %s %s 0x%06x =>%s 0x%06x; WWNN 0x%08x%08x WWPN 0x%08x%08x",
466 		    chan, i, lp->handle, dbs[lp->state], lp->autologin, mb, roles[lp->roles], lp->portid, roles[lp->new_roles], lp->new_portid,
467 		    (uint32_t) (lp->node_wwn >> 32), (uint32_t) (lp->node_wwn), (uint32_t) (lp->port_wwn >> 32), (uint32_t) (lp->port_wwn));
468 	}
469 }
470 
471 const char *
472 isp_fc_fw_statename(int state)
473 {
474 	switch (state) {
475 	case FW_CONFIG_WAIT:	return "Config Wait";
476 	case FW_WAIT_AL_PA:	return "Waiting for AL_PA";
477 	case FW_WAIT_LOGIN:	return "Wait Login";
478 	case FW_READY:		return "Ready";
479 	case FW_LOSS_OF_SYNC:	return "Loss Of Sync";
480 	case FW_ERROR:		return "Error";
481 	case FW_REINIT:		return "Re-Init";
482 	case FW_NON_PART:	return "Nonparticipating";
483 	default:		return "?????";
484 	}
485 }
486 
487 const char *
488 isp_fc_loop_statename(int state)
489 {
490 	switch (state) {
491 	case LOOP_NIL:                  return "NIL";
492 	case LOOP_LIP_RCVD:             return "LIP Received";
493 	case LOOP_PDB_RCVD:             return "PDB Received";
494 	case LOOP_SCANNING_LOOP:        return "Scanning";
495 	case LOOP_LSCAN_DONE:           return "Loop Scan Done";
496 	case LOOP_SCANNING_FABRIC:      return "Scanning Fabric";
497 	case LOOP_FSCAN_DONE:           return "Fabric Scan Done";
498 	case LOOP_SYNCING_PDB:          return "Syncing PDB";
499 	case LOOP_READY:                return "Ready";
500 	default:                        return "?????";
501 	}
502 }
503 
504 const char *
505 isp_fc_toponame(fcparam *fcp)
506 {
507 
508 	if (fcp->isp_fwstate != FW_READY) {
509 		return "Unavailable";
510 	}
511 	switch (fcp->isp_topo) {
512 	case TOPO_NL_PORT:      return "Private Loop";
513 	case TOPO_FL_PORT:      return "FL Port";
514 	case TOPO_N_PORT:       return "N-Port to N-Port";
515 	case TOPO_F_PORT:       return "F Port";
516 	case TOPO_PTP_STUB:     return "F Port (no FLOGI_ACC response)";
517 	default:                return "?????";
518 	}
519 }
520 
521 /*
522  * Change Roles
523  */
524 int
525 isp_fc_change_role(ispsoftc_t *isp, int chan, int new_role)
526 {
527 	fcparam *fcp = FCPARAM(isp, chan);
528 
529 	if (chan >= isp->isp_nchan) {
530 		isp_prt(isp, ISP_LOGWARN, "%s: bad channel %d", __func__, chan);
531 		return (ENXIO);
532 	}
533 	if (chan == 0) {
534 #ifdef	ISP_TARGET_MODE
535 		isp_del_all_wwn_entries(isp, chan);
536 #endif
537 		isp_clear_commands(isp);
538 
539 		isp_reset(isp, 0);
540 		if (isp->isp_state != ISP_RESETSTATE) {
541 			isp_prt(isp, ISP_LOGERR, "%s: cannot reset card", __func__);
542 			return (EIO);
543 		}
544 		fcp->role = new_role;
545 		isp_init(isp);
546 		if (isp->isp_state != ISP_INITSTATE) {
547 			isp_prt(isp, ISP_LOGERR, "%s: cannot init card", __func__);
548 			return (EIO);
549 		}
550 		isp->isp_state = ISP_RUNSTATE;
551 		return (0);
552 	} else if (ISP_CAP_MULTI_ID(isp)) {
553 		mbreg_t mbs;
554 		vp_modify_t *vp;
555 		uint8_t qe[QENTRY_LEN], *scp;
556 
557 		ISP_MEMZERO(qe, QENTRY_LEN);
558 		/* Acquire Scratch */
559 
560 		if (FC_SCRATCH_ACQUIRE(isp, chan)) {
561 			return (EBUSY);
562 		}
563 		scp = fcp->isp_scratch;
564 
565 		/*
566 		 * Build a VP MODIFY command in memory
567 		 */
568 		vp = (vp_modify_t *) qe;
569 		vp->vp_mod_hdr.rqs_entry_type = RQSTYPE_VP_MODIFY;
570 		vp->vp_mod_hdr.rqs_entry_count = 1;
571 		vp->vp_mod_cnt = 1;
572 		vp->vp_mod_idx0 = chan;
573 		vp->vp_mod_cmd = VP_MODIFY_ENA;
574 		vp->vp_mod_ports[0].options = ICB2400_VPOPT_ENABLED;
575 		if (new_role & ISP_ROLE_INITIATOR) {
576 			vp->vp_mod_ports[0].options |= ICB2400_VPOPT_INI_ENABLE;
577 		}
578 		if ((new_role & ISP_ROLE_TARGET) == 0) {
579 			vp->vp_mod_ports[0].options |= ICB2400_VPOPT_TGT_DISABLE;
580 		}
581 		MAKE_NODE_NAME_FROM_WWN(vp->vp_mod_ports[0].wwpn, fcp->isp_wwpn);
582 		MAKE_NODE_NAME_FROM_WWN(vp->vp_mod_ports[0].wwnn, fcp->isp_wwnn);
583 		isp_put_vp_modify(isp, vp, (vp_modify_t *) scp);
584 
585 		/*
586 		 * Build a EXEC IOCB A64 command that points to the VP MODIFY command
587 		 */
588 		MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 0);
589 		mbs.param[1] = QENTRY_LEN;
590 		mbs.param[2] = DMA_WD1(fcp->isp_scdma);
591 		mbs.param[3] = DMA_WD0(fcp->isp_scdma);
592 		mbs.param[6] = DMA_WD3(fcp->isp_scdma);
593 		mbs.param[7] = DMA_WD2(fcp->isp_scdma);
594 		MEMORYBARRIER(isp, SYNC_SFORDEV, 0, 2 * QENTRY_LEN);
595 		isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
596 		if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
597 			FC_SCRATCH_RELEASE(isp, chan);
598 			return (EIO);
599 		}
600 		MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN);
601 		isp_get_vp_modify(isp, (vp_modify_t *)&scp[QENTRY_LEN], vp);
602 
603 #ifdef	ISP_TARGET_MODE
604 		isp_del_all_wwn_entries(isp, chan);
605 #endif
606 		/*
607 		 * Release Scratch
608 		 */
609 		FC_SCRATCH_RELEASE(isp, chan);
610 
611 		if (vp->vp_mod_status != VP_STS_OK) {
612 			isp_prt(isp, ISP_LOGERR, "%s: VP_MODIFY of Chan %d failed with status %d", __func__, chan, vp->vp_mod_status);
613 			return (EIO);
614 		}
615 		fcp->role = new_role;
616 		return (0);
617 	} else {
618 		return (EINVAL);
619 	}
620 }
621 
622 void
623 isp_clear_commands(ispsoftc_t *isp)
624 {
625 	uint32_t tmp;
626 	isp_hdl_t *hdp;
627 #ifdef	ISP_TARGET_MODE
628 	isp_notify_t notify;
629 #endif
630 
631 	for (tmp = 0; isp->isp_xflist && tmp < isp->isp_maxcmds; tmp++) {
632 		XS_T *xs;
633 
634 		hdp = &isp->isp_xflist[tmp];
635 		if (hdp->handle == ISP_HANDLE_FREE) {
636 			continue;
637 		}
638 		xs = hdp->cmd;
639 		if (XS_XFRLEN(xs)) {
640 			ISP_DMAFREE(isp, xs, hdp->handle);
641 			XS_SET_RESID(xs, XS_XFRLEN(xs));
642 		} else {
643 			XS_SET_RESID(xs, 0);
644 		}
645 		hdp->handle = 0;
646 		hdp->cmd = NULL;
647 		XS_SETERR(xs, HBA_BUSRESET);
648 		isp_done(xs);
649 	}
650 #ifdef	ISP_TARGET_MODE
651 	for (tmp = 0; isp->isp_tgtlist && tmp < isp->isp_maxcmds; tmp++) {
652 		uint8_t local[QENTRY_LEN];
653 		hdp = &isp->isp_tgtlist[tmp];
654 		if (hdp->handle == ISP_HANDLE_FREE) {
655 			continue;
656 		}
657 		ISP_DMAFREE(isp, hdp->cmd, hdp->handle);
658 		ISP_MEMZERO(local, QENTRY_LEN);
659 		if (IS_24XX(isp)) {
660 			ct7_entry_t *ctio = (ct7_entry_t *) local;
661 			ctio->ct_syshandle = hdp->handle;
662 			ctio->ct_nphdl = CT_HBA_RESET;
663 			ctio->ct_header.rqs_entry_type = RQSTYPE_CTIO7;
664 		} else if (IS_FC(isp)) {
665 			ct2_entry_t *ctio = (ct2_entry_t *) local;
666 			ctio->ct_syshandle = hdp->handle;
667 			ctio->ct_status = CT_HBA_RESET;
668 			ctio->ct_header.rqs_entry_type = RQSTYPE_CTIO2;
669 		} else {
670 			ct_entry_t *ctio = (ct_entry_t *) local;
671 			ctio->ct_syshandle = hdp->handle;
672 			ctio->ct_status = CT_HBA_RESET & 0xff;
673 			ctio->ct_header.rqs_entry_type = RQSTYPE_CTIO;
674 		}
675 		isp_async(isp, ISPASYNC_TARGET_ACTION, local);
676 	}
677 	for (tmp = 0; tmp < isp->isp_nchan; tmp++) {
678 		ISP_MEMZERO(&notify, sizeof (isp_notify_t));
679 		notify.nt_ncode = NT_HBA_RESET;
680 		notify.nt_hba = isp;
681 		notify.nt_wwn = INI_ANY;
682 		notify.nt_nphdl = NIL_HANDLE;
683 		notify.nt_sid = PORT_ANY;
684 		notify.nt_did = PORT_ANY;
685 		notify.nt_tgt = TGT_ANY;
686 		notify.nt_channel = tmp;
687 		notify.nt_lun = LUN_ANY;
688 		notify.nt_tagval = TAG_ANY;
689 		isp_async(isp, ISPASYNC_TARGET_NOTIFY, &notify);
690 	}
691 #endif
692 }
693 
694 void
695 isp_shutdown(ispsoftc_t *isp)
696 {
697 	if (IS_FC(isp)) {
698 		if (IS_24XX(isp)) {
699 			ISP_WRITE(isp, BIU2400_ICR, 0);
700 			ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_PAUSE);
701 		} else {
702 			ISP_WRITE(isp, BIU_ICR, 0);
703 			ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE);
704 			ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS);
705 			ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET);
706 			ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS);
707 			ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL);
708 			ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS);
709 		}
710 	} else {
711 		ISP_WRITE(isp, BIU_ICR, 0);
712 		ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE);
713 	}
714 }
715 
716 /*
717  * Functions to move stuff to a form that the QLogic RISC engine understands
718  * and functions to move stuff back to a form the processor understands.
719  *
720  * Each platform is required to provide the 8, 16 and 32 bit
721  * swizzle and unswizzle macros (ISP_IOX{PUT|GET}_{8,16,32})
722  *
723  * The assumption is that swizzling and unswizzling is mostly done 'in place'
724  * (with a few exceptions for efficiency).
725  */
726 
727 #define	ISP_IS_SBUS(isp)	(ISP_SBUS_SUPPORTED && (isp)->isp_bustype == ISP_BT_SBUS)
728 
729 #define	ASIZE(x)	(sizeof (x) / sizeof (x[0]))
730 /*
731  * Swizzle/Copy Functions
732  */
733 void
734 isp_put_hdr(ispsoftc_t *isp, isphdr_t *hpsrc, isphdr_t *hpdst)
735 {
736 	if (ISP_IS_SBUS(isp)) {
737 		ISP_IOXPUT_8(isp, hpsrc->rqs_entry_type, &hpdst->rqs_entry_count);
738 		ISP_IOXPUT_8(isp, hpsrc->rqs_entry_count, &hpdst->rqs_entry_type);
739 		ISP_IOXPUT_8(isp, hpsrc->rqs_seqno, &hpdst->rqs_flags);
740 		ISP_IOXPUT_8(isp, hpsrc->rqs_flags, &hpdst->rqs_seqno);
741 	} else {
742 		ISP_IOXPUT_8(isp, hpsrc->rqs_entry_type, &hpdst->rqs_entry_type);
743 		ISP_IOXPUT_8(isp, hpsrc->rqs_entry_count, &hpdst->rqs_entry_count);
744 		ISP_IOXPUT_8(isp, hpsrc->rqs_seqno, &hpdst->rqs_seqno);
745 		ISP_IOXPUT_8(isp, hpsrc->rqs_flags, &hpdst->rqs_flags);
746 	}
747 }
748 
749 void
750 isp_get_hdr(ispsoftc_t *isp, isphdr_t *hpsrc, isphdr_t *hpdst)
751 {
752 	if (ISP_IS_SBUS(isp)) {
753 		ISP_IOXGET_8(isp, &hpsrc->rqs_entry_type, hpdst->rqs_entry_count);
754 		ISP_IOXGET_8(isp, &hpsrc->rqs_entry_count, hpdst->rqs_entry_type);
755 		ISP_IOXGET_8(isp, &hpsrc->rqs_seqno, hpdst->rqs_flags);
756 		ISP_IOXGET_8(isp, &hpsrc->rqs_flags, hpdst->rqs_seqno);
757 	} else {
758 		ISP_IOXGET_8(isp, &hpsrc->rqs_entry_type, hpdst->rqs_entry_type);
759 		ISP_IOXGET_8(isp, &hpsrc->rqs_entry_count, hpdst->rqs_entry_count);
760 		ISP_IOXGET_8(isp, &hpsrc->rqs_seqno, hpdst->rqs_seqno);
761 		ISP_IOXGET_8(isp, &hpsrc->rqs_flags, hpdst->rqs_flags);
762 	}
763 }
764 
765 int
766 isp_get_response_type(ispsoftc_t *isp, isphdr_t *hp)
767 {
768 	uint8_t type;
769 	if (ISP_IS_SBUS(isp)) {
770 		ISP_IOXGET_8(isp, &hp->rqs_entry_count, type);
771 	} else {
772 		ISP_IOXGET_8(isp, &hp->rqs_entry_type, type);
773 	}
774 	return ((int)type);
775 }
776 
777 void
778 isp_put_request(ispsoftc_t *isp, ispreq_t *rqsrc, ispreq_t *rqdst)
779 {
780 	int i;
781 	isp_put_hdr(isp, &rqsrc->req_header, &rqdst->req_header);
782 	ISP_IOXPUT_32(isp, rqsrc->req_handle, &rqdst->req_handle);
783 	if (ISP_IS_SBUS(isp)) {
784 		ISP_IOXPUT_8(isp, rqsrc->req_lun_trn, &rqdst->req_target);
785 		ISP_IOXPUT_8(isp, rqsrc->req_target, &rqdst->req_lun_trn);
786 	} else {
787 		ISP_IOXPUT_8(isp, rqsrc->req_lun_trn, &rqdst->req_lun_trn);
788 		ISP_IOXPUT_8(isp, rqsrc->req_target, &rqdst->req_target);
789 	}
790 	ISP_IOXPUT_16(isp, rqsrc->req_cdblen, &rqdst->req_cdblen);
791 	ISP_IOXPUT_16(isp, rqsrc->req_flags, &rqdst->req_flags);
792 	ISP_IOXPUT_16(isp, rqsrc->req_time, &rqdst->req_time);
793 	ISP_IOXPUT_16(isp, rqsrc->req_seg_count, &rqdst->req_seg_count);
794 	for (i = 0; i < ASIZE(rqsrc->req_cdb); i++) {
795 		ISP_IOXPUT_8(isp, rqsrc->req_cdb[i], &rqdst->req_cdb[i]);
796 	}
797 	for (i = 0; i < ISP_RQDSEG; i++) {
798 		ISP_IOXPUT_32(isp, rqsrc->req_dataseg[i].ds_base, &rqdst->req_dataseg[i].ds_base);
799 		ISP_IOXPUT_32(isp, rqsrc->req_dataseg[i].ds_count, &rqdst->req_dataseg[i].ds_count);
800 	}
801 }
802 
803 void
804 isp_put_marker(ispsoftc_t *isp, isp_marker_t *src, isp_marker_t *dst)
805 {
806 	int i;
807 	isp_put_hdr(isp, &src->mrk_header, &dst->mrk_header);
808 	ISP_IOXPUT_32(isp, src->mrk_handle, &dst->mrk_handle);
809 	if (ISP_IS_SBUS(isp)) {
810 		ISP_IOXPUT_8(isp, src->mrk_reserved0, &dst->mrk_target);
811 		ISP_IOXPUT_8(isp, src->mrk_target, &dst->mrk_reserved0);
812 	} else {
813 		ISP_IOXPUT_8(isp, src->mrk_reserved0, &dst->mrk_reserved0);
814 		ISP_IOXPUT_8(isp, src->mrk_target, &dst->mrk_target);
815 	}
816 	ISP_IOXPUT_16(isp, src->mrk_modifier, &dst->mrk_modifier);
817 	ISP_IOXPUT_16(isp, src->mrk_flags, &dst->mrk_flags);
818 	ISP_IOXPUT_16(isp, src->mrk_lun, &dst->mrk_lun);
819 	for (i = 0; i < ASIZE(src->mrk_reserved1); i++) {
820 		ISP_IOXPUT_8(isp, src->mrk_reserved1[i], &dst->mrk_reserved1[i]);
821 	}
822 }
823 
824 void
825 isp_put_marker_24xx(ispsoftc_t *isp, isp_marker_24xx_t *src, isp_marker_24xx_t *dst)
826 {
827 	int i;
828 	isp_put_hdr(isp, &src->mrk_header, &dst->mrk_header);
829 	ISP_IOXPUT_32(isp, src->mrk_handle, &dst->mrk_handle);
830 	ISP_IOXPUT_16(isp, src->mrk_nphdl, &dst->mrk_nphdl);
831 	ISP_IOXPUT_8(isp, src->mrk_modifier, &dst->mrk_modifier);
832 	ISP_IOXPUT_8(isp, src->mrk_reserved0, &dst->mrk_reserved0);
833 	ISP_IOXPUT_8(isp, src->mrk_reserved1, &dst->mrk_reserved1);
834 	ISP_IOXPUT_8(isp, src->mrk_vphdl, &dst->mrk_vphdl);
835 	ISP_IOXPUT_8(isp, src->mrk_reserved2, &dst->mrk_reserved2);
836 	for (i = 0; i < ASIZE(src->mrk_lun); i++) {
837 		ISP_IOXPUT_8(isp, src->mrk_lun[i], &dst->mrk_lun[i]);
838 	}
839 	for (i = 0; i < ASIZE(src->mrk_reserved3); i++) {
840 		ISP_IOXPUT_8(isp, src->mrk_reserved3[i], &dst->mrk_reserved3[i]);
841 	}
842 }
843 
844 void
845 isp_put_request_t2(ispsoftc_t *isp, ispreqt2_t *src, ispreqt2_t *dst)
846 {
847 	int i;
848 	isp_put_hdr(isp, &src->req_header, &dst->req_header);
849 	ISP_IOXPUT_32(isp, src->req_handle, &dst->req_handle);
850 	ISP_IOXPUT_8(isp, src->req_lun_trn, &dst->req_lun_trn);
851 	ISP_IOXPUT_8(isp, src->req_target, &dst->req_target);
852 	ISP_IOXPUT_16(isp, src->req_scclun, &dst->req_scclun);
853 	ISP_IOXPUT_16(isp, src->req_flags,  &dst->req_flags);
854 	ISP_IOXPUT_16(isp, src->req_reserved, &dst->req_reserved);
855 	ISP_IOXPUT_16(isp, src->req_time, &dst->req_time);
856 	ISP_IOXPUT_16(isp, src->req_seg_count, &dst->req_seg_count);
857 	for (i = 0; i < ASIZE(src->req_cdb); i++) {
858 		ISP_IOXPUT_8(isp, src->req_cdb[i], &dst->req_cdb[i]);
859 	}
860 	ISP_IOXPUT_32(isp, src->req_totalcnt, &dst->req_totalcnt);
861 	for (i = 0; i < ISP_RQDSEG_T2; i++) {
862 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_base, &dst->req_dataseg[i].ds_base);
863 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_count, &dst->req_dataseg[i].ds_count);
864 	}
865 }
866 
867 void
868 isp_put_request_t2e(ispsoftc_t *isp, ispreqt2e_t *src, ispreqt2e_t *dst)
869 {
870 	int i;
871 	isp_put_hdr(isp, &src->req_header, &dst->req_header);
872 	ISP_IOXPUT_32(isp, src->req_handle, &dst->req_handle);
873 	ISP_IOXPUT_16(isp, src->req_target, &dst->req_target);
874 	ISP_IOXPUT_16(isp, src->req_scclun, &dst->req_scclun);
875 	ISP_IOXPUT_16(isp, src->req_flags,  &dst->req_flags);
876 	ISP_IOXPUT_16(isp, src->req_reserved, &dst->req_reserved);
877 	ISP_IOXPUT_16(isp, src->req_time, &dst->req_time);
878 	ISP_IOXPUT_16(isp, src->req_seg_count, &dst->req_seg_count);
879 	for (i = 0; i < ASIZE(src->req_cdb); i++) {
880 		ISP_IOXPUT_8(isp, src->req_cdb[i], &dst->req_cdb[i]);
881 	}
882 	ISP_IOXPUT_32(isp, src->req_totalcnt, &dst->req_totalcnt);
883 	for (i = 0; i < ISP_RQDSEG_T2; i++) {
884 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_base, &dst->req_dataseg[i].ds_base);
885 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_count, &dst->req_dataseg[i].ds_count);
886 	}
887 }
888 
889 void
890 isp_put_request_t3(ispsoftc_t *isp, ispreqt3_t *src, ispreqt3_t *dst)
891 {
892 	int i;
893 	isp_put_hdr(isp, &src->req_header, &dst->req_header);
894 	ISP_IOXPUT_32(isp, src->req_handle, &dst->req_handle);
895 	ISP_IOXPUT_8(isp, src->req_lun_trn, &dst->req_lun_trn);
896 	ISP_IOXPUT_8(isp, src->req_target, &dst->req_target);
897 	ISP_IOXPUT_16(isp, src->req_scclun, &dst->req_scclun);
898 	ISP_IOXPUT_16(isp, src->req_flags,  &dst->req_flags);
899 	ISP_IOXPUT_16(isp, src->req_reserved, &dst->req_reserved);
900 	ISP_IOXPUT_16(isp, src->req_time, &dst->req_time);
901 	ISP_IOXPUT_16(isp, src->req_seg_count, &dst->req_seg_count);
902 	for (i = 0; i < ASIZE(src->req_cdb); i++) {
903 		ISP_IOXPUT_8(isp, src->req_cdb[i], &dst->req_cdb[i]);
904 	}
905 	ISP_IOXPUT_32(isp, src->req_totalcnt, &dst->req_totalcnt);
906 	for (i = 0; i < ISP_RQDSEG_T3; i++) {
907 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_base, &dst->req_dataseg[i].ds_base);
908 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_basehi, &dst->req_dataseg[i].ds_basehi);
909 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_count, &dst->req_dataseg[i].ds_count);
910 	}
911 }
912 
913 void
914 isp_put_request_t3e(ispsoftc_t *isp, ispreqt3e_t *src, ispreqt3e_t *dst)
915 {
916 	int i;
917 	isp_put_hdr(isp, &src->req_header, &dst->req_header);
918 	ISP_IOXPUT_32(isp, src->req_handle, &dst->req_handle);
919 	ISP_IOXPUT_16(isp, src->req_target, &dst->req_target);
920 	ISP_IOXPUT_16(isp, src->req_scclun, &dst->req_scclun);
921 	ISP_IOXPUT_16(isp, src->req_flags,  &dst->req_flags);
922 	ISP_IOXPUT_16(isp, src->req_reserved, &dst->req_reserved);
923 	ISP_IOXPUT_16(isp, src->req_time, &dst->req_time);
924 	ISP_IOXPUT_16(isp, src->req_seg_count, &dst->req_seg_count);
925 	for (i = 0; i < ASIZE(src->req_cdb); i++) {
926 		ISP_IOXPUT_8(isp, src->req_cdb[i], &dst->req_cdb[i]);
927 	}
928 	ISP_IOXPUT_32(isp, src->req_totalcnt, &dst->req_totalcnt);
929 	for (i = 0; i < ISP_RQDSEG_T3; i++) {
930 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_base, &dst->req_dataseg[i].ds_base);
931 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_basehi, &dst->req_dataseg[i].ds_basehi);
932 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_count, &dst->req_dataseg[i].ds_count);
933 	}
934 }
935 
936 void
937 isp_put_extended_request(ispsoftc_t *isp, ispextreq_t *src, ispextreq_t *dst)
938 {
939 	int i;
940 	isp_put_hdr(isp, &src->req_header, &dst->req_header);
941 	ISP_IOXPUT_32(isp, src->req_handle, &dst->req_handle);
942 	if (ISP_IS_SBUS(isp)) {
943 		ISP_IOXPUT_8(isp, src->req_lun_trn, &dst->req_target);
944 		ISP_IOXPUT_8(isp, src->req_target, &dst->req_lun_trn);
945 	} else {
946 		ISP_IOXPUT_8(isp, src->req_lun_trn, &dst->req_lun_trn);
947 		ISP_IOXPUT_8(isp, src->req_target, &dst->req_target);
948 	}
949 	ISP_IOXPUT_16(isp, src->req_cdblen, &dst->req_cdblen);
950 	ISP_IOXPUT_16(isp, src->req_flags, &dst->req_flags);
951 	ISP_IOXPUT_16(isp, src->req_time, &dst->req_time);
952 	ISP_IOXPUT_16(isp, src->req_seg_count, &dst->req_seg_count);
953 	for (i = 0; i < ASIZE(src->req_cdb); i++) {
954 		ISP_IOXPUT_8(isp, src->req_cdb[i], &dst->req_cdb[i]);
955 	}
956 }
957 
958 void
959 isp_put_request_t7(ispsoftc_t *isp, ispreqt7_t *src, ispreqt7_t *dst)
960 {
961 	int i;
962 	uint32_t *a, *b;
963 
964 	isp_put_hdr(isp, &src->req_header, &dst->req_header);
965 	ISP_IOXPUT_32(isp, src->req_handle, &dst->req_handle);
966 	ISP_IOXPUT_16(isp, src->req_nphdl, &dst->req_nphdl);
967 	ISP_IOXPUT_16(isp, src->req_time, &dst->req_time);
968 	ISP_IOXPUT_16(isp, src->req_seg_count, &dst->req_seg_count);
969 	ISP_IOXPUT_16(isp, src->req_reserved, &dst->req_reserved);
970 	a = (uint32_t *) src->req_lun;
971 	b = (uint32_t *) dst->req_lun;
972 	for (i = 0; i < (ASIZE(src->req_lun) >> 2); i++ ) {
973 		*b++ = ISP_SWAP32(isp, *a++);
974 	}
975 	ISP_IOXPUT_8(isp, src->req_alen_datadir, &dst->req_alen_datadir);
976 	ISP_IOXPUT_8(isp, src->req_task_management, &dst->req_task_management);
977 	ISP_IOXPUT_8(isp, src->req_task_attribute, &dst->req_task_attribute);
978 	ISP_IOXPUT_8(isp, src->req_crn, &dst->req_crn);
979 	a = (uint32_t *) src->req_cdb;
980 	b = (uint32_t *) dst->req_cdb;
981 	for (i = 0; i < (ASIZE(src->req_cdb) >> 2); i++) {
982 		*b++ = ISP_SWAP32(isp, *a++);
983 	}
984 	ISP_IOXPUT_32(isp, src->req_dl, &dst->req_dl);
985 	ISP_IOXPUT_16(isp, src->req_tidlo, &dst->req_tidlo);
986 	ISP_IOXPUT_8(isp, src->req_tidhi, &dst->req_tidhi);
987 	ISP_IOXPUT_8(isp, src->req_vpidx, &dst->req_vpidx);
988 	ISP_IOXPUT_32(isp, src->req_dataseg.ds_base, &dst->req_dataseg.ds_base);
989 	ISP_IOXPUT_32(isp, src->req_dataseg.ds_basehi, &dst->req_dataseg.ds_basehi);
990 	ISP_IOXPUT_32(isp, src->req_dataseg.ds_count, &dst->req_dataseg.ds_count);
991 }
992 
993 void
994 isp_put_24xx_tmf(ispsoftc_t *isp, isp24xx_tmf_t *src, isp24xx_tmf_t *dst)
995 {
996 	int i;
997 	uint32_t *a, *b;
998 
999 	isp_put_hdr(isp, &src->tmf_header, &dst->tmf_header);
1000 	ISP_IOXPUT_32(isp, src->tmf_handle, &dst->tmf_handle);
1001 	ISP_IOXPUT_16(isp, src->tmf_nphdl, &dst->tmf_nphdl);
1002 	ISP_IOXPUT_16(isp, src->tmf_delay, &dst->tmf_delay);
1003 	ISP_IOXPUT_16(isp, src->tmf_timeout, &dst->tmf_timeout);
1004 	for (i = 0; i < ASIZE(src->tmf_reserved0); i++) {
1005 		ISP_IOXPUT_8(isp, src->tmf_reserved0[i], &dst->tmf_reserved0[i]);
1006 	}
1007 	a = (uint32_t *) src->tmf_lun;
1008 	b = (uint32_t *) dst->tmf_lun;
1009 	for (i = 0; i < (ASIZE(src->tmf_lun) >> 2); i++ ) {
1010 		*b++ = ISP_SWAP32(isp, *a++);
1011 	}
1012 	ISP_IOXPUT_32(isp, src->tmf_flags, &dst->tmf_flags);
1013 	for (i = 0; i < ASIZE(src->tmf_reserved1); i++) {
1014 		ISP_IOXPUT_8(isp, src->tmf_reserved1[i], &dst->tmf_reserved1[i]);
1015 	}
1016 	ISP_IOXPUT_16(isp, src->tmf_tidlo, &dst->tmf_tidlo);
1017 	ISP_IOXPUT_8(isp, src->tmf_tidhi, &dst->tmf_tidhi);
1018 	ISP_IOXPUT_8(isp, src->tmf_vpidx, &dst->tmf_vpidx);
1019 	for (i = 0; i < ASIZE(src->tmf_reserved2); i++) {
1020 		ISP_IOXPUT_8(isp, src->tmf_reserved2[i], &dst->tmf_reserved2[i]);
1021 	}
1022 }
1023 
1024 void
1025 isp_put_24xx_abrt(ispsoftc_t *isp, isp24xx_abrt_t *src, isp24xx_abrt_t *dst)
1026 {
1027 	int i;
1028 	isp_put_hdr(isp, &src->abrt_header, &dst->abrt_header);
1029 	ISP_IOXPUT_32(isp, src->abrt_handle, &dst->abrt_handle);
1030 	ISP_IOXPUT_16(isp, src->abrt_nphdl, &dst->abrt_nphdl);
1031 	ISP_IOXPUT_16(isp, src->abrt_options, &dst->abrt_options);
1032 	ISP_IOXPUT_32(isp, src->abrt_cmd_handle, &dst->abrt_cmd_handle);
1033 	for (i = 0; i < ASIZE(src->abrt_reserved); i++) {
1034 		ISP_IOXPUT_8(isp, src->abrt_reserved[i], &dst->abrt_reserved[i]);
1035 	}
1036 	ISP_IOXPUT_16(isp, src->abrt_tidlo, &dst->abrt_tidlo);
1037 	ISP_IOXPUT_8(isp, src->abrt_tidhi, &dst->abrt_tidhi);
1038 	ISP_IOXPUT_8(isp, src->abrt_vpidx, &dst->abrt_vpidx);
1039 	for (i = 0; i < ASIZE(src->abrt_reserved1); i++) {
1040 		ISP_IOXPUT_8(isp, src->abrt_reserved1[i], &dst->abrt_reserved1[i]);
1041 	}
1042 }
1043 
1044 void
1045 isp_put_cont_req(ispsoftc_t *isp, ispcontreq_t *src, ispcontreq_t *dst)
1046 {
1047 	int i;
1048 	isp_put_hdr(isp, &src->req_header, &dst->req_header);
1049 	for (i = 0; i < ISP_CDSEG; i++) {
1050 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_base, &dst->req_dataseg[i].ds_base);
1051 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_count, &dst->req_dataseg[i].ds_count);
1052 	}
1053 }
1054 
1055 void
1056 isp_put_cont64_req(ispsoftc_t *isp, ispcontreq64_t *src, ispcontreq64_t *dst)
1057 {
1058 	int i;
1059 	isp_put_hdr(isp, &src->req_header, &dst->req_header);
1060 	for (i = 0; i < ISP_CDSEG64; i++) {
1061 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_base, &dst->req_dataseg[i].ds_base);
1062 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_basehi, &dst->req_dataseg[i].ds_basehi);
1063 		ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_count, &dst->req_dataseg[i].ds_count);
1064 	}
1065 }
1066 
1067 void
1068 isp_get_response(ispsoftc_t *isp, ispstatusreq_t *src, ispstatusreq_t *dst)
1069 {
1070 	int i;
1071 	isp_get_hdr(isp, &src->req_header, &dst->req_header);
1072 	ISP_IOXGET_32(isp, &src->req_handle, dst->req_handle);
1073 	ISP_IOXGET_16(isp, &src->req_scsi_status, dst->req_scsi_status);
1074 	ISP_IOXGET_16(isp, &src->req_completion_status, dst->req_completion_status);
1075 	ISP_IOXGET_16(isp, &src->req_state_flags, dst->req_state_flags);
1076 	ISP_IOXGET_16(isp, &src->req_status_flags, dst->req_status_flags);
1077 	ISP_IOXGET_16(isp, &src->req_time, dst->req_time);
1078 	ISP_IOXGET_16(isp, &src->req_sense_len, dst->req_sense_len);
1079 	ISP_IOXGET_32(isp, &src->req_resid, dst->req_resid);
1080 	for (i = 0; i < 8; i++) {
1081 		ISP_IOXGET_8(isp, &src->req_response[i], dst->req_response[i]);
1082 	}
1083 	for (i = 0; i < 32; i++) {
1084 		ISP_IOXGET_8(isp, &src->req_sense_data[i], dst->req_sense_data[i]);
1085 	}
1086 }
1087 
1088 void
1089 isp_get_24xx_response(ispsoftc_t *isp, isp24xx_statusreq_t *src, isp24xx_statusreq_t *dst)
1090 {
1091 	int i;
1092 	uint32_t *s, *d;
1093 
1094 	isp_get_hdr(isp, &src->req_header, &dst->req_header);
1095 	ISP_IOXGET_32(isp, &src->req_handle, dst->req_handle);
1096 	ISP_IOXGET_16(isp, &src->req_completion_status, dst->req_completion_status);
1097 	ISP_IOXGET_16(isp, &src->req_oxid, dst->req_oxid);
1098 	ISP_IOXGET_32(isp, &src->req_resid, dst->req_resid);
1099 	ISP_IOXGET_16(isp, &src->req_reserved0, dst->req_reserved0);
1100 	ISP_IOXGET_16(isp, &src->req_state_flags, dst->req_state_flags);
1101 	ISP_IOXGET_16(isp, &src->req_reserved1, dst->req_reserved1);
1102 	ISP_IOXGET_16(isp, &src->req_scsi_status, dst->req_scsi_status);
1103 	ISP_IOXGET_32(isp, &src->req_fcp_residual, dst->req_fcp_residual);
1104 	ISP_IOXGET_32(isp, &src->req_sense_len, dst->req_sense_len);
1105 	ISP_IOXGET_32(isp, &src->req_response_len, dst->req_response_len);
1106 	s = (uint32_t *)src->req_rsp_sense;
1107 	d = (uint32_t *)dst->req_rsp_sense;
1108 	for (i = 0; i < (ASIZE(src->req_rsp_sense) >> 2); i++) {
1109 		d[i] = ISP_SWAP32(isp, s[i]);
1110 	}
1111 }
1112 
1113 void
1114 isp_get_24xx_abrt(ispsoftc_t *isp, isp24xx_abrt_t *src, isp24xx_abrt_t *dst)
1115 {
1116 	int i;
1117 	isp_get_hdr(isp, &src->abrt_header, &dst->abrt_header);
1118 	ISP_IOXGET_32(isp, &src->abrt_handle, dst->abrt_handle);
1119 	ISP_IOXGET_16(isp, &src->abrt_nphdl, dst->abrt_nphdl);
1120 	ISP_IOXGET_16(isp, &src->abrt_options, dst->abrt_options);
1121 	ISP_IOXGET_32(isp, &src->abrt_cmd_handle, dst->abrt_cmd_handle);
1122 	for (i = 0; i < ASIZE(src->abrt_reserved); i++) {
1123 		ISP_IOXGET_8(isp, &src->abrt_reserved[i], dst->abrt_reserved[i]);
1124 	}
1125 	ISP_IOXGET_16(isp, &src->abrt_tidlo, dst->abrt_tidlo);
1126 	ISP_IOXGET_8(isp, &src->abrt_tidhi, dst->abrt_tidhi);
1127 	ISP_IOXGET_8(isp, &src->abrt_vpidx, dst->abrt_vpidx);
1128 	for (i = 0; i < ASIZE(src->abrt_reserved1); i++) {
1129 		ISP_IOXGET_8(isp, &src->abrt_reserved1[i], dst->abrt_reserved1[i]);
1130 	}
1131 }
1132 
1133 
1134 void
1135 isp_get_rio1(ispsoftc_t *isp, isp_rio1_t *r1src, isp_rio1_t *r1dst)
1136 {
1137 	const int lim = sizeof (r1dst->req_handles) / sizeof (r1dst->req_handles[0]);
1138 	int i;
1139 	isp_get_hdr(isp, &r1src->req_header, &r1dst->req_header);
1140 	if (r1dst->req_header.rqs_seqno > lim) {
1141 		r1dst->req_header.rqs_seqno = lim;
1142 	}
1143 	for (i = 0; i < r1dst->req_header.rqs_seqno; i++) {
1144 		ISP_IOXGET_32(isp, &r1src->req_handles[i], r1dst->req_handles[i]);
1145 	}
1146 	while (i < lim) {
1147 		r1dst->req_handles[i++] = 0;
1148 	}
1149 }
1150 
1151 void
1152 isp_get_rio2(ispsoftc_t *isp, isp_rio2_t *r2src, isp_rio2_t *r2dst)
1153 {
1154 	const int lim = sizeof (r2dst->req_handles) / sizeof (r2dst->req_handles[0]);
1155 	int i;
1156 
1157 	isp_get_hdr(isp, &r2src->req_header, &r2dst->req_header);
1158 	if (r2dst->req_header.rqs_seqno > lim) {
1159 		r2dst->req_header.rqs_seqno = lim;
1160 	}
1161 	for (i = 0; i < r2dst->req_header.rqs_seqno; i++) {
1162 		ISP_IOXGET_16(isp, &r2src->req_handles[i], r2dst->req_handles[i]);
1163 	}
1164 	while (i < lim) {
1165 		r2dst->req_handles[i++] = 0;
1166 	}
1167 }
1168 
1169 void
1170 isp_put_icb(ispsoftc_t *isp, isp_icb_t *src, isp_icb_t *dst)
1171 {
1172 	int i;
1173 	if (ISP_IS_SBUS(isp)) {
1174 		ISP_IOXPUT_8(isp, src->icb_version, &dst->icb_reserved0);
1175 		ISP_IOXPUT_8(isp, src->icb_reserved0, &dst->icb_version);
1176 	} else {
1177 		ISP_IOXPUT_8(isp, src->icb_version, &dst->icb_version);
1178 		ISP_IOXPUT_8(isp, src->icb_reserved0, &dst->icb_reserved0);
1179 	}
1180 	ISP_IOXPUT_16(isp, src->icb_fwoptions, &dst->icb_fwoptions);
1181 	ISP_IOXPUT_16(isp, src->icb_maxfrmlen, &dst->icb_maxfrmlen);
1182 	ISP_IOXPUT_16(isp, src->icb_maxalloc, &dst->icb_maxalloc);
1183 	ISP_IOXPUT_16(isp, src->icb_execthrottle, &dst->icb_execthrottle);
1184 	if (ISP_IS_SBUS(isp)) {
1185 		ISP_IOXPUT_8(isp, src->icb_retry_count, &dst->icb_retry_delay);
1186 		ISP_IOXPUT_8(isp, src->icb_retry_delay, &dst->icb_retry_count);
1187 	} else {
1188 		ISP_IOXPUT_8(isp, src->icb_retry_count, &dst->icb_retry_count);
1189 		ISP_IOXPUT_8(isp, src->icb_retry_delay, &dst->icb_retry_delay);
1190 	}
1191 	for (i = 0; i < 8; i++) {
1192 		ISP_IOXPUT_8(isp, src->icb_portname[i], &dst->icb_portname[i]);
1193 	}
1194 	ISP_IOXPUT_16(isp, src->icb_hardaddr, &dst->icb_hardaddr);
1195 	if (ISP_IS_SBUS(isp)) {
1196 		ISP_IOXPUT_8(isp, src->icb_iqdevtype, &dst->icb_logintime);
1197 		ISP_IOXPUT_8(isp, src->icb_logintime, &dst->icb_iqdevtype);
1198 	} else {
1199 		ISP_IOXPUT_8(isp, src->icb_iqdevtype, &dst->icb_iqdevtype);
1200 		ISP_IOXPUT_8(isp, src->icb_logintime, &dst->icb_logintime);
1201 	}
1202 	for (i = 0; i < 8; i++) {
1203 		ISP_IOXPUT_8(isp, src->icb_nodename[i], &dst->icb_nodename[i]);
1204 	}
1205 	ISP_IOXPUT_16(isp, src->icb_rqstout, &dst->icb_rqstout);
1206 	ISP_IOXPUT_16(isp, src->icb_rspnsin, &dst->icb_rspnsin);
1207 	ISP_IOXPUT_16(isp, src->icb_rqstqlen, &dst->icb_rqstqlen);
1208 	ISP_IOXPUT_16(isp, src->icb_rsltqlen, &dst->icb_rsltqlen);
1209 	for (i = 0; i < 4; i++) {
1210 		ISP_IOXPUT_16(isp, src->icb_rqstaddr[i], &dst->icb_rqstaddr[i]);
1211 	}
1212 	for (i = 0; i < 4; i++) {
1213 		ISP_IOXPUT_16(isp, src->icb_respaddr[i], &dst->icb_respaddr[i]);
1214 	}
1215 	ISP_IOXPUT_16(isp, src->icb_lunenables, &dst->icb_lunenables);
1216 	if (ISP_IS_SBUS(isp)) {
1217 		ISP_IOXPUT_8(isp, src->icb_ccnt, &dst->icb_icnt);
1218 		ISP_IOXPUT_8(isp, src->icb_icnt, &dst->icb_ccnt);
1219 	} else {
1220 		ISP_IOXPUT_8(isp, src->icb_ccnt, &dst->icb_ccnt);
1221 		ISP_IOXPUT_8(isp, src->icb_icnt, &dst->icb_icnt);
1222 	}
1223 	ISP_IOXPUT_16(isp, src->icb_lunetimeout, &dst->icb_lunetimeout);
1224 	ISP_IOXPUT_16(isp, src->icb_reserved1, &dst->icb_reserved1);
1225 	ISP_IOXPUT_16(isp, src->icb_xfwoptions, &dst->icb_xfwoptions);
1226 	if (ISP_IS_SBUS(isp)) {
1227 		ISP_IOXPUT_8(isp, src->icb_racctimer, &dst->icb_idelaytimer);
1228 		ISP_IOXPUT_8(isp, src->icb_idelaytimer, &dst->icb_racctimer);
1229 	} else {
1230 		ISP_IOXPUT_8(isp, src->icb_racctimer, &dst->icb_racctimer);
1231 		ISP_IOXPUT_8(isp, src->icb_idelaytimer, &dst->icb_idelaytimer);
1232 	}
1233 	ISP_IOXPUT_16(isp, src->icb_zfwoptions, &dst->icb_zfwoptions);
1234 }
1235 
1236 void
1237 isp_put_icb_2400(ispsoftc_t *isp, isp_icb_2400_t *src, isp_icb_2400_t *dst)
1238 {
1239 	int i;
1240 	ISP_IOXPUT_16(isp, src->icb_version, &dst->icb_version);
1241 	ISP_IOXPUT_16(isp, src->icb_reserved0, &dst->icb_reserved0);
1242 	ISP_IOXPUT_16(isp, src->icb_maxfrmlen, &dst->icb_maxfrmlen);
1243 	ISP_IOXPUT_16(isp, src->icb_execthrottle, &dst->icb_execthrottle);
1244 	ISP_IOXPUT_16(isp, src->icb_xchgcnt, &dst->icb_xchgcnt);
1245 	ISP_IOXPUT_16(isp, src->icb_hardaddr, &dst->icb_hardaddr);
1246 	for (i = 0; i < 8; i++) {
1247 		ISP_IOXPUT_8(isp, src->icb_portname[i], &dst->icb_portname[i]);
1248 	}
1249 	for (i = 0; i < 8; i++) {
1250 		ISP_IOXPUT_8(isp, src->icb_nodename[i], &dst->icb_nodename[i]);
1251 	}
1252 	ISP_IOXPUT_16(isp, src->icb_rspnsin, &dst->icb_rspnsin);
1253 	ISP_IOXPUT_16(isp, src->icb_rqstout, &dst->icb_rqstout);
1254 	ISP_IOXPUT_16(isp, src->icb_retry_count, &dst->icb_retry_count);
1255 	ISP_IOXPUT_16(isp, src->icb_priout, &dst->icb_priout);
1256 	ISP_IOXPUT_16(isp, src->icb_rsltqlen, &dst->icb_rsltqlen);
1257 	ISP_IOXPUT_16(isp, src->icb_rqstqlen, &dst->icb_rqstqlen);
1258 	ISP_IOXPUT_16(isp, src->icb_ldn_nols, &dst->icb_ldn_nols);
1259 	ISP_IOXPUT_16(isp, src->icb_prqstqlen, &dst->icb_prqstqlen);
1260 	for (i = 0; i < 4; i++) {
1261 		ISP_IOXPUT_16(isp, src->icb_rqstaddr[i], &dst->icb_rqstaddr[i]);
1262 	}
1263 	for (i = 0; i < 4; i++) {
1264 		ISP_IOXPUT_16(isp, src->icb_respaddr[i], &dst->icb_respaddr[i]);
1265 	}
1266 	for (i = 0; i < 4; i++) {
1267 		ISP_IOXPUT_16(isp, src->icb_priaddr[i], &dst->icb_priaddr[i]);
1268 	}
1269 	for (i = 0; i < 4; i++) {
1270 		ISP_IOXPUT_16(isp, src->icb_reserved1[i], &dst->icb_reserved1[i]);
1271 	}
1272 	ISP_IOXPUT_16(isp, src->icb_atio_in, &dst->icb_atio_in);
1273 	ISP_IOXPUT_16(isp, src->icb_atioqlen, &dst->icb_atioqlen);
1274 	for (i = 0; i < 4; i++) {
1275 		ISP_IOXPUT_16(isp, src->icb_atioqaddr[i], &dst->icb_atioqaddr[i]);
1276 	}
1277 	ISP_IOXPUT_16(isp, src->icb_idelaytimer, &dst->icb_idelaytimer);
1278 	ISP_IOXPUT_16(isp, src->icb_logintime, &dst->icb_logintime);
1279 	ISP_IOXPUT_32(isp, src->icb_fwoptions1, &dst->icb_fwoptions1);
1280 	ISP_IOXPUT_32(isp, src->icb_fwoptions2, &dst->icb_fwoptions2);
1281 	ISP_IOXPUT_32(isp, src->icb_fwoptions3, &dst->icb_fwoptions3);
1282 	for (i = 0; i < 12; i++) {
1283 		ISP_IOXPUT_16(isp, src->icb_reserved2[i], &dst->icb_reserved2[i]);
1284 	}
1285 }
1286 
1287 void
1288 isp_put_icb_2400_vpinfo(ispsoftc_t *isp, isp_icb_2400_vpinfo_t *src, isp_icb_2400_vpinfo_t *dst)
1289 {
1290 	ISP_IOXPUT_16(isp, src->vp_count, &dst->vp_count);
1291 	ISP_IOXPUT_16(isp, src->vp_global_options, &dst->vp_global_options);
1292 }
1293 
1294 void
1295 isp_put_vp_port_info(ispsoftc_t *isp, vp_port_info_t *src, vp_port_info_t *dst)
1296 {
1297 	int i;
1298 	ISP_IOXPUT_16(isp, src->vp_port_status, &dst->vp_port_status);
1299 	ISP_IOXPUT_8(isp, src->vp_port_options, &dst->vp_port_options);
1300 	ISP_IOXPUT_8(isp, src->vp_port_loopid, &dst->vp_port_loopid);
1301 	for (i = 0; i < 8; i++) {
1302 		ISP_IOXPUT_8(isp, src->vp_port_portname[i], &dst->vp_port_portname[i]);
1303 	}
1304 	for (i = 0; i < 8; i++) {
1305 		ISP_IOXPUT_8(isp, src->vp_port_nodename[i], &dst->vp_port_nodename[i]);
1306 	}
1307 	/* we never *put* portid_lo/portid_hi */
1308 }
1309 
1310 void
1311 isp_get_vp_port_info(ispsoftc_t *isp, vp_port_info_t *src, vp_port_info_t *dst)
1312 {
1313 	int i;
1314 	ISP_IOXGET_16(isp, &src->vp_port_status, dst->vp_port_status);
1315 	ISP_IOXGET_8(isp, &src->vp_port_options, dst->vp_port_options);
1316 	ISP_IOXGET_8(isp, &src->vp_port_loopid, dst->vp_port_loopid);
1317 	for (i = 0; i < ASIZE(src->vp_port_portname); i++) {
1318 		ISP_IOXGET_8(isp, &src->vp_port_portname[i], dst->vp_port_portname[i]);
1319 	}
1320 	for (i = 0; i < ASIZE(src->vp_port_nodename); i++) {
1321 		ISP_IOXGET_8(isp, &src->vp_port_nodename[i], dst->vp_port_nodename[i]);
1322 	}
1323 	ISP_IOXGET_16(isp, &src->vp_port_portid_lo, dst->vp_port_portid_lo);
1324 	ISP_IOXGET_16(isp, &src->vp_port_portid_hi, dst->vp_port_portid_hi);
1325 }
1326 
1327 void
1328 isp_put_vp_ctrl_info(ispsoftc_t *isp, vp_ctrl_info_t *src, vp_ctrl_info_t *dst)
1329 {
1330 	int i;
1331 	isp_put_hdr(isp, &src->vp_ctrl_hdr, &dst->vp_ctrl_hdr);
1332 	ISP_IOXPUT_32(isp, src->vp_ctrl_handle, &dst->vp_ctrl_handle);
1333 	ISP_IOXPUT_16(isp, src->vp_ctrl_index_fail, &dst->vp_ctrl_index_fail);
1334 	ISP_IOXPUT_16(isp, src->vp_ctrl_status, &dst->vp_ctrl_status);
1335 	ISP_IOXPUT_16(isp, src->vp_ctrl_command, &dst->vp_ctrl_command);
1336 	ISP_IOXPUT_16(isp, src->vp_ctrl_vp_count, &dst->vp_ctrl_vp_count);
1337 	for (i = 0; i < ASIZE(src->vp_ctrl_idmap); i++) {
1338 		ISP_IOXPUT_16(isp, src->vp_ctrl_idmap[i], &dst->vp_ctrl_idmap[i]);
1339 	}
1340 	for (i = 0; i < ASIZE(src->vp_ctrl_reserved); i++) {
1341 		ISP_IOXPUT_8(isp, src->vp_ctrl_reserved[i], &dst->vp_ctrl_reserved[i]);
1342 	}
1343 }
1344 
1345 void
1346 isp_get_vp_ctrl_info(ispsoftc_t *isp, vp_ctrl_info_t *src, vp_ctrl_info_t *dst)
1347 {
1348 	int i;
1349 	isp_get_hdr(isp, &src->vp_ctrl_hdr, &dst->vp_ctrl_hdr);
1350 	ISP_IOXGET_32(isp, &src->vp_ctrl_handle, dst->vp_ctrl_handle);
1351 	ISP_IOXGET_16(isp, &src->vp_ctrl_index_fail, dst->vp_ctrl_index_fail);
1352 	ISP_IOXGET_16(isp, &src->vp_ctrl_status, dst->vp_ctrl_status);
1353 	ISP_IOXGET_16(isp, &src->vp_ctrl_command, dst->vp_ctrl_command);
1354 	ISP_IOXGET_16(isp, &src->vp_ctrl_vp_count, dst->vp_ctrl_vp_count);
1355 	for (i = 0; i < ASIZE(src->vp_ctrl_idmap); i++) {
1356 		ISP_IOXGET_16(isp, &src->vp_ctrl_idmap[i], dst->vp_ctrl_idmap[i]);
1357 	}
1358 	for (i = 0; i < ASIZE(src->vp_ctrl_reserved); i++) {
1359 		ISP_IOXGET_8(isp, &src->vp_ctrl_reserved[i], dst->vp_ctrl_reserved[i]);
1360 	}
1361 }
1362 
1363 void
1364 isp_put_vp_modify(ispsoftc_t *isp, vp_modify_t *src, vp_modify_t *dst)
1365 {
1366 	int i, j;
1367 	isp_put_hdr(isp, &src->vp_mod_hdr, &dst->vp_mod_hdr);
1368 	ISP_IOXPUT_32(isp, src->vp_mod_hdl, &dst->vp_mod_hdl);
1369 	ISP_IOXPUT_16(isp, src->vp_mod_reserved0, &dst->vp_mod_reserved0);
1370 	ISP_IOXPUT_16(isp, src->vp_mod_status, &dst->vp_mod_status);
1371 	ISP_IOXPUT_8(isp, src->vp_mod_cmd, &dst->vp_mod_cmd);
1372 	ISP_IOXPUT_8(isp, src->vp_mod_cnt, &dst->vp_mod_cnt);
1373 	ISP_IOXPUT_8(isp, src->vp_mod_idx0, &dst->vp_mod_idx0);
1374 	ISP_IOXPUT_8(isp, src->vp_mod_idx1, &dst->vp_mod_idx1);
1375 	for (i = 0; i < ASIZE(src->vp_mod_ports); i++) {
1376 		ISP_IOXPUT_8(isp, src->vp_mod_ports[i].options, &dst->vp_mod_ports[i].options);
1377 		ISP_IOXPUT_8(isp, src->vp_mod_ports[i].loopid, &dst->vp_mod_ports[i].loopid);
1378 		ISP_IOXPUT_16(isp, src->vp_mod_ports[i].reserved1, &dst->vp_mod_ports[i].reserved1);
1379 		for (j = 0; j < ASIZE(src->vp_mod_ports[i].wwpn); j++) {
1380 			ISP_IOXPUT_8(isp, src->vp_mod_ports[i].wwpn[j], &dst->vp_mod_ports[i].wwpn[j]);
1381 		}
1382 		for (j = 0; j < ASIZE(src->vp_mod_ports[i].wwnn); j++) {
1383 			ISP_IOXPUT_8(isp, src->vp_mod_ports[i].wwnn[j], &dst->vp_mod_ports[i].wwnn[j]);
1384 		}
1385 	}
1386 	for (i = 0; i < ASIZE(src->vp_mod_reserved2); i++) {
1387 		ISP_IOXPUT_8(isp, src->vp_mod_reserved2[i], &dst->vp_mod_reserved2[i]);
1388 	}
1389 }
1390 
1391 void
1392 isp_get_vp_modify(ispsoftc_t *isp, vp_modify_t *src, vp_modify_t *dst)
1393 {
1394 	int i, j;
1395 	isp_get_hdr(isp, &src->vp_mod_hdr, &dst->vp_mod_hdr);
1396 	ISP_IOXGET_32(isp, &src->vp_mod_hdl, dst->vp_mod_hdl);
1397 	ISP_IOXGET_16(isp, &src->vp_mod_reserved0, dst->vp_mod_reserved0);
1398 	ISP_IOXGET_16(isp, &src->vp_mod_status, dst->vp_mod_status);
1399 	ISP_IOXGET_8(isp, &src->vp_mod_cmd, dst->vp_mod_cmd);
1400 	ISP_IOXGET_8(isp, &src->vp_mod_cnt, dst->vp_mod_cnt);
1401 	ISP_IOXGET_8(isp, &src->vp_mod_idx0, dst->vp_mod_idx0);
1402 	ISP_IOXGET_8(isp, &src->vp_mod_idx1, dst->vp_mod_idx1);
1403 	for (i = 0; i < ASIZE(src->vp_mod_ports); i++) {
1404 		ISP_IOXGET_8(isp, &src->vp_mod_ports[i].options, dst->vp_mod_ports[i].options);
1405 		ISP_IOXGET_8(isp, &src->vp_mod_ports[i].loopid, dst->vp_mod_ports[i].loopid);
1406 		ISP_IOXGET_16(isp, &src->vp_mod_ports[i].reserved1, dst->vp_mod_ports[i].reserved1);
1407 		for (j = 0; j < ASIZE(src->vp_mod_ports[i].wwpn); j++) {
1408 			ISP_IOXGET_8(isp, &src->vp_mod_ports[i].wwpn[j], dst->vp_mod_ports[i].wwpn[j]);
1409 		}
1410 		for (j = 0; j < ASIZE(src->vp_mod_ports[i].wwnn); j++) {
1411 			ISP_IOXGET_8(isp, &src->vp_mod_ports[i].wwnn[j], dst->vp_mod_ports[i].wwnn[j]);
1412 		}
1413 	}
1414 	for (i = 0; i < ASIZE(src->vp_mod_reserved2); i++) {
1415 		ISP_IOXGET_8(isp, &src->vp_mod_reserved2[i], dst->vp_mod_reserved2[i]);
1416 	}
1417 }
1418 
1419 void
1420 isp_get_pdb_21xx(ispsoftc_t *isp, isp_pdb_21xx_t *src, isp_pdb_21xx_t *dst)
1421 {
1422 	int i;
1423 	ISP_IOXGET_16(isp, &src->pdb_options, dst->pdb_options);
1424         ISP_IOXGET_8(isp, &src->pdb_mstate, dst->pdb_mstate);
1425         ISP_IOXGET_8(isp, &src->pdb_sstate, dst->pdb_sstate);
1426 	for (i = 0; i < 4; i++) {
1427 		ISP_IOXGET_8(isp, &src->pdb_hardaddr_bits[i], dst->pdb_hardaddr_bits[i]);
1428 	}
1429 	for (i = 0; i < 4; i++) {
1430 		ISP_IOXGET_8(isp, &src->pdb_portid_bits[i], dst->pdb_portid_bits[i]);
1431 	}
1432 	for (i = 0; i < 8; i++) {
1433 		ISP_IOXGET_8(isp, &src->pdb_nodename[i], dst->pdb_nodename[i]);
1434 	}
1435 	for (i = 0; i < 8; i++) {
1436 		ISP_IOXGET_8(isp, &src->pdb_portname[i], dst->pdb_portname[i]);
1437 	}
1438 	ISP_IOXGET_16(isp, &src->pdb_execthrottle, dst->pdb_execthrottle);
1439 	ISP_IOXGET_16(isp, &src->pdb_exec_count, dst->pdb_exec_count);
1440 	ISP_IOXGET_8(isp, &src->pdb_retry_count, dst->pdb_retry_count);
1441 	ISP_IOXGET_8(isp, &src->pdb_retry_delay, dst->pdb_retry_delay);
1442 	ISP_IOXGET_16(isp, &src->pdb_resalloc, dst->pdb_resalloc);
1443 	ISP_IOXGET_16(isp, &src->pdb_curalloc, dst->pdb_curalloc);
1444 	ISP_IOXGET_16(isp, &src->pdb_qhead, dst->pdb_qhead);
1445 	ISP_IOXGET_16(isp, &src->pdb_qtail, dst->pdb_qtail);
1446 	ISP_IOXGET_16(isp, &src->pdb_tl_next, dst->pdb_tl_next);
1447 	ISP_IOXGET_16(isp, &src->pdb_tl_last, dst->pdb_tl_last);
1448 	ISP_IOXGET_16(isp, &src->pdb_features, dst->pdb_features);
1449 	ISP_IOXGET_16(isp, &src->pdb_pconcurrnt, dst->pdb_pconcurrnt);
1450 	ISP_IOXGET_16(isp, &src->pdb_roi, dst->pdb_roi);
1451 	ISP_IOXGET_8(isp, &src->pdb_target, dst->pdb_target);
1452 	ISP_IOXGET_8(isp, &src->pdb_initiator, dst->pdb_initiator);
1453 	ISP_IOXGET_16(isp, &src->pdb_rdsiz, dst->pdb_rdsiz);
1454 	ISP_IOXGET_16(isp, &src->pdb_ncseq, dst->pdb_ncseq);
1455 	ISP_IOXGET_16(isp, &src->pdb_noseq, dst->pdb_noseq);
1456 	ISP_IOXGET_16(isp, &src->pdb_labrtflg, dst->pdb_labrtflg);
1457 	ISP_IOXGET_16(isp, &src->pdb_lstopflg, dst->pdb_lstopflg);
1458 	ISP_IOXGET_16(isp, &src->pdb_sqhead, dst->pdb_sqhead);
1459 	ISP_IOXGET_16(isp, &src->pdb_sqtail, dst->pdb_sqtail);
1460 	ISP_IOXGET_16(isp, &src->pdb_ptimer, dst->pdb_ptimer);
1461 	ISP_IOXGET_16(isp, &src->pdb_nxt_seqid, dst->pdb_nxt_seqid);
1462 	ISP_IOXGET_16(isp, &src->pdb_fcount, dst->pdb_fcount);
1463 	ISP_IOXGET_16(isp, &src->pdb_prli_len, dst->pdb_prli_len);
1464 	ISP_IOXGET_16(isp, &src->pdb_prli_svc0, dst->pdb_prli_svc0);
1465 	ISP_IOXGET_16(isp, &src->pdb_prli_svc3, dst->pdb_prli_svc3);
1466 	ISP_IOXGET_16(isp, &src->pdb_loopid, dst->pdb_loopid);
1467 	ISP_IOXGET_16(isp, &src->pdb_il_ptr, dst->pdb_il_ptr);
1468 	ISP_IOXGET_16(isp, &src->pdb_sl_ptr, dst->pdb_sl_ptr);
1469 }
1470 
1471 void
1472 isp_get_pdb_24xx(ispsoftc_t *isp, isp_pdb_24xx_t *src, isp_pdb_24xx_t *dst)
1473 {
1474 	int i;
1475 	ISP_IOXGET_16(isp, &src->pdb_flags, dst->pdb_flags);
1476         ISP_IOXGET_8(isp, &src->pdb_curstate, dst->pdb_curstate);
1477         ISP_IOXGET_8(isp, &src->pdb_laststate, dst->pdb_laststate);
1478 	for (i = 0; i < 4; i++) {
1479 		ISP_IOXGET_8(isp, &src->pdb_hardaddr_bits[i], dst->pdb_hardaddr_bits[i]);
1480 	}
1481 	for (i = 0; i < 4; i++) {
1482 		ISP_IOXGET_8(isp, &src->pdb_portid_bits[i], dst->pdb_portid_bits[i]);
1483 	}
1484 	ISP_IOXGET_16(isp, &src->pdb_retry_timer, dst->pdb_retry_timer);
1485 	ISP_IOXGET_16(isp, &src->pdb_handle, dst->pdb_handle);
1486 	ISP_IOXGET_16(isp, &src->pdb_rcv_dsize, dst->pdb_rcv_dsize);
1487 	ISP_IOXGET_16(isp, &src->pdb_reserved0, dst->pdb_reserved0);
1488 	ISP_IOXGET_16(isp, &src->pdb_prli_svc0, dst->pdb_prli_svc0);
1489 	ISP_IOXGET_16(isp, &src->pdb_prli_svc3, dst->pdb_prli_svc3);
1490 	for (i = 0; i < 8; i++) {
1491 		ISP_IOXGET_8(isp, &src->pdb_nodename[i], dst->pdb_nodename[i]);
1492 	}
1493 	for (i = 0; i < 8; i++) {
1494 		ISP_IOXGET_8(isp, &src->pdb_portname[i], dst->pdb_portname[i]);
1495 	}
1496 	for (i = 0; i < 24; i++) {
1497 		ISP_IOXGET_8(isp, &src->pdb_reserved1[i], dst->pdb_reserved1[i]);
1498 	}
1499 }
1500 
1501 /*
1502  * PLOGI/LOGO IOCB canonicalization
1503  */
1504 
1505 void
1506 isp_get_plogx(ispsoftc_t *isp, isp_plogx_t *src, isp_plogx_t *dst)
1507 {
1508 	int i;
1509 	isp_get_hdr(isp, &src->plogx_header, &dst->plogx_header);
1510 	ISP_IOXGET_32(isp, &src->plogx_handle, dst->plogx_handle);
1511 	ISP_IOXGET_16(isp, &src->plogx_status, dst->plogx_status);
1512 	ISP_IOXGET_16(isp, &src->plogx_nphdl, dst->plogx_nphdl);
1513 	ISP_IOXGET_16(isp, &src->plogx_flags, dst->plogx_flags);
1514 	ISP_IOXGET_16(isp, &src->plogx_vphdl, dst->plogx_vphdl);
1515 	ISP_IOXGET_16(isp, &src->plogx_portlo, dst->plogx_portlo);
1516 	ISP_IOXGET_16(isp, &src->plogx_rspsz_porthi, dst->plogx_rspsz_porthi);
1517 	for (i = 0; i < 11; i++) {
1518 		ISP_IOXGET_16(isp, &src->plogx_ioparm[i].lo16, dst->plogx_ioparm[i].lo16);
1519 		ISP_IOXGET_16(isp, &src->plogx_ioparm[i].hi16, dst->plogx_ioparm[i].hi16);
1520 	}
1521 }
1522 
1523 void
1524 isp_put_plogx(ispsoftc_t *isp, isp_plogx_t *src, isp_plogx_t *dst)
1525 {
1526 	int i;
1527 	isp_put_hdr(isp, &src->plogx_header, &dst->plogx_header);
1528 	ISP_IOXPUT_32(isp, src->plogx_handle, &dst->plogx_handle);
1529 	ISP_IOXPUT_16(isp, src->plogx_status, &dst->plogx_status);
1530 	ISP_IOXPUT_16(isp, src->plogx_nphdl, &dst->plogx_nphdl);
1531 	ISP_IOXPUT_16(isp, src->plogx_flags, &dst->plogx_flags);
1532 	ISP_IOXPUT_16(isp, src->plogx_vphdl, &dst->plogx_vphdl);
1533 	ISP_IOXPUT_16(isp, src->plogx_portlo, &dst->plogx_portlo);
1534 	ISP_IOXPUT_16(isp, src->plogx_rspsz_porthi, &dst->plogx_rspsz_porthi);
1535 	for (i = 0; i < 11; i++) {
1536 		ISP_IOXPUT_16(isp, src->plogx_ioparm[i].lo16, &dst->plogx_ioparm[i].lo16);
1537 		ISP_IOXPUT_16(isp, src->plogx_ioparm[i].hi16, &dst->plogx_ioparm[i].hi16);
1538 	}
1539 }
1540 
1541 /*
1542  * Report ID canonicalization
1543  */
1544 void
1545 isp_get_ridacq(ispsoftc_t *isp, isp_ridacq_t *src, isp_ridacq_t *dst)
1546 {
1547 	int i;
1548 	isp_get_hdr(isp, &src->ridacq_hdr, &dst->ridacq_hdr);
1549 	ISP_IOXGET_32(isp, &src->ridacq_handle, dst->ridacq_handle);
1550 	ISP_IOXGET_16(isp, &src->ridacq_vp_port_lo, dst->ridacq_vp_port_lo);
1551 	ISP_IOXGET_8(isp, &src->ridacq_vp_port_hi, dst->ridacq_vp_port_hi);
1552 	ISP_IOXGET_8(isp, &src->ridacq_format, dst->ridacq_format);
1553 	for (i = 0; i < sizeof (src->ridacq_map) / sizeof (src->ridacq_map[0]); i++) {
1554 		ISP_IOXGET_16(isp, &src->ridacq_map[i], dst->ridacq_map[i]);
1555 	}
1556 	for (i = 0; i < sizeof (src->ridacq_reserved1) / sizeof (src->ridacq_reserved1[0]); i++) {
1557 		ISP_IOXGET_16(isp, &src->ridacq_reserved1[i], dst->ridacq_reserved1[i]);
1558 	}
1559 	if (dst->ridacq_format == 0) {
1560 		ISP_IOXGET_8(isp, &src->un.type0.ridacq_vp_acquired, dst->un.type0.ridacq_vp_acquired);
1561 		ISP_IOXGET_8(isp, &src->un.type0.ridacq_vp_setup, dst->un.type0.ridacq_vp_setup);
1562 		ISP_IOXGET_16(isp, &src->un.type0.ridacq_reserved0, dst->un.type0.ridacq_reserved0);
1563 	} else if (dst->ridacq_format == 1) {
1564 		ISP_IOXGET_16(isp, &src->un.type1.ridacq_vp_count, dst->un.type1.ridacq_vp_count);
1565 		ISP_IOXGET_8(isp, &src->un.type1.ridacq_vp_index, dst->un.type1.ridacq_vp_index);
1566 		ISP_IOXGET_8(isp, &src->un.type1.ridacq_vp_status, dst->un.type1.ridacq_vp_status);
1567 	} else {
1568 		ISP_MEMZERO(&dst->un, sizeof (dst->un));
1569 	}
1570 }
1571 
1572 
1573 /*
1574  * CT Passthru canonicalization
1575  */
1576 void
1577 isp_get_ct_pt(ispsoftc_t *isp, isp_ct_pt_t *src, isp_ct_pt_t *dst)
1578 {
1579 	int i;
1580 
1581 	isp_get_hdr(isp, &src->ctp_header, &dst->ctp_header);
1582 	ISP_IOXGET_32(isp, &src->ctp_handle, dst->ctp_handle);
1583 	ISP_IOXGET_16(isp, &src->ctp_status, dst->ctp_status);
1584 	ISP_IOXGET_16(isp, &src->ctp_nphdl, dst->ctp_nphdl);
1585 	ISP_IOXGET_16(isp, &src->ctp_cmd_cnt, dst->ctp_cmd_cnt);
1586 	ISP_IOXGET_8(isp, &src->ctp_vpidx, dst->ctp_vpidx);
1587 	ISP_IOXGET_8(isp, &src->ctp_reserved0, dst->ctp_reserved0);
1588 	ISP_IOXGET_16(isp, &src->ctp_time, dst->ctp_time);
1589 	ISP_IOXGET_16(isp, &src->ctp_reserved1, dst->ctp_reserved1);
1590 	ISP_IOXGET_16(isp, &src->ctp_rsp_cnt, dst->ctp_rsp_cnt);
1591 	for (i = 0; i < 5; i++) {
1592 		ISP_IOXGET_16(isp, &src->ctp_reserved2[i], dst->ctp_reserved2[i]);
1593 	}
1594 	ISP_IOXGET_32(isp, &src->ctp_rsp_bcnt, dst->ctp_rsp_bcnt);
1595 	ISP_IOXGET_32(isp, &src->ctp_cmd_bcnt, dst->ctp_cmd_bcnt);
1596 	for (i = 0; i < 2; i++) {
1597 		ISP_IOXGET_32(isp, &src->ctp_dataseg[i].ds_base, dst->ctp_dataseg[i].ds_base);
1598 		ISP_IOXGET_32(isp, &src->ctp_dataseg[i].ds_basehi, dst->ctp_dataseg[i].ds_basehi);
1599 		ISP_IOXGET_32(isp, &src->ctp_dataseg[i].ds_count, dst->ctp_dataseg[i].ds_count);
1600 	}
1601 }
1602 
1603 void
1604 isp_get_ms(ispsoftc_t *isp, isp_ms_t *src, isp_ms_t *dst)
1605 {
1606 	int i;
1607 
1608 	isp_get_hdr(isp, &src->ms_header, &dst->ms_header);
1609 	ISP_IOXGET_32(isp, &src->ms_handle, dst->ms_handle);
1610 	ISP_IOXGET_16(isp, &src->ms_nphdl, dst->ms_nphdl);
1611 	ISP_IOXGET_16(isp, &src->ms_status, dst->ms_status);
1612 	ISP_IOXGET_16(isp, &src->ms_flags, dst->ms_flags);
1613 	ISP_IOXGET_16(isp, &src->ms_reserved1, dst->ms_reserved1);
1614 	ISP_IOXGET_16(isp, &src->ms_time, dst->ms_time);
1615 	ISP_IOXGET_16(isp, &src->ms_cmd_cnt, dst->ms_cmd_cnt);
1616 	ISP_IOXGET_16(isp, &src->ms_tot_cnt, dst->ms_tot_cnt);
1617 	ISP_IOXGET_8(isp, &src->ms_type, dst->ms_type);
1618 	ISP_IOXGET_8(isp, &src->ms_r_ctl, dst->ms_r_ctl);
1619 	ISP_IOXGET_16(isp, &src->ms_rxid, dst->ms_rxid);
1620 	ISP_IOXGET_16(isp, &src->ms_reserved2, dst->ms_reserved2);
1621 	ISP_IOXGET_32(isp, &src->ms_rsp_bcnt, dst->ms_rsp_bcnt);
1622 	ISP_IOXGET_32(isp, &src->ms_cmd_bcnt, dst->ms_cmd_bcnt);
1623 	for (i = 0; i < 2; i++) {
1624 		ISP_IOXGET_32(isp, &src->ms_dataseg[i].ds_base, dst->ms_dataseg[i].ds_base);
1625 		ISP_IOXGET_32(isp, &src->ms_dataseg[i].ds_basehi, dst->ms_dataseg[i].ds_basehi);
1626 		ISP_IOXGET_32(isp, &src->ms_dataseg[i].ds_count, dst->ms_dataseg[i].ds_count);
1627 	}
1628 }
1629 
1630 void
1631 isp_put_ct_pt(ispsoftc_t *isp, isp_ct_pt_t *src, isp_ct_pt_t *dst)
1632 {
1633 	int i;
1634 
1635 	isp_put_hdr(isp, &src->ctp_header, &dst->ctp_header);
1636 	ISP_IOXPUT_32(isp, src->ctp_handle, &dst->ctp_handle);
1637 	ISP_IOXPUT_16(isp, src->ctp_status, &dst->ctp_status);
1638 	ISP_IOXPUT_16(isp, src->ctp_nphdl, &dst->ctp_nphdl);
1639 	ISP_IOXPUT_16(isp, src->ctp_cmd_cnt, &dst->ctp_cmd_cnt);
1640 	ISP_IOXPUT_8(isp, src->ctp_vpidx, &dst->ctp_vpidx);
1641 	ISP_IOXPUT_8(isp, src->ctp_reserved0, &dst->ctp_reserved0);
1642 	ISP_IOXPUT_16(isp, src->ctp_time, &dst->ctp_time);
1643 	ISP_IOXPUT_16(isp, src->ctp_reserved1, &dst->ctp_reserved1);
1644 	ISP_IOXPUT_16(isp, src->ctp_rsp_cnt, &dst->ctp_rsp_cnt);
1645 	for (i = 0; i < 5; i++) {
1646 		ISP_IOXPUT_16(isp, src->ctp_reserved2[i], &dst->ctp_reserved2[i]);
1647 	}
1648 	ISP_IOXPUT_32(isp, src->ctp_rsp_bcnt, &dst->ctp_rsp_bcnt);
1649 	ISP_IOXPUT_32(isp, src->ctp_cmd_bcnt, &dst->ctp_cmd_bcnt);
1650 	for (i = 0; i < 2; i++) {
1651 		ISP_IOXPUT_32(isp, src->ctp_dataseg[i].ds_base, &dst->ctp_dataseg[i].ds_base);
1652 		ISP_IOXPUT_32(isp, src->ctp_dataseg[i].ds_basehi, &dst->ctp_dataseg[i].ds_basehi);
1653 		ISP_IOXPUT_32(isp, src->ctp_dataseg[i].ds_count, &dst->ctp_dataseg[i].ds_count);
1654 	}
1655 }
1656 
1657 void
1658 isp_put_ms(ispsoftc_t *isp, isp_ms_t *src, isp_ms_t *dst)
1659 {
1660 	int i;
1661 
1662 	isp_put_hdr(isp, &src->ms_header, &dst->ms_header);
1663 	ISP_IOXPUT_32(isp, src->ms_handle, &dst->ms_handle);
1664 	ISP_IOXPUT_16(isp, src->ms_nphdl, &dst->ms_nphdl);
1665 	ISP_IOXPUT_16(isp, src->ms_status, &dst->ms_status);
1666 	ISP_IOXPUT_16(isp, src->ms_flags, &dst->ms_flags);
1667 	ISP_IOXPUT_16(isp, src->ms_reserved1, &dst->ms_reserved1);
1668 	ISP_IOXPUT_16(isp, src->ms_time, &dst->ms_time);
1669 	ISP_IOXPUT_16(isp, src->ms_cmd_cnt, &dst->ms_cmd_cnt);
1670 	ISP_IOXPUT_16(isp, src->ms_tot_cnt, &dst->ms_tot_cnt);
1671 	ISP_IOXPUT_8(isp, src->ms_type, &dst->ms_type);
1672 	ISP_IOXPUT_8(isp, src->ms_r_ctl, &dst->ms_r_ctl);
1673 	ISP_IOXPUT_16(isp, src->ms_rxid, &dst->ms_rxid);
1674 	ISP_IOXPUT_16(isp, src->ms_reserved2, &dst->ms_reserved2);
1675 	ISP_IOXPUT_32(isp, src->ms_rsp_bcnt, &dst->ms_rsp_bcnt);
1676 	ISP_IOXPUT_32(isp, src->ms_cmd_bcnt, &dst->ms_cmd_bcnt);
1677 	for (i = 0; i < 2; i++) {
1678 		ISP_IOXPUT_32(isp, src->ms_dataseg[i].ds_base, &dst->ms_dataseg[i].ds_base);
1679 		ISP_IOXPUT_32(isp, src->ms_dataseg[i].ds_basehi, &dst->ms_dataseg[i].ds_basehi);
1680 		ISP_IOXPUT_32(isp, src->ms_dataseg[i].ds_count, &dst->ms_dataseg[i].ds_count);
1681 	}
1682 }
1683 
1684 /*
1685  * Generic SNS request - not particularly useful since the per-command data
1686  * isn't always 16 bit words.
1687  */
1688 void
1689 isp_put_sns_request(ispsoftc_t *isp, sns_screq_t *src, sns_screq_t *dst)
1690 {
1691 	int i, nw = (int) src->snscb_sblen;
1692 	ISP_IOXPUT_16(isp, src->snscb_rblen, &dst->snscb_rblen);
1693 	for (i = 0; i < 4; i++) {
1694 		ISP_IOXPUT_16(isp, src->snscb_addr[i], &dst->snscb_addr[i]);
1695 	}
1696 	ISP_IOXPUT_16(isp, src->snscb_sblen, &dst->snscb_sblen);
1697 	for (i = 0; i < nw; i++) {
1698 		ISP_IOXPUT_16(isp, src->snscb_data[i], &dst->snscb_data[i]);
1699 	}
1700 }
1701 
1702 void
1703 isp_put_gid_ft_request(ispsoftc_t *isp, sns_gid_ft_req_t *src, sns_gid_ft_req_t *dst)
1704 {
1705 	ISP_IOXPUT_16(isp, src->snscb_rblen, &dst->snscb_rblen);
1706 	ISP_IOXPUT_16(isp, src->snscb_reserved0, &dst->snscb_reserved0);
1707 	ISP_IOXPUT_16(isp, src->snscb_addr[0], &dst->snscb_addr[0]);
1708 	ISP_IOXPUT_16(isp, src->snscb_addr[1], &dst->snscb_addr[1]);
1709 	ISP_IOXPUT_16(isp, src->snscb_addr[2], &dst->snscb_addr[2]);
1710 	ISP_IOXPUT_16(isp, src->snscb_addr[3], &dst->snscb_addr[3]);
1711 	ISP_IOXPUT_16(isp, src->snscb_sblen, &dst->snscb_sblen);
1712 	ISP_IOXPUT_16(isp, src->snscb_reserved1, &dst->snscb_reserved1);
1713 	ISP_IOXPUT_16(isp, src->snscb_cmd, &dst->snscb_cmd);
1714 	ISP_IOXPUT_16(isp, src->snscb_mword_div_2, &dst->snscb_mword_div_2);
1715 	ISP_IOXPUT_32(isp, src->snscb_reserved3, &dst->snscb_reserved3);
1716 	ISP_IOXPUT_32(isp, src->snscb_fc4_type, &dst->snscb_fc4_type);
1717 }
1718 
1719 void
1720 isp_put_gxn_id_request(ispsoftc_t *isp, sns_gxn_id_req_t *src, sns_gxn_id_req_t *dst)
1721 {
1722 	ISP_IOXPUT_16(isp, src->snscb_rblen, &dst->snscb_rblen);
1723 	ISP_IOXPUT_16(isp, src->snscb_reserved0, &dst->snscb_reserved0);
1724 	ISP_IOXPUT_16(isp, src->snscb_addr[0], &dst->snscb_addr[0]);
1725 	ISP_IOXPUT_16(isp, src->snscb_addr[1], &dst->snscb_addr[1]);
1726 	ISP_IOXPUT_16(isp, src->snscb_addr[2], &dst->snscb_addr[2]);
1727 	ISP_IOXPUT_16(isp, src->snscb_addr[3], &dst->snscb_addr[3]);
1728 	ISP_IOXPUT_16(isp, src->snscb_sblen, &dst->snscb_sblen);
1729 	ISP_IOXPUT_16(isp, src->snscb_reserved1, &dst->snscb_reserved1);
1730 	ISP_IOXPUT_16(isp, src->snscb_cmd, &dst->snscb_cmd);
1731 	ISP_IOXPUT_16(isp, src->snscb_reserved2, &dst->snscb_reserved2);
1732 	ISP_IOXPUT_32(isp, src->snscb_reserved3, &dst->snscb_reserved3);
1733 	ISP_IOXPUT_32(isp, src->snscb_portid, &dst->snscb_portid);
1734 }
1735 
1736 /*
1737  * Generic SNS response - not particularly useful since the per-command data
1738  * isn't always 16 bit words.
1739  */
1740 void
1741 isp_get_sns_response(ispsoftc_t *isp, sns_scrsp_t *src, sns_scrsp_t *dst, int nwords)
1742 {
1743 	int i;
1744 	isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
1745 	ISP_IOXGET_8(isp, &src->snscb_port_type, dst->snscb_port_type);
1746 	for (i = 0; i < 3; i++) {
1747 		ISP_IOXGET_8(isp, &src->snscb_port_id[i],
1748 		    dst->snscb_port_id[i]);
1749 	}
1750 	for (i = 0; i < 8; i++) {
1751 		ISP_IOXGET_8(isp, &src->snscb_portname[i],
1752 		    dst->snscb_portname[i]);
1753 	}
1754 	for (i = 0; i < nwords; i++) {
1755 		ISP_IOXGET_16(isp, &src->snscb_data[i], dst->snscb_data[i]);
1756 	}
1757 }
1758 
1759 void
1760 isp_get_gid_ft_response(ispsoftc_t *isp, sns_gid_ft_rsp_t *src, sns_gid_ft_rsp_t *dst, int nwords)
1761 {
1762 	int i;
1763 	isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
1764 	for (i = 0; i < nwords; i++) {
1765 		int j;
1766 		ISP_IOXGET_8(isp, &src->snscb_ports[i].control, dst->snscb_ports[i].control);
1767 		for (j = 0; j < 3; j++) {
1768 			ISP_IOXGET_8(isp, &src->snscb_ports[i].portid[j], dst->snscb_ports[i].portid[j]);
1769 		}
1770 		if (dst->snscb_ports[i].control & 0x80) {
1771 			break;
1772 		}
1773 	}
1774 }
1775 
1776 void
1777 isp_get_gxn_id_response(ispsoftc_t *isp, sns_gxn_id_rsp_t *src, sns_gxn_id_rsp_t *dst)
1778 {
1779 	int i;
1780 	isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
1781 	for (i = 0; i < 8; i++) {
1782 		ISP_IOXGET_8(isp, &src->snscb_wwn[i], dst->snscb_wwn[i]);
1783 	}
1784 }
1785 
1786 void
1787 isp_get_gff_id_response(ispsoftc_t *isp, sns_gff_id_rsp_t *src, sns_gff_id_rsp_t *dst)
1788 {
1789 	int i;
1790 	isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
1791 	for (i = 0; i < 32; i++) {
1792 		ISP_IOXGET_32(isp, &src->snscb_fc4_features[i], dst->snscb_fc4_features[i]);
1793 	}
1794 }
1795 
1796 void
1797 isp_get_ga_nxt_response(ispsoftc_t *isp, sns_ga_nxt_rsp_t *src, sns_ga_nxt_rsp_t *dst)
1798 {
1799 	int i;
1800 	isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
1801 	ISP_IOXGET_8(isp, &src->snscb_port_type, dst->snscb_port_type);
1802 	for (i = 0; i < 3; i++) {
1803 		ISP_IOXGET_8(isp, &src->snscb_port_id[i], dst->snscb_port_id[i]);
1804 	}
1805 	for (i = 0; i < 8; i++) {
1806 		ISP_IOXGET_8(isp, &src->snscb_portname[i], dst->snscb_portname[i]);
1807 	}
1808 	ISP_IOXGET_8(isp, &src->snscb_pnlen, dst->snscb_pnlen);
1809 	for (i = 0; i < 255; i++) {
1810 		ISP_IOXGET_8(isp, &src->snscb_pname[i], dst->snscb_pname[i]);
1811 	}
1812 	for (i = 0; i < 8; i++) {
1813 		ISP_IOXGET_8(isp, &src->snscb_nodename[i], dst->snscb_nodename[i]);
1814 	}
1815 	ISP_IOXGET_8(isp, &src->snscb_nnlen, dst->snscb_nnlen);
1816 	for (i = 0; i < 255; i++) {
1817 		ISP_IOXGET_8(isp, &src->snscb_nname[i], dst->snscb_nname[i]);
1818 	}
1819 	for (i = 0; i < 8; i++) {
1820 		ISP_IOXGET_8(isp, &src->snscb_ipassoc[i], dst->snscb_ipassoc[i]);
1821 	}
1822 	for (i = 0; i < 16; i++) {
1823 		ISP_IOXGET_8(isp, &src->snscb_ipaddr[i], dst->snscb_ipaddr[i]);
1824 	}
1825 	for (i = 0; i < 4; i++) {
1826 		ISP_IOXGET_8(isp, &src->snscb_svc_class[i], dst->snscb_svc_class[i]);
1827 	}
1828 	for (i = 0; i < 32; i++) {
1829 		ISP_IOXGET_8(isp, &src->snscb_fc4_types[i], dst->snscb_fc4_types[i]);
1830 	}
1831 	for (i = 0; i < 8; i++) {
1832 		ISP_IOXGET_8(isp, &src->snscb_fpname[i], dst->snscb_fpname[i]);
1833 	}
1834 	ISP_IOXGET_8(isp, &src->snscb_reserved, dst->snscb_reserved);
1835 	for (i = 0; i < 3; i++) {
1836 		ISP_IOXGET_8(isp, &src->snscb_hardaddr[i], dst->snscb_hardaddr[i]);
1837 	}
1838 }
1839 
1840 void
1841 isp_get_els(ispsoftc_t *isp, els_t *src, els_t *dst)
1842 {
1843 	int i;
1844 
1845 	isp_get_hdr(isp, &src->els_hdr, &dst->els_hdr);
1846 	ISP_IOXGET_32(isp, &src->els_handle, dst->els_handle);
1847 	ISP_IOXGET_16(isp, &src->els_status, dst->els_status);
1848 	ISP_IOXGET_16(isp, &src->els_nphdl, dst->els_nphdl);
1849 	ISP_IOXGET_16(isp, &src->els_xmit_dsd_count, dst->els_xmit_dsd_count);
1850 	ISP_IOXGET_8(isp, &src->els_vphdl, dst->els_vphdl);
1851 	ISP_IOXGET_8(isp, &src->els_sof, dst->els_sof);
1852 	ISP_IOXGET_32(isp, &src->els_rxid, dst->els_rxid);
1853 	ISP_IOXGET_16(isp, &src->els_recv_dsd_count, dst->els_recv_dsd_count);
1854 	ISP_IOXGET_8(isp, &src->els_opcode, dst->els_opcode);
1855 	ISP_IOXGET_8(isp, &src->els_reserved2, dst->els_reserved1);
1856 	ISP_IOXGET_8(isp, &src->els_did_lo, dst->els_did_lo);
1857 	ISP_IOXGET_8(isp, &src->els_did_mid, dst->els_did_mid);
1858 	ISP_IOXGET_8(isp, &src->els_did_hi, dst->els_did_hi);
1859 	ISP_IOXGET_8(isp, &src->els_reserved2, dst->els_reserved2);
1860 	ISP_IOXGET_16(isp, &src->els_reserved3, dst->els_reserved3);
1861 	ISP_IOXGET_16(isp, &src->els_ctl_flags, dst->els_ctl_flags);
1862 	ISP_IOXGET_32(isp, &src->els_bytecnt, dst->els_bytecnt);
1863 	ISP_IOXGET_32(isp, &src->els_subcode1, dst->els_subcode1);
1864 	ISP_IOXGET_32(isp, &src->els_subcode2, dst->els_subcode2);
1865 	for (i = 0; i < 20; i++) {
1866 		ISP_IOXGET_8(isp, &src->els_reserved4[i], dst->els_reserved4[i]);
1867 	}
1868 }
1869 
1870 void
1871 isp_put_els(ispsoftc_t *isp, els_t *src, els_t *dst)
1872 {
1873 	isp_put_hdr(isp, &src->els_hdr, &dst->els_hdr);
1874 	ISP_IOXPUT_32(isp, src->els_handle, &dst->els_handle);
1875 	ISP_IOXPUT_16(isp, src->els_status, &dst->els_status);
1876 	ISP_IOXPUT_16(isp, src->els_nphdl, &dst->els_nphdl);
1877 	ISP_IOXPUT_16(isp, src->els_xmit_dsd_count, &dst->els_xmit_dsd_count);
1878 	ISP_IOXPUT_8(isp, src->els_vphdl, &dst->els_vphdl);
1879 	ISP_IOXPUT_8(isp, src->els_sof, &dst->els_sof);
1880 	ISP_IOXPUT_32(isp, src->els_rxid, &dst->els_rxid);
1881 	ISP_IOXPUT_16(isp, src->els_recv_dsd_count, &dst->els_recv_dsd_count);
1882 	ISP_IOXPUT_8(isp, src->els_opcode, &dst->els_opcode);
1883 	ISP_IOXPUT_8(isp, src->els_reserved2, &dst->els_reserved1);
1884 	ISP_IOXPUT_8(isp, src->els_did_lo, &dst->els_did_lo);
1885 	ISP_IOXPUT_8(isp, src->els_did_mid, &dst->els_did_mid);
1886 	ISP_IOXPUT_8(isp, src->els_did_hi, &dst->els_did_hi);
1887 	ISP_IOXPUT_8(isp, src->els_reserved2, &dst->els_reserved2);
1888 	ISP_IOXPUT_16(isp, src->els_reserved3, &dst->els_reserved3);
1889 	ISP_IOXPUT_16(isp, src->els_ctl_flags, &dst->els_ctl_flags);
1890 	ISP_IOXPUT_32(isp, src->els_recv_bytecnt, &dst->els_recv_bytecnt);
1891 	ISP_IOXPUT_32(isp, src->els_xmit_bytecnt, &dst->els_xmit_bytecnt);
1892 	ISP_IOXPUT_32(isp, src->els_xmit_dsd_length, &dst->els_xmit_dsd_length);
1893 	ISP_IOXPUT_16(isp, src->els_xmit_dsd_a1500, &dst->els_xmit_dsd_a1500);
1894 	ISP_IOXPUT_16(isp, src->els_xmit_dsd_a3116, &dst->els_xmit_dsd_a3116);
1895 	ISP_IOXPUT_16(isp, src->els_xmit_dsd_a4732, &dst->els_xmit_dsd_a4732);
1896 	ISP_IOXPUT_16(isp, src->els_xmit_dsd_a6348, &dst->els_xmit_dsd_a6348);
1897 	ISP_IOXPUT_32(isp, src->els_recv_dsd_length, &dst->els_recv_dsd_length);
1898 	ISP_IOXPUT_16(isp, src->els_recv_dsd_a1500, &dst->els_recv_dsd_a1500);
1899 	ISP_IOXPUT_16(isp, src->els_recv_dsd_a3116, &dst->els_recv_dsd_a3116);
1900 	ISP_IOXPUT_16(isp, src->els_recv_dsd_a4732, &dst->els_recv_dsd_a4732);
1901 	ISP_IOXPUT_16(isp, src->els_recv_dsd_a6348, &dst->els_recv_dsd_a6348);
1902 }
1903 
1904 /*
1905  * FC Structure Canonicalization
1906  */
1907 
1908 void
1909 isp_get_fc_hdr(ispsoftc_t *isp, fc_hdr_t *src, fc_hdr_t *dst)
1910 {
1911         ISP_IOZGET_8(isp, &src->r_ctl, dst->r_ctl);
1912         ISP_IOZGET_8(isp, &src->d_id[0], dst->d_id[0]);
1913         ISP_IOZGET_8(isp, &src->d_id[1], dst->d_id[1]);
1914         ISP_IOZGET_8(isp, &src->d_id[2], dst->d_id[2]);
1915         ISP_IOZGET_8(isp, &src->cs_ctl, dst->cs_ctl);
1916         ISP_IOZGET_8(isp, &src->s_id[0], dst->s_id[0]);
1917         ISP_IOZGET_8(isp, &src->s_id[1], dst->s_id[1]);
1918         ISP_IOZGET_8(isp, &src->s_id[2], dst->s_id[2]);
1919         ISP_IOZGET_8(isp, &src->type, dst->type);
1920         ISP_IOZGET_8(isp, &src->f_ctl[0], dst->f_ctl[0]);
1921         ISP_IOZGET_8(isp, &src->f_ctl[1], dst->f_ctl[1]);
1922         ISP_IOZGET_8(isp, &src->f_ctl[2], dst->f_ctl[2]);
1923         ISP_IOZGET_8(isp, &src->seq_id, dst->seq_id);
1924         ISP_IOZGET_8(isp, &src->df_ctl, dst->df_ctl);
1925         ISP_IOZGET_16(isp, &src->seq_cnt, dst->seq_cnt);
1926         ISP_IOZGET_16(isp, &src->ox_id, dst->ox_id);
1927         ISP_IOZGET_16(isp, &src->rx_id, dst->rx_id);
1928         ISP_IOZGET_32(isp, &src->parameter, dst->parameter);
1929 }
1930 
1931 void
1932 isp_get_fcp_cmnd_iu(ispsoftc_t *isp, fcp_cmnd_iu_t *src, fcp_cmnd_iu_t *dst)
1933 {
1934 	int i;
1935 
1936 	for (i = 0; i < 8; i++) {
1937 		ISP_IOZGET_8(isp, &src->fcp_cmnd_lun[i], dst->fcp_cmnd_lun[i]);
1938 	}
1939         ISP_IOZGET_8(isp, &src->fcp_cmnd_crn, dst->fcp_cmnd_crn);
1940         ISP_IOZGET_8(isp, &src->fcp_cmnd_task_attribute, dst->fcp_cmnd_task_attribute);
1941         ISP_IOZGET_8(isp, &src->fcp_cmnd_task_management, dst->fcp_cmnd_task_management);
1942         ISP_IOZGET_8(isp, &src->fcp_cmnd_alen_datadir, dst->fcp_cmnd_alen_datadir);
1943 	for (i = 0; i < 16; i++) {
1944 		ISP_IOZGET_8(isp, &src->cdb_dl.sf.fcp_cmnd_cdb[i], dst->cdb_dl.sf.fcp_cmnd_cdb[i]);
1945 	}
1946 	ISP_IOZGET_32(isp, &src->cdb_dl.sf.fcp_cmnd_dl, dst->cdb_dl.sf.fcp_cmnd_dl);
1947 }
1948 
1949 void
1950 isp_put_rft_id(ispsoftc_t *isp, rft_id_t *src, rft_id_t *dst)
1951 {
1952 	int i;
1953 	isp_put_ct_hdr(isp, &src->rftid_hdr, &dst->rftid_hdr);
1954 	ISP_IOZPUT_8(isp, src->rftid_reserved, &dst->rftid_reserved);
1955 	for (i = 0; i < 3; i++) {
1956 		ISP_IOZPUT_8(isp, src->rftid_portid[i], &dst->rftid_portid[i]);
1957 	}
1958 	for (i = 0; i < 8; i++) {
1959 		ISP_IOZPUT_32(isp, src->rftid_fc4types[i], &dst->rftid_fc4types[i]);
1960 	}
1961 }
1962 
1963 void
1964 isp_get_ct_hdr(ispsoftc_t *isp, ct_hdr_t *src, ct_hdr_t *dst)
1965 {
1966 	ISP_IOZGET_8(isp, &src->ct_revision, dst->ct_revision);
1967 	ISP_IOZGET_8(isp, &src->ct_in_id[0], dst->ct_in_id[0]);
1968 	ISP_IOZGET_8(isp, &src->ct_in_id[1], dst->ct_in_id[1]);
1969 	ISP_IOZGET_8(isp, &src->ct_in_id[2], dst->ct_in_id[2]);
1970 	ISP_IOZGET_8(isp, &src->ct_fcs_type, dst->ct_fcs_type);
1971 	ISP_IOZGET_8(isp, &src->ct_fcs_subtype, dst->ct_fcs_subtype);
1972 	ISP_IOZGET_8(isp, &src->ct_options, dst->ct_options);
1973 	ISP_IOZGET_8(isp, &src->ct_reserved0, dst->ct_reserved0);
1974 	ISP_IOZGET_16(isp, &src->ct_cmd_resp, dst->ct_cmd_resp);
1975 	ISP_IOZGET_16(isp, &src->ct_bcnt_resid, dst->ct_bcnt_resid);
1976 	ISP_IOZGET_8(isp, &src->ct_reserved1, dst->ct_reserved1);
1977 	ISP_IOZGET_8(isp, &src->ct_reason, dst->ct_reason);
1978 	ISP_IOZGET_8(isp, &src->ct_explanation, dst->ct_explanation);
1979 	ISP_IOZGET_8(isp, &src->ct_vunique, dst->ct_vunique);
1980 }
1981 
1982 void
1983 isp_put_ct_hdr(ispsoftc_t *isp, ct_hdr_t *src, ct_hdr_t *dst)
1984 {
1985 	ISP_IOZPUT_8(isp, src->ct_revision, &dst->ct_revision);
1986 	ISP_IOZPUT_8(isp, src->ct_in_id[0], &dst->ct_in_id[0]);
1987 	ISP_IOZPUT_8(isp, src->ct_in_id[1], &dst->ct_in_id[1]);
1988 	ISP_IOZPUT_8(isp, src->ct_in_id[2], &dst->ct_in_id[2]);
1989 	ISP_IOZPUT_8(isp, src->ct_fcs_type, &dst->ct_fcs_type);
1990 	ISP_IOZPUT_8(isp, src->ct_fcs_subtype, &dst->ct_fcs_subtype);
1991 	ISP_IOZPUT_8(isp, src->ct_options, &dst->ct_options);
1992 	ISP_IOZPUT_8(isp, src->ct_reserved0, &dst->ct_reserved0);
1993 	ISP_IOZPUT_16(isp, src->ct_cmd_resp, &dst->ct_cmd_resp);
1994 	ISP_IOZPUT_16(isp, src->ct_bcnt_resid, &dst->ct_bcnt_resid);
1995 	ISP_IOZPUT_8(isp, src->ct_reserved1, &dst->ct_reserved1);
1996 	ISP_IOZPUT_8(isp, src->ct_reason, &dst->ct_reason);
1997 	ISP_IOZPUT_8(isp, src->ct_explanation, &dst->ct_explanation);
1998 	ISP_IOZPUT_8(isp, src->ct_vunique, &dst->ct_vunique);
1999 }
2000 
2001 #ifdef	ISP_TARGET_MODE
2002 
2003 /*
2004  * Command shipping- finish off first queue entry and do dma mapping and
2005  * additional segments as needed.
2006  *
2007  * Called with the first queue entry at least partially filled out.
2008  */
2009 int
2010 isp_send_tgt_cmd(ispsoftc_t *isp, void *fqe, void *segp, uint32_t nsegs, uint32_t totalcnt, isp_ddir_t ddir, void *snsptr, uint32_t snslen)
2011 {
2012 	uint8_t storage[QENTRY_LEN], storage2[QENTRY_LEN];
2013 	uint8_t type, nqe;
2014 	uint32_t seg, curseg, seglim, nxt, nxtnxt;
2015 	ispds_t *dsp = NULL;
2016 	ispds64_t *dsp64 = NULL;
2017 	void *qe0, *qe1, *sqe = NULL;
2018 
2019 	qe0 = isp_getrqentry(isp);
2020 	if (qe0 == NULL) {
2021 		return (CMD_EAGAIN);
2022 	}
2023 	nxt = ISP_NXT_QENTRY(isp->isp_reqidx, RQUEST_QUEUE_LEN(isp));
2024 
2025 	type = ((isphdr_t *)fqe)->rqs_entry_type;
2026 	nqe = 1;
2027 	seglim = 0;
2028 
2029 	/*
2030 	 * If we have no data to transmit, just copy the first IOCB and start it up.
2031 	 */
2032 	if (ddir != ISP_NOXFR) {
2033 		/*
2034 		 * First, figure out how many pieces of data to transfer and what kind and how many we can put into the first queue entry.
2035 		 */
2036 		switch (type) {
2037 		case RQSTYPE_CTIO:
2038 			dsp = ((ct_entry_t *)fqe)->ct_dataseg;
2039 			seglim = ISP_RQDSEG;
2040 			break;
2041 		case RQSTYPE_CTIO2:
2042 		case RQSTYPE_CTIO3:
2043 		{
2044 			ct2_entry_t *ct = fqe, *ct2 = (ct2_entry_t *) storage2;
2045 			uint16_t swd = ct->rsp.m0.ct_scsi_status & 0xff;
2046 
2047 			if ((ct->ct_flags & CT2_SENDSTATUS) && (swd || ct->ct_resid)) {
2048 				memcpy(ct2, ct, QENTRY_LEN);
2049 				/*
2050 				 * Clear fields from first CTIO2 that now need to be cleared
2051 				 */
2052 				ct->ct_header.rqs_seqno = 0;
2053 				ct->ct_flags &= ~(CT2_SENDSTATUS|CT2_CCINCR|CT2_FASTPOST);
2054 				ct->ct_resid = 0;
2055 				ct->ct_syshandle = 0;
2056 				ct->rsp.m0.ct_scsi_status = 0;
2057 
2058 				/*
2059 				 * Reset fields in the second CTIO2 as appropriate.
2060 				 */
2061 				ct2->ct_flags &= ~(CT2_FLAG_MMASK|CT2_DATAMASK|CT2_FASTPOST);
2062 				ct2->ct_flags |= CT2_NO_DATA|CT2_FLAG_MODE1;
2063 				ct2->ct_seg_count = 0;
2064 				ct2->ct_reloff = 0;
2065 				memset(&ct2->rsp, 0, sizeof (ct2->rsp));
2066 				if (swd == SCSI_CHECK && snsptr && snslen) {
2067 					ct2->rsp.m1.ct_senselen = min(snslen, MAXRESPLEN);
2068 					memcpy(ct2->rsp.m1.ct_resp, snsptr, ct2->rsp.m1.ct_senselen);
2069 					swd |= CT2_SNSLEN_VALID;
2070 				}
2071 				if (ct2->ct_resid > 0) {
2072 					swd |= CT2_DATA_UNDER;
2073 				} else if (ct2->ct_resid < 0) {
2074 					swd |= CT2_DATA_OVER;
2075 				}
2076 				ct2->rsp.m1.ct_scsi_status = swd;
2077 				sqe = storage2;
2078 			}
2079 			if (type == RQSTYPE_CTIO2) {
2080 				dsp = ct->rsp.m0.u.ct_dataseg;
2081 				seglim = ISP_RQDSEG_T2;
2082 			} else {
2083 				dsp64 = ct->rsp.m0.u.ct_dataseg64;
2084 				seglim = ISP_RQDSEG_T3;
2085 			}
2086 			break;
2087 		}
2088 		case RQSTYPE_CTIO7:
2089 		{
2090 			ct7_entry_t *ct = fqe, *ct2 = (ct7_entry_t *)storage2;
2091 			uint16_t swd = ct->ct_scsi_status & 0xff;
2092 
2093 			dsp64 = &ct->rsp.m0.ds;
2094 			seglim = 1;
2095 			if ((ct->ct_flags & CT7_SENDSTATUS) && (swd || ct->ct_resid)) {
2096 				memcpy(ct2, ct, sizeof (ct7_entry_t));
2097 
2098 				/*
2099 				 * Clear fields from first CTIO7 that now need to be cleared
2100 				 */
2101 				ct->ct_header.rqs_seqno = 0;
2102 				ct->ct_flags &= ~CT7_SENDSTATUS;
2103 				ct->ct_resid = 0;
2104 				ct->ct_syshandle = 0;
2105 				ct->ct_scsi_status = 0;
2106 
2107 				/*
2108 				 * Reset fields in the second CTIO7 as appropriate.
2109 				 */
2110 				ct2->ct_flags &= ~(CT7_FLAG_MMASK|CT7_DATAMASK);
2111 				ct2->ct_flags |= CT7_NO_DATA|CT7_NO_DATA|CT7_FLAG_MODE1;
2112 				ct2->ct_seg_count = 0;
2113 				memset(&ct2->rsp, 0, sizeof (ct2->rsp));
2114 				if (swd == SCSI_CHECK && snsptr && snslen) {
2115 					ct2->rsp.m1.ct_resplen = min(snslen, MAXRESPLEN_24XX);
2116 					memcpy(ct2->rsp.m1.ct_resp, snsptr, ct2->rsp.m1.ct_resplen);
2117 					swd |= (FCP_SNSLEN_VALID << 8);
2118 				}
2119 				if (ct2->ct_resid < 0) {
2120 					swd |= (FCP_RESID_OVERFLOW << 8);
2121 				} else if (ct2->ct_resid > 0) {
2122 					swd |= (FCP_RESID_UNDERFLOW << 8);
2123 				}
2124 				ct2->ct_scsi_status = swd;
2125 				sqe = storage2;
2126 			}
2127 			break;
2128 		}
2129 		default:
2130 			return (CMD_COMPLETE);
2131 		}
2132 	}
2133 
2134 	/*
2135 	 * Fill out the data transfer stuff in the first queue entry
2136 	 */
2137 	if (seglim > nsegs) {
2138 		seglim = nsegs;
2139 	}
2140 
2141 	for (seg = curseg = 0; curseg < seglim; curseg++) {
2142 		if (dsp64) {
2143 			XS_GET_DMA64_SEG(dsp64++, segp, seg++);
2144 		} else {
2145 			XS_GET_DMA_SEG(dsp++, segp, seg++);
2146 		}
2147 	}
2148 
2149 	/*
2150 	 * First, if we are sending status with data and we have a non-zero
2151 	 * status or non-zero residual, we have to make a synthetic extra CTIO
2152 	 * that contains the status that we'll ship separately (FC cards only).
2153 	 */
2154 
2155 	/*
2156 	 * Second, start building additional continuation segments as needed.
2157 	 */
2158 	while (seg < nsegs) {
2159 		nxtnxt = ISP_NXT_QENTRY(nxt, RQUEST_QUEUE_LEN(isp));
2160 		if (nxtnxt == isp->isp_reqodx) {
2161 			return (CMD_EAGAIN);
2162 		}
2163 		ISP_MEMZERO(storage, QENTRY_LEN);
2164 		qe1 = ISP_QUEUE_ENTRY(isp->isp_rquest, nxt);
2165 		nxt = nxtnxt;
2166 		if (dsp64) {
2167 			ispcontreq64_t *crq = (ispcontreq64_t *) storage;
2168 			seglim = ISP_CDSEG64;
2169 			crq->req_header.rqs_entry_type = RQSTYPE_A64_CONT;
2170 			crq->req_header.rqs_entry_count = 1;
2171 			dsp64 = crq->req_dataseg;
2172 		} else {
2173 			ispcontreq_t *crq = (ispcontreq_t *) storage;
2174 			seglim = ISP_CDSEG;
2175 			crq->req_header.rqs_entry_type = RQSTYPE_DATASEG;
2176 			crq->req_header.rqs_entry_count = 1;
2177 			dsp = crq->req_dataseg;
2178 		}
2179 		if (seg + seglim > nsegs) {
2180 			seglim = nsegs - seg;
2181 		}
2182 		for (curseg = 0; curseg < seglim; curseg++) {
2183 			if (dsp64) {
2184 				XS_GET_DMA64_SEG(dsp64++, segp, seg++);
2185 			} else {
2186 				XS_GET_DMA_SEG(dsp++, segp, seg++);
2187 			}
2188 		}
2189 		if (dsp64) {
2190 			isp_put_cont64_req(isp, (ispcontreq64_t *)storage, qe1);
2191 		} else {
2192 			isp_put_cont_req(isp, (ispcontreq_t *)storage, qe1);
2193 		}
2194 		if (isp->isp_dblev & ISP_LOGTDEBUG1) {
2195 			isp_print_bytes(isp, "additional queue entry", QENTRY_LEN, storage);
2196 		}
2197 		nqe++;
2198         }
2199 
2200 	/*
2201 	 * If we have a synthetic queue entry to complete things, do it here.
2202 	 */
2203 	if (sqe) {
2204 		nxtnxt = ISP_NXT_QENTRY(nxt, RQUEST_QUEUE_LEN(isp));
2205 		if (nxtnxt == isp->isp_reqodx) {
2206 			return (CMD_EAGAIN);
2207 		}
2208 		qe1 = ISP_QUEUE_ENTRY(isp->isp_rquest, nxt);
2209 		nxt = nxtnxt;
2210 		if (type == RQSTYPE_CTIO7) {
2211 			isp_put_ctio7(isp, sqe, qe1);
2212 		} else {
2213 			isp_put_ctio2(isp, sqe, qe1);
2214 		}
2215 		if (isp->isp_dblev & ISP_LOGTDEBUG1) {
2216 			isp_print_bytes(isp, "synthetic final queue entry", QENTRY_LEN, storage2);
2217 		}
2218 	}
2219 
2220 	((isphdr_t *)fqe)->rqs_entry_count = nqe;
2221 	switch (type) {
2222 	case RQSTYPE_CTIO:
2223 		((ct_entry_t *)fqe)->ct_seg_count = nsegs;
2224 		isp_put_ctio(isp, fqe, qe0);
2225 		break;
2226 	case RQSTYPE_CTIO2:
2227 	case RQSTYPE_CTIO3:
2228 		((ct2_entry_t *)fqe)->ct_seg_count = nsegs;
2229 		if (ISP_CAP_2KLOGIN(isp)) {
2230 			isp_put_ctio2e(isp, fqe, qe0);
2231 		} else {
2232 			isp_put_ctio2(isp, fqe, qe0);
2233 		}
2234 		break;
2235 	case RQSTYPE_CTIO7:
2236 		((ct7_entry_t *)fqe)->ct_seg_count = nsegs;
2237 		isp_put_ctio7(isp, fqe, qe0);
2238 		break;
2239 	default:
2240 		return (CMD_COMPLETE);
2241 	}
2242 	if (isp->isp_dblev & ISP_LOGTDEBUG1) {
2243 		isp_print_bytes(isp, "first queue entry", QENTRY_LEN, fqe);
2244 	}
2245 	ISP_ADD_REQUEST(isp, nxt);
2246 	return (CMD_QUEUED);
2247 }
2248 
2249 int
2250 isp_allocate_xs_tgt(ispsoftc_t *isp, void *xs, uint32_t *handlep)
2251 {
2252 	isp_hdl_t *hdp;
2253 
2254 	hdp = isp->isp_tgtfree;
2255 	if (hdp == NULL) {
2256 		return (-1);
2257 	}
2258 	isp->isp_tgtfree = hdp->cmd;
2259 	hdp->cmd = xs;
2260 	hdp->handle = (hdp - isp->isp_tgtlist);
2261 	hdp->handle |= (ISP_HANDLE_TARGET << ISP_HANDLE_USAGE_SHIFT);
2262 	/*
2263 	 * Target handles for SCSI cards are only 16 bits, so
2264 	 * sequence number protection will be ommitted.
2265 	 */
2266 	if (IS_FC(isp)) {
2267 		hdp->handle |= (isp->isp_seqno++ << ISP_HANDLE_SEQ_SHIFT);
2268 	}
2269 	*handlep = hdp->handle;
2270 	return (0);
2271 }
2272 
2273 void *
2274 isp_find_xs_tgt(ispsoftc_t *isp, uint32_t handle)
2275 {
2276 	if (!ISP_VALID_TGT_HANDLE(isp, handle)) {
2277 		isp_prt(isp, ISP_LOGERR, "%s: bad handle 0x%x", __func__, handle);
2278 		return (NULL);
2279 	}
2280 	return (isp->isp_tgtlist[(handle & ISP_HANDLE_CMD_MASK)].cmd);
2281 }
2282 
2283 uint32_t
2284 isp_find_tgt_handle(ispsoftc_t *isp, void *xs)
2285 {
2286 	uint32_t i, foundhdl = ISP_HANDLE_FREE;
2287 
2288 	if (xs != NULL) {
2289 		for (i = 0; i < isp->isp_maxcmds; i++) {
2290 			if (isp->isp_tgtlist[i].cmd != xs) {
2291 				continue;
2292 			}
2293 			foundhdl = isp->isp_tgtlist[i].handle;
2294 			break;
2295 		}
2296 	}
2297 	return (foundhdl);
2298 }
2299 
2300 void
2301 isp_destroy_tgt_handle(ispsoftc_t *isp, uint32_t handle)
2302 {
2303 	if (!ISP_VALID_TGT_HANDLE(isp, handle)) {
2304 		isp_prt(isp, ISP_LOGERR, "%s: bad handle 0x%x", __func__, handle);
2305 	} else {
2306 		isp->isp_tgtlist[(handle & ISP_HANDLE_CMD_MASK)].handle = ISP_HANDLE_FREE;
2307 		isp->isp_tgtlist[(handle & ISP_HANDLE_CMD_MASK)].cmd = isp->isp_tgtfree;
2308 		isp->isp_tgtfree = &isp->isp_tgtlist[(handle & ISP_HANDLE_CMD_MASK)];
2309 	}
2310 }
2311 
2312 /*
2313  * Find target mode entries
2314  */
2315 int
2316 isp_find_pdb_by_wwn(ispsoftc_t *isp, int chan, uint64_t wwn, fcportdb_t **lptr)
2317 {
2318 	fcparam *fcp;
2319 	int i;
2320 
2321 	if (chan < isp->isp_nchan) {
2322 		fcp = FCPARAM(isp, chan);
2323 		for (i = 0; i < MAX_FC_TARG; i++) {
2324 			fcportdb_t *lp = &fcp->portdb[i];
2325 
2326 			if (lp->target_mode == 0) {
2327 				continue;
2328 			}
2329 			if (lp->port_wwn == wwn) {
2330 				*lptr = lp;
2331 				return (1);
2332 			}
2333 		}
2334 	}
2335 	return (0);
2336 }
2337 
2338 int
2339 isp_find_pdb_by_loopid(ispsoftc_t *isp, int chan, uint32_t loopid, fcportdb_t **lptr)
2340 {
2341 	fcparam *fcp;
2342 	int i;
2343 
2344 	if (chan < isp->isp_nchan) {
2345 		fcp = FCPARAM(isp, chan);
2346 		for (i = 0; i < MAX_FC_TARG; i++) {
2347 			fcportdb_t *lp = &fcp->portdb[i];
2348 
2349 			if (lp->target_mode == 0) {
2350 				continue;
2351 			}
2352 			if (lp->handle == loopid) {
2353 				*lptr = lp;
2354 				return (1);
2355 			}
2356 		}
2357 	}
2358 	return (0);
2359 }
2360 
2361 int
2362 isp_find_pdb_by_sid(ispsoftc_t *isp, int chan, uint32_t sid, fcportdb_t **lptr)
2363 {
2364 	fcparam *fcp;
2365 	int i;
2366 
2367 	if (chan >= isp->isp_nchan) {
2368 		return (0);
2369 	}
2370 
2371 	fcp = FCPARAM(isp, chan);
2372 	for (i = 0; i < MAX_FC_TARG; i++) {
2373 		fcportdb_t *lp = &fcp->portdb[i];
2374 
2375 		if (lp->target_mode == 0) {
2376 			continue;
2377 		}
2378 		if (lp->portid == sid) {
2379 			*lptr = lp;
2380 			return (1);
2381 		}
2382 	}
2383 	return (0);
2384 }
2385 
2386 void
2387 isp_find_chan_by_did(ispsoftc_t *isp, uint32_t did, uint16_t *cp)
2388 {
2389 	uint16_t chan;
2390 
2391 	*cp = ISP_NOCHAN;
2392 	for (chan = 0; chan < isp->isp_nchan; chan++) {
2393 		fcparam *fcp = FCPARAM(isp, chan);
2394 		if ((fcp->role & ISP_ROLE_TARGET) == 0 || fcp->isp_fwstate != FW_READY || fcp->isp_loopstate < LOOP_PDB_RCVD) {
2395 			continue;
2396 		}
2397 		if (fcp->isp_portid == did) {
2398 			*cp = chan;
2399 			break;
2400 		}
2401 	}
2402 }
2403 
2404 /*
2405  * Add an initiator device to the port database
2406  */
2407 void
2408 isp_add_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint32_t s_id)
2409 {
2410 	fcparam *fcp;
2411 	fcportdb_t *lp;
2412 	isp_notify_t nt;
2413 	int i;
2414 
2415 	fcp = FCPARAM(isp, chan);
2416 
2417 	if (nphdl >= MAX_NPORT_HANDLE) {
2418 		isp_prt(isp, ISP_LOGWARN, "%s: Chan %d IID 0x%016llx bad N-Port handle 0x%04x Port ID 0x%06x",
2419 		    __func__, chan, (unsigned long long) ini, nphdl, s_id);
2420 		return;
2421 	}
2422 
2423 	lp = NULL;
2424 	if (fcp->isp_tgt_map[nphdl]) {
2425 		lp = &fcp->portdb[fcp->isp_tgt_map[nphdl] - 1];
2426 	} else {
2427 		/*
2428 		 * Make sure the addition of a new target mode entry doesn't duplicate entries
2429 		 * with the same N-Port handles, the same portids or the same Port WWN.
2430 		 */
2431 		for (i = 0; i < MAX_FC_TARG; i++) {
2432 			lp = &fcp->portdb[i];
2433 			if (lp->target_mode == 0) {
2434 				lp = NULL;
2435 				continue;
2436 			}
2437 			if (lp->handle == nphdl) {
2438 				break;
2439 			}
2440 			if (s_id != PORT_ANY && lp->portid == s_id) {
2441 				break;
2442 			}
2443 			if (VALID_INI(ini) && lp->port_wwn == ini) {
2444 				break;
2445 			}
2446 			lp = NULL;
2447 		}
2448 
2449 	}
2450 
2451 	if (lp) {
2452 		int something = 0;
2453 		if (lp->handle != nphdl) {
2454 			isp_prt(isp, ISP_LOGWARN, "%s: Chan %d attempt to re-enter N-port handle 0x%04x IID 0x%016llx Port ID 0x%06x finds IID 0x%016llx N-Port Handle 0x%04x Port ID 0x%06x",
2455 			    __func__, chan, nphdl, (unsigned long long)ini, s_id, (unsigned long long) lp->port_wwn, lp->handle, lp->portid);
2456 			isp_dump_portdb(isp, chan);
2457 			return;
2458 		}
2459 		if (s_id != PORT_NONE) {
2460 			if (lp->portid == PORT_NONE) {
2461 				lp->portid = s_id;
2462 				isp_prt(isp, ISP_LOGTINFO, "%s: Chan %d N-port handle 0x%04x gets Port ID 0x%06x", __func__, chan, nphdl, s_id);
2463 				something++;
2464 			} else if (lp->portid != s_id) {
2465 				isp_prt(isp, ISP_LOGTINFO, "%s: Chan %d N-port handle 0x%04x tries to change Port ID 0x%06x to 0x%06x", __func__, chan, nphdl,
2466 				    lp->portid, s_id);
2467 				isp_dump_portdb(isp, chan);
2468 				return;
2469 			}
2470 		}
2471 		if (VALID_INI(ini)) {
2472 			if (!VALID_INI(lp->port_wwn)) {
2473 				lp->port_wwn = ini;
2474 				isp_prt(isp, ISP_LOGTINFO, "%s: Chan %d N-port handle 0x%04x gets WWN 0x%016llxx", __func__, chan, nphdl, (unsigned long long) ini);
2475 				something++;
2476 			} else if (lp->port_wwn != ini) {
2477 				isp_prt(isp, ISP_LOGWARN, "%s: Chan %d N-port handle 0x%04x tries to change WWN 0x%016llx to 0x%016llx", __func__, chan, nphdl,
2478 				    (unsigned long long) lp->port_wwn, (unsigned long long) ini);
2479 				isp_dump_portdb(isp, chan);
2480 				return;
2481 			}
2482 		}
2483 
2484 		if (!something) {
2485 			isp_prt(isp, ISP_LOGWARN, "%s: Chan %d IID 0x%016llx N-Port Handle 0x%04x Port ID 0x%06x reentered", __func__, chan,
2486 			    (unsigned long long) lp->port_wwn, lp->handle, lp->portid);
2487 		}
2488 		return;
2489 	}
2490 
2491 	/*
2492 	 * Find a new spot
2493 	 */
2494 	for (i = MAX_FC_TARG - 1; i >= 0; i--) {
2495 		if (fcp->portdb[i].target_mode == 1) {
2496 			continue;
2497 		}
2498 		if (fcp->portdb[i].state == FC_PORTDB_STATE_NIL) {
2499 			break;
2500 		}
2501 	}
2502 	if (i < 0) {
2503 		isp_prt(isp, ISP_LOGWARN, "%s: Chan %d IID 0x%016llx N-Port Handle 0x%04x Port ID 0x%06x- no room in port database",
2504 		    __func__, chan, (unsigned long long) ini, nphdl, s_id);
2505 		return;
2506 	}
2507 
2508 	lp = &fcp->portdb[i];
2509 	ISP_MEMZERO(lp, sizeof (fcportdb_t));
2510 	lp->target_mode = 1;
2511 	lp->handle = nphdl;
2512 	lp->portid = s_id;
2513 	lp->port_wwn = ini;
2514 	fcp->isp_tgt_map[nphdl] = i + 1;
2515 
2516 	isp_prt(isp, ISP_LOGTINFO, "%s: Chan %d IID 0x%016llx N-Port Handle 0x%04x Port ID 0x%06x vtgt %d added", __func__, chan, (unsigned long long) ini, nphdl, s_id, fcp->isp_tgt_map[nphdl] - 1);
2517 
2518 	ISP_MEMZERO(&nt, sizeof (nt));
2519 	nt.nt_hba = isp;
2520 	nt.nt_wwn = ini;
2521 	nt.nt_tgt = FCPARAM(isp, chan)->isp_wwpn;
2522 	nt.nt_sid = s_id;
2523 	nt.nt_did = FCPARAM(isp, chan)->isp_portid;
2524 	nt.nt_nphdl = nphdl;
2525 	nt.nt_channel = chan;
2526 	nt.nt_ncode = NT_ARRIVED;
2527 	isp_async(isp, ISPASYNC_TARGET_NOTIFY, &nt);
2528 }
2529 
2530 /*
2531  * Remove a target device to the port database
2532  */
2533 void
2534 isp_del_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint32_t s_id)
2535 {
2536 	fcparam *fcp;
2537 	isp_notify_t nt;
2538 	fcportdb_t *lp;
2539 
2540 	if (nphdl >= MAX_NPORT_HANDLE) {
2541 		isp_prt(isp, ISP_LOGWARN, "%s: Chan %d IID 0x%016llx bad N-Port handle 0x%04x Port ID 0x%06x",
2542 		    __func__, chan, (unsigned long long) ini, nphdl, s_id);
2543 		return;
2544 	}
2545 
2546 	fcp = FCPARAM(isp, chan);
2547 	if (fcp->isp_tgt_map[nphdl] == 0) {
2548 		lp = NULL;
2549 	} else {
2550 		lp = &fcp->portdb[fcp->isp_tgt_map[nphdl] - 1];
2551 		if (lp->target_mode == 0) {
2552 			lp = NULL;
2553 		}
2554 	}
2555 	if (lp == NULL) {
2556 		isp_prt(isp, ISP_LOGWARN, "%s: Chan %d IID 0x%016llx N-Port Handle 0x%04x Port ID 0x%06x cannot be found to be cleared",
2557 		    __func__, chan, (unsigned long long) ini, nphdl, s_id);
2558 		isp_dump_portdb(isp, chan);
2559 		return;
2560 	}
2561 	isp_prt(isp, ISP_LOGTINFO, "%s: Chan %d IID 0x%016llx N-Port Handle 0x%04x Port ID 0x%06x vtgt %d cleared",
2562 	    __func__, chan, (unsigned long long) lp->port_wwn, nphdl, lp->portid, fcp->isp_tgt_map[nphdl] - 1);
2563 	fcp->isp_tgt_map[nphdl] = 0;
2564 
2565 	ISP_MEMZERO(&nt, sizeof (nt));
2566 	nt.nt_hba = isp;
2567 	nt.nt_wwn = lp->port_wwn;
2568 	nt.nt_tgt = FCPARAM(isp, chan)->isp_wwpn;
2569 	nt.nt_sid = lp->portid;
2570 	nt.nt_did = FCPARAM(isp, chan)->isp_portid;
2571 	nt.nt_nphdl = nphdl;
2572 	nt.nt_channel = chan;
2573 	nt.nt_ncode = NT_DEPARTED;
2574 	isp_async(isp, ISPASYNC_TARGET_NOTIFY, &nt);
2575 }
2576 
2577 void
2578 isp_del_all_wwn_entries(ispsoftc_t *isp, int chan)
2579 {
2580 	fcparam *fcp;
2581 	int i;
2582 
2583 	if (!IS_FC(isp)) {
2584 		return;
2585 	}
2586 
2587 	/*
2588 	 * Handle iterations over all channels via recursion
2589 	 */
2590 	if (chan == ISP_NOCHAN) {
2591 		for (chan = 0; chan < isp->isp_nchan; chan++) {
2592 			isp_del_all_wwn_entries(isp, chan);
2593 		}
2594 		return;
2595 	}
2596 
2597 	if (chan > isp->isp_nchan) {
2598 		return;
2599 	}
2600 
2601 	fcp = FCPARAM(isp, chan);
2602 	if (fcp == NULL) {
2603 		return;
2604 	}
2605 	for (i = 0; i < MAX_NPORT_HANDLE; i++) {
2606 		if (fcp->isp_tgt_map[i]) {
2607 			fcportdb_t *lp = &fcp->portdb[fcp->isp_tgt_map[i] - 1];
2608 			isp_del_wwn_entry(isp, chan, lp->port_wwn, lp->handle, lp->portid);
2609 		}
2610 	}
2611 }
2612 
2613 void
2614 isp_del_wwn_entries(ispsoftc_t *isp, isp_notify_t *mp)
2615 {
2616 	fcportdb_t *lp;
2617 
2618 	/*
2619 	 * Handle iterations over all channels via recursion
2620 	 */
2621 	if (mp->nt_channel == ISP_NOCHAN) {
2622 		for (mp->nt_channel = 0; mp->nt_channel < isp->isp_nchan; mp->nt_channel++) {
2623 			isp_del_wwn_entries(isp, mp);
2624 		}
2625 		mp->nt_channel = ISP_NOCHAN;
2626 		return;
2627 	}
2628 
2629 	/*
2630 	 * We have an entry which is only partially identified.
2631 	 *
2632 	 * It's only known by WWN, N-Port handle, or Port ID.
2633 	 * We need to find the actual entry so we can delete it.
2634 	 */
2635 	if (mp->nt_nphdl != NIL_HANDLE) {
2636 		if (isp_find_pdb_by_loopid(isp, mp->nt_channel, mp->nt_nphdl, &lp)) {
2637 			isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid);
2638 			return;
2639 		}
2640 	}
2641 	if (mp->nt_wwn != INI_ANY) {
2642 		if (isp_find_pdb_by_wwn(isp, mp->nt_channel, mp->nt_wwn, &lp)) {
2643 			isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid);
2644 			return;
2645 		}
2646 	}
2647 	if (mp->nt_sid != PORT_ANY && mp->nt_sid != PORT_NONE) {
2648 		if (isp_find_pdb_by_sid(isp, mp->nt_channel, mp->nt_sid, &lp)) {
2649 			isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid);
2650 			return;
2651 		}
2652 	}
2653 	isp_prt(isp, ISP_LOGWARN, "%s: Chan %d unable to find entry to delete N-port handle 0x%04x initiator WWN 0x%016llx Port ID 0x%06x", __func__,
2654 	    mp->nt_channel, mp->nt_nphdl, (unsigned long long) mp->nt_wwn, mp->nt_sid);
2655 }
2656 
2657 void
2658 isp_put_atio(ispsoftc_t *isp, at_entry_t *src, at_entry_t *dst)
2659 {
2660 	int i;
2661 	isp_put_hdr(isp, &src->at_header, &dst->at_header);
2662 	ISP_IOXPUT_16(isp, src->at_reserved, &dst->at_reserved);
2663 	ISP_IOXPUT_16(isp, src->at_handle, &dst->at_handle);
2664 	if (ISP_IS_SBUS(isp)) {
2665 		ISP_IOXPUT_8(isp, src->at_lun, &dst->at_iid);
2666 		ISP_IOXPUT_8(isp, src->at_iid, &dst->at_lun);
2667 		ISP_IOXPUT_8(isp, src->at_cdblen, &dst->at_tgt);
2668 		ISP_IOXPUT_8(isp, src->at_tgt, &dst->at_cdblen);
2669 		ISP_IOXPUT_8(isp, src->at_status, &dst->at_scsi_status);
2670 		ISP_IOXPUT_8(isp, src->at_scsi_status, &dst->at_status);
2671 		ISP_IOXPUT_8(isp, src->at_tag_val, &dst->at_tag_type);
2672 		ISP_IOXPUT_8(isp, src->at_tag_type, &dst->at_tag_val);
2673 	} else {
2674 		ISP_IOXPUT_8(isp, src->at_lun, &dst->at_lun);
2675 		ISP_IOXPUT_8(isp, src->at_iid, &dst->at_iid);
2676 		ISP_IOXPUT_8(isp, src->at_cdblen, &dst->at_cdblen);
2677 		ISP_IOXPUT_8(isp, src->at_tgt, &dst->at_tgt);
2678 		ISP_IOXPUT_8(isp, src->at_status, &dst->at_status);
2679 		ISP_IOXPUT_8(isp, src->at_scsi_status, &dst->at_scsi_status);
2680 		ISP_IOXPUT_8(isp, src->at_tag_val, &dst->at_tag_val);
2681 		ISP_IOXPUT_8(isp, src->at_tag_type, &dst->at_tag_type);
2682 	}
2683 	ISP_IOXPUT_32(isp, src->at_flags, &dst->at_flags);
2684 	for (i = 0; i < ATIO_CDBLEN; i++) {
2685 		ISP_IOXPUT_8(isp, src->at_cdb[i], &dst->at_cdb[i]);
2686 	}
2687 	for (i = 0; i < QLTM_SENSELEN; i++) {
2688 		ISP_IOXPUT_8(isp, src->at_sense[i], &dst->at_sense[i]);
2689 	}
2690 }
2691 
2692 void
2693 isp_get_atio(ispsoftc_t *isp, at_entry_t *src, at_entry_t *dst)
2694 {
2695 	int i;
2696 	isp_get_hdr(isp, &src->at_header, &dst->at_header);
2697 	ISP_IOXGET_16(isp, &src->at_reserved, dst->at_reserved);
2698 	ISP_IOXGET_16(isp, &src->at_handle, dst->at_handle);
2699 	if (ISP_IS_SBUS(isp)) {
2700 		ISP_IOXGET_8(isp, &src->at_lun, dst->at_iid);
2701 		ISP_IOXGET_8(isp, &src->at_iid, dst->at_lun);
2702 		ISP_IOXGET_8(isp, &src->at_cdblen, dst->at_tgt);
2703 		ISP_IOXGET_8(isp, &src->at_tgt, dst->at_cdblen);
2704 		ISP_IOXGET_8(isp, &src->at_status, dst->at_scsi_status);
2705 		ISP_IOXGET_8(isp, &src->at_scsi_status, dst->at_status);
2706 		ISP_IOXGET_8(isp, &src->at_tag_val, dst->at_tag_type);
2707 		ISP_IOXGET_8(isp, &src->at_tag_type, dst->at_tag_val);
2708 	} else {
2709 		ISP_IOXGET_8(isp, &src->at_lun, dst->at_lun);
2710 		ISP_IOXGET_8(isp, &src->at_iid, dst->at_iid);
2711 		ISP_IOXGET_8(isp, &src->at_cdblen, dst->at_cdblen);
2712 		ISP_IOXGET_8(isp, &src->at_tgt, dst->at_tgt);
2713 		ISP_IOXGET_8(isp, &src->at_status, dst->at_status);
2714 		ISP_IOXGET_8(isp, &src->at_scsi_status, dst->at_scsi_status);
2715 		ISP_IOXGET_8(isp, &src->at_tag_val, dst->at_tag_val);
2716 		ISP_IOXGET_8(isp, &src->at_tag_type, dst->at_tag_type);
2717 	}
2718 	ISP_IOXGET_32(isp, &src->at_flags, dst->at_flags);
2719 	for (i = 0; i < ATIO_CDBLEN; i++) {
2720 		ISP_IOXGET_8(isp, &src->at_cdb[i], dst->at_cdb[i]);
2721 	}
2722 	for (i = 0; i < QLTM_SENSELEN; i++) {
2723 		ISP_IOXGET_8(isp, &src->at_sense[i], dst->at_sense[i]);
2724 	}
2725 }
2726 
2727 void
2728 isp_put_atio2(ispsoftc_t *isp, at2_entry_t *src, at2_entry_t *dst)
2729 {
2730 	int i;
2731 	isp_put_hdr(isp, &src->at_header, &dst->at_header);
2732 	ISP_IOXPUT_32(isp, src->at_reserved, &dst->at_reserved);
2733 	ISP_IOXPUT_8(isp, src->at_lun, &dst->at_lun);
2734 	ISP_IOXPUT_8(isp, src->at_iid, &dst->at_iid);
2735 	ISP_IOXPUT_16(isp, src->at_rxid, &dst->at_rxid);
2736 	ISP_IOXPUT_16(isp, src->at_flags, &dst->at_flags);
2737 	ISP_IOXPUT_16(isp, src->at_status, &dst->at_status);
2738 	ISP_IOXPUT_8(isp, src->at_crn, &dst->at_crn);
2739 	ISP_IOXPUT_8(isp, src->at_taskcodes, &dst->at_taskcodes);
2740 	ISP_IOXPUT_8(isp, src->at_taskflags, &dst->at_taskflags);
2741 	ISP_IOXPUT_8(isp, src->at_execodes, &dst->at_execodes);
2742 	for (i = 0; i < ATIO2_CDBLEN; i++) {
2743 		ISP_IOXPUT_8(isp, src->at_cdb[i], &dst->at_cdb[i]);
2744 	}
2745 	ISP_IOXPUT_32(isp, src->at_datalen, &dst->at_datalen);
2746 	ISP_IOXPUT_16(isp, src->at_scclun, &dst->at_scclun);
2747 	for (i = 0; i < 4; i++) {
2748 		ISP_IOXPUT_16(isp, src->at_wwpn[i], &dst->at_wwpn[i]);
2749 	}
2750 	for (i = 0; i < 6; i++) {
2751 		ISP_IOXPUT_16(isp, src->at_reserved2[i], &dst->at_reserved2[i]);
2752 	}
2753 	ISP_IOXPUT_16(isp, src->at_oxid, &dst->at_oxid);
2754 }
2755 
2756 void
2757 isp_put_atio2e(ispsoftc_t *isp, at2e_entry_t *src, at2e_entry_t *dst)
2758 {
2759 	int i;
2760 	isp_put_hdr(isp, &src->at_header, &dst->at_header);
2761 	ISP_IOXPUT_32(isp, src->at_reserved, &dst->at_reserved);
2762 	ISP_IOXPUT_16(isp, src->at_iid, &dst->at_iid);
2763 	ISP_IOXPUT_16(isp, src->at_rxid, &dst->at_rxid);
2764 	ISP_IOXPUT_16(isp, src->at_flags, &dst->at_flags);
2765 	ISP_IOXPUT_16(isp, src->at_status, &dst->at_status);
2766 	ISP_IOXPUT_8(isp, src->at_crn, &dst->at_crn);
2767 	ISP_IOXPUT_8(isp, src->at_taskcodes, &dst->at_taskcodes);
2768 	ISP_IOXPUT_8(isp, src->at_taskflags, &dst->at_taskflags);
2769 	ISP_IOXPUT_8(isp, src->at_execodes, &dst->at_execodes);
2770 	for (i = 0; i < ATIO2_CDBLEN; i++) {
2771 		ISP_IOXPUT_8(isp, src->at_cdb[i], &dst->at_cdb[i]);
2772 	}
2773 	ISP_IOXPUT_32(isp, src->at_datalen, &dst->at_datalen);
2774 	ISP_IOXPUT_16(isp, src->at_scclun, &dst->at_scclun);
2775 	for (i = 0; i < 4; i++) {
2776 		ISP_IOXPUT_16(isp, src->at_wwpn[i], &dst->at_wwpn[i]);
2777 	}
2778 	for (i = 0; i < 6; i++) {
2779 		ISP_IOXPUT_16(isp, src->at_reserved2[i], &dst->at_reserved2[i]);
2780 	}
2781 	ISP_IOXPUT_16(isp, src->at_oxid, &dst->at_oxid);
2782 }
2783 
2784 void
2785 isp_get_atio2(ispsoftc_t *isp, at2_entry_t *src, at2_entry_t *dst)
2786 {
2787 	int i;
2788 	isp_get_hdr(isp, &src->at_header, &dst->at_header);
2789 	ISP_IOXGET_32(isp, &src->at_reserved, dst->at_reserved);
2790 	ISP_IOXGET_8(isp, &src->at_lun, dst->at_lun);
2791 	ISP_IOXGET_8(isp, &src->at_iid, dst->at_iid);
2792 	ISP_IOXGET_16(isp, &src->at_rxid, dst->at_rxid);
2793 	ISP_IOXGET_16(isp, &src->at_flags, dst->at_flags);
2794 	ISP_IOXGET_16(isp, &src->at_status, dst->at_status);
2795 	ISP_IOXGET_8(isp, &src->at_crn, dst->at_crn);
2796 	ISP_IOXGET_8(isp, &src->at_taskcodes, dst->at_taskcodes);
2797 	ISP_IOXGET_8(isp, &src->at_taskflags, dst->at_taskflags);
2798 	ISP_IOXGET_8(isp, &src->at_execodes, dst->at_execodes);
2799 	for (i = 0; i < ATIO2_CDBLEN; i++) {
2800 		ISP_IOXGET_8(isp, &src->at_cdb[i], dst->at_cdb[i]);
2801 	}
2802 	ISP_IOXGET_32(isp, &src->at_datalen, dst->at_datalen);
2803 	ISP_IOXGET_16(isp, &src->at_scclun, dst->at_scclun);
2804 	for (i = 0; i < 4; i++) {
2805 		ISP_IOXGET_16(isp, &src->at_wwpn[i], dst->at_wwpn[i]);
2806 	}
2807 	for (i = 0; i < 6; i++) {
2808 		ISP_IOXGET_16(isp, &src->at_reserved2[i], dst->at_reserved2[i]);
2809 	}
2810 	ISP_IOXGET_16(isp, &src->at_oxid, dst->at_oxid);
2811 }
2812 
2813 void
2814 isp_get_atio2e(ispsoftc_t *isp, at2e_entry_t *src, at2e_entry_t *dst)
2815 {
2816 	int i;
2817 	isp_get_hdr(isp, &src->at_header, &dst->at_header);
2818 	ISP_IOXGET_32(isp, &src->at_reserved, dst->at_reserved);
2819 	ISP_IOXGET_16(isp, &src->at_iid, dst->at_iid);
2820 	ISP_IOXGET_16(isp, &src->at_rxid, dst->at_rxid);
2821 	ISP_IOXGET_16(isp, &src->at_flags, dst->at_flags);
2822 	ISP_IOXGET_16(isp, &src->at_status, dst->at_status);
2823 	ISP_IOXGET_8(isp, &src->at_crn, dst->at_crn);
2824 	ISP_IOXGET_8(isp, &src->at_taskcodes, dst->at_taskcodes);
2825 	ISP_IOXGET_8(isp, &src->at_taskflags, dst->at_taskflags);
2826 	ISP_IOXGET_8(isp, &src->at_execodes, dst->at_execodes);
2827 	for (i = 0; i < ATIO2_CDBLEN; i++) {
2828 		ISP_IOXGET_8(isp, &src->at_cdb[i], dst->at_cdb[i]);
2829 	}
2830 	ISP_IOXGET_32(isp, &src->at_datalen, dst->at_datalen);
2831 	ISP_IOXGET_16(isp, &src->at_scclun, dst->at_scclun);
2832 	for (i = 0; i < 4; i++) {
2833 		ISP_IOXGET_16(isp, &src->at_wwpn[i], dst->at_wwpn[i]);
2834 	}
2835 	for (i = 0; i < 6; i++) {
2836 		ISP_IOXGET_16(isp, &src->at_reserved2[i], dst->at_reserved2[i]);
2837 	}
2838 	ISP_IOXGET_16(isp, &src->at_oxid, dst->at_oxid);
2839 }
2840 
2841 void
2842 isp_get_atio7(ispsoftc_t *isp, at7_entry_t *src, at7_entry_t *dst)
2843 {
2844 	ISP_IOXGET_8(isp, &src->at_type, dst->at_type);
2845 	ISP_IOXGET_8(isp, &src->at_count, dst->at_count);
2846 	ISP_IOXGET_16(isp, &src->at_ta_len, dst->at_ta_len);
2847 	ISP_IOXGET_32(isp, &src->at_rxid, dst->at_rxid);
2848 	isp_get_fc_hdr(isp, &src->at_hdr, &dst->at_hdr);
2849 	isp_get_fcp_cmnd_iu(isp, &src->at_cmnd, &dst->at_cmnd);
2850 }
2851 
2852 void
2853 isp_put_ctio(ispsoftc_t *isp, ct_entry_t *src, ct_entry_t *dst)
2854 {
2855 	int i;
2856 	isp_put_hdr(isp, &src->ct_header, &dst->ct_header);
2857 	ISP_IOXPUT_16(isp, src->ct_syshandle, &dst->ct_syshandle);
2858 	ISP_IOXPUT_16(isp, src->ct_fwhandle, &dst->ct_fwhandle);
2859 	if (ISP_IS_SBUS(isp)) {
2860 		ISP_IOXPUT_8(isp, src->ct_iid, &dst->ct_lun);
2861 		ISP_IOXPUT_8(isp, src->ct_lun, &dst->ct_iid);
2862 		ISP_IOXPUT_8(isp, src->ct_tgt, &dst->ct_reserved2);
2863 		ISP_IOXPUT_8(isp, src->ct_reserved2, &dst->ct_tgt);
2864 		ISP_IOXPUT_8(isp, src->ct_status, &dst->ct_scsi_status);
2865 		ISP_IOXPUT_8(isp, src->ct_scsi_status, &dst->ct_status);
2866 		ISP_IOXPUT_8(isp, src->ct_tag_type, &dst->ct_tag_val);
2867 		ISP_IOXPUT_8(isp, src->ct_tag_val, &dst->ct_tag_type);
2868 	} else {
2869 		ISP_IOXPUT_8(isp, src->ct_iid, &dst->ct_iid);
2870 		ISP_IOXPUT_8(isp, src->ct_lun, &dst->ct_lun);
2871 		ISP_IOXPUT_8(isp, src->ct_tgt, &dst->ct_tgt);
2872 		ISP_IOXPUT_8(isp, src->ct_reserved2, &dst->ct_reserved2);
2873 		ISP_IOXPUT_8(isp, src->ct_scsi_status,
2874 		    &dst->ct_scsi_status);
2875 		ISP_IOXPUT_8(isp, src->ct_status, &dst->ct_status);
2876 		ISP_IOXPUT_8(isp, src->ct_tag_type, &dst->ct_tag_type);
2877 		ISP_IOXPUT_8(isp, src->ct_tag_val, &dst->ct_tag_val);
2878 	}
2879 	ISP_IOXPUT_32(isp, src->ct_flags, &dst->ct_flags);
2880 	ISP_IOXPUT_32(isp, src->ct_xfrlen, &dst->ct_xfrlen);
2881 	ISP_IOXPUT_32(isp, src->ct_resid, &dst->ct_resid);
2882 	ISP_IOXPUT_16(isp, src->ct_timeout, &dst->ct_timeout);
2883 	ISP_IOXPUT_16(isp, src->ct_seg_count, &dst->ct_seg_count);
2884 	for (i = 0; i < ISP_RQDSEG; i++) {
2885 		ISP_IOXPUT_32(isp, src->ct_dataseg[i].ds_base, &dst->ct_dataseg[i].ds_base);
2886 		ISP_IOXPUT_32(isp, src->ct_dataseg[i].ds_count, &dst->ct_dataseg[i].ds_count);
2887 	}
2888 }
2889 
2890 void
2891 isp_get_ctio(ispsoftc_t *isp, ct_entry_t *src, ct_entry_t *dst)
2892 {
2893 	int i;
2894 	isp_get_hdr(isp, &src->ct_header, &dst->ct_header);
2895 	ISP_IOXGET_16(isp, &src->ct_syshandle, dst->ct_syshandle);
2896 	ISP_IOXGET_16(isp, &src->ct_fwhandle, dst->ct_fwhandle);
2897 	if (ISP_IS_SBUS(isp)) {
2898 		ISP_IOXGET_8(isp, &src->ct_lun, dst->ct_iid);
2899 		ISP_IOXGET_8(isp, &src->ct_iid, dst->ct_lun);
2900 		ISP_IOXGET_8(isp, &src->ct_reserved2, dst->ct_tgt);
2901 		ISP_IOXGET_8(isp, &src->ct_tgt, dst->ct_reserved2);
2902 		ISP_IOXGET_8(isp, &src->ct_status, dst->ct_scsi_status);
2903 		ISP_IOXGET_8(isp, &src->ct_scsi_status, dst->ct_status);
2904 		ISP_IOXGET_8(isp, &src->ct_tag_val, dst->ct_tag_type);
2905 		ISP_IOXGET_8(isp, &src->ct_tag_type, dst->ct_tag_val);
2906 	} else {
2907 		ISP_IOXGET_8(isp, &src->ct_lun, dst->ct_lun);
2908 		ISP_IOXGET_8(isp, &src->ct_iid, dst->ct_iid);
2909 		ISP_IOXGET_8(isp, &src->ct_reserved2, dst->ct_reserved2);
2910 		ISP_IOXGET_8(isp, &src->ct_tgt, dst->ct_tgt);
2911 		ISP_IOXGET_8(isp, &src->ct_status, dst->ct_status);
2912 		ISP_IOXGET_8(isp, &src->ct_scsi_status, dst->ct_scsi_status);
2913 		ISP_IOXGET_8(isp, &src->ct_tag_val, dst->ct_tag_val);
2914 		ISP_IOXGET_8(isp, &src->ct_tag_type, dst->ct_tag_type);
2915 	}
2916 	ISP_IOXGET_32(isp, &src->ct_flags, dst->ct_flags);
2917 	ISP_IOXGET_32(isp, &src->ct_xfrlen, dst->ct_xfrlen);
2918 	ISP_IOXGET_32(isp, &src->ct_resid, dst->ct_resid);
2919 	ISP_IOXGET_16(isp, &src->ct_timeout, dst->ct_timeout);
2920 	ISP_IOXGET_16(isp, &src->ct_seg_count, dst->ct_seg_count);
2921 	for (i = 0; i < ISP_RQDSEG; i++) {
2922 		ISP_IOXGET_32(isp, &src->ct_dataseg[i].ds_base, dst->ct_dataseg[i].ds_base);
2923 		ISP_IOXGET_32(isp, &src->ct_dataseg[i].ds_count, dst->ct_dataseg[i].ds_count);
2924 	}
2925 }
2926 
2927 void
2928 isp_put_ctio2(ispsoftc_t *isp, ct2_entry_t *src, ct2_entry_t *dst)
2929 {
2930 	int i;
2931 	isp_put_hdr(isp, &src->ct_header, &dst->ct_header);
2932 	ISP_IOXPUT_32(isp, src->ct_syshandle, &dst->ct_syshandle);
2933 	ISP_IOXPUT_8(isp, src->ct_lun, &dst->ct_lun);
2934 	ISP_IOXPUT_8(isp, src->ct_iid, &dst->ct_iid);
2935 	ISP_IOXPUT_16(isp, src->ct_rxid, &dst->ct_rxid);
2936 	ISP_IOXPUT_16(isp, src->ct_flags, &dst->ct_flags);
2937 	ISP_IOXPUT_16(isp, src->ct_timeout, &dst->ct_timeout);
2938 	ISP_IOXPUT_16(isp, src->ct_seg_count, &dst->ct_seg_count);
2939 	ISP_IOXPUT_32(isp, src->ct_resid, &dst->ct_resid);
2940 	ISP_IOXPUT_32(isp, src->ct_reloff, &dst->ct_reloff);
2941 	if ((src->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE0) {
2942 		ISP_IOXPUT_32(isp, src->rsp.m0._reserved, &dst->rsp.m0._reserved);
2943 		ISP_IOXPUT_16(isp, src->rsp.m0._reserved2, &dst->rsp.m0._reserved2);
2944 		ISP_IOXPUT_16(isp, src->rsp.m0.ct_scsi_status, &dst->rsp.m0.ct_scsi_status);
2945 		ISP_IOXPUT_32(isp, src->rsp.m0.ct_xfrlen, &dst->rsp.m0.ct_xfrlen);
2946 		if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO2) {
2947 			for (i = 0; i < ISP_RQDSEG_T2; i++) {
2948 				ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dataseg[i].ds_base, &dst->rsp.m0.u.ct_dataseg[i].ds_base);
2949 				ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dataseg[i].ds_count, &dst->rsp.m0.u.ct_dataseg[i].ds_count);
2950 			}
2951 		} else if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO3) {
2952 			for (i = 0; i < ISP_RQDSEG_T3; i++) {
2953 				ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dataseg64[i].ds_base, &dst->rsp.m0.u.ct_dataseg64[i].ds_base);
2954 				ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dataseg64[i].ds_basehi, &dst->rsp.m0.u.ct_dataseg64[i].ds_basehi);
2955 				ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dataseg64[i].ds_count, &dst->rsp.m0.u.ct_dataseg64[i].ds_count);
2956 			}
2957 		} else if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO4) {
2958 			ISP_IOXPUT_16(isp, src->rsp.m0.u.ct_dslist.ds_type, &dst->rsp.m0.u.ct_dslist.ds_type); ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dslist.ds_segment,
2959 			    &dst->rsp.m0.u.ct_dslist.ds_segment);
2960 			ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dslist.ds_base, &dst->rsp.m0.u.ct_dslist.ds_base);
2961 		}
2962 	} else if ((src->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE1) {
2963 		ISP_IOXPUT_16(isp, src->rsp.m1._reserved, &dst->rsp.m1._reserved);
2964 		ISP_IOXPUT_16(isp, src->rsp.m1._reserved2, &dst->rsp.m1._reserved2);
2965 		ISP_IOXPUT_16(isp, src->rsp.m1.ct_senselen, &dst->rsp.m1.ct_senselen);
2966 		ISP_IOXPUT_16(isp, src->rsp.m1.ct_scsi_status, &dst->rsp.m1.ct_scsi_status);
2967 		ISP_IOXPUT_16(isp, src->rsp.m1.ct_resplen, &dst->rsp.m1.ct_resplen);
2968 		for (i = 0; i < MAXRESPLEN; i++) {
2969 			ISP_IOXPUT_8(isp, src->rsp.m1.ct_resp[i], &dst->rsp.m1.ct_resp[i]);
2970 		}
2971 	} else {
2972 		ISP_IOXPUT_32(isp, src->rsp.m2._reserved, &dst->rsp.m2._reserved);
2973 		ISP_IOXPUT_16(isp, src->rsp.m2._reserved2, &dst->rsp.m2._reserved2);
2974 		ISP_IOXPUT_16(isp, src->rsp.m2._reserved3, &dst->rsp.m2._reserved3);
2975 		ISP_IOXPUT_32(isp, src->rsp.m2.ct_datalen, &dst->rsp.m2.ct_datalen);
2976 		ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_base, &dst->rsp.m2.ct_fcp_rsp_iudata.ds_base);
2977 		ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_count, &dst->rsp.m2.ct_fcp_rsp_iudata.ds_count);
2978 	}
2979 }
2980 
2981 void
2982 isp_put_ctio2e(ispsoftc_t *isp, ct2e_entry_t *src, ct2e_entry_t *dst)
2983 {
2984 	int i;
2985 	isp_put_hdr(isp, &src->ct_header, &dst->ct_header);
2986 	ISP_IOXPUT_32(isp, src->ct_syshandle, &dst->ct_syshandle);
2987 	ISP_IOXPUT_16(isp, src->ct_iid, &dst->ct_iid);
2988 	ISP_IOXPUT_16(isp, src->ct_rxid, &dst->ct_rxid);
2989 	ISP_IOXPUT_16(isp, src->ct_flags, &dst->ct_flags);
2990 	ISP_IOXPUT_16(isp, src->ct_timeout, &dst->ct_timeout);
2991 	ISP_IOXPUT_16(isp, src->ct_seg_count, &dst->ct_seg_count);
2992 	ISP_IOXPUT_32(isp, src->ct_resid, &dst->ct_resid);
2993 	ISP_IOXPUT_32(isp, src->ct_reloff, &dst->ct_reloff);
2994 	if ((src->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE0) {
2995 		ISP_IOXPUT_32(isp, src->rsp.m0._reserved, &dst->rsp.m0._reserved);
2996 		ISP_IOXPUT_16(isp, src->rsp.m0._reserved2, &dst->rsp.m0._reserved2);
2997 		ISP_IOXPUT_16(isp, src->rsp.m0.ct_scsi_status, &dst->rsp.m0.ct_scsi_status);
2998 		ISP_IOXPUT_32(isp, src->rsp.m0.ct_xfrlen, &dst->rsp.m0.ct_xfrlen);
2999 		if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO2) {
3000 			for (i = 0; i < ISP_RQDSEG_T2; i++) {
3001 				ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dataseg[i].ds_base, &dst->rsp.m0.u.ct_dataseg[i].ds_base);
3002 				ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dataseg[i].ds_count, &dst->rsp.m0.u.ct_dataseg[i].ds_count);
3003 			}
3004 		} else if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO3) {
3005 			for (i = 0; i < ISP_RQDSEG_T3; i++) {
3006 				ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dataseg64[i].ds_base, &dst->rsp.m0.u.ct_dataseg64[i].ds_base);
3007 				ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dataseg64[i].ds_basehi, &dst->rsp.m0.u.ct_dataseg64[i].ds_basehi);
3008 				ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dataseg64[i].ds_count, &dst->rsp.m0.u.ct_dataseg64[i].ds_count);
3009 			}
3010 		} else if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO4) {
3011 			ISP_IOXPUT_16(isp, src->rsp.m0.u.ct_dslist.ds_type, &dst->rsp.m0.u.ct_dslist.ds_type);
3012 			ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dslist.ds_segment, &dst->rsp.m0.u.ct_dslist.ds_segment);
3013 			ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dslist.ds_base, &dst->rsp.m0.u.ct_dslist.ds_base);
3014 		}
3015 	} else if ((src->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE1) {
3016 		ISP_IOXPUT_16(isp, src->rsp.m1._reserved, &dst->rsp.m1._reserved);
3017 		ISP_IOXPUT_16(isp, src->rsp.m1._reserved2, &dst->rsp.m1._reserved2);
3018 		ISP_IOXPUT_16(isp, src->rsp.m1.ct_senselen, &dst->rsp.m1.ct_senselen);
3019 		ISP_IOXPUT_16(isp, src->rsp.m1.ct_scsi_status, &dst->rsp.m1.ct_scsi_status);
3020 		ISP_IOXPUT_16(isp, src->rsp.m1.ct_resplen, &dst->rsp.m1.ct_resplen);
3021 		for (i = 0; i < MAXRESPLEN; i++) {
3022 			ISP_IOXPUT_8(isp, src->rsp.m1.ct_resp[i], &dst->rsp.m1.ct_resp[i]);
3023 		}
3024 	} else {
3025 		ISP_IOXPUT_32(isp, src->rsp.m2._reserved, &dst->rsp.m2._reserved);
3026 		ISP_IOXPUT_16(isp, src->rsp.m2._reserved2, &dst->rsp.m2._reserved2);
3027 		ISP_IOXPUT_16(isp, src->rsp.m2._reserved3, &dst->rsp.m2._reserved3);
3028 		ISP_IOXPUT_32(isp, src->rsp.m2.ct_datalen, &dst->rsp.m2.ct_datalen);
3029 		ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_base, &dst->rsp.m2.ct_fcp_rsp_iudata.ds_base);
3030 		ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_count, &dst->rsp.m2.ct_fcp_rsp_iudata.ds_count);
3031 	}
3032 }
3033 
3034 void
3035 isp_put_ctio7(ispsoftc_t *isp, ct7_entry_t *src, ct7_entry_t *dst)
3036 {
3037 	int i;
3038 
3039 	isp_put_hdr(isp, &src->ct_header, &dst->ct_header);
3040 	ISP_IOXPUT_32(isp, src->ct_syshandle, &dst->ct_syshandle);
3041 	ISP_IOXPUT_16(isp, src->ct_nphdl, &dst->ct_nphdl);
3042 	ISP_IOXPUT_16(isp, src->ct_timeout, &dst->ct_timeout);
3043 	ISP_IOXPUT_16(isp, src->ct_seg_count, &dst->ct_seg_count);
3044 	ISP_IOXPUT_8(isp, src->ct_vpidx, &dst->ct_vpidx);
3045 	ISP_IOXPUT_8(isp, src->ct_xflags, &dst->ct_xflags);
3046 	ISP_IOXPUT_16(isp, src->ct_iid_lo, &dst->ct_iid_lo);
3047 	ISP_IOXPUT_8(isp, src->ct_iid_hi, &dst->ct_iid_hi);
3048 	ISP_IOXPUT_8(isp, src->ct_reserved, &dst->ct_reserved);
3049 	ISP_IOXPUT_32(isp, src->ct_rxid, &dst->ct_rxid);
3050 	ISP_IOXPUT_16(isp, src->ct_senselen, &dst->ct_senselen);
3051 	ISP_IOXPUT_16(isp, src->ct_flags, &dst->ct_flags);
3052 	ISP_IOXPUT_32(isp, src->ct_resid, &dst->ct_resid);
3053 	ISP_IOXPUT_16(isp, src->ct_oxid, &dst->ct_oxid);
3054 	ISP_IOXPUT_16(isp, src->ct_scsi_status, &dst->ct_scsi_status);
3055 	if ((dst->ct_flags & CT7_FLAG_MMASK) == CT7_FLAG_MODE0) {
3056 		ISP_IOXPUT_32(isp, src->rsp.m0.reloff, &dst->rsp.m0.reloff);
3057 		ISP_IOXPUT_32(isp, src->rsp.m0.reserved0, &dst->rsp.m0.reserved0);
3058 		ISP_IOXPUT_32(isp, src->rsp.m0.ct_xfrlen, &dst->rsp.m0.ct_xfrlen);
3059 		ISP_IOXPUT_32(isp, src->rsp.m0.reserved1, &dst->rsp.m0.reserved1);
3060 		ISP_IOXPUT_32(isp, src->rsp.m0.ds.ds_base, &dst->rsp.m0.ds.ds_base);
3061 		ISP_IOXPUT_32(isp, src->rsp.m0.ds.ds_basehi, &dst->rsp.m0.ds.ds_basehi);
3062 		ISP_IOXPUT_32(isp, src->rsp.m0.ds.ds_count, &dst->rsp.m0.ds.ds_count);
3063 	} else if ((dst->ct_flags & CT7_FLAG_MMASK) == CT7_FLAG_MODE1) {
3064 		uint32_t *a, *b;
3065 
3066 		ISP_IOXPUT_16(isp, src->rsp.m1.ct_resplen, &dst->rsp.m1.ct_resplen);
3067 		ISP_IOXPUT_16(isp, src->rsp.m1.reserved, &dst->rsp.m1.reserved);
3068 		a = (uint32_t *) src->rsp.m1.ct_resp;
3069 		b = (uint32_t *) dst->rsp.m1.ct_resp;
3070 		for (i = 0; i < (ASIZE(src->rsp.m1.ct_resp) >> 2); i++) {
3071 			*b++ = ISP_SWAP32(isp, *a++);
3072 		}
3073 	} else {
3074 		ISP_IOXPUT_32(isp, src->rsp.m2.reserved0, &dst->rsp.m2.reserved0);
3075 		ISP_IOXPUT_32(isp, src->rsp.m2.ct_datalen, &dst->rsp.m2.ct_datalen);
3076 		ISP_IOXPUT_32(isp, src->rsp.m2.reserved1, &dst->rsp.m2.reserved1);
3077 		ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_base, &dst->rsp.m2.ct_fcp_rsp_iudata.ds_base);
3078 		ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_basehi, &dst->rsp.m2.ct_fcp_rsp_iudata.ds_basehi);
3079 		ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_count, &dst->rsp.m2.ct_fcp_rsp_iudata.ds_count);
3080 	}
3081 }
3082 
3083 
3084 void
3085 isp_get_ctio2(ispsoftc_t *isp, ct2_entry_t *src, ct2_entry_t *dst)
3086 {
3087 	int i;
3088 
3089 	isp_get_hdr(isp, &src->ct_header, &dst->ct_header);
3090 	ISP_IOXGET_32(isp, &src->ct_syshandle, dst->ct_syshandle);
3091 	ISP_IOXGET_8(isp, &src->ct_lun, dst->ct_lun);
3092 	ISP_IOXGET_8(isp, &src->ct_iid, dst->ct_iid);
3093 	ISP_IOXGET_16(isp, &src->ct_rxid, dst->ct_rxid);
3094 	ISP_IOXGET_16(isp, &src->ct_flags, dst->ct_flags);
3095 	ISP_IOXGET_16(isp, &src->ct_status, dst->ct_status);
3096 	ISP_IOXGET_16(isp, &src->ct_timeout, dst->ct_timeout);
3097 	ISP_IOXGET_16(isp, &src->ct_seg_count, dst->ct_seg_count);
3098 	ISP_IOXGET_32(isp, &src->ct_reloff, dst->ct_reloff);
3099 	ISP_IOXGET_32(isp, &src->ct_resid, dst->ct_resid);
3100 	if ((dst->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE0) {
3101 		ISP_IOXGET_32(isp, &src->rsp.m0._reserved, dst->rsp.m0._reserved);
3102 		ISP_IOXGET_16(isp, &src->rsp.m0._reserved2, dst->rsp.m0._reserved2);
3103 		ISP_IOXGET_16(isp, &src->rsp.m0.ct_scsi_status, dst->rsp.m0.ct_scsi_status);
3104 		ISP_IOXGET_32(isp, &src->rsp.m0.ct_xfrlen, dst->rsp.m0.ct_xfrlen);
3105 		if (dst->ct_header.rqs_entry_type == RQSTYPE_CTIO2) {
3106 			for (i = 0; i < ISP_RQDSEG_T2; i++) {
3107 				ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dataseg[i].ds_base, dst->rsp.m0.u.ct_dataseg[i].ds_base);
3108 				ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dataseg[i].ds_count, dst->rsp.m0.u.ct_dataseg[i].ds_count);
3109 			}
3110 		} else if (dst->ct_header.rqs_entry_type == RQSTYPE_CTIO3) {
3111 			for (i = 0; i < ISP_RQDSEG_T3; i++) {
3112 				ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dataseg64[i].ds_base, dst->rsp.m0.u.ct_dataseg64[i].ds_base);
3113 				ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dataseg64[i].ds_basehi, dst->rsp.m0.u.ct_dataseg64[i].ds_basehi);
3114 				ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dataseg64[i].ds_count, dst->rsp.m0.u.ct_dataseg64[i].ds_count);
3115 			}
3116 		} else if (dst->ct_header.rqs_entry_type == RQSTYPE_CTIO4) {
3117 			ISP_IOXGET_16(isp, &src->rsp.m0.u.ct_dslist.ds_type, dst->rsp.m0.u.ct_dslist.ds_type);
3118 			ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dslist.ds_segment, dst->rsp.m0.u.ct_dslist.ds_segment);
3119 			ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dslist.ds_base, dst->rsp.m0.u.ct_dslist.ds_base);
3120 		}
3121 	} else if ((dst->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE1) {
3122 		ISP_IOXGET_16(isp, &src->rsp.m1._reserved, dst->rsp.m1._reserved);
3123 		ISP_IOXGET_16(isp, &src->rsp.m1._reserved2, dst->rsp.m1._reserved2);
3124 		ISP_IOXGET_16(isp, &src->rsp.m1.ct_senselen, dst->rsp.m1.ct_senselen);
3125 		ISP_IOXGET_16(isp, &src->rsp.m1.ct_scsi_status, dst->rsp.m1.ct_scsi_status);
3126 		ISP_IOXGET_16(isp, &src->rsp.m1.ct_resplen, dst->rsp.m1.ct_resplen);
3127 		for (i = 0; i < MAXRESPLEN; i++) {
3128 			ISP_IOXGET_8(isp, &src->rsp.m1.ct_resp[i], dst->rsp.m1.ct_resp[i]);
3129 		}
3130 	} else {
3131 		ISP_IOXGET_32(isp, &src->rsp.m2._reserved, dst->rsp.m2._reserved);
3132 		ISP_IOXGET_16(isp, &src->rsp.m2._reserved2, dst->rsp.m2._reserved2);
3133 		ISP_IOXGET_16(isp, &src->rsp.m2._reserved3, dst->rsp.m2._reserved3);
3134 		ISP_IOXGET_32(isp, &src->rsp.m2.ct_datalen, dst->rsp.m2.ct_datalen);
3135 		ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_base, dst->rsp.m2.ct_fcp_rsp_iudata.ds_base);
3136 		ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_count, dst->rsp.m2.ct_fcp_rsp_iudata.ds_count);
3137 	}
3138 }
3139 
3140 void
3141 isp_get_ctio2e(ispsoftc_t *isp, ct2e_entry_t *src, ct2e_entry_t *dst)
3142 {
3143 	int i;
3144 
3145 	isp_get_hdr(isp, &src->ct_header, &dst->ct_header);
3146 	ISP_IOXGET_32(isp, &src->ct_syshandle, dst->ct_syshandle);
3147 	ISP_IOXGET_16(isp, &src->ct_iid, dst->ct_iid);
3148 	ISP_IOXGET_16(isp, &src->ct_rxid, dst->ct_rxid);
3149 	ISP_IOXGET_16(isp, &src->ct_flags, dst->ct_flags);
3150 	ISP_IOXGET_16(isp, &src->ct_status, dst->ct_status);
3151 	ISP_IOXGET_16(isp, &src->ct_timeout, dst->ct_timeout);
3152 	ISP_IOXGET_16(isp, &src->ct_seg_count, dst->ct_seg_count);
3153 	ISP_IOXGET_32(isp, &src->ct_reloff, dst->ct_reloff);
3154 	ISP_IOXGET_32(isp, &src->ct_resid, dst->ct_resid);
3155 	if ((dst->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE0) {
3156 		ISP_IOXGET_32(isp, &src->rsp.m0._reserved, dst->rsp.m0._reserved);
3157 		ISP_IOXGET_16(isp, &src->rsp.m0._reserved2, dst->rsp.m0._reserved2);
3158 		ISP_IOXGET_16(isp, &src->rsp.m0.ct_scsi_status, dst->rsp.m0.ct_scsi_status);
3159 		ISP_IOXGET_32(isp, &src->rsp.m0.ct_xfrlen, dst->rsp.m0.ct_xfrlen);
3160 		if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO2) {
3161 			for (i = 0; i < ISP_RQDSEG_T2; i++) {
3162 				ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dataseg[i].ds_base, dst->rsp.m0.u.ct_dataseg[i].ds_base);
3163 				ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dataseg[i].ds_count, dst->rsp.m0.u.ct_dataseg[i].ds_count);
3164 			}
3165 		} else if (dst->ct_header.rqs_entry_type == RQSTYPE_CTIO3) {
3166 			for (i = 0; i < ISP_RQDSEG_T3; i++) {
3167 				ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dataseg64[i].ds_base, dst->rsp.m0.u.ct_dataseg64[i].ds_base);
3168 				ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dataseg64[i].ds_basehi, dst->rsp.m0.u.ct_dataseg64[i].ds_basehi);
3169 				ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dataseg64[i].ds_count, dst->rsp.m0.u.ct_dataseg64[i].ds_count);
3170 			}
3171 		} else if (dst->ct_header.rqs_entry_type == RQSTYPE_CTIO4) {
3172 			ISP_IOXGET_16(isp, &src->rsp.m0.u.ct_dslist.ds_type, dst->rsp.m0.u.ct_dslist.ds_type);
3173 			ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dslist.ds_segment, dst->rsp.m0.u.ct_dslist.ds_segment);
3174 			ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dslist.ds_base, dst->rsp.m0.u.ct_dslist.ds_base);
3175 		}
3176 	} else if ((dst->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE1) {
3177 		ISP_IOXGET_16(isp, &src->rsp.m1._reserved, dst->rsp.m1._reserved);
3178 		ISP_IOXGET_16(isp, &src->rsp.m1._reserved2, dst->rsp.m1._reserved2);
3179 		ISP_IOXGET_16(isp, &src->rsp.m1.ct_senselen, dst->rsp.m1.ct_senselen);
3180 		ISP_IOXGET_16(isp, &src->rsp.m1.ct_scsi_status, dst->rsp.m1.ct_scsi_status);
3181 		ISP_IOXGET_16(isp, &src->rsp.m1.ct_resplen, dst->rsp.m1.ct_resplen);
3182 		for (i = 0; i < MAXRESPLEN; i++) {
3183 			ISP_IOXGET_8(isp, &src->rsp.m1.ct_resp[i], dst->rsp.m1.ct_resp[i]);
3184 		}
3185 	} else {
3186 		ISP_IOXGET_32(isp, &src->rsp.m2._reserved, dst->rsp.m2._reserved);
3187 		ISP_IOXGET_16(isp, &src->rsp.m2._reserved2, dst->rsp.m2._reserved2);
3188 		ISP_IOXGET_16(isp, &src->rsp.m2._reserved3, dst->rsp.m2._reserved3);
3189 		ISP_IOXGET_32(isp, &src->rsp.m2.ct_datalen, dst->rsp.m2.ct_datalen);
3190 		ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_base, dst->rsp.m2.ct_fcp_rsp_iudata.ds_base);
3191 		ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_count, dst->rsp.m2.ct_fcp_rsp_iudata.ds_count);
3192 	}
3193 }
3194 
3195 void
3196 isp_get_ctio7(ispsoftc_t *isp, ct7_entry_t *src, ct7_entry_t *dst)
3197 {
3198 	int i;
3199 
3200 	isp_get_hdr(isp, &src->ct_header, &dst->ct_header);
3201 	ISP_IOXGET_32(isp, &src->ct_syshandle, dst->ct_syshandle);
3202 	ISP_IOXGET_16(isp, &src->ct_nphdl, dst->ct_nphdl);
3203 	ISP_IOXGET_16(isp, &src->ct_timeout, dst->ct_timeout);
3204 	ISP_IOXGET_16(isp, &src->ct_seg_count, dst->ct_seg_count);
3205 	ISP_IOXGET_8(isp, &src->ct_vpidx, dst->ct_vpidx);
3206 	ISP_IOXGET_8(isp, &src->ct_xflags, dst->ct_xflags);
3207 	ISP_IOXGET_16(isp, &src->ct_iid_lo, dst->ct_iid_lo);
3208 	ISP_IOXGET_8(isp, &src->ct_iid_hi, dst->ct_iid_hi);
3209 	ISP_IOXGET_8(isp, &src->ct_reserved, dst->ct_reserved);
3210 	ISP_IOXGET_32(isp, &src->ct_rxid, dst->ct_rxid);
3211 	ISP_IOXGET_16(isp, &src->ct_senselen, dst->ct_senselen);
3212 	ISP_IOXGET_16(isp, &src->ct_flags, dst->ct_flags);
3213 	ISP_IOXGET_32(isp, &src->ct_resid, dst->ct_resid);
3214 	ISP_IOXGET_16(isp, &src->ct_oxid, dst->ct_oxid);
3215 	ISP_IOXGET_16(isp, &src->ct_scsi_status, dst->ct_scsi_status);
3216 	if ((dst->ct_flags & CT7_FLAG_MMASK) == CT7_FLAG_MODE0) {
3217 		ISP_IOXGET_32(isp, &src->rsp.m0.reloff, dst->rsp.m0.reloff);
3218 		ISP_IOXGET_32(isp, &src->rsp.m0.reserved0, dst->rsp.m0.reserved0);
3219 		ISP_IOXGET_32(isp, &src->rsp.m0.ct_xfrlen, dst->rsp.m0.ct_xfrlen);
3220 		ISP_IOXGET_32(isp, &src->rsp.m0.reserved1, dst->rsp.m0.reserved1);
3221 		ISP_IOXGET_32(isp, &src->rsp.m0.ds.ds_base, dst->rsp.m0.ds.ds_base);
3222 		ISP_IOXGET_32(isp, &src->rsp.m0.ds.ds_basehi, dst->rsp.m0.ds.ds_basehi);
3223 		ISP_IOXGET_32(isp, &src->rsp.m0.ds.ds_count, dst->rsp.m0.ds.ds_count);
3224 	} else if ((dst->ct_flags & CT7_FLAG_MMASK) == CT7_FLAG_MODE1) {
3225 		uint32_t *a, *b;
3226 
3227 		ISP_IOXGET_16(isp, &src->rsp.m1.ct_resplen, dst->rsp.m1.ct_resplen);
3228 		ISP_IOXGET_16(isp, &src->rsp.m1.reserved, dst->rsp.m1.reserved);
3229 		a = (uint32_t *) src->rsp.m1.ct_resp;
3230 		b = (uint32_t *) dst->rsp.m1.ct_resp;
3231 		for (i = 0; i < MAXRESPLEN_24XX; i++) {
3232 			ISP_IOXGET_8(isp, &src->rsp.m1.ct_resp[i], dst->rsp.m1.ct_resp[i]);
3233 		}
3234 		for (i = 0; i < (ASIZE(src->rsp.m1.ct_resp) >> 2); i++) {
3235 			*b++ = ISP_SWAP32(isp, *a++);
3236 		}
3237 	} else {
3238 		ISP_IOXGET_32(isp, &src->rsp.m2.reserved0, dst->rsp.m2.reserved0);
3239 		ISP_IOXGET_32(isp, &src->rsp.m2.ct_datalen, dst->rsp.m2.ct_datalen);
3240 		ISP_IOXGET_32(isp, &src->rsp.m2.reserved1, dst->rsp.m2.reserved1);
3241 		ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_base, dst->rsp.m2.ct_fcp_rsp_iudata.ds_base);
3242 		ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_basehi, dst->rsp.m2.ct_fcp_rsp_iudata.ds_basehi);
3243 		ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_count, dst->rsp.m2.ct_fcp_rsp_iudata.ds_count);
3244 	}
3245 }
3246 
3247 void
3248 isp_put_enable_lun(ispsoftc_t *isp, lun_entry_t *lesrc, lun_entry_t *ledst)
3249 {
3250 	int i;
3251 	isp_put_hdr(isp, &lesrc->le_header, &ledst->le_header);
3252 	ISP_IOXPUT_32(isp, lesrc->le_reserved, &ledst->le_reserved);
3253 	if (ISP_IS_SBUS(isp)) {
3254 		ISP_IOXPUT_8(isp, lesrc->le_lun, &ledst->le_rsvd);
3255 		ISP_IOXPUT_8(isp, lesrc->le_rsvd, &ledst->le_lun);
3256 		ISP_IOXPUT_8(isp, lesrc->le_ops, &ledst->le_tgt);
3257 		ISP_IOXPUT_8(isp, lesrc->le_tgt, &ledst->le_ops);
3258 		ISP_IOXPUT_8(isp, lesrc->le_status, &ledst->le_reserved2);
3259 		ISP_IOXPUT_8(isp, lesrc->le_reserved2, &ledst->le_status);
3260 		ISP_IOXPUT_8(isp, lesrc->le_cmd_count, &ledst->le_in_count);
3261 		ISP_IOXPUT_8(isp, lesrc->le_in_count, &ledst->le_cmd_count);
3262 		ISP_IOXPUT_8(isp, lesrc->le_cdb6len, &ledst->le_cdb7len);
3263 		ISP_IOXPUT_8(isp, lesrc->le_cdb7len, &ledst->le_cdb6len);
3264 	} else {
3265 		ISP_IOXPUT_8(isp, lesrc->le_lun, &ledst->le_lun);
3266 		ISP_IOXPUT_8(isp, lesrc->le_rsvd, &ledst->le_rsvd);
3267 		ISP_IOXPUT_8(isp, lesrc->le_ops, &ledst->le_ops);
3268 		ISP_IOXPUT_8(isp, lesrc->le_tgt, &ledst->le_tgt);
3269 		ISP_IOXPUT_8(isp, lesrc->le_status, &ledst->le_status);
3270 		ISP_IOXPUT_8(isp, lesrc->le_reserved2, &ledst->le_reserved2);
3271 		ISP_IOXPUT_8(isp, lesrc->le_cmd_count, &ledst->le_cmd_count);
3272 		ISP_IOXPUT_8(isp, lesrc->le_in_count, &ledst->le_in_count);
3273 		ISP_IOXPUT_8(isp, lesrc->le_cdb6len, &ledst->le_cdb6len);
3274 		ISP_IOXPUT_8(isp, lesrc->le_cdb7len, &ledst->le_cdb7len);
3275 	}
3276 	ISP_IOXPUT_32(isp, lesrc->le_flags, &ledst->le_flags);
3277 	ISP_IOXPUT_16(isp, lesrc->le_timeout, &ledst->le_timeout);
3278 	for (i = 0; i < 20; i++) {
3279 		ISP_IOXPUT_8(isp, lesrc->le_reserved3[i], &ledst->le_reserved3[i]);
3280 	}
3281 }
3282 
3283 void
3284 isp_get_enable_lun(ispsoftc_t *isp, lun_entry_t *lesrc, lun_entry_t *ledst)
3285 {
3286 	int i;
3287 	isp_get_hdr(isp, &lesrc->le_header, &ledst->le_header);
3288 	ISP_IOXGET_32(isp, &lesrc->le_reserved, ledst->le_reserved);
3289 	if (ISP_IS_SBUS(isp)) {
3290 		ISP_IOXGET_8(isp, &lesrc->le_lun, ledst->le_rsvd);
3291 		ISP_IOXGET_8(isp, &lesrc->le_rsvd, ledst->le_lun);
3292 		ISP_IOXGET_8(isp, &lesrc->le_ops, ledst->le_tgt);
3293 		ISP_IOXGET_8(isp, &lesrc->le_tgt, ledst->le_ops);
3294 		ISP_IOXGET_8(isp, &lesrc->le_status, ledst->le_reserved2);
3295 		ISP_IOXGET_8(isp, &lesrc->le_reserved2, ledst->le_status);
3296 		ISP_IOXGET_8(isp, &lesrc->le_cmd_count, ledst->le_in_count);
3297 		ISP_IOXGET_8(isp, &lesrc->le_in_count, ledst->le_cmd_count);
3298 		ISP_IOXGET_8(isp, &lesrc->le_cdb6len, ledst->le_cdb7len);
3299 		ISP_IOXGET_8(isp, &lesrc->le_cdb7len, ledst->le_cdb6len);
3300 	} else {
3301 		ISP_IOXGET_8(isp, &lesrc->le_lun, ledst->le_lun);
3302 		ISP_IOXGET_8(isp, &lesrc->le_rsvd, ledst->le_rsvd);
3303 		ISP_IOXGET_8(isp, &lesrc->le_ops, ledst->le_ops);
3304 		ISP_IOXGET_8(isp, &lesrc->le_tgt, ledst->le_tgt);
3305 		ISP_IOXGET_8(isp, &lesrc->le_status, ledst->le_status);
3306 		ISP_IOXGET_8(isp, &lesrc->le_reserved2, ledst->le_reserved2);
3307 		ISP_IOXGET_8(isp, &lesrc->le_cmd_count, ledst->le_cmd_count);
3308 		ISP_IOXGET_8(isp, &lesrc->le_in_count, ledst->le_in_count);
3309 		ISP_IOXGET_8(isp, &lesrc->le_cdb6len, ledst->le_cdb6len);
3310 		ISP_IOXGET_8(isp, &lesrc->le_cdb7len, ledst->le_cdb7len);
3311 	}
3312 	ISP_IOXGET_32(isp, &lesrc->le_flags, ledst->le_flags);
3313 	ISP_IOXGET_16(isp, &lesrc->le_timeout, ledst->le_timeout);
3314 	for (i = 0; i < 20; i++) {
3315 		ISP_IOXGET_8(isp, &lesrc->le_reserved3[i], ledst->le_reserved3[i]);
3316 	}
3317 }
3318 
3319 void
3320 isp_put_notify(ispsoftc_t *isp, in_entry_t *src, in_entry_t *dst)
3321 {
3322 	int i;
3323 	isp_put_hdr(isp, &src->in_header, &dst->in_header);
3324 	ISP_IOXPUT_32(isp, src->in_reserved, &dst->in_reserved);
3325 	if (ISP_IS_SBUS(isp)) {
3326 		ISP_IOXPUT_8(isp, src->in_lun, &dst->in_iid);
3327 		ISP_IOXPUT_8(isp, src->in_iid, &dst->in_lun);
3328 		ISP_IOXPUT_8(isp, src->in_reserved2, &dst->in_tgt);
3329 		ISP_IOXPUT_8(isp, src->in_tgt, &dst->in_reserved2);
3330 		ISP_IOXPUT_8(isp, src->in_status, &dst->in_rsvd2);
3331 		ISP_IOXPUT_8(isp, src->in_rsvd2, &dst->in_status);
3332 		ISP_IOXPUT_8(isp, src->in_tag_val, &dst->in_tag_type);
3333 		ISP_IOXPUT_8(isp, src->in_tag_type, &dst->in_tag_val);
3334 	} else {
3335 		ISP_IOXPUT_8(isp, src->in_lun, &dst->in_lun);
3336 		ISP_IOXPUT_8(isp, src->in_iid, &dst->in_iid);
3337 		ISP_IOXPUT_8(isp, src->in_reserved2, &dst->in_reserved2);
3338 		ISP_IOXPUT_8(isp, src->in_tgt, &dst->in_tgt);
3339 		ISP_IOXPUT_8(isp, src->in_status, &dst->in_status);
3340 		ISP_IOXPUT_8(isp, src->in_rsvd2, &dst->in_rsvd2);
3341 		ISP_IOXPUT_8(isp, src->in_tag_val, &dst->in_tag_val);
3342 		ISP_IOXPUT_8(isp, src->in_tag_type, &dst->in_tag_type);
3343 	}
3344 	ISP_IOXPUT_32(isp, src->in_flags, &dst->in_flags);
3345 	ISP_IOXPUT_16(isp, src->in_seqid, &dst->in_seqid);
3346 	for (i = 0; i < IN_MSGLEN; i++) {
3347 		ISP_IOXPUT_8(isp, src->in_msg[i], &dst->in_msg[i]);
3348 	}
3349 	for (i = 0; i < IN_RSVDLEN; i++) {
3350 		ISP_IOXPUT_8(isp, src->in_reserved3[i], &dst->in_reserved3[i]);
3351 	}
3352 	for (i = 0; i < QLTM_SENSELEN; i++) {
3353 		ISP_IOXPUT_8(isp, src->in_sense[i], &dst->in_sense[i]);
3354 	}
3355 }
3356 
3357 void
3358 isp_get_notify(ispsoftc_t *isp, in_entry_t *src, in_entry_t *dst)
3359 {
3360 	int i;
3361 	isp_get_hdr(isp, &src->in_header, &dst->in_header);
3362 	ISP_IOXGET_32(isp, &src->in_reserved, dst->in_reserved);
3363 	if (ISP_IS_SBUS(isp)) {
3364 		ISP_IOXGET_8(isp, &src->in_lun, dst->in_iid);
3365 		ISP_IOXGET_8(isp, &src->in_iid, dst->in_lun);
3366 		ISP_IOXGET_8(isp, &src->in_reserved2, dst->in_tgt);
3367 		ISP_IOXGET_8(isp, &src->in_tgt, dst->in_reserved2);
3368 		ISP_IOXGET_8(isp, &src->in_status, dst->in_rsvd2);
3369 		ISP_IOXGET_8(isp, &src->in_rsvd2, dst->in_status);
3370 		ISP_IOXGET_8(isp, &src->in_tag_val, dst->in_tag_type);
3371 		ISP_IOXGET_8(isp, &src->in_tag_type, dst->in_tag_val);
3372 	} else {
3373 		ISP_IOXGET_8(isp, &src->in_lun, dst->in_lun);
3374 		ISP_IOXGET_8(isp, &src->in_iid, dst->in_iid);
3375 		ISP_IOXGET_8(isp, &src->in_reserved2, dst->in_reserved2);
3376 		ISP_IOXGET_8(isp, &src->in_tgt, dst->in_tgt);
3377 		ISP_IOXGET_8(isp, &src->in_status, dst->in_status);
3378 		ISP_IOXGET_8(isp, &src->in_rsvd2, dst->in_rsvd2);
3379 		ISP_IOXGET_8(isp, &src->in_tag_val, dst->in_tag_val);
3380 		ISP_IOXGET_8(isp, &src->in_tag_type, dst->in_tag_type);
3381 	}
3382 	ISP_IOXGET_32(isp, &src->in_flags, dst->in_flags);
3383 	ISP_IOXGET_16(isp, &src->in_seqid, dst->in_seqid);
3384 	for (i = 0; i < IN_MSGLEN; i++) {
3385 		ISP_IOXGET_8(isp, &src->in_msg[i], dst->in_msg[i]);
3386 	}
3387 	for (i = 0; i < IN_RSVDLEN; i++) {
3388 		ISP_IOXGET_8(isp, &src->in_reserved3[i], dst->in_reserved3[i]);
3389 	}
3390 	for (i = 0; i < QLTM_SENSELEN; i++) {
3391 		ISP_IOXGET_8(isp, &src->in_sense[i], dst->in_sense[i]);
3392 	}
3393 }
3394 
3395 void
3396 isp_put_notify_fc(ispsoftc_t *isp, in_fcentry_t *src, in_fcentry_t *dst)
3397 {
3398 	isp_put_hdr(isp, &src->in_header, &dst->in_header);
3399 	ISP_IOXPUT_32(isp, src->in_reserved, &dst->in_reserved);
3400 	ISP_IOXPUT_8(isp, src->in_lun, &dst->in_lun);
3401 	ISP_IOXPUT_8(isp, src->in_iid, &dst->in_iid);
3402 	ISP_IOXPUT_16(isp, src->in_scclun, &dst->in_scclun);
3403 	ISP_IOXPUT_32(isp, src->in_reserved2, &dst->in_reserved2);
3404 	ISP_IOXPUT_16(isp, src->in_status, &dst->in_status);
3405 	ISP_IOXPUT_16(isp, src->in_task_flags, &dst->in_task_flags);
3406 	ISP_IOXPUT_16(isp, src->in_seqid, &dst->in_seqid);
3407 }
3408 
3409 void
3410 isp_put_notify_fc_e(ispsoftc_t *isp, in_fcentry_e_t *src, in_fcentry_e_t *dst)
3411 {
3412 	isp_put_hdr(isp, &src->in_header, &dst->in_header);
3413 	ISP_IOXPUT_32(isp, src->in_reserved, &dst->in_reserved);
3414 	ISP_IOXPUT_16(isp, src->in_iid, &dst->in_iid);
3415 	ISP_IOXPUT_16(isp, src->in_scclun, &dst->in_scclun);
3416 	ISP_IOXPUT_32(isp, src->in_reserved2, &dst->in_reserved2);
3417 	ISP_IOXPUT_16(isp, src->in_status, &dst->in_status);
3418 	ISP_IOXPUT_16(isp, src->in_task_flags, &dst->in_task_flags);
3419 	ISP_IOXPUT_16(isp, src->in_seqid, &dst->in_seqid);
3420 }
3421 
3422 void
3423 isp_put_notify_24xx(ispsoftc_t *isp, in_fcentry_24xx_t *src, in_fcentry_24xx_t *dst)
3424 {
3425 	int i;
3426 
3427 	isp_put_hdr(isp, &src->in_header, &dst->in_header);
3428 	ISP_IOXPUT_32(isp, src->in_reserved, &dst->in_reserved);
3429 	ISP_IOXPUT_16(isp, src->in_nphdl, &dst->in_nphdl);
3430 	ISP_IOXPUT_16(isp, src->in_reserved1, &dst->in_reserved1);
3431 	ISP_IOXPUT_16(isp, src->in_flags, &dst->in_flags);
3432 	ISP_IOXPUT_16(isp, src->in_srr_rxid, &dst->in_srr_rxid);
3433 	ISP_IOXPUT_16(isp, src->in_status, &dst->in_status);
3434 	ISP_IOXPUT_8(isp, src->in_status_subcode, &dst->in_status_subcode);
3435 	ISP_IOXPUT_16(isp, src->in_reserved2, &dst->in_reserved2);
3436 	ISP_IOXPUT_32(isp, src->in_rxid, &dst->in_rxid);
3437 	ISP_IOXPUT_16(isp, src->in_srr_reloff_hi, &dst->in_srr_reloff_hi);
3438 	ISP_IOXPUT_16(isp, src->in_srr_reloff_lo, &dst->in_srr_reloff_lo);
3439 	ISP_IOXPUT_16(isp, src->in_srr_iu, &dst->in_srr_iu);
3440 	ISP_IOXPUT_16(isp, src->in_srr_oxid, &dst->in_srr_oxid);
3441 	ISP_IOXPUT_16(isp, src->in_nport_id_hi, &dst->in_nport_id_hi);
3442 	ISP_IOXPUT_8(isp, src->in_nport_id_lo, &dst->in_nport_id_lo);
3443 	ISP_IOXPUT_8(isp, src->in_reserved3, &dst->in_reserved3);
3444 	ISP_IOXPUT_16(isp, src->in_np_handle, &dst->in_np_handle);
3445 	for (i = 0; i < ASIZE(src->in_reserved4); i++) {
3446 		ISP_IOXPUT_8(isp, src->in_reserved4[i], &dst->in_reserved4[i]);
3447 	}
3448 	ISP_IOXPUT_8(isp, src->in_reserved5, &dst->in_reserved5);
3449 	ISP_IOXPUT_8(isp, src->in_vpidx, &dst->in_vpidx);
3450 	ISP_IOXPUT_32(isp, src->in_reserved6, &dst->in_reserved6);
3451 	ISP_IOXPUT_16(isp, src->in_portid_lo, &dst->in_portid_lo);
3452 	ISP_IOXPUT_8(isp, src->in_portid_hi, &dst->in_portid_hi);
3453 	ISP_IOXPUT_8(isp, src->in_reserved7, &dst->in_reserved7);
3454 	ISP_IOXPUT_16(isp, src->in_reserved8, &dst->in_reserved8);
3455 	ISP_IOXPUT_16(isp, src->in_oxid, &dst->in_oxid);
3456 }
3457 
3458 void
3459 isp_get_notify_fc(ispsoftc_t *isp, in_fcentry_t *src, in_fcentry_t *dst)
3460 {
3461 	isp_get_hdr(isp, &src->in_header, &dst->in_header);
3462 	ISP_IOXGET_32(isp, &src->in_reserved, dst->in_reserved);
3463 	ISP_IOXGET_8(isp, &src->in_lun, dst->in_lun);
3464 	ISP_IOXGET_8(isp, &src->in_iid, dst->in_iid);
3465 	ISP_IOXGET_16(isp, &src->in_scclun, dst->in_scclun);
3466 	ISP_IOXGET_32(isp, &src->in_reserved2, dst->in_reserved2);
3467 	ISP_IOXGET_16(isp, &src->in_status, dst->in_status);
3468 	ISP_IOXGET_16(isp, &src->in_task_flags, dst->in_task_flags);
3469 	ISP_IOXGET_16(isp, &src->in_seqid, dst->in_seqid);
3470 }
3471 
3472 void
3473 isp_get_notify_fc_e(ispsoftc_t *isp, in_fcentry_e_t *src, in_fcentry_e_t *dst)
3474 {
3475 	isp_get_hdr(isp, &src->in_header, &dst->in_header);
3476 	ISP_IOXGET_32(isp, &src->in_reserved, dst->in_reserved);
3477 	ISP_IOXGET_16(isp, &src->in_iid, dst->in_iid);
3478 	ISP_IOXGET_16(isp, &src->in_scclun, dst->in_scclun);
3479 	ISP_IOXGET_32(isp, &src->in_reserved2, dst->in_reserved2);
3480 	ISP_IOXGET_16(isp, &src->in_status, dst->in_status);
3481 	ISP_IOXGET_16(isp, &src->in_task_flags, dst->in_task_flags);
3482 	ISP_IOXGET_16(isp, &src->in_seqid, dst->in_seqid);
3483 }
3484 
3485 void
3486 isp_get_notify_24xx(ispsoftc_t *isp, in_fcentry_24xx_t *src, in_fcentry_24xx_t *dst)
3487 {
3488 	int i;
3489 
3490 	isp_get_hdr(isp, &src->in_header, &dst->in_header);
3491 	ISP_IOXGET_32(isp, &src->in_reserved, dst->in_reserved);
3492 	ISP_IOXGET_16(isp, &src->in_nphdl, dst->in_nphdl);
3493 	ISP_IOXGET_16(isp, &src->in_reserved1, dst->in_reserved1);
3494 	ISP_IOXGET_16(isp, &src->in_flags, dst->in_flags);
3495 	ISP_IOXGET_16(isp, &src->in_srr_rxid, dst->in_srr_rxid);
3496 	ISP_IOXGET_16(isp, &src->in_status, dst->in_status);
3497 	ISP_IOXGET_8(isp, &src->in_status_subcode, dst->in_status_subcode);
3498 	ISP_IOXGET_16(isp, &src->in_reserved2, dst->in_reserved2);
3499 	ISP_IOXGET_32(isp, &src->in_rxid, dst->in_rxid);
3500 	ISP_IOXGET_16(isp, &src->in_srr_reloff_hi, dst->in_srr_reloff_hi);
3501 	ISP_IOXGET_16(isp, &src->in_srr_reloff_lo, dst->in_srr_reloff_lo);
3502 	ISP_IOXGET_16(isp, &src->in_srr_iu, dst->in_srr_iu);
3503 	ISP_IOXGET_16(isp, &src->in_srr_oxid, dst->in_srr_oxid);
3504 	ISP_IOXGET_16(isp, &src->in_nport_id_hi, dst->in_nport_id_hi);
3505 	ISP_IOXGET_8(isp, &src->in_nport_id_lo, dst->in_nport_id_lo);
3506 	ISP_IOXGET_8(isp, &src->in_reserved3, dst->in_reserved3);
3507 	ISP_IOXGET_16(isp, &src->in_np_handle, dst->in_np_handle);
3508 	for (i = 0; i < ASIZE(src->in_reserved4); i++) {
3509 		ISP_IOXGET_8(isp, &src->in_reserved4[i], dst->in_reserved4[i]);
3510 	}
3511 	ISP_IOXGET_8(isp, &src->in_reserved5, dst->in_reserved5);
3512 	ISP_IOXGET_8(isp, &src->in_vpidx, dst->in_vpidx);
3513 	ISP_IOXGET_32(isp, &src->in_reserved6, dst->in_reserved6);
3514 	ISP_IOXGET_16(isp, &src->in_portid_lo, dst->in_portid_lo);
3515 	ISP_IOXGET_8(isp, &src->in_portid_hi, dst->in_portid_hi);
3516 	ISP_IOXGET_8(isp, &src->in_reserved7, dst->in_reserved7);
3517 	ISP_IOXGET_16(isp, &src->in_reserved8, dst->in_reserved8);
3518 	ISP_IOXGET_16(isp, &src->in_oxid, dst->in_oxid);
3519 }
3520 
3521 void
3522 isp_put_notify_ack(ispsoftc_t *isp, na_entry_t *src,  na_entry_t *dst)
3523 {
3524 	int i;
3525 	isp_put_hdr(isp, &src->na_header, &dst->na_header);
3526 	ISP_IOXPUT_32(isp, src->na_reserved, &dst->na_reserved);
3527 	if (ISP_IS_SBUS(isp)) {
3528 		ISP_IOXPUT_8(isp, src->na_lun, &dst->na_iid);
3529 		ISP_IOXPUT_8(isp, src->na_iid, &dst->na_lun);
3530 		ISP_IOXPUT_8(isp, src->na_status, &dst->na_event);
3531 		ISP_IOXPUT_8(isp, src->na_event, &dst->na_status);
3532 	} else {
3533 		ISP_IOXPUT_8(isp, src->na_lun, &dst->na_lun);
3534 		ISP_IOXPUT_8(isp, src->na_iid, &dst->na_iid);
3535 		ISP_IOXPUT_8(isp, src->na_status, &dst->na_status);
3536 		ISP_IOXPUT_8(isp, src->na_event, &dst->na_event);
3537 	}
3538 	ISP_IOXPUT_32(isp, src->na_flags, &dst->na_flags);
3539 	for (i = 0; i < NA_RSVDLEN; i++) {
3540 		ISP_IOXPUT_16(isp, src->na_reserved3[i], &dst->na_reserved3[i]);
3541 	}
3542 }
3543 
3544 void
3545 isp_get_notify_ack(ispsoftc_t *isp, na_entry_t *src, na_entry_t *dst)
3546 {
3547 	int i;
3548 	isp_get_hdr(isp, &src->na_header, &dst->na_header);
3549 	ISP_IOXGET_32(isp, &src->na_reserved, dst->na_reserved);
3550 	if (ISP_IS_SBUS(isp)) {
3551 		ISP_IOXGET_8(isp, &src->na_lun, dst->na_iid);
3552 		ISP_IOXGET_8(isp, &src->na_iid, dst->na_lun);
3553 		ISP_IOXGET_8(isp, &src->na_status, dst->na_event);
3554 		ISP_IOXGET_8(isp, &src->na_event, dst->na_status);
3555 	} else {
3556 		ISP_IOXGET_8(isp, &src->na_lun, dst->na_lun);
3557 		ISP_IOXGET_8(isp, &src->na_iid, dst->na_iid);
3558 		ISP_IOXGET_8(isp, &src->na_status, dst->na_status);
3559 		ISP_IOXGET_8(isp, &src->na_event, dst->na_event);
3560 	}
3561 	ISP_IOXGET_32(isp, &src->na_flags, dst->na_flags);
3562 	for (i = 0; i < NA_RSVDLEN; i++) {
3563 		ISP_IOXGET_16(isp, &src->na_reserved3[i], dst->na_reserved3[i]);
3564 	}
3565 }
3566 
3567 void
3568 isp_put_notify_ack_fc(ispsoftc_t *isp, na_fcentry_t *src, na_fcentry_t *dst)
3569 {
3570 	int i;
3571 	isp_put_hdr(isp, &src->na_header, &dst->na_header);
3572 	ISP_IOXPUT_32(isp, src->na_reserved, &dst->na_reserved);
3573 	ISP_IOXPUT_8(isp, src->na_reserved1, &dst->na_reserved1);
3574 	ISP_IOXPUT_8(isp, src->na_iid, &dst->na_iid);
3575 	ISP_IOXPUT_16(isp, src->na_response, &dst->na_response);
3576 	ISP_IOXPUT_16(isp, src->na_flags, &dst->na_flags);
3577 	ISP_IOXPUT_16(isp, src->na_reserved2, &dst->na_reserved2);
3578 	ISP_IOXPUT_16(isp, src->na_status, &dst->na_status);
3579 	ISP_IOXPUT_16(isp, src->na_task_flags, &dst->na_task_flags);
3580 	ISP_IOXPUT_16(isp, src->na_seqid, &dst->na_seqid);
3581 	for (i = 0; i < NA2_RSVDLEN; i++) {
3582 		ISP_IOXPUT_16(isp, src->na_reserved3[i], &dst->na_reserved3[i]);
3583 	}
3584 }
3585 
3586 void
3587 isp_put_notify_ack_fc_e(ispsoftc_t *isp, na_fcentry_e_t *src, na_fcentry_e_t *dst)
3588 {
3589 	int i;
3590 	isp_put_hdr(isp, &src->na_header, &dst->na_header);
3591 	ISP_IOXPUT_32(isp, src->na_reserved, &dst->na_reserved);
3592 	ISP_IOXPUT_16(isp, src->na_iid, &dst->na_iid);
3593 	ISP_IOXPUT_16(isp, src->na_response, &dst->na_response);
3594 	ISP_IOXPUT_16(isp, src->na_flags, &dst->na_flags);
3595 	ISP_IOXPUT_16(isp, src->na_reserved2, &dst->na_reserved2);
3596 	ISP_IOXPUT_16(isp, src->na_status, &dst->na_status);
3597 	ISP_IOXPUT_16(isp, src->na_task_flags, &dst->na_task_flags);
3598 	ISP_IOXPUT_16(isp, src->na_seqid, &dst->na_seqid);
3599 	for (i = 0; i < NA2_RSVDLEN; i++) {
3600 		ISP_IOXPUT_16(isp, src->na_reserved3[i], &dst->na_reserved3[i]);
3601 	}
3602 }
3603 
3604 void
3605 isp_put_notify_24xx_ack(ispsoftc_t *isp, na_fcentry_24xx_t *src, na_fcentry_24xx_t *dst)
3606 {
3607 	int i;
3608 
3609 	isp_put_hdr(isp, &src->na_header, &dst->na_header);
3610 	ISP_IOXPUT_32(isp, src->na_handle, &dst->na_handle);
3611 	ISP_IOXPUT_16(isp, src->na_nphdl, &dst->na_nphdl);
3612 	ISP_IOXPUT_16(isp, src->na_reserved1, &dst->na_reserved1);
3613 	ISP_IOXPUT_16(isp, src->na_flags, &dst->na_flags);
3614 	ISP_IOXPUT_16(isp, src->na_srr_rxid, &dst->na_srr_rxid);
3615 	ISP_IOXPUT_16(isp, src->na_status, &dst->na_status);
3616 	ISP_IOXPUT_8(isp, src->na_status_subcode, &dst->na_status_subcode);
3617 	ISP_IOXPUT_16(isp, src->na_reserved2, &dst->na_reserved2);
3618 	ISP_IOXPUT_32(isp, src->na_rxid, &dst->na_rxid);
3619 	ISP_IOXPUT_16(isp, src->na_srr_reloff_hi, &dst->na_srr_reloff_hi);
3620 	ISP_IOXPUT_16(isp, src->na_srr_reloff_lo, &dst->na_srr_reloff_lo);
3621 	ISP_IOXPUT_16(isp, src->na_srr_iu, &dst->na_srr_iu);
3622 	ISP_IOXPUT_16(isp, src->na_srr_flags, &dst->na_srr_flags);
3623 	for (i = 0; i < 18; i++) {
3624 		ISP_IOXPUT_8(isp, src->na_reserved3[i], &dst->na_reserved3[i]);
3625 	}
3626 	ISP_IOXPUT_8(isp, src->na_reserved4, &dst->na_reserved4);
3627 	ISP_IOXPUT_8(isp, src->na_vpidx, &dst->na_vpidx);
3628 	ISP_IOXPUT_8(isp, src->na_srr_reject_vunique, &dst->na_srr_reject_vunique);
3629 	ISP_IOXPUT_8(isp, src->na_srr_reject_explanation, &dst->na_srr_reject_explanation);
3630 	ISP_IOXPUT_8(isp, src->na_srr_reject_code, &dst->na_srr_reject_code);
3631 	ISP_IOXPUT_8(isp, src->na_reserved5, &dst->na_reserved5);
3632 	for (i = 0; i < 6; i++) {
3633 		ISP_IOXPUT_8(isp, src->na_reserved6[i], &dst->na_reserved6[i]);
3634 	}
3635 	ISP_IOXPUT_16(isp, src->na_oxid, &dst->na_oxid);
3636 }
3637 
3638 void
3639 isp_get_notify_ack_fc(ispsoftc_t *isp, na_fcentry_t *src, na_fcentry_t *dst)
3640 {
3641 	int i;
3642 	isp_get_hdr(isp, &src->na_header, &dst->na_header);
3643 	ISP_IOXGET_32(isp, &src->na_reserved, dst->na_reserved);
3644 	ISP_IOXGET_8(isp, &src->na_reserved1, dst->na_reserved1);
3645 	ISP_IOXGET_8(isp, &src->na_iid, dst->na_iid);
3646 	ISP_IOXGET_16(isp, &src->na_response, dst->na_response);
3647 	ISP_IOXGET_16(isp, &src->na_flags, dst->na_flags);
3648 	ISP_IOXGET_16(isp, &src->na_reserved2, dst->na_reserved2);
3649 	ISP_IOXGET_16(isp, &src->na_status, dst->na_status);
3650 	ISP_IOXGET_16(isp, &src->na_task_flags, dst->na_task_flags);
3651 	ISP_IOXGET_16(isp, &src->na_seqid, dst->na_seqid);
3652 	for (i = 0; i < NA2_RSVDLEN; i++) {
3653 		ISP_IOXGET_16(isp, &src->na_reserved3[i], dst->na_reserved3[i]);
3654 	}
3655 }
3656 
3657 void
3658 isp_get_notify_ack_fc_e(ispsoftc_t *isp, na_fcentry_e_t *src, na_fcentry_e_t *dst)
3659 {
3660 	int i;
3661 	isp_get_hdr(isp, &src->na_header, &dst->na_header);
3662 	ISP_IOXGET_32(isp, &src->na_reserved, dst->na_reserved);
3663 	ISP_IOXGET_16(isp, &src->na_iid, dst->na_iid);
3664 	ISP_IOXGET_16(isp, &src->na_response, dst->na_response);
3665 	ISP_IOXGET_16(isp, &src->na_flags, dst->na_flags);
3666 	ISP_IOXGET_16(isp, &src->na_reserved2, dst->na_reserved2);
3667 	ISP_IOXGET_16(isp, &src->na_status, dst->na_status);
3668 	ISP_IOXGET_16(isp, &src->na_task_flags, dst->na_task_flags);
3669 	ISP_IOXGET_16(isp, &src->na_seqid, dst->na_seqid);
3670 	for (i = 0; i < NA2_RSVDLEN; i++) {
3671 		ISP_IOXGET_16(isp, &src->na_reserved3[i], dst->na_reserved3[i]);
3672 	}
3673 }
3674 
3675 void
3676 isp_get_notify_ack_24xx(ispsoftc_t *isp, na_fcentry_24xx_t *src, na_fcentry_24xx_t *dst)
3677 {
3678 	int i;
3679 
3680 	isp_get_hdr(isp, &src->na_header, &dst->na_header);
3681 	ISP_IOXGET_32(isp, &src->na_handle, dst->na_handle);
3682 	ISP_IOXGET_16(isp, &src->na_nphdl, dst->na_nphdl);
3683 	ISP_IOXGET_16(isp, &src->na_reserved1, dst->na_reserved1);
3684 	ISP_IOXGET_16(isp, &src->na_flags, dst->na_flags);
3685 	ISP_IOXGET_16(isp, &src->na_srr_rxid, dst->na_srr_rxid);
3686 	ISP_IOXGET_16(isp, &src->na_status, dst->na_status);
3687 	ISP_IOXGET_8(isp, &src->na_status_subcode, dst->na_status_subcode);
3688 	ISP_IOXGET_16(isp, &src->na_reserved2, dst->na_reserved2);
3689 	ISP_IOXGET_32(isp, &src->na_rxid, dst->na_rxid);
3690 	ISP_IOXGET_16(isp, &src->na_srr_reloff_hi, dst->na_srr_reloff_hi);
3691 	ISP_IOXGET_16(isp, &src->na_srr_reloff_lo, dst->na_srr_reloff_lo);
3692 	ISP_IOXGET_16(isp, &src->na_srr_iu, dst->na_srr_iu);
3693 	ISP_IOXGET_16(isp, &src->na_srr_flags, dst->na_srr_flags);
3694 	for (i = 0; i < 18; i++) {
3695 		ISP_IOXGET_8(isp, &src->na_reserved3[i], dst->na_reserved3[i]);
3696 	}
3697 	ISP_IOXGET_8(isp, &src->na_reserved4, dst->na_reserved4);
3698 	ISP_IOXGET_8(isp, &src->na_vpidx, dst->na_vpidx);
3699 	ISP_IOXGET_8(isp, &src->na_srr_reject_vunique, dst->na_srr_reject_vunique);
3700 	ISP_IOXGET_8(isp, &src->na_srr_reject_explanation, dst->na_srr_reject_explanation);
3701 	ISP_IOXGET_8(isp, &src->na_srr_reject_code, dst->na_srr_reject_code);
3702 	ISP_IOXGET_8(isp, &src->na_reserved5, dst->na_reserved5);
3703 	for (i = 0; i < 6; i++) {
3704 		ISP_IOXGET_8(isp, &src->na_reserved6[i], dst->na_reserved6[i]);
3705 	}
3706 	ISP_IOXGET_16(isp, &src->na_oxid, dst->na_oxid);
3707 }
3708 
3709 void
3710 isp_get_abts(ispsoftc_t *isp, abts_t *src, abts_t *dst)
3711 {
3712 	int i;
3713 
3714 	isp_get_hdr(isp, &src->abts_header, &dst->abts_header);
3715 	for (i = 0; i < 6; i++) {
3716 		ISP_IOXGET_8(isp, &src->abts_reserved0[i], dst->abts_reserved0[i]);
3717 	}
3718 	ISP_IOXGET_16(isp, &src->abts_nphdl, dst->abts_nphdl);
3719 	ISP_IOXGET_16(isp, &src->abts_reserved1, dst->abts_reserved1);
3720 	ISP_IOXGET_16(isp, &src->abts_sof, dst->abts_sof);
3721 	ISP_IOXGET_32(isp, &src->abts_rxid_abts, dst->abts_rxid_abts);
3722 	ISP_IOXGET_16(isp, &src->abts_did_lo, dst->abts_did_lo);
3723 	ISP_IOXGET_8(isp, &src->abts_did_hi, dst->abts_did_hi);
3724 	ISP_IOXGET_8(isp, &src->abts_r_ctl, dst->abts_r_ctl);
3725 	ISP_IOXGET_16(isp, &src->abts_sid_lo, dst->abts_sid_lo);
3726 	ISP_IOXGET_8(isp, &src->abts_sid_hi, dst->abts_sid_hi);
3727 	ISP_IOXGET_8(isp, &src->abts_cs_ctl, dst->abts_cs_ctl);
3728 	ISP_IOXGET_16(isp, &src->abts_fs_ctl, dst->abts_fs_ctl);
3729 	ISP_IOXGET_8(isp, &src->abts_f_ctl, dst->abts_f_ctl);
3730 	ISP_IOXGET_8(isp, &src->abts_type, dst->abts_type);
3731 	ISP_IOXGET_16(isp, &src->abts_seq_cnt, dst->abts_seq_cnt);
3732 	ISP_IOXGET_8(isp, &src->abts_df_ctl, dst->abts_df_ctl);
3733 	ISP_IOXGET_8(isp, &src->abts_seq_id, dst->abts_seq_id);
3734 	ISP_IOXGET_16(isp, &src->abts_rx_id, dst->abts_rx_id);
3735 	ISP_IOXGET_16(isp, &src->abts_ox_id, dst->abts_ox_id);
3736 	ISP_IOXGET_32(isp, &src->abts_param, dst->abts_param);
3737 	for (i = 0; i < 16; i++) {
3738 		ISP_IOXGET_8(isp, &src->abts_reserved2[i], dst->abts_reserved2[i]);
3739 	}
3740 	ISP_IOXGET_32(isp, &src->abts_rxid_task, dst->abts_rxid_task);
3741 }
3742 
3743 void
3744 isp_put_abts_rsp(ispsoftc_t *isp, abts_rsp_t *src, abts_rsp_t *dst)
3745 {
3746 	int i;
3747 
3748 	isp_put_hdr(isp, &src->abts_rsp_header, &dst->abts_rsp_header);
3749 	ISP_IOXPUT_32(isp, src->abts_rsp_handle, &dst->abts_rsp_handle);
3750 	ISP_IOXPUT_16(isp, src->abts_rsp_status, &dst->abts_rsp_status);
3751 	ISP_IOXPUT_16(isp, src->abts_rsp_nphdl, &dst->abts_rsp_nphdl);
3752 	ISP_IOXPUT_16(isp, src->abts_rsp_ctl_flags, &dst->abts_rsp_ctl_flags);
3753 	ISP_IOXPUT_16(isp, src->abts_rsp_sof, &dst->abts_rsp_sof);
3754 	ISP_IOXPUT_32(isp, src->abts_rsp_rxid_abts, &dst->abts_rsp_rxid_abts);
3755 	ISP_IOXPUT_16(isp, src->abts_rsp_did_lo, &dst->abts_rsp_did_lo);
3756 	ISP_IOXPUT_8(isp, src->abts_rsp_did_hi, &dst->abts_rsp_did_hi);
3757 	ISP_IOXPUT_8(isp, src->abts_rsp_r_ctl, &dst->abts_rsp_r_ctl);
3758 	ISP_IOXPUT_16(isp, src->abts_rsp_sid_lo, &dst->abts_rsp_sid_lo);
3759 	ISP_IOXPUT_8(isp, src->abts_rsp_sid_hi, &dst->abts_rsp_sid_hi);
3760 	ISP_IOXPUT_8(isp, src->abts_rsp_cs_ctl, &dst->abts_rsp_cs_ctl);
3761 	ISP_IOXPUT_16(isp, src->abts_rsp_f_ctl_lo, &dst->abts_rsp_f_ctl_lo);
3762 	ISP_IOXPUT_8(isp, src->abts_rsp_f_ctl_hi, &dst->abts_rsp_f_ctl_hi);
3763 	ISP_IOXPUT_8(isp, src->abts_rsp_type, &dst->abts_rsp_type);
3764 	ISP_IOXPUT_16(isp, src->abts_rsp_seq_cnt, &dst->abts_rsp_seq_cnt);
3765 	ISP_IOXPUT_8(isp, src->abts_rsp_df_ctl, &dst->abts_rsp_df_ctl);
3766 	ISP_IOXPUT_8(isp, src->abts_rsp_seq_id, &dst->abts_rsp_seq_id);
3767 	ISP_IOXPUT_16(isp, src->abts_rsp_rx_id, &dst->abts_rsp_rx_id);
3768 	ISP_IOXPUT_16(isp, src->abts_rsp_ox_id, &dst->abts_rsp_ox_id);
3769 	ISP_IOXPUT_32(isp, src->abts_rsp_param, &dst->abts_rsp_param);
3770 	if (src->abts_rsp_r_ctl == BA_ACC) {
3771 		ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.reserved, &dst->abts_rsp_payload.ba_acc.reserved);
3772 		ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_acc.last_seq_id, &dst->abts_rsp_payload.ba_acc.last_seq_id);
3773 		ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_acc.seq_id_valid, &dst->abts_rsp_payload.ba_acc.seq_id_valid);
3774 		ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.aborted_rx_id, &dst->abts_rsp_payload.ba_acc.aborted_rx_id);
3775 		ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.aborted_ox_id, &dst->abts_rsp_payload.ba_acc.aborted_ox_id);
3776 		ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.high_seq_cnt, &dst->abts_rsp_payload.ba_acc.high_seq_cnt);
3777 		ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.low_seq_cnt, &dst->abts_rsp_payload.ba_acc.low_seq_cnt);
3778 		for (i = 0; i < 4; i++) {
3779 			ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.reserved2[i], &dst->abts_rsp_payload.ba_acc.reserved2[i]);
3780 		}
3781 	} else if (src->abts_rsp_r_ctl == BA_RJT) {
3782 		ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_rjt.vendor_unique, &dst->abts_rsp_payload.ba_rjt.vendor_unique);
3783 		ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_rjt.explanation, &dst->abts_rsp_payload.ba_rjt.explanation);
3784 		ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_rjt.reason, &dst->abts_rsp_payload.ba_rjt.reason);
3785 		ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_rjt.reserved, &dst->abts_rsp_payload.ba_rjt.reserved);
3786 		for (i = 0; i < 12; i++) {
3787 			ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_rjt.reserved2[i], &dst->abts_rsp_payload.ba_rjt.reserved2[i]);
3788 		}
3789 	} else {
3790 		for (i = 0; i < 16; i++) {
3791 			ISP_IOXPUT_8(isp, src->abts_rsp_payload.reserved[i], &dst->abts_rsp_payload.reserved[i]);
3792 		}
3793 	}
3794 	ISP_IOXPUT_32(isp, src->abts_rsp_rxid_task, &dst->abts_rsp_rxid_task);
3795 }
3796 
3797 void
3798 isp_get_abts_rsp(ispsoftc_t *isp, abts_rsp_t *src, abts_rsp_t *dst)
3799 {
3800 	int i;
3801 
3802 	isp_get_hdr(isp, &src->abts_rsp_header, &dst->abts_rsp_header);
3803 	ISP_IOXGET_32(isp, &src->abts_rsp_handle, dst->abts_rsp_handle);
3804 	ISP_IOXGET_16(isp, &src->abts_rsp_status, dst->abts_rsp_status);
3805 	ISP_IOXGET_16(isp, &src->abts_rsp_nphdl, dst->abts_rsp_nphdl);
3806 	ISP_IOXGET_16(isp, &src->abts_rsp_ctl_flags, dst->abts_rsp_ctl_flags);
3807 	ISP_IOXGET_16(isp, &src->abts_rsp_sof, dst->abts_rsp_sof);
3808 	ISP_IOXGET_32(isp, &src->abts_rsp_rxid_abts, dst->abts_rsp_rxid_abts);
3809 	ISP_IOXGET_16(isp, &src->abts_rsp_did_lo, dst->abts_rsp_did_lo);
3810 	ISP_IOXGET_8(isp, &src->abts_rsp_did_hi, dst->abts_rsp_did_hi);
3811 	ISP_IOXGET_8(isp, &src->abts_rsp_r_ctl, dst->abts_rsp_r_ctl);
3812 	ISP_IOXGET_16(isp, &src->abts_rsp_sid_lo, dst->abts_rsp_sid_lo);
3813 	ISP_IOXGET_8(isp, &src->abts_rsp_sid_hi, dst->abts_rsp_sid_hi);
3814 	ISP_IOXGET_8(isp, &src->abts_rsp_cs_ctl, dst->abts_rsp_cs_ctl);
3815 	ISP_IOXGET_16(isp, &src->abts_rsp_f_ctl_lo, dst->abts_rsp_f_ctl_lo);
3816 	ISP_IOXGET_8(isp, &src->abts_rsp_f_ctl_hi, dst->abts_rsp_f_ctl_hi);
3817 	ISP_IOXGET_8(isp, &src->abts_rsp_type, dst->abts_rsp_type);
3818 	ISP_IOXGET_16(isp, &src->abts_rsp_seq_cnt, dst->abts_rsp_seq_cnt);
3819 	ISP_IOXGET_8(isp, &src->abts_rsp_df_ctl, dst->abts_rsp_df_ctl);
3820 	ISP_IOXGET_8(isp, &src->abts_rsp_seq_id, dst->abts_rsp_seq_id);
3821 	ISP_IOXGET_16(isp, &src->abts_rsp_rx_id, dst->abts_rsp_rx_id);
3822 	ISP_IOXGET_16(isp, &src->abts_rsp_ox_id, dst->abts_rsp_ox_id);
3823 	ISP_IOXGET_32(isp, &src->abts_rsp_param, dst->abts_rsp_param);
3824 	for (i = 0; i < 8; i++) {
3825 		ISP_IOXGET_8(isp, &src->abts_rsp_payload.rsp.reserved[i], dst->abts_rsp_payload.rsp.reserved[i]);
3826 	}
3827 	ISP_IOXGET_32(isp, &src->abts_rsp_payload.rsp.subcode1, dst->abts_rsp_payload.rsp.subcode1);
3828 	ISP_IOXGET_32(isp, &src->abts_rsp_payload.rsp.subcode2, dst->abts_rsp_payload.rsp.subcode2);
3829 	ISP_IOXGET_32(isp, &src->abts_rsp_rxid_task, dst->abts_rsp_rxid_task);
3830 }
3831 #endif	/* ISP_TARGET_MODE */
3832 /*
3833  * vim:ts=8:sw=8
3834  */
3835