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