Lines Matching full:scp
926 static void mk_sense_invalid_fld(struct scsi_cmnd *scp, in mk_sense_invalid_fld() argument
934 sbuff = scp->sense_buffer; in mk_sense_invalid_fld()
936 sdev_printk(KERN_ERR, scp->device, in mk_sense_invalid_fld()
942 scsi_build_sense(scp, sdebug_dsense, ILLEGAL_REQUEST, asc, 0); in mk_sense_invalid_fld()
961 sdev_printk(KERN_INFO, scp->device, "%s: [sense_key,asc,ascq" in mk_sense_invalid_fld()
966 static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) in mk_sense_buffer() argument
968 if (!scp->sense_buffer) { in mk_sense_buffer()
969 sdev_printk(KERN_ERR, scp->device, in mk_sense_buffer()
973 memset(scp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in mk_sense_buffer()
975 scsi_build_sense(scp, sdebug_dsense, key, asc, asq); in mk_sense_buffer()
978 sdev_printk(KERN_INFO, scp->device, in mk_sense_buffer()
983 static void mk_sense_invalid_opcode(struct scsi_cmnd *scp) in mk_sense_invalid_opcode() argument
985 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_OPCODE, 0); in mk_sense_invalid_opcode()
1078 static int make_ua(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in make_ua() argument
1088 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1094 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1100 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1106 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
1112 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
1118 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1125 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1142 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1156 sdev_printk(KERN_INFO, scp->device, in make_ua()
1165 static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fill_from_dev_buffer() argument
1169 struct scsi_data_buffer *sdb = &scp->sdb; in fill_from_dev_buffer()
1173 if (scp->sc_data_direction != DMA_FROM_DEVICE) in fill_from_dev_buffer()
1178 scsi_set_resid(scp, scsi_bufflen(scp) - act_len); in fill_from_dev_buffer()
1188 static int p_fill_from_dev_buffer(struct scsi_cmnd *scp, const void *arr, in p_fill_from_dev_buffer() argument
1192 struct scsi_data_buffer *sdb = &scp->sdb; in p_fill_from_dev_buffer()
1197 if (scp->sc_data_direction != DMA_FROM_DEVICE) in p_fill_from_dev_buffer()
1203 __func__, off_dst, scsi_bufflen(scp), act_len, in p_fill_from_dev_buffer()
1204 scsi_get_resid(scp)); in p_fill_from_dev_buffer()
1205 n = scsi_bufflen(scp) - (off_dst + act_len); in p_fill_from_dev_buffer()
1206 scsi_set_resid(scp, min_t(u32, scsi_get_resid(scp), n)); in p_fill_from_dev_buffer()
1213 static int fetch_to_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fetch_to_dev_buffer() argument
1216 if (!scsi_bufflen(scp)) in fetch_to_dev_buffer()
1218 if (scp->sc_data_direction != DMA_TO_DEVICE) in fetch_to_dev_buffer()
1221 return scsi_sg_copy_to_buffer(scp, arr, arr_len); in fetch_to_dev_buffer()
1580 static int resp_inquiry(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_inquiry() argument
1584 unsigned char *cmd = scp->cmnd; in resp_inquiry()
1596 have_wlun = scsi_is_wlun(scp->device->lun); in resp_inquiry()
1605 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 1); in resp_inquiry()
1697 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_inquiry()
1702 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
1738 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
1748 static int resp_requests(struct scsi_cmnd *scp, in resp_requests() argument
1751 unsigned char *cmd = scp->cmnd; in resp_requests()
1799 return fill_from_dev_buffer(scp, arr, min_t(u32, len, alloc_len)); in resp_requests()
1802 static int resp_start_stop(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_start_stop() argument
1804 unsigned char *cmd = scp->cmnd; in resp_start_stop()
1810 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 7); in resp_start_stop()
1831 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 0 /* START bit */); in resp_start_stop()
1857 static int resp_readcap(struct scsi_cmnd *scp, in resp_readcap() argument
1872 return fill_from_dev_buffer(scp, arr, SDEBUG_READCAP_ARR_SZ); in resp_readcap()
1876 static int resp_readcap16(struct scsi_cmnd *scp, in resp_readcap16() argument
1879 unsigned char *cmd = scp->cmnd; in resp_readcap16()
1916 return fill_from_dev_buffer(scp, arr, in resp_readcap16()
1922 static int resp_report_tgtpgs(struct scsi_cmnd *scp, in resp_report_tgtpgs() argument
1925 unsigned char *cmd = scp->cmnd; in resp_report_tgtpgs()
1993 ret = fill_from_dev_buffer(scp, arr, in resp_report_tgtpgs()
1999 static int resp_rsup_opcodes(struct scsi_cmnd *scp, in resp_rsup_opcodes() argument
2010 u8 *cmd = scp->cmnd; in resp_rsup_opcodes()
2018 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_opcodes()
2027 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_rsup_opcodes()
2088 mk_sense_invalid_fld(scp, SDEB_IN_CDB, in resp_rsup_opcodes()
2096 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, -1); in resp_rsup_opcodes()
2139 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_rsup_opcodes()
2145 errsts = fill_from_dev_buffer(scp, arr, len); in resp_rsup_opcodes()
2150 static int resp_rsup_tmfs(struct scsi_cmnd *scp, in resp_rsup_tmfs() argument
2156 u8 *cmd = scp->cmnd; in resp_rsup_tmfs()
2162 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_tmfs()
2174 return fill_from_dev_buffer(scp, arr, len); in resp_rsup_tmfs()
2339 static int resp_mode_sense(struct scsi_cmnd *scp, in resp_mode_sense() argument
2346 int target = scp->device->id; in resp_mode_sense()
2349 unsigned char *cmd = scp->cmnd; in resp_mode_sense()
2367 mk_sense_buffer(scp, ILLEGAL_REQUEST, SAVING_PARAMS_UNSUP, 0); in resp_mode_sense()
2411 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2445 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2485 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2494 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_mode_sense()
2501 return fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, offset)); in resp_mode_sense()
2506 static int resp_mode_select(struct scsi_cmnd *scp, in resp_mode_select() argument
2512 unsigned char *cmd = scp->cmnd; in resp_mode_select()
2520 mk_sense_invalid_fld(scp, SDEB_IN_CDB, mselect6 ? 4 : 7, -1); in resp_mode_select()
2523 res = fetch_to_dev_buffer(scp, arr, param_len); in resp_mode_select()
2527 sdev_printk(KERN_INFO, scp->device, in resp_mode_select()
2534 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 0, -1); in resp_mode_select()
2540 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 7); in resp_mode_select()
2547 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_mode_select()
2581 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 5); in resp_mode_select()
2625 static int resp_log_sense(struct scsi_cmnd *scp, in resp_log_sense() argument
2631 unsigned char *cmd = scp->cmnd; in resp_log_sense()
2637 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, ppc ? 1 : 0); in resp_log_sense()
2660 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2704 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2713 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2717 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_log_sense()
2721 return fill_from_dev_buffer(scp, arr, in resp_log_sense()
2896 static int check_zbc_access_params(struct scsi_cmnd *scp, in check_zbc_access_params() argument
2899 struct scsi_device *sdp = scp->device; in check_zbc_access_params()
2909 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2919 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, in check_zbc_access_params()
2927 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2938 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2945 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2951 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2962 mk_sense_buffer(scp, DATA_PROTECT, in check_zbc_access_params()
2974 (struct scsi_cmnd *scp, unsigned long long lba, in check_device_access_params() argument
2977 struct scsi_device *sdp = scp->device; in check_device_access_params()
2981 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in check_device_access_params()
2987 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in check_device_access_params()
2991 mk_sense_buffer(scp, DATA_PROTECT, WRITE_PROTECTED, 0x2); in check_device_access_params()
2995 return check_zbc_access_params(scp, lba, num, write); in check_device_access_params()
3017 static int do_device_access(struct sdeb_store_info *sip, struct scsi_cmnd *scp, in do_device_access() argument
3023 struct scsi_data_buffer *sdb = &scp->sdb; in do_device_access()
3035 if (scp->sc_data_direction != dir) in do_device_access()
3060 static int do_dout_fetch(struct scsi_cmnd *scp, u32 num, u8 *doutp) in do_dout_fetch() argument
3062 struct scsi_data_buffer *sdb = &scp->sdb; in do_dout_fetch()
3066 if (scp->sc_data_direction != DMA_TO_DEVICE) in do_dout_fetch()
3144 static void dif_copy_prot(struct scsi_cmnd *scp, sector_t sector, in dif_copy_prot() argument
3150 scp->device->hostdata, true); in dif_copy_prot()
3158 sg_miter_start(&miter, scsi_prot_sglist(scp), in dif_copy_prot()
3159 scsi_prot_sg_count(scp), SG_MITER_ATOMIC | in dif_copy_prot()
3190 static int prot_verify_read(struct scsi_cmnd *scp, sector_t start_sec, in prot_verify_read() argument
3197 scp->device->hostdata, true); in prot_verify_read()
3214 if (scp->cmnd[1] >> 5) { /* RDPROTECT */ in prot_verify_read()
3224 dif_copy_prot(scp, start_sec, sectors, true); in prot_verify_read()
3294 static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_read_dt0() argument
3302 u8 *cmd = scp->cmnd; in resp_read_dt0()
3346 mk_sense_invalid_opcode(scp); in resp_read_dt0()
3352 sdev_printk(KERN_ERR, scp->device, "Unprotected RD " in resp_read_dt0()
3361 ret = check_device_access_params(scp, lba, num, false); in resp_read_dt0()
3368 mk_sense_buffer(scp, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 0); in resp_read_dt0()
3370 if (0x70 == (scp->sense_buffer[0] & 0x7f)) { in resp_read_dt0()
3371 scp->sense_buffer[0] |= 0x80; /* Valid bit */ in resp_read_dt0()
3374 put_unaligned_be32(ret, scp->sense_buffer + 3); in resp_read_dt0()
3376 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_read_dt0()
3383 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_read_dt0()
3384 switch (prot_verify_read(scp, lba, num, ei_lba)) { in resp_read_dt0()
3388 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
3390 } else if (scp->prot_flags & SCSI_PROT_GUARD_CHECK) { in resp_read_dt0()
3392 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
3399 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 3); in resp_read_dt0()
3401 } else if (scp->prot_flags & SCSI_PROT_REF_CHECK) { in resp_read_dt0()
3403 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 3); in resp_read_dt0()
3410 ret = do_device_access(sip, scp, 0, lba, num, false); in resp_read_dt0()
3415 scsi_set_resid(scp, scsi_bufflen(scp) - ret); in resp_read_dt0()
3420 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_read_dt0()
3425 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
3429 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
3591 static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_dt0() argument
3599 u8 *cmd = scp->cmnd; in resp_write_dt0()
3643 mk_sense_invalid_opcode(scp); in resp_write_dt0()
3649 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_write_dt0()
3654 ret = check_device_access_params(scp, lba, num, true); in resp_write_dt0()
3661 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_dt0()
3662 switch (prot_verify_write(scp, lba, num, ei_lba)) { in resp_write_dt0()
3664 if (scp->prot_flags & SCSI_PROT_GUARD_CHECK) { in resp_write_dt0()
3666 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
3668 } else if (scp->cmnd[1] >> 5 != 3) { /* WRPROTECT != 3 */ in resp_write_dt0()
3670 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
3675 if (scp->prot_flags & SCSI_PROT_REF_CHECK) { in resp_write_dt0()
3677 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 3); in resp_write_dt0()
3679 } else if (scp->cmnd[1] >> 5 != 3) { /* WRPROTECT != 3 */ in resp_write_dt0()
3681 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 3); in resp_write_dt0()
3688 ret = do_device_access(sip, scp, 0, lba, num, true); in resp_write_dt0()
3699 sdev_printk(KERN_INFO, scp->device, in resp_write_dt0()
3706 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_write_dt0()
3711 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
3715 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
3727 static int resp_write_scat(struct scsi_cmnd *scp, in resp_write_scat() argument
3730 u8 *cmd = scp->cmnd; in resp_write_scat()
3759 mk_sense_invalid_opcode(scp); in resp_write_scat()
3765 sdev_printk(KERN_ERR, scp->device, in resp_write_scat()
3773 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3776 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
3782 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3785 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
3792 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3795 res = fetch_to_dev_buffer(scp, lrdp, lbdof_blen); in resp_write_scat()
3809 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3814 ret = check_device_access_params(scp, lba, num, true); in resp_write_scat()
3822 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3825 mk_sense_buffer(scp, ILLEGAL_REQUEST, WRITE_ERROR_ASC, in resp_write_scat()
3832 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_scat()
3833 int prot_ret = prot_verify_write(scp, lba, num, in resp_write_scat()
3837 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, in resp_write_scat()
3844 ret = do_device_access(sip, scp, sg_off, lba, num, true); in resp_write_scat()
3854 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3861 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_write_scat()
3867 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_scat()
3872 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_scat()
3889 static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num, in resp_write_same() argument
3892 struct scsi_device *sdp = scp->device; in resp_write_same()
3899 scp->device->hostdata, true); in resp_write_same()
3905 ret = check_device_access_params(scp, lba, num, true); in resp_write_same()
3924 ret = fetch_to_dev_buffer(scp, fs1p, lb_size); in resp_write_same()
3930 sdev_printk(KERN_INFO, scp->device, in resp_write_same()
3951 static int resp_write_same_10(struct scsi_cmnd *scp, in resp_write_same_10() argument
3954 u8 *cmd = scp->cmnd; in resp_write_same_10()
3962 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_10()
3970 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_write_same_10()
3973 return resp_write_same(scp, lba, num, ei_lba, unmap, false); in resp_write_same_10()
3976 static int resp_write_same_16(struct scsi_cmnd *scp, in resp_write_same_16() argument
3979 u8 *cmd = scp->cmnd; in resp_write_same_16()
3988 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_16()
3998 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 10, -1); in resp_write_same_16()
4001 return resp_write_same(scp, lba, num, ei_lba, unmap, ndob); in resp_write_same_16()
4007 static int resp_write_buffer(struct scsi_cmnd *scp, in resp_write_buffer() argument
4010 u8 *cmd = scp->cmnd; in resp_write_buffer()
4011 struct scsi_device *sdp = scp->device; in resp_write_buffer()
4053 static int resp_comp_write(struct scsi_cmnd *scp, in resp_comp_write() argument
4056 u8 *cmd = scp->cmnd; in resp_comp_write()
4072 mk_sense_invalid_opcode(scp); in resp_comp_write()
4078 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_comp_write()
4080 ret = check_device_access_params(scp, lba, num, false); in resp_comp_write()
4086 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_comp_write()
4093 ret = do_dout_fetch(scp, dnum, arr); in resp_comp_write()
4098 sdev_printk(KERN_INFO, scp->device, "%s: compare_write: cdb " in resp_comp_write()
4102 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_comp_write()
4120 static int resp_unmap(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_unmap() argument
4130 payload_len = get_unaligned_be16(scp->cmnd + 7); in resp_unmap()
4131 BUG_ON(scsi_bufflen(scp) != payload_len); in resp_unmap()
4135 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_unmap()
4139 buf = kzalloc(scsi_bufflen(scp), GFP_ATOMIC); in resp_unmap()
4141 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_unmap()
4146 scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); in resp_unmap()
4159 ret = check_device_access_params(scp, lba, num, true); in resp_unmap()
4177 static int resp_get_lba_status(struct scsi_cmnd *scp, in resp_get_lba_status() argument
4180 u8 *cmd = scp->cmnd; in resp_get_lba_status()
4192 ret = check_device_access_params(scp, lba, 1, false); in resp_get_lba_status()
4216 return fill_from_dev_buffer(scp, arr, SDEBUG_GET_LBA_STATUS_LEN); in resp_get_lba_status()
4219 static int resp_sync_cache(struct scsi_cmnd *scp, in resp_sync_cache() argument
4225 u8 *cmd = scp->cmnd; in resp_sync_cache()
4235 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_sync_cache()
4252 static int resp_pre_fetch(struct scsi_cmnd *scp, in resp_pre_fetch() argument
4259 u8 *cmd = scp->cmnd; in resp_pre_fetch()
4271 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_pre_fetch()
4304 static int resp_report_luns(struct scsi_cmnd *scp, in resp_report_luns() argument
4307 unsigned char *cmd = scp->cmnd; in resp_report_luns()
4328 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_report_luns()
4350 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_report_luns()
4359 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_report_luns()
4383 res = p_fill_from_dev_buffer(scp, arr, n, off_rsp); in resp_report_luns()
4393 res = p_fill_from_dev_buffer(scp, arr, j * sz_lun, off_rsp); in resp_report_luns()
4397 static int resp_verify(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_verify() argument
4406 u8 *cmd = scp->cmnd; in resp_verify()
4413 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_verify()
4428 mk_sense_invalid_opcode(scp); in resp_verify()
4435 ret = check_device_access_params(scp, lba, a_num, false); in resp_verify()
4441 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_verify()
4448 ret = do_dout_fetch(scp, a_num, arr); in resp_verify()
4453 sdev_printk(KERN_INFO, scp->device, in resp_verify()
4463 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_verify()
4476 static int resp_report_zones(struct scsi_cmnd *scp, in resp_report_zones() argument
4485 u8 *cmd = scp->cmnd; in resp_report_zones()
4490 mk_sense_invalid_opcode(scp); in resp_report_zones()
4501 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_report_zones()
4509 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_report_zones()
4575 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_report_zones()
4609 ret = fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, rep_len)); in resp_report_zones()
4629 static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_open_zone() argument
4634 u8 *cmd = scp->cmnd; in resp_open_zone()
4640 mk_sense_invalid_opcode(scp); in resp_open_zone()
4650 mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC, in resp_open_zone()
4663 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_open_zone()
4670 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_open_zone()
4675 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_open_zone()
4685 mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC, in resp_open_zone()
4705 static int resp_close_zone(struct scsi_cmnd *scp, in resp_close_zone() argument
4710 u8 *cmd = scp->cmnd; in resp_close_zone()
4716 mk_sense_invalid_opcode(scp); in resp_close_zone()
4730 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_close_zone()
4737 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_close_zone()
4742 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_close_zone()
4777 static int resp_finish_zone(struct scsi_cmnd *scp, in resp_finish_zone() argument
4783 u8 *cmd = scp->cmnd; in resp_finish_zone()
4788 mk_sense_invalid_opcode(scp); in resp_finish_zone()
4802 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_finish_zone()
4809 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_finish_zone()
4814 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_finish_zone()
4858 static int resp_rwp_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_rwp_zone() argument
4863 u8 *cmd = scp->cmnd; in resp_rwp_zone()
4868 mk_sense_invalid_opcode(scp); in resp_rwp_zone()
4881 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_rwp_zone()
4888 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_rwp_zone()
4893 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_rwp_zone()
4932 struct scsi_cmnd *scp; in sdebug_q_cmd_complete() local
4951 scp = sqcp->a_cmnd; in sdebug_q_cmd_complete()
4952 if (unlikely(scp == NULL)) { in sdebug_q_cmd_complete()
4954 pr_err("scp is NULL, sqa_idx=%d, qc_idx=%d, hc_idx=%d\n", in sdebug_q_cmd_complete()
4958 devip = (struct sdebug_dev_info *)scp->device->hostdata; in sdebug_q_cmd_complete()
4994 scsi_done(scp); /* callback to mid level */ in sdebug_q_cmd_complete()
7431 static bool fake_timeout(struct scsi_cmnd *scp) in fake_timeout() argument
7439 scsi_medium_access_command(scp)) in fake_timeout()
7446 static int resp_not_ready(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_not_ready() argument
7451 struct scsi_device *sdp = scp->device; in resp_not_ready()
7463 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x1); in resp_not_ready()
7467 if (scp->cmnd[0] == TEST_UNIT_READY) { in resp_not_ready()
7476 scsi_set_sense_information(scp->sense_buffer, SCSI_SENSE_BUFFERSIZE, in resp_not_ready()
7481 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x2); in resp_not_ready()
7527 struct scsi_cmnd *scp; in sdebug_blk_mq_poll() local
7554 scp = sqcp->a_cmnd; in sdebug_blk_mq_poll()
7555 if (unlikely(scp == NULL)) { in sdebug_blk_mq_poll()
7556 pr_err("scp is NULL, queue_num=%d, qc_idx=%u from %s\n", in sdebug_blk_mq_poll()
7566 devip = (struct sdebug_dev_info *)scp->device->hostdata; in sdebug_blk_mq_poll()
7596 scsi_done(scp); /* callback to mid level */ in sdebug_blk_mq_poll()
7612 struct scsi_cmnd *scp) in scsi_debug_queuecommand() argument
7615 struct scsi_device *sdp = scp->device; in scsi_debug_queuecommand()
7619 u8 *cmd = scp->cmnd; in scsi_debug_queuecommand()
7631 scsi_set_resid(scp, 0); in scsi_debug_queuecommand()
7643 len = scp->cmd_len; in scsi_debug_queuecommand()
7653 blk_mq_unique_tag(scsi_cmd_to_rq(scp)), b); in scsi_debug_queuecommand()
7693 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 4); in scsi_debug_queuecommand()
7695 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 8, 7); in scsi_debug_queuecommand()
7697 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
7703 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
7710 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
7724 mk_sense_invalid_fld(scp, SDEB_IN_CDB, k, j); in scsi_debug_queuecommand()
7732 errsts = make_ua(scp, devip); in scsi_debug_queuecommand()
7736 if (unlikely(((F_M_ACCESS & flags) || scp->cmnd[0] == TEST_UNIT_READY) && in scsi_debug_queuecommand()
7738 errsts = resp_not_ready(scp, devip); in scsi_debug_queuecommand()
7745 if (fake_timeout(scp)) in scsi_debug_queuecommand()
7755 return schedule_resp(scp, devip, errsts, pfp, 0, 0); in scsi_debug_queuecommand()
7768 return schedule_resp(scp, devip, errsts, pfp, jdelay, 0); in scsi_debug_queuecommand()
7770 return schedule_resp(scp, devip, errsts, pfp, sdebug_jdelay, in scsi_debug_queuecommand()
7773 return schedule_resp(scp, devip, check_condition_result, NULL, 0, 0); in scsi_debug_queuecommand()
7775 return schedule_resp(scp, NULL, DID_NO_CONNECT << 16, NULL, 0, 0); in scsi_debug_queuecommand()