1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2009-2020 Alexander Motin <mav@FreeBSD.org>
5 * Copyright (c) 1997-2009 by Matthew Jacob
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 */
31 /*
32 * Qlogic Host Adapter Internal Library Functions
33 */
34 #ifdef __NetBSD__
35 #include <sys/cdefs.h>
36 __KERNEL_RCSID(0, "$NetBSD$");
37 #include <dev/ic/isp_netbsd.h>
38 #endif
39 #ifdef __FreeBSD__
40 #include <sys/cdefs.h>
41 #include <dev/isp/isp_freebsd.h>
42 #endif
43 #ifdef __OpenBSD__
44 #include <dev/ic/isp_openbsd.h>
45 #endif
46 #ifdef __linux__
47 #include "isp_linux.h"
48 #endif
49 #ifdef __svr4__
50 #include "isp_solaris.h"
51 #endif
52
53 const char *isp_class3_roles[4] = {
54 "None", "Target", "Initiator", "Target/Initiator"
55 };
56
57 /*
58 * Command shipping- finish off first queue entry and do dma mapping and additional segments as needed.
59 *
60 * Called with the first queue entry at least partially filled out.
61 */
62 int
isp_send_cmd(ispsoftc_t * isp,void * fqe,void * segp,uint32_t nsegs)63 isp_send_cmd(ispsoftc_t *isp, void *fqe, void *segp, uint32_t nsegs)
64 {
65 ispcontreq64_t crq;
66 uint8_t type, nqe = 1;
67 uint32_t seg, seglim, nxt;
68 ispds64_t *dsp64 = NULL;
69 void *qe0, *qe1;
70
71 qe0 = isp_getrqentry(isp);
72 if (qe0 == NULL)
73 return (CMD_EAGAIN);
74 nxt = ISP_NXT_QENTRY(isp->isp_reqidx, RQUEST_QUEUE_LEN(isp));
75 type = ((isphdr_t *)fqe)->rqs_entry_type;
76
77 /*
78 * If we have no data to transmit, just copy the first IOCB and start it up.
79 */
80 if (nsegs == 0)
81 goto copy_and_sync;
82
83 /*
84 * First figure out how many pieces of data to transfer, what
85 * kind and how many we can put into the first queue entry.
86 */
87 switch (type) {
88 case RQSTYPE_T7RQS:
89 dsp64 = &((ispreqt7_t *)fqe)->req_dataseg;
90 seglim = 1;
91 break;
92 #ifdef ISP_TARGET_MODE
93 case RQSTYPE_CTIO7:
94 dsp64 = &((ct7_entry_t *)fqe)->rsp.m0.ds;
95 seglim = 1;
96 break;
97 #endif
98 default:
99 panic("%s: unsupported IOCB type 0x%x\n", __func__, type);
100 }
101 if (seglim > nsegs)
102 seglim = nsegs;
103 seg = 0;
104 while (seg < seglim)
105 XS_GET_DMA64_SEG(dsp64++, segp, seg++);
106
107 /*
108 * Second, start building additional continuation segments as needed.
109 */
110 while (seg < nsegs) {
111 if (!isp_rqentry_avail(isp, ++nqe))
112 return (CMD_EAGAIN);
113
114 ISP_MEMZERO(&crq, QENTRY_LEN);
115 crq.req_header.rqs_entry_type = RQSTYPE_A64_CONT;
116 crq.req_header.rqs_entry_count = 1;
117 dsp64 = crq.req_dataseg;
118
119 seglim = seg + ISP_CDSEG64;
120 if (seglim > nsegs)
121 seglim = nsegs;
122 while (seg < seglim)
123 XS_GET_DMA64_SEG(dsp64++, segp, seg++);
124
125 qe1 = ISP_QUEUE_ENTRY(isp->isp_rquest, nxt);
126 isp_put_cont64_req(isp, &crq, qe1);
127 if (isp->isp_dblev & ISP_LOGDEBUG1) {
128 isp_print_bytes(isp, "additional queue entry",
129 QENTRY_LEN, qe1);
130 }
131
132 nxt = ISP_NXT_QENTRY(nxt, RQUEST_QUEUE_LEN(isp));
133 }
134
135 copy_and_sync:
136 ((isphdr_t *)fqe)->rqs_entry_count = nqe;
137 switch (type) {
138 case RQSTYPE_T7RQS:
139 ((ispreqt7_t *)fqe)->req_seg_count = nsegs;
140 isp_put_request_t7(isp, fqe, qe0);
141 break;
142 #ifdef ISP_TARGET_MODE
143 case RQSTYPE_CTIO7:
144 if (((ct7_entry_t *)fqe)->ct_flags & CT7_FLAG_MODE2) {
145 ((ct7_entry_t *)fqe)->ct_seg_count = 1;
146 } else {
147 ((ct7_entry_t *)fqe)->ct_seg_count = nsegs;
148 }
149 isp_put_ctio7(isp, fqe, qe0);
150 break;
151 #endif
152 default:
153 panic("%s: unsupported IOCB type 0x%x\n", __func__, type);
154 }
155 if (isp->isp_dblev & ISP_LOGDEBUG1) {
156 isp_print_bytes(isp, "first queue entry", QENTRY_LEN, qe0);
157 }
158 ISP_ADD_REQUEST(isp, nxt);
159 return (0);
160 }
161
162 uint32_t
isp_allocate_handle(ispsoftc_t * isp,void * xs,int type)163 isp_allocate_handle(ispsoftc_t *isp, void *xs, int type)
164 {
165 isp_hdl_t *hdp;
166
167 hdp = isp->isp_xffree;
168 if (hdp == NULL)
169 return (ISP_HANDLE_FREE);
170 isp->isp_xffree = hdp->cmd;
171 hdp->cmd = xs;
172 hdp->handle = (hdp - isp->isp_xflist);
173 hdp->handle |= (type << ISP_HANDLE_USAGE_SHIFT);
174 hdp->handle |= (isp->isp_seqno++ << ISP_HANDLE_SEQ_SHIFT);
175 return (hdp->handle);
176 }
177
178 void *
isp_find_xs(ispsoftc_t * isp,uint32_t handle)179 isp_find_xs(ispsoftc_t *isp, uint32_t handle)
180 {
181 if (!ISP_VALID_HANDLE(isp, handle)) {
182 isp_prt(isp, ISP_LOGERR, "%s: bad handle 0x%x", __func__, handle);
183 return (NULL);
184 }
185 return (isp->isp_xflist[(handle & ISP_HANDLE_CMD_MASK)].cmd);
186 }
187
188 uint32_t
isp_find_handle(ispsoftc_t * isp,void * xs)189 isp_find_handle(ispsoftc_t *isp, void *xs)
190 {
191 uint32_t i, foundhdl = ISP_HANDLE_FREE;
192
193 if (xs != NULL) {
194 for (i = 0; i < ISP_HANDLE_NUM(isp); i++) {
195 if (isp->isp_xflist[i].cmd != xs) {
196 continue;
197 }
198 foundhdl = isp->isp_xflist[i].handle;
199 break;
200 }
201 }
202 return (foundhdl);
203 }
204
205 void
isp_destroy_handle(ispsoftc_t * isp,uint32_t handle)206 isp_destroy_handle(ispsoftc_t *isp, uint32_t handle)
207 {
208 if (!ISP_VALID_HANDLE(isp, handle)) {
209 isp_prt(isp, ISP_LOGERR, "%s: bad handle 0x%x", __func__, handle);
210 } else {
211 isp->isp_xflist[(handle & ISP_HANDLE_CMD_MASK)].handle = ISP_HANDLE_FREE;
212 isp->isp_xflist[(handle & ISP_HANDLE_CMD_MASK)].cmd = isp->isp_xffree;
213 isp->isp_xffree = &isp->isp_xflist[(handle & ISP_HANDLE_CMD_MASK)];
214 }
215 }
216
217 #define TBA (4 * (((QENTRY_LEN >> 2) * 3) + 1) + 1)
218 void
isp_print_qentry(ispsoftc_t * isp,const char * msg,int idx,void * arg)219 isp_print_qentry(ispsoftc_t *isp, const char *msg, int idx, void *arg)
220 {
221 char buf[TBA];
222 int amt, i, j;
223 uint8_t *ptr = arg;
224
225 isp_prt(isp, ISP_LOGALL, "%s index %d=>", msg, idx);
226 for (buf[0] = 0, amt = i = 0; i < 4; i++) {
227 buf[0] = 0;
228 ISP_SNPRINTF(buf, TBA, " ");
229 for (j = 0; j < (QENTRY_LEN >> 2); j++) {
230 ISP_SNPRINTF(buf, TBA, "%s %02x", buf, ptr[amt++] & 0xff);
231 }
232 isp_prt(isp, ISP_LOGALL, "%s", buf);
233 }
234 }
235
236 void
isp_print_bytes(ispsoftc_t * isp,const char * msg,int amt,void * arg)237 isp_print_bytes(ispsoftc_t *isp, const char *msg, int amt, void *arg)
238 {
239 char buf[128];
240 uint8_t *ptr = arg;
241 int off;
242
243 if (msg)
244 isp_prt(isp, ISP_LOGALL, "%s:", msg);
245 off = 0;
246 buf[0] = 0;
247 while (off < amt) {
248 int j, to;
249 to = off;
250 for (j = 0; j < 16; j++) {
251 ISP_SNPRINTF(buf, 128, "%s %02x", buf, ptr[off++] & 0xff);
252 if (off == amt) {
253 break;
254 }
255 }
256 isp_prt(isp, ISP_LOGALL, "0x%08x:%s", to, buf);
257 buf[0] = 0;
258 }
259 }
260
261 /*
262 * Do the common path to try and ensure that link is up, we've scanned
263 * the fabric (if we're on a fabric), and that we've synchronized this
264 * all with our own database and done the appropriate logins.
265 *
266 * We repeatedly check for firmware state and loop state after each
267 * action because things may have changed while we were doing this.
268 * Any failure or change of state causes us to return a nonzero value.
269 *
270 * We assume we enter here with any locks held.
271 */
272
273 int
isp_fc_runstate(ispsoftc_t * isp,int chan,int tval)274 isp_fc_runstate(ispsoftc_t *isp, int chan, int tval)
275 {
276 fcparam *fcp = FCPARAM(isp, chan);
277 int res;
278
279 again:
280 if (fcp->role == ISP_ROLE_NONE)
281 return (-1);
282 res = isp_control(isp, ISPCTL_FCLINK_TEST, chan, tval);
283 if (res > 0)
284 goto again;
285 if (res < 0)
286 return (fcp->isp_loopstate);
287 res = isp_control(isp, ISPCTL_SCAN_LOOP, chan);
288 if (res > 0)
289 goto again;
290 if (res < 0)
291 return (fcp->isp_loopstate);
292 res = isp_control(isp, ISPCTL_SCAN_FABRIC, chan);
293 if (res > 0)
294 goto again;
295 if (res < 0)
296 return (fcp->isp_loopstate);
297 res = isp_control(isp, ISPCTL_PDB_SYNC, chan);
298 if (res > 0)
299 goto again;
300 return (fcp->isp_loopstate);
301 }
302
303 /*
304 * Fibre Channel Support routines
305 */
306 void
isp_dump_portdb(ispsoftc_t * isp,int chan)307 isp_dump_portdb(ispsoftc_t *isp, int chan)
308 {
309 fcparam *fcp = FCPARAM(isp, chan);
310 int i;
311
312 for (i = 0; i < MAX_FC_TARG; i++) {
313 char buf1[64], buf2[64];
314 const char *dbs[8] = {
315 "NIL ",
316 "PROB",
317 "DEAD",
318 "CHGD",
319 "NEW ",
320 "PVLD",
321 "ZOMB",
322 "VLD "
323 };
324 fcportdb_t *lp = &fcp->portdb[i];
325
326 if (lp->state == FC_PORTDB_STATE_NIL) {
327 continue;
328 }
329 isp_gen_role_str(buf1, sizeof (buf1), lp->prli_word3);
330 isp_gen_role_str(buf2, sizeof (buf2), lp->new_prli_word3);
331 isp_prt(isp, ISP_LOGALL, "Chan %d [%d]: hdl 0x%x %s %s 0x%06x =>%s 0x%06x; WWNN 0x%08x%08x WWPN 0x%08x%08x",
332 chan, i, lp->handle, dbs[lp->state], buf1, lp->portid, buf2, lp->new_portid,
333 (uint32_t) (lp->node_wwn >> 32), (uint32_t) (lp->node_wwn), (uint32_t) (lp->port_wwn >> 32), (uint32_t) (lp->port_wwn));
334 }
335 }
336
337 void
isp_gen_role_str(char * buf,size_t len,uint16_t p3)338 isp_gen_role_str(char *buf, size_t len, uint16_t p3)
339 {
340 int nd = 0;
341 buf[0] = '(';
342 buf[1] = 0;
343 if (p3 & PRLI_WD3_ENHANCED_DISCOVERY) {
344 nd++;
345 strlcat(buf, "EDisc", len);
346 }
347 if (p3 & PRLI_WD3_REC_SUPPORT) {
348 if (nd++) {
349 strlcat(buf, ",", len);
350 }
351 strlcat(buf, "REC", len);
352 }
353 if (p3 & PRLI_WD3_TASK_RETRY_IDENTIFICATION_REQUESTED) {
354 if (nd++) {
355 strlcat(buf, ",", len);
356 }
357 strlcat(buf, "RetryID", len);
358 }
359 if (p3 & PRLI_WD3_RETRY) {
360 if (nd++) {
361 strlcat(buf, ",", len);
362 }
363 strlcat(buf, "Retry", len);
364 }
365 if (p3 & PRLI_WD3_CONFIRMED_COMPLETION_ALLOWED) {
366 if (nd++) {
367 strlcat(buf, ",", len);
368 }
369 strlcat(buf, "CNFRM", len);
370 }
371 if (p3 & PRLI_WD3_DATA_OVERLAY_ALLOWED) {
372 if (nd++) {
373 strlcat(buf, ",", len);
374 }
375 strlcat(buf, "DOver", len);
376 }
377 if (p3 & PRLI_WD3_INITIATOR_FUNCTION) {
378 if (nd++) {
379 strlcat(buf, ",", len);
380 }
381 strlcat(buf, "INI", len);
382 }
383 if (p3 & PRLI_WD3_TARGET_FUNCTION) {
384 if (nd++) {
385 strlcat(buf, ",", len);
386 }
387 strlcat(buf, "TGT", len);
388 }
389 if (p3 & PRLI_WD3_READ_FCP_XFER_RDY_DISABLED) {
390 if (nd++) {
391 strlcat(buf, ",", len);
392 }
393 strlcat(buf, "RdXfrDis", len);
394 }
395 if (p3 & PRLI_WD3_WRITE_FCP_XFER_RDY_DISABLED) {
396 if (nd++) {
397 strlcat(buf, ",", len);
398 }
399 strlcat(buf, "XfrDis", len);
400 }
401 strlcat(buf, ")", len);
402 }
403
404 const char *
isp_fc_fw_statename(int state)405 isp_fc_fw_statename(int state)
406 {
407 switch (state) {
408 case FW_CONFIG_WAIT: return "Config Wait";
409 case FW_WAIT_LINK: return "Wait Link";
410 case FW_WAIT_LOGIN: return "Wait Login";
411 case FW_READY: return "Ready";
412 case FW_LOSS_OF_SYNC: return "Loss Of Sync";
413 case FW_ERROR: return "Error";
414 case FW_REINIT: return "Re-Init";
415 case FW_NON_PART: return "Nonparticipating";
416 default: return "?????";
417 }
418 }
419
420 const char *
isp_fc_loop_statename(int state)421 isp_fc_loop_statename(int state)
422 {
423 switch (state) {
424 case LOOP_NIL: return "NIL";
425 case LOOP_HAVE_LINK: return "Have Link";
426 case LOOP_HAVE_ADDR: return "Have Address";
427 case LOOP_TESTING_LINK: return "Testing Link";
428 case LOOP_LTEST_DONE: return "Link Test Done";
429 case LOOP_SCANNING_LOOP: return "Scanning Loop";
430 case LOOP_LSCAN_DONE: return "Loop Scan Done";
431 case LOOP_SCANNING_FABRIC: return "Scanning Fabric";
432 case LOOP_FSCAN_DONE: return "Fabric Scan Done";
433 case LOOP_SYNCING_PDB: return "Syncing PDB";
434 case LOOP_READY: return "Ready";
435 default: return "?????";
436 }
437 }
438
439 const char *
isp_fc_toponame(fcparam * fcp)440 isp_fc_toponame(fcparam *fcp)
441 {
442
443 if (fcp->isp_loopstate < LOOP_HAVE_ADDR) {
444 return "Unavailable";
445 }
446 switch (fcp->isp_topo) {
447 case TOPO_NL_PORT: return "Private Loop (NL_Port)";
448 case TOPO_FL_PORT: return "Public Loop (FL_Port)";
449 case TOPO_N_PORT: return "Point-to-Point (N_Port)";
450 case TOPO_F_PORT: return "Fabric (F_Port)";
451 case TOPO_PTP_STUB: return "Point-to-Point (no response)";
452 default: return "?????";
453 }
454 }
455
456 void
isp_clear_commands(ispsoftc_t * isp)457 isp_clear_commands(ispsoftc_t *isp)
458 {
459 uint32_t tmp;
460 isp_hdl_t *hdp;
461 #ifdef ISP_TARGET_MODE
462 isp_notify_t notify;
463 #endif
464
465 for (tmp = 0; isp->isp_xflist && tmp < ISP_HANDLE_NUM(isp); tmp++) {
466
467 hdp = &isp->isp_xflist[tmp];
468 switch (ISP_H2HT(hdp->handle)) {
469 case ISP_HANDLE_INITIATOR: {
470 XS_T *xs = hdp->cmd;
471 ISP_DMAFREE(isp, xs);
472 isp_destroy_handle(isp, hdp->handle);
473 XS_SET_RESID(xs, XS_XFRLEN(xs));
474 XS_SETERR(xs, HBA_BUSRESET);
475 isp_done(xs);
476 break;
477 }
478 #ifdef ISP_TARGET_MODE
479 case ISP_HANDLE_TARGET: {
480 ct7_entry_t ctio;
481
482 ISP_DMAFREE(isp, hdp->cmd);
483 ISP_MEMZERO(&ctio, sizeof(ct7_entry_t));
484 ctio.ct_syshandle = hdp->handle;
485 ctio.ct_nphdl = CT_HBA_RESET;
486 ctio.ct_header.rqs_entry_type = RQSTYPE_CTIO7;
487 isp_async(isp, ISPASYNC_TARGET_ACTION, &ctio);
488 break;
489 }
490 #endif
491 case ISP_HANDLE_CTRL:
492 ISP_MEMZERO(hdp->cmd, QENTRY_LEN);
493 wakeup(hdp->cmd);
494 isp_destroy_handle(isp, hdp->handle);
495 break;
496 }
497 }
498 #ifdef ISP_TARGET_MODE
499 for (tmp = 0; tmp < isp->isp_nchan; tmp++) {
500 ISP_MEMZERO(¬ify, sizeof (isp_notify_t));
501 notify.nt_ncode = NT_HBA_RESET;
502 notify.nt_hba = isp;
503 notify.nt_wwn = INI_ANY;
504 notify.nt_nphdl = NIL_HANDLE;
505 notify.nt_sid = PORT_ANY;
506 notify.nt_did = PORT_ANY;
507 notify.nt_tgt = TGT_ANY;
508 notify.nt_channel = tmp;
509 notify.nt_lun = LUN_ANY;
510 notify.nt_tagval = TAG_ANY;
511 isp_async(isp, ISPASYNC_TARGET_NOTIFY, ¬ify);
512 }
513 #endif
514 }
515
516 /*
517 * Functions to move stuff to a form that the QLogic RISC engine understands
518 * and functions to move stuff back to a form the processor understands.
519 *
520 * Each platform is required to provide the 8, 16 and 32 bit
521 * swizzle and unswizzle macros (ISP_IOX{PUT|GET}_{8,16,32})
522 *
523 * The assumption is that swizzling and unswizzling is mostly done 'in place'
524 * (with a few exceptions for efficiency).
525 */
526
527 /*
528 * Swizzle/Copy Functions
529 */
530 void
isp_put_hdr(ispsoftc_t * isp,isphdr_t * hpsrc,isphdr_t * hpdst)531 isp_put_hdr(ispsoftc_t *isp, isphdr_t *hpsrc, isphdr_t *hpdst)
532 {
533 ISP_IOXPUT_8(isp, hpsrc->rqs_entry_type, &hpdst->rqs_entry_type);
534 ISP_IOXPUT_8(isp, hpsrc->rqs_entry_count, &hpdst->rqs_entry_count);
535 ISP_IOXPUT_8(isp, hpsrc->rqs_seqno, &hpdst->rqs_seqno);
536 ISP_IOXPUT_8(isp, hpsrc->rqs_flags, &hpdst->rqs_flags);
537 }
538
539 void
isp_get_hdr(ispsoftc_t * isp,isphdr_t * hpsrc,isphdr_t * hpdst)540 isp_get_hdr(ispsoftc_t *isp, isphdr_t *hpsrc, isphdr_t *hpdst)
541 {
542 ISP_IOXGET_8(isp, &hpsrc->rqs_entry_type, hpdst->rqs_entry_type);
543 ISP_IOXGET_8(isp, &hpsrc->rqs_entry_count, hpdst->rqs_entry_count);
544 ISP_IOXGET_8(isp, &hpsrc->rqs_seqno, hpdst->rqs_seqno);
545 ISP_IOXGET_8(isp, &hpsrc->rqs_flags, hpdst->rqs_flags);
546 }
547
548 int
isp_get_response_type(ispsoftc_t * isp,isphdr_t * hp)549 isp_get_response_type(ispsoftc_t *isp, isphdr_t *hp)
550 {
551 uint8_t type;
552 ISP_IOXGET_8(isp, &hp->rqs_entry_type, type);
553 return ((int)type);
554 }
555
556 void
isp_put_marker_24xx(ispsoftc_t * isp,isp_marker_24xx_t * src,isp_marker_24xx_t * dst)557 isp_put_marker_24xx(ispsoftc_t *isp, isp_marker_24xx_t *src, isp_marker_24xx_t *dst)
558 {
559 int i;
560 isp_put_hdr(isp, &src->mrk_header, &dst->mrk_header);
561 ISP_IOXPUT_32(isp, src->mrk_handle, &dst->mrk_handle);
562 ISP_IOXPUT_16(isp, src->mrk_nphdl, &dst->mrk_nphdl);
563 ISP_IOXPUT_8(isp, src->mrk_modifier, &dst->mrk_modifier);
564 ISP_IOXPUT_8(isp, src->mrk_reserved0, &dst->mrk_reserved0);
565 ISP_IOXPUT_8(isp, src->mrk_reserved1, &dst->mrk_reserved1);
566 ISP_IOXPUT_8(isp, src->mrk_vphdl, &dst->mrk_vphdl);
567 ISP_IOXPUT_8(isp, src->mrk_reserved2, &dst->mrk_reserved2);
568 for (i = 0; i < nitems(src->mrk_lun); i++) {
569 ISP_IOXPUT_8(isp, src->mrk_lun[i], &dst->mrk_lun[i]);
570 }
571 for (i = 0; i < nitems(src->mrk_reserved3); i++) {
572 ISP_IOXPUT_8(isp, src->mrk_reserved3[i], &dst->mrk_reserved3[i]);
573 }
574 }
575
576 void
isp_put_request_t7(ispsoftc_t * isp,ispreqt7_t * src,ispreqt7_t * dst)577 isp_put_request_t7(ispsoftc_t *isp, ispreqt7_t *src, ispreqt7_t *dst)
578 {
579 int i;
580 uint32_t *a, *b;
581
582 isp_put_hdr(isp, &src->req_header, &dst->req_header);
583 ISP_IOXPUT_32(isp, src->req_handle, &dst->req_handle);
584 ISP_IOXPUT_16(isp, src->req_nphdl, &dst->req_nphdl);
585 ISP_IOXPUT_16(isp, src->req_time, &dst->req_time);
586 ISP_IOXPUT_16(isp, src->req_seg_count, &dst->req_seg_count);
587 ISP_IOXPUT_16(isp, src->req_reserved, &dst->req_reserved);
588 a = (uint32_t *) src->req_lun;
589 b = (uint32_t *) dst->req_lun;
590 for (i = 0; i < (nitems(src->req_lun) >> 2); i++ ) {
591 *b++ = ISP_SWAP32(isp, *a++);
592 }
593 ISP_IOXPUT_8(isp, src->req_alen_datadir, &dst->req_alen_datadir);
594 ISP_IOXPUT_8(isp, src->req_task_management, &dst->req_task_management);
595 ISP_IOXPUT_8(isp, src->req_task_attribute, &dst->req_task_attribute);
596 ISP_IOXPUT_8(isp, src->req_crn, &dst->req_crn);
597 a = (uint32_t *) src->req_cdb;
598 b = (uint32_t *) dst->req_cdb;
599 for (i = 0; i < (nitems(src->req_cdb) >> 2); i++) {
600 *b++ = ISP_SWAP32(isp, *a++);
601 }
602 ISP_IOXPUT_32(isp, src->req_dl, &dst->req_dl);
603 ISP_IOXPUT_16(isp, src->req_tidlo, &dst->req_tidlo);
604 ISP_IOXPUT_8(isp, src->req_tidhi, &dst->req_tidhi);
605 ISP_IOXPUT_8(isp, src->req_vpidx, &dst->req_vpidx);
606 ISP_IOXPUT_32(isp, src->req_dataseg.ds_base, &dst->req_dataseg.ds_base);
607 ISP_IOXPUT_32(isp, src->req_dataseg.ds_basehi, &dst->req_dataseg.ds_basehi);
608 ISP_IOXPUT_32(isp, src->req_dataseg.ds_count, &dst->req_dataseg.ds_count);
609 }
610
611 void
isp_put_24xx_tmf(ispsoftc_t * isp,isp24xx_tmf_t * src,isp24xx_tmf_t * dst)612 isp_put_24xx_tmf(ispsoftc_t *isp, isp24xx_tmf_t *src, isp24xx_tmf_t *dst)
613 {
614 int i;
615 uint32_t *a, *b;
616
617 isp_put_hdr(isp, &src->tmf_header, &dst->tmf_header);
618 ISP_IOXPUT_32(isp, src->tmf_handle, &dst->tmf_handle);
619 ISP_IOXPUT_16(isp, src->tmf_nphdl, &dst->tmf_nphdl);
620 ISP_IOXPUT_16(isp, src->tmf_delay, &dst->tmf_delay);
621 ISP_IOXPUT_16(isp, src->tmf_timeout, &dst->tmf_timeout);
622 for (i = 0; i < nitems(src->tmf_reserved0); i++) {
623 ISP_IOXPUT_8(isp, src->tmf_reserved0[i], &dst->tmf_reserved0[i]);
624 }
625 a = (uint32_t *) src->tmf_lun;
626 b = (uint32_t *) dst->tmf_lun;
627 for (i = 0; i < (nitems(src->tmf_lun) >> 2); i++ ) {
628 *b++ = ISP_SWAP32(isp, *a++);
629 }
630 ISP_IOXPUT_32(isp, src->tmf_flags, &dst->tmf_flags);
631 for (i = 0; i < nitems(src->tmf_reserved1); i++) {
632 ISP_IOXPUT_8(isp, src->tmf_reserved1[i], &dst->tmf_reserved1[i]);
633 }
634 ISP_IOXPUT_16(isp, src->tmf_tidlo, &dst->tmf_tidlo);
635 ISP_IOXPUT_8(isp, src->tmf_tidhi, &dst->tmf_tidhi);
636 ISP_IOXPUT_8(isp, src->tmf_vpidx, &dst->tmf_vpidx);
637 for (i = 0; i < nitems(src->tmf_reserved2); i++) {
638 ISP_IOXPUT_8(isp, src->tmf_reserved2[i], &dst->tmf_reserved2[i]);
639 }
640 }
641
642 void
isp_put_24xx_abrt(ispsoftc_t * isp,isp24xx_abrt_t * src,isp24xx_abrt_t * dst)643 isp_put_24xx_abrt(ispsoftc_t *isp, isp24xx_abrt_t *src, isp24xx_abrt_t *dst)
644 {
645 int i;
646 isp_put_hdr(isp, &src->abrt_header, &dst->abrt_header);
647 ISP_IOXPUT_32(isp, src->abrt_handle, &dst->abrt_handle);
648 ISP_IOXPUT_16(isp, src->abrt_nphdl, &dst->abrt_nphdl);
649 ISP_IOXPUT_16(isp, src->abrt_options, &dst->abrt_options);
650 ISP_IOXPUT_32(isp, src->abrt_cmd_handle, &dst->abrt_cmd_handle);
651 ISP_IOXPUT_16(isp, src->abrt_queue_number, &dst->abrt_queue_number);
652 for (i = 0; i < nitems(src->abrt_reserved); i++) {
653 ISP_IOXPUT_8(isp, src->abrt_reserved[i], &dst->abrt_reserved[i]);
654 }
655 ISP_IOXPUT_16(isp, src->abrt_tidlo, &dst->abrt_tidlo);
656 ISP_IOXPUT_8(isp, src->abrt_tidhi, &dst->abrt_tidhi);
657 ISP_IOXPUT_8(isp, src->abrt_vpidx, &dst->abrt_vpidx);
658 for (i = 0; i < nitems(src->abrt_reserved1); i++) {
659 ISP_IOXPUT_8(isp, src->abrt_reserved1[i], &dst->abrt_reserved1[i]);
660 }
661 }
662
663 void
isp_put_cont64_req(ispsoftc_t * isp,ispcontreq64_t * src,ispcontreq64_t * dst)664 isp_put_cont64_req(ispsoftc_t *isp, ispcontreq64_t *src, ispcontreq64_t *dst)
665 {
666 int i;
667 isp_put_hdr(isp, &src->req_header, &dst->req_header);
668 for (i = 0; i < ISP_CDSEG64; i++) {
669 ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_base, &dst->req_dataseg[i].ds_base);
670 ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_basehi, &dst->req_dataseg[i].ds_basehi);
671 ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_count, &dst->req_dataseg[i].ds_count);
672 }
673 }
674
675 void
isp_get_cont_response(ispsoftc_t * isp,ispstatus_cont_t * src,ispstatus_cont_t * dst)676 isp_get_cont_response(ispsoftc_t *isp, ispstatus_cont_t *src, ispstatus_cont_t *dst)
677 {
678 int i;
679 uint32_t *a, *b;
680
681 isp_get_hdr(isp, &src->req_header, &dst->req_header);
682 a = (uint32_t *) src->req_sense_data;
683 b = (uint32_t *) dst->req_sense_data;
684 for (i = 0; i < (sizeof (src->req_sense_data) / sizeof (uint32_t)); i++)
685 ISP_IOZGET_32(isp, a++, *b++);
686 }
687
688 void
isp_get_24xx_response(ispsoftc_t * isp,isp24xx_statusreq_t * src,isp24xx_statusreq_t * dst)689 isp_get_24xx_response(ispsoftc_t *isp, isp24xx_statusreq_t *src, isp24xx_statusreq_t *dst)
690 {
691 int i;
692 uint32_t *s, *d;
693
694 isp_get_hdr(isp, &src->req_header, &dst->req_header);
695 ISP_IOXGET_32(isp, &src->req_handle, dst->req_handle);
696 ISP_IOXGET_16(isp, &src->req_completion_status, dst->req_completion_status);
697 ISP_IOXGET_16(isp, &src->req_oxid, dst->req_oxid);
698 ISP_IOXGET_32(isp, &src->req_resid, dst->req_resid);
699 ISP_IOXGET_16(isp, &src->req_reserved0, dst->req_reserved0);
700 ISP_IOXGET_16(isp, &src->req_state_flags, dst->req_state_flags);
701 ISP_IOXGET_16(isp, &src->req_retry_delay, dst->req_retry_delay);
702 ISP_IOXGET_16(isp, &src->req_scsi_status, dst->req_scsi_status);
703 ISP_IOXGET_32(isp, &src->req_fcp_residual, dst->req_fcp_residual);
704 ISP_IOXGET_32(isp, &src->req_sense_len, dst->req_sense_len);
705 ISP_IOXGET_32(isp, &src->req_response_len, dst->req_response_len);
706 s = (uint32_t *)src->req_rsp_sense;
707 d = (uint32_t *)dst->req_rsp_sense;
708 for (i = 0; i < (nitems(src->req_rsp_sense) >> 2); i++) {
709 d[i] = ISP_SWAP32(isp, s[i]);
710 }
711 }
712
713 void
isp_get_24xx_abrt(ispsoftc_t * isp,isp24xx_abrt_t * src,isp24xx_abrt_t * dst)714 isp_get_24xx_abrt(ispsoftc_t *isp, isp24xx_abrt_t *src, isp24xx_abrt_t *dst)
715 {
716 int i;
717 isp_get_hdr(isp, &src->abrt_header, &dst->abrt_header);
718 ISP_IOXGET_32(isp, &src->abrt_handle, dst->abrt_handle);
719 ISP_IOXGET_16(isp, &src->abrt_nphdl, dst->abrt_nphdl);
720 ISP_IOXGET_16(isp, &src->abrt_options, dst->abrt_options);
721 ISP_IOXGET_32(isp, &src->abrt_cmd_handle, dst->abrt_cmd_handle);
722 ISP_IOXGET_16(isp, &src->abrt_queue_number, dst->abrt_queue_number);
723 for (i = 0; i < nitems(src->abrt_reserved); i++) {
724 ISP_IOXGET_8(isp, &src->abrt_reserved[i], dst->abrt_reserved[i]);
725 }
726 ISP_IOXGET_16(isp, &src->abrt_tidlo, dst->abrt_tidlo);
727 ISP_IOXGET_8(isp, &src->abrt_tidhi, dst->abrt_tidhi);
728 ISP_IOXGET_8(isp, &src->abrt_vpidx, dst->abrt_vpidx);
729 for (i = 0; i < nitems(src->abrt_reserved1); i++) {
730 ISP_IOXGET_8(isp, &src->abrt_reserved1[i], dst->abrt_reserved1[i]);
731 }
732 }
733
734 void
isp_put_icb_2400(ispsoftc_t * isp,isp_icb_2400_t * src,isp_icb_2400_t * dst)735 isp_put_icb_2400(ispsoftc_t *isp, isp_icb_2400_t *src, isp_icb_2400_t *dst)
736 {
737 int i;
738 ISP_IOXPUT_16(isp, src->icb_version, &dst->icb_version);
739 ISP_IOXPUT_16(isp, src->icb_reserved0, &dst->icb_reserved0);
740 ISP_IOXPUT_16(isp, src->icb_maxfrmlen, &dst->icb_maxfrmlen);
741 ISP_IOXPUT_16(isp, src->icb_execthrottle, &dst->icb_execthrottle);
742 ISP_IOXPUT_16(isp, src->icb_xchgcnt, &dst->icb_xchgcnt);
743 ISP_IOXPUT_16(isp, src->icb_hardaddr, &dst->icb_hardaddr);
744 for (i = 0; i < 8; i++) {
745 ISP_IOXPUT_8(isp, src->icb_portname[i], &dst->icb_portname[i]);
746 }
747 for (i = 0; i < 8; i++) {
748 ISP_IOXPUT_8(isp, src->icb_nodename[i], &dst->icb_nodename[i]);
749 }
750 ISP_IOXPUT_16(isp, src->icb_rspnsin, &dst->icb_rspnsin);
751 ISP_IOXPUT_16(isp, src->icb_rqstout, &dst->icb_rqstout);
752 ISP_IOXPUT_16(isp, src->icb_retry_count, &dst->icb_retry_count);
753 ISP_IOXPUT_16(isp, src->icb_priout, &dst->icb_priout);
754 ISP_IOXPUT_16(isp, src->icb_rsltqlen, &dst->icb_rsltqlen);
755 ISP_IOXPUT_16(isp, src->icb_rqstqlen, &dst->icb_rqstqlen);
756 ISP_IOXPUT_16(isp, src->icb_ldn_nols, &dst->icb_ldn_nols);
757 ISP_IOXPUT_16(isp, src->icb_prqstqlen, &dst->icb_prqstqlen);
758 for (i = 0; i < 4; i++) {
759 ISP_IOXPUT_16(isp, src->icb_rqstaddr[i], &dst->icb_rqstaddr[i]);
760 }
761 for (i = 0; i < 4; i++) {
762 ISP_IOXPUT_16(isp, src->icb_respaddr[i], &dst->icb_respaddr[i]);
763 }
764 for (i = 0; i < 4; i++) {
765 ISP_IOXPUT_16(isp, src->icb_priaddr[i], &dst->icb_priaddr[i]);
766 }
767 ISP_IOXPUT_16(isp, src->icb_msixresp, &dst->icb_msixresp);
768 ISP_IOXPUT_16(isp, src->icb_msixatio, &dst->icb_msixatio);
769 for (i = 0; i < 2; i++) {
770 ISP_IOXPUT_16(isp, src->icb_reserved1[i], &dst->icb_reserved1[i]);
771 }
772 ISP_IOXPUT_16(isp, src->icb_atio_in, &dst->icb_atio_in);
773 ISP_IOXPUT_16(isp, src->icb_atioqlen, &dst->icb_atioqlen);
774 for (i = 0; i < 4; i++) {
775 ISP_IOXPUT_16(isp, src->icb_atioqaddr[i], &dst->icb_atioqaddr[i]);
776 }
777 ISP_IOXPUT_16(isp, src->icb_idelaytimer, &dst->icb_idelaytimer);
778 ISP_IOXPUT_16(isp, src->icb_logintime, &dst->icb_logintime);
779 ISP_IOXPUT_32(isp, src->icb_fwoptions1, &dst->icb_fwoptions1);
780 ISP_IOXPUT_32(isp, src->icb_fwoptions2, &dst->icb_fwoptions2);
781 ISP_IOXPUT_32(isp, src->icb_fwoptions3, &dst->icb_fwoptions3);
782 ISP_IOXPUT_16(isp, src->icb_qos, &dst->icb_qos);
783 for (i = 0; i < 3; i++)
784 ISP_IOXPUT_16(isp, src->icb_reserved2[i], &dst->icb_reserved2[i]);
785 for (i = 0; i < 6; i++)
786 ISP_IOXPUT_8(isp, src->icb_enodemac[i], &dst->icb_enodemac[i]);
787 ISP_IOXPUT_16(isp, src->icb_disctime, &dst->icb_disctime);
788 for (i = 0; i < 4; i++)
789 ISP_IOXPUT_16(isp, src->icb_reserved3[i], &dst->icb_reserved3[i]);
790 }
791
792 void
isp_put_icb_2400_vpinfo(ispsoftc_t * isp,isp_icb_2400_vpinfo_t * src,isp_icb_2400_vpinfo_t * dst)793 isp_put_icb_2400_vpinfo(ispsoftc_t *isp, isp_icb_2400_vpinfo_t *src, isp_icb_2400_vpinfo_t *dst)
794 {
795 ISP_IOXPUT_16(isp, src->vp_count, &dst->vp_count);
796 ISP_IOXPUT_16(isp, src->vp_global_options, &dst->vp_global_options);
797 }
798
799 void
isp_put_vp_port_info(ispsoftc_t * isp,vp_port_info_t * src,vp_port_info_t * dst)800 isp_put_vp_port_info(ispsoftc_t *isp, vp_port_info_t *src, vp_port_info_t *dst)
801 {
802 int i;
803 ISP_IOXPUT_16(isp, src->vp_port_status, &dst->vp_port_status);
804 ISP_IOXPUT_8(isp, src->vp_port_options, &dst->vp_port_options);
805 ISP_IOXPUT_8(isp, src->vp_port_loopid, &dst->vp_port_loopid);
806 for (i = 0; i < 8; i++) {
807 ISP_IOXPUT_8(isp, src->vp_port_portname[i], &dst->vp_port_portname[i]);
808 }
809 for (i = 0; i < 8; i++) {
810 ISP_IOXPUT_8(isp, src->vp_port_nodename[i], &dst->vp_port_nodename[i]);
811 }
812 /* we never *put* portid_lo/portid_hi */
813 }
814
815 void
isp_get_vp_port_info(ispsoftc_t * isp,vp_port_info_t * src,vp_port_info_t * dst)816 isp_get_vp_port_info(ispsoftc_t *isp, vp_port_info_t *src, vp_port_info_t *dst)
817 {
818 int i;
819 ISP_IOXGET_16(isp, &src->vp_port_status, dst->vp_port_status);
820 ISP_IOXGET_8(isp, &src->vp_port_options, dst->vp_port_options);
821 ISP_IOXGET_8(isp, &src->vp_port_loopid, dst->vp_port_loopid);
822 for (i = 0; i < nitems(src->vp_port_portname); i++) {
823 ISP_IOXGET_8(isp, &src->vp_port_portname[i], dst->vp_port_portname[i]);
824 }
825 for (i = 0; i < nitems(src->vp_port_nodename); i++) {
826 ISP_IOXGET_8(isp, &src->vp_port_nodename[i], dst->vp_port_nodename[i]);
827 }
828 ISP_IOXGET_16(isp, &src->vp_port_portid_lo, dst->vp_port_portid_lo);
829 ISP_IOXGET_16(isp, &src->vp_port_portid_hi, dst->vp_port_portid_hi);
830 }
831
832 void
isp_put_vp_ctrl_info(ispsoftc_t * isp,vp_ctrl_info_t * src,vp_ctrl_info_t * dst)833 isp_put_vp_ctrl_info(ispsoftc_t *isp, vp_ctrl_info_t *src, vp_ctrl_info_t *dst)
834 {
835 int i;
836 isp_put_hdr(isp, &src->vp_ctrl_hdr, &dst->vp_ctrl_hdr);
837 ISP_IOXPUT_32(isp, src->vp_ctrl_handle, &dst->vp_ctrl_handle);
838 ISP_IOXPUT_16(isp, src->vp_ctrl_index_fail, &dst->vp_ctrl_index_fail);
839 ISP_IOXPUT_16(isp, src->vp_ctrl_status, &dst->vp_ctrl_status);
840 ISP_IOXPUT_16(isp, src->vp_ctrl_command, &dst->vp_ctrl_command);
841 ISP_IOXPUT_16(isp, src->vp_ctrl_vp_count, &dst->vp_ctrl_vp_count);
842 for (i = 0; i < nitems(src->vp_ctrl_idmap); i++) {
843 ISP_IOXPUT_16(isp, src->vp_ctrl_idmap[i], &dst->vp_ctrl_idmap[i]);
844 }
845 for (i = 0; i < nitems(src->vp_ctrl_reserved); i++) {
846 ISP_IOXPUT_16(isp, src->vp_ctrl_reserved[i], &dst->vp_ctrl_reserved[i]);
847 }
848 ISP_IOXPUT_16(isp, src->vp_ctrl_fcf_index, &dst->vp_ctrl_fcf_index);
849 }
850
851 void
isp_get_vp_ctrl_info(ispsoftc_t * isp,vp_ctrl_info_t * src,vp_ctrl_info_t * dst)852 isp_get_vp_ctrl_info(ispsoftc_t *isp, vp_ctrl_info_t *src, vp_ctrl_info_t *dst)
853 {
854 int i;
855 isp_get_hdr(isp, &src->vp_ctrl_hdr, &dst->vp_ctrl_hdr);
856 ISP_IOXGET_32(isp, &src->vp_ctrl_handle, dst->vp_ctrl_handle);
857 ISP_IOXGET_16(isp, &src->vp_ctrl_index_fail, dst->vp_ctrl_index_fail);
858 ISP_IOXGET_16(isp, &src->vp_ctrl_status, dst->vp_ctrl_status);
859 ISP_IOXGET_16(isp, &src->vp_ctrl_command, dst->vp_ctrl_command);
860 ISP_IOXGET_16(isp, &src->vp_ctrl_vp_count, dst->vp_ctrl_vp_count);
861 for (i = 0; i < nitems(src->vp_ctrl_idmap); i++) {
862 ISP_IOXGET_16(isp, &src->vp_ctrl_idmap[i], dst->vp_ctrl_idmap[i]);
863 }
864 for (i = 0; i < nitems(src->vp_ctrl_reserved); i++) {
865 ISP_IOXGET_16(isp, &src->vp_ctrl_reserved[i], dst->vp_ctrl_reserved[i]);
866 }
867 ISP_IOXGET_16(isp, &src->vp_ctrl_fcf_index, dst->vp_ctrl_fcf_index);
868 }
869
870 void
isp_put_vp_modify(ispsoftc_t * isp,vp_modify_t * src,vp_modify_t * dst)871 isp_put_vp_modify(ispsoftc_t *isp, vp_modify_t *src, vp_modify_t *dst)
872 {
873 int i, j;
874 isp_put_hdr(isp, &src->vp_mod_hdr, &dst->vp_mod_hdr);
875 ISP_IOXPUT_32(isp, src->vp_mod_hdl, &dst->vp_mod_hdl);
876 ISP_IOXPUT_16(isp, src->vp_mod_reserved0, &dst->vp_mod_reserved0);
877 ISP_IOXPUT_16(isp, src->vp_mod_status, &dst->vp_mod_status);
878 ISP_IOXPUT_8(isp, src->vp_mod_cmd, &dst->vp_mod_cmd);
879 ISP_IOXPUT_8(isp, src->vp_mod_cnt, &dst->vp_mod_cnt);
880 ISP_IOXPUT_8(isp, src->vp_mod_idx0, &dst->vp_mod_idx0);
881 ISP_IOXPUT_8(isp, src->vp_mod_idx1, &dst->vp_mod_idx1);
882 for (i = 0; i < nitems(src->vp_mod_ports); i++) {
883 ISP_IOXPUT_8(isp, src->vp_mod_ports[i].options, &dst->vp_mod_ports[i].options);
884 ISP_IOXPUT_8(isp, src->vp_mod_ports[i].loopid, &dst->vp_mod_ports[i].loopid);
885 ISP_IOXPUT_16(isp, src->vp_mod_ports[i].reserved1, &dst->vp_mod_ports[i].reserved1);
886 for (j = 0; j < nitems(src->vp_mod_ports[i].wwpn); j++) {
887 ISP_IOXPUT_8(isp, src->vp_mod_ports[i].wwpn[j], &dst->vp_mod_ports[i].wwpn[j]);
888 }
889 for (j = 0; j < nitems(src->vp_mod_ports[i].wwnn); j++) {
890 ISP_IOXPUT_8(isp, src->vp_mod_ports[i].wwnn[j], &dst->vp_mod_ports[i].wwnn[j]);
891 }
892 }
893 for (i = 0; i < nitems(src->vp_mod_reserved2); i++) {
894 ISP_IOXPUT_8(isp, src->vp_mod_reserved2[i], &dst->vp_mod_reserved2[i]);
895 }
896 }
897
898 void
isp_get_vp_modify(ispsoftc_t * isp,vp_modify_t * src,vp_modify_t * dst)899 isp_get_vp_modify(ispsoftc_t *isp, vp_modify_t *src, vp_modify_t *dst)
900 {
901 int i, j;
902 isp_get_hdr(isp, &src->vp_mod_hdr, &dst->vp_mod_hdr);
903 ISP_IOXGET_32(isp, &src->vp_mod_hdl, dst->vp_mod_hdl);
904 ISP_IOXGET_16(isp, &src->vp_mod_reserved0, dst->vp_mod_reserved0);
905 ISP_IOXGET_16(isp, &src->vp_mod_status, dst->vp_mod_status);
906 ISP_IOXGET_8(isp, &src->vp_mod_cmd, dst->vp_mod_cmd);
907 ISP_IOXGET_8(isp, &src->vp_mod_cnt, dst->vp_mod_cnt);
908 ISP_IOXGET_8(isp, &src->vp_mod_idx0, dst->vp_mod_idx0);
909 ISP_IOXGET_8(isp, &src->vp_mod_idx1, dst->vp_mod_idx1);
910 for (i = 0; i < nitems(src->vp_mod_ports); i++) {
911 ISP_IOXGET_8(isp, &src->vp_mod_ports[i].options, dst->vp_mod_ports[i].options);
912 ISP_IOXGET_8(isp, &src->vp_mod_ports[i].loopid, dst->vp_mod_ports[i].loopid);
913 ISP_IOXGET_16(isp, &src->vp_mod_ports[i].reserved1, dst->vp_mod_ports[i].reserved1);
914 for (j = 0; j < nitems(src->vp_mod_ports[i].wwpn); j++) {
915 ISP_IOXGET_8(isp, &src->vp_mod_ports[i].wwpn[j], dst->vp_mod_ports[i].wwpn[j]);
916 }
917 for (j = 0; j < nitems(src->vp_mod_ports[i].wwnn); j++) {
918 ISP_IOXGET_8(isp, &src->vp_mod_ports[i].wwnn[j], dst->vp_mod_ports[i].wwnn[j]);
919 }
920 }
921 for (i = 0; i < nitems(src->vp_mod_reserved2); i++) {
922 ISP_IOXGET_8(isp, &src->vp_mod_reserved2[i], dst->vp_mod_reserved2[i]);
923 }
924 }
925
926 void
isp_get_pdb_24xx(ispsoftc_t * isp,isp_pdb_24xx_t * src,isp_pdb_24xx_t * dst)927 isp_get_pdb_24xx(ispsoftc_t *isp, isp_pdb_24xx_t *src, isp_pdb_24xx_t *dst)
928 {
929 int i;
930 ISP_IOXGET_16(isp, &src->pdb_flags, dst->pdb_flags);
931 ISP_IOXGET_8(isp, &src->pdb_curstate, dst->pdb_curstate);
932 ISP_IOXGET_8(isp, &src->pdb_laststate, dst->pdb_laststate);
933 for (i = 0; i < 4; i++) {
934 ISP_IOXGET_8(isp, &src->pdb_hardaddr_bits[i], dst->pdb_hardaddr_bits[i]);
935 }
936 for (i = 0; i < 4; i++) {
937 ISP_IOXGET_8(isp, &src->pdb_portid_bits[i], dst->pdb_portid_bits[i]);
938 }
939 ISP_IOXGET_16(isp, &src->pdb_retry_timer, dst->pdb_retry_timer);
940 ISP_IOXGET_16(isp, &src->pdb_handle, dst->pdb_handle);
941 ISP_IOXGET_16(isp, &src->pdb_rcv_dsize, dst->pdb_rcv_dsize);
942 ISP_IOXGET_16(isp, &src->pdb_reserved0, dst->pdb_reserved0);
943 ISP_IOXGET_16(isp, &src->pdb_prli_svc0, dst->pdb_prli_svc0);
944 ISP_IOXGET_16(isp, &src->pdb_prli_svc3, dst->pdb_prli_svc3);
945 for (i = 0; i < 8; i++) {
946 ISP_IOXGET_8(isp, &src->pdb_nodename[i], dst->pdb_nodename[i]);
947 }
948 for (i = 0; i < 8; i++) {
949 ISP_IOXGET_8(isp, &src->pdb_portname[i], dst->pdb_portname[i]);
950 }
951 for (i = 0; i < 24; i++) {
952 ISP_IOXGET_8(isp, &src->pdb_reserved1[i], dst->pdb_reserved1[i]);
953 }
954 }
955
956 void
isp_get_pnhle_24xx(ispsoftc_t * isp,isp_pnhle_24xx_t * src,isp_pnhle_24xx_t * dst)957 isp_get_pnhle_24xx(ispsoftc_t *isp, isp_pnhle_24xx_t *src, isp_pnhle_24xx_t *dst)
958 {
959
960 ISP_IOXGET_16(isp, &src->pnhle_port_id_lo, dst->pnhle_port_id_lo);
961 ISP_IOXGET_16(isp, &src->pnhle_port_id_hi, dst->pnhle_port_id_hi);
962 ISP_IOXGET_16(isp, &src->pnhle_handle, dst->pnhle_handle);
963 ISP_IOXGET_16(isp, &src->pnhle_reserved, dst->pnhle_reserved);
964 }
965
966 /*
967 * PLOGI/LOGO IOCB canonicalization
968 */
969
970 void
isp_get_plogx(ispsoftc_t * isp,isp_plogx_t * src,isp_plogx_t * dst)971 isp_get_plogx(ispsoftc_t *isp, isp_plogx_t *src, isp_plogx_t *dst)
972 {
973 int i;
974 isp_get_hdr(isp, &src->plogx_header, &dst->plogx_header);
975 ISP_IOXGET_32(isp, &src->plogx_handle, dst->plogx_handle);
976 ISP_IOXGET_16(isp, &src->plogx_status, dst->plogx_status);
977 ISP_IOXGET_16(isp, &src->plogx_nphdl, dst->plogx_nphdl);
978 ISP_IOXGET_16(isp, &src->plogx_flags, dst->plogx_flags);
979 ISP_IOXGET_16(isp, &src->plogx_vphdl, dst->plogx_vphdl);
980 ISP_IOXGET_16(isp, &src->plogx_portlo, dst->plogx_portlo);
981 ISP_IOXGET_16(isp, &src->plogx_rspsz_porthi, dst->plogx_rspsz_porthi);
982 for (i = 0; i < 11; i++) {
983 ISP_IOXGET_16(isp, &src->plogx_ioparm[i].lo16, dst->plogx_ioparm[i].lo16);
984 ISP_IOXGET_16(isp, &src->plogx_ioparm[i].hi16, dst->plogx_ioparm[i].hi16);
985 }
986 }
987
988 void
isp_put_plogx(ispsoftc_t * isp,isp_plogx_t * src,isp_plogx_t * dst)989 isp_put_plogx(ispsoftc_t *isp, isp_plogx_t *src, isp_plogx_t *dst)
990 {
991 int i;
992 isp_put_hdr(isp, &src->plogx_header, &dst->plogx_header);
993 ISP_IOXPUT_32(isp, src->plogx_handle, &dst->plogx_handle);
994 ISP_IOXPUT_16(isp, src->plogx_status, &dst->plogx_status);
995 ISP_IOXPUT_16(isp, src->plogx_nphdl, &dst->plogx_nphdl);
996 ISP_IOXPUT_16(isp, src->plogx_flags, &dst->plogx_flags);
997 ISP_IOXPUT_16(isp, src->plogx_vphdl, &dst->plogx_vphdl);
998 ISP_IOXPUT_16(isp, src->plogx_portlo, &dst->plogx_portlo);
999 ISP_IOXPUT_16(isp, src->plogx_rspsz_porthi, &dst->plogx_rspsz_porthi);
1000 for (i = 0; i < 11; i++) {
1001 ISP_IOXPUT_16(isp, src->plogx_ioparm[i].lo16, &dst->plogx_ioparm[i].lo16);
1002 ISP_IOXPUT_16(isp, src->plogx_ioparm[i].hi16, &dst->plogx_ioparm[i].hi16);
1003 }
1004 }
1005
1006 /*
1007 * Report ID canonicalization
1008 */
1009 void
isp_get_ridacq(ispsoftc_t * isp,isp_ridacq_t * src,isp_ridacq_t * dst)1010 isp_get_ridacq(ispsoftc_t *isp, isp_ridacq_t *src, isp_ridacq_t *dst)
1011 {
1012 int i;
1013 isp_get_hdr(isp, &src->ridacq_hdr, &dst->ridacq_hdr);
1014 ISP_IOXGET_32(isp, &src->ridacq_handle, dst->ridacq_handle);
1015 ISP_IOXGET_8(isp, &src->ridacq_vp_acquired, dst->ridacq_vp_acquired);
1016 ISP_IOXGET_8(isp, &src->ridacq_vp_setup, dst->ridacq_vp_setup);
1017 ISP_IOXGET_8(isp, &src->ridacq_vp_index, dst->ridacq_vp_index);
1018 ISP_IOXGET_8(isp, &src->ridacq_vp_status, dst->ridacq_vp_status);
1019 ISP_IOXGET_16(isp, &src->ridacq_vp_port_lo, dst->ridacq_vp_port_lo);
1020 ISP_IOXGET_8(isp, &src->ridacq_vp_port_hi, dst->ridacq_vp_port_hi);
1021 ISP_IOXGET_8(isp, &src->ridacq_format, dst->ridacq_format);
1022 for (i = 0; i < sizeof (src->ridacq_map) / sizeof (src->ridacq_map[0]); i++) {
1023 ISP_IOXGET_16(isp, &src->ridacq_map[i], dst->ridacq_map[i]);
1024 }
1025 for (i = 0; i < sizeof (src->ridacq_reserved1) / sizeof (src->ridacq_reserved1[0]); i++) {
1026 ISP_IOXGET_16(isp, &src->ridacq_reserved1[i], dst->ridacq_reserved1[i]);
1027 }
1028 }
1029
1030
1031 /*
1032 * CT Passthru canonicalization
1033 */
1034 void
isp_get_ct_pt(ispsoftc_t * isp,isp_ct_pt_t * src,isp_ct_pt_t * dst)1035 isp_get_ct_pt(ispsoftc_t *isp, isp_ct_pt_t *src, isp_ct_pt_t *dst)
1036 {
1037 int i;
1038
1039 isp_get_hdr(isp, &src->ctp_header, &dst->ctp_header);
1040 ISP_IOXGET_32(isp, &src->ctp_handle, dst->ctp_handle);
1041 ISP_IOXGET_16(isp, &src->ctp_status, dst->ctp_status);
1042 ISP_IOXGET_16(isp, &src->ctp_nphdl, dst->ctp_nphdl);
1043 ISP_IOXGET_16(isp, &src->ctp_cmd_cnt, dst->ctp_cmd_cnt);
1044 ISP_IOXGET_8(isp, &src->ctp_vpidx, dst->ctp_vpidx);
1045 ISP_IOXGET_8(isp, &src->ctp_reserved0, dst->ctp_reserved0);
1046 ISP_IOXGET_16(isp, &src->ctp_time, dst->ctp_time);
1047 ISP_IOXGET_16(isp, &src->ctp_reserved1, dst->ctp_reserved1);
1048 ISP_IOXGET_16(isp, &src->ctp_rsp_cnt, dst->ctp_rsp_cnt);
1049 for (i = 0; i < 5; i++) {
1050 ISP_IOXGET_16(isp, &src->ctp_reserved2[i], dst->ctp_reserved2[i]);
1051 }
1052 ISP_IOXGET_32(isp, &src->ctp_rsp_bcnt, dst->ctp_rsp_bcnt);
1053 ISP_IOXGET_32(isp, &src->ctp_cmd_bcnt, dst->ctp_cmd_bcnt);
1054 for (i = 0; i < 2; i++) {
1055 ISP_IOXGET_32(isp, &src->ctp_dataseg[i].ds_base, dst->ctp_dataseg[i].ds_base);
1056 ISP_IOXGET_32(isp, &src->ctp_dataseg[i].ds_basehi, dst->ctp_dataseg[i].ds_basehi);
1057 ISP_IOXGET_32(isp, &src->ctp_dataseg[i].ds_count, dst->ctp_dataseg[i].ds_count);
1058 }
1059 }
1060
1061 void
isp_put_ct_pt(ispsoftc_t * isp,isp_ct_pt_t * src,isp_ct_pt_t * dst)1062 isp_put_ct_pt(ispsoftc_t *isp, isp_ct_pt_t *src, isp_ct_pt_t *dst)
1063 {
1064 int i;
1065
1066 isp_put_hdr(isp, &src->ctp_header, &dst->ctp_header);
1067 ISP_IOXPUT_32(isp, src->ctp_handle, &dst->ctp_handle);
1068 ISP_IOXPUT_16(isp, src->ctp_status, &dst->ctp_status);
1069 ISP_IOXPUT_16(isp, src->ctp_nphdl, &dst->ctp_nphdl);
1070 ISP_IOXPUT_16(isp, src->ctp_cmd_cnt, &dst->ctp_cmd_cnt);
1071 ISP_IOXPUT_8(isp, src->ctp_vpidx, &dst->ctp_vpidx);
1072 ISP_IOXPUT_8(isp, src->ctp_reserved0, &dst->ctp_reserved0);
1073 ISP_IOXPUT_16(isp, src->ctp_time, &dst->ctp_time);
1074 ISP_IOXPUT_16(isp, src->ctp_reserved1, &dst->ctp_reserved1);
1075 ISP_IOXPUT_16(isp, src->ctp_rsp_cnt, &dst->ctp_rsp_cnt);
1076 for (i = 0; i < 5; i++) {
1077 ISP_IOXPUT_16(isp, src->ctp_reserved2[i], &dst->ctp_reserved2[i]);
1078 }
1079 ISP_IOXPUT_32(isp, src->ctp_rsp_bcnt, &dst->ctp_rsp_bcnt);
1080 ISP_IOXPUT_32(isp, src->ctp_cmd_bcnt, &dst->ctp_cmd_bcnt);
1081 for (i = 0; i < 2; i++) {
1082 ISP_IOXPUT_32(isp, src->ctp_dataseg[i].ds_base, &dst->ctp_dataseg[i].ds_base);
1083 ISP_IOXPUT_32(isp, src->ctp_dataseg[i].ds_basehi, &dst->ctp_dataseg[i].ds_basehi);
1084 ISP_IOXPUT_32(isp, src->ctp_dataseg[i].ds_count, &dst->ctp_dataseg[i].ds_count);
1085 }
1086 }
1087
1088 void
isp_put_gid_ft_request(ispsoftc_t * isp,sns_gid_ft_req_t * src,sns_gid_ft_req_t * dst)1089 isp_put_gid_ft_request(ispsoftc_t *isp, sns_gid_ft_req_t *src, sns_gid_ft_req_t *dst)
1090 {
1091 ISP_IOXPUT_16(isp, src->snscb_rblen, &dst->snscb_rblen);
1092 ISP_IOXPUT_16(isp, src->snscb_reserved0, &dst->snscb_reserved0);
1093 ISP_IOXPUT_16(isp, src->snscb_addr[0], &dst->snscb_addr[0]);
1094 ISP_IOXPUT_16(isp, src->snscb_addr[1], &dst->snscb_addr[1]);
1095 ISP_IOXPUT_16(isp, src->snscb_addr[2], &dst->snscb_addr[2]);
1096 ISP_IOXPUT_16(isp, src->snscb_addr[3], &dst->snscb_addr[3]);
1097 ISP_IOXPUT_16(isp, src->snscb_sblen, &dst->snscb_sblen);
1098 ISP_IOXPUT_16(isp, src->snscb_reserved1, &dst->snscb_reserved1);
1099 ISP_IOXPUT_16(isp, src->snscb_cmd, &dst->snscb_cmd);
1100 ISP_IOXPUT_16(isp, src->snscb_mword_div_2, &dst->snscb_mword_div_2);
1101 ISP_IOXPUT_32(isp, src->snscb_reserved3, &dst->snscb_reserved3);
1102 ISP_IOXPUT_32(isp, src->snscb_fc4_type, &dst->snscb_fc4_type);
1103 }
1104
1105 void
isp_get_gid_xx_response(ispsoftc_t * isp,sns_gid_xx_rsp_t * src,sns_gid_xx_rsp_t * dst,int nwords)1106 isp_get_gid_xx_response(ispsoftc_t *isp, sns_gid_xx_rsp_t *src, sns_gid_xx_rsp_t *dst, int nwords)
1107 {
1108 int i, j;
1109
1110 isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
1111 for (i = 0; i < nwords; i++) {
1112 ISP_IOZGET_8(isp, &src->snscb_ports[i].control,
1113 dst->snscb_ports[i].control);
1114 for (j = 0; j < 3; j++) {
1115 ISP_IOZGET_8(isp, &src->snscb_ports[i].portid[j],
1116 dst->snscb_ports[i].portid[j]);
1117 }
1118 if (dst->snscb_ports[i].control & 0x80)
1119 break;
1120 }
1121 }
1122
1123 void
isp_get_gxn_id_response(ispsoftc_t * isp,sns_gxn_id_rsp_t * src,sns_gxn_id_rsp_t * dst)1124 isp_get_gxn_id_response(ispsoftc_t *isp, sns_gxn_id_rsp_t *src, sns_gxn_id_rsp_t *dst)
1125 {
1126 int i;
1127
1128 isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
1129 for (i = 0; i < 8; i++)
1130 ISP_IOZGET_8(isp, &src->snscb_wwn[i], dst->snscb_wwn[i]);
1131 }
1132
1133 void
isp_get_gft_id_response(ispsoftc_t * isp,sns_gft_id_rsp_t * src,sns_gft_id_rsp_t * dst)1134 isp_get_gft_id_response(ispsoftc_t *isp, sns_gft_id_rsp_t *src, sns_gft_id_rsp_t *dst)
1135 {
1136 int i;
1137
1138 isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
1139 for (i = 0; i < 8; i++) {
1140 ISP_IOZGET_32(isp, &src->snscb_fc4_types[i],
1141 dst->snscb_fc4_types[i]);
1142 }
1143 }
1144
1145 void
isp_get_gff_id_response(ispsoftc_t * isp,sns_gff_id_rsp_t * src,sns_gff_id_rsp_t * dst)1146 isp_get_gff_id_response(ispsoftc_t *isp, sns_gff_id_rsp_t *src, sns_gff_id_rsp_t *dst)
1147 {
1148 int i;
1149
1150 isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
1151 for (i = 0; i < 32; i++) {
1152 ISP_IOZGET_32(isp, &src->snscb_fc4_features[i],
1153 dst->snscb_fc4_features[i]);
1154 }
1155 }
1156
1157 void
isp_get_ga_nxt_response(ispsoftc_t * isp,sns_ga_nxt_rsp_t * src,sns_ga_nxt_rsp_t * dst)1158 isp_get_ga_nxt_response(ispsoftc_t *isp, sns_ga_nxt_rsp_t *src, sns_ga_nxt_rsp_t *dst)
1159 {
1160 int i;
1161 isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr);
1162 ISP_IOZGET_8(isp, &src->snscb_port_type, dst->snscb_port_type);
1163 for (i = 0; i < 3; i++) {
1164 ISP_IOZGET_8(isp, &src->snscb_port_id[i], dst->snscb_port_id[i]);
1165 }
1166 for (i = 0; i < 8; i++) {
1167 ISP_IOZGET_8(isp, &src->snscb_portname[i], dst->snscb_portname[i]);
1168 }
1169 ISP_IOZGET_8(isp, &src->snscb_pnlen, dst->snscb_pnlen);
1170 for (i = 0; i < 255; i++) {
1171 ISP_IOZGET_8(isp, &src->snscb_pname[i], dst->snscb_pname[i]);
1172 }
1173 for (i = 0; i < 8; i++) {
1174 ISP_IOZGET_8(isp, &src->snscb_nodename[i], dst->snscb_nodename[i]);
1175 }
1176 ISP_IOZGET_8(isp, &src->snscb_nnlen, dst->snscb_nnlen);
1177 for (i = 0; i < 255; i++) {
1178 ISP_IOZGET_8(isp, &src->snscb_nname[i], dst->snscb_nname[i]);
1179 }
1180 for (i = 0; i < 8; i++) {
1181 ISP_IOZGET_8(isp, &src->snscb_ipassoc[i], dst->snscb_ipassoc[i]);
1182 }
1183 for (i = 0; i < 16; i++) {
1184 ISP_IOZGET_8(isp, &src->snscb_ipaddr[i], dst->snscb_ipaddr[i]);
1185 }
1186 for (i = 0; i < 4; i++) {
1187 ISP_IOZGET_8(isp, &src->snscb_svc_class[i], dst->snscb_svc_class[i]);
1188 }
1189 for (i = 0; i < 32; i++) {
1190 ISP_IOZGET_8(isp, &src->snscb_fc4_types[i], dst->snscb_fc4_types[i]);
1191 }
1192 for (i = 0; i < 8; i++) {
1193 ISP_IOZGET_8(isp, &src->snscb_fpname[i], dst->snscb_fpname[i]);
1194 }
1195 ISP_IOZGET_8(isp, &src->snscb_reserved, dst->snscb_reserved);
1196 for (i = 0; i < 3; i++) {
1197 ISP_IOZGET_8(isp, &src->snscb_hardaddr[i], dst->snscb_hardaddr[i]);
1198 }
1199 }
1200
1201 /*
1202 * FC Structure Canonicalization
1203 */
1204
1205 void
isp_get_fc_hdr(ispsoftc_t * isp,fc_hdr_t * src,fc_hdr_t * dst)1206 isp_get_fc_hdr(ispsoftc_t *isp, fc_hdr_t *src, fc_hdr_t *dst)
1207 {
1208 ISP_IOZGET_8(isp, &src->r_ctl, dst->r_ctl);
1209 ISP_IOZGET_8(isp, &src->d_id[0], dst->d_id[0]);
1210 ISP_IOZGET_8(isp, &src->d_id[1], dst->d_id[1]);
1211 ISP_IOZGET_8(isp, &src->d_id[2], dst->d_id[2]);
1212 ISP_IOZGET_8(isp, &src->cs_ctl, dst->cs_ctl);
1213 ISP_IOZGET_8(isp, &src->s_id[0], dst->s_id[0]);
1214 ISP_IOZGET_8(isp, &src->s_id[1], dst->s_id[1]);
1215 ISP_IOZGET_8(isp, &src->s_id[2], dst->s_id[2]);
1216 ISP_IOZGET_8(isp, &src->type, dst->type);
1217 ISP_IOZGET_8(isp, &src->f_ctl[0], dst->f_ctl[0]);
1218 ISP_IOZGET_8(isp, &src->f_ctl[1], dst->f_ctl[1]);
1219 ISP_IOZGET_8(isp, &src->f_ctl[2], dst->f_ctl[2]);
1220 ISP_IOZGET_8(isp, &src->seq_id, dst->seq_id);
1221 ISP_IOZGET_8(isp, &src->df_ctl, dst->df_ctl);
1222 ISP_IOZGET_16(isp, &src->seq_cnt, dst->seq_cnt);
1223 ISP_IOZGET_16(isp, &src->ox_id, dst->ox_id);
1224 ISP_IOZGET_16(isp, &src->rx_id, dst->rx_id);
1225 ISP_IOZGET_32(isp, &src->parameter, dst->parameter);
1226 }
1227
1228 void
isp_put_fc_hdr(ispsoftc_t * isp,fc_hdr_t * src,fc_hdr_t * dst)1229 isp_put_fc_hdr(ispsoftc_t *isp, fc_hdr_t *src, fc_hdr_t *dst)
1230 {
1231 ISP_IOZPUT_8(isp, src->r_ctl, &dst->r_ctl);
1232 ISP_IOZPUT_8(isp, src->d_id[0], &dst->d_id[0]);
1233 ISP_IOZPUT_8(isp, src->d_id[1], &dst->d_id[1]);
1234 ISP_IOZPUT_8(isp, src->d_id[2], &dst->d_id[2]);
1235 ISP_IOZPUT_8(isp, src->cs_ctl, &dst->cs_ctl);
1236 ISP_IOZPUT_8(isp, src->s_id[0], &dst->s_id[0]);
1237 ISP_IOZPUT_8(isp, src->s_id[1], &dst->s_id[1]);
1238 ISP_IOZPUT_8(isp, src->s_id[2], &dst->s_id[2]);
1239 ISP_IOZPUT_8(isp, src->type, &dst->type);
1240 ISP_IOZPUT_8(isp, src->f_ctl[0], &dst->f_ctl[0]);
1241 ISP_IOZPUT_8(isp, src->f_ctl[1], &dst->f_ctl[1]);
1242 ISP_IOZPUT_8(isp, src->f_ctl[2], &dst->f_ctl[2]);
1243 ISP_IOZPUT_8(isp, src->seq_id, &dst->seq_id);
1244 ISP_IOZPUT_8(isp, src->df_ctl, &dst->df_ctl);
1245 ISP_IOZPUT_16(isp, src->seq_cnt, &dst->seq_cnt);
1246 ISP_IOZPUT_16(isp, src->ox_id, &dst->ox_id);
1247 ISP_IOZPUT_16(isp, src->rx_id, &dst->rx_id);
1248 ISP_IOZPUT_32(isp, src->parameter, &dst->parameter);
1249 }
1250
1251 void
isp_get_fcp_cmnd_iu(ispsoftc_t * isp,fcp_cmnd_iu_t * src,fcp_cmnd_iu_t * dst)1252 isp_get_fcp_cmnd_iu(ispsoftc_t *isp, fcp_cmnd_iu_t *src, fcp_cmnd_iu_t *dst)
1253 {
1254 int i;
1255
1256 for (i = 0; i < 8; i++) {
1257 ISP_IOZGET_8(isp, &src->fcp_cmnd_lun[i], dst->fcp_cmnd_lun[i]);
1258 }
1259 ISP_IOZGET_8(isp, &src->fcp_cmnd_crn, dst->fcp_cmnd_crn);
1260 ISP_IOZGET_8(isp, &src->fcp_cmnd_task_attribute, dst->fcp_cmnd_task_attribute);
1261 ISP_IOZGET_8(isp, &src->fcp_cmnd_task_management, dst->fcp_cmnd_task_management);
1262 ISP_IOZGET_8(isp, &src->fcp_cmnd_alen_datadir, dst->fcp_cmnd_alen_datadir);
1263 for (i = 0; i < 16; i++) {
1264 ISP_IOZGET_8(isp, &src->cdb_dl.sf.fcp_cmnd_cdb[i], dst->cdb_dl.sf.fcp_cmnd_cdb[i]);
1265 }
1266 ISP_IOZGET_32(isp, &src->cdb_dl.sf.fcp_cmnd_dl, dst->cdb_dl.sf.fcp_cmnd_dl);
1267 }
1268
1269 void
isp_put_rft_id(ispsoftc_t * isp,rft_id_t * src,rft_id_t * dst)1270 isp_put_rft_id(ispsoftc_t *isp, rft_id_t *src, rft_id_t *dst)
1271 {
1272 int i;
1273 isp_put_ct_hdr(isp, &src->rftid_hdr, &dst->rftid_hdr);
1274 ISP_IOZPUT_8(isp, src->rftid_reserved, &dst->rftid_reserved);
1275 for (i = 0; i < 3; i++) {
1276 ISP_IOZPUT_8(isp, src->rftid_portid[i], &dst->rftid_portid[i]);
1277 }
1278 for (i = 0; i < 8; i++) {
1279 ISP_IOZPUT_32(isp, src->rftid_fc4types[i], &dst->rftid_fc4types[i]);
1280 }
1281 }
1282
1283 void
isp_put_rspn_id(ispsoftc_t * isp,rspn_id_t * src,rspn_id_t * dst)1284 isp_put_rspn_id(ispsoftc_t *isp, rspn_id_t *src, rspn_id_t *dst)
1285 {
1286 /* int i;*/
1287 isp_put_ct_hdr(isp, &src->rspnid_hdr, &dst->rspnid_hdr);
1288 ISP_IOZPUT_8(isp, src->rspnid_reserved, &dst->rspnid_reserved);
1289 ISP_IOZPUT_8(isp, src->rspnid_length, &dst->rspnid_length);
1290 /* for (i = 0; i < src->rspnid_length; i++)
1291 ISP_IOZPUT_8(isp, src->rspnid_name[i], &dst->rspnid_name[i]);*/
1292 }
1293
1294 void
isp_put_rff_id(ispsoftc_t * isp,rff_id_t * src,rff_id_t * dst)1295 isp_put_rff_id(ispsoftc_t *isp, rff_id_t *src, rff_id_t *dst)
1296 {
1297 int i;
1298
1299 isp_put_ct_hdr(isp, &src->rffid_hdr, &dst->rffid_hdr);
1300 ISP_IOZPUT_8(isp, src->rffid_reserved, &dst->rffid_reserved);
1301 for (i = 0; i < 3; i++)
1302 ISP_IOZPUT_8(isp, src->rffid_portid[i], &dst->rffid_portid[i]);
1303 ISP_IOZPUT_16(isp, src->rffid_reserved2, &dst->rffid_reserved2);
1304 ISP_IOZPUT_8(isp, src->rffid_fc4features, &dst->rffid_fc4features);
1305 ISP_IOZPUT_8(isp, src->rffid_fc4type, &dst->rffid_fc4type);
1306 }
1307
1308 void
isp_put_rsnn_nn(ispsoftc_t * isp,rsnn_nn_t * src,rsnn_nn_t * dst)1309 isp_put_rsnn_nn(ispsoftc_t *isp, rsnn_nn_t *src, rsnn_nn_t *dst)
1310 {
1311 int i;
1312 isp_put_ct_hdr(isp, &src->rsnnnn_hdr, &dst->rsnnnn_hdr);
1313 for (i = 0; i < 8; i++)
1314 ISP_IOZPUT_8(isp, src->rsnnnn_nodename[i], &dst->rsnnnn_nodename[i]);
1315 ISP_IOZPUT_8(isp, src->rsnnnn_length, &dst->rsnnnn_length);
1316 /* for (i = 0; i < src->rsnnnn_length; i++)
1317 ISP_IOZPUT_8(isp, src->rsnnnn_name[i], &dst->rsnnnn_name[i]);*/
1318 }
1319
1320 void
isp_get_ct_hdr(ispsoftc_t * isp,ct_hdr_t * src,ct_hdr_t * dst)1321 isp_get_ct_hdr(ispsoftc_t *isp, ct_hdr_t *src, ct_hdr_t *dst)
1322 {
1323 ISP_IOZGET_8(isp, &src->ct_revision, dst->ct_revision);
1324 ISP_IOZGET_8(isp, &src->ct_in_id[0], dst->ct_in_id[0]);
1325 ISP_IOZGET_8(isp, &src->ct_in_id[1], dst->ct_in_id[1]);
1326 ISP_IOZGET_8(isp, &src->ct_in_id[2], dst->ct_in_id[2]);
1327 ISP_IOZGET_8(isp, &src->ct_fcs_type, dst->ct_fcs_type);
1328 ISP_IOZGET_8(isp, &src->ct_fcs_subtype, dst->ct_fcs_subtype);
1329 ISP_IOZGET_8(isp, &src->ct_options, dst->ct_options);
1330 ISP_IOZGET_8(isp, &src->ct_reserved0, dst->ct_reserved0);
1331 ISP_IOZGET_16(isp, &src->ct_cmd_resp, dst->ct_cmd_resp);
1332 ISP_IOZGET_16(isp, &src->ct_bcnt_resid, dst->ct_bcnt_resid);
1333 ISP_IOZGET_8(isp, &src->ct_reserved1, dst->ct_reserved1);
1334 ISP_IOZGET_8(isp, &src->ct_reason, dst->ct_reason);
1335 ISP_IOZGET_8(isp, &src->ct_explanation, dst->ct_explanation);
1336 ISP_IOZGET_8(isp, &src->ct_vunique, dst->ct_vunique);
1337 }
1338
1339 void
isp_put_ct_hdr(ispsoftc_t * isp,ct_hdr_t * src,ct_hdr_t * dst)1340 isp_put_ct_hdr(ispsoftc_t *isp, ct_hdr_t *src, ct_hdr_t *dst)
1341 {
1342 ISP_IOZPUT_8(isp, src->ct_revision, &dst->ct_revision);
1343 ISP_IOZPUT_8(isp, src->ct_in_id[0], &dst->ct_in_id[0]);
1344 ISP_IOZPUT_8(isp, src->ct_in_id[1], &dst->ct_in_id[1]);
1345 ISP_IOZPUT_8(isp, src->ct_in_id[2], &dst->ct_in_id[2]);
1346 ISP_IOZPUT_8(isp, src->ct_fcs_type, &dst->ct_fcs_type);
1347 ISP_IOZPUT_8(isp, src->ct_fcs_subtype, &dst->ct_fcs_subtype);
1348 ISP_IOZPUT_8(isp, src->ct_options, &dst->ct_options);
1349 ISP_IOZPUT_8(isp, src->ct_reserved0, &dst->ct_reserved0);
1350 ISP_IOZPUT_16(isp, src->ct_cmd_resp, &dst->ct_cmd_resp);
1351 ISP_IOZPUT_16(isp, src->ct_bcnt_resid, &dst->ct_bcnt_resid);
1352 ISP_IOZPUT_8(isp, src->ct_reserved1, &dst->ct_reserved1);
1353 ISP_IOZPUT_8(isp, src->ct_reason, &dst->ct_reason);
1354 ISP_IOZPUT_8(isp, src->ct_explanation, &dst->ct_explanation);
1355 ISP_IOZPUT_8(isp, src->ct_vunique, &dst->ct_vunique);
1356 }
1357
1358 void
isp_put_fcp_rsp_iu(ispsoftc_t * isp,fcp_rsp_iu_t * src,fcp_rsp_iu_t * dst)1359 isp_put_fcp_rsp_iu(ispsoftc_t *isp, fcp_rsp_iu_t *src, fcp_rsp_iu_t *dst)
1360 {
1361 int i;
1362 for (i = 0; i < ((sizeof (src->fcp_rsp_reserved))/(sizeof (src->fcp_rsp_reserved[0]))); i++) {
1363 ISP_IOZPUT_8(isp, src->fcp_rsp_reserved[i], &dst->fcp_rsp_reserved[i]);
1364 }
1365 ISP_IOZPUT_16(isp, src->fcp_rsp_status_qualifier, &dst->fcp_rsp_status_qualifier);
1366 ISP_IOZPUT_8(isp, src->fcp_rsp_bits, &dst->fcp_rsp_bits);
1367 ISP_IOZPUT_8(isp, src->fcp_rsp_scsi_status, &dst->fcp_rsp_scsi_status);
1368 ISP_IOZPUT_32(isp, src->fcp_rsp_resid, &dst->fcp_rsp_resid);
1369 ISP_IOZPUT_32(isp, src->fcp_rsp_snslen, &dst->fcp_rsp_snslen);
1370 ISP_IOZPUT_32(isp, src->fcp_rsp_rsplen, &dst->fcp_rsp_rsplen);
1371 }
1372
1373 /*
1374 * Find port database entries
1375 */
1376 int
isp_find_pdb_empty(ispsoftc_t * isp,int chan,fcportdb_t ** lptr)1377 isp_find_pdb_empty(ispsoftc_t *isp, int chan, fcportdb_t **lptr)
1378 {
1379 fcparam *fcp = FCPARAM(isp, chan);
1380 int i;
1381
1382 for (i = 0; i < MAX_FC_TARG; i++) {
1383 fcportdb_t *lp = &fcp->portdb[i];
1384
1385 if (lp->state == FC_PORTDB_STATE_NIL) {
1386 *lptr = lp;
1387 return (1);
1388 }
1389 }
1390 return (0);
1391 }
1392
1393 int
isp_find_pdb_by_wwpn(ispsoftc_t * isp,int chan,uint64_t wwpn,fcportdb_t ** lptr)1394 isp_find_pdb_by_wwpn(ispsoftc_t *isp, int chan, uint64_t wwpn, fcportdb_t **lptr)
1395 {
1396 fcparam *fcp = FCPARAM(isp, chan);
1397 int i;
1398
1399 for (i = 0; i < MAX_FC_TARG; i++) {
1400 fcportdb_t *lp = &fcp->portdb[i];
1401
1402 if (lp->state == FC_PORTDB_STATE_NIL)
1403 continue;
1404 if (lp->port_wwn == wwpn) {
1405 *lptr = lp;
1406 return (1);
1407 }
1408 }
1409 return (0);
1410 }
1411
1412 int
isp_find_pdb_by_handle(ispsoftc_t * isp,int chan,uint16_t handle,fcportdb_t ** lptr)1413 isp_find_pdb_by_handle(ispsoftc_t *isp, int chan, uint16_t handle,
1414 fcportdb_t **lptr)
1415 {
1416 fcparam *fcp = FCPARAM(isp, chan);
1417 int i;
1418
1419 for (i = 0; i < MAX_FC_TARG; i++) {
1420 fcportdb_t *lp = &fcp->portdb[i];
1421
1422 if (lp->state == FC_PORTDB_STATE_NIL)
1423 continue;
1424 if (lp->handle == handle) {
1425 *lptr = lp;
1426 return (1);
1427 }
1428 }
1429 return (0);
1430 }
1431
1432 int
isp_find_pdb_by_portid(ispsoftc_t * isp,int chan,uint32_t portid,fcportdb_t ** lptr)1433 isp_find_pdb_by_portid(ispsoftc_t *isp, int chan, uint32_t portid,
1434 fcportdb_t **lptr)
1435 {
1436 fcparam *fcp = FCPARAM(isp, chan);
1437 int i;
1438
1439 for (i = 0; i < MAX_FC_TARG; i++) {
1440 fcportdb_t *lp = &fcp->portdb[i];
1441
1442 if (lp->state == FC_PORTDB_STATE_NIL)
1443 continue;
1444 if (lp->portid == portid) {
1445 *lptr = lp;
1446 return (1);
1447 }
1448 }
1449 return (0);
1450 }
1451
1452 #ifdef ISP_TARGET_MODE
1453 void
isp_find_chan_by_did(ispsoftc_t * isp,uint32_t did,uint16_t * cp)1454 isp_find_chan_by_did(ispsoftc_t *isp, uint32_t did, uint16_t *cp)
1455 {
1456 uint16_t chan;
1457
1458 *cp = ISP_NOCHAN;
1459 for (chan = 0; chan < isp->isp_nchan; chan++) {
1460 fcparam *fcp = FCPARAM(isp, chan);
1461 if ((fcp->role & ISP_ROLE_TARGET) == 0 ||
1462 fcp->isp_loopstate < LOOP_HAVE_ADDR) {
1463 continue;
1464 }
1465 if (fcp->isp_portid == did) {
1466 *cp = chan;
1467 break;
1468 }
1469 }
1470 }
1471
1472 /*
1473 * Add an initiator device to the port database
1474 */
1475 void
isp_add_wwn_entry(ispsoftc_t * isp,int chan,uint64_t wwpn,uint64_t wwnn,uint16_t nphdl,uint32_t s_id,uint16_t prli_params)1476 isp_add_wwn_entry(ispsoftc_t *isp, int chan, uint64_t wwpn, uint64_t wwnn,
1477 uint16_t nphdl, uint32_t s_id, uint16_t prli_params)
1478 {
1479 char buf[64];
1480 fcparam *fcp;
1481 fcportdb_t *lp;
1482 int i, change;
1483
1484 fcp = FCPARAM(isp, chan);
1485 if (nphdl >= MAX_NPORT_HANDLE) {
1486 isp_prt(isp, ISP_LOGTINFO|ISP_LOGWARN, "Chan %d WWPN 0x%016llx "
1487 "PortID 0x%06x handle 0x%x -- bad handle",
1488 chan, (unsigned long long) wwpn, s_id, nphdl);
1489 return;
1490 }
1491
1492 /*
1493 * If valid record for requested handle already exists, update it
1494 * with new parameters. Some cases of update can be suspicious,
1495 * so log them verbosely and dump the whole port database.
1496 */
1497 if ((VALID_INI(wwpn) && isp_find_pdb_by_wwpn(isp, chan, wwpn, &lp)) ||
1498 (VALID_PORT(s_id) && isp_find_pdb_by_portid(isp, chan, s_id, &lp))) {
1499 change = 0;
1500 lp->new_portid = lp->portid;
1501 lp->new_prli_word3 = lp->prli_word3;
1502 if (VALID_PORT(s_id) && lp->portid != s_id) {
1503 if (!VALID_PORT(lp->portid)) {
1504 isp_prt(isp, ISP_LOGTINFO,
1505 "Chan %d WWPN 0x%016llx handle 0x%x "
1506 "gets PortID 0x%06x",
1507 chan, (unsigned long long) lp->port_wwn,
1508 nphdl, s_id);
1509 } else {
1510 isp_prt(isp, ISP_LOGTINFO|ISP_LOGWARN,
1511 "Chan %d WWPN 0x%016llx handle 0x%x "
1512 "changes PortID 0x%06x to 0x%06x",
1513 chan, (unsigned long long) lp->port_wwn,
1514 nphdl, lp->portid, s_id);
1515 if (isp->isp_dblev & (ISP_LOGTINFO|ISP_LOGWARN))
1516 isp_dump_portdb(isp, chan);
1517 }
1518 lp->new_portid = s_id;
1519 change++;
1520 }
1521 if (VALID_INI(wwpn) && lp->port_wwn != wwpn) {
1522 if (!VALID_INI(lp->port_wwn)) {
1523 isp_prt(isp, ISP_LOGTINFO,
1524 "Chan %d PortID 0x%06x handle 0x%x "
1525 "gets WWPN 0x%016llxx",
1526 chan, lp->portid, nphdl,
1527 (unsigned long long) wwpn);
1528 } else if (lp->port_wwn != wwpn) {
1529 isp_prt(isp, ISP_LOGTINFO|ISP_LOGWARN,
1530 "Chan %d PortID 0x%06x handle 0x%x "
1531 "changes WWPN 0x%016llx to 0x%016llx",
1532 chan, lp->portid, nphdl,
1533 (unsigned long long) lp->port_wwn,
1534 (unsigned long long) wwpn);
1535 if (isp->isp_dblev & (ISP_LOGTINFO|ISP_LOGWARN))
1536 isp_dump_portdb(isp, chan);
1537 }
1538 lp->port_wwn = wwpn;
1539 change++;
1540 }
1541 if (VALID_INI(wwnn) && lp->node_wwn != wwnn) {
1542 if (!VALID_INI(lp->node_wwn)) {
1543 isp_prt(isp, ISP_LOGTINFO,
1544 "Chan %d PortID 0x%06x handle 0x%x "
1545 "gets WWNN 0x%016llxx",
1546 chan, lp->portid, nphdl,
1547 (unsigned long long) wwnn);
1548 } else if (lp->port_wwn != wwnn) {
1549 isp_prt(isp, ISP_LOGTINFO,
1550 "Chan %d PortID 0x%06x handle 0x%x "
1551 "changes WWNN 0x%016llx to 0x%016llx",
1552 chan, lp->portid, nphdl,
1553 (unsigned long long) lp->node_wwn,
1554 (unsigned long long) wwnn);
1555 }
1556 lp->node_wwn = wwnn;
1557 change++;
1558 }
1559 if (prli_params != 0 && lp->prli_word3 != prli_params) {
1560 isp_gen_role_str(buf, sizeof (buf), prli_params);
1561 isp_prt(isp, ISP_LOGTINFO|ISP_LOGCONFIG,
1562 "Chan %d WWPN 0x%016llx PortID 0x%06x "
1563 "handle 0x%x changes PRLI Word 3 %s",
1564 chan, (unsigned long long) lp->port_wwn,
1565 lp->portid, lp->handle, buf);
1566 lp->new_prli_word3 = prli_params;
1567 change++;
1568 }
1569 if (lp->handle != nphdl) {
1570 isp_prt(isp, ISP_LOGTINFO|ISP_LOGCONFIG,
1571 "Chan %d WWPN 0x%016llx PortID 0x%06x "
1572 "changes handle 0x%x to 0x%x",
1573 chan, (unsigned long long) lp->port_wwn,
1574 lp->portid, lp->handle, nphdl);
1575 lp->handle = nphdl;
1576 change++;
1577 }
1578 lp->state = FC_PORTDB_STATE_VALID;
1579 if (change) {
1580 isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp);
1581 lp->portid = lp->new_portid;
1582 lp->prli_word3 = lp->new_prli_word3;
1583 } else {
1584 isp_prt(isp, ISP_LOGTINFO,
1585 "Chan %d WWPN 0x%016llx PortID 0x%06x "
1586 "handle 0x%x reentered",
1587 chan, (unsigned long long) lp->port_wwn,
1588 lp->portid, lp->handle);
1589 isp_async(isp, ISPASYNC_DEV_STAYED, chan, lp);
1590 }
1591 return;
1592 }
1593
1594 /* Search for room to insert new record. */
1595 for (i = 0; i < MAX_FC_TARG; i++) {
1596 if (fcp->portdb[i].state == FC_PORTDB_STATE_NIL)
1597 break;
1598 }
1599 if (i >= MAX_FC_TARG) {
1600 isp_prt(isp, ISP_LOGTINFO|ISP_LOGWARN,
1601 "Chan %d WWPN 0x%016llx PortID 0x%06x handle 0x%x "
1602 "-- no room in port database",
1603 chan, (unsigned long long) wwpn, s_id, nphdl);
1604 if (isp->isp_dblev & (ISP_LOGTINFO|ISP_LOGWARN))
1605 isp_dump_portdb(isp, chan);
1606 return;
1607 }
1608
1609 /* Insert new record and mark it valid. */
1610 lp = &fcp->portdb[i];
1611 ISP_MEMZERO(lp, sizeof (fcportdb_t));
1612 lp->handle = nphdl;
1613 lp->portid = s_id;
1614 lp->port_wwn = wwpn;
1615 lp->node_wwn = wwnn;
1616 lp->prli_word3 = (prli_params != 0) ? prli_params : PRLI_WD3_INITIATOR_FUNCTION;
1617 lp->state = FC_PORTDB_STATE_VALID;
1618
1619 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
1620 isp_prt(isp, ISP_LOGTINFO, "Chan %d WWPN 0x%016llx "
1621 "PortID 0x%06x handle 0x%x vtgt %d %s added", chan,
1622 (unsigned long long) wwpn, s_id, nphdl, i, buf);
1623
1624 /* Notify above levels about new port arrival. */
1625 isp_async(isp, ISPASYNC_DEV_ARRIVED, chan, lp);
1626 }
1627
1628 /*
1629 * Remove a target device to the port database
1630 */
1631 void
isp_del_wwn_entry(ispsoftc_t * isp,int chan,uint64_t wwpn,uint16_t nphdl,uint32_t s_id)1632 isp_del_wwn_entry(ispsoftc_t *isp, int chan, uint64_t wwpn, uint16_t nphdl, uint32_t s_id)
1633 {
1634 fcportdb_t *lp;
1635
1636 if (nphdl >= MAX_NPORT_HANDLE) {
1637 isp_prt(isp, ISP_LOGWARN, "Chan %d WWPN 0x%016llx PortID 0x%06x bad handle 0x%x",
1638 chan, (unsigned long long) wwpn, s_id, nphdl);
1639 return;
1640 }
1641
1642 if (isp_find_pdb_by_handle(isp, chan, nphdl, &lp) == 0) {
1643 isp_prt(isp, ISP_LOGWARN, "Chan %d WWPN 0x%016llx PortID 0x%06x handle 0x%x cannot be found to be deleted",
1644 chan, (unsigned long long) wwpn, s_id, nphdl);
1645 isp_dump_portdb(isp, chan);
1646 return;
1647 }
1648 isp_prt(isp, ISP_LOGTINFO, "Chan %d WWPN 0x%016llx PortID 0x%06x handle 0x%x vtgt %d deleted",
1649 chan, (unsigned long long) lp->port_wwn, lp->portid, nphdl, FC_PORTDB_TGT(isp, chan, lp));
1650 lp->state = FC_PORTDB_STATE_NIL;
1651
1652 /* Notify above levels about gone port. */
1653 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp);
1654 }
1655 #endif /* ISP_TARGET_MODE */
1656
1657 void
isp_get_atio7(ispsoftc_t * isp,at7_entry_t * src,at7_entry_t * dst)1658 isp_get_atio7(ispsoftc_t *isp, at7_entry_t *src, at7_entry_t *dst)
1659 {
1660 ISP_IOXGET_8(isp, &src->at_type, dst->at_type);
1661 ISP_IOXGET_8(isp, &src->at_count, dst->at_count);
1662 ISP_IOXGET_16(isp, &src->at_ta_len, dst->at_ta_len);
1663 ISP_IOXGET_32(isp, &src->at_rxid, dst->at_rxid);
1664 isp_get_fc_hdr(isp, &src->at_hdr, &dst->at_hdr);
1665 isp_get_fcp_cmnd_iu(isp, &src->at_cmnd, &dst->at_cmnd);
1666 }
1667
1668 void
isp_put_ctio7(ispsoftc_t * isp,ct7_entry_t * src,ct7_entry_t * dst)1669 isp_put_ctio7(ispsoftc_t *isp, ct7_entry_t *src, ct7_entry_t *dst)
1670 {
1671 int i;
1672
1673 isp_put_hdr(isp, &src->ct_header, &dst->ct_header);
1674 ISP_IOXPUT_32(isp, src->ct_syshandle, &dst->ct_syshandle);
1675 ISP_IOXPUT_16(isp, src->ct_nphdl, &dst->ct_nphdl);
1676 ISP_IOXPUT_16(isp, src->ct_timeout, &dst->ct_timeout);
1677 ISP_IOXPUT_16(isp, src->ct_seg_count, &dst->ct_seg_count);
1678 ISP_IOXPUT_8(isp, src->ct_vpidx, &dst->ct_vpidx);
1679 ISP_IOXPUT_8(isp, src->ct_xflags, &dst->ct_xflags);
1680 ISP_IOXPUT_16(isp, src->ct_iid_lo, &dst->ct_iid_lo);
1681 ISP_IOXPUT_8(isp, src->ct_iid_hi, &dst->ct_iid_hi);
1682 ISP_IOXPUT_8(isp, src->ct_reserved, &dst->ct_reserved);
1683 ISP_IOXPUT_32(isp, src->ct_rxid, &dst->ct_rxid);
1684 ISP_IOXPUT_16(isp, src->ct_senselen, &dst->ct_senselen);
1685 ISP_IOXPUT_16(isp, src->ct_flags, &dst->ct_flags);
1686 ISP_IOXPUT_32(isp, src->ct_resid, &dst->ct_resid);
1687 ISP_IOXPUT_16(isp, src->ct_oxid, &dst->ct_oxid);
1688 ISP_IOXPUT_16(isp, src->ct_scsi_status, &dst->ct_scsi_status);
1689 if ((dst->ct_flags & CT7_FLAG_MMASK) == CT7_FLAG_MODE0) {
1690 ISP_IOXPUT_32(isp, src->rsp.m0.reloff, &dst->rsp.m0.reloff);
1691 ISP_IOXPUT_32(isp, src->rsp.m0.reserved0, &dst->rsp.m0.reserved0);
1692 ISP_IOXPUT_32(isp, src->rsp.m0.ct_xfrlen, &dst->rsp.m0.ct_xfrlen);
1693 ISP_IOXPUT_32(isp, src->rsp.m0.reserved1, &dst->rsp.m0.reserved1);
1694 ISP_IOXPUT_32(isp, src->rsp.m0.ds.ds_base, &dst->rsp.m0.ds.ds_base);
1695 ISP_IOXPUT_32(isp, src->rsp.m0.ds.ds_basehi, &dst->rsp.m0.ds.ds_basehi);
1696 ISP_IOXPUT_32(isp, src->rsp.m0.ds.ds_count, &dst->rsp.m0.ds.ds_count);
1697 } else if ((dst->ct_flags & CT7_FLAG_MMASK) == CT7_FLAG_MODE1) {
1698 uint32_t *a, *b;
1699
1700 ISP_IOXPUT_16(isp, src->rsp.m1.ct_resplen, &dst->rsp.m1.ct_resplen);
1701 ISP_IOXPUT_16(isp, src->rsp.m1.reserved, &dst->rsp.m1.reserved);
1702 a = (uint32_t *) src->rsp.m1.ct_resp;
1703 b = (uint32_t *) dst->rsp.m1.ct_resp;
1704 for (i = 0; i < (nitems(src->rsp.m1.ct_resp) >> 2); i++) {
1705 *b++ = ISP_SWAP32(isp, *a++);
1706 }
1707 } else {
1708 ISP_IOXPUT_32(isp, src->rsp.m2.reserved0, &dst->rsp.m2.reserved0);
1709 ISP_IOXPUT_32(isp, src->rsp.m2.reserved1, &dst->rsp.m2.reserved1);
1710 ISP_IOXPUT_32(isp, src->rsp.m2.ct_datalen, &dst->rsp.m2.ct_datalen);
1711 ISP_IOXPUT_32(isp, src->rsp.m2.reserved2, &dst->rsp.m2.reserved2);
1712 ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_base, &dst->rsp.m2.ct_fcp_rsp_iudata.ds_base);
1713 ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_basehi, &dst->rsp.m2.ct_fcp_rsp_iudata.ds_basehi);
1714 ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_count, &dst->rsp.m2.ct_fcp_rsp_iudata.ds_count);
1715 }
1716 }
1717
1718 void
isp_get_ctio7(ispsoftc_t * isp,ct7_entry_t * src,ct7_entry_t * dst)1719 isp_get_ctio7(ispsoftc_t *isp, ct7_entry_t *src, ct7_entry_t *dst)
1720 {
1721 int i;
1722
1723 isp_get_hdr(isp, &src->ct_header, &dst->ct_header);
1724 ISP_IOXGET_32(isp, &src->ct_syshandle, dst->ct_syshandle);
1725 ISP_IOXGET_16(isp, &src->ct_nphdl, dst->ct_nphdl);
1726 ISP_IOXGET_16(isp, &src->ct_timeout, dst->ct_timeout);
1727 ISP_IOXGET_16(isp, &src->ct_seg_count, dst->ct_seg_count);
1728 ISP_IOXGET_8(isp, &src->ct_vpidx, dst->ct_vpidx);
1729 ISP_IOXGET_8(isp, &src->ct_xflags, dst->ct_xflags);
1730 ISP_IOXGET_16(isp, &src->ct_iid_lo, dst->ct_iid_lo);
1731 ISP_IOXGET_8(isp, &src->ct_iid_hi, dst->ct_iid_hi);
1732 ISP_IOXGET_8(isp, &src->ct_reserved, dst->ct_reserved);
1733 ISP_IOXGET_32(isp, &src->ct_rxid, dst->ct_rxid);
1734 ISP_IOXGET_16(isp, &src->ct_senselen, dst->ct_senselen);
1735 ISP_IOXGET_16(isp, &src->ct_flags, dst->ct_flags);
1736 ISP_IOXGET_32(isp, &src->ct_resid, dst->ct_resid);
1737 ISP_IOXGET_16(isp, &src->ct_oxid, dst->ct_oxid);
1738 ISP_IOXGET_16(isp, &src->ct_scsi_status, dst->ct_scsi_status);
1739 if ((dst->ct_flags & CT7_FLAG_MMASK) == CT7_FLAG_MODE0) {
1740 ISP_IOXGET_32(isp, &src->rsp.m0.reloff, dst->rsp.m0.reloff);
1741 ISP_IOXGET_32(isp, &src->rsp.m0.reserved0, dst->rsp.m0.reserved0);
1742 ISP_IOXGET_32(isp, &src->rsp.m0.ct_xfrlen, dst->rsp.m0.ct_xfrlen);
1743 ISP_IOXGET_32(isp, &src->rsp.m0.reserved1, dst->rsp.m0.reserved1);
1744 ISP_IOXGET_32(isp, &src->rsp.m0.ds.ds_base, dst->rsp.m0.ds.ds_base);
1745 ISP_IOXGET_32(isp, &src->rsp.m0.ds.ds_basehi, dst->rsp.m0.ds.ds_basehi);
1746 ISP_IOXGET_32(isp, &src->rsp.m0.ds.ds_count, dst->rsp.m0.ds.ds_count);
1747 } else if ((dst->ct_flags & CT7_FLAG_MMASK) == CT7_FLAG_MODE1) {
1748 uint32_t *a, *b;
1749
1750 ISP_IOXGET_16(isp, &src->rsp.m1.ct_resplen, dst->rsp.m1.ct_resplen);
1751 ISP_IOXGET_16(isp, &src->rsp.m1.reserved, dst->rsp.m1.reserved);
1752 a = (uint32_t *) src->rsp.m1.ct_resp;
1753 b = (uint32_t *) dst->rsp.m1.ct_resp;
1754 for (i = 0; i < MAXRESPLEN_24XX; i++) {
1755 ISP_IOXGET_8(isp, &src->rsp.m1.ct_resp[i], dst->rsp.m1.ct_resp[i]);
1756 }
1757 for (i = 0; i < (nitems(src->rsp.m1.ct_resp) >> 2); i++) {
1758 *b++ = ISP_SWAP32(isp, *a++);
1759 }
1760 } else {
1761 ISP_IOXGET_32(isp, &src->rsp.m2.reserved0, dst->rsp.m2.reserved0);
1762 ISP_IOXGET_32(isp, &src->rsp.m2.ct_datalen, dst->rsp.m2.ct_datalen);
1763 ISP_IOXGET_32(isp, &src->rsp.m2.reserved1, dst->rsp.m2.reserved1);
1764 ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_base, dst->rsp.m2.ct_fcp_rsp_iudata.ds_base);
1765 ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_basehi, dst->rsp.m2.ct_fcp_rsp_iudata.ds_basehi);
1766 ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_count, dst->rsp.m2.ct_fcp_rsp_iudata.ds_count);
1767 }
1768 }
1769
1770 void
isp_put_notify_24xx(ispsoftc_t * isp,in_fcentry_24xx_t * src,in_fcentry_24xx_t * dst)1771 isp_put_notify_24xx(ispsoftc_t *isp, in_fcentry_24xx_t *src, in_fcentry_24xx_t *dst)
1772 {
1773 int i;
1774
1775 isp_put_hdr(isp, &src->in_header, &dst->in_header);
1776 ISP_IOXPUT_32(isp, src->in_reserved, &dst->in_reserved);
1777 ISP_IOXPUT_16(isp, src->in_nphdl, &dst->in_nphdl);
1778 ISP_IOXPUT_16(isp, src->in_reserved1, &dst->in_reserved1);
1779 ISP_IOXPUT_16(isp, src->in_flags, &dst->in_flags);
1780 ISP_IOXPUT_16(isp, src->in_srr_rxid, &dst->in_srr_rxid);
1781 ISP_IOXPUT_16(isp, src->in_status, &dst->in_status);
1782 ISP_IOXPUT_8(isp, src->in_status_subcode, &dst->in_status_subcode);
1783 ISP_IOXPUT_8(isp, src->in_fwhandle, &dst->in_fwhandle);
1784 ISP_IOXPUT_32(isp, src->in_rxid, &dst->in_rxid);
1785 ISP_IOXPUT_16(isp, src->in_srr_reloff_hi, &dst->in_srr_reloff_hi);
1786 ISP_IOXPUT_16(isp, src->in_srr_reloff_lo, &dst->in_srr_reloff_lo);
1787 ISP_IOXPUT_16(isp, src->in_srr_iu, &dst->in_srr_iu);
1788 ISP_IOXPUT_16(isp, src->in_srr_oxid, &dst->in_srr_oxid);
1789 ISP_IOXPUT_16(isp, src->in_nport_id_hi, &dst->in_nport_id_hi);
1790 ISP_IOXPUT_8(isp, src->in_nport_id_lo, &dst->in_nport_id_lo);
1791 ISP_IOXPUT_8(isp, src->in_reserved3, &dst->in_reserved3);
1792 ISP_IOXPUT_16(isp, src->in_np_handle, &dst->in_np_handle);
1793 for (i = 0; i < nitems(src->in_reserved4); i++) {
1794 ISP_IOXPUT_8(isp, src->in_reserved4[i], &dst->in_reserved4[i]);
1795 }
1796 ISP_IOXPUT_8(isp, src->in_reserved5, &dst->in_reserved5);
1797 ISP_IOXPUT_8(isp, src->in_vpidx, &dst->in_vpidx);
1798 ISP_IOXPUT_32(isp, src->in_reserved6, &dst->in_reserved6);
1799 ISP_IOXPUT_16(isp, src->in_portid_lo, &dst->in_portid_lo);
1800 ISP_IOXPUT_8(isp, src->in_portid_hi, &dst->in_portid_hi);
1801 ISP_IOXPUT_8(isp, src->in_reserved7, &dst->in_reserved7);
1802 ISP_IOXPUT_16(isp, src->in_reserved8, &dst->in_reserved8);
1803 ISP_IOXPUT_16(isp, src->in_oxid, &dst->in_oxid);
1804 }
1805
1806 void
isp_get_notify_24xx(ispsoftc_t * isp,in_fcentry_24xx_t * src,in_fcentry_24xx_t * dst)1807 isp_get_notify_24xx(ispsoftc_t *isp, in_fcentry_24xx_t *src, in_fcentry_24xx_t *dst)
1808 {
1809 int i;
1810
1811 isp_get_hdr(isp, &src->in_header, &dst->in_header);
1812 ISP_IOXGET_32(isp, &src->in_reserved, dst->in_reserved);
1813 ISP_IOXGET_16(isp, &src->in_nphdl, dst->in_nphdl);
1814 ISP_IOXGET_16(isp, &src->in_reserved1, dst->in_reserved1);
1815 ISP_IOXGET_16(isp, &src->in_flags, dst->in_flags);
1816 ISP_IOXGET_16(isp, &src->in_srr_rxid, dst->in_srr_rxid);
1817 ISP_IOXGET_16(isp, &src->in_status, dst->in_status);
1818 ISP_IOXGET_8(isp, &src->in_status_subcode, dst->in_status_subcode);
1819 ISP_IOXGET_8(isp, &src->in_fwhandle, dst->in_fwhandle);
1820 ISP_IOXGET_32(isp, &src->in_rxid, dst->in_rxid);
1821 ISP_IOXGET_16(isp, &src->in_srr_reloff_hi, dst->in_srr_reloff_hi);
1822 ISP_IOXGET_16(isp, &src->in_srr_reloff_lo, dst->in_srr_reloff_lo);
1823 ISP_IOXGET_16(isp, &src->in_srr_iu, dst->in_srr_iu);
1824 ISP_IOXGET_16(isp, &src->in_srr_oxid, dst->in_srr_oxid);
1825 ISP_IOXGET_16(isp, &src->in_nport_id_hi, dst->in_nport_id_hi);
1826 ISP_IOXGET_8(isp, &src->in_nport_id_lo, dst->in_nport_id_lo);
1827 ISP_IOXGET_8(isp, &src->in_reserved3, dst->in_reserved3);
1828 ISP_IOXGET_16(isp, &src->in_np_handle, dst->in_np_handle);
1829 for (i = 0; i < nitems(src->in_reserved4); i++) {
1830 ISP_IOXGET_8(isp, &src->in_reserved4[i], dst->in_reserved4[i]);
1831 }
1832 ISP_IOXGET_8(isp, &src->in_reserved5, dst->in_reserved5);
1833 ISP_IOXGET_8(isp, &src->in_vpidx, dst->in_vpidx);
1834 ISP_IOXGET_32(isp, &src->in_reserved6, dst->in_reserved6);
1835 ISP_IOXGET_16(isp, &src->in_portid_lo, dst->in_portid_lo);
1836 ISP_IOXGET_8(isp, &src->in_portid_hi, dst->in_portid_hi);
1837 ISP_IOXGET_8(isp, &src->in_reserved7, dst->in_reserved7);
1838 ISP_IOXGET_16(isp, &src->in_reserved8, dst->in_reserved8);
1839 ISP_IOXGET_16(isp, &src->in_oxid, dst->in_oxid);
1840 }
1841
1842 void
isp_put_notify_ack_24xx(ispsoftc_t * isp,na_fcentry_24xx_t * src,na_fcentry_24xx_t * dst)1843 isp_put_notify_ack_24xx(ispsoftc_t *isp, na_fcentry_24xx_t *src, na_fcentry_24xx_t *dst)
1844 {
1845 int i;
1846
1847 isp_put_hdr(isp, &src->na_header, &dst->na_header);
1848 ISP_IOXPUT_32(isp, src->na_handle, &dst->na_handle);
1849 ISP_IOXPUT_16(isp, src->na_nphdl, &dst->na_nphdl);
1850 ISP_IOXPUT_16(isp, src->na_reserved1, &dst->na_reserved1);
1851 ISP_IOXPUT_16(isp, src->na_flags, &dst->na_flags);
1852 ISP_IOXPUT_16(isp, src->na_srr_rxid, &dst->na_srr_rxid);
1853 ISP_IOXPUT_16(isp, src->na_status, &dst->na_status);
1854 ISP_IOXPUT_8(isp, src->na_status_subcode, &dst->na_status_subcode);
1855 ISP_IOXPUT_8(isp, src->na_fwhandle, &dst->na_fwhandle);
1856 ISP_IOXPUT_32(isp, src->na_rxid, &dst->na_rxid);
1857 ISP_IOXPUT_16(isp, src->na_srr_reloff_hi, &dst->na_srr_reloff_hi);
1858 ISP_IOXPUT_16(isp, src->na_srr_reloff_lo, &dst->na_srr_reloff_lo);
1859 ISP_IOXPUT_16(isp, src->na_srr_iu, &dst->na_srr_iu);
1860 ISP_IOXPUT_16(isp, src->na_srr_flags, &dst->na_srr_flags);
1861 for (i = 0; i < 18; i++) {
1862 ISP_IOXPUT_8(isp, src->na_reserved3[i], &dst->na_reserved3[i]);
1863 }
1864 ISP_IOXPUT_8(isp, src->na_reserved4, &dst->na_reserved4);
1865 ISP_IOXPUT_8(isp, src->na_vpidx, &dst->na_vpidx);
1866 ISP_IOXPUT_8(isp, src->na_srr_reject_vunique, &dst->na_srr_reject_vunique);
1867 ISP_IOXPUT_8(isp, src->na_srr_reject_explanation, &dst->na_srr_reject_explanation);
1868 ISP_IOXPUT_8(isp, src->na_srr_reject_code, &dst->na_srr_reject_code);
1869 ISP_IOXPUT_8(isp, src->na_reserved5, &dst->na_reserved5);
1870 for (i = 0; i < 6; i++) {
1871 ISP_IOXPUT_8(isp, src->na_reserved6[i], &dst->na_reserved6[i]);
1872 }
1873 ISP_IOXPUT_16(isp, src->na_oxid, &dst->na_oxid);
1874 }
1875
1876 void
isp_get_notify_ack_24xx(ispsoftc_t * isp,na_fcentry_24xx_t * src,na_fcentry_24xx_t * dst)1877 isp_get_notify_ack_24xx(ispsoftc_t *isp, na_fcentry_24xx_t *src, na_fcentry_24xx_t *dst)
1878 {
1879 int i;
1880
1881 isp_get_hdr(isp, &src->na_header, &dst->na_header);
1882 ISP_IOXGET_32(isp, &src->na_handle, dst->na_handle);
1883 ISP_IOXGET_16(isp, &src->na_nphdl, dst->na_nphdl);
1884 ISP_IOXGET_16(isp, &src->na_reserved1, dst->na_reserved1);
1885 ISP_IOXGET_16(isp, &src->na_flags, dst->na_flags);
1886 ISP_IOXGET_16(isp, &src->na_srr_rxid, dst->na_srr_rxid);
1887 ISP_IOXGET_16(isp, &src->na_status, dst->na_status);
1888 ISP_IOXGET_8(isp, &src->na_status_subcode, dst->na_status_subcode);
1889 ISP_IOXGET_8(isp, &src->na_fwhandle, dst->na_fwhandle);
1890 ISP_IOXGET_32(isp, &src->na_rxid, dst->na_rxid);
1891 ISP_IOXGET_16(isp, &src->na_srr_reloff_hi, dst->na_srr_reloff_hi);
1892 ISP_IOXGET_16(isp, &src->na_srr_reloff_lo, dst->na_srr_reloff_lo);
1893 ISP_IOXGET_16(isp, &src->na_srr_iu, dst->na_srr_iu);
1894 ISP_IOXGET_16(isp, &src->na_srr_flags, dst->na_srr_flags);
1895 for (i = 0; i < 18; i++) {
1896 ISP_IOXGET_8(isp, &src->na_reserved3[i], dst->na_reserved3[i]);
1897 }
1898 ISP_IOXGET_8(isp, &src->na_reserved4, dst->na_reserved4);
1899 ISP_IOXGET_8(isp, &src->na_vpidx, dst->na_vpidx);
1900 ISP_IOXGET_8(isp, &src->na_srr_reject_vunique, dst->na_srr_reject_vunique);
1901 ISP_IOXGET_8(isp, &src->na_srr_reject_explanation, dst->na_srr_reject_explanation);
1902 ISP_IOXGET_8(isp, &src->na_srr_reject_code, dst->na_srr_reject_code);
1903 ISP_IOXGET_8(isp, &src->na_reserved5, dst->na_reserved5);
1904 for (i = 0; i < 6; i++) {
1905 ISP_IOXGET_8(isp, &src->na_reserved6[i], dst->na_reserved6[i]);
1906 }
1907 ISP_IOXGET_16(isp, &src->na_oxid, dst->na_oxid);
1908 }
1909
1910 void
isp_get_abts(ispsoftc_t * isp,abts_t * src,abts_t * dst)1911 isp_get_abts(ispsoftc_t *isp, abts_t *src, abts_t *dst)
1912 {
1913 int i;
1914
1915 isp_get_hdr(isp, &src->abts_header, &dst->abts_header);
1916 for (i = 0; i < 6; i++) {
1917 ISP_IOXGET_8(isp, &src->abts_reserved0[i], dst->abts_reserved0[i]);
1918 }
1919 ISP_IOXGET_16(isp, &src->abts_nphdl, dst->abts_nphdl);
1920 ISP_IOXGET_16(isp, &src->abts_reserved1, dst->abts_reserved1);
1921 ISP_IOXGET_16(isp, &src->abts_sof, dst->abts_sof);
1922 ISP_IOXGET_32(isp, &src->abts_rxid_abts, dst->abts_rxid_abts);
1923 ISP_IOXGET_16(isp, &src->abts_did_lo, dst->abts_did_lo);
1924 ISP_IOXGET_8(isp, &src->abts_did_hi, dst->abts_did_hi);
1925 ISP_IOXGET_8(isp, &src->abts_r_ctl, dst->abts_r_ctl);
1926 ISP_IOXGET_16(isp, &src->abts_sid_lo, dst->abts_sid_lo);
1927 ISP_IOXGET_8(isp, &src->abts_sid_hi, dst->abts_sid_hi);
1928 ISP_IOXGET_8(isp, &src->abts_cs_ctl, dst->abts_cs_ctl);
1929 ISP_IOXGET_16(isp, &src->abts_fs_ctl, dst->abts_fs_ctl);
1930 ISP_IOXGET_8(isp, &src->abts_f_ctl, dst->abts_f_ctl);
1931 ISP_IOXGET_8(isp, &src->abts_type, dst->abts_type);
1932 ISP_IOXGET_16(isp, &src->abts_seq_cnt, dst->abts_seq_cnt);
1933 ISP_IOXGET_8(isp, &src->abts_df_ctl, dst->abts_df_ctl);
1934 ISP_IOXGET_8(isp, &src->abts_seq_id, dst->abts_seq_id);
1935 ISP_IOXGET_16(isp, &src->abts_rx_id, dst->abts_rx_id);
1936 ISP_IOXGET_16(isp, &src->abts_ox_id, dst->abts_ox_id);
1937 ISP_IOXGET_32(isp, &src->abts_param, dst->abts_param);
1938 for (i = 0; i < 16; i++) {
1939 ISP_IOXGET_8(isp, &src->abts_reserved2[i], dst->abts_reserved2[i]);
1940 }
1941 ISP_IOXGET_32(isp, &src->abts_rxid_task, dst->abts_rxid_task);
1942 }
1943
1944 void
isp_put_abts_rsp(ispsoftc_t * isp,abts_rsp_t * src,abts_rsp_t * dst)1945 isp_put_abts_rsp(ispsoftc_t *isp, abts_rsp_t *src, abts_rsp_t *dst)
1946 {
1947 int i;
1948
1949 isp_put_hdr(isp, &src->abts_rsp_header, &dst->abts_rsp_header);
1950 ISP_IOXPUT_32(isp, src->abts_rsp_handle, &dst->abts_rsp_handle);
1951 ISP_IOXPUT_16(isp, src->abts_rsp_status, &dst->abts_rsp_status);
1952 ISP_IOXPUT_16(isp, src->abts_rsp_nphdl, &dst->abts_rsp_nphdl);
1953 ISP_IOXPUT_16(isp, src->abts_rsp_ctl_flags, &dst->abts_rsp_ctl_flags);
1954 ISP_IOXPUT_16(isp, src->abts_rsp_sof, &dst->abts_rsp_sof);
1955 ISP_IOXPUT_32(isp, src->abts_rsp_rxid_abts, &dst->abts_rsp_rxid_abts);
1956 ISP_IOXPUT_16(isp, src->abts_rsp_did_lo, &dst->abts_rsp_did_lo);
1957 ISP_IOXPUT_8(isp, src->abts_rsp_did_hi, &dst->abts_rsp_did_hi);
1958 ISP_IOXPUT_8(isp, src->abts_rsp_r_ctl, &dst->abts_rsp_r_ctl);
1959 ISP_IOXPUT_16(isp, src->abts_rsp_sid_lo, &dst->abts_rsp_sid_lo);
1960 ISP_IOXPUT_8(isp, src->abts_rsp_sid_hi, &dst->abts_rsp_sid_hi);
1961 ISP_IOXPUT_8(isp, src->abts_rsp_cs_ctl, &dst->abts_rsp_cs_ctl);
1962 ISP_IOXPUT_16(isp, src->abts_rsp_f_ctl_lo, &dst->abts_rsp_f_ctl_lo);
1963 ISP_IOXPUT_8(isp, src->abts_rsp_f_ctl_hi, &dst->abts_rsp_f_ctl_hi);
1964 ISP_IOXPUT_8(isp, src->abts_rsp_type, &dst->abts_rsp_type);
1965 ISP_IOXPUT_16(isp, src->abts_rsp_seq_cnt, &dst->abts_rsp_seq_cnt);
1966 ISP_IOXPUT_8(isp, src->abts_rsp_df_ctl, &dst->abts_rsp_df_ctl);
1967 ISP_IOXPUT_8(isp, src->abts_rsp_seq_id, &dst->abts_rsp_seq_id);
1968 ISP_IOXPUT_16(isp, src->abts_rsp_rx_id, &dst->abts_rsp_rx_id);
1969 ISP_IOXPUT_16(isp, src->abts_rsp_ox_id, &dst->abts_rsp_ox_id);
1970 ISP_IOXPUT_32(isp, src->abts_rsp_param, &dst->abts_rsp_param);
1971 if (src->abts_rsp_r_ctl == BA_ACC) {
1972 ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.reserved, &dst->abts_rsp_payload.ba_acc.reserved);
1973 ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_acc.last_seq_id, &dst->abts_rsp_payload.ba_acc.last_seq_id);
1974 ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_acc.seq_id_valid, &dst->abts_rsp_payload.ba_acc.seq_id_valid);
1975 ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.aborted_rx_id, &dst->abts_rsp_payload.ba_acc.aborted_rx_id);
1976 ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.aborted_ox_id, &dst->abts_rsp_payload.ba_acc.aborted_ox_id);
1977 ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.high_seq_cnt, &dst->abts_rsp_payload.ba_acc.high_seq_cnt);
1978 ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.low_seq_cnt, &dst->abts_rsp_payload.ba_acc.low_seq_cnt);
1979 for (i = 0; i < 4; i++) {
1980 ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.reserved2[i], &dst->abts_rsp_payload.ba_acc.reserved2[i]);
1981 }
1982 } else if (src->abts_rsp_r_ctl == BA_RJT) {
1983 ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_rjt.vendor_unique, &dst->abts_rsp_payload.ba_rjt.vendor_unique);
1984 ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_rjt.explanation, &dst->abts_rsp_payload.ba_rjt.explanation);
1985 ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_rjt.reason, &dst->abts_rsp_payload.ba_rjt.reason);
1986 ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_rjt.reserved, &dst->abts_rsp_payload.ba_rjt.reserved);
1987 for (i = 0; i < 12; i++) {
1988 ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_rjt.reserved2[i], &dst->abts_rsp_payload.ba_rjt.reserved2[i]);
1989 }
1990 } else {
1991 for (i = 0; i < 16; i++) {
1992 ISP_IOXPUT_8(isp, src->abts_rsp_payload.reserved[i], &dst->abts_rsp_payload.reserved[i]);
1993 }
1994 }
1995 ISP_IOXPUT_32(isp, src->abts_rsp_rxid_task, &dst->abts_rsp_rxid_task);
1996 }
1997
1998 void
isp_get_abts_rsp(ispsoftc_t * isp,abts_rsp_t * src,abts_rsp_t * dst)1999 isp_get_abts_rsp(ispsoftc_t *isp, abts_rsp_t *src, abts_rsp_t *dst)
2000 {
2001 int i;
2002
2003 isp_get_hdr(isp, &src->abts_rsp_header, &dst->abts_rsp_header);
2004 ISP_IOXGET_32(isp, &src->abts_rsp_handle, dst->abts_rsp_handle);
2005 ISP_IOXGET_16(isp, &src->abts_rsp_status, dst->abts_rsp_status);
2006 ISP_IOXGET_16(isp, &src->abts_rsp_nphdl, dst->abts_rsp_nphdl);
2007 ISP_IOXGET_16(isp, &src->abts_rsp_ctl_flags, dst->abts_rsp_ctl_flags);
2008 ISP_IOXGET_16(isp, &src->abts_rsp_sof, dst->abts_rsp_sof);
2009 ISP_IOXGET_32(isp, &src->abts_rsp_rxid_abts, dst->abts_rsp_rxid_abts);
2010 ISP_IOXGET_16(isp, &src->abts_rsp_did_lo, dst->abts_rsp_did_lo);
2011 ISP_IOXGET_8(isp, &src->abts_rsp_did_hi, dst->abts_rsp_did_hi);
2012 ISP_IOXGET_8(isp, &src->abts_rsp_r_ctl, dst->abts_rsp_r_ctl);
2013 ISP_IOXGET_16(isp, &src->abts_rsp_sid_lo, dst->abts_rsp_sid_lo);
2014 ISP_IOXGET_8(isp, &src->abts_rsp_sid_hi, dst->abts_rsp_sid_hi);
2015 ISP_IOXGET_8(isp, &src->abts_rsp_cs_ctl, dst->abts_rsp_cs_ctl);
2016 ISP_IOXGET_16(isp, &src->abts_rsp_f_ctl_lo, dst->abts_rsp_f_ctl_lo);
2017 ISP_IOXGET_8(isp, &src->abts_rsp_f_ctl_hi, dst->abts_rsp_f_ctl_hi);
2018 ISP_IOXGET_8(isp, &src->abts_rsp_type, dst->abts_rsp_type);
2019 ISP_IOXGET_16(isp, &src->abts_rsp_seq_cnt, dst->abts_rsp_seq_cnt);
2020 ISP_IOXGET_8(isp, &src->abts_rsp_df_ctl, dst->abts_rsp_df_ctl);
2021 ISP_IOXGET_8(isp, &src->abts_rsp_seq_id, dst->abts_rsp_seq_id);
2022 ISP_IOXGET_16(isp, &src->abts_rsp_rx_id, dst->abts_rsp_rx_id);
2023 ISP_IOXGET_16(isp, &src->abts_rsp_ox_id, dst->abts_rsp_ox_id);
2024 ISP_IOXGET_32(isp, &src->abts_rsp_param, dst->abts_rsp_param);
2025 for (i = 0; i < 8; i++) {
2026 ISP_IOXGET_8(isp, &src->abts_rsp_payload.rsp.reserved[i], dst->abts_rsp_payload.rsp.reserved[i]);
2027 }
2028 ISP_IOXGET_32(isp, &src->abts_rsp_payload.rsp.subcode1, dst->abts_rsp_payload.rsp.subcode1);
2029 ISP_IOXGET_32(isp, &src->abts_rsp_payload.rsp.subcode2, dst->abts_rsp_payload.rsp.subcode2);
2030 ISP_IOXGET_32(isp, &src->abts_rsp_rxid_task, dst->abts_rsp_rxid_task);
2031 }
2032
2033 void
isp_put_entry(ispsoftc_t * isp,void * src,void * dst)2034 isp_put_entry(ispsoftc_t *isp, void *src, void *dst)
2035 {
2036 uint8_t etype = ((isphdr_t *)src)->rqs_entry_type;
2037
2038 switch (etype) {
2039 case RQSTYPE_NOTIFY_ACK:
2040 isp_put_notify_ack_24xx(isp, (na_fcentry_24xx_t *)src,
2041 (na_fcentry_24xx_t *)dst);
2042 break;
2043 case RQSTYPE_CTIO7:
2044 isp_put_ctio7(isp, (ct7_entry_t *)src, (ct7_entry_t *)dst);
2045 break;
2046 case RQSTYPE_TSK_MGMT:
2047 isp_put_24xx_tmf(isp, (isp24xx_tmf_t *)src, (isp24xx_tmf_t *)dst);
2048 break;
2049 case RQSTYPE_CT_PASSTHRU:
2050 isp_put_ct_pt(isp, (isp_ct_pt_t *)src, (isp_ct_pt_t *)dst);
2051 break;
2052 case RQSTYPE_VP_CTRL:
2053 isp_put_vp_ctrl_info(isp, (vp_ctrl_info_t *)src, (vp_ctrl_info_t *)dst);
2054 break;
2055 case RQSTYPE_VP_MODIFY:
2056 isp_put_vp_modify(isp, (vp_modify_t *)src, (vp_modify_t *)dst);
2057 break;
2058 case RQSTYPE_ABORT_IO:
2059 isp_put_24xx_abrt(isp, (isp24xx_abrt_t *)src, (isp24xx_abrt_t *)dst);
2060 break;
2061 case RQSTYPE_LOGIN:
2062 isp_put_plogx(isp, (isp_plogx_t *)src, (isp_plogx_t *)dst);
2063 break;
2064 case RQSTYPE_ABTS_RSP:
2065 isp_put_abts_rsp(isp, (abts_rsp_t *)src, (abts_rsp_t *)dst);
2066 break;
2067 default:
2068 panic("%s: Unknown type 0x%x\n", __func__, etype);
2069 }
2070 }
2071
2072 void
isp_get_entry(ispsoftc_t * isp,void * src,void * dst)2073 isp_get_entry(ispsoftc_t *isp, void *src, void *dst)
2074 {
2075 uint8_t etype;
2076
2077 isp_get_hdr(isp, src, (isphdr_t *)dst);
2078 etype = ((isphdr_t *)dst)->rqs_entry_type;
2079 switch (etype) {
2080 case 0: /* After isp_clear_commands() */
2081 ISP_MEMZERO(dst, QENTRY_LEN);
2082 break;
2083 case RQSTYPE_RESPONSE:
2084 isp_get_24xx_response(isp, (isp24xx_statusreq_t *)src, (isp24xx_statusreq_t *)dst);
2085 break;
2086 case RQSTYPE_CT_PASSTHRU:
2087 isp_get_ct_pt(isp, (isp_ct_pt_t *)src, (isp_ct_pt_t *)dst);
2088 break;
2089 case RQSTYPE_VP_CTRL:
2090 isp_get_vp_ctrl_info(isp, (vp_ctrl_info_t *)src, (vp_ctrl_info_t *)dst);
2091 break;
2092 case RQSTYPE_VP_MODIFY:
2093 isp_get_vp_modify(isp, (vp_modify_t *)src, (vp_modify_t *)dst);
2094 break;
2095 case RQSTYPE_ABORT_IO:
2096 isp_get_24xx_abrt(isp, (isp24xx_abrt_t *)src, (isp24xx_abrt_t *)dst);
2097 break;
2098 case RQSTYPE_LOGIN:
2099 isp_get_plogx(isp, (isp_plogx_t *)src, (isp_plogx_t *)dst);
2100 break;
2101 default:
2102 panic("%s: Unknown type 0x%x\n", __func__, etype);
2103 }
2104 }
2105
2106 int
isp_send_entry(ispsoftc_t * isp,void * src)2107 isp_send_entry(ispsoftc_t *isp, void *src)
2108 {
2109 void *outp;
2110
2111 outp = isp_getrqentry(isp);
2112 if (outp == NULL) {
2113 isp_prt(isp, ISP_LOGWARN, "%s: Request Queue Overflow", __func__);
2114 return (-1);
2115 }
2116 isp_put_entry(isp, src, outp);
2117 if (isp->isp_dblev & ISP_LOGTDEBUG2)
2118 isp_print_qentry(isp, __func__, isp->isp_reqidx, outp);
2119 ISP_SYNC_REQUEST(isp);
2120 return (0);
2121 }
2122
2123 int
isp_exec_entry_mbox(ispsoftc_t * isp,void * src,void * dst,int timeout)2124 isp_exec_entry_mbox(ispsoftc_t *isp, void *src, void *dst, int timeout)
2125 {
2126 mbreg_t mbs;
2127
2128 isp_put_entry(isp, src, isp->isp_iocb);
2129 MEMORYBARRIER(isp, SYNC_IFORDEV, 0, 2 * QENTRY_LEN, 0);
2130
2131 MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
2132 MBCMD_DEFAULT_TIMEOUT + timeout * 1000000);
2133 mbs.param[1] = QENTRY_LEN;
2134 mbs.param[2] = DMA_WD1(isp->isp_iocb_dma);
2135 mbs.param[3] = DMA_WD0(isp->isp_iocb_dma);
2136 mbs.param[6] = DMA_WD3(isp->isp_iocb_dma);
2137 mbs.param[7] = DMA_WD2(isp->isp_iocb_dma);
2138 isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
2139 if (mbs.param[0] != MBOX_COMMAND_COMPLETE)
2140 return (EIO);
2141
2142 MEMORYBARRIER(isp, SYNC_IFORCPU, QENTRY_LEN, QENTRY_LEN, 0);
2143 isp_get_entry(isp, &((isp24xx_statusreq_t *)isp->isp_iocb)[1], dst);
2144 return (0);
2145 }
2146
2147 int
isp_exec_entry_queue(ispsoftc_t * isp,void * src,void * dst,int timeout)2148 isp_exec_entry_queue(ispsoftc_t *isp, void *src, void *dst, int timeout)
2149 {
2150 uint8_t resp[QENTRY_LEN];
2151 uint32_t hdl;
2152
2153 timeout *= hz;
2154 again:
2155 /* Wait for empty request queue slot. */
2156 while (!isp_rqentry_avail(isp, QENTRY_MAX) && timeout-- > 0)
2157 msleep(resp, &isp->isp_lock, 0, "isprqa", 1);
2158 if (timeout <= 0)
2159 return (ENOMEM);
2160
2161 /* Allocate handle. Should always be available, but stay safe. */
2162 hdl = isp_allocate_handle(isp, resp, ISP_HANDLE_CTRL);
2163 if (hdl == 0) {
2164 if (timeout-- > 0) {
2165 msleep(resp, &isp->isp_lock, 0, "ispha", 1);
2166 goto again;
2167 }
2168 return (ENOMEM);
2169 }
2170 ((uint32_t *)src)[1] = hdl;
2171
2172 /* Execute the request and wait for response. */
2173 isp_send_entry(isp, src);
2174 if (msleep(resp, &isp->isp_lock, 0, "ispeeq", timeout) != 0) {
2175 isp_destroy_handle(isp, hdl);
2176 return (EWOULDBLOCK);
2177 }
2178 isp_get_entry(isp, resp, dst);
2179 return (0);
2180 }
2181
2182 /*
2183 * vim:ts=8:sw=8
2184 */
2185