Lines Matching refs:qc

45 typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc);
628 struct ata_queued_cmd *qc; in ata_scsi_qc_new() local
630 qc = ata_qc_new_init(dev, cmd->request->tag); in ata_scsi_qc_new()
631 if (qc) { in ata_scsi_qc_new()
632 qc->scsicmd = cmd; in ata_scsi_qc_new()
633 qc->scsidone = cmd->scsi_done; in ata_scsi_qc_new()
635 qc->sg = scsi_sglist(cmd); in ata_scsi_qc_new()
636 qc->n_elem = scsi_sg_count(cmd); in ata_scsi_qc_new()
639 qc->flags |= ATA_QCFLAG_QUIET; in ata_scsi_qc_new()
645 return qc; in ata_scsi_qc_new()
648 static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc) in ata_qc_set_pc_nbytes() argument
650 struct scsi_cmnd *scmd = qc->scsicmd; in ata_qc_set_pc_nbytes()
652 qc->extrabytes = scmd->extra_len; in ata_qc_set_pc_nbytes()
653 qc->nbytes = scsi_bufflen(scmd) + qc->extrabytes; in ata_qc_set_pc_nbytes()
850 static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) in ata_gen_passthru_sense() argument
852 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_passthru_sense()
853 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_passthru_sense()
856 int verbose = qc->ap->ops->error_handler == NULL; 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->command, tf->feature, in ata_gen_passthru_sense()
871 ata_scsi_set_sense(qc->dev, cmd, sense_key, asc, ascq); in ata_gen_passthru_sense()
948 static void ata_gen_ata_sense(struct ata_queued_cmd *qc) in ata_gen_ata_sense() argument
950 struct ata_device *dev = qc->dev; in ata_gen_ata_sense()
951 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_ata_sense()
952 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_ata_sense()
954 int verbose = qc->ap->ops->error_handler == NULL; in ata_gen_ata_sense()
971 if (qc->err_mask || in ata_gen_ata_sense()
973 ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, in ata_gen_ata_sense()
979 tf->command, qc->err_mask); in ata_gen_ata_sense()
984 block = ata_tf_read_block(&qc->result_tf, dev); in ata_gen_ata_sense()
1168 static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) in ata_scsi_start_stop_xlat() argument
1170 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_start_stop_xlat()
1171 struct ata_taskfile *tf = &qc->tf; in ata_scsi_start_stop_xlat()
1200 if (qc->dev->flags & ATA_DFLAG_LBA) { in ata_scsi_start_stop_xlat()
1219 if ((qc->ap->flags & ATA_FLAG_NO_POWEROFF_SPINDOWN) && in ata_scsi_start_stop_xlat()
1223 if ((qc->ap->flags & ATA_FLAG_NO_HIBERNATE_SPINDOWN) && in ata_scsi_start_stop_xlat()
1241 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_start_stop_xlat()
1262 static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc) in ata_scsi_flush_xlat() argument
1264 struct ata_taskfile *tf = &qc->tf; in ata_scsi_flush_xlat()
1269 if (qc->dev->flags & ATA_DFLAG_FLUSH_EXT) in ata_scsi_flush_xlat()
1275 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_flush_xlat()
1383 static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc) in ata_scsi_verify_xlat() argument
1385 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_verify_xlat()
1386 struct ata_taskfile *tf = &qc->tf; in ata_scsi_verify_xlat()
1387 struct ata_device *dev = qc->dev; in ata_scsi_verify_xlat()
1388 u64 dev_sectors = qc->dev->n_sectors; in ata_scsi_verify_xlat()
1486 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_verify_xlat()
1490 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x0); in ata_scsi_verify_xlat()
1532 static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc) in ata_scsi_rw_xlat() argument
1534 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_rw_xlat()
1606 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_rw_xlat()
1607 qc->nbytes = n_block * scmd->device->sector_size; in ata_scsi_rw_xlat()
1609 rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags, in ata_scsi_rw_xlat()
1610 qc->hw_tag, class); in ata_scsi_rw_xlat()
1619 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_rw_xlat()
1623 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x0); in ata_scsi_rw_xlat()
1632 static void ata_qc_done(struct ata_queued_cmd *qc) in ata_qc_done() argument
1634 struct scsi_cmnd *cmd = qc->scsicmd; in ata_qc_done()
1635 void (*done)(struct scsi_cmnd *) = qc->scsidone; in ata_qc_done()
1637 ata_qc_free(qc); in ata_qc_done()
1641 static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) in ata_scsi_qc_complete() argument
1643 struct ata_port *ap = qc->ap; in ata_scsi_qc_complete()
1644 struct scsi_cmnd *cmd = qc->scsicmd; in ata_scsi_qc_complete()
1646 int need_sense = (qc->err_mask != 0); in ata_scsi_qc_complete()
1659 ata_gen_passthru_sense(qc); in ata_scsi_qc_complete()
1660 else if (qc->flags & ATA_QCFLAG_SENSE_VALID) in ata_scsi_qc_complete()
1663 ata_gen_ata_sense(qc); in ata_scsi_qc_complete()
1668 ata_dump_status(ap->print_id, &qc->result_tf); in ata_scsi_qc_complete()
1670 ata_qc_done(qc); in ata_scsi_qc_complete()
1703 struct ata_queued_cmd *qc; in ata_scsi_translate() local
1708 qc = ata_scsi_qc_new(dev, cmd); in ata_scsi_translate()
1709 if (!qc) in ata_scsi_translate()
1720 ata_sg_init(qc, scsi_sglist(cmd), scsi_sg_count(cmd)); in ata_scsi_translate()
1722 qc->dma_dir = cmd->sc_data_direction; in ata_scsi_translate()
1725 qc->complete_fn = ata_scsi_qc_complete; in ata_scsi_translate()
1727 if (xlat_func(qc)) in ata_scsi_translate()
1731 if ((rc = ap->ops->qc_defer(qc))) in ata_scsi_translate()
1736 ata_qc_issue(qc); in ata_scsi_translate()
1742 ata_qc_free(qc); in ata_scsi_translate()
1748 ata_qc_free(qc); in ata_scsi_translate()
1756 ata_qc_free(qc); in ata_scsi_translate()
2501 static void atapi_sense_complete(struct ata_queued_cmd *qc) in atapi_sense_complete() argument
2503 if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) { in atapi_sense_complete()
2509 ata_gen_passthru_sense(qc); in atapi_sense_complete()
2512 ata_qc_done(qc); in atapi_sense_complete()
2521 static void atapi_request_sense(struct ata_queued_cmd *qc) in atapi_request_sense() argument
2523 struct ata_port *ap = qc->ap; in atapi_request_sense()
2524 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_request_sense()
2532 ap->ops->sff_tf_read(ap, &qc->tf); in atapi_request_sense()
2537 cmd->sense_buffer[2] = qc->tf.feature >> 4; in atapi_request_sense()
2539 ata_qc_reinit(qc); in atapi_request_sense()
2542 sg_init_one(&qc->sgent, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); in atapi_request_sense()
2543 ata_sg_init(qc, &qc->sgent, 1); in atapi_request_sense()
2544 qc->dma_dir = DMA_FROM_DEVICE; in atapi_request_sense()
2546 memset(&qc->cdb, 0, qc->dev->cdb_len); in atapi_request_sense()
2547 qc->cdb[0] = REQUEST_SENSE; in atapi_request_sense()
2548 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2550 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_request_sense()
2551 qc->tf.command = ATA_CMD_PACKET; in atapi_request_sense()
2554 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_request_sense()
2555 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_request_sense()
2557 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_request_sense()
2558 qc->tf.lbam = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2559 qc->tf.lbah = 0; in atapi_request_sense()
2561 qc->nbytes = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2563 qc->complete_fn = atapi_sense_complete; in atapi_request_sense()
2565 ata_qc_issue(qc); in atapi_request_sense()
2590 static void atapi_qc_complete(struct ata_queued_cmd *qc) in atapi_qc_complete() argument
2592 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_qc_complete()
2593 unsigned int err_mask = qc->err_mask; in atapi_qc_complete()
2598 if (unlikely(qc->ap->ops->error_handler && in atapi_qc_complete()
2599 (err_mask || qc->flags & ATA_QCFLAG_SENSE_VALID))) { in atapi_qc_complete()
2601 if (!(qc->flags & ATA_QCFLAG_SENSE_VALID)) { in atapi_qc_complete()
2607 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2623 if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev) in atapi_qc_complete()
2624 qc->dev->sdev->locked = 0; in atapi_qc_complete()
2626 qc->scsicmd->result = SAM_STAT_CHECK_CONDITION; in atapi_qc_complete()
2627 ata_qc_done(qc); in atapi_qc_complete()
2634 atapi_request_sense(qc); in atapi_qc_complete()
2642 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2649 ata_qc_done(qc); in atapi_qc_complete()
2661 static unsigned int atapi_xlat(struct ata_queued_cmd *qc) in atapi_xlat() argument
2663 struct scsi_cmnd *scmd = qc->scsicmd; in atapi_xlat()
2664 struct ata_device *dev = qc->dev; in atapi_xlat()
2669 memset(qc->cdb, 0, dev->cdb_len); in atapi_xlat()
2670 memcpy(qc->cdb, scmd->cmnd, scmd->cmd_len); in atapi_xlat()
2672 qc->complete_fn = atapi_qc_complete; in atapi_xlat()
2674 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_xlat()
2676 qc->tf.flags |= ATA_TFLAG_WRITE; in atapi_xlat()
2680 qc->tf.command = ATA_CMD_PACKET; in atapi_xlat()
2681 ata_qc_set_pc_nbytes(qc); in atapi_xlat()
2684 if (!nodata && !using_pio && atapi_check_dma(qc)) in atapi_xlat()
2692 nbytes = min(ata_qc_raw_nbytes(qc), (unsigned int)63 * 1024); in atapi_xlat()
2721 qc->tf.lbam = (nbytes & 0xFF); in atapi_xlat()
2722 qc->tf.lbah = (nbytes >> 8); in atapi_xlat()
2725 qc->tf.protocol = ATAPI_PROT_NODATA; in atapi_xlat()
2727 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_xlat()
2730 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_xlat()
2731 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_xlat()
2736 qc->tf.feature |= ATAPI_DMADIR; in atapi_xlat()
2854 static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) in ata_scsi_pass_thru() argument
2856 struct ata_taskfile *tf = &(qc->tf); in ata_scsi_pass_thru()
2857 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_pass_thru()
2858 struct ata_device *dev = qc->dev; in ata_scsi_pass_thru()
2950 tf->nsect = qc->hw_tag << 3; in ata_scsi_pass_thru()
2966 qc->sect_size = scsi_bufflen(scmd); in ata_scsi_pass_thru()
3000 qc->sect_size = scmd->device->sector_size; in ata_scsi_pass_thru()
3005 qc->sect_size = ATA_SECT_SIZE; in ata_scsi_pass_thru()
3017 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; in ata_scsi_pass_thru()
3025 ata_qc_set_pc_nbytes(qc); in ata_scsi_pass_thru()
3161 static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) in ata_scsi_write_same_xlat() argument
3163 struct ata_taskfile *tf = &qc->tf; in ata_scsi_write_same_xlat()
3164 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_write_same_xlat()
3167 struct ata_device *dev = qc->dev; in ata_scsi_write_same_xlat()
3230 tf->nsect = qc->hw_tag << 3; in ata_scsi_write_same_xlat()
3247 ata_qc_set_pc_nbytes(qc); in ata_scsi_write_same_xlat()
3343 static void ata_scsi_report_zones_complete(struct ata_queued_cmd *qc) in ata_scsi_report_zones_complete() argument
3345 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_report_zones_complete()
3403 ata_scsi_qc_complete(qc); in ata_scsi_report_zones_complete()
3406 static unsigned int ata_scsi_zbc_in_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_in_xlat() argument
3408 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_in_xlat()
3409 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_in_xlat()
3417 ata_dev_warn(qc->dev, "invalid cdb length %d\n", in ata_scsi_zbc_in_xlat()
3424 ata_dev_warn(qc->dev, "non-matching transfer count (%d/%d)\n", in ata_scsi_zbc_in_xlat()
3430 ata_dev_warn(qc->dev, "invalid service action %d\n", sa); in ata_scsi_zbc_in_xlat()
3439 ata_dev_warn(qc->dev, "invalid transfer count %d\n", n_block); in ata_scsi_zbc_in_xlat()
3445 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_in_xlat()
3446 ata_fpdma_zac_mgmt_in_supported(qc->dev)) { in ata_scsi_zbc_in_xlat()
3450 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_in_xlat()
3471 qc->flags |= ATA_QCFLAG_RESULT_TF; in ata_scsi_zbc_in_xlat()
3473 ata_qc_set_pc_nbytes(qc); in ata_scsi_zbc_in_xlat()
3475 qc->complete_fn = ata_scsi_report_zones_complete; in ata_scsi_zbc_in_xlat()
3480 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_zbc_in_xlat()
3485 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_in_xlat()
3489 static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_out_xlat() argument
3491 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_out_xlat()
3492 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_out_xlat()
3493 struct ata_device *dev = qc->dev; in ata_scsi_zbc_out_xlat()
3534 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_out_xlat()
3535 ata_fpdma_zac_mgmt_out_supported(qc->dev)) { in ata_scsi_zbc_out_xlat()
3539 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_out_xlat()
3559 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_zbc_out_xlat()
3563 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_out_xlat()
3579 static int ata_mselect_caching(struct ata_queued_cmd *qc, in ata_mselect_caching() argument
3582 struct ata_taskfile *tf = &qc->tf; in ata_mselect_caching()
3583 struct ata_device *dev = qc->dev; in ata_mselect_caching()
3636 static int ata_mselect_control(struct ata_queued_cmd *qc, in ata_mselect_control() argument
3639 struct ata_device *dev = qc->dev; in ata_mselect_control()
3689 static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc) in ata_scsi_mode_select_xlat() argument
3691 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_mode_select_xlat()
3795 if (ata_mselect_caching(qc, p, pg_len, &fp) < 0) { in ata_scsi_mode_select_xlat()
3801 if (ata_mselect_control(qc, p, pg_len, &fp) < 0) { in ata_scsi_mode_select_xlat()
3823 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_mode_select_xlat()
3827 ata_scsi_set_invalid_parameter(qc->dev, scmd, fp); in ata_scsi_mode_select_xlat()
3832 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_mode_select_xlat()
3850 static unsigned int ata_scsi_security_inout_xlat(struct ata_queued_cmd *qc) in ata_scsi_security_inout_xlat() argument
3852 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_security_inout_xlat()
3854 struct ata_taskfile *tf = &qc->tf; in ata_scsi_security_inout_xlat()
3859 bool dma = !(qc->dev->flags & ATA_DFLAG_PIO); in ata_scsi_security_inout_xlat()
3865 ata_scsi_set_invalid_field(qc->dev, scmd, 1, 0); in ata_scsi_security_inout_xlat()
3871 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
3876 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
3901 ata_qc_set_pc_nbytes(qc); in ata_scsi_security_inout_xlat()
3916 static unsigned int ata_scsi_var_len_cdb_xlat(struct ata_queued_cmd *qc) in ata_scsi_var_len_cdb_xlat() argument
3918 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_var_len_cdb_xlat()
3927 return ata_scsi_pass_thru(qc); in ata_scsi_var_len_cdb_xlat()