Lines Matching refs:qc

45 typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc);
642 struct ata_queued_cmd *qc; in ata_scsi_qc_new() local
660 qc = __ata_qc_from_tag(ap, tag); in ata_scsi_qc_new()
661 qc->tag = qc->hw_tag = tag; in ata_scsi_qc_new()
662 qc->ap = ap; in ata_scsi_qc_new()
663 qc->dev = dev; in ata_scsi_qc_new()
665 ata_qc_reinit(qc); in ata_scsi_qc_new()
667 qc->scsicmd = cmd; in ata_scsi_qc_new()
668 qc->scsidone = scsi_done; in ata_scsi_qc_new()
670 qc->sg = scsi_sglist(cmd); in ata_scsi_qc_new()
671 qc->n_elem = scsi_sg_count(cmd); in ata_scsi_qc_new()
674 qc->flags |= ATA_QCFLAG_QUIET; in ata_scsi_qc_new()
676 return qc; in ata_scsi_qc_new()
685 static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc) in ata_qc_set_pc_nbytes() argument
687 struct scsi_cmnd *scmd = qc->scsicmd; in ata_qc_set_pc_nbytes()
689 qc->extrabytes = scmd->extra_len; in ata_qc_set_pc_nbytes()
690 qc->nbytes = scsi_bufflen(scmd) + qc->extrabytes; in ata_qc_set_pc_nbytes()
882 static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) in ata_gen_passthru_sense() argument
884 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_passthru_sense()
885 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_passthru_sense()
888 int verbose = qc->ap->ops->error_handler == NULL; in ata_gen_passthru_sense()
897 if (qc->err_mask || in ata_gen_passthru_sense()
899 ata_to_sense_error(qc->ap->print_id, tf->status, tf->error, in ata_gen_passthru_sense()
901 ata_scsi_set_sense(qc->dev, cmd, sense_key, asc, ascq); in ata_gen_passthru_sense()
977 static void ata_gen_ata_sense(struct ata_queued_cmd *qc) in ata_gen_ata_sense() argument
979 struct ata_device *dev = qc->dev; in ata_gen_ata_sense()
980 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_ata_sense()
981 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_ata_sense()
983 int verbose = qc->ap->ops->error_handler == NULL; in ata_gen_ata_sense()
998 if (qc->err_mask || in ata_gen_ata_sense()
1000 ata_to_sense_error(qc->ap->print_id, tf->status, tf->error, in ata_gen_ata_sense()
1006 tf->status, qc->err_mask); in ata_gen_ata_sense()
1011 block = ata_tf_read_block(&qc->result_tf, dev); in ata_gen_ata_sense()
1195 static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) in ata_scsi_start_stop_xlat() argument
1197 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_start_stop_xlat()
1198 struct ata_taskfile *tf = &qc->tf; in ata_scsi_start_stop_xlat()
1227 if (qc->dev->flags & ATA_DFLAG_LBA) { in ata_scsi_start_stop_xlat()
1246 if ((qc->ap->flags & ATA_FLAG_NO_POWEROFF_SPINDOWN) && in ata_scsi_start_stop_xlat()
1250 if ((qc->ap->flags & ATA_FLAG_NO_HIBERNATE_SPINDOWN) && in ata_scsi_start_stop_xlat()
1268 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_start_stop_xlat()
1289 static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc) in ata_scsi_flush_xlat() argument
1291 struct ata_taskfile *tf = &qc->tf; in ata_scsi_flush_xlat()
1296 if (qc->dev->flags & ATA_DFLAG_FLUSH_EXT) in ata_scsi_flush_xlat()
1302 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_flush_xlat()
1376 static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc) in ata_scsi_verify_xlat() argument
1378 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_verify_xlat()
1379 struct ata_taskfile *tf = &qc->tf; in ata_scsi_verify_xlat()
1380 struct ata_device *dev = qc->dev; in ata_scsi_verify_xlat()
1381 u64 dev_sectors = qc->dev->n_sectors; in ata_scsi_verify_xlat()
1479 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_verify_xlat()
1483 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x0); in ata_scsi_verify_xlat()
1525 static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc) in ata_scsi_rw_xlat() argument
1527 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_rw_xlat()
1603 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_rw_xlat()
1604 qc->nbytes = n_block * scmd->device->sector_size; in ata_scsi_rw_xlat()
1606 rc = ata_build_rw_tf(qc, block, n_block, tf_flags, class); in ata_scsi_rw_xlat()
1614 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_rw_xlat()
1618 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x0); in ata_scsi_rw_xlat()
1627 static void ata_qc_done(struct ata_queued_cmd *qc) in ata_qc_done() argument
1629 struct scsi_cmnd *cmd = qc->scsicmd; in ata_qc_done()
1630 void (*done)(struct scsi_cmnd *) = qc->scsidone; in ata_qc_done()
1632 ata_qc_free(qc); in ata_qc_done()
1636 static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) in ata_scsi_qc_complete() argument
1638 struct ata_port *ap = qc->ap; in ata_scsi_qc_complete()
1639 struct scsi_cmnd *cmd = qc->scsicmd; in ata_scsi_qc_complete()
1641 int need_sense = (qc->err_mask != 0); in ata_scsi_qc_complete()
1654 ata_gen_passthru_sense(qc); in ata_scsi_qc_complete()
1655 else if (qc->flags & ATA_QCFLAG_SENSE_VALID) in ata_scsi_qc_complete()
1658 ata_gen_ata_sense(qc); in ata_scsi_qc_complete()
1663 ata_dump_status(ap, &qc->result_tf); in ata_scsi_qc_complete()
1665 ata_qc_done(qc); in ata_scsi_qc_complete()
1698 struct ata_queued_cmd *qc; in ata_scsi_translate() local
1701 qc = ata_scsi_qc_new(dev, cmd); in ata_scsi_translate()
1702 if (!qc) in ata_scsi_translate()
1713 ata_sg_init(qc, scsi_sglist(cmd), scsi_sg_count(cmd)); in ata_scsi_translate()
1715 qc->dma_dir = cmd->sc_data_direction; in ata_scsi_translate()
1718 qc->complete_fn = ata_scsi_qc_complete; in ata_scsi_translate()
1720 if (xlat_func(qc)) in ata_scsi_translate()
1724 if ((rc = ap->ops->qc_defer(qc))) in ata_scsi_translate()
1729 ata_qc_issue(qc); in ata_scsi_translate()
1734 ata_qc_free(qc); in ata_scsi_translate()
1739 ata_qc_free(qc); in ata_scsi_translate()
1746 ata_qc_free(qc); in ata_scsi_translate()
2465 static void atapi_sense_complete(struct ata_queued_cmd *qc) in atapi_sense_complete() argument
2467 if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) { in atapi_sense_complete()
2473 ata_gen_passthru_sense(qc); in atapi_sense_complete()
2476 ata_qc_done(qc); in atapi_sense_complete()
2485 static void atapi_request_sense(struct ata_queued_cmd *qc) in atapi_request_sense() argument
2487 struct ata_port *ap = qc->ap; in atapi_request_sense()
2488 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_request_sense()
2494 ap->ops->sff_tf_read(ap, &qc->tf); in atapi_request_sense()
2499 cmd->sense_buffer[2] = qc->tf.error >> 4; in atapi_request_sense()
2501 ata_qc_reinit(qc); in atapi_request_sense()
2504 sg_init_one(&qc->sgent, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); in atapi_request_sense()
2505 ata_sg_init(qc, &qc->sgent, 1); in atapi_request_sense()
2506 qc->dma_dir = DMA_FROM_DEVICE; in atapi_request_sense()
2508 memset(&qc->cdb, 0, qc->dev->cdb_len); in atapi_request_sense()
2509 qc->cdb[0] = REQUEST_SENSE; in atapi_request_sense()
2510 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2512 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_request_sense()
2513 qc->tf.command = ATA_CMD_PACKET; in atapi_request_sense()
2516 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_request_sense()
2517 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_request_sense()
2519 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_request_sense()
2520 qc->tf.lbam = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2521 qc->tf.lbah = 0; in atapi_request_sense()
2523 qc->nbytes = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2525 qc->complete_fn = atapi_sense_complete; in atapi_request_sense()
2527 ata_qc_issue(qc); in atapi_request_sense()
2550 static void atapi_qc_complete(struct ata_queued_cmd *qc) in atapi_qc_complete() argument
2552 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_qc_complete()
2553 unsigned int err_mask = qc->err_mask; in atapi_qc_complete()
2556 if (unlikely(qc->ap->ops->error_handler && in atapi_qc_complete()
2557 (err_mask || qc->flags & ATA_QCFLAG_SENSE_VALID))) { in atapi_qc_complete()
2559 if (!(qc->flags & ATA_QCFLAG_SENSE_VALID)) { in atapi_qc_complete()
2565 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2581 if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev) in atapi_qc_complete()
2582 qc->dev->sdev->locked = 0; in atapi_qc_complete()
2584 qc->scsicmd->result = SAM_STAT_CHECK_CONDITION; in atapi_qc_complete()
2585 ata_qc_done(qc); in atapi_qc_complete()
2592 atapi_request_sense(qc); in atapi_qc_complete()
2600 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2607 ata_qc_done(qc); in atapi_qc_complete()
2619 static unsigned int atapi_xlat(struct ata_queued_cmd *qc) in atapi_xlat() argument
2621 struct scsi_cmnd *scmd = qc->scsicmd; in atapi_xlat()
2622 struct ata_device *dev = qc->dev; in atapi_xlat()
2627 memset(qc->cdb, 0, dev->cdb_len); in atapi_xlat()
2628 memcpy(qc->cdb, scmd->cmnd, scmd->cmd_len); in atapi_xlat()
2630 qc->complete_fn = atapi_qc_complete; in atapi_xlat()
2632 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_xlat()
2634 qc->tf.flags |= ATA_TFLAG_WRITE; in atapi_xlat()
2637 qc->tf.command = ATA_CMD_PACKET; in atapi_xlat()
2638 ata_qc_set_pc_nbytes(qc); in atapi_xlat()
2641 if (!nodata && !using_pio && atapi_check_dma(qc)) in atapi_xlat()
2649 nbytes = min(ata_qc_raw_nbytes(qc), (unsigned int)63 * 1024); in atapi_xlat()
2678 qc->tf.lbam = (nbytes & 0xFF); in atapi_xlat()
2679 qc->tf.lbah = (nbytes >> 8); in atapi_xlat()
2682 qc->tf.protocol = ATAPI_PROT_NODATA; in atapi_xlat()
2684 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_xlat()
2687 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_xlat()
2688 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_xlat()
2693 qc->tf.feature |= ATAPI_DMADIR; in atapi_xlat()
2811 static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) in ata_scsi_pass_thru() argument
2813 struct ata_taskfile *tf = &(qc->tf); in ata_scsi_pass_thru()
2814 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_pass_thru()
2815 struct ata_device *dev = qc->dev; in ata_scsi_pass_thru()
2922 tf->nsect = qc->hw_tag << 3; in ata_scsi_pass_thru()
2938 qc->sect_size = scsi_bufflen(scmd); in ata_scsi_pass_thru()
2972 qc->sect_size = scmd->device->sector_size; in ata_scsi_pass_thru()
2977 qc->sect_size = ATA_SECT_SIZE; in ata_scsi_pass_thru()
2989 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; in ata_scsi_pass_thru()
2997 ata_qc_set_pc_nbytes(qc); in ata_scsi_pass_thru()
3133 static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) in ata_scsi_write_same_xlat() argument
3135 struct ata_taskfile *tf = &qc->tf; in ata_scsi_write_same_xlat()
3136 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_write_same_xlat()
3139 struct ata_device *dev = qc->dev; in ata_scsi_write_same_xlat()
3202 tf->nsect = qc->hw_tag << 3; in ata_scsi_write_same_xlat()
3219 ata_qc_set_pc_nbytes(qc); in ata_scsi_write_same_xlat()
3316 static void ata_scsi_report_zones_complete(struct ata_queued_cmd *qc) in ata_scsi_report_zones_complete() argument
3318 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_report_zones_complete()
3376 ata_scsi_qc_complete(qc); in ata_scsi_report_zones_complete()
3379 static unsigned int ata_scsi_zbc_in_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_in_xlat() argument
3381 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_in_xlat()
3382 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_in_xlat()
3390 ata_dev_warn(qc->dev, "invalid cdb length %d\n", in ata_scsi_zbc_in_xlat()
3397 ata_dev_warn(qc->dev, "non-matching transfer count (%d/%d)\n", in ata_scsi_zbc_in_xlat()
3403 ata_dev_warn(qc->dev, "invalid service action %d\n", sa); in ata_scsi_zbc_in_xlat()
3412 ata_dev_warn(qc->dev, "invalid transfer count %d\n", n_block); in ata_scsi_zbc_in_xlat()
3418 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_in_xlat()
3419 ata_fpdma_zac_mgmt_in_supported(qc->dev)) { in ata_scsi_zbc_in_xlat()
3423 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_in_xlat()
3444 qc->flags |= ATA_QCFLAG_RESULT_TF; in ata_scsi_zbc_in_xlat()
3446 ata_qc_set_pc_nbytes(qc); in ata_scsi_zbc_in_xlat()
3448 qc->complete_fn = ata_scsi_report_zones_complete; in ata_scsi_zbc_in_xlat()
3453 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_zbc_in_xlat()
3458 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_in_xlat()
3462 static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_out_xlat() argument
3464 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_out_xlat()
3465 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_out_xlat()
3466 struct ata_device *dev = qc->dev; in ata_scsi_zbc_out_xlat()
3507 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_out_xlat()
3508 ata_fpdma_zac_mgmt_out_supported(qc->dev)) { in ata_scsi_zbc_out_xlat()
3512 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_out_xlat()
3532 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_zbc_out_xlat()
3536 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_out_xlat()
3552 static int ata_mselect_caching(struct ata_queued_cmd *qc, in ata_mselect_caching() argument
3555 struct ata_taskfile *tf = &qc->tf; in ata_mselect_caching()
3556 struct ata_device *dev = qc->dev; in ata_mselect_caching()
3606 static int ata_mselect_control(struct ata_queued_cmd *qc, in ata_mselect_control() argument
3609 struct ata_device *dev = qc->dev; in ata_mselect_control()
3656 static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc) in ata_scsi_mode_select_xlat() argument
3658 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_mode_select_xlat()
3760 if (ata_mselect_caching(qc, p, pg_len, &fp) < 0) { in ata_scsi_mode_select_xlat()
3766 if (ata_mselect_control(qc, p, pg_len, &fp) < 0) { in ata_scsi_mode_select_xlat()
3788 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_mode_select_xlat()
3792 ata_scsi_set_invalid_parameter(qc->dev, scmd, fp); in ata_scsi_mode_select_xlat()
3797 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_mode_select_xlat()
3815 static unsigned int ata_scsi_security_inout_xlat(struct ata_queued_cmd *qc) in ata_scsi_security_inout_xlat() argument
3817 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_security_inout_xlat()
3819 struct ata_taskfile *tf = &qc->tf; in ata_scsi_security_inout_xlat()
3824 bool dma = !(qc->dev->flags & ATA_DFLAG_PIO); in ata_scsi_security_inout_xlat()
3830 ata_scsi_set_invalid_field(qc->dev, scmd, 1, 0); in ata_scsi_security_inout_xlat()
3836 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
3841 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
3866 ata_qc_set_pc_nbytes(qc); in ata_scsi_security_inout_xlat()
3881 static unsigned int ata_scsi_var_len_cdb_xlat(struct ata_queued_cmd *qc) in ata_scsi_var_len_cdb_xlat() argument
3883 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_var_len_cdb_xlat()
3892 return ata_scsi_pass_thru(qc); in ata_scsi_var_len_cdb_xlat()