Lines Matching refs:qc

63 typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc);
861 struct ata_queued_cmd *qc; in ata_scsi_qc_new() local
863 qc = ata_qc_new_init(dev, cmd->request->tag); in ata_scsi_qc_new()
864 if (qc) { in ata_scsi_qc_new()
865 qc->scsicmd = cmd; in ata_scsi_qc_new()
866 qc->scsidone = cmd->scsi_done; in ata_scsi_qc_new()
868 qc->sg = scsi_sglist(cmd); in ata_scsi_qc_new()
869 qc->n_elem = scsi_sg_count(cmd); in ata_scsi_qc_new()
872 qc->flags |= ATA_QCFLAG_QUIET; in ata_scsi_qc_new()
878 return qc; in ata_scsi_qc_new()
881 static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc) in ata_qc_set_pc_nbytes() argument
883 struct scsi_cmnd *scmd = qc->scsicmd; in ata_qc_set_pc_nbytes()
885 qc->extrabytes = scmd->request->extra_len; in ata_qc_set_pc_nbytes()
886 qc->nbytes = scsi_bufflen(scmd) + qc->extrabytes; in ata_qc_set_pc_nbytes()
1083 static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) in ata_gen_passthru_sense() argument
1085 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_passthru_sense()
1086 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_passthru_sense()
1089 int verbose = qc->ap->ops->error_handler == NULL; in ata_gen_passthru_sense()
1100 if (qc->err_mask || in ata_gen_passthru_sense()
1102 ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, in ata_gen_passthru_sense()
1104 ata_scsi_set_sense(qc->dev, cmd, sense_key, asc, ascq); in ata_gen_passthru_sense()
1181 static void ata_gen_ata_sense(struct ata_queued_cmd *qc) in ata_gen_ata_sense() argument
1183 struct ata_device *dev = qc->dev; in ata_gen_ata_sense()
1184 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_ata_sense()
1185 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_ata_sense()
1187 int verbose = qc->ap->ops->error_handler == NULL; in ata_gen_ata_sense()
1204 if (qc->err_mask || in ata_gen_ata_sense()
1206 ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, in ata_gen_ata_sense()
1212 tf->command, qc->err_mask); in ata_gen_ata_sense()
1217 block = ata_tf_read_block(&qc->result_tf, dev); in ata_gen_ata_sense()
1475 static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) in ata_scsi_start_stop_xlat() argument
1477 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_start_stop_xlat()
1478 struct ata_taskfile *tf = &qc->tf; in ata_scsi_start_stop_xlat()
1507 if (qc->dev->flags & ATA_DFLAG_LBA) { in ata_scsi_start_stop_xlat()
1526 if ((qc->ap->flags & ATA_FLAG_NO_POWEROFF_SPINDOWN) && in ata_scsi_start_stop_xlat()
1530 if ((qc->ap->flags & ATA_FLAG_NO_HIBERNATE_SPINDOWN) && in ata_scsi_start_stop_xlat()
1548 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_start_stop_xlat()
1569 static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc) in ata_scsi_flush_xlat() argument
1571 struct ata_taskfile *tf = &qc->tf; in ata_scsi_flush_xlat()
1576 if (qc->dev->flags & ATA_DFLAG_FLUSH_EXT) in ata_scsi_flush_xlat()
1582 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_flush_xlat()
1690 static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc) in ata_scsi_verify_xlat() argument
1692 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_verify_xlat()
1693 struct ata_taskfile *tf = &qc->tf; in ata_scsi_verify_xlat()
1694 struct ata_device *dev = qc->dev; in ata_scsi_verify_xlat()
1695 u64 dev_sectors = qc->dev->n_sectors; in ata_scsi_verify_xlat()
1793 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_verify_xlat()
1797 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x0); in ata_scsi_verify_xlat()
1824 static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc) in ata_scsi_rw_xlat() argument
1826 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_rw_xlat()
1892 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_rw_xlat()
1893 qc->nbytes = n_block * scmd->device->sector_size; in ata_scsi_rw_xlat()
1895 rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags, in ata_scsi_rw_xlat()
1896 qc->hw_tag, class); in ata_scsi_rw_xlat()
1905 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_rw_xlat()
1909 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x0); in ata_scsi_rw_xlat()
1918 static void ata_qc_done(struct ata_queued_cmd *qc) in ata_qc_done() argument
1920 struct scsi_cmnd *cmd = qc->scsicmd; in ata_qc_done()
1921 void (*done)(struct scsi_cmnd *) = qc->scsidone; in ata_qc_done()
1923 ata_qc_free(qc); in ata_qc_done()
1927 static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) in ata_scsi_qc_complete() argument
1929 struct ata_port *ap = qc->ap; in ata_scsi_qc_complete()
1930 struct scsi_cmnd *cmd = qc->scsicmd; in ata_scsi_qc_complete()
1932 int need_sense = (qc->err_mask != 0); in ata_scsi_qc_complete()
1945 ata_gen_passthru_sense(qc); in ata_scsi_qc_complete()
1946 else if (qc->flags & ATA_QCFLAG_SENSE_VALID) in ata_scsi_qc_complete()
1949 ata_gen_ata_sense(qc); in ata_scsi_qc_complete()
1954 ata_dump_status(ap->print_id, &qc->result_tf); in ata_scsi_qc_complete()
1956 ata_qc_done(qc); in ata_scsi_qc_complete()
1989 struct ata_queued_cmd *qc; in ata_scsi_translate() local
1994 qc = ata_scsi_qc_new(dev, cmd); in ata_scsi_translate()
1995 if (!qc) in ata_scsi_translate()
2006 ata_sg_init(qc, scsi_sglist(cmd), scsi_sg_count(cmd)); in ata_scsi_translate()
2008 qc->dma_dir = cmd->sc_data_direction; in ata_scsi_translate()
2011 qc->complete_fn = ata_scsi_qc_complete; in ata_scsi_translate()
2013 if (xlat_func(qc)) in ata_scsi_translate()
2017 if ((rc = ap->ops->qc_defer(qc))) in ata_scsi_translate()
2022 ata_qc_issue(qc); in ata_scsi_translate()
2028 ata_qc_free(qc); in ata_scsi_translate()
2034 ata_qc_free(qc); in ata_scsi_translate()
2042 ata_qc_free(qc); in ata_scsi_translate()
2785 static void atapi_sense_complete(struct ata_queued_cmd *qc) in atapi_sense_complete() argument
2787 if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) { in atapi_sense_complete()
2793 ata_gen_passthru_sense(qc); in atapi_sense_complete()
2796 ata_qc_done(qc); in atapi_sense_complete()
2805 static void atapi_request_sense(struct ata_queued_cmd *qc) in atapi_request_sense() argument
2807 struct ata_port *ap = qc->ap; in atapi_request_sense()
2808 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_request_sense()
2816 ap->ops->sff_tf_read(ap, &qc->tf); in atapi_request_sense()
2821 cmd->sense_buffer[2] = qc->tf.feature >> 4; in atapi_request_sense()
2823 ata_qc_reinit(qc); in atapi_request_sense()
2826 sg_init_one(&qc->sgent, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); in atapi_request_sense()
2827 ata_sg_init(qc, &qc->sgent, 1); in atapi_request_sense()
2828 qc->dma_dir = DMA_FROM_DEVICE; in atapi_request_sense()
2830 memset(&qc->cdb, 0, qc->dev->cdb_len); in atapi_request_sense()
2831 qc->cdb[0] = REQUEST_SENSE; in atapi_request_sense()
2832 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2834 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_request_sense()
2835 qc->tf.command = ATA_CMD_PACKET; in atapi_request_sense()
2838 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_request_sense()
2839 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_request_sense()
2841 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_request_sense()
2842 qc->tf.lbam = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2843 qc->tf.lbah = 0; in atapi_request_sense()
2845 qc->nbytes = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2847 qc->complete_fn = atapi_sense_complete; in atapi_request_sense()
2849 ata_qc_issue(qc); in atapi_request_sense()
2874 static void atapi_qc_complete(struct ata_queued_cmd *qc) in atapi_qc_complete() argument
2876 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_qc_complete()
2877 unsigned int err_mask = qc->err_mask; in atapi_qc_complete()
2882 if (unlikely(qc->ap->ops->error_handler && in atapi_qc_complete()
2883 (err_mask || qc->flags & ATA_QCFLAG_SENSE_VALID))) { in atapi_qc_complete()
2885 if (!(qc->flags & ATA_QCFLAG_SENSE_VALID)) { in atapi_qc_complete()
2891 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2907 if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev) in atapi_qc_complete()
2908 qc->dev->sdev->locked = 0; in atapi_qc_complete()
2910 qc->scsicmd->result = SAM_STAT_CHECK_CONDITION; in atapi_qc_complete()
2911 ata_qc_done(qc); in atapi_qc_complete()
2918 atapi_request_sense(qc); in atapi_qc_complete()
2926 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2933 ata_qc_done(qc); in atapi_qc_complete()
2945 static unsigned int atapi_xlat(struct ata_queued_cmd *qc) in atapi_xlat() argument
2947 struct scsi_cmnd *scmd = qc->scsicmd; in atapi_xlat()
2948 struct ata_device *dev = qc->dev; in atapi_xlat()
2953 memset(qc->cdb, 0, dev->cdb_len); in atapi_xlat()
2954 memcpy(qc->cdb, scmd->cmnd, scmd->cmd_len); in atapi_xlat()
2956 qc->complete_fn = atapi_qc_complete; in atapi_xlat()
2958 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_xlat()
2960 qc->tf.flags |= ATA_TFLAG_WRITE; in atapi_xlat()
2964 qc->tf.command = ATA_CMD_PACKET; in atapi_xlat()
2965 ata_qc_set_pc_nbytes(qc); in atapi_xlat()
2968 if (!nodata && !using_pio && atapi_check_dma(qc)) in atapi_xlat()
2976 nbytes = min(ata_qc_raw_nbytes(qc), (unsigned int)63 * 1024); in atapi_xlat()
3005 qc->tf.lbam = (nbytes & 0xFF); in atapi_xlat()
3006 qc->tf.lbah = (nbytes >> 8); in atapi_xlat()
3009 qc->tf.protocol = ATAPI_PROT_NODATA; in atapi_xlat()
3011 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_xlat()
3014 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_xlat()
3015 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_xlat()
3020 qc->tf.feature |= ATAPI_DMADIR; in atapi_xlat()
3138 static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) in ata_scsi_pass_thru() argument
3140 struct ata_taskfile *tf = &(qc->tf); in ata_scsi_pass_thru()
3141 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_pass_thru()
3142 struct ata_device *dev = qc->dev; in ata_scsi_pass_thru()
3234 tf->nsect = qc->hw_tag << 3; in ata_scsi_pass_thru()
3250 qc->sect_size = scsi_bufflen(scmd); in ata_scsi_pass_thru()
3284 qc->sect_size = scmd->device->sector_size; in ata_scsi_pass_thru()
3289 qc->sect_size = ATA_SECT_SIZE; in ata_scsi_pass_thru()
3301 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; in ata_scsi_pass_thru()
3309 ata_qc_set_pc_nbytes(qc); in ata_scsi_pass_thru()
3445 static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) in ata_scsi_write_same_xlat() argument
3447 struct ata_taskfile *tf = &qc->tf; in ata_scsi_write_same_xlat()
3448 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_write_same_xlat()
3451 struct ata_device *dev = qc->dev; in ata_scsi_write_same_xlat()
3514 tf->nsect = qc->hw_tag << 3; in ata_scsi_write_same_xlat()
3531 ata_qc_set_pc_nbytes(qc); in ata_scsi_write_same_xlat()
3627 static void ata_scsi_report_zones_complete(struct ata_queued_cmd *qc) in ata_scsi_report_zones_complete() argument
3629 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_report_zones_complete()
3687 ata_scsi_qc_complete(qc); in ata_scsi_report_zones_complete()
3690 static unsigned int ata_scsi_zbc_in_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_in_xlat() argument
3692 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_in_xlat()
3693 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_in_xlat()
3701 ata_dev_warn(qc->dev, "invalid cdb length %d\n", in ata_scsi_zbc_in_xlat()
3708 ata_dev_warn(qc->dev, "non-matching transfer count (%d/%d)\n", in ata_scsi_zbc_in_xlat()
3714 ata_dev_warn(qc->dev, "invalid service action %d\n", sa); in ata_scsi_zbc_in_xlat()
3723 ata_dev_warn(qc->dev, "invalid transfer count %d\n", n_block); in ata_scsi_zbc_in_xlat()
3729 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_in_xlat()
3730 ata_fpdma_zac_mgmt_in_supported(qc->dev)) { in ata_scsi_zbc_in_xlat()
3734 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_in_xlat()
3755 qc->flags |= ATA_QCFLAG_RESULT_TF; in ata_scsi_zbc_in_xlat()
3757 ata_qc_set_pc_nbytes(qc); in ata_scsi_zbc_in_xlat()
3759 qc->complete_fn = ata_scsi_report_zones_complete; in ata_scsi_zbc_in_xlat()
3764 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_zbc_in_xlat()
3769 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_in_xlat()
3773 static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_out_xlat() argument
3775 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_out_xlat()
3776 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_out_xlat()
3777 struct ata_device *dev = qc->dev; in ata_scsi_zbc_out_xlat()
3818 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_out_xlat()
3819 ata_fpdma_zac_mgmt_out_supported(qc->dev)) { in ata_scsi_zbc_out_xlat()
3823 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_out_xlat()
3843 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_zbc_out_xlat()
3847 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_out_xlat()
3863 static int ata_mselect_caching(struct ata_queued_cmd *qc, in ata_mselect_caching() argument
3866 struct ata_taskfile *tf = &qc->tf; in ata_mselect_caching()
3867 struct ata_device *dev = qc->dev; in ata_mselect_caching()
3920 static int ata_mselect_control(struct ata_queued_cmd *qc, in ata_mselect_control() argument
3923 struct ata_device *dev = qc->dev; in ata_mselect_control()
3973 static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc) in ata_scsi_mode_select_xlat() argument
3975 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_mode_select_xlat()
4076 if (ata_mselect_caching(qc, p, pg_len, &fp) < 0) { in ata_scsi_mode_select_xlat()
4082 if (ata_mselect_control(qc, p, pg_len, &fp) < 0) { in ata_scsi_mode_select_xlat()
4104 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_mode_select_xlat()
4108 ata_scsi_set_invalid_parameter(qc->dev, scmd, fp); in ata_scsi_mode_select_xlat()
4113 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_mode_select_xlat()
4131 static unsigned int ata_scsi_security_inout_xlat(struct ata_queued_cmd *qc) in ata_scsi_security_inout_xlat() argument
4133 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_security_inout_xlat()
4135 struct ata_taskfile *tf = &qc->tf; in ata_scsi_security_inout_xlat()
4140 bool dma = !(qc->dev->flags & ATA_DFLAG_PIO); in ata_scsi_security_inout_xlat()
4146 ata_scsi_set_invalid_field(qc->dev, scmd, 1, 0); in ata_scsi_security_inout_xlat()
4152 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
4157 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
4182 ata_qc_set_pc_nbytes(qc); in ata_scsi_security_inout_xlat()
4197 static unsigned int ata_scsi_var_len_cdb_xlat(struct ata_queued_cmd *qc) in ata_scsi_var_len_cdb_xlat() argument
4199 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_var_len_cdb_xlat()
4208 return ata_scsi_pass_thru(qc); in ata_scsi_var_len_cdb_xlat()