Lines Matching full:scp

1226 static void mk_sense_invalid_fld(struct scsi_cmnd *scp,  in mk_sense_invalid_fld()  argument
1234 sbuff = scp->sense_buffer; in mk_sense_invalid_fld()
1236 sdev_printk(KERN_ERR, scp->device, in mk_sense_invalid_fld()
1242 scsi_build_sense(scp, sdebug_dsense, ILLEGAL_REQUEST, asc, 0); in mk_sense_invalid_fld()
1261 sdev_printk(KERN_INFO, scp->device, "%s: [sense_key,asc,ascq" in mk_sense_invalid_fld()
1266 static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) in mk_sense_buffer() argument
1268 if (!scp->sense_buffer) { in mk_sense_buffer()
1269 sdev_printk(KERN_ERR, scp->device, in mk_sense_buffer()
1273 memset(scp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in mk_sense_buffer()
1275 scsi_build_sense(scp, sdebug_dsense, key, asc, asq); in mk_sense_buffer()
1278 sdev_printk(KERN_INFO, scp->device, in mk_sense_buffer()
1283 static void mk_sense_invalid_opcode(struct scsi_cmnd *scp) in mk_sense_invalid_opcode() argument
1285 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_OPCODE, 0); in mk_sense_invalid_opcode()
1375 static int make_ua(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in make_ua() argument
1385 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1391 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1397 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1403 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
1409 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
1415 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1422 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1439 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1453 sdev_printk(KERN_INFO, scp->device, in make_ua()
1462 static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fill_from_dev_buffer() argument
1466 struct scsi_data_buffer *sdb = &scp->sdb; in fill_from_dev_buffer()
1470 if (scp->sc_data_direction != DMA_FROM_DEVICE) in fill_from_dev_buffer()
1475 scsi_set_resid(scp, scsi_bufflen(scp) - act_len); in fill_from_dev_buffer()
1485 static int p_fill_from_dev_buffer(struct scsi_cmnd *scp, const void *arr, in p_fill_from_dev_buffer() argument
1489 struct scsi_data_buffer *sdb = &scp->sdb; in p_fill_from_dev_buffer()
1494 if (scp->sc_data_direction != DMA_FROM_DEVICE) in p_fill_from_dev_buffer()
1500 __func__, off_dst, scsi_bufflen(scp), act_len, in p_fill_from_dev_buffer()
1501 scsi_get_resid(scp)); in p_fill_from_dev_buffer()
1502 n = scsi_bufflen(scp) - (off_dst + act_len); in p_fill_from_dev_buffer()
1503 scsi_set_resid(scp, min_t(u32, scsi_get_resid(scp), n)); in p_fill_from_dev_buffer()
1510 static int fetch_to_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fetch_to_dev_buffer() argument
1513 if (!scsi_bufflen(scp)) in fetch_to_dev_buffer()
1515 if (scp->sc_data_direction != DMA_TO_DEVICE) in fetch_to_dev_buffer()
1518 return scsi_sg_copy_to_buffer(scp, arr, arr_len); in fetch_to_dev_buffer()
1873 static int resp_inquiry(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_inquiry() argument
1877 unsigned char *cmd = scp->cmnd; in resp_inquiry()
1889 have_wlun = scsi_is_wlun(scp->device->lun); in resp_inquiry()
1898 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 1); in resp_inquiry()
1990 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_inquiry()
1995 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
2031 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
2041 static int resp_requests(struct scsi_cmnd *scp, in resp_requests() argument
2044 unsigned char *cmd = scp->cmnd; in resp_requests()
2092 return fill_from_dev_buffer(scp, arr, min_t(u32, len, alloc_len)); in resp_requests()
2095 static int resp_start_stop(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_start_stop() argument
2097 unsigned char *cmd = scp->cmnd; in resp_start_stop()
2103 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 7); in resp_start_stop()
2124 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 0 /* START bit */); in resp_start_stop()
2150 static int resp_readcap(struct scsi_cmnd *scp, in resp_readcap() argument
2165 return fill_from_dev_buffer(scp, arr, SDEBUG_READCAP_ARR_SZ); in resp_readcap()
2169 static int resp_readcap16(struct scsi_cmnd *scp, in resp_readcap16() argument
2172 unsigned char *cmd = scp->cmnd; in resp_readcap16()
2209 return fill_from_dev_buffer(scp, arr, in resp_readcap16()
2215 static int resp_report_tgtpgs(struct scsi_cmnd *scp, in resp_report_tgtpgs() argument
2218 unsigned char *cmd = scp->cmnd; in resp_report_tgtpgs()
2286 ret = fill_from_dev_buffer(scp, arr, in resp_report_tgtpgs()
2292 static int resp_rsup_opcodes(struct scsi_cmnd *scp, in resp_rsup_opcodes() argument
2303 u8 *cmd = scp->cmnd; in resp_rsup_opcodes()
2311 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_opcodes()
2320 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_rsup_opcodes()
2381 mk_sense_invalid_fld(scp, SDEB_IN_CDB, in resp_rsup_opcodes()
2389 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, -1); in resp_rsup_opcodes()
2432 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_rsup_opcodes()
2438 errsts = fill_from_dev_buffer(scp, arr, len); in resp_rsup_opcodes()
2443 static int resp_rsup_tmfs(struct scsi_cmnd *scp, in resp_rsup_tmfs() argument
2449 u8 *cmd = scp->cmnd; in resp_rsup_tmfs()
2455 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_tmfs()
2467 return fill_from_dev_buffer(scp, arr, len); in resp_rsup_tmfs()
2632 static int resp_mode_sense(struct scsi_cmnd *scp, in resp_mode_sense() argument
2639 int target = scp->device->id; in resp_mode_sense()
2642 unsigned char *cmd = scp->cmnd; in resp_mode_sense()
2660 mk_sense_buffer(scp, ILLEGAL_REQUEST, SAVING_PARAMS_UNSUP, 0); in resp_mode_sense()
2704 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2738 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2778 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2787 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_mode_sense()
2794 return fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, offset)); in resp_mode_sense()
2799 static int resp_mode_select(struct scsi_cmnd *scp, in resp_mode_select() argument
2805 unsigned char *cmd = scp->cmnd; in resp_mode_select()
2813 mk_sense_invalid_fld(scp, SDEB_IN_CDB, mselect6 ? 4 : 7, -1); in resp_mode_select()
2816 res = fetch_to_dev_buffer(scp, arr, param_len); in resp_mode_select()
2820 sdev_printk(KERN_INFO, scp->device, in resp_mode_select()
2827 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 0, -1); in resp_mode_select()
2833 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 7); in resp_mode_select()
2840 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_mode_select()
2874 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 5); in resp_mode_select()
2918 static int resp_log_sense(struct scsi_cmnd *scp, in resp_log_sense() argument
2924 unsigned char *cmd = scp->cmnd; in resp_log_sense()
2930 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, ppc ? 1 : 0); in resp_log_sense()
2953 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2997 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
3006 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
3010 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_log_sense()
3014 return fill_from_dev_buffer(scp, arr, in resp_log_sense()
3189 static int check_zbc_access_params(struct scsi_cmnd *scp, in check_zbc_access_params() argument
3192 struct scsi_device *sdp = scp->device; in check_zbc_access_params()
3200 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3210 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, in check_zbc_access_params()
3218 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3229 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3236 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3242 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3253 mk_sense_buffer(scp, DATA_PROTECT, in check_zbc_access_params()
3265 (struct scsi_cmnd *scp, unsigned long long lba, in check_device_access_params() argument
3268 struct scsi_device *sdp = scp->device; in check_device_access_params()
3272 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in check_device_access_params()
3278 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in check_device_access_params()
3282 mk_sense_buffer(scp, DATA_PROTECT, WRITE_PROTECTED, 0x2); in check_device_access_params()
3286 return check_zbc_access_params(scp, lba, num, write); in check_device_access_params()
3308 static int do_device_access(struct sdeb_store_info *sip, struct scsi_cmnd *scp, in do_device_access() argument
3314 struct scsi_data_buffer *sdb = &scp->sdb; in do_device_access()
3326 if (scp->sc_data_direction != dir) in do_device_access()
3351 static int do_dout_fetch(struct scsi_cmnd *scp, u32 num, u8 *doutp) in do_dout_fetch() argument
3353 struct scsi_data_buffer *sdb = &scp->sdb; in do_dout_fetch()
3357 if (scp->sc_data_direction != DMA_TO_DEVICE) in do_dout_fetch()
3435 static void dif_copy_prot(struct scsi_cmnd *scp, sector_t sector, in dif_copy_prot() argument
3441 scp->device->hostdata, true); in dif_copy_prot()
3449 sg_miter_start(&miter, scsi_prot_sglist(scp), in dif_copy_prot()
3450 scsi_prot_sg_count(scp), SG_MITER_ATOMIC | in dif_copy_prot()
3481 static int prot_verify_read(struct scsi_cmnd *scp, sector_t start_sec, in prot_verify_read() argument
3488 scp->device->hostdata, true); in prot_verify_read()
3505 if (scp->cmnd[1] >> 5) { /* RDPROTECT */ in prot_verify_read()
3515 dif_copy_prot(scp, start_sec, sectors, true); in prot_verify_read()
3585 static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_read_dt0() argument
3593 u8 *cmd = scp->cmnd; in resp_read_dt0()
3637 mk_sense_invalid_opcode(scp); in resp_read_dt0()
3643 sdev_printk(KERN_ERR, scp->device, "Unprotected RD " in resp_read_dt0()
3652 ret = check_device_access_params(scp, lba, num, false); in resp_read_dt0()
3659 mk_sense_buffer(scp, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 0); in resp_read_dt0()
3661 if (0x70 == (scp->sense_buffer[0] & 0x7f)) { in resp_read_dt0()
3662 scp->sense_buffer[0] |= 0x80; /* Valid bit */ in resp_read_dt0()
3665 put_unaligned_be32(ret, scp->sense_buffer + 3); in resp_read_dt0()
3667 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_read_dt0()
3674 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_read_dt0()
3675 switch (prot_verify_read(scp, lba, num, ei_lba)) { in resp_read_dt0()
3679 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
3681 } else if (scp->prot_flags & SCSI_PROT_GUARD_CHECK) { in resp_read_dt0()
3683 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
3690 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 3); in resp_read_dt0()
3692 } else if (scp->prot_flags & SCSI_PROT_REF_CHECK) { in resp_read_dt0()
3694 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 3); in resp_read_dt0()
3701 ret = do_device_access(sip, scp, 0, lba, num, false); in resp_read_dt0()
3706 scsi_set_resid(scp, scsi_bufflen(scp) - ret); in resp_read_dt0()
3711 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_read_dt0()
3716 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
3720 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
3882 static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_dt0() argument
3890 u8 *cmd = scp->cmnd; in resp_write_dt0()
3934 mk_sense_invalid_opcode(scp); in resp_write_dt0()
3940 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_write_dt0()
3945 ret = check_device_access_params(scp, lba, num, true); in resp_write_dt0()
3952 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_dt0()
3953 switch (prot_verify_write(scp, lba, num, ei_lba)) { in resp_write_dt0()
3955 if (scp->prot_flags & SCSI_PROT_GUARD_CHECK) { in resp_write_dt0()
3957 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
3959 } else if (scp->cmnd[1] >> 5 != 3) { /* WRPROTECT != 3 */ in resp_write_dt0()
3961 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
3966 if (scp->prot_flags & SCSI_PROT_REF_CHECK) { in resp_write_dt0()
3968 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 3); in resp_write_dt0()
3970 } else if (scp->cmnd[1] >> 5 != 3) { /* WRPROTECT != 3 */ in resp_write_dt0()
3972 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 3); in resp_write_dt0()
3979 ret = do_device_access(sip, scp, 0, lba, num, true); in resp_write_dt0()
3990 sdev_printk(KERN_INFO, scp->device, in resp_write_dt0()
3997 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_write_dt0()
4002 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
4006 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
4018 static int resp_write_scat(struct scsi_cmnd *scp, in resp_write_scat() argument
4021 u8 *cmd = scp->cmnd; in resp_write_scat()
4050 mk_sense_invalid_opcode(scp); in resp_write_scat()
4056 sdev_printk(KERN_ERR, scp->device, in resp_write_scat()
4064 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
4067 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
4073 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
4076 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
4083 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
4086 res = fetch_to_dev_buffer(scp, lrdp, lbdof_blen); in resp_write_scat()
4100 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
4105 ret = check_device_access_params(scp, lba, num, true); in resp_write_scat()
4113 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
4116 mk_sense_buffer(scp, ILLEGAL_REQUEST, WRITE_ERROR_ASC, in resp_write_scat()
4123 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_scat()
4124 int prot_ret = prot_verify_write(scp, lba, num, in resp_write_scat()
4128 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, in resp_write_scat()
4135 ret = do_device_access(sip, scp, sg_off, lba, num, true); in resp_write_scat()
4145 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
4152 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_write_scat()
4158 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_scat()
4163 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_scat()
4180 static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num, in resp_write_same() argument
4183 struct scsi_device *sdp = scp->device; in resp_write_same()
4190 scp->device->hostdata, true); in resp_write_same()
4196 ret = check_device_access_params(scp, lba, num, true); in resp_write_same()
4215 ret = fetch_to_dev_buffer(scp, fs1p, lb_size); in resp_write_same()
4221 sdev_printk(KERN_INFO, scp->device, in resp_write_same()
4242 static int resp_write_same_10(struct scsi_cmnd *scp, in resp_write_same_10() argument
4245 u8 *cmd = scp->cmnd; in resp_write_same_10()
4253 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_10()
4261 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_write_same_10()
4264 return resp_write_same(scp, lba, num, ei_lba, unmap, false); in resp_write_same_10()
4267 static int resp_write_same_16(struct scsi_cmnd *scp, in resp_write_same_16() argument
4270 u8 *cmd = scp->cmnd; in resp_write_same_16()
4279 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_16()
4289 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 10, -1); in resp_write_same_16()
4292 return resp_write_same(scp, lba, num, ei_lba, unmap, ndob); in resp_write_same_16()
4298 static int resp_write_buffer(struct scsi_cmnd *scp, in resp_write_buffer() argument
4301 u8 *cmd = scp->cmnd; in resp_write_buffer()
4302 struct scsi_device *sdp = scp->device; in resp_write_buffer()
4344 static int resp_comp_write(struct scsi_cmnd *scp, in resp_comp_write() argument
4347 u8 *cmd = scp->cmnd; in resp_comp_write()
4363 mk_sense_invalid_opcode(scp); in resp_comp_write()
4369 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_comp_write()
4371 ret = check_device_access_params(scp, lba, num, false); in resp_comp_write()
4377 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_comp_write()
4384 ret = do_dout_fetch(scp, dnum, arr); in resp_comp_write()
4389 sdev_printk(KERN_INFO, scp->device, "%s: compare_write: cdb " in resp_comp_write()
4393 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_comp_write()
4411 static int resp_unmap(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_unmap() argument
4421 payload_len = get_unaligned_be16(scp->cmnd + 7); in resp_unmap()
4422 BUG_ON(scsi_bufflen(scp) != payload_len); in resp_unmap()
4426 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_unmap()
4430 buf = kzalloc(scsi_bufflen(scp), GFP_ATOMIC); in resp_unmap()
4432 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_unmap()
4437 scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); in resp_unmap()
4450 ret = check_device_access_params(scp, lba, num, true); in resp_unmap()
4468 static int resp_get_lba_status(struct scsi_cmnd *scp, in resp_get_lba_status() argument
4471 u8 *cmd = scp->cmnd; in resp_get_lba_status()
4483 ret = check_device_access_params(scp, lba, 1, false); in resp_get_lba_status()
4507 return fill_from_dev_buffer(scp, arr, SDEBUG_GET_LBA_STATUS_LEN); in resp_get_lba_status()
4510 static int resp_sync_cache(struct scsi_cmnd *scp, in resp_sync_cache() argument
4516 u8 *cmd = scp->cmnd; in resp_sync_cache()
4526 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_sync_cache()
4543 static int resp_pre_fetch(struct scsi_cmnd *scp, in resp_pre_fetch() argument
4550 u8 *cmd = scp->cmnd; in resp_pre_fetch()
4562 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_pre_fetch()
4595 static int resp_report_luns(struct scsi_cmnd *scp, in resp_report_luns() argument
4598 unsigned char *cmd = scp->cmnd; in resp_report_luns()
4619 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_report_luns()
4641 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_report_luns()
4650 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_report_luns()
4674 res = p_fill_from_dev_buffer(scp, arr, n, off_rsp); in resp_report_luns()
4684 res = p_fill_from_dev_buffer(scp, arr, j * sz_lun, off_rsp); in resp_report_luns()
4688 static int resp_verify(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_verify() argument
4697 u8 *cmd = scp->cmnd; in resp_verify()
4704 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_verify()
4719 mk_sense_invalid_opcode(scp); in resp_verify()
4726 ret = check_device_access_params(scp, lba, a_num, false); in resp_verify()
4732 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_verify()
4739 ret = do_dout_fetch(scp, a_num, arr); in resp_verify()
4744 sdev_printk(KERN_INFO, scp->device, in resp_verify()
4754 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_verify()
4767 static int resp_report_zones(struct scsi_cmnd *scp, in resp_report_zones() argument
4776 u8 *cmd = scp->cmnd; in resp_report_zones()
4781 mk_sense_invalid_opcode(scp); in resp_report_zones()
4792 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_report_zones()
4800 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_report_zones()
4866 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_report_zones()
4900 ret = fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, rep_len)); in resp_report_zones()
4920 static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_open_zone() argument
4925 u8 *cmd = scp->cmnd; in resp_open_zone()
4931 mk_sense_invalid_opcode(scp); in resp_open_zone()
4941 mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC, in resp_open_zone()
4954 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_open_zone()
4961 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_open_zone()
4966 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_open_zone()
4976 mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC, in resp_open_zone()
4996 static int resp_close_zone(struct scsi_cmnd *scp, in resp_close_zone() argument
5001 u8 *cmd = scp->cmnd; in resp_close_zone()
5007 mk_sense_invalid_opcode(scp); in resp_close_zone()
5021 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_close_zone()
5028 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_close_zone()
5033 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_close_zone()
5068 static int resp_finish_zone(struct scsi_cmnd *scp, in resp_finish_zone() argument
5074 u8 *cmd = scp->cmnd; in resp_finish_zone()
5079 mk_sense_invalid_opcode(scp); in resp_finish_zone()
5093 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_finish_zone()
5100 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_finish_zone()
5105 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_finish_zone()
5149 static int resp_rwp_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_rwp_zone() argument
5154 u8 *cmd = scp->cmnd; in resp_rwp_zone()
5159 mk_sense_invalid_opcode(scp); in resp_rwp_zone()
5172 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_rwp_zone()
5179 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_rwp_zone()
5184 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_rwp_zone()
5205 struct scsi_cmnd *scp = sqcp->scmd; in sdebug_q_cmd_complete() local
5215 if (!scp) { in sdebug_q_cmd_complete()
5220 sdsc = scsi_cmd_priv(scp); in sdebug_q_cmd_complete()
5225 ASSIGN_QUEUED_CMD(scp, NULL); in sdebug_q_cmd_complete()
5231 blk_abort_request(scsi_cmd_to_rq(scp)); in sdebug_q_cmd_complete()
5235 scsi_done(scp); /* callback to mid level */ in sdebug_q_cmd_complete()
7764 static bool fake_timeout(struct scsi_cmnd *scp) in fake_timeout() argument
7772 scsi_medium_access_command(scp)) in fake_timeout()
7779 static int resp_not_ready(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_not_ready() argument
7784 struct scsi_device *sdp = scp->device; in resp_not_ready()
7796 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x1); in resp_not_ready()
7800 if (scp->cmnd[0] == TEST_UNIT_READY) { in resp_not_ready()
7809 scsi_set_sense_information(scp->sense_buffer, SCSI_SENSE_BUFFERSIZE, in resp_not_ready()
7814 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x2); in resp_not_ready()
8031 struct scsi_cmnd *scp) in scsi_debug_queuecommand() argument
8034 struct scsi_device *sdp = scp->device; in scsi_debug_queuecommand()
8038 u8 *cmd = scp->cmnd; in scsi_debug_queuecommand()
8052 scsi_set_resid(scp, 0); in scsi_debug_queuecommand()
8064 len = scp->cmd_len; in scsi_debug_queuecommand()
8074 blk_mq_unique_tag(scsi_cmd_to_rq(scp)), b); in scsi_debug_queuecommand()
8091 if (sdebug_timeout_cmd(scp)) { in scsi_debug_queuecommand()
8092 scmd_printk(KERN_INFO, scp, "timeout command 0x%x\n", opcode); in scsi_debug_queuecommand()
8096 ret = sdebug_fail_queue_cmd(scp); in scsi_debug_queuecommand()
8098 scmd_printk(KERN_INFO, scp, "fail queue command 0x%x with 0x%x\n", in scsi_debug_queuecommand()
8103 if (sdebug_fail_cmd(scp, &ret, &err)) { in scsi_debug_queuecommand()
8104 scmd_printk(KERN_INFO, scp, in scsi_debug_queuecommand()
8137 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 4); in scsi_debug_queuecommand()
8139 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 8, 7); in scsi_debug_queuecommand()
8141 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
8147 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
8154 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
8168 mk_sense_invalid_fld(scp, SDEB_IN_CDB, k, j); in scsi_debug_queuecommand()
8176 errsts = make_ua(scp, devip); in scsi_debug_queuecommand()
8180 if (unlikely(((F_M_ACCESS & flags) || scp->cmnd[0] == TEST_UNIT_READY) && in scsi_debug_queuecommand()
8182 errsts = resp_not_ready(scp, devip); in scsi_debug_queuecommand()
8189 if (fake_timeout(scp)) in scsi_debug_queuecommand()
8199 return schedule_resp(scp, devip, errsts, pfp, 0, 0); in scsi_debug_queuecommand()
8212 return schedule_resp(scp, devip, errsts, pfp, jdelay, 0); in scsi_debug_queuecommand()
8214 return schedule_resp(scp, devip, errsts, pfp, sdebug_jdelay, in scsi_debug_queuecommand()
8217 return schedule_resp(scp, devip, check_condition_result, NULL, 0, 0); in scsi_debug_queuecommand()
8219 return schedule_resp(scp, NULL, DID_NO_CONNECT << 16, NULL, 0, 0); in scsi_debug_queuecommand()