Lines Matching full:scp
557 static int resp_get_stream_status(struct scsi_cmnd *scp,
1277 static void mk_sense_invalid_fld(struct scsi_cmnd *scp, in mk_sense_invalid_fld() argument
1285 sbuff = scp->sense_buffer; in mk_sense_invalid_fld()
1287 sdev_printk(KERN_ERR, scp->device, in mk_sense_invalid_fld()
1293 scsi_build_sense(scp, sdebug_dsense, ILLEGAL_REQUEST, asc, 0); in mk_sense_invalid_fld()
1312 sdev_printk(KERN_INFO, scp->device, "%s: [sense_key,asc,ascq" in mk_sense_invalid_fld()
1317 static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) in mk_sense_buffer() argument
1319 if (!scp->sense_buffer) { in mk_sense_buffer()
1320 sdev_printk(KERN_ERR, scp->device, in mk_sense_buffer()
1324 memset(scp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in mk_sense_buffer()
1326 scsi_build_sense(scp, sdebug_dsense, key, asc, asq); in mk_sense_buffer()
1329 sdev_printk(KERN_INFO, scp->device, in mk_sense_buffer()
1334 static void mk_sense_invalid_opcode(struct scsi_cmnd *scp) in mk_sense_invalid_opcode() argument
1336 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_OPCODE, 0); in mk_sense_invalid_opcode()
1426 static int make_ua(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in make_ua() argument
1436 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1442 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1448 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1454 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
1460 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
1466 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1473 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1490 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1504 sdev_printk(KERN_INFO, scp->device, in make_ua()
1513 static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fill_from_dev_buffer() argument
1517 struct scsi_data_buffer *sdb = &scp->sdb; in fill_from_dev_buffer()
1521 if (scp->sc_data_direction != DMA_FROM_DEVICE) in fill_from_dev_buffer()
1526 scsi_set_resid(scp, scsi_bufflen(scp) - act_len); in fill_from_dev_buffer()
1536 static int p_fill_from_dev_buffer(struct scsi_cmnd *scp, const void *arr, in p_fill_from_dev_buffer() argument
1540 struct scsi_data_buffer *sdb = &scp->sdb; in p_fill_from_dev_buffer()
1545 if (scp->sc_data_direction != DMA_FROM_DEVICE) in p_fill_from_dev_buffer()
1551 __func__, off_dst, scsi_bufflen(scp), act_len, in p_fill_from_dev_buffer()
1552 scsi_get_resid(scp)); in p_fill_from_dev_buffer()
1553 n = scsi_bufflen(scp) - (off_dst + act_len); in p_fill_from_dev_buffer()
1554 scsi_set_resid(scp, min_t(u32, scsi_get_resid(scp), n)); in p_fill_from_dev_buffer()
1561 static int fetch_to_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fetch_to_dev_buffer() argument
1564 if (!scsi_bufflen(scp)) in fetch_to_dev_buffer()
1566 if (scp->sc_data_direction != DMA_TO_DEVICE) in fetch_to_dev_buffer()
1569 return scsi_sg_copy_to_buffer(scp, arr, arr_len); in fetch_to_dev_buffer()
1945 static int resp_inquiry(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_inquiry() argument
1949 unsigned char *cmd = scp->cmnd; in resp_inquiry()
1961 have_wlun = scsi_is_wlun(scp->device->lun); in resp_inquiry()
1970 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 1); in resp_inquiry()
2057 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_inquiry()
2062 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
2098 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
2108 static int resp_requests(struct scsi_cmnd *scp, in resp_requests() argument
2111 unsigned char *cmd = scp->cmnd; in resp_requests()
2159 return fill_from_dev_buffer(scp, arr, min_t(u32, len, alloc_len)); in resp_requests()
2162 static int resp_start_stop(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_start_stop() argument
2164 unsigned char *cmd = scp->cmnd; in resp_start_stop()
2170 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 7); in resp_start_stop()
2191 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 0 /* START bit */); in resp_start_stop()
2217 static int resp_readcap(struct scsi_cmnd *scp, in resp_readcap() argument
2232 return fill_from_dev_buffer(scp, arr, SDEBUG_READCAP_ARR_SZ); in resp_readcap()
2236 static int resp_readcap16(struct scsi_cmnd *scp, in resp_readcap16() argument
2239 unsigned char *cmd = scp->cmnd; in resp_readcap16()
2276 return fill_from_dev_buffer(scp, arr, in resp_readcap16()
2282 static int resp_report_tgtpgs(struct scsi_cmnd *scp, in resp_report_tgtpgs() argument
2285 unsigned char *cmd = scp->cmnd; in resp_report_tgtpgs()
2353 ret = fill_from_dev_buffer(scp, arr, in resp_report_tgtpgs()
2359 static int resp_rsup_opcodes(struct scsi_cmnd *scp, in resp_rsup_opcodes() argument
2370 u8 *cmd = scp->cmnd; in resp_rsup_opcodes()
2378 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_opcodes()
2387 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_rsup_opcodes()
2448 mk_sense_invalid_fld(scp, SDEB_IN_CDB, in resp_rsup_opcodes()
2456 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, -1); in resp_rsup_opcodes()
2499 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_rsup_opcodes()
2505 errsts = fill_from_dev_buffer(scp, arr, len); in resp_rsup_opcodes()
2510 static int resp_rsup_tmfs(struct scsi_cmnd *scp, in resp_rsup_tmfs() argument
2516 u8 *cmd = scp->cmnd; in resp_rsup_tmfs()
2522 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_tmfs()
2534 return fill_from_dev_buffer(scp, arr, len); in resp_rsup_tmfs()
2734 static int resp_mode_sense(struct scsi_cmnd *scp, in resp_mode_sense() argument
2741 int target = scp->device->id; in resp_mode_sense()
2744 unsigned char *cmd = scp->cmnd; in resp_mode_sense()
2764 mk_sense_buffer(scp, ILLEGAL_REQUEST, SAVING_PARAMS_UNSUP, 0); in resp_mode_sense()
2909 return fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, offset)); in resp_mode_sense()
2912 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_mode_sense()
2916 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2922 static int resp_mode_select(struct scsi_cmnd *scp, in resp_mode_select() argument
2928 unsigned char *cmd = scp->cmnd; in resp_mode_select()
2936 mk_sense_invalid_fld(scp, SDEB_IN_CDB, mselect6 ? 4 : 7, -1); in resp_mode_select()
2939 res = fetch_to_dev_buffer(scp, arr, param_len); in resp_mode_select()
2943 sdev_printk(KERN_INFO, scp->device, in resp_mode_select()
2950 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 0, -1); in resp_mode_select()
2956 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 7); in resp_mode_select()
2963 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_mode_select()
2997 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 5); in resp_mode_select()
3041 static int resp_log_sense(struct scsi_cmnd *scp, in resp_log_sense() argument
3047 unsigned char *cmd = scp->cmnd; in resp_log_sense()
3053 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, ppc ? 1 : 0); in resp_log_sense()
3076 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
3120 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
3129 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
3133 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_log_sense()
3137 return fill_from_dev_buffer(scp, arr, in resp_log_sense()
3312 static int check_zbc_access_params(struct scsi_cmnd *scp, in check_zbc_access_params() argument
3315 struct scsi_device *sdp = scp->device; in check_zbc_access_params()
3323 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3333 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, in check_zbc_access_params()
3341 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3352 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3359 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3365 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3376 mk_sense_buffer(scp, DATA_PROTECT, in check_zbc_access_params()
3388 (struct scsi_cmnd *scp, unsigned long long lba, in check_device_access_params() argument
3391 struct scsi_device *sdp = scp->device; in check_device_access_params()
3395 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in check_device_access_params()
3401 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in check_device_access_params()
3405 mk_sense_buffer(scp, DATA_PROTECT, WRITE_PROTECTED, 0x2); in check_device_access_params()
3409 return check_zbc_access_params(scp, lba, num, write); in check_device_access_params()
3645 static int do_device_access(struct sdeb_store_info *sip, struct scsi_cmnd *scp, in do_device_access() argument
3652 struct scsi_data_buffer *sdb = &scp->sdb; in do_device_access()
3672 if (scp->sc_data_direction != dir) in do_device_access()
3704 static int do_dout_fetch(struct scsi_cmnd *scp, u32 num, u8 *doutp) in do_dout_fetch() argument
3706 struct scsi_data_buffer *sdb = &scp->sdb; in do_dout_fetch()
3710 if (scp->sc_data_direction != DMA_TO_DEVICE) in do_dout_fetch()
3788 static void dif_copy_prot(struct scsi_cmnd *scp, sector_t sector, in dif_copy_prot() argument
3794 scp->device->hostdata, true); in dif_copy_prot()
3802 sg_miter_start(&miter, scsi_prot_sglist(scp), in dif_copy_prot()
3803 scsi_prot_sg_count(scp), SG_MITER_ATOMIC | in dif_copy_prot()
3834 static int prot_verify_read(struct scsi_cmnd *scp, sector_t start_sec, in prot_verify_read() argument
3841 scp->device->hostdata, true); in prot_verify_read()
3858 if (scp->cmnd[1] >> 5) { /* RDPROTECT */ in prot_verify_read()
3868 dif_copy_prot(scp, start_sec, sectors, true); in prot_verify_read()
3874 static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_read_dt0() argument
3882 u8 *cmd = scp->cmnd; in resp_read_dt0()
3927 mk_sense_invalid_opcode(scp); in resp_read_dt0()
3933 sdev_printk(KERN_ERR, scp->device, "Unprotected RD " in resp_read_dt0()
3946 ret = check_device_access_params(scp, lba, num, false); in resp_read_dt0()
3953 mk_sense_buffer(scp, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 0); in resp_read_dt0()
3955 if (0x70 == (scp->sense_buffer[0] & 0x7f)) { in resp_read_dt0()
3956 scp->sense_buffer[0] |= 0x80; /* Valid bit */ in resp_read_dt0()
3959 put_unaligned_be32(ret, scp->sense_buffer + 3); in resp_read_dt0()
3961 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_read_dt0()
3966 (sdebug_dix && scsi_prot_sg_count(scp))) { in resp_read_dt0()
3972 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_read_dt0()
3973 switch (prot_verify_read(scp, lba, num, ei_lba)) { in resp_read_dt0()
3977 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
3979 } else if (scp->prot_flags & SCSI_PROT_GUARD_CHECK) { in resp_read_dt0()
3981 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
3988 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 3); in resp_read_dt0()
3990 } else if (scp->prot_flags & SCSI_PROT_REF_CHECK) { in resp_read_dt0()
3992 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 3); in resp_read_dt0()
3999 ret = do_device_access(sip, scp, 0, lba, num, 0, false, false); in resp_read_dt0()
4005 scsi_set_resid(scp, scsi_bufflen(scp) - ret); in resp_read_dt0()
4010 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_read_dt0()
4015 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
4019 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
4181 static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_dt0() argument
4190 u8 *cmd = scp->cmnd; in resp_write_dt0()
4240 mk_sense_invalid_opcode(scp); in resp_write_dt0()
4246 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_write_dt0()
4251 (sdebug_dix && scsi_prot_sg_count(scp)) || in resp_write_dt0()
4257 ret = check_device_access_params(scp, lba, num, true); in resp_write_dt0()
4265 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_dt0()
4266 switch (prot_verify_write(scp, lba, num, ei_lba)) { in resp_write_dt0()
4268 if (scp->prot_flags & SCSI_PROT_GUARD_CHECK) { in resp_write_dt0()
4270 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
4272 } else if (scp->cmnd[1] >> 5 != 3) { /* WRPROTECT != 3 */ in resp_write_dt0()
4274 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
4279 if (scp->prot_flags & SCSI_PROT_REF_CHECK) { in resp_write_dt0()
4281 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 3); in resp_write_dt0()
4283 } else if (scp->cmnd[1] >> 5 != 3) { /* WRPROTECT != 3 */ in resp_write_dt0()
4285 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 3); in resp_write_dt0()
4292 ret = do_device_access(sip, scp, 0, lba, num, group, true, false); in resp_write_dt0()
4306 sdev_printk(KERN_INFO, scp->device, in resp_write_dt0()
4313 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_write_dt0()
4318 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
4322 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
4334 static int resp_write_scat(struct scsi_cmnd *scp, in resp_write_scat() argument
4337 u8 *cmd = scp->cmnd; in resp_write_scat()
4369 mk_sense_invalid_opcode(scp); in resp_write_scat()
4375 sdev_printk(KERN_ERR, scp->device, in resp_write_scat()
4383 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
4386 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
4392 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
4395 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
4402 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
4405 res = fetch_to_dev_buffer(scp, lrdp, lbdof_blen); in resp_write_scat()
4420 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
4425 ret = check_device_access_params(scp, lba, num, true); in resp_write_scat()
4433 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
4436 mk_sense_buffer(scp, ILLEGAL_REQUEST, WRITE_ERROR_ASC, in resp_write_scat()
4443 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_scat()
4444 int prot_ret = prot_verify_write(scp, lba, num, in resp_write_scat()
4448 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, in resp_write_scat()
4459 ret = do_device_access(sip, scp, sg_off, lba, num, group, true, true); in resp_write_scat()
4469 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
4476 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_write_scat()
4482 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_scat()
4487 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_scat()
4504 static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num, in resp_write_same() argument
4507 struct scsi_device *sdp = scp->device; in resp_write_same()
4514 scp->device->hostdata, true); in resp_write_same()
4524 ret = check_device_access_params(scp, lba, num, true); in resp_write_same()
4542 ret = fetch_to_dev_buffer(scp, fs1p, lb_size); in resp_write_same()
4548 sdev_printk(KERN_INFO, scp->device, in resp_write_same()
4571 static int resp_write_same_10(struct scsi_cmnd *scp, in resp_write_same_10() argument
4574 u8 *cmd = scp->cmnd; in resp_write_same_10()
4582 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_10()
4590 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_write_same_10()
4593 return resp_write_same(scp, lba, num, ei_lba, unmap, false); in resp_write_same_10()
4596 static int resp_write_same_16(struct scsi_cmnd *scp, in resp_write_same_16() argument
4599 u8 *cmd = scp->cmnd; in resp_write_same_16()
4608 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_16()
4618 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 10, -1); in resp_write_same_16()
4621 return resp_write_same(scp, lba, num, ei_lba, unmap, ndob); in resp_write_same_16()
4627 static int resp_write_buffer(struct scsi_cmnd *scp, in resp_write_buffer() argument
4630 u8 *cmd = scp->cmnd; in resp_write_buffer()
4631 struct scsi_device *sdp = scp->device; in resp_write_buffer()
4673 static int resp_comp_write(struct scsi_cmnd *scp, in resp_comp_write() argument
4676 u8 *cmd = scp->cmnd; in resp_comp_write()
4692 mk_sense_invalid_opcode(scp); in resp_comp_write()
4698 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_comp_write()
4700 ret = check_device_access_params(scp, lba, num, false); in resp_comp_write()
4706 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_comp_write()
4711 ret = do_dout_fetch(scp, dnum, arr); in resp_comp_write()
4716 sdev_printk(KERN_INFO, scp->device, "%s: compare_write: cdb " in resp_comp_write()
4723 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_comp_write()
4745 static int resp_unmap(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_unmap() argument
4755 payload_len = get_unaligned_be16(scp->cmnd + 7); in resp_unmap()
4756 BUG_ON(scsi_bufflen(scp) != payload_len); in resp_unmap()
4760 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_unmap()
4764 buf = kzalloc(scsi_bufflen(scp), GFP_ATOMIC); in resp_unmap()
4766 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_unmap()
4771 scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); in resp_unmap()
4784 ret = check_device_access_params(scp, lba, num, true); in resp_unmap()
4802 static int resp_get_lba_status(struct scsi_cmnd *scp, in resp_get_lba_status() argument
4805 u8 *cmd = scp->cmnd; in resp_get_lba_status()
4817 ret = check_device_access_params(scp, lba, 1, false); in resp_get_lba_status()
4841 return fill_from_dev_buffer(scp, arr, SDEBUG_GET_LBA_STATUS_LEN); in resp_get_lba_status()
4844 static int resp_get_stream_status(struct scsi_cmnd *scp, in resp_get_stream_status() argument
4848 const u8 *cmd = scp->cmnd; in resp_get_stream_status()
4857 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 10, -1); in resp_get_stream_status()
4862 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, -1); in resp_get_stream_status()
4886 return fill_from_dev_buffer(scp, arr, min(offset, alloc_len)); in resp_get_stream_status()
4889 static int resp_sync_cache(struct scsi_cmnd *scp, in resp_sync_cache() argument
4895 u8 *cmd = scp->cmnd; in resp_sync_cache()
4905 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_sync_cache()
4922 static int resp_pre_fetch(struct scsi_cmnd *scp, in resp_pre_fetch() argument
4929 u8 *cmd = scp->cmnd; in resp_pre_fetch()
4941 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_pre_fetch()
4975 static int resp_report_luns(struct scsi_cmnd *scp, in resp_report_luns() argument
4978 unsigned char *cmd = scp->cmnd; in resp_report_luns()
4999 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_report_luns()
5021 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_report_luns()
5030 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_report_luns()
5054 res = p_fill_from_dev_buffer(scp, arr, n, off_rsp); in resp_report_luns()
5064 res = p_fill_from_dev_buffer(scp, arr, j * sz_lun, off_rsp); in resp_report_luns()
5068 static int resp_verify(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_verify() argument
5077 u8 *cmd = scp->cmnd; in resp_verify()
5084 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_verify()
5099 mk_sense_invalid_opcode(scp); in resp_verify()
5106 ret = check_device_access_params(scp, lba, a_num, false); in resp_verify()
5112 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_verify()
5119 ret = do_dout_fetch(scp, a_num, arr); in resp_verify()
5124 sdev_printk(KERN_INFO, scp->device, in resp_verify()
5134 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_verify()
5147 static int resp_report_zones(struct scsi_cmnd *scp, in resp_report_zones() argument
5156 u8 *cmd = scp->cmnd; in resp_report_zones()
5161 mk_sense_invalid_opcode(scp); in resp_report_zones()
5172 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_report_zones()
5180 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_report_zones()
5246 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_report_zones()
5280 ret = fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, rep_len)); in resp_report_zones()
5288 static int resp_atomic_write(struct scsi_cmnd *scp, in resp_atomic_write() argument
5292 u8 *cmd = scp->cmnd; in resp_atomic_write()
5298 mk_sense_invalid_opcode(scp); in resp_atomic_write()
5312 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_atomic_write()
5318 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_atomic_write()
5324 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 12, -1); in resp_atomic_write()
5329 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 12, -1); in resp_atomic_write()
5334 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 12, -1); in resp_atomic_write()
5339 ret = do_device_access(sip, scp, 0, lba, len, 0, true, true); in resp_atomic_write()
5359 static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_open_zone() argument
5364 u8 *cmd = scp->cmnd; in resp_open_zone()
5370 mk_sense_invalid_opcode(scp); in resp_open_zone()
5379 mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC, in resp_open_zone()
5392 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_open_zone()
5399 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_open_zone()
5404 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_open_zone()
5414 mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC, in resp_open_zone()
5434 static int resp_close_zone(struct scsi_cmnd *scp, in resp_close_zone() argument
5439 u8 *cmd = scp->cmnd; in resp_close_zone()
5445 mk_sense_invalid_opcode(scp); in resp_close_zone()
5459 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_close_zone()
5466 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_close_zone()
5471 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_close_zone()
5506 static int resp_finish_zone(struct scsi_cmnd *scp, in resp_finish_zone() argument
5512 u8 *cmd = scp->cmnd; in resp_finish_zone()
5517 mk_sense_invalid_opcode(scp); in resp_finish_zone()
5531 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_finish_zone()
5538 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_finish_zone()
5543 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_finish_zone()
5587 static int resp_rwp_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_rwp_zone() argument
5592 u8 *cmd = scp->cmnd; in resp_rwp_zone()
5597 mk_sense_invalid_opcode(scp); in resp_rwp_zone()
5610 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_rwp_zone()
5617 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_rwp_zone()
5622 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_rwp_zone()
5643 struct scsi_cmnd *scp = sqcp->scmd; in sdebug_q_cmd_complete() local
5653 if (!scp) { in sdebug_q_cmd_complete()
5658 sdsc = scsi_cmd_priv(scp); in sdebug_q_cmd_complete()
5663 ASSIGN_QUEUED_CMD(scp, NULL); in sdebug_q_cmd_complete()
5669 blk_abort_request(scsi_cmd_to_rq(scp)); in sdebug_q_cmd_complete()
5673 scsi_done(scp); /* callback to mid level */ in sdebug_q_cmd_complete()
8242 static bool fake_timeout(struct scsi_cmnd *scp) in fake_timeout() argument
8250 scsi_medium_access_command(scp)) in fake_timeout()
8257 static int resp_not_ready(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_not_ready() argument
8262 struct scsi_device *sdp = scp->device; in resp_not_ready()
8274 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x1); in resp_not_ready()
8278 if (scp->cmnd[0] == TEST_UNIT_READY) { in resp_not_ready()
8287 scsi_set_sense_information(scp->sense_buffer, SCSI_SENSE_BUFFERSIZE, in resp_not_ready()
8292 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x2); in resp_not_ready()
8509 struct scsi_cmnd *scp) in scsi_debug_queuecommand() argument
8512 struct scsi_device *sdp = scp->device; in scsi_debug_queuecommand()
8516 u8 *cmd = scp->cmnd; in scsi_debug_queuecommand()
8530 scsi_set_resid(scp, 0); in scsi_debug_queuecommand()
8542 len = scp->cmd_len; in scsi_debug_queuecommand()
8552 blk_mq_unique_tag(scsi_cmd_to_rq(scp)), b); in scsi_debug_queuecommand()
8569 if (sdebug_timeout_cmd(scp)) { in scsi_debug_queuecommand()
8570 scmd_printk(KERN_INFO, scp, "timeout command 0x%x\n", opcode); in scsi_debug_queuecommand()
8574 ret = sdebug_fail_queue_cmd(scp); in scsi_debug_queuecommand()
8576 scmd_printk(KERN_INFO, scp, "fail queue command 0x%x with 0x%x\n", in scsi_debug_queuecommand()
8581 if (sdebug_fail_cmd(scp, &ret, &err)) { in scsi_debug_queuecommand()
8582 scmd_printk(KERN_INFO, scp, in scsi_debug_queuecommand()
8615 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 4); in scsi_debug_queuecommand()
8617 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 8, 7); in scsi_debug_queuecommand()
8619 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
8625 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
8632 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
8646 mk_sense_invalid_fld(scp, SDEB_IN_CDB, k, j); in scsi_debug_queuecommand()
8654 errsts = make_ua(scp, devip); in scsi_debug_queuecommand()
8658 if (unlikely(((F_M_ACCESS & flags) || scp->cmnd[0] == TEST_UNIT_READY) && in scsi_debug_queuecommand()
8660 errsts = resp_not_ready(scp, devip); in scsi_debug_queuecommand()
8667 if (fake_timeout(scp)) in scsi_debug_queuecommand()
8677 return schedule_resp(scp, devip, errsts, pfp, 0, 0); in scsi_debug_queuecommand()
8690 return schedule_resp(scp, devip, errsts, pfp, jdelay, 0); in scsi_debug_queuecommand()
8692 return schedule_resp(scp, devip, errsts, pfp, sdebug_jdelay, in scsi_debug_queuecommand()
8695 return schedule_resp(scp, devip, check_condition_result, NULL, 0, 0); in scsi_debug_queuecommand()
8697 return schedule_resp(scp, NULL, DID_NO_CONNECT << 16, NULL, 0, 0); in scsi_debug_queuecommand()