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>
42 #include <sys/param.h>
43 #include <sys/queue.h>
44 #include <sys/systm.h>
45 #include <sys/kernel.h>
46 #include <sys/lock.h>
47 #include <sys/mutex.h>
48 #include <sys/condvar.h>
49 #include <sys/malloc.h>
50 #include <sys/bus.h>
51 #include <sys/endian.h>
52 #include <sys/sbuf.h>
53 #include <sys/sysctl.h>
54 #include <sys/types.h>
55 #include <sys/systm.h>
56 #include <sys/taskqueue.h>
57 #include <machine/bus.h>
59 #include <cam/cam.h>
60 #include <cam/cam_ccb.h>
61 #include <cam/cam_periph.h>
62 #include <cam/cam_queue.h>
63 #include <cam/cam_xpt_periph.h>
64 #include <cam/cam_debug.h>
65 #include <cam/cam_sim.h>
66 #include <cam/cam_xpt.h>
68 #include <cam/scsi/scsi_all.h>
69 #include <cam/scsi/scsi_message.h>
71 #include <cam/ctl/ctl_io.h>
72 #include <cam/ctl/ctl.h>
73 #include <cam/ctl/ctl_frontend.h>
74 #include <cam/ctl/ctl_util.h>
75 #include <cam/ctl/ctl_error.h>
109 LIST_HEAD(, ccb_hdr) atio_list; /* List of ATIOs queued to SIM. */
110 LIST_HEAD(, ccb_hdr) inot_list; /* List of INOTs queued to SIM. */
125 * bytes on amd64. So with 32 elements, this is 256 bytes on
126 * i386 and 512 bytes on amd64.
134 * allocated. This should be the maximum supported by the adapter, but we
135 * currently don't have a way to get that back from the path inquiry.
136 * XXX KDM add that to the path inquiry.
141 * adapter per LUN.
146 * Number of Immediate Notify CCBs (used for aborts, resets, etc.) to
147 * allocate and queue down to the adapter per LUN.
158 * Turn this on to enable extra debugging prints.
171 #define PRIV_CCB(io) ((io)->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptrs[0])
172 #define PRIV_INFO(io) ((io)->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptrs[1])
205 TAILQ_HEAD_INITIALIZER(ctlfe_driver.units), /*generation*/ 0,
212 .name = "camtgt",
213 .init = ctlfeinitialize,
214 .fe_dump = ctlfe_dump,
215 .shutdown = ctlfeshutdown,
258 /* XXX: It would be good to tear down active ports here. */ in ctlfeperiphdeinit()
259 if (!TAILQ_EMPTY(&ctlfe_driver.units)) in ctlfeperiphdeinit()
283 * mode, go ahead and attach. Later on, we may need to be more in ctlfeasync()
284 * selective, but for now this will be sufficient. in ctlfeasync()
313 * use M_NOWAIT. Of course this means trouble if we in ctlfeasync()
314 * can't allocate memory. in ctlfeasync()
323 softc->path_id = cpi->ccb_h.path_id; in ctlfeasync()
353 * frontend structure itself. in ctlfeasync()
434 "remove", softc->port.targ_port, in ctlfeasync()
470 /* Increase device openings to maximum for the SIM. */ in ctlferegister()
481 xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); in ctlferegister()
482 ccb.ccb_h.func_code = XPT_EN_LUN; in ctlferegister()
483 ccb.cel.grp6_len = 0; in ctlferegister()
484 ccb.cel.grp7_len = 0; in ctlferegister()
485 ccb.cel.enable = 1; in ctlferegister()
487 status = (ccb.ccb_h.status & CAM_STATUS_MASK); in ctlferegister()
490 __func__, ccb.ccb_h.status); in ctlferegister()
507 new_io = ctl_alloc_io_nowait(bus_softc->port.ctl_pool_ref); in ctlferegister()
523 new_ccb->ccb_h.io_ptr = new_io; in ctlferegister()
524 LIST_INSERT_HEAD(&softc->atio_list, &new_ccb->ccb_h, periph_links.le); in ctlferegister()
527 new_ccb->ccb_h.func_code = XPT_ACCEPT_TARGET_IO; in ctlferegister()
528 new_ccb->ccb_h.cbfcnp = ctlfedone; in ctlferegister()
529 new_ccb->ccb_h.flags |= CAM_UNLOCKED; in ctlferegister()
531 status = new_ccb->ccb_h.status; in ctlferegister()
563 new_io = ctl_alloc_io_nowait(bus_softc->port.ctl_pool_ref); in ctlferegister()
570 new_ccb->ccb_h.io_ptr = new_io; in ctlferegister()
571 LIST_INSERT_HEAD(&softc->inot_list, &new_ccb->ccb_h, periph_links.le); in ctlferegister()
574 new_ccb->ccb_h.func_code = XPT_IMMEDIATE_NOTIFY; in ctlferegister()
575 new_ccb->ccb_h.cbfcnp = ctlfedone; in ctlferegister()
576 new_ccb->ccb_h.flags |= CAM_UNLOCKED; in ctlferegister()
578 status = new_ccb->ccb_h.status; in ctlferegister()
581 * Note that we don't free the CCB here. If the in ctlferegister()
585 * XPT_IMMEDIATE_NOTIFY CCB. i.e. it supports the in ctlferegister()
586 * older API. In that case, it'll call xpt_done() in ctlferegister()
588 * routine as a result. in ctlferegister()
614 /* Abort all ATIOs and INOTs queued to SIM. */ in ctlfeoninvalidate()
616 xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); in ctlfeoninvalidate()
617 ccb.ccb_h.func_code = XPT_ABORT; in ctlfeoninvalidate()
618 LIST_FOREACH(hdr, &softc->atio_list, periph_links.le) { in ctlfeoninvalidate()
619 ccb.cab.abort_ccb = (union ccb *)hdr; in ctlfeoninvalidate()
622 LIST_FOREACH(hdr, &softc->inot_list, periph_links.le) { in ctlfeoninvalidate()
623 ccb.cab.abort_ccb = (union ccb *)hdr; in ctlfeoninvalidate()
627 /* Disable the LUN in SIM. */ in ctlfeoninvalidate()
628 ccb.ccb_h.func_code = XPT_EN_LUN; in ctlfeoninvalidate()
629 ccb.cel.grp6_len = 0; in ctlfeoninvalidate()
630 ccb.cel.grp7_len = 0; in ctlfeoninvalidate()
631 ccb.cel.enable = 0; in ctlfeoninvalidate()
633 status = (ccb.ccb_h.status & CAM_STATUS_MASK); in ctlfeoninvalidate()
636 __func__, ccb.ccb_h.status); in ctlfeoninvalidate()
683 * Set the direction, relative to the initiator. in ctlfedata()
686 if ((io->io_hdr.flags & CTL_FLAG_DATA_MASK) == CTL_FLAG_DATA_IN) in ctlfedata()
695 if (io->scsiio.kern_sg_entries == 0) { /* No S/G list. */ in ctlfedata()
697 /* One time shift for SRR offset. */ in ctlfedata()
698 off += io->scsiio.ext_data_filled; in ctlfedata()
699 io->scsiio.ext_data_filled = 0; in ctlfedata()
701 *data_ptr = io->scsiio.kern_data_ptr + off; in ctlfedata()
702 if (io->scsiio.kern_data_len - off <= bus_softc->maxio) { in ctlfedata()
703 *dxfer_len = io->scsiio.kern_data_len - off; in ctlfedata()
711 if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR) in ctlfedata()
715 } else { /* S/G list with physical or virtual pointers. */ in ctlfedata()
716 ctl_sglist = (struct ctl_sg_entry *)io->scsiio.kern_data_ptr; in ctlfedata()
718 /* One time shift for SRR offset. */ in ctlfedata()
719 while (io->scsiio.ext_data_filled >= ctl_sglist[idx].len - off) { in ctlfedata()
720 io->scsiio.ext_data_filled -= ctl_sglist[idx].len - off; in ctlfedata()
724 off += io->scsiio.ext_data_filled; in ctlfedata()
725 io->scsiio.ext_data_filled = 0; in ctlfedata()
729 for (i = 0; i < io->scsiio.kern_sg_entries - idx; i++) { in ctlfedata()
730 cam_sglist[i].ds_addr = (bus_addr_t)(uintptr_t)ctl_sglist[i + idx].addr + off; in ctlfedata()
731 if (ctl_sglist[i + idx].len - off <= bus_softc->maxio - *dxfer_len) { in ctlfedata()
732 cam_sglist[i].ds_len = ctl_sglist[idx + i].len - off; in ctlfedata()
733 *dxfer_len += cam_sglist[i].ds_len; in ctlfedata()
735 cam_sglist[i].ds_len = bus_softc->maxio - *dxfer_len; in ctlfedata()
737 cmd_info->cur_transfer_off = cam_sglist[i].ds_len + off; in ctlfedata()
739 *dxfer_len += cam_sglist[i].ds_len; in ctlfedata()
740 if (ctl_sglist[i].len != 0) in ctlfedata()
745 idx + i < (io->scsiio.kern_sg_entries - 1)) { in ctlfedata()
755 if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR) in ctlfedata()
786 STAILQ_REMOVE_HEAD(&softc->work_queue, periph_links.stqe); in ctlfestart()
791 flags = atio->ccb_h.flags & in ctlfestart()
798 if (io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) { in ctlfestart()
800 * Datamove call, we need to setup the S/G list. in ctlfestart()
806 * We're done, send status back. in ctlfestart()
808 if ((io->io_hdr.flags & CTL_FLAG_ABORT) && in ctlfestart()
809 (io->io_hdr.flags & CTL_FLAG_ABORT_STATUS) == 0) { in ctlfestart()
810 io->io_hdr.flags &= ~CTL_FLAG_STATUS_QUEUED; in ctlfestart()
816 KASSERT(atio->ccb_h.func_code == XPT_ACCEPT_TARGET_IO, in ctlfestart()
817 ("func_code %#x is not ATIO", atio->ccb_h.func_code)); in ctlfestart()
818 start_ccb->ccb_h.func_code = XPT_ABORT; in ctlfestart()
819 start_ccb->cab.abort_ccb = (union ccb *)atio; in ctlfestart()
825 /* XPT_ABORT is not queued, so we can take next I/O. */ in ctlfestart()
833 if ((io->io_hdr.flags & CTL_FLAG_STATUS_QUEUED) && in ctlfestart()
835 ((io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) == 0 || in ctlfestart()
836 io->io_hdr.status == CTL_SUCCESS)) { in ctlfestart()
838 scsi_status = io->scsiio.scsi_status; in ctlfestart()
839 csio->sense_len = io->scsiio.sense_len; in ctlfestart()
842 atio->tag_id, io->io_hdr.status); in ctlfestart()
845 csio->sense_data = io->scsiio.sense_data; in ctlfestart()
881 atio->tag_id, io->io_hdr.status); in ctlfestart()
895 start_ccb->ccb_h.flags |= CAM_UNLOCKED; in ctlfestart()
896 start_ccb->ccb_h.ccb_atio = atio; in ctlfestart()
897 if (io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) in ctlfestart()
898 io->io_hdr.flags |= CTL_FLAG_DMA_INPROG; in ctlfestart()
899 io->io_hdr.flags &= ~(CTL_FLAG_DMA_QUEUED | CTL_FLAG_STATUS_QUEUED); in ctlfestart()
909 * If we still have work to do, ask for another CCB. in ctlfestart()
938 io = ccb->ccb_h.io_ptr; in ctlfe_free_ccb()
940 switch (ccb->ccb_h.func_code) { in ctlfe_free_ccb()
964 * reference on the peripheral driver. It will probably go away in ctlfe_free_ccb()
965 * now. in ctlfe_free_ccb()
979 * Send the ATIO/INOT back to the SIM, or free it if periph was invalidated.
995 if (ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) in ctlfe_requeue_ccb()
996 LIST_INSERT_HEAD(&softc->atio_list, &ccb->ccb_h, periph_links.le); in ctlfe_requeue_ccb()
998 LIST_INSERT_HEAD(&softc->inot_list, &ccb->ccb_h, periph_links.le); in ctlfe_requeue_ccb()
1004 * target/lun. Reset the target and LUN fields back to the wildcard in ctlfe_requeue_ccb()
1005 * values before we send them back down to the SIM. in ctlfe_requeue_ccb()
1008 ccb->ccb_h.flags); in ctlfe_requeue_ccb()
1091 KASSERT((done_ccb->ccb_h.flags & CAM_UNLOCKED) != 0, in ctlfedone()
1095 done_ccb->ccb_h.func_code); in ctlfedone()
1099 * At this point CTL has no known use case for device queue freezes. in ctlfedone()
1100 * In case some SIM think different -- drop its freeze right here. in ctlfedone()
1102 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { in ctlfedone()
1108 done_ccb->ccb_h.status &= ~CAM_DEV_QFRZN; in ctlfedone()
1116 switch (done_ccb->ccb_h.func_code) { in ctlfedone()
1118 LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); in ctlfedone()
1120 status = atio->ccb_h.status & CAM_STATUS_MASK; in ctlfedone()
1129 * datamove or done. in ctlfedone()
1132 io = done_ccb->ccb_h.io_ptr; in ctlfedone()
1139 done_ccb->ccb_h.io_ptr = io; in ctlfedone()
1142 * Only SCSI I/O comes down this path, resets, etc. come in ctlfedone()
1143 * down the immediate notify path below. in ctlfedone()
1145 io->io_hdr.io_type = CTL_IO_SCSI; in ctlfedone()
1146 io->io_hdr.nexus.initid = atio->init_id; in ctlfedone()
1147 io->io_hdr.nexus.targ_port = bus_softc->port.targ_port; in ctlfedone()
1149 io->io_hdr.nexus.targ_lun = ctl_decode_lun( in ctlfedone()
1150 CAM_EXTLUN_BYTE_SWIZZLE(atio->ccb_h.target_lun)); in ctlfedone()
1152 io->io_hdr.nexus.targ_lun = atio->ccb_h.target_lun; in ctlfedone()
1154 io->scsiio.priority = atio->priority; in ctlfedone()
1155 io->scsiio.tag_num = atio->tag_id; in ctlfedone()
1158 io->scsiio.tag_type = CTL_TAG_UNTAGGED; in ctlfedone()
1161 io->scsiio.tag_type = CTL_TAG_SIMPLE; in ctlfedone()
1164 io->scsiio.tag_type = CTL_TAG_HEAD_OF_QUEUE; in ctlfedone()
1167 io->scsiio.tag_type = CTL_TAG_ORDERED; in ctlfedone()
1170 io->scsiio.tag_type = CTL_TAG_ACA; in ctlfedone()
1173 io->scsiio.tag_type = CTL_TAG_UNTAGGED; in ctlfedone()
1178 if (atio->cdb_len > sizeof(io->scsiio.cdb)) { in ctlfedone()
1180 __func__, atio->cdb_len, sizeof(io->scsiio.cdb)); in ctlfedone()
1182 io->scsiio.cdb_len = min(atio->cdb_len, sizeof(io->scsiio.cdb)); in ctlfedone()
1183 bcopy(atio_cdb_ptr(atio), io->scsiio.cdb, io->scsiio.cdb_len); in ctlfedone()
1187 io->io_hdr.nexus.initid, in ctlfedone()
1188 io->io_hdr.nexus.targ_port, in ctlfedone()
1189 io->io_hdr.nexus.targ_lun, in ctlfedone()
1190 io->scsiio.tag_num, io->scsiio.cdb[0]); in ctlfedone()
1200 atio = (struct ccb_accept_tio *)done_ccb->ccb_h.ccb_atio; in ctlfedone()
1201 io = (union ctl_io *)atio->ccb_h.io_ptr; in ctlfedone()
1206 __func__, atio->tag_id, done_ccb->ccb_h.flags); in ctlfedone()
1211 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_MESSAGE_RECV in ctlfedone()
1212 && done_ccb->csio.msg_ptr != NULL in ctlfedone()
1213 && done_ccb->csio.msg_ptr[0] == MSG_EXTENDED in ctlfedone()
1214 && done_ccb->csio.msg_ptr[1] == 5 in ctlfedone()
1215 && done_ccb->csio.msg_ptr[2] == 0) { in ctlfedone()
1218 (done_ccb->csio.msg_ptr[3] << 24) in ctlfedone()
1219 | (done_ccb->csio.msg_ptr[4] << 16) in ctlfedone()
1220 | (done_ccb->csio.msg_ptr[5] << 8) in ctlfedone()
1221 | (done_ccb->csio.msg_ptr[6]); in ctlfedone()
1226 * should be able to adjust offsets and cycle again. in ctlfedone()
1227 * It is possible only if offset is from this datamove. in ctlfedone()
1229 if (srr && (io->io_hdr.flags & CTL_FLAG_DMA_INPROG) && in ctlfedone()
1230 srr_off >= io->scsiio.kern_rel_offset && in ctlfedone()
1231 srr_off < io->scsiio.kern_rel_offset + in ctlfedone()
1232 io->scsiio.kern_data_len) { in ctlfedone()
1233 io->scsiio.kern_data_resid = in ctlfedone()
1234 io->scsiio.kern_rel_offset + in ctlfedone()
1235 io->scsiio.kern_data_len - srr_off; in ctlfedone()
1236 io->scsiio.ext_data_filled = srr_off; in ctlfedone()
1237 io->scsiio.io_hdr.status = CTL_STATUS_NONE; in ctlfedone()
1238 io->io_hdr.flags |= CTL_FLAG_DMA_QUEUED; in ctlfedone()
1241 periph_links.stqe); in ctlfedone()
1247 * If status was being sent, the back end data is now history. in ctlfedone()
1248 * Hack it up and resubmit a new command with the CDB adjusted. in ctlfedone()
1250 * should work. in ctlfedone()
1252 if (srr && (io->io_hdr.flags & CTL_FLAG_DMA_INPROG) == 0) { in ctlfedone()
1259 * Fall through to doom.... in ctlfedone()
1263 if ((done_ccb->ccb_h.flags & CAM_SEND_STATUS) && in ctlfedone()
1264 (done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) in ctlfedone()
1265 io->io_hdr.flags |= CTL_FLAG_STATUS_SENT; in ctlfedone()
1269 * resources. If we were doing a datamove, call the in ctlfedone()
1270 * datamove done routine. in ctlfedone()
1272 if ((io->io_hdr.flags & CTL_FLAG_DMA_INPROG) == 0) { in ctlfedone()
1275 * queue the I/O back to CTL for later REQUEST SENSE. in ctlfedone()
1277 if ((done_ccb->ccb_h.flags & CAM_SEND_SENSE) != 0 && in ctlfedone()
1278 (done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP && in ctlfedone()
1279 (done_ccb->ccb_h.status & CAM_SENT_SENSE) == 0 && in ctlfedone()
1280 (io = ctl_alloc_io_nowait(bus_softc->port.ctl_pool_ref)) != NULL) { in ctlfedone()
1282 (union ctl_io *)atio->ccb_h.io_ptr); in ctlfedone()
1283 ctl_queue_sense(atio->ccb_h.io_ptr); in ctlfedone()
1284 atio->ccb_h.io_ptr = io; in ctlfedone()
1287 /* Abort ATIO if CTIO sending status has failed. */ in ctlfedone()
1288 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != in ctlfedone()
1290 done_ccb->ccb_h.func_code = XPT_ABORT; in ctlfedone()
1291 done_ccb->cab.abort_ccb = (union ccb *)atio; in ctlfedone()
1306 io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG; in ctlfedone()
1309 * Translate CAM status to CTL status. Success in ctlfedone()
1310 * does not change the overall, ctl_io status. In in ctlfedone()
1311 * that case we just set port_status to 0. If we in ctlfedone()
1313 * for the overall ctl_io. in ctlfedone()
1315 switch (done_ccb->ccb_h.status & CAM_STATUS_MASK) { in ctlfedone()
1317 io->scsiio.kern_data_resid -= in ctlfedone()
1319 io->io_hdr.port_status = 0; in ctlfedone()
1326 * data transfer failure. A data phase in ctlfedone()
1328 * data transfer error of some sort. in ctlfedone()
1331 * a clue what happened. in ctlfedone()
1333 io->io_hdr.port_status = 0xbad1; in ctlfedone()
1336 * XXX KDM figure out residual. in ctlfedone()
1343 * continue sending pieces if necessary. in ctlfedone()
1346 io->io_hdr.port_status == 0 && csio->resid == 0) { in ctlfedone()
1351 flags = atio->ccb_h.flags & in ctlfedone()
1366 io->io_hdr.status); in ctlfedone()
1382 csio->ccb_h.flags |= CAM_UNLOCKED; in ctlfedone()
1384 csio->ccb_h.ccb_atio = atio; in ctlfedone()
1385 io->io_hdr.flags |= CTL_FLAG_DMA_INPROG; in ctlfedone()
1391 * Release the CTIO. The ATIO will be sent back in ctlfedone()
1392 * down to the SIM once we send status. in ctlfedone()
1408 LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); in ctlfedone()
1410 io = done_ccb->ccb_h.io_ptr; in ctlfedone()
1415 io->io_hdr.io_type = CTL_IO_TASK; in ctlfedone()
1417 inot->ccb_h.io_ptr = io; in ctlfedone()
1418 io->io_hdr.nexus.initid = inot->initiator_id; in ctlfedone()
1419 io->io_hdr.nexus.targ_port = bus_softc->port.targ_port; in ctlfedone()
1421 io->io_hdr.nexus.targ_lun = ctl_decode_lun( in ctlfedone()
1422 CAM_EXTLUN_BYTE_SWIZZLE(inot->ccb_h.target_lun)); in ctlfedone()
1424 io->io_hdr.nexus.targ_lun = inot->ccb_h.target_lun; in ctlfedone()
1427 io->taskio.tag_num = inot->seq_id; in ctlfedone()
1429 status = inot->ccb_h.status & CAM_STATUS_MASK; in ctlfedone()
1432 io->taskio.task_action = CTL_TASK_BUS_RESET; in ctlfedone()
1435 io->taskio.task_action = CTL_TASK_TARGET_RESET; in ctlfedone()
1440 io->taskio.task_action = in ctlfedone()
1444 io->taskio.task_action = CTL_TASK_TARGET_RESET; in ctlfedone()
1447 io->taskio.task_action = CTL_TASK_ABORT_TASK; in ctlfedone()
1450 io->taskio.task_action = CTL_TASK_LUN_RESET; in ctlfedone()
1453 io->taskio.task_action = in ctlfedone()
1457 io->taskio.task_action = CTL_TASK_CLEAR_ACA; in ctlfedone()
1460 io->taskio.task_action = CTL_TASK_QUERY_TASK; in ctlfedone()
1463 io->taskio.task_action = in ctlfedone()
1467 io->taskio.task_action = in ctlfedone()
1497 done_ccb->ccb_h.status = CAM_REQ_INPROG; in ctlfedone()
1498 done_ccb->ccb_h.func_code = XPT_NOTIFY_ACKNOWLEDGE; in ctlfedone()
1504 /* Queue this back down to the SIM as an immediate notify. */ in ctlfedone()
1505 done_ccb->ccb_h.status = CAM_REQ_INPROG; in ctlfedone()
1506 done_ccb->ccb_h.func_code = XPT_IMMEDIATE_NOTIFY; in ctlfedone()
1515 done_ccb->ccb_h.func_code); in ctlfedone()
1540 ccb->ccb_h.func_code = XPT_GET_SIM_KNOB; in ctlfe_onoffline()
1543 /* Check whether we should change WWNs. */ in ctlfe_onoffline()
1545 if ((ccb->knob.xport_specific.valid & KNOB_VALID_ADDRESS) != 0){ in ctlfe_onoffline()
1548 ccb->knob.xport_specific.fc.wwnn); in ctlfe_onoffline()
1551 ccb->knob.xport_specific.fc.wwpn); in ctlfe_onoffline()
1555 * down to the SIM. Otherwise, record what the SIM in ctlfe_onoffline()
1556 * has reported. in ctlfe_onoffline()
1558 if (bus_softc->port.wwnn != 0 && bus_softc->port.wwnn in ctlfe_onoffline()
1559 != ccb->knob.xport_specific.fc.wwnn) { in ctlfe_onoffline()
1560 ccb->knob.xport_specific.fc.wwnn = in ctlfe_onoffline()
1561 bus_softc->port.wwnn; in ctlfe_onoffline()
1565 true, ccb->knob.xport_specific.fc.wwnn, in ctlfe_onoffline()
1568 if (bus_softc->port.wwpn != 0 && bus_softc->port.wwpn in ctlfe_onoffline()
1569 != ccb->knob.xport_specific.fc.wwpn) { in ctlfe_onoffline()
1570 ccb->knob.xport_specific.fc.wwpn = in ctlfe_onoffline()
1571 bus_softc->port.wwpn; in ctlfe_onoffline()
1576 true, ccb->knob.xport_specific.fc.wwpn); in ctlfe_onoffline()
1581 if (bus_softc->port.wwnn != 0) { in ctlfe_onoffline()
1582 ccb->knob.xport_specific.fc.wwnn = in ctlfe_onoffline()
1583 bus_softc->port.wwnn; in ctlfe_onoffline()
1586 if (bus_softc->port.wwpn != 0) { in ctlfe_onoffline()
1587 ccb->knob.xport_specific.fc.wwpn = in ctlfe_onoffline()
1588 bus_softc->port.wwpn; in ctlfe_onoffline()
1594 ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; in ctlfe_onoffline()
1595 ccb->knob.xport_specific.valid = KNOB_VALID_ADDRESS; in ctlfe_onoffline()
1597 if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { in ctlfe_onoffline()
1600 ccb->ccb_h.status); in ctlfe_onoffline()
1604 ccb->knob.xport_specific.fc.wwnn); in ctlfe_onoffline()
1607 ccb->knob.xport_specific.fc.wwpn); in ctlfe_onoffline()
1611 /* Check whether we should change role. */ in ctlfe_onoffline()
1612 if ((ccb->knob.xport_specific.valid & KNOB_VALID_ROLE) == 0 || in ctlfe_onoffline()
1614 ((ccb->knob.xport_specific.fc.role & KNOB_ROLE_TARGET) != 0)) != 0) { in ctlfe_onoffline()
1615 ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; in ctlfe_onoffline()
1616 ccb->knob.xport_specific.valid = KNOB_VALID_ROLE; in ctlfe_onoffline()
1618 ccb->knob.xport_specific.fc.role |= KNOB_ROLE_TARGET; in ctlfe_onoffline()
1620 ccb->knob.xport_specific.fc.role &= ~KNOB_ROLE_TARGET; in ctlfe_onoffline()
1622 if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { in ctlfe_onoffline()
1625 online ? "enable" : "disable", ccb->ccb_h.status); in ctlfe_onoffline()
1649 * Create the wildcard LUN before bringing the port online. in ctlfe_online()
1665 /* We've already got a periph, no need to alloc a new one. */ in ctlfe_online()
1714 * the port offline. in ctlfe_offline()
1733 * CTL. So we only need to create a path/periph for this particular bus.
1761 /* We've already got a periph, no need to alloc a new one. */ in ctlfe_lun_enable()
1797 * on every bus that is attached to CTL.
1845 * 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 ("%s: unexpected I/O type %x", __func__, 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()