Lines Matching refs:ctio
75 struct ccb_scsiio *ctio, int dir);
135 tcmd_handle(struct ccb_accept_tio *atio, struct ccb_scsiio *ctio, io_ops event)
143 warnx("tcmd_handle atio %p ctio %p atioflags %#x", atio, ctio,
163 last_cmd->done(atio, ctio, event);
165 free_ccb((union ccb *)ctio);
176 tcmd_illegal_req(atio, ctio);
177 send_ccb((union ccb *)ctio, /*priority*/1);
181 istate = tcmd_get_istate(ctio->init_id);
183 tcmd_illegal_req(atio, ctio);
184 send_ccb((union ccb *)ctio, /*priority*/1);
190 tcmd_sense(ctio->init_id, ctio, SSD_KEY_UNIT_ATTENTION,
197 send_ccb((union ccb *)ctio, /*priority*/1);
218 ret = last_cmd->start(atio, ctio);
221 a_descr->init_req += ctio->dxfer_len;
222 send_ccb((union ccb *)ctio, /*priority*/1);
241 tcmd_sense(u_int init_id, struct ccb_scsiio *ctio, u_int8_t flags,
263 if (ctio != NULL) {
264 bcopy(sense, &ctio->sense_data, sizeof(*sense));
265 ctio->sense_len = sizeof(*sense); /* XXX */
266 ctio->ccb_h.flags &= ~CAM_DIR_MASK;
267 ctio->ccb_h.flags |= CAM_DIR_NONE | CAM_SEND_SENSE |
269 ctio->dxfer_len = 0;
270 ctio->scsi_status = SCSI_STATUS_CHECK_COND;
296 tcmd_inquiry(struct ccb_accept_tio *atio, struct ccb_scsiio *ctio)
312 istate = tcmd_get_istate(ctio->init_id);
315 tcmd_illegal_req(atio, ctio);
322 tcmd_illegal_req(atio, ctio);
328 bcopy(&inq_data, ctio->data_ptr, sizeof(inq_data));
329 ctio->dxfer_len = inq_data.additional_length + 4;
330 ctio->dxfer_len = min(ctio->dxfer_len,
332 ctio->ccb_h.flags |= CAM_DIR_IN | CAM_SEND_STATUS;
333 ctio->scsi_status = SCSI_STATUS_OK;
376 tcmd_req_sense(struct ccb_accept_tio *atio, struct ccb_scsiio *ctio)
387 istate = tcmd_get_istate(ctio->init_id);
397 tcmd_sense(ctio->init_id, NULL, SSD_KEY_NO_SENSE, 0, 0);
399 ctio->init_id);
402 bcopy(sense, ctio->data_ptr, sizeof(struct scsi_sense_data));
405 ctio->dxfer_len = min(dlen, SCSI_CDB6_LEN(rsense->length));
406 ctio->ccb_h.flags |= CAM_DIR_IN | CAM_SEND_STATUS;
407 ctio->scsi_status = SCSI_STATUS_OK;
412 tcmd_rd_cap(struct ccb_accept_tio *atio, struct ccb_scsiio *ctio)
419 srp = (struct scsi_read_capacity_data *)ctio->data_ptr;
435 ctio->dxfer_len = sizeof(*srp);
436 ctio->ccb_h.flags |= CAM_DIR_IN | CAM_SEND_STATUS;
437 ctio->scsi_status = SCSI_STATUS_OK;
443 tcmd_rd_cap16(struct ccb_accept_tio *atio, struct ccb_scsiio *ctio)
451 srp = (struct scsi_read_capacity_data_long *)ctio->data_ptr;
454 tcmd_illegal_req(atio, ctio);
467 ctio->dxfer_len = sizeof(*srp);
468 ctio->ccb_h.flags |= CAM_DIR_IN | CAM_SEND_STATUS;
469 ctio->scsi_status = SCSI_STATUS_OK;
475 tcmd_rdwr(struct ccb_accept_tio *atio, struct ccb_scsiio *ctio)
482 c_descr = (struct ctio_descr *)ctio->ccb_h.targ_descr;
488 ret = tcmd_rdwr_decode(atio, ctio);
490 send_ccb((union ccb *)ctio, /*priority*/1);
494 ctio->ccb_h.flags |= a_descr->flags;
498 ret = start_io(atio, ctio, CAM_DIR_IN);
503 ret = start_io(atio, ctio, CAM_DIR_OUT);
513 tcmd_rdwr_decode(struct ccb_accept_tio *atio, struct ccb_scsiio *ctio)
553 tcmd_illegal_req(atio, ctio);
558 tcmd_sense(ctio->init_id, ctio,
569 tcmd_null_ok(atio, ctio);
584 start_io(struct ccb_accept_tio *atio, struct ccb_scsiio *ctio, int dir)
592 c_descr = (struct ctio_descr *)ctio->ccb_h.targ_descr;
596 ctio->dxfer_len = a_descr->total_len - a_descr->targ_req;
599 ctio->dxfer_len = a_descr->total_len - a_descr->init_req;
601 ctio->dxfer_len = min(ctio->dxfer_len, buf_size);
602 assert(ctio->dxfer_len >= 0);
605 c_descr->aiocb.aio_nbytes = ctio->dxfer_len;
614 (ctio->dxfer_len / sector_size),
623 ctio->dxfer_len) != ctio->dxfer_len) {
630 (ctio->dxfer_len / sector_size),
636 a_descr->targ_req += ctio->dxfer_len;
639 ctio->ccb_h.flags |= CAM_SEND_STATUS;
640 ctio->scsi_status = SCSI_STATUS_OK;
644 tcmd_rdwr_done(atio, ctio, AIO_DONE);
647 tcmd_null_ok(atio, ctio);
648 a_descr->init_req += ctio->dxfer_len;
650 ctio->dxfer_len > 0) {
658 send_ccb((union ccb *)ctio, /*priority*/1);
665 tcmd_rdwr_done(struct ccb_accept_tio *atio, struct ccb_scsiio *ctio,
672 c_descr = (struct ctio_descr *)ctio->ccb_h.targ_descr;
679 tcmd_sense(ctio->init_id, ctio,
681 send_ccb((union ccb *)ctio, /*priority*/1);
684 a_descr->targ_ack += ctio->dxfer_len;
692 a_descr->init_req += ctio->dxfer_len;
693 send_ccb((union ccb *)ctio, /*priority*/1);
700 free_ccb((union ccb *)ctio);
704 switch (ctio->ccb_h.status & CAM_STATUS_MASK) {
720 errx(1, "CTIO failed, status %#x", ctio->ccb_h.status);
722 a_descr->init_ack += ctio->dxfer_len;
724 ctio->dxfer_len > 0) {
725 a_descr->targ_req += ctio->dxfer_len;
730 (ctio->dxfer_len / sector_size),
739 ctio->dxfer_len) != ctio->dxfer_len) {
742 tcmd_rdwr_done(atio, ctio, AIO_DONE);
747 (ctio->dxfer_len / sector_size),
756 free_ccb((union ccb *)ctio);
768 tcmd_null_ok(struct ccb_accept_tio *atio, struct ccb_scsiio *ctio)
777 ctio->dxfer_len = 0;
778 ctio->ccb_h.flags &= ~CAM_DIR_MASK;
779 ctio->ccb_h.flags |= CAM_DIR_NONE | CAM_SEND_STATUS;
780 ctio->scsi_status = SCSI_STATUS_OK;
786 tcmd_illegal_req(struct ccb_accept_tio *atio, struct ccb_scsiio *ctio)
795 tcmd_sense(atio->init_id, ctio, SSD_KEY_ILLEGAL_REQUEST,