Lines Matching refs:qc

47 typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc);
846 struct ata_queued_cmd *qc; in ata_scsi_qc_new() local
848 qc = ata_qc_new_init(dev, cmd->request->tag); in ata_scsi_qc_new()
849 if (qc) { in ata_scsi_qc_new()
850 qc->scsicmd = cmd; in ata_scsi_qc_new()
851 qc->scsidone = cmd->scsi_done; in ata_scsi_qc_new()
853 qc->sg = scsi_sglist(cmd); in ata_scsi_qc_new()
854 qc->n_elem = scsi_sg_count(cmd); in ata_scsi_qc_new()
857 qc->flags |= ATA_QCFLAG_QUIET; in ata_scsi_qc_new()
863 return qc; in ata_scsi_qc_new()
866 static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc) in ata_qc_set_pc_nbytes() argument
868 struct scsi_cmnd *scmd = qc->scsicmd; in ata_qc_set_pc_nbytes()
870 qc->extrabytes = scmd->request->extra_len; in ata_qc_set_pc_nbytes()
871 qc->nbytes = scsi_bufflen(scmd) + qc->extrabytes; in ata_qc_set_pc_nbytes()
1068 static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) in ata_gen_passthru_sense() argument
1070 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_passthru_sense()
1071 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_passthru_sense()
1074 int verbose = qc->ap->ops->error_handler == NULL; in ata_gen_passthru_sense()
1085 if (qc->err_mask || in ata_gen_passthru_sense()
1087 ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, in ata_gen_passthru_sense()
1089 ata_scsi_set_sense(qc->dev, cmd, sense_key, asc, ascq); in ata_gen_passthru_sense()
1166 static void ata_gen_ata_sense(struct ata_queued_cmd *qc) in ata_gen_ata_sense() argument
1168 struct ata_device *dev = qc->dev; in ata_gen_ata_sense()
1169 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_ata_sense()
1170 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_ata_sense()
1172 int verbose = qc->ap->ops->error_handler == NULL; in ata_gen_ata_sense()
1189 if (qc->err_mask || in ata_gen_ata_sense()
1191 ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, in ata_gen_ata_sense()
1197 tf->command, qc->err_mask); in ata_gen_ata_sense()
1202 block = ata_tf_read_block(&qc->result_tf, dev); in ata_gen_ata_sense()
1458 static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) in ata_scsi_start_stop_xlat() argument
1460 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_start_stop_xlat()
1461 struct ata_taskfile *tf = &qc->tf; in ata_scsi_start_stop_xlat()
1490 if (qc->dev->flags & ATA_DFLAG_LBA) { in ata_scsi_start_stop_xlat()
1509 if ((qc->ap->flags & ATA_FLAG_NO_POWEROFF_SPINDOWN) && in ata_scsi_start_stop_xlat()
1513 if ((qc->ap->flags & ATA_FLAG_NO_HIBERNATE_SPINDOWN) && in ata_scsi_start_stop_xlat()
1531 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_start_stop_xlat()
1552 static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc) in ata_scsi_flush_xlat() argument
1554 struct ata_taskfile *tf = &qc->tf; in ata_scsi_flush_xlat()
1559 if (qc->dev->flags & ATA_DFLAG_FLUSH_EXT) in ata_scsi_flush_xlat()
1565 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_flush_xlat()
1673 static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc) in ata_scsi_verify_xlat() argument
1675 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_verify_xlat()
1676 struct ata_taskfile *tf = &qc->tf; in ata_scsi_verify_xlat()
1677 struct ata_device *dev = qc->dev; in ata_scsi_verify_xlat()
1678 u64 dev_sectors = qc->dev->n_sectors; in ata_scsi_verify_xlat()
1776 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_verify_xlat()
1780 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x0); in ata_scsi_verify_xlat()
1822 static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc) in ata_scsi_rw_xlat() argument
1824 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_rw_xlat()
1896 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_rw_xlat()
1897 qc->nbytes = n_block * scmd->device->sector_size; in ata_scsi_rw_xlat()
1899 rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags, in ata_scsi_rw_xlat()
1900 qc->hw_tag, class); in ata_scsi_rw_xlat()
1909 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_rw_xlat()
1913 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x0); in ata_scsi_rw_xlat()
1922 static void ata_qc_done(struct ata_queued_cmd *qc) in ata_qc_done() argument
1924 struct scsi_cmnd *cmd = qc->scsicmd; in ata_qc_done()
1925 void (*done)(struct scsi_cmnd *) = qc->scsidone; in ata_qc_done()
1927 ata_qc_free(qc); in ata_qc_done()
1931 static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) in ata_scsi_qc_complete() argument
1933 struct ata_port *ap = qc->ap; in ata_scsi_qc_complete()
1934 struct scsi_cmnd *cmd = qc->scsicmd; in ata_scsi_qc_complete()
1936 int need_sense = (qc->err_mask != 0); in ata_scsi_qc_complete()
1949 ata_gen_passthru_sense(qc); in ata_scsi_qc_complete()
1950 else if (qc->flags & ATA_QCFLAG_SENSE_VALID) in ata_scsi_qc_complete()
1953 ata_gen_ata_sense(qc); in ata_scsi_qc_complete()
1958 ata_dump_status(ap->print_id, &qc->result_tf); in ata_scsi_qc_complete()
1960 ata_qc_done(qc); in ata_scsi_qc_complete()
1993 struct ata_queued_cmd *qc; in ata_scsi_translate() local
1998 qc = ata_scsi_qc_new(dev, cmd); in ata_scsi_translate()
1999 if (!qc) in ata_scsi_translate()
2010 ata_sg_init(qc, scsi_sglist(cmd), scsi_sg_count(cmd)); in ata_scsi_translate()
2012 qc->dma_dir = cmd->sc_data_direction; in ata_scsi_translate()
2015 qc->complete_fn = ata_scsi_qc_complete; in ata_scsi_translate()
2017 if (xlat_func(qc)) in ata_scsi_translate()
2021 if ((rc = ap->ops->qc_defer(qc))) in ata_scsi_translate()
2026 ata_qc_issue(qc); in ata_scsi_translate()
2032 ata_qc_free(qc); in ata_scsi_translate()
2038 ata_qc_free(qc); in ata_scsi_translate()
2046 ata_qc_free(qc); in ata_scsi_translate()
2789 static void atapi_sense_complete(struct ata_queued_cmd *qc) in atapi_sense_complete() argument
2791 if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) { in atapi_sense_complete()
2797 ata_gen_passthru_sense(qc); in atapi_sense_complete()
2800 ata_qc_done(qc); in atapi_sense_complete()
2809 static void atapi_request_sense(struct ata_queued_cmd *qc) in atapi_request_sense() argument
2811 struct ata_port *ap = qc->ap; in atapi_request_sense()
2812 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_request_sense()
2820 ap->ops->sff_tf_read(ap, &qc->tf); in atapi_request_sense()
2825 cmd->sense_buffer[2] = qc->tf.feature >> 4; in atapi_request_sense()
2827 ata_qc_reinit(qc); in atapi_request_sense()
2830 sg_init_one(&qc->sgent, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); in atapi_request_sense()
2831 ata_sg_init(qc, &qc->sgent, 1); in atapi_request_sense()
2832 qc->dma_dir = DMA_FROM_DEVICE; in atapi_request_sense()
2834 memset(&qc->cdb, 0, qc->dev->cdb_len); in atapi_request_sense()
2835 qc->cdb[0] = REQUEST_SENSE; in atapi_request_sense()
2836 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2838 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_request_sense()
2839 qc->tf.command = ATA_CMD_PACKET; in atapi_request_sense()
2842 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_request_sense()
2843 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_request_sense()
2845 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_request_sense()
2846 qc->tf.lbam = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2847 qc->tf.lbah = 0; in atapi_request_sense()
2849 qc->nbytes = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2851 qc->complete_fn = atapi_sense_complete; in atapi_request_sense()
2853 ata_qc_issue(qc); in atapi_request_sense()
2878 static void atapi_qc_complete(struct ata_queued_cmd *qc) in atapi_qc_complete() argument
2880 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_qc_complete()
2881 unsigned int err_mask = qc->err_mask; in atapi_qc_complete()
2886 if (unlikely(qc->ap->ops->error_handler && in atapi_qc_complete()
2887 (err_mask || qc->flags & ATA_QCFLAG_SENSE_VALID))) { in atapi_qc_complete()
2889 if (!(qc->flags & ATA_QCFLAG_SENSE_VALID)) { in atapi_qc_complete()
2895 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2911 if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev) in atapi_qc_complete()
2912 qc->dev->sdev->locked = 0; in atapi_qc_complete()
2914 qc->scsicmd->result = SAM_STAT_CHECK_CONDITION; in atapi_qc_complete()
2915 ata_qc_done(qc); in atapi_qc_complete()
2922 atapi_request_sense(qc); in atapi_qc_complete()
2930 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2937 ata_qc_done(qc); in atapi_qc_complete()
2949 static unsigned int atapi_xlat(struct ata_queued_cmd *qc) in atapi_xlat() argument
2951 struct scsi_cmnd *scmd = qc->scsicmd; in atapi_xlat()
2952 struct ata_device *dev = qc->dev; in atapi_xlat()
2957 memset(qc->cdb, 0, dev->cdb_len); in atapi_xlat()
2958 memcpy(qc->cdb, scmd->cmnd, scmd->cmd_len); in atapi_xlat()
2960 qc->complete_fn = atapi_qc_complete; in atapi_xlat()
2962 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_xlat()
2964 qc->tf.flags |= ATA_TFLAG_WRITE; in atapi_xlat()
2968 qc->tf.command = ATA_CMD_PACKET; in atapi_xlat()
2969 ata_qc_set_pc_nbytes(qc); in atapi_xlat()
2972 if (!nodata && !using_pio && atapi_check_dma(qc)) in atapi_xlat()
2980 nbytes = min(ata_qc_raw_nbytes(qc), (unsigned int)63 * 1024); in atapi_xlat()
3009 qc->tf.lbam = (nbytes & 0xFF); in atapi_xlat()
3010 qc->tf.lbah = (nbytes >> 8); in atapi_xlat()
3013 qc->tf.protocol = ATAPI_PROT_NODATA; in atapi_xlat()
3015 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_xlat()
3018 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_xlat()
3019 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_xlat()
3024 qc->tf.feature |= ATAPI_DMADIR; in atapi_xlat()
3142 static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) in ata_scsi_pass_thru() argument
3144 struct ata_taskfile *tf = &(qc->tf); in ata_scsi_pass_thru()
3145 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_pass_thru()
3146 struct ata_device *dev = qc->dev; in ata_scsi_pass_thru()
3238 tf->nsect = qc->hw_tag << 3; in ata_scsi_pass_thru()
3254 qc->sect_size = scsi_bufflen(scmd); in ata_scsi_pass_thru()
3288 qc->sect_size = scmd->device->sector_size; in ata_scsi_pass_thru()
3293 qc->sect_size = ATA_SECT_SIZE; in ata_scsi_pass_thru()
3305 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; in ata_scsi_pass_thru()
3313 ata_qc_set_pc_nbytes(qc); in ata_scsi_pass_thru()
3449 static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) in ata_scsi_write_same_xlat() argument
3451 struct ata_taskfile *tf = &qc->tf; in ata_scsi_write_same_xlat()
3452 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_write_same_xlat()
3455 struct ata_device *dev = qc->dev; in ata_scsi_write_same_xlat()
3518 tf->nsect = qc->hw_tag << 3; in ata_scsi_write_same_xlat()
3535 ata_qc_set_pc_nbytes(qc); in ata_scsi_write_same_xlat()
3631 static void ata_scsi_report_zones_complete(struct ata_queued_cmd *qc) in ata_scsi_report_zones_complete() argument
3633 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_report_zones_complete()
3691 ata_scsi_qc_complete(qc); in ata_scsi_report_zones_complete()
3694 static unsigned int ata_scsi_zbc_in_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_in_xlat() argument
3696 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_in_xlat()
3697 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_in_xlat()
3705 ata_dev_warn(qc->dev, "invalid cdb length %d\n", in ata_scsi_zbc_in_xlat()
3712 ata_dev_warn(qc->dev, "non-matching transfer count (%d/%d)\n", in ata_scsi_zbc_in_xlat()
3718 ata_dev_warn(qc->dev, "invalid service action %d\n", sa); in ata_scsi_zbc_in_xlat()
3727 ata_dev_warn(qc->dev, "invalid transfer count %d\n", n_block); in ata_scsi_zbc_in_xlat()
3733 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_in_xlat()
3734 ata_fpdma_zac_mgmt_in_supported(qc->dev)) { in ata_scsi_zbc_in_xlat()
3738 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_in_xlat()
3759 qc->flags |= ATA_QCFLAG_RESULT_TF; in ata_scsi_zbc_in_xlat()
3761 ata_qc_set_pc_nbytes(qc); in ata_scsi_zbc_in_xlat()
3763 qc->complete_fn = ata_scsi_report_zones_complete; in ata_scsi_zbc_in_xlat()
3768 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_zbc_in_xlat()
3773 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_in_xlat()
3777 static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_out_xlat() argument
3779 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_out_xlat()
3780 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_out_xlat()
3781 struct ata_device *dev = qc->dev; in ata_scsi_zbc_out_xlat()
3822 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_out_xlat()
3823 ata_fpdma_zac_mgmt_out_supported(qc->dev)) { in ata_scsi_zbc_out_xlat()
3827 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_out_xlat()
3847 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_zbc_out_xlat()
3851 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_out_xlat()
3867 static int ata_mselect_caching(struct ata_queued_cmd *qc, in ata_mselect_caching() argument
3870 struct ata_taskfile *tf = &qc->tf; in ata_mselect_caching()
3871 struct ata_device *dev = qc->dev; in ata_mselect_caching()
3924 static int ata_mselect_control(struct ata_queued_cmd *qc, in ata_mselect_control() argument
3927 struct ata_device *dev = qc->dev; in ata_mselect_control()
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()
4080 if (ata_mselect_caching(qc, p, pg_len, &fp) < 0) { in ata_scsi_mode_select_xlat()
4086 if (ata_mselect_control(qc, p, pg_len, &fp) < 0) { in ata_scsi_mode_select_xlat()
4108 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_mode_select_xlat()
4112 ata_scsi_set_invalid_parameter(qc->dev, scmd, fp); in ata_scsi_mode_select_xlat()
4117 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_mode_select_xlat()
4135 static unsigned int ata_scsi_security_inout_xlat(struct ata_queued_cmd *qc) in ata_scsi_security_inout_xlat() argument
4137 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_security_inout_xlat()
4139 struct ata_taskfile *tf = &qc->tf; in ata_scsi_security_inout_xlat()
4144 bool dma = !(qc->dev->flags & ATA_DFLAG_PIO); in ata_scsi_security_inout_xlat()
4150 ata_scsi_set_invalid_field(qc->dev, scmd, 1, 0); in ata_scsi_security_inout_xlat()
4156 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
4161 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
4186 ata_qc_set_pc_nbytes(qc); in ata_scsi_security_inout_xlat()
4201 static unsigned int ata_scsi_var_len_cdb_xlat(struct ata_queued_cmd *qc) in ata_scsi_var_len_cdb_xlat() argument
4203 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_var_len_cdb_xlat()
4212 return ata_scsi_pass_thru(qc); in ata_scsi_var_len_cdb_xlat()