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