Lines Matching full:qc
45 typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc);
235 * @qc: ATA PASS-THROUGH command.
243 static void ata_scsi_set_passthru_sense_fields(struct ata_queued_cmd *qc) in ata_scsi_set_passthru_sense_fields() argument
245 struct ata_device *dev = qc->dev; in ata_scsi_set_passthru_sense_fields()
246 struct scsi_cmnd *cmd = qc->scsicmd; in ata_scsi_set_passthru_sense_fields()
247 struct ata_taskfile *tf = &qc->result_tf; in ata_scsi_set_passthru_sense_fields()
250 if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { in ata_scsi_set_passthru_sense_fields()
742 struct ata_queued_cmd *qc; in ata_scsi_qc_new() local
760 qc = __ata_qc_from_tag(ap, tag); in ata_scsi_qc_new()
761 qc->tag = qc->hw_tag = tag; in ata_scsi_qc_new()
762 qc->ap = ap; in ata_scsi_qc_new()
763 qc->dev = dev; in ata_scsi_qc_new()
765 ata_qc_reinit(qc); in ata_scsi_qc_new()
767 qc->scsicmd = cmd; in ata_scsi_qc_new()
768 qc->scsidone = scsi_done; in ata_scsi_qc_new()
770 qc->sg = scsi_sglist(cmd); in ata_scsi_qc_new()
771 qc->n_elem = scsi_sg_count(cmd); in ata_scsi_qc_new()
774 qc->flags |= ATA_QCFLAG_QUIET; in ata_scsi_qc_new()
776 return qc; in ata_scsi_qc_new()
785 static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc) in ata_qc_set_pc_nbytes() argument
787 struct scsi_cmnd *scmd = qc->scsicmd; in ata_qc_set_pc_nbytes()
789 qc->extrabytes = scmd->extra_len; in ata_qc_set_pc_nbytes()
790 qc->nbytes = scsi_bufflen(scmd) + qc->extrabytes; in ata_qc_set_pc_nbytes()
918 * @qc: Command that completed.
931 static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) in ata_gen_passthru_sense() argument
933 struct ata_device *dev = qc->dev; in ata_gen_passthru_sense()
934 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_passthru_sense()
935 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_passthru_sense()
938 if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { in ata_gen_passthru_sense()
948 if (qc->err_mask || in ata_gen_passthru_sense()
952 ata_scsi_set_sense(qc->dev, cmd, sense_key, asc, ascq); in ata_gen_passthru_sense()
972 * @qc: Command that we are erroring out
974 * Generate sense block for a failed ATA command @qc. Descriptor
980 static void ata_gen_ata_sense(struct ata_queued_cmd *qc) in ata_gen_ata_sense() argument
982 struct ata_device *dev = qc->dev; in ata_gen_ata_sense()
983 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_ata_sense()
984 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_ata_sense()
996 if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { in ata_gen_ata_sense()
1005 if (qc->err_mask || in ata_gen_ata_sense()
1013 tf->status, qc->err_mask); in ata_gen_ata_sense()
1018 block = ata_tf_read_block(&qc->result_tf, dev); in ata_gen_ata_sense()
1032 * it needs to see every deferred qc. Set dev_blocked to 1 to in ata_scsi_sdev_config()
1234 * @qc: Storage for translated ATA taskfile
1247 static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) in ata_scsi_start_stop_xlat() argument
1249 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_start_stop_xlat()
1274 if (!ata_dev_power_init_tf(qc->dev, &qc->tf, cdb[4] & 0x1)) { in ata_scsi_start_stop_xlat()
1275 ata_scsi_set_sense(qc->dev, scmd, ABORTED_COMMAND, 0, 0); in ata_scsi_start_stop_xlat()
1289 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_start_stop_xlat()
1295 * @qc: Storage for translated ATA taskfile
1306 static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc) in ata_scsi_flush_xlat() argument
1308 struct ata_taskfile *tf = &qc->tf; in ata_scsi_flush_xlat()
1313 if (qc->dev->flags & ATA_DFLAG_FLUSH_EXT) in ata_scsi_flush_xlat()
1319 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_flush_xlat()
1386 * @qc: Storage for translated ATA taskfile
1396 static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc) in ata_scsi_verify_xlat() argument
1398 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_verify_xlat()
1399 struct ata_taskfile *tf = &qc->tf; in ata_scsi_verify_xlat()
1400 struct ata_device *dev = qc->dev; in ata_scsi_verify_xlat()
1401 u64 dev_sectors = qc->dev->n_sectors; in ata_scsi_verify_xlat()
1499 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_verify_xlat()
1503 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x0); in ata_scsi_verify_xlat()
1529 * @qc: Storage for translated ATA taskfile
1545 static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc) in ata_scsi_rw_xlat() argument
1547 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_rw_xlat()
1625 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_rw_xlat()
1626 qc->nbytes = n_block * scmd->device->sector_size; in ata_scsi_rw_xlat()
1628 rc = ata_build_rw_tf(qc, block, n_block, tf_flags, dld, class); in ata_scsi_rw_xlat()
1636 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_rw_xlat()
1640 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x0); in ata_scsi_rw_xlat()
1649 static void ata_qc_done(struct ata_queued_cmd *qc) in ata_qc_done() argument
1651 struct scsi_cmnd *cmd = qc->scsicmd; in ata_qc_done()
1652 void (*done)(struct scsi_cmnd *) = qc->scsidone; in ata_qc_done()
1654 ata_qc_free(qc); in ata_qc_done()
1658 static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) in ata_scsi_qc_complete() argument
1660 struct scsi_cmnd *cmd = qc->scsicmd; in ata_scsi_qc_complete()
1662 bool have_sense = qc->flags & ATA_QCFLAG_SENSE_VALID; in ata_scsi_qc_complete()
1665 bool is_error = qc->err_mask != 0; in ata_scsi_qc_complete()
1678 ata_gen_passthru_sense(qc); in ata_scsi_qc_complete()
1679 ata_scsi_set_passthru_sense_fields(qc); in ata_scsi_qc_complete()
1681 set_status_byte(qc->scsicmd, SAM_STAT_CHECK_CONDITION); in ata_scsi_qc_complete()
1683 ata_gen_ata_sense(qc); in ata_scsi_qc_complete()
1686 ata_qc_done(qc); in ata_scsi_qc_complete()
1719 struct ata_queued_cmd *qc; in ata_scsi_translate() local
1722 qc = ata_scsi_qc_new(dev, cmd); in ata_scsi_translate()
1723 if (!qc) in ata_scsi_translate()
1734 ata_sg_init(qc, scsi_sglist(cmd), scsi_sg_count(cmd)); in ata_scsi_translate()
1736 qc->dma_dir = cmd->sc_data_direction; in ata_scsi_translate()
1739 qc->complete_fn = ata_scsi_qc_complete; in ata_scsi_translate()
1741 if (xlat_func(qc)) in ata_scsi_translate()
1745 if ((rc = ap->ops->qc_defer(qc))) in ata_scsi_translate()
1750 ata_qc_issue(qc); in ata_scsi_translate()
1755 ata_qc_free(qc); in ata_scsi_translate()
1760 ata_qc_free(qc); in ata_scsi_translate()
1767 ata_qc_free(qc); in ata_scsi_translate()
2776 static void atapi_qc_complete(struct ata_queued_cmd *qc) in atapi_qc_complete() argument
2778 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_qc_complete()
2779 unsigned int err_mask = qc->err_mask; in atapi_qc_complete()
2782 if (unlikely(err_mask || qc->flags & ATA_QCFLAG_SENSE_VALID)) { in atapi_qc_complete()
2784 if (!(qc->flags & ATA_QCFLAG_SENSE_VALID)) in atapi_qc_complete()
2785 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2798 * sure qc->dev->sdev isn't NULL before dereferencing. in atapi_qc_complete()
2800 if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev) in atapi_qc_complete()
2801 qc->dev->sdev->locked = 0; in atapi_qc_complete()
2803 qc->scsicmd->result = SAM_STAT_CHECK_CONDITION; in atapi_qc_complete()
2804 ata_qc_done(qc); in atapi_qc_complete()
2813 ata_qc_done(qc); in atapi_qc_complete()
2817 * @qc: command structure to be initialized
2825 static unsigned int atapi_xlat(struct ata_queued_cmd *qc) in atapi_xlat() argument
2827 struct scsi_cmnd *scmd = qc->scsicmd; in atapi_xlat()
2828 struct ata_device *dev = qc->dev; in atapi_xlat()
2833 memset(qc->cdb, 0, dev->cdb_len); in atapi_xlat()
2834 memcpy(qc->cdb, scmd->cmnd, scmd->cmd_len); in atapi_xlat()
2836 qc->complete_fn = atapi_qc_complete; in atapi_xlat()
2838 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_xlat()
2840 qc->tf.flags |= ATA_TFLAG_WRITE; in atapi_xlat()
2843 qc->tf.command = ATA_CMD_PACKET; in atapi_xlat()
2844 ata_qc_set_pc_nbytes(qc); in atapi_xlat()
2847 if (!nodata && !using_pio && atapi_check_dma(qc)) in atapi_xlat()
2855 nbytes = min(ata_qc_raw_nbytes(qc), (unsigned int)63 * 1024); in atapi_xlat()
2884 qc->tf.lbam = (nbytes & 0xFF); in atapi_xlat()
2885 qc->tf.lbah = (nbytes >> 8); in atapi_xlat()
2888 qc->tf.protocol = ATAPI_PROT_NODATA; in atapi_xlat()
2890 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_xlat()
2893 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_xlat()
2894 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_xlat()
2899 qc->tf.feature |= ATAPI_DMADIR; in atapi_xlat()
3028 * @qc: command structure to be initialized
3035 static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) in ata_scsi_pass_thru() argument
3037 struct ata_taskfile *tf = &(qc->tf); in ata_scsi_pass_thru()
3038 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_pass_thru()
3039 struct ata_device *dev = qc->dev; in ata_scsi_pass_thru()
3146 tf->nsect = qc->hw_tag << 3; in ata_scsi_pass_thru()
3162 qc->sect_size = scsi_bufflen(scmd); in ata_scsi_pass_thru()
3196 qc->sect_size = scmd->device->sector_size; in ata_scsi_pass_thru()
3201 qc->sect_size = ATA_SECT_SIZE; in ata_scsi_pass_thru()
3213 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; in ata_scsi_pass_thru()
3221 ata_qc_set_pc_nbytes(qc); in ata_scsi_pass_thru()
3348 * @qc: Command to be translated
3357 static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) in ata_scsi_write_same_xlat() argument
3359 struct ata_taskfile *tf = &qc->tf; in ata_scsi_write_same_xlat()
3360 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_write_same_xlat()
3363 struct ata_device *dev = qc->dev; in ata_scsi_write_same_xlat()
3425 tf->nsect = qc->hw_tag << 3; in ata_scsi_write_same_xlat()
3442 ata_qc_set_pc_nbytes(qc); in ata_scsi_write_same_xlat()
3562 * @qc: command structure returning the data
3568 static void ata_scsi_report_zones_complete(struct ata_queued_cmd *qc) in ata_scsi_report_zones_complete() argument
3570 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_report_zones_complete()
3628 ata_scsi_qc_complete(qc); in ata_scsi_report_zones_complete()
3631 static unsigned int ata_scsi_zbc_in_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_in_xlat() argument
3633 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_in_xlat()
3634 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_in_xlat()
3642 ata_dev_warn(qc->dev, "invalid cdb length %d\n", in ata_scsi_zbc_in_xlat()
3649 ata_dev_warn(qc->dev, "non-matching transfer count (%d/%d)\n", in ata_scsi_zbc_in_xlat()
3655 ata_dev_warn(qc->dev, "invalid service action %d\n", sa); in ata_scsi_zbc_in_xlat()
3664 ata_dev_warn(qc->dev, "invalid transfer count %d\n", n_block); in ata_scsi_zbc_in_xlat()
3670 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_in_xlat()
3671 ata_fpdma_zac_mgmt_in_supported(qc->dev)) { in ata_scsi_zbc_in_xlat()
3675 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_in_xlat()
3696 qc->flags |= ATA_QCFLAG_RESULT_TF; in ata_scsi_zbc_in_xlat()
3698 ata_qc_set_pc_nbytes(qc); in ata_scsi_zbc_in_xlat()
3700 qc->complete_fn = ata_scsi_report_zones_complete; in ata_scsi_zbc_in_xlat()
3705 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_zbc_in_xlat()
3710 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_in_xlat()
3714 static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_out_xlat() argument
3716 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_out_xlat()
3717 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_out_xlat()
3718 struct ata_device *dev = qc->dev; in ata_scsi_zbc_out_xlat()
3759 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_out_xlat()
3760 ata_fpdma_zac_mgmt_out_supported(qc->dev)) { in ata_scsi_zbc_out_xlat()
3764 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_out_xlat()
3784 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_zbc_out_xlat()
3788 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_out_xlat()
3794 * @qc: Storage for translated ATA taskfile
3804 static int ata_mselect_caching(struct ata_queued_cmd *qc, in ata_mselect_caching() argument
3807 struct ata_taskfile *tf = &qc->tf; in ata_mselect_caching()
3808 struct ata_device *dev = qc->dev; in ata_mselect_caching()
3849 static int ata_mselect_control_spg0(struct ata_queued_cmd *qc, in ata_mselect_control_spg0() argument
3852 struct ata_device *dev = qc->dev; in ata_mselect_control_spg0()
3892 static unsigned int ata_mselect_control_ata_feature(struct ata_queued_cmd *qc, in ata_mselect_control_ata_feature() argument
3896 struct ata_device *dev = qc->dev; in ata_mselect_control_ata_feature()
3897 struct ata_taskfile *tf = &qc->tf; in ata_mselect_control_ata_feature()
3942 * @qc: Storage for translated ATA taskfile
3953 static int ata_mselect_control(struct ata_queued_cmd *qc, u8 spg, in ata_mselect_control() argument
3958 return ata_mselect_control_spg0(qc, buf, len, fp); in ata_mselect_control()
3960 return ata_mselect_control_ata_feature(qc, buf, len, fp); in ata_mselect_control()
3968 * @qc: Storage for translated ATA taskfile
3977 static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc) in ata_scsi_mode_select_xlat() argument
3979 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_mode_select_xlat()
4082 if (qc->dev->flags & ATA_DFLAG_CDL && in ata_scsi_mode_select_xlat()
4097 if (ata_mselect_caching(qc, p, pg_len, &fp) < 0) { in ata_scsi_mode_select_xlat()
4103 ret = ata_mselect_control(qc, spg, p, pg_len, &fp); in ata_scsi_mode_select_xlat()
4127 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_mode_select_xlat()
4131 ata_scsi_set_invalid_parameter(qc->dev, scmd, fp); in ata_scsi_mode_select_xlat()
4136 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_mode_select_xlat()
4154 static unsigned int ata_scsi_security_inout_xlat(struct ata_queued_cmd *qc) in ata_scsi_security_inout_xlat() argument
4156 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_security_inout_xlat()
4158 struct ata_taskfile *tf = &qc->tf; in ata_scsi_security_inout_xlat()
4163 bool dma = !(qc->dev->flags & ATA_DFLAG_PIO); in ata_scsi_security_inout_xlat()
4169 ata_scsi_set_invalid_field(qc->dev, scmd, 1, 0); in ata_scsi_security_inout_xlat()
4175 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
4180 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
4205 ata_qc_set_pc_nbytes(qc); in ata_scsi_security_inout_xlat()
4211 * @qc: Command to be translated
4220 static unsigned int ata_scsi_var_len_cdb_xlat(struct ata_queued_cmd *qc) in ata_scsi_var_len_cdb_xlat() argument
4222 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_var_len_cdb_xlat()
4231 return ata_scsi_pass_thru(qc); in ata_scsi_var_len_cdb_xlat()
4502 * callback and it needs to see every deferred qc. in ata_scsi_add_hosts()