2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2009-2020 Alexander Motin <mav@FreeBSD.org>
5 * Copyright (c) 1997-2009 by Matthew Jacob
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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
32 * Qlogic Host Adapter Internal Library Functions
35 #include <sys/cdefs.h>
36 __KERNEL_RCSID(0, "$NetBSD$");
37 #include <dev/ic/isp_netbsd.h>
40 #include <sys/cdefs.h>
41 #include <dev/isp/isp_freebsd.h>
44 #include <dev/ic/isp_openbsd.h>
47 #include "isp_linux.h"
50 #include "isp_solaris.h"
53 const char *isp_class3_roles[4] = {
54 "None", "Target", "Initiator", "Target/Initiator"
58 * Command shipping- finish off first queue entry and do dma mapping and additional segments as needed.
60 * Called with the first queue entry at least partially filled out.
63 isp_send_cmd(ispsoftc_t *isp, void *fqe, void *segp, uint32_t nsegs)
66 uint8_t type, nqe = 1;
67 uint32_t seg, seglim, nxt;
68 ispds64_t *dsp64 = NULL;
71 qe0 = isp_getrqentry(isp);
74 nxt = ISP_NXT_QENTRY(isp->isp_reqidx, RQUEST_QUEUE_LEN(isp));
75 type = ((isphdr_t *)fqe)->rqs_entry_type;
78 * If we have no data to transmit, just copy the first IOCB and start it up.
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.
89 dsp64 = &((ispreqt7_t *)fqe)->req_dataseg;
92 #ifdef ISP_TARGET_MODE
94 dsp64 = &((ct7_entry_t *)fqe)->rsp.m0.ds;
99 panic("%s: unsupported IOCB type 0x%x\n", __func__, type);
105 XS_GET_DMA64_SEG(dsp64++, segp, seg++);
108 * Second, start building additional continuation segments as needed.
110 while (seg < nsegs) {
111 if (!isp_rqentry_avail(isp, ++nqe))
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;
119 seglim = seg + ISP_CDSEG64;
123 XS_GET_DMA64_SEG(dsp64++, segp, seg++);
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",
132 nxt = ISP_NXT_QENTRY(nxt, RQUEST_QUEUE_LEN(isp));
136 ((isphdr_t *)fqe)->rqs_entry_count = nqe;
139 ((ispreqt7_t *)fqe)->req_seg_count = nsegs;
140 isp_put_request_t7(isp, fqe, qe0);
142 #ifdef ISP_TARGET_MODE
144 if (((ct7_entry_t *)fqe)->ct_flags & CT7_FLAG_MODE2) {
145 ((ct7_entry_t *)fqe)->ct_seg_count = 1;
147 ((ct7_entry_t *)fqe)->ct_seg_count = nsegs;
149 isp_put_ctio7(isp, fqe, qe0);
153 panic("%s: unsupported IOCB type 0x%x\n", __func__, type);
155 if (isp->isp_dblev & ISP_LOGDEBUG1) {
156 isp_print_bytes(isp, "first queue entry", QENTRY_LEN, qe0);
158 ISP_ADD_REQUEST(isp, nxt);
163 isp_allocate_handle(ispsoftc_t *isp, void *xs, int type)
167 hdp = isp->isp_xffree;
169 return (ISP_HANDLE_FREE);
170 isp->isp_xffree = hdp->cmd;
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);
179 isp_find_xs(ispsoftc_t *isp, uint32_t handle)
181 if (!ISP_VALID_HANDLE(isp, handle)) {
182 isp_prt(isp, ISP_LOGERR, "%s: bad handle 0x%x", __func__, handle);
185 return (isp->isp_xflist[(handle & ISP_HANDLE_CMD_MASK)].cmd);
189 isp_find_handle(ispsoftc_t *isp, void *xs)
191 uint32_t i, foundhdl = ISP_HANDLE_FREE;
194 for (i = 0; i < ISP_HANDLE_NUM(isp); i++) {
195 if (isp->isp_xflist[i].cmd != xs) {
198 foundhdl = isp->isp_xflist[i].handle;
206 isp_destroy_handle(ispsoftc_t *isp, uint32_t handle)
208 if (!ISP_VALID_HANDLE(isp, handle)) {
209 isp_prt(isp, ISP_LOGERR, "%s: bad handle 0x%x", __func__, handle);
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)];
217 #define TBA (4 * (((QENTRY_LEN >> 2) * 3) + 1) + 1)
219 isp_print_qentry(ispsoftc_t *isp, const char *msg, int idx, void *arg)
225 isp_prt(isp, ISP_LOGALL, "%s index %d=>", msg, idx);
226 for (buf[0] = 0, amt = i = 0; i < 4; i++) {
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);
232 isp_prt(isp, ISP_LOGALL, "%s", buf);
237 isp_print_bytes(ispsoftc_t *isp, const char *msg, int amt, void *arg)
244 isp_prt(isp, ISP_LOGALL, "%s:", msg);
250 for (j = 0; j < 16; j++) {
251 ISP_SNPRINTF(buf, 128, "%s %02x", buf, ptr[off++] & 0xff);
256 isp_prt(isp, ISP_LOGALL, "0x%08x:%s", to, buf);
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.
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.
270 * We assume we enter here with any locks held.
274 isp_fc_runstate(ispsoftc_t *isp, int chan, int tval)
276 fcparam *fcp = FCPARAM(isp, chan);
280 if (fcp->role == ISP_ROLE_NONE)
282 res = isp_control(isp, ISPCTL_FCLINK_TEST, chan, tval);
286 return (fcp->isp_loopstate);
287 res = isp_control(isp, ISPCTL_SCAN_LOOP, chan);
291 return (fcp->isp_loopstate);
292 res = isp_control(isp, ISPCTL_SCAN_FABRIC, chan);
296 return (fcp->isp_loopstate);
297 res = isp_control(isp, ISPCTL_PDB_SYNC, chan);
300 return (fcp->isp_loopstate);
304 * Fibre Channel Support routines
307 isp_dump_portdb(ispsoftc_t *isp, int chan)
309 fcparam *fcp = FCPARAM(isp, chan);
312 for (i = 0; i < MAX_FC_TARG; i++) {
313 char buf1[64], buf2[64];
314 const char *dbs[8] = {
324 fcportdb_t *lp = &fcp->portdb[i];
326 if (lp->state == FC_PORTDB_STATE_NIL) {
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));
338 isp_gen_role_str(char *buf, size_t len, uint16_t p3)
343 if (p3 & PRLI_WD3_ENHANCED_DISCOVERY) {
345 strlcat(buf, "EDisc", len);
347 if (p3 & PRLI_WD3_REC_SUPPORT) {
349 strlcat(buf, ",", len);
351 strlcat(buf, "REC", len);
353 if (p3 & PRLI_WD3_TASK_RETRY_IDENTIFICATION_REQUESTED) {
355 strlcat(buf, ",", len);
357 strlcat(buf, "RetryID", len);
359 if (p3 & PRLI_WD3_RETRY) {
361 strlcat(buf, ",", len);
363 strlcat(buf, "Retry", len);
365 if (p3 & PRLI_WD3_CONFIRMED_COMPLETION_ALLOWED) {
367 strlcat(buf, ",", len);
369 strlcat(buf, "CNFRM", len);
371 if (p3 & PRLI_WD3_DATA_OVERLAY_ALLOWED) {
373 strlcat(buf, ",", len);
375 strlcat(buf, "DOver", len);
377 if (p3 & PRLI_WD3_INITIATOR_FUNCTION) {
379 strlcat(buf, ",", len);
381 strlcat(buf, "INI", len);
383 if (p3 & PRLI_WD3_TARGET_FUNCTION) {
385 strlcat(buf, ",", len);
387 strlcat(buf, "TGT", len);
389 if (p3 & PRLI_WD3_READ_FCP_XFER_RDY_DISABLED) {
391 strlcat(buf, ",", len);
393 strlcat(buf, "RdXfrDis", len);
395 if (p3 & PRLI_WD3_WRITE_FCP_XFER_RDY_DISABLED) {
397 strlcat(buf, ",", len);
399 strlcat(buf, "XfrDis", len);
401 strlcat(buf, ")", len);
405 isp_fc_fw_statename(int 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 "?????";
421 isp_fc_loop_statename(int 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 "?????";
440 isp_fc_toponame(fcparam *fcp)
443 if (fcp->isp_loopstate < LOOP_HAVE_ADDR) {
444 return "Unavailable";
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 "?????";
457 isp_clear_commands(ispsoftc_t *isp)
461 #ifdef ISP_TARGET_MODE
465 for (tmp = 0; isp->isp_xflist && tmp < ISP_HANDLE_NUM(isp); tmp++) {
467 hdp = &isp->isp_xflist[tmp];
468 switch (ISP_H2HT(hdp->handle)) {
469 case ISP_HANDLE_INITIATOR: {
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);
478 #ifdef ISP_TARGET_MODE
479 case ISP_HANDLE_TARGET: {
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);
491 case ISP_HANDLE_CTRL:
492 ISP_MEMZERO(hdp->cmd, QENTRY_LEN);
494 isp_destroy_handle(isp, hdp->handle);
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;
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);
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.
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})
523 * The assumption is that swizzling and unswizzling is mostly done 'in place'
524 * (with a few exceptions for efficiency).
528 * Swizzle/Copy Functions
531 isp_put_hdr(ispsoftc_t *isp, isphdr_t *hpsrc, isphdr_t *hpdst)
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);
540 isp_get_hdr(ispsoftc_t *isp, isphdr_t *hpsrc, isphdr_t *hpdst)
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);
549 isp_get_response_type(ispsoftc_t *isp, isphdr_t *hp)
552 ISP_IOXGET_8(isp, &hp->rqs_entry_type, type);
557 isp_put_marker_24xx(ispsoftc_t *isp, isp_marker_24xx_t *src, isp_marker_24xx_t *dst)
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]);
571 for (i = 0; i < nitems(src->mrk_reserved3); i++) {
572 ISP_IOXPUT_8(isp, src->mrk_reserved3[i], &dst->mrk_reserved3[i]);
577 isp_put_request_t7(ispsoftc_t *isp, ispreqt7_t *src, ispreqt7_t *dst)
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++);
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++);
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);
612 isp_put_24xx_tmf(ispsoftc_t *isp, isp24xx_tmf_t *src, isp24xx_tmf_t *dst)
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]);
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++);
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]);
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]);
643 isp_put_24xx_abrt(ispsoftc_t *isp, isp24xx_abrt_t *src, isp24xx_abrt_t *dst)
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]);
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]);
664 isp_put_cont64_req(ispsoftc_t *isp, ispcontreq64_t *src, ispcontreq64_t *dst)
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);
676 isp_get_cont_response(ispsoftc_t *isp, ispstatus_cont_t *src, ispstatus_cont_t *dst)
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++);
689 isp_get_24xx_response(ispsoftc_t *isp, isp24xx_statusreq_t *src, isp24xx_statusreq_t *dst)
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]);
714 isp_get_24xx_abrt(ispsoftc_t *isp, isp24xx_abrt_t *src, isp24xx_abrt_t *dst)
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]);
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]);
735 isp_put_icb_2400(ispsoftc_t *isp, isp_icb_2400_t *src, isp_icb_2400_t *dst)
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]);
747 for (i = 0; i < 8; i++) {
748 ISP_IOXPUT_8(isp, src->icb_nodename[i], &dst->icb_nodename[i]);
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]);
761 for (i = 0; i < 4; i++) {
762 ISP_IOXPUT_16(isp, src->icb_respaddr[i], &dst->icb_respaddr[i]);
764 for (i = 0; i < 4; i++) {
765 ISP_IOXPUT_16(isp, src->icb_priaddr[i], &dst->icb_priaddr[i]);
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]);
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]);
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]);
793 isp_put_icb_2400_vpinfo(ispsoftc_t *isp, isp_icb_2400_vpinfo_t *src, isp_icb_2400_vpinfo_t *dst)
795 ISP_IOXPUT_16(isp, src->vp_count, &dst->vp_count);
796 ISP_IOXPUT_16(isp, src->vp_global_options, &dst->vp_global_options);
800 isp_put_vp_port_info(ispsoftc_t *isp, vp_port_info_t *src, vp_port_info_t *dst)
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]);
809 for (i = 0; i < 8; i++) {
810 ISP_IOXPUT_8(isp, src->vp_port_nodename[i], &dst->vp_port_nodename[i]);
812 /* we never *put* portid_lo/portid_hi */
816 isp_get_vp_port_info(ispsoftc_t *isp, vp_port_info_t *src, vp_port_info_t *dst)
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]);
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]);
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);
833 isp_put_vp_ctrl_info(ispsoftc_t *isp, vp_ctrl_info_t *src, vp_ctrl_info_t *dst)
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]);
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]);
848 ISP_IOXPUT_16(isp, src->vp_ctrl_fcf_index, &dst->vp_ctrl_fcf_index);
852 isp_get_vp_ctrl_info(ispsoftc_t *isp, vp_ctrl_info_t *src, vp_ctrl_info_t *dst)
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]);
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]);
867 ISP_IOXGET_16(isp, &src->vp_ctrl_fcf_index, dst->vp_ctrl_fcf_index);
871 isp_put_vp_modify(ispsoftc_t *isp, vp_modify_t *src, vp_modify_t *dst)
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]);
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]);
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]);
899 isp_get_vp_modify(ispsoftc_t *isp, vp_modify_t *src, vp_modify_t *dst)
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]);
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]);
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]);
927 isp_get_pdb_24xx(ispsoftc_t *isp, isp_pdb_24xx_t *src, isp_pdb_24xx_t *dst)
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]);
936 for (i = 0; i < 4; i++) {
937 ISP_IOXGET_8(isp, &src->pdb_portid_bits[i], dst->pdb_portid_bits[i]);
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]);
948 for (i = 0; i < 8; i++) {
949 ISP_IOXGET_8(isp, &src->pdb_portname[i], dst->pdb_portname[i]);
951 for (i = 0; i < 24; i++) {
952 ISP_IOXGET_8(isp, &src->pdb_reserved1[i], dst->pdb_reserved1[i]);
957 isp_get_pnhle_24xx(ispsoftc_t *isp, isp_pnhle_24xx_t *src, isp_pnhle_24xx_t *dst)
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);
967 * PLOGI/LOGO IOCB canonicalization
971 isp_get_plogx(ispsoftc_t *isp, isp_plogx_t *src, isp_plogx_t *dst)
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);
989 isp_put_plogx(ispsoftc_t *isp, isp_plogx_t *src, isp_plogx_t *dst)
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);
1007 * Report ID canonicalization
1010 isp_get_ridacq(ispsoftc_t *isp, isp_ridacq_t *src, isp_ridacq_t *dst)
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]);
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]);
1032 * CT Passthru canonicalization
1035 isp_get_ct_pt(ispsoftc_t *isp, isp_ct_pt_t *src, isp_ct_pt_t *dst)
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]);
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);
1062 isp_put_ct_pt(ispsoftc_t *isp, isp_ct_pt_t *src, isp_ct_pt_t *dst)
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]);
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);
1089 isp_put_gid_ft_request(ispsoftc_t *isp, sns_gid_ft_req_t *src, sns_gid_ft_req_t *dst)
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);
1106 isp_get_gid_xx_response(ispsoftc_t *isp, sns_gid_xx_rsp_t *src, sns_gid_xx_rsp_t *dst, int nwords)
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]);
1118 if (dst->snscb_ports[i].control & 0x80)
1124 isp_get_gxn_id_response(ispsoftc_t *isp, sns_gxn_id_rsp_t *src, sns_gxn_id_rsp_t *dst)
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]);
1134 isp_get_gft_id_response(ispsoftc_t *isp, sns_gft_id_rsp_t *src, sns_gft_id_rsp_t *dst)
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]);
1146 isp_get_gff_id_response(ispsoftc_t *isp, sns_gff_id_rsp_t *src, sns_gff_id_rsp_t *dst)
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]);
1158 isp_get_ga_nxt_response(ispsoftc_t *isp, sns_ga_nxt_rsp_t *src, sns_ga_nxt_rsp_t *dst)
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]);
1166 for (i = 0; i < 8; i++) {
1167 ISP_IOZGET_8(isp, &src->snscb_portname[i], dst->snscb_portname[i]);
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]);
1173 for (i = 0; i < 8; i++) {
1174 ISP_IOZGET_8(isp, &src->snscb_nodename[i], dst->snscb_nodename[i]);
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]);
1180 for (i = 0; i < 8; i++) {
1181 ISP_IOZGET_8(isp, &src->snscb_ipassoc[i], dst->snscb_ipassoc[i]);
1183 for (i = 0; i < 16; i++) {
1184 ISP_IOZGET_8(isp, &src->snscb_ipaddr[i], dst->snscb_ipaddr[i]);
1186 for (i = 0; i < 4; i++) {
1187 ISP_IOZGET_8(isp, &src->snscb_svc_class[i], dst->snscb_svc_class[i]);
1189 for (i = 0; i < 32; i++) {
1190 ISP_IOZGET_8(isp, &src->snscb_fc4_types[i], dst->snscb_fc4_types[i]);
1192 for (i = 0; i < 8; i++) {
1193 ISP_IOZGET_8(isp, &src->snscb_fpname[i], dst->snscb_fpname[i]);
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]);
1202 * FC Structure Canonicalization
1206 isp_get_fc_hdr(ispsoftc_t *isp, fc_hdr_t *src, fc_hdr_t *dst)
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);
1229 isp_put_fc_hdr(ispsoftc_t *isp, fc_hdr_t *src, fc_hdr_t *dst)
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);
1252 isp_get_fcp_cmnd_iu(ispsoftc_t *isp, fcp_cmnd_iu_t *src, fcp_cmnd_iu_t *dst)
1256 for (i = 0; i < 8; i++) {
1257 ISP_IOZGET_8(isp, &src->fcp_cmnd_lun[i], dst->fcp_cmnd_lun[i]);
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]);
1266 ISP_IOZGET_32(isp, &src->cdb_dl.sf.fcp_cmnd_dl, dst->cdb_dl.sf.fcp_cmnd_dl);
1270 isp_put_rft_id(ispsoftc_t *isp, rft_id_t *src, rft_id_t *dst)
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]);
1278 for (i = 0; i < 8; i++) {
1279 ISP_IOZPUT_32(isp, src->rftid_fc4types[i], &dst->rftid_fc4types[i]);
1284 isp_put_rspn_id(ispsoftc_t *isp, rspn_id_t *src, rspn_id_t *dst)
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]);*/
1295 isp_put_rff_id(ispsoftc_t *isp, rff_id_t *src, rff_id_t *dst)
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);
1309 isp_put_rsnn_nn(ispsoftc_t *isp, rsnn_nn_t *src, rsnn_nn_t *dst)
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]);*/
1321 isp_get_ct_hdr(ispsoftc_t *isp, ct_hdr_t *src, ct_hdr_t *dst)
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);
1340 isp_put_ct_hdr(ispsoftc_t *isp, ct_hdr_t *src, ct_hdr_t *dst)
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);
1359 isp_put_fcp_rsp_iu(ispsoftc_t *isp, fcp_rsp_iu_t *src, fcp_rsp_iu_t *dst)
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]);
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);
1374 * Find port database entries
1377 isp_find_pdb_empty(ispsoftc_t *isp, int chan, fcportdb_t **lptr)
1379 fcparam *fcp = FCPARAM(isp, chan);
1382 for (i = 0; i < MAX_FC_TARG; i++) {
1383 fcportdb_t *lp = &fcp->portdb[i];
1385 if (lp->state == FC_PORTDB_STATE_NIL) {
1394 isp_find_pdb_by_wwpn(ispsoftc_t *isp, int chan, uint64_t wwpn, fcportdb_t **lptr)
1396 fcparam *fcp = FCPARAM(isp, chan);
1399 for (i = 0; i < MAX_FC_TARG; i++) {
1400 fcportdb_t *lp = &fcp->portdb[i];
1402 if (lp->state == FC_PORTDB_STATE_NIL)
1404 if (lp->port_wwn == wwpn) {
1413 isp_find_pdb_by_handle(ispsoftc_t *isp, int chan, uint16_t handle,
1416 fcparam *fcp = FCPARAM(isp, chan);
1419 for (i = 0; i < MAX_FC_TARG; i++) {
1420 fcportdb_t *lp = &fcp->portdb[i];
1422 if (lp->state == FC_PORTDB_STATE_NIL)
1424 if (lp->handle == handle) {
1433 isp_find_pdb_by_portid(ispsoftc_t *isp, int chan, uint32_t portid,
1436 fcparam *fcp = FCPARAM(isp, chan);
1439 for (i = 0; i < MAX_FC_TARG; i++) {
1440 fcportdb_t *lp = &fcp->portdb[i];
1442 if (lp->state == FC_PORTDB_STATE_NIL)
1444 if (lp->portid == portid) {
1452 #ifdef ISP_TARGET_MODE
1454 isp_find_chan_by_did(ispsoftc_t *isp, uint32_t did, uint16_t *cp)
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) {
1465 if (fcp->isp_portid == did) {
1473 * Add an initiator device to the port database
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)
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);
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.
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))) {
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,
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);
1518 lp->new_portid = s_id;
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);
1538 lp->port_wwn = wwpn;
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);
1556 lp->node_wwn = wwnn;
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;
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);
1578 lp->state = FC_PORTDB_STATE_VALID;
1580 isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp);
1581 lp->portid = lp->new_portid;
1582 lp->prli_word3 = lp->new_prli_word3;
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);
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)
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);
1609 /* Insert new record and mark it valid. */
1610 lp = &fcp->portdb[i];
1611 ISP_MEMZERO(lp, sizeof (fcportdb_t));
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;
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);
1624 /* Notify above levels about new port arrival. */
1625 isp_async(isp, ISPASYNC_DEV_ARRIVED, chan, lp);
1629 * Remove a target device to the port database
1632 isp_del_wwn_entry(ispsoftc_t *isp, int chan, uint64_t wwpn, uint16_t nphdl, uint32_t s_id)
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);
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);
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;
1652 /* Notify above levels about gone port. */
1653 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp);
1655 #endif /* ISP_TARGET_MODE */
1658 isp_get_atio7(ispsoftc_t *isp, at7_entry_t *src, at7_entry_t *dst)
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);
1669 isp_put_ctio7(ispsoftc_t *isp, ct7_entry_t *src, ct7_entry_t *dst)
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) {
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++);
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);
1719 isp_get_ctio7(ispsoftc_t *isp, ct7_entry_t *src, ct7_entry_t *dst)
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) {
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]);
1757 for (i = 0; i < (nitems(src->rsp.m1.ct_resp) >> 2); i++) {
1758 *b++ = ISP_SWAP32(isp, *a++);
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);
1771 isp_put_notify_24xx(ispsoftc_t *isp, in_fcentry_24xx_t *src, in_fcentry_24xx_t *dst)
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]);
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);
1807 isp_get_notify_24xx(ispsoftc_t *isp, in_fcentry_24xx_t *src, in_fcentry_24xx_t *dst)
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]);
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);
1843 isp_put_notify_ack_24xx(ispsoftc_t *isp, na_fcentry_24xx_t *src, na_fcentry_24xx_t *dst)
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]);
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]);
1873 ISP_IOXPUT_16(isp, src->na_oxid, &dst->na_oxid);
1877 isp_get_notify_ack_24xx(ispsoftc_t *isp, na_fcentry_24xx_t *src, na_fcentry_24xx_t *dst)
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]);
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]);
1907 ISP_IOXGET_16(isp, &src->na_oxid, dst->na_oxid);
1911 isp_get_abts(ispsoftc_t *isp, abts_t *src, abts_t *dst)
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]);
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]);
1941 ISP_IOXGET_32(isp, &src->abts_rxid_task, dst->abts_rxid_task);
1945 isp_put_abts_rsp(ispsoftc_t *isp, abts_rsp_t *src, abts_rsp_t *dst)
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]);
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]);
1991 for (i = 0; i < 16; i++) {
1992 ISP_IOXPUT_8(isp, src->abts_rsp_payload.reserved[i], &dst->abts_rsp_payload.reserved[i]);
1995 ISP_IOXPUT_32(isp, src->abts_rsp_rxid_task, &dst->abts_rsp_rxid_task);
1999 isp_get_abts_rsp(ispsoftc_t *isp, abts_rsp_t *src, abts_rsp_t *dst)
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]);
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);
2034 isp_put_entry(ispsoftc_t *isp, void *src, void *dst)
2036 uint8_t etype = ((isphdr_t *)src)->rqs_entry_type;
2039 case RQSTYPE_NOTIFY_ACK:
2040 isp_put_notify_ack_24xx(isp, (na_fcentry_24xx_t *)src,
2041 (na_fcentry_24xx_t *)dst);
2044 isp_put_ctio7(isp, (ct7_entry_t *)src, (ct7_entry_t *)dst);
2046 case RQSTYPE_TSK_MGMT:
2047 isp_put_24xx_tmf(isp, (isp24xx_tmf_t *)src, (isp24xx_tmf_t *)dst);
2049 case RQSTYPE_CT_PASSTHRU:
2050 isp_put_ct_pt(isp, (isp_ct_pt_t *)src, (isp_ct_pt_t *)dst);
2052 case RQSTYPE_VP_CTRL:
2053 isp_put_vp_ctrl_info(isp, (vp_ctrl_info_t *)src, (vp_ctrl_info_t *)dst);
2055 case RQSTYPE_VP_MODIFY:
2056 isp_put_vp_modify(isp, (vp_modify_t *)src, (vp_modify_t *)dst);
2058 case RQSTYPE_ABORT_IO:
2059 isp_put_24xx_abrt(isp, (isp24xx_abrt_t *)src, (isp24xx_abrt_t *)dst);
2062 isp_put_plogx(isp, (isp_plogx_t *)src, (isp_plogx_t *)dst);
2064 case RQSTYPE_ABTS_RSP:
2065 isp_put_abts_rsp(isp, (abts_rsp_t *)src, (abts_rsp_t *)dst);
2068 panic("%s: Unknown type 0x%x\n", __func__, etype);
2073 isp_get_entry(ispsoftc_t *isp, void *src, void *dst)
2077 isp_get_hdr(isp, src, (isphdr_t *)dst);
2078 etype = ((isphdr_t *)dst)->rqs_entry_type;
2080 case 0: /* After isp_clear_commands() */
2081 ISP_MEMZERO(dst, QENTRY_LEN);
2083 case RQSTYPE_RESPONSE:
2084 isp_get_24xx_response(isp, (isp24xx_statusreq_t *)src, (isp24xx_statusreq_t *)dst);
2086 case RQSTYPE_CT_PASSTHRU:
2087 isp_get_ct_pt(isp, (isp_ct_pt_t *)src, (isp_ct_pt_t *)dst);
2089 case RQSTYPE_VP_CTRL:
2090 isp_get_vp_ctrl_info(isp, (vp_ctrl_info_t *)src, (vp_ctrl_info_t *)dst);
2092 case RQSTYPE_VP_MODIFY:
2093 isp_get_vp_modify(isp, (vp_modify_t *)src, (vp_modify_t *)dst);
2095 case RQSTYPE_ABORT_IO:
2096 isp_get_24xx_abrt(isp, (isp24xx_abrt_t *)src, (isp24xx_abrt_t *)dst);
2099 isp_get_plogx(isp, (isp_plogx_t *)src, (isp_plogx_t *)dst);
2102 panic("%s: Unknown type 0x%x\n", __func__, etype);
2107 isp_send_entry(ispsoftc_t *isp, void *src)
2111 outp = isp_getrqentry(isp);
2113 isp_prt(isp, ISP_LOGWARN, "%s: Request Queue Overflow", __func__);
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);
2124 isp_exec_entry_mbox(ispsoftc_t *isp, void *src, void *dst, int timeout)
2128 isp_put_entry(isp, src, isp->isp_iocb);
2129 MEMORYBARRIER(isp, SYNC_IFORDEV, 0, 2 * QENTRY_LEN, 0);
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)
2142 MEMORYBARRIER(isp, SYNC_IFORCPU, QENTRY_LEN, QENTRY_LEN, 0);
2143 isp_get_entry(isp, &((isp24xx_statusreq_t *)isp->isp_iocb)[1], dst);
2148 isp_exec_entry_queue(ispsoftc_t *isp, void *src, void *dst, int timeout)
2150 uint8_t resp[QENTRY_LEN];
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);
2161 /* Allocate handle. Should always be available, but stay safe. */
2162 hdl = isp_allocate_handle(isp, resp, ISP_HANDLE_CTRL);
2164 if (timeout-- > 0) {
2165 msleep(resp, &isp->isp_lock, 0, "ispha", 1);
2170 ((uint32_t *)src)[1] = hdl;
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);
2178 isp_get_entry(isp, resp, dst);