Lines Matching refs:qc

45 typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc);
661 struct ata_queued_cmd *qc; in ata_scsi_qc_new() local
679 qc = __ata_qc_from_tag(ap, tag); in ata_scsi_qc_new()
680 qc->tag = qc->hw_tag = tag; in ata_scsi_qc_new()
681 qc->ap = ap; in ata_scsi_qc_new()
682 qc->dev = dev; in ata_scsi_qc_new()
684 ata_qc_reinit(qc); in ata_scsi_qc_new()
686 qc->scsicmd = cmd; in ata_scsi_qc_new()
687 qc->scsidone = scsi_done; in ata_scsi_qc_new()
689 qc->sg = scsi_sglist(cmd); in ata_scsi_qc_new()
690 qc->n_elem = scsi_sg_count(cmd); in ata_scsi_qc_new()
693 qc->flags |= ATA_QCFLAG_QUIET; in ata_scsi_qc_new()
695 return qc; in ata_scsi_qc_new()
704 static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc) in ata_qc_set_pc_nbytes() argument
706 struct scsi_cmnd *scmd = qc->scsicmd; in ata_qc_set_pc_nbytes()
708 qc->extrabytes = scmd->extra_len; in ata_qc_set_pc_nbytes()
709 qc->nbytes = scsi_bufflen(scmd) + qc->extrabytes; in ata_qc_set_pc_nbytes()
853 static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) in ata_gen_passthru_sense() argument
855 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_passthru_sense()
856 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_passthru_sense()
867 if (qc->err_mask || in ata_gen_passthru_sense()
869 ata_to_sense_error(qc->ap->print_id, tf->status, tf->error, in ata_gen_passthru_sense()
871 ata_scsi_set_sense(qc->dev, cmd, sense_key, asc, ascq); in ata_gen_passthru_sense()
947 static void ata_gen_ata_sense(struct ata_queued_cmd *qc) in ata_gen_ata_sense() argument
949 struct ata_device *dev = qc->dev; in ata_gen_ata_sense()
950 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_ata_sense()
951 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_ata_sense()
967 if (qc->err_mask || in ata_gen_ata_sense()
969 ata_to_sense_error(qc->ap->print_id, tf->status, tf->error, in ata_gen_ata_sense()
975 tf->status, qc->err_mask); in ata_gen_ata_sense()
980 block = ata_tf_read_block(&qc->result_tf, dev); in ata_gen_ata_sense()
1203 static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) in ata_scsi_start_stop_xlat() argument
1205 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_start_stop_xlat()
1206 struct ata_taskfile *tf = &qc->tf; in ata_scsi_start_stop_xlat()
1235 if (qc->dev->flags & ATA_DFLAG_LBA) { in ata_scsi_start_stop_xlat()
1254 if ((qc->ap->flags & ATA_FLAG_NO_POWEROFF_SPINDOWN) && in ata_scsi_start_stop_xlat()
1258 if ((qc->ap->flags & ATA_FLAG_NO_HIBERNATE_SPINDOWN) && in ata_scsi_start_stop_xlat()
1276 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_start_stop_xlat()
1297 static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc) in ata_scsi_flush_xlat() argument
1299 struct ata_taskfile *tf = &qc->tf; in ata_scsi_flush_xlat()
1304 if (qc->dev->flags & ATA_DFLAG_FLUSH_EXT) in ata_scsi_flush_xlat()
1310 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_flush_xlat()
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()
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 int need_sense = (qc->err_mask != 0) && in ata_scsi_qc_complete()
1663 !(qc->flags & ATA_QCFLAG_SENSE_VALID); in ata_scsi_qc_complete()
1676 ata_gen_passthru_sense(qc); in ata_scsi_qc_complete()
1678 ata_gen_ata_sense(qc); in ata_scsi_qc_complete()
1683 ata_qc_done(qc); in ata_scsi_qc_complete()
1716 struct ata_queued_cmd *qc; in ata_scsi_translate() local
1719 qc = ata_scsi_qc_new(dev, cmd); in ata_scsi_translate()
1720 if (!qc) in ata_scsi_translate()
1731 ata_sg_init(qc, scsi_sglist(cmd), scsi_sg_count(cmd)); in ata_scsi_translate()
1733 qc->dma_dir = cmd->sc_data_direction; in ata_scsi_translate()
1736 qc->complete_fn = ata_scsi_qc_complete; in ata_scsi_translate()
1738 if (xlat_func(qc)) in ata_scsi_translate()
1742 if ((rc = ap->ops->qc_defer(qc))) in ata_scsi_translate()
1747 ata_qc_issue(qc); in ata_scsi_translate()
1752 ata_qc_free(qc); in ata_scsi_translate()
1757 ata_qc_free(qc); in ata_scsi_translate()
1764 ata_qc_free(qc); in ata_scsi_translate()
2612 static void atapi_qc_complete(struct ata_queued_cmd *qc) in atapi_qc_complete() argument
2614 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_qc_complete()
2615 unsigned int err_mask = qc->err_mask; in atapi_qc_complete()
2618 if (unlikely(err_mask || qc->flags & ATA_QCFLAG_SENSE_VALID)) { in atapi_qc_complete()
2620 if (!(qc->flags & ATA_QCFLAG_SENSE_VALID)) { in atapi_qc_complete()
2626 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2642 if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev) in atapi_qc_complete()
2643 qc->dev->sdev->locked = 0; in atapi_qc_complete()
2645 qc->scsicmd->result = SAM_STAT_CHECK_CONDITION; in atapi_qc_complete()
2646 ata_qc_done(qc); in atapi_qc_complete()
2655 ata_qc_done(qc); in atapi_qc_complete()
2667 static unsigned int atapi_xlat(struct ata_queued_cmd *qc) in atapi_xlat() argument
2669 struct scsi_cmnd *scmd = qc->scsicmd; in atapi_xlat()
2670 struct ata_device *dev = qc->dev; in atapi_xlat()
2675 memset(qc->cdb, 0, dev->cdb_len); in atapi_xlat()
2676 memcpy(qc->cdb, scmd->cmnd, scmd->cmd_len); in atapi_xlat()
2678 qc->complete_fn = atapi_qc_complete; in atapi_xlat()
2680 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_xlat()
2682 qc->tf.flags |= ATA_TFLAG_WRITE; in atapi_xlat()
2685 qc->tf.command = ATA_CMD_PACKET; in atapi_xlat()
2686 ata_qc_set_pc_nbytes(qc); in atapi_xlat()
2689 if (!nodata && !using_pio && atapi_check_dma(qc)) in atapi_xlat()
2697 nbytes = min(ata_qc_raw_nbytes(qc), (unsigned int)63 * 1024); in atapi_xlat()
2726 qc->tf.lbam = (nbytes & 0xFF); in atapi_xlat()
2727 qc->tf.lbah = (nbytes >> 8); in atapi_xlat()
2730 qc->tf.protocol = ATAPI_PROT_NODATA; in atapi_xlat()
2732 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_xlat()
2735 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_xlat()
2736 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_xlat()
2741 qc->tf.feature |= ATAPI_DMADIR; in atapi_xlat()
2877 static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) in ata_scsi_pass_thru() argument
2879 struct ata_taskfile *tf = &(qc->tf); in ata_scsi_pass_thru()
2880 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_pass_thru()
2881 struct ata_device *dev = qc->dev; in ata_scsi_pass_thru()
2988 tf->nsect = qc->hw_tag << 3; in ata_scsi_pass_thru()
3004 qc->sect_size = scsi_bufflen(scmd); in ata_scsi_pass_thru()
3038 qc->sect_size = scmd->device->sector_size; in ata_scsi_pass_thru()
3043 qc->sect_size = ATA_SECT_SIZE; in ata_scsi_pass_thru()
3055 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; in ata_scsi_pass_thru()
3063 ata_qc_set_pc_nbytes(qc); in ata_scsi_pass_thru()
3199 static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) in ata_scsi_write_same_xlat() argument
3201 struct ata_taskfile *tf = &qc->tf; in ata_scsi_write_same_xlat()
3202 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_write_same_xlat()
3205 struct ata_device *dev = qc->dev; in ata_scsi_write_same_xlat()
3268 tf->nsect = qc->hw_tag << 3; in ata_scsi_write_same_xlat()
3285 ata_qc_set_pc_nbytes(qc); in ata_scsi_write_same_xlat()
3405 static void ata_scsi_report_zones_complete(struct ata_queued_cmd *qc) in ata_scsi_report_zones_complete() argument
3407 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_report_zones_complete()
3465 ata_scsi_qc_complete(qc); in ata_scsi_report_zones_complete()
3468 static unsigned int ata_scsi_zbc_in_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_in_xlat() argument
3470 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_in_xlat()
3471 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_in_xlat()
3479 ata_dev_warn(qc->dev, "invalid cdb length %d\n", in ata_scsi_zbc_in_xlat()
3486 ata_dev_warn(qc->dev, "non-matching transfer count (%d/%d)\n", in ata_scsi_zbc_in_xlat()
3492 ata_dev_warn(qc->dev, "invalid service action %d\n", sa); in ata_scsi_zbc_in_xlat()
3501 ata_dev_warn(qc->dev, "invalid transfer count %d\n", n_block); in ata_scsi_zbc_in_xlat()
3507 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_in_xlat()
3508 ata_fpdma_zac_mgmt_in_supported(qc->dev)) { in ata_scsi_zbc_in_xlat()
3512 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_in_xlat()
3533 qc->flags |= ATA_QCFLAG_RESULT_TF; in ata_scsi_zbc_in_xlat()
3535 ata_qc_set_pc_nbytes(qc); in ata_scsi_zbc_in_xlat()
3537 qc->complete_fn = ata_scsi_report_zones_complete; in ata_scsi_zbc_in_xlat()
3542 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_zbc_in_xlat()
3547 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_in_xlat()
3551 static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_out_xlat() argument
3553 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_out_xlat()
3554 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_out_xlat()
3555 struct ata_device *dev = qc->dev; in ata_scsi_zbc_out_xlat()
3596 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_out_xlat()
3597 ata_fpdma_zac_mgmt_out_supported(qc->dev)) { in ata_scsi_zbc_out_xlat()
3601 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_out_xlat()
3621 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_zbc_out_xlat()
3625 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_out_xlat()
3641 static int ata_mselect_caching(struct ata_queued_cmd *qc, in ata_mselect_caching() argument
3644 struct ata_taskfile *tf = &qc->tf; in ata_mselect_caching()
3645 struct ata_device *dev = qc->dev; in ata_mselect_caching()
3686 static int ata_mselect_control_spg0(struct ata_queued_cmd *qc, in ata_mselect_control_spg0() argument
3689 struct ata_device *dev = qc->dev; in ata_mselect_control_spg0()
3729 static unsigned int ata_mselect_control_ata_feature(struct ata_queued_cmd *qc, in ata_mselect_control_ata_feature() argument
3733 struct ata_device *dev = qc->dev; in ata_mselect_control_ata_feature()
3734 struct ata_taskfile *tf = &qc->tf; in ata_mselect_control_ata_feature()
3790 static int ata_mselect_control(struct ata_queued_cmd *qc, u8 spg, in ata_mselect_control() argument
3795 return ata_mselect_control_spg0(qc, buf, len, fp); in ata_mselect_control()
3797 return ata_mselect_control_ata_feature(qc, buf, len, fp); in ata_mselect_control()
3814 static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc) in ata_scsi_mode_select_xlat() argument
3816 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_mode_select_xlat()
3919 if (qc->dev->flags & ATA_DFLAG_CDL && in ata_scsi_mode_select_xlat()
3934 if (ata_mselect_caching(qc, p, pg_len, &fp) < 0) { in ata_scsi_mode_select_xlat()
3940 ret = ata_mselect_control(qc, spg, p, pg_len, &fp); in ata_scsi_mode_select_xlat()
3964 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_mode_select_xlat()
3968 ata_scsi_set_invalid_parameter(qc->dev, scmd, fp); in ata_scsi_mode_select_xlat()
3973 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_mode_select_xlat()
3991 static unsigned int ata_scsi_security_inout_xlat(struct ata_queued_cmd *qc) in ata_scsi_security_inout_xlat() argument
3993 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_security_inout_xlat()
3995 struct ata_taskfile *tf = &qc->tf; in ata_scsi_security_inout_xlat()
4000 bool dma = !(qc->dev->flags & ATA_DFLAG_PIO); in ata_scsi_security_inout_xlat()
4006 ata_scsi_set_invalid_field(qc->dev, scmd, 1, 0); in ata_scsi_security_inout_xlat()
4012 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
4017 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
4042 ata_qc_set_pc_nbytes(qc); in ata_scsi_security_inout_xlat()
4057 static unsigned int ata_scsi_var_len_cdb_xlat(struct ata_queued_cmd *qc) in ata_scsi_var_len_cdb_xlat() argument
4059 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_var_len_cdb_xlat()
4068 return ata_scsi_pass_thru(qc); in ata_scsi_var_len_cdb_xlat()