Lines Matching refs:ccb

60 static void ataaction(struct cam_sim *sim, union ccb *ccb);
62 static void ata_cam_begin_transaction(device_t dev, union ccb *ccb);
65 static int ata_check_ids(device_t dev, union ccb *ccb);
263 union ccb *ccb;
271 if ((ccb = xpt_alloc_ccb_nowait()) == NULL)
273 if (xpt_create_path(&ccb->ccb_h.path, NULL,
276 xpt_free_ccb(ccb);
279 xpt_rescan(ccb);
443 request->u.atapi.saved_cmd : request->u.atapi.ccb[0]) {
729 ata_cam_begin_transaction(device_t dev, union ccb *ccb)
740 request->unit = ccb->ccb_h.target_id;
741 if (ccb->ccb_h.func_code == XPT_ATA_IO) {
742 request->data = ccb->ataio.data_ptr;
743 request->bytecount = ccb->ataio.dxfer_len;
744 request->u.ata.command = ccb->ataio.cmd.command;
745 request->u.ata.feature = ((uint16_t)ccb->ataio.cmd.features_exp << 8) |
746 (uint16_t)ccb->ataio.cmd.features;
747 request->u.ata.count = ((uint16_t)ccb->ataio.cmd.sector_count_exp << 8) |
748 (uint16_t)ccb->ataio.cmd.sector_count;
749 if (ccb->ataio.cmd.flags & CAM_ATAIO_48BIT) {
752 ((uint64_t)ccb->ataio.cmd.lba_high_exp << 40) |
753 ((uint64_t)ccb->ataio.cmd.lba_mid_exp << 32) |
754 ((uint64_t)ccb->ataio.cmd.lba_low_exp << 24);
757 ((uint64_t)(ccb->ataio.cmd.device & 0x0f) << 24);
759 request->u.ata.lba |= ((uint64_t)ccb->ataio.cmd.lba_high << 16) |
760 ((uint64_t)ccb->ataio.cmd.lba_mid << 8) |
761 (uint64_t)ccb->ataio.cmd.lba_low;
762 if (ccb->ataio.cmd.flags & CAM_ATAIO_NEEDRESULT)
764 if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE &&
765 ccb->ataio.cmd.flags & CAM_ATAIO_DMA)
767 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
769 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT)
771 if (ccb->ataio.cmd.command == ATA_READ_MUL ||
772 ccb->ataio.cmd.command == ATA_READ_MUL48 ||
773 ccb->ataio.cmd.command == ATA_WRITE_MUL ||
774 ccb->ataio.cmd.command == ATA_WRITE_MUL48) {
776 ch->curr[ccb->ccb_h.target_id].bytecount);
780 request->data = ccb->csio.data_ptr;
781 request->bytecount = ccb->csio.dxfer_len;
782 bcopy((ccb->ccb_h.flags & CAM_CDB_POINTER) ?
783 ccb->csio.cdb_io.cdb_ptr : ccb->csio.cdb_io.cdb_bytes,
784 request->u.atapi.ccb, ccb->csio.cdb_len);
786 if (ch->curr[ccb->ccb_h.target_id].atapi == 16)
788 if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE &&
789 ch->curr[ccb->ccb_h.target_id].mode >= ATA_DMA)
791 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
793 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT)
796 ch->curr[ccb->ccb_h.target_id].bytecount);
799 request->timeout = (ccb->ccb_h.timeout + 999) / 1000;
801 request->ccb = ccb;
818 union ccb *ccb = request->ccb;
825 request->unit = ccb->ccb_h.target_id;
826 request->data = (void *)&ccb->csio.sense_data;
827 request->bytecount = ccb->csio.sense_len;
828 request->u.atapi.ccb[0] = ATAPI_REQUEST_SENSE;
829 request->u.atapi.ccb[4] = ccb->csio.sense_len;
831 if (ch->curr[ccb->ccb_h.target_id].atapi == 16)
833 if (ch->curr[ccb->ccb_h.target_id].mode >= ATA_DMA)
837 ch->curr[ccb->ccb_h.target_id].bytecount);
839 request->timeout = (ccb->ccb_h.timeout + 999) / 1000;
841 request->ccb = ccb;
857 union ccb *ccb = request->ccb;
867 ccb->ccb_h.status |= CAM_AUTOSNS_VALID;
869 ccb->ccb_h.status &= ~CAM_STATUS_MASK;
870 ccb->ccb_h.status |= CAM_AUTOSENSE_FAIL;
873 xpt_done(ccb);
883 union ccb *ccb = request->ccb;
891 ccb->ccb_h.status &= ~CAM_STATUS_MASK;
894 ccb->ccb_h.status &= ~CAM_STATUS_MASK;
895 ccb->ccb_h.status |= CAM_CMD_TIMEOUT | CAM_RELEASE_SIMQ;
898 if (ccb->ccb_h.func_code == XPT_ATA_IO) {
899 ccb->ccb_h.status |= CAM_ATA_STATUS_ERROR;
901 ccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR;
902 ccb->csio.scsi_status = SCSI_STATUS_CHECK_COND;
905 ccb->ccb_h.status |= CAM_REQUEUE_REQ;
907 ccb->ccb_h.status |= CAM_REQ_CMP_ERR;
909 ccb->ccb_h.status |= CAM_REQ_CMP;
910 if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP &&
911 !(ccb->ccb_h.status & CAM_DEV_QFRZN)) {
912 xpt_freeze_devq(ccb->ccb_h.path, 1);
913 ccb->ccb_h.status |= CAM_DEV_QFRZN;
915 if (ccb->ccb_h.func_code == XPT_ATA_IO &&
917 (ccb->ataio.cmd.flags & CAM_ATAIO_NEEDRESULT))) {
918 struct ata_res *res = &ccb->ataio.res;
931 if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
932 if (ccb->ccb_h.func_code == XPT_ATA_IO) {
933 ccb->ataio.resid =
934 ccb->ataio.dxfer_len - request->donecount;
936 ccb->csio.resid =
937 ccb->csio.dxfer_len - request->donecount;
940 if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR &&
941 (ccb->ccb_h.flags & CAM_DIS_AUTOSENSE) == 0)
944 xpt_done(ccb);
951 ata_check_ids(device_t dev, union ccb *ccb)
955 if (ccb->ccb_h.target_id > ((ch->flags & ATA_NO_SLAVE) ? 0 : 1)) {
956 ccb->ccb_h.status = CAM_TID_INVALID;
957 xpt_done(ccb);
960 if (ccb->ccb_h.target_lun != 0) {
961 ccb->ccb_h.status = CAM_LUN_INVALID;
962 xpt_done(ccb);
968 KASSERT(ccb->ccb_h.func_code != XPT_ATA_IO ||
969 ((ccb->ataio.ata_flags & ATA_FLAG_AUX) == 0),
975 ataaction(struct cam_sim *sim, union ccb *ccb)
980 CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("ataaction func_code=%x\n",
981 ccb->ccb_h.func_code));
985 switch (ccb->ccb_h.func_code) {
989 if (ata_check_ids(dev, ccb))
992 << ccb->ccb_h.target_id)) == 0) {
993 ccb->ccb_h.status = CAM_SEL_TIMEOUT;
998 if (ccb->ccb_h.func_code == XPT_ATA_IO &&
999 (ccb->ataio.cmd.flags & CAM_ATAIO_CONTROL) &&
1000 (ccb->ataio.cmd.control & ATA_A_RESET)) {
1001 struct ata_res *res = &ccb->ataio.res;
1004 if (ch->devices & (ATA_ATA_MASTER << ccb->ccb_h.target_id)) {
1011 ccb->ccb_h.status = CAM_REQ_CMP;
1014 ata_cam_begin_transaction(dev, ccb);
1018 ccb->ccb_h.status = CAM_REQ_INVALID;
1022 struct ccb_trans_settings *cts = &ccb->cts;
1025 if (ata_check_ids(dev, ccb))
1028 d = &ch->curr[ccb->ccb_h.target_id];
1030 d = &ch->user[ccb->ccb_h.target_id];
1037 ccb->ccb_h.target_id,
1052 ccb->ccb_h.target_id,
1064 ccb->ccb_h.status = CAM_REQ_CMP;
1069 struct ccb_trans_settings *cts = &ccb->cts;
1072 if (ata_check_ids(dev, ccb))
1075 d = &ch->curr[ccb->ccb_h.target_id];
1077 d = &ch->user[ccb->ccb_h.target_id];
1090 ATA_GETREV(dev, ccb->ccb_h.target_id);
1102 ch->user[ccb->ccb_h.target_id].caps;
1126 ch->user[ccb->ccb_h.target_id].caps;
1133 ccb->ccb_h.status = CAM_REQ_CMP;
1139 ccb->ccb_h.status = CAM_REQ_CMP;
1143 ccb->ccb_h.status = CAM_REQ_INVALID;
1147 struct ccb_pathinq *cpi = &ccb->cpi;
1189 ccb->ccb_h.status = CAM_REQ_INVALID;
1192 xpt_done(ccb);