Lines Matching +full:test2 +full:. +full:good
4 * Copyright (c) 2008, 2009 Silicon Graphics International Corp.
5 * Copyright (c) 2014-2015 Alexander Motin <mav@FreeBSD.org>
6 * All rights reserved.
11 * 1. Redistributions of source code must retain the above copyright
13 * without modification.
14 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * binary redistribution.
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * POSSIBILITY OF SUCH DAMAGES.
33 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/scsi_ctl.c#4 $
36 * Peripheral driver interface between CAM and CTL (CAM Target Layer).
38 * Author: Ken Merry <ken@FreeBSD.org>
41 #include <sys/cdefs.h>
44 #include <sys/param.h>
45 #include <sys/queue.h>
46 #include <sys/systm.h>
47 #include <sys/kernel.h>
48 #include <sys/lock.h>
49 #include <sys/mutex.h>
50 #include <sys/condvar.h>
51 #include <sys/malloc.h>
52 #include <sys/bus.h>
53 #include <sys/endian.h>
54 #include <sys/sbuf.h>
55 #include <sys/sysctl.h>
56 #include <sys/types.h>
57 #include <sys/systm.h>
58 #include <sys/taskqueue.h>
59 #include <machine/bus.h>
61 #include <cam/cam.h>
62 #include <cam/cam_ccb.h>
63 #include <cam/cam_periph.h>
64 #include <cam/cam_queue.h>
65 #include <cam/cam_xpt_periph.h>
66 #include <cam/cam_debug.h>
67 #include <cam/cam_sim.h>
68 #include <cam/cam_xpt.h>
70 #include <cam/scsi/scsi_all.h>
71 #include <cam/scsi/scsi_message.h>
73 #include <cam/ctl/ctl_io.h>
74 #include <cam/ctl/ctl.h>
75 #include <cam/ctl/ctl_frontend.h>
76 #include <cam/ctl/ctl_util.h>
77 #include <cam/ctl/ctl_error.h>
111 LIST_HEAD(, ccb_hdr) atio_list; /* List of ATIOs queued to SIM. */
112 LIST_HEAD(, ccb_hdr) inot_list; /* List of INOTs queued to SIM. */
127 * bytes on amd64. So with 32 elements, this is 256 bytes on
128 * i386 and 512 bytes on amd64.
136 * allocated. This should be the maximum supported by the adapter, but we
137 * currently don't have a way to get that back from the path inquiry.
138 * XXX KDM add that to the path inquiry.
143 * adapter per LUN.
148 * Number of Immediate Notify CCBs (used for aborts, resets, etc.) to
149 * allocate and queue down to the adapter per LUN.
160 * Turn this on to enable extra debugging prints.
173 #define PRIV_CCB(io) ((io)->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptrs[0])
174 #define PRIV_INFO(io) ((io)->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptrs[1])
207 TAILQ_HEAD_INITIALIZER(ctlfe_driver.units), /*generation*/ 0,
214 .name = "camtgt",
215 .init = ctlfeinitialize,
216 .fe_dump = ctlfe_dump,
217 .shutdown = ctlfeshutdown,
260 /* XXX: It would be good to tear down active ports here. */ in ctlfeperiphdeinit()
261 if (!TAILQ_EMPTY(&ctlfe_driver.units)) in ctlfeperiphdeinit()
285 * mode, go ahead and attach. Later on, we may need to be more in ctlfeasync()
286 * selective, but for now this will be sufficient. in ctlfeasync()
315 * use M_NOWAIT. Of course this means trouble if we in ctlfeasync()
316 * can't allocate memory. in ctlfeasync()
325 softc->path_id = cpi->ccb_h.path_id; in ctlfeasync()
355 * frontend structure itself. in ctlfeasync()
437 "remove", softc->port.targ_port, in ctlfeasync()
473 /* Increase device openings to maximum for the SIM. */ in ctlferegister()
483 xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); in ctlferegister()
484 ccb.ccb_h.func_code = XPT_EN_LUN; in ctlferegister()
485 ccb.cel.grp6_len = 0; in ctlferegister()
486 ccb.cel.grp7_len = 0; in ctlferegister()
487 ccb.cel.enable = 1; in ctlferegister()
489 status = (ccb.ccb_h.status & CAM_STATUS_MASK); in ctlferegister()
492 __func__, ccb.ccb_h.status); in ctlferegister()
509 new_io = ctl_alloc_io_nowait(bus_softc->port.ctl_pool_ref); in ctlferegister()
525 new_ccb->ccb_h.io_ptr = new_io; in ctlferegister()
526 LIST_INSERT_HEAD(&softc->atio_list, &new_ccb->ccb_h, periph_links.le); in ctlferegister()
529 new_ccb->ccb_h.func_code = XPT_ACCEPT_TARGET_IO; in ctlferegister()
530 new_ccb->ccb_h.cbfcnp = ctlfedone; in ctlferegister()
531 new_ccb->ccb_h.flags |= CAM_UNLOCKED; in ctlferegister()
533 status = new_ccb->ccb_h.status; in ctlferegister()
565 new_io = ctl_alloc_io_nowait(bus_softc->port.ctl_pool_ref); in ctlferegister()
572 new_ccb->ccb_h.io_ptr = new_io; in ctlferegister()
573 LIST_INSERT_HEAD(&softc->inot_list, &new_ccb->ccb_h, periph_links.le); in ctlferegister()
576 new_ccb->ccb_h.func_code = XPT_IMMEDIATE_NOTIFY; in ctlferegister()
577 new_ccb->ccb_h.cbfcnp = ctlfedone; in ctlferegister()
578 new_ccb->ccb_h.flags |= CAM_UNLOCKED; in ctlferegister()
580 status = new_ccb->ccb_h.status; in ctlferegister()
583 * Note that we don't free the CCB here. If the in ctlferegister()
587 * XPT_IMMEDIATE_NOTIFY CCB. i.e. it supports the in ctlferegister()
588 * older API. In that case, it'll call xpt_done() in ctlferegister()
590 * routine as a result. in ctlferegister()
616 /* Abort all ATIOs and INOTs queued to SIM. */ in ctlfeoninvalidate()
617 xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); in ctlfeoninvalidate()
618 ccb.ccb_h.func_code = XPT_ABORT; in ctlfeoninvalidate()
619 LIST_FOREACH(hdr, &softc->atio_list, periph_links.le) { in ctlfeoninvalidate()
620 ccb.cab.abort_ccb = (union ccb *)hdr; in ctlfeoninvalidate()
623 LIST_FOREACH(hdr, &softc->inot_list, periph_links.le) { in ctlfeoninvalidate()
624 ccb.cab.abort_ccb = (union ccb *)hdr; in ctlfeoninvalidate()
628 /* Disable the LUN in SIM. */ in ctlfeoninvalidate()
629 ccb.ccb_h.func_code = XPT_EN_LUN; in ctlfeoninvalidate()
630 ccb.cel.grp6_len = 0; in ctlfeoninvalidate()
631 ccb.cel.grp7_len = 0; in ctlfeoninvalidate()
632 ccb.cel.enable = 0; in ctlfeoninvalidate()
634 status = (ccb.ccb_h.status & CAM_STATUS_MASK); in ctlfeoninvalidate()
637 __func__, ccb.ccb_h.status); in ctlfeoninvalidate()
684 * Set the direction, relative to the initiator. in ctlfedata()
687 if ((io->io_hdr.flags & CTL_FLAG_DATA_MASK) == CTL_FLAG_DATA_IN) in ctlfedata()
696 if (io->scsiio.kern_sg_entries == 0) { /* No S/G list. */ in ctlfedata()
698 /* One time shift for SRR offset. */ in ctlfedata()
699 off += io->scsiio.ext_data_filled; in ctlfedata()
700 io->scsiio.ext_data_filled = 0; in ctlfedata()
702 *data_ptr = io->scsiio.kern_data_ptr + off; in ctlfedata()
703 if (io->scsiio.kern_data_len - off <= bus_softc->maxio) { in ctlfedata()
704 *dxfer_len = io->scsiio.kern_data_len - off; in ctlfedata()
712 if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR) in ctlfedata()
716 } else { /* S/G list with physical or virtual pointers. */ in ctlfedata()
717 ctl_sglist = (struct ctl_sg_entry *)io->scsiio.kern_data_ptr; in ctlfedata()
719 /* One time shift for SRR offset. */ in ctlfedata()
720 while (io->scsiio.ext_data_filled >= ctl_sglist[idx].len - off) { in ctlfedata()
721 io->scsiio.ext_data_filled -= ctl_sglist[idx].len - off; in ctlfedata()
725 off += io->scsiio.ext_data_filled; in ctlfedata()
726 io->scsiio.ext_data_filled = 0; in ctlfedata()
730 for (i = 0; i < io->scsiio.kern_sg_entries - idx; i++) { in ctlfedata()
731 cam_sglist[i].ds_addr = (bus_addr_t)(uintptr_t)ctl_sglist[i + idx].addr + off; in ctlfedata()
732 if (ctl_sglist[i + idx].len - off <= bus_softc->maxio - *dxfer_len) { in ctlfedata()
733 cam_sglist[i].ds_len = ctl_sglist[idx + i].len - off; in ctlfedata()
734 *dxfer_len += cam_sglist[i].ds_len; in ctlfedata()
736 cam_sglist[i].ds_len = bus_softc->maxio - *dxfer_len; in ctlfedata()
738 cmd_info->cur_transfer_off = cam_sglist[i].ds_len + off; in ctlfedata()
740 *dxfer_len += cam_sglist[i].ds_len; in ctlfedata()
741 if (ctl_sglist[i].len != 0) in ctlfedata()
746 idx + i < (io->scsiio.kern_sg_entries - 1)) { in ctlfedata()
756 if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR) in ctlfedata()
787 STAILQ_REMOVE_HEAD(&softc->work_queue, periph_links.stqe); in ctlfestart()
792 flags = atio->ccb_h.flags & in ctlfestart()
799 if (io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) { in ctlfestart()
801 * Datamove call, we need to setup the S/G list. in ctlfestart()
807 * We're done, send status back. in ctlfestart()
809 if ((io->io_hdr.flags & CTL_FLAG_ABORT) && in ctlfestart()
810 (io->io_hdr.flags & CTL_FLAG_ABORT_STATUS) == 0) { in ctlfestart()
811 io->io_hdr.flags &= ~CTL_FLAG_STATUS_QUEUED; in ctlfestart()
817 KASSERT(atio->ccb_h.func_code == XPT_ACCEPT_TARGET_IO, in ctlfestart()
818 ("func_code %#x is not ATIO", atio->ccb_h.func_code)); in ctlfestart()
819 start_ccb->ccb_h.func_code = XPT_ABORT; in ctlfestart()
820 start_ccb->cab.abort_ccb = (union ccb *)atio; in ctlfestart()
826 /* XPT_ABORT is not queued, so we can take next I/O. */ in ctlfestart()
834 if ((io->io_hdr.flags & CTL_FLAG_STATUS_QUEUED) && in ctlfestart()
836 ((io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) == 0 || in ctlfestart()
837 io->io_hdr.status == CTL_SUCCESS)) { in ctlfestart()
839 scsi_status = io->scsiio.scsi_status; in ctlfestart()
840 csio->sense_len = io->scsiio.sense_len; in ctlfestart()
843 atio->tag_id, io->io_hdr.status); in ctlfestart()
846 csio->sense_data = io->scsiio.sense_data; in ctlfestart()
882 atio->tag_id, io->io_hdr.status); in ctlfestart()
896 start_ccb->ccb_h.flags |= CAM_UNLOCKED; in ctlfestart()
897 start_ccb->ccb_h.ccb_atio = atio; in ctlfestart()
898 if (io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) in ctlfestart()
899 io->io_hdr.flags |= CTL_FLAG_DMA_INPROG; in ctlfestart()
900 io->io_hdr.flags &= ~(CTL_FLAG_DMA_QUEUED | CTL_FLAG_STATUS_QUEUED); in ctlfestart()
910 * If we still have work to do, ask for another CCB. in ctlfestart()
939 io = ccb->ccb_h.io_ptr; in ctlfe_free_ccb()
941 switch (ccb->ccb_h.func_code) { in ctlfe_free_ccb()
965 * reference on the peripheral driver. It will probably go away in ctlfe_free_ccb()
966 * now. in ctlfe_free_ccb()
980 * Send the ATIO/INOT back to the SIM, or free it if periph was invalidated.
996 if (ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) in ctlfe_requeue_ccb()
997 LIST_INSERT_HEAD(&softc->atio_list, &ccb->ccb_h, periph_links.le); in ctlfe_requeue_ccb()
999 LIST_INSERT_HEAD(&softc->inot_list, &ccb->ccb_h, periph_links.le); in ctlfe_requeue_ccb()
1005 * target/lun. Reset the target and LUN fields back to the wildcard in ctlfe_requeue_ccb()
1006 * values before we send them back down to the SIM. in ctlfe_requeue_ccb()
1009 ccb->ccb_h.flags); in ctlfe_requeue_ccb()
1092 KASSERT((done_ccb->ccb_h.flags & CAM_UNLOCKED) != 0, in ctlfedone()
1096 done_ccb->ccb_h.func_code); in ctlfedone()
1100 * At this point CTL has no known use case for device queue freezes. in ctlfedone()
1101 * In case some SIM think different -- drop its freeze right here. in ctlfedone()
1103 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { in ctlfedone()
1109 done_ccb->ccb_h.status &= ~CAM_DEV_QFRZN; in ctlfedone()
1117 switch (done_ccb->ccb_h.func_code) { in ctlfedone()
1120 LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); in ctlfedone()
1122 status = atio->ccb_h.status & CAM_STATUS_MASK; in ctlfedone()
1131 * datamove or done. in ctlfedone()
1134 io = done_ccb->ccb_h.io_ptr; in ctlfedone()
1141 done_ccb->ccb_h.io_ptr = io; in ctlfedone()
1144 * Only SCSI I/O comes down this path, resets, etc. come in ctlfedone()
1145 * down the immediate notify path below. in ctlfedone()
1147 io->io_hdr.io_type = CTL_IO_SCSI; in ctlfedone()
1148 io->io_hdr.nexus.initid = atio->init_id; in ctlfedone()
1149 io->io_hdr.nexus.targ_port = bus_softc->port.targ_port; in ctlfedone()
1151 io->io_hdr.nexus.targ_lun = ctl_decode_lun( in ctlfedone()
1152 CAM_EXTLUN_BYTE_SWIZZLE(atio->ccb_h.target_lun)); in ctlfedone()
1154 io->io_hdr.nexus.targ_lun = atio->ccb_h.target_lun; in ctlfedone()
1156 io->scsiio.tag_num = atio->tag_id; in ctlfedone()
1159 io->scsiio.tag_type = CTL_TAG_UNTAGGED; in ctlfedone()
1162 io->scsiio.tag_type = CTL_TAG_SIMPLE; in ctlfedone()
1165 io->scsiio.tag_type = CTL_TAG_HEAD_OF_QUEUE; in ctlfedone()
1168 io->scsiio.tag_type = CTL_TAG_ORDERED; in ctlfedone()
1171 io->scsiio.tag_type = CTL_TAG_ACA; in ctlfedone()
1174 io->scsiio.tag_type = CTL_TAG_UNTAGGED; in ctlfedone()
1179 if (atio->cdb_len > sizeof(io->scsiio.cdb)) { in ctlfedone()
1181 __func__, atio->cdb_len, sizeof(io->scsiio.cdb)); in ctlfedone()
1183 io->scsiio.cdb_len = min(atio->cdb_len, sizeof(io->scsiio.cdb)); in ctlfedone()
1184 bcopy(atio_cdb_ptr(atio), io->scsiio.cdb, io->scsiio.cdb_len); in ctlfedone()
1188 io->io_hdr.nexus.initid, in ctlfedone()
1189 io->io_hdr.nexus.targ_port, in ctlfedone()
1190 io->io_hdr.nexus.targ_lun, in ctlfedone()
1191 io->scsiio.tag_num, io->scsiio.cdb[0]); in ctlfedone()
1201 atio = (struct ccb_accept_tio *)done_ccb->ccb_h.ccb_atio; in ctlfedone()
1202 io = (union ctl_io *)atio->ccb_h.io_ptr; in ctlfedone()
1207 __func__, atio->tag_id, done_ccb->ccb_h.flags); in ctlfedone()
1212 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_MESSAGE_RECV in ctlfedone()
1213 && done_ccb->csio.msg_ptr != NULL in ctlfedone()
1214 && done_ccb->csio.msg_ptr[0] == MSG_EXTENDED in ctlfedone()
1215 && done_ccb->csio.msg_ptr[1] == 5 in ctlfedone()
1216 && done_ccb->csio.msg_ptr[2] == 0) { in ctlfedone()
1219 (done_ccb->csio.msg_ptr[3] << 24) in ctlfedone()
1220 | (done_ccb->csio.msg_ptr[4] << 16) in ctlfedone()
1221 | (done_ccb->csio.msg_ptr[5] << 8) in ctlfedone()
1222 | (done_ccb->csio.msg_ptr[6]); in ctlfedone()
1227 * should be able to adjust offsets and cycle again. in ctlfedone()
1228 * It is possible only if offset is from this datamove. in ctlfedone()
1230 if (srr && (io->io_hdr.flags & CTL_FLAG_DMA_INPROG) && in ctlfedone()
1231 srr_off >= io->scsiio.kern_rel_offset && in ctlfedone()
1232 srr_off < io->scsiio.kern_rel_offset + in ctlfedone()
1233 io->scsiio.kern_data_len) { in ctlfedone()
1234 io->scsiio.kern_data_resid = in ctlfedone()
1235 io->scsiio.kern_rel_offset + in ctlfedone()
1236 io->scsiio.kern_data_len - srr_off; in ctlfedone()
1237 io->scsiio.ext_data_filled = srr_off; in ctlfedone()
1238 io->scsiio.io_hdr.status = CTL_STATUS_NONE; in ctlfedone()
1239 io->io_hdr.flags |= CTL_FLAG_DMA_QUEUED; in ctlfedone()
1242 periph_links.stqe); in ctlfedone()
1248 * If status was being sent, the back end data is now history. in ctlfedone()
1249 * Hack it up and resubmit a new command with the CDB adjusted. in ctlfedone()
1251 * should work. in ctlfedone()
1253 if (srr && (io->io_hdr.flags & CTL_FLAG_DMA_INPROG) == 0) { in ctlfedone()
1260 * Fall through to doom.... in ctlfedone()
1264 if ((done_ccb->ccb_h.flags & CAM_SEND_STATUS) && in ctlfedone()
1265 (done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) in ctlfedone()
1266 io->io_hdr.flags |= CTL_FLAG_STATUS_SENT; in ctlfedone()
1270 * resources. If we were doing a datamove, call the in ctlfedone()
1271 * datamove done routine. in ctlfedone()
1273 if ((io->io_hdr.flags & CTL_FLAG_DMA_INPROG) == 0) { in ctlfedone()
1276 * queue the I/O back to CTL for later REQUEST SENSE. in ctlfedone()
1278 if ((done_ccb->ccb_h.flags & CAM_SEND_SENSE) != 0 && in ctlfedone()
1279 (done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP && in ctlfedone()
1280 (done_ccb->ccb_h.status & CAM_SENT_SENSE) == 0 && in ctlfedone()
1281 (io = ctl_alloc_io_nowait(bus_softc->port.ctl_pool_ref)) != NULL) { in ctlfedone()
1283 (union ctl_io *)atio->ccb_h.io_ptr); in ctlfedone()
1284 ctl_queue_sense(atio->ccb_h.io_ptr); in ctlfedone()
1285 atio->ccb_h.io_ptr = io; in ctlfedone()
1288 /* Abort ATIO if CTIO sending status has failed. */ in ctlfedone()
1289 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != in ctlfedone()
1291 done_ccb->ccb_h.func_code = XPT_ABORT; in ctlfedone()
1292 done_ccb->cab.abort_ccb = (union ccb *)atio; in ctlfedone()
1307 io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG; in ctlfedone()
1310 * Translate CAM status to CTL status. Success in ctlfedone()
1311 * does not change the overall, ctl_io status. In in ctlfedone()
1312 * that case we just set port_status to 0. If we in ctlfedone()
1314 * for the overall ctl_io. in ctlfedone()
1316 switch (done_ccb->ccb_h.status & CAM_STATUS_MASK) { in ctlfedone()
1318 io->scsiio.kern_data_resid -= in ctlfedone()
1320 io->io_hdr.port_status = 0; in ctlfedone()
1327 * data transfer failure. A data phase in ctlfedone()
1329 * data transfer error of some sort. in ctlfedone()
1332 * a clue what happened. in ctlfedone()
1334 io->io_hdr.port_status = 0xbad1; in ctlfedone()
1337 * XXX KDM figure out residual. in ctlfedone()
1344 * continue sending pieces if necessary. in ctlfedone()
1347 io->io_hdr.port_status == 0 && csio->resid == 0) { in ctlfedone()
1352 flags = atio->ccb_h.flags & in ctlfedone()
1367 io->io_hdr.status); in ctlfedone()
1383 csio->ccb_h.flags |= CAM_UNLOCKED; in ctlfedone()
1385 csio->ccb_h.ccb_atio = atio; in ctlfedone()
1386 io->io_hdr.flags |= CTL_FLAG_DMA_INPROG; in ctlfedone()
1392 * Release the CTIO. The ATIO will be sent back in ctlfedone()
1393 * down to the SIM once we send status. in ctlfedone()
1399 io->scsiio.be_move_done(io); in ctlfedone()
1410 LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); in ctlfedone()
1412 io = done_ccb->ccb_h.io_ptr; in ctlfedone()
1417 io->io_hdr.io_type = CTL_IO_TASK; in ctlfedone()
1419 inot->ccb_h.io_ptr = io; in ctlfedone()
1420 io->io_hdr.nexus.initid = inot->initiator_id; in ctlfedone()
1421 io->io_hdr.nexus.targ_port = bus_softc->port.targ_port; in ctlfedone()
1423 io->io_hdr.nexus.targ_lun = ctl_decode_lun( in ctlfedone()
1424 CAM_EXTLUN_BYTE_SWIZZLE(inot->ccb_h.target_lun)); in ctlfedone()
1426 io->io_hdr.nexus.targ_lun = inot->ccb_h.target_lun; in ctlfedone()
1429 io->taskio.tag_num = inot->seq_id; in ctlfedone()
1431 status = inot->ccb_h.status & CAM_STATUS_MASK; in ctlfedone()
1434 io->taskio.task_action = CTL_TASK_BUS_RESET; in ctlfedone()
1437 io->taskio.task_action = CTL_TASK_TARGET_RESET; in ctlfedone()
1442 io->taskio.task_action = in ctlfedone()
1446 io->taskio.task_action = CTL_TASK_TARGET_RESET; in ctlfedone()
1449 io->taskio.task_action = CTL_TASK_ABORT_TASK; in ctlfedone()
1452 io->taskio.task_action = CTL_TASK_LUN_RESET; in ctlfedone()
1455 io->taskio.task_action = in ctlfedone()
1459 io->taskio.task_action = CTL_TASK_CLEAR_ACA; in ctlfedone()
1462 io->taskio.task_action = CTL_TASK_QUERY_TASK; in ctlfedone()
1465 io->taskio.task_action = in ctlfedone()
1469 io->taskio.task_action = in ctlfedone()
1498 done_ccb->ccb_h.status = CAM_REQ_INPROG; in ctlfedone()
1499 done_ccb->ccb_h.func_code = XPT_NOTIFY_ACKNOWLEDGE; in ctlfedone()
1505 /* Queue this back down to the SIM as an immediate notify. */ in ctlfedone()
1506 done_ccb->ccb_h.status = CAM_REQ_INPROG; in ctlfedone()
1507 done_ccb->ccb_h.func_code = XPT_IMMEDIATE_NOTIFY; in ctlfedone()
1516 done_ccb->ccb_h.func_code); in ctlfedone()
1541 ccb->ccb_h.func_code = XPT_GET_SIM_KNOB; in ctlfe_onoffline()
1544 /* Check whether we should change WWNs. */ in ctlfe_onoffline()
1546 if ((ccb->knob.xport_specific.valid & KNOB_VALID_ADDRESS) != 0){ in ctlfe_onoffline()
1549 ccb->knob.xport_specific.fc.wwnn); in ctlfe_onoffline()
1552 ccb->knob.xport_specific.fc.wwpn); in ctlfe_onoffline()
1556 * down to the SIM. Otherwise, record what the SIM in ctlfe_onoffline()
1557 * has reported. in ctlfe_onoffline()
1559 if (bus_softc->port.wwnn != 0 && bus_softc->port.wwnn in ctlfe_onoffline()
1560 != ccb->knob.xport_specific.fc.wwnn) { in ctlfe_onoffline()
1561 ccb->knob.xport_specific.fc.wwnn = in ctlfe_onoffline()
1562 bus_softc->port.wwnn; in ctlfe_onoffline()
1566 true, ccb->knob.xport_specific.fc.wwnn, in ctlfe_onoffline()
1569 if (bus_softc->port.wwpn != 0 && bus_softc->port.wwpn in ctlfe_onoffline()
1570 != ccb->knob.xport_specific.fc.wwpn) { in ctlfe_onoffline()
1571 ccb->knob.xport_specific.fc.wwpn = in ctlfe_onoffline()
1572 bus_softc->port.wwpn; in ctlfe_onoffline()
1577 true, ccb->knob.xport_specific.fc.wwpn); in ctlfe_onoffline()
1582 if (bus_softc->port.wwnn != 0) { in ctlfe_onoffline()
1583 ccb->knob.xport_specific.fc.wwnn = in ctlfe_onoffline()
1584 bus_softc->port.wwnn; in ctlfe_onoffline()
1587 if (bus_softc->port.wwpn != 0) { in ctlfe_onoffline()
1588 ccb->knob.xport_specific.fc.wwpn = in ctlfe_onoffline()
1589 bus_softc->port.wwpn; in ctlfe_onoffline()
1595 ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; in ctlfe_onoffline()
1596 ccb->knob.xport_specific.valid = KNOB_VALID_ADDRESS; in ctlfe_onoffline()
1598 if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { in ctlfe_onoffline()
1601 ccb->ccb_h.status); in ctlfe_onoffline()
1605 ccb->knob.xport_specific.fc.wwnn); in ctlfe_onoffline()
1608 ccb->knob.xport_specific.fc.wwpn); in ctlfe_onoffline()
1612 /* Check whether we should change role. */ in ctlfe_onoffline()
1613 if ((ccb->knob.xport_specific.valid & KNOB_VALID_ROLE) == 0 || in ctlfe_onoffline()
1615 ((ccb->knob.xport_specific.fc.role & KNOB_ROLE_TARGET) != 0)) != 0) { in ctlfe_onoffline()
1616 ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; in ctlfe_onoffline()
1617 ccb->knob.xport_specific.valid = KNOB_VALID_ROLE; in ctlfe_onoffline()
1619 ccb->knob.xport_specific.fc.role |= KNOB_ROLE_TARGET; in ctlfe_onoffline()
1621 ccb->knob.xport_specific.fc.role &= ~KNOB_ROLE_TARGET; in ctlfe_onoffline()
1623 if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { in ctlfe_onoffline()
1626 online ? "enable" : "disable", ccb->ccb_h.status); in ctlfe_onoffline()
1650 * Create the wildcard LUN before bringing the port online. in ctlfe_online()
1666 /* We've already got a periph, no need to alloc a new one. */ in ctlfe_online()
1715 * the port offline. in ctlfe_offline()
1734 * CTL. So we only need to create a path/periph for this particular bus.
1762 /* We've already got a periph, no need to alloc a new one. */ in ctlfe_lun_enable()
1798 * on every bus that is attached to CTL.
1846 * Assumes that the SIM lock is held.
1856 xpt_setup_ccb(&cgds.ccb_h, periph->path, CAM_PRIORITY_NORMAL); in ctlfe_dump_queue()
1857 cgds.ccb_h.func_code = XPT_GDEV_STATS; in ctlfe_dump_queue()
1859 if ((cgds.ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in ctlfe_dump_queue()
1862 cgds.dev_openings, cgds.dev_active, cgds.allocated, in ctlfe_dump_queue()
1863 cgds.queued, cgds.held); in ctlfe_dump_queue()
1868 STAILQ_FOREACH(hdr, &softc->work_queue, periph_links.stqe) { in ctlfe_dump_queue()
1875 * queue, so we can print sense here. There may be no in ctlfe_dump_queue()
1877 * print out the CCB as well. in ctlfe_dump_queue()
1880 * CTL is merged in with CAM. in ctlfe_dump_queue()
1885 * Print DMA status if we are DMA_QUEUED. in ctlfe_dump_queue()
1887 if (io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) { in ctlfe_dump_queue()
1890 io->scsiio.kern_total_len, in ctlfe_dump_queue()
1891 io->scsiio.kern_data_len, in ctlfe_dump_queue()
1892 io->scsiio.kern_data_resid); in ctlfe_dump_queue()
1901 * Datamove/done routine called by CTL. Put ourselves on the queue to
1903 * to the adapter.
1912 KASSERT(io->io_hdr.io_type == CTL_IO_SCSI, in ctlfe_datamove()
1913 ("Unexpected io_type (%d) in ctlfe_datamove", io->io_hdr.io_type)); in ctlfe_datamove()
1915 io->scsiio.ext_data_filled = 0; in ctlfe_datamove()
1917 periph = xpt_path_periph(ccb->ccb_h.path); in ctlfe_datamove()
1920 io->io_hdr.flags |= CTL_FLAG_DMA_QUEUED; in ctlfe_datamove()
1921 if ((io->io_hdr.status & CTL_STATUS_MASK) != CTL_STATUS_NONE) in ctlfe_datamove()
1922 io->io_hdr.flags |= CTL_FLAG_STATUS_QUEUED; in ctlfe_datamove()
1924 periph_links.stqe); in ctlfe_datamove()
1937 periph = xpt_path_periph(ccb->ccb_h.path); in ctlfe_done()
1941 if (io->io_hdr.io_type == CTL_IO_TASK) { in ctlfe_done()
1944 * know we processed the task management command. in ctlfe_done()
1946 ccb->ccb_h.status = CAM_REQ_INPROG; in ctlfe_done()
1947 ccb->ccb_h.func_code = XPT_NOTIFY_ACKNOWLEDGE; in ctlfe_done()
1948 switch (io->taskio.task_status) { in ctlfe_done()
1950 ccb->cna2.arg = CAM_RSP_TMF_COMPLETE; in ctlfe_done()
1953 ccb->cna2.arg = CAM_RSP_TMF_SUCCEEDED; in ctlfe_done()
1954 ccb->ccb_h.flags |= CAM_SEND_STATUS; in ctlfe_done()
1957 ccb->cna2.arg = CAM_RSP_TMF_REJECTED; in ctlfe_done()
1958 ccb->ccb_h.flags |= CAM_SEND_STATUS; in ctlfe_done()
1961 ccb->cna2.arg = CAM_RSP_TMF_INCORRECT_LUN; in ctlfe_done()
1962 ccb->ccb_h.flags |= CAM_SEND_STATUS; in ctlfe_done()
1965 ccb->cna2.arg = CAM_RSP_TMF_FAILED; in ctlfe_done()
1966 ccb->ccb_h.flags |= CAM_SEND_STATUS; in ctlfe_done()
1969 ccb->cna2.arg |= scsi_3btoul(io->taskio.task_resp) << 8; in ctlfe_done()
1971 } else if (io->io_hdr.flags & CTL_FLAG_STATUS_SENT) { in ctlfe_done()
1975 io->io_hdr.flags |= CTL_FLAG_STATUS_QUEUED; in ctlfe_done()
1977 periph_links.stqe); in ctlfe_done()