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