Lines Matching full:scp

593 static int resp_get_stream_status(struct scsi_cmnd *scp,
1330 static void mk_sense_invalid_fld(struct scsi_cmnd *scp, in mk_sense_invalid_fld() argument
1338 sbuff = scp->sense_buffer; in mk_sense_invalid_fld()
1340 sdev_printk(KERN_ERR, scp->device, in mk_sense_invalid_fld()
1346 scsi_build_sense(scp, sdebug_dsense, ILLEGAL_REQUEST, asc, 0); in mk_sense_invalid_fld()
1365 sdev_printk(KERN_INFO, scp->device, "%s: [sense_key,asc,ascq" in mk_sense_invalid_fld()
1370 static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) in mk_sense_buffer() argument
1372 if (!scp->sense_buffer) { in mk_sense_buffer()
1373 sdev_printk(KERN_ERR, scp->device, in mk_sense_buffer()
1377 memset(scp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in mk_sense_buffer()
1379 scsi_build_sense(scp, sdebug_dsense, key, asc, asq); in mk_sense_buffer()
1382 sdev_printk(KERN_INFO, scp->device, in mk_sense_buffer()
1388 static void mk_sense_info_tape(struct scsi_cmnd *scp, int key, int asc, int asq, in mk_sense_info_tape() argument
1391 if (!scp->sense_buffer) { in mk_sense_info_tape()
1392 sdev_printk(KERN_ERR, scp->device, in mk_sense_info_tape()
1396 memset(scp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in mk_sense_info_tape()
1398 scsi_build_sense(scp, /* sdebug_dsense */ 0, key, asc, asq); in mk_sense_info_tape()
1401 scp->sense_buffer[0] |= 0x80; /* valid */ in mk_sense_info_tape()
1402 scp->sense_buffer[2] |= tape_flags; in mk_sense_info_tape()
1403 put_unaligned_be32(information, &scp->sense_buffer[3]); in mk_sense_info_tape()
1406 sdev_printk(KERN_INFO, scp->device, in mk_sense_info_tape()
1411 static void mk_sense_invalid_opcode(struct scsi_cmnd *scp) in mk_sense_invalid_opcode() argument
1413 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_OPCODE, 0); in mk_sense_invalid_opcode()
1503 static int make_ua(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in make_ua() argument
1513 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1519 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1525 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1531 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
1537 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
1543 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1550 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1567 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1574 mk_sense_buffer(scp, UNIT_ATTENTION, UA_READY_ASC, in make_ua()
1587 sdev_printk(KERN_INFO, scp->device, in make_ua()
1596 static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fill_from_dev_buffer() argument
1600 struct scsi_data_buffer *sdb = &scp->sdb; in fill_from_dev_buffer()
1604 if (scp->sc_data_direction != DMA_FROM_DEVICE) in fill_from_dev_buffer()
1609 scsi_set_resid(scp, scsi_bufflen(scp) - act_len); in fill_from_dev_buffer()
1619 static int p_fill_from_dev_buffer(struct scsi_cmnd *scp, const void *arr, in p_fill_from_dev_buffer() argument
1623 struct scsi_data_buffer *sdb = &scp->sdb; in p_fill_from_dev_buffer()
1628 if (scp->sc_data_direction != DMA_FROM_DEVICE) in p_fill_from_dev_buffer()
1634 __func__, off_dst, scsi_bufflen(scp), act_len, in p_fill_from_dev_buffer()
1635 scsi_get_resid(scp)); in p_fill_from_dev_buffer()
1636 n = scsi_bufflen(scp) - (off_dst + act_len); in p_fill_from_dev_buffer()
1637 scsi_set_resid(scp, min_t(u32, scsi_get_resid(scp), n)); in p_fill_from_dev_buffer()
1644 static int fetch_to_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fetch_to_dev_buffer() argument
1647 if (!scsi_bufflen(scp)) in fetch_to_dev_buffer()
1649 if (scp->sc_data_direction != DMA_TO_DEVICE) in fetch_to_dev_buffer()
1652 return scsi_sg_copy_to_buffer(scp, arr, arr_len); in fetch_to_dev_buffer()
2028 static int resp_inquiry(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_inquiry() argument
2032 unsigned char *cmd = scp->cmnd; in resp_inquiry()
2044 have_wlun = scsi_is_wlun(scp->device->lun); in resp_inquiry()
2053 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 1); in resp_inquiry()
2140 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_inquiry()
2145 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
2181 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
2191 static int resp_requests(struct scsi_cmnd *scp, in resp_requests() argument
2194 unsigned char *cmd = scp->cmnd; in resp_requests()
2242 return fill_from_dev_buffer(scp, arr, min_t(u32, len, alloc_len)); in resp_requests()
2245 static int resp_start_stop(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_start_stop() argument
2247 unsigned char *cmd = scp->cmnd; in resp_start_stop()
2253 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 7); in resp_start_stop()
2274 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 0 /* START bit */); in resp_start_stop()
2308 static int resp_readcap(struct scsi_cmnd *scp, in resp_readcap() argument
2323 return fill_from_dev_buffer(scp, arr, SDEBUG_READCAP_ARR_SZ); in resp_readcap()
2327 static int resp_readcap16(struct scsi_cmnd *scp, in resp_readcap16() argument
2330 unsigned char *cmd = scp->cmnd; in resp_readcap16()
2367 return fill_from_dev_buffer(scp, arr, in resp_readcap16()
2373 static int resp_report_tgtpgs(struct scsi_cmnd *scp, in resp_report_tgtpgs() argument
2376 unsigned char *cmd = scp->cmnd; in resp_report_tgtpgs()
2444 ret = fill_from_dev_buffer(scp, arr, in resp_report_tgtpgs()
2450 static int resp_rsup_opcodes(struct scsi_cmnd *scp, in resp_rsup_opcodes() argument
2461 u8 *cmd = scp->cmnd; in resp_rsup_opcodes()
2469 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_opcodes()
2478 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_rsup_opcodes()
2539 mk_sense_invalid_fld(scp, SDEB_IN_CDB, in resp_rsup_opcodes()
2547 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, -1); in resp_rsup_opcodes()
2590 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_rsup_opcodes()
2596 errsts = fill_from_dev_buffer(scp, arr, len); in resp_rsup_opcodes()
2601 static int resp_rsup_tmfs(struct scsi_cmnd *scp, in resp_rsup_tmfs() argument
2607 u8 *cmd = scp->cmnd; in resp_rsup_tmfs()
2613 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_tmfs()
2625 return fill_from_dev_buffer(scp, arr, len); in resp_rsup_tmfs()
2895 static int resp_mode_sense(struct scsi_cmnd *scp, in resp_mode_sense() argument
2902 int target = scp->device->id; in resp_mode_sense()
2905 unsigned char *cmd = scp->cmnd; in resp_mode_sense()
2926 mk_sense_buffer(scp, ILLEGAL_REQUEST, SAVING_PARAMS_UNSUP, 0); in resp_mode_sense()
2967 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 1, 4); in resp_mode_sense()
3094 return fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, offset)); in resp_mode_sense()
3097 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_mode_sense()
3101 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
3107 static int resp_mode_select(struct scsi_cmnd *scp, in resp_mode_select() argument
3113 unsigned char *cmd = scp->cmnd; in resp_mode_select()
3121 mk_sense_invalid_fld(scp, SDEB_IN_CDB, mselect6 ? 4 : 7, -1); in resp_mode_select()
3124 res = fetch_to_dev_buffer(scp, arr, param_len); in resp_mode_select()
3128 sdev_printk(KERN_INFO, scp->device, in resp_mode_select()
3138 mk_sense_invalid_fld(scp, SDEB_IN_DATA, in resp_mode_select()
3143 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 0, -1); in resp_mode_select()
3151 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 1, -1); in resp_mode_select()
3161 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 0, -1); in resp_mode_select()
3167 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 7); in resp_mode_select()
3174 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_mode_select()
3213 mk_sense_invalid_fld(scp, SDEB_IN_DATA, fld, -1); in resp_mode_select()
3227 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 5); in resp_mode_select()
3234 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_mode_select()
3275 static int resp_log_sense(struct scsi_cmnd *scp, in resp_log_sense() argument
3281 unsigned char *cmd = scp->cmnd; in resp_log_sense()
3287 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, ppc ? 1 : 0); in resp_log_sense()
3310 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
3354 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
3363 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
3367 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_log_sense()
3371 return fill_from_dev_buffer(scp, arr, in resp_log_sense()
3376 static int resp_read_blklimits(struct scsi_cmnd *scp, in resp_read_blklimits() argument
3384 return fill_from_dev_buffer(scp, arr, SDEBUG_READ_BLOCK_LIMITS_ARR_SZ); in resp_read_blklimits()
3387 static int resp_locate(struct scsi_cmnd *scp, in resp_locate() argument
3390 unsigned char *cmd = scp->cmnd; in resp_locate()
3397 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 8, -1); in resp_locate()
3411 mk_sense_buffer(scp, BLANK_CHECK, 0x05, 0); in resp_locate()
3419 static int resp_write_filemarks(struct scsi_cmnd *scp, in resp_write_filemarks() argument
3422 unsigned char *cmd = scp->cmnd; in resp_write_filemarks()
3428 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 1); in resp_write_filemarks()
3436 mk_sense_info_tape(scp, VOLUME_OVERFLOW, NO_ADDITIONAL_SENSE, in resp_write_filemarks()
3449 static int resp_space(struct scsi_cmnd *scp, in resp_space() argument
3452 unsigned char *cmd = scp->cmnd, code; in resp_space()
3530 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 8, -1); in resp_space()
3538 mk_sense_info_tape(scp, NO_SENSE, NO_ADDITIONAL_SENSE, in resp_space()
3545 mk_sense_info_tape(scp, BLANK_CHECK, NO_ADDITIONAL_SENSE, in resp_space()
3552 mk_sense_info_tape(scp, NO_SENSE, NO_ADDITIONAL_SENSE, in resp_space()
3560 mk_sense_info_tape(scp, MEDIUM_ERROR, NO_ADDITIONAL_SENSE, in resp_space()
3566 static int resp_rewind(struct scsi_cmnd *scp, in resp_rewind() argument
3601 static int resp_format_medium(struct scsi_cmnd *scp, in resp_format_medium() argument
3605 unsigned char *cmd = scp->cmnd; in resp_format_medium()
3608 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 0, -1); in resp_format_medium()
3612 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 2, -1); in resp_format_medium()
3805 static int check_zbc_access_params(struct scsi_cmnd *scp, in check_zbc_access_params() argument
3808 struct scsi_device *sdp = scp->device; in check_zbc_access_params()
3816 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3826 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, in check_zbc_access_params()
3834 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3845 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3852 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3858 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
3869 mk_sense_buffer(scp, DATA_PROTECT, in check_zbc_access_params()
3881 (struct scsi_cmnd *scp, unsigned long long lba, in check_device_access_params() argument
3884 struct scsi_device *sdp = scp->device; in check_device_access_params()
3888 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in check_device_access_params()
3894 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in check_device_access_params()
3898 mk_sense_buffer(scp, DATA_PROTECT, WRITE_PROTECTED, 0x2); in check_device_access_params()
3902 return check_zbc_access_params(scp, lba, num, write); in check_device_access_params()
4138 static int do_device_access(struct sdeb_store_info *sip, struct scsi_cmnd *scp, in do_device_access() argument
4145 struct scsi_data_buffer *sdb = &scp->sdb; in do_device_access()
4165 if (scp->sc_data_direction != dir) in do_device_access()
4197 static int do_dout_fetch(struct scsi_cmnd *scp, u32 num, u8 *doutp) in do_dout_fetch() argument
4199 struct scsi_data_buffer *sdb = &scp->sdb; in do_dout_fetch()
4203 if (scp->sc_data_direction != DMA_TO_DEVICE) in do_dout_fetch()
4281 static void dif_copy_prot(struct scsi_cmnd *scp, sector_t sector, in dif_copy_prot() argument
4287 scp->device->hostdata, true); in dif_copy_prot()
4295 sg_miter_start(&miter, scsi_prot_sglist(scp), in dif_copy_prot()
4296 scsi_prot_sg_count(scp), SG_MITER_ATOMIC | in dif_copy_prot()
4327 static int prot_verify_read(struct scsi_cmnd *scp, sector_t start_sec, in prot_verify_read() argument
4334 scp->device->hostdata, true); in prot_verify_read()
4351 if (scp->cmnd[1] >> 5) { /* RDPROTECT */ in prot_verify_read()
4361 dif_copy_prot(scp, start_sec, sectors, true); in prot_verify_read()
4367 static int resp_read_tape(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_read_tape() argument
4370 u8 *cmd = scp->cmnd; in resp_read_tape()
4371 struct scsi_data_buffer *sdb = &scp->sdb; in resp_read_tape()
4378 mk_sense_invalid_opcode(scp); in resp_read_tape()
4384 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 1); in resp_read_tape()
4395 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_read_tape()
4407 mk_sense_info_tape(scp, NO_SENSE, NO_ADDITIONAL_SENSE, in resp_read_tape()
4410 scsi_set_resid(scp, (num - i) * size); in resp_read_tape()
4415 mk_sense_info_tape(scp, BLANK_CHECK, NO_ADDITIONAL_SENSE, in resp_read_tape()
4419 scsi_set_resid(scp, (num - i) * size); in resp_read_tape()
4428 scsi_set_resid(scp, (num - i) * size); in resp_read_tape()
4429 mk_sense_info_tape(scp, NO_SENSE, NO_ADDITIONAL_SENSE, in resp_read_tape()
4437 scsi_set_resid(scp, size - blp->fl_size); in resp_read_tape()
4439 mk_sense_info_tape(scp, NO_SENSE, NO_ADDITIONAL_SENSE, in resp_read_tape()
4448 mk_sense_info_tape(scp, NO_SENSE, NO_ADDITIONAL_SENSE, in resp_read_tape()
4459 static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_read_dt0() argument
4467 u8 *cmd = scp->cmnd; in resp_read_dt0()
4471 return resp_read_tape(scp, devip); in resp_read_dt0()
4515 mk_sense_invalid_opcode(scp); in resp_read_dt0()
4521 sdev_printk(KERN_ERR, scp->device, "Unprotected RD " in resp_read_dt0()
4534 ret = check_device_access_params(scp, lba, num, false); in resp_read_dt0()
4541 mk_sense_buffer(scp, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 0); in resp_read_dt0()
4543 if (0x70 == (scp->sense_buffer[0] & 0x7f)) { in resp_read_dt0()
4544 scp->sense_buffer[0] |= 0x80; /* Valid bit */ in resp_read_dt0()
4547 put_unaligned_be32(ret, scp->sense_buffer + 3); in resp_read_dt0()
4549 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_read_dt0()
4554 (sdebug_dix && scsi_prot_sg_count(scp))) { in resp_read_dt0()
4560 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_read_dt0()
4561 switch (prot_verify_read(scp, lba, num, ei_lba)) { in resp_read_dt0()
4565 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
4567 } else if (scp->prot_flags & SCSI_PROT_GUARD_CHECK) { in resp_read_dt0()
4569 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
4576 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 3); in resp_read_dt0()
4578 } else if (scp->prot_flags & SCSI_PROT_REF_CHECK) { in resp_read_dt0()
4580 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 3); in resp_read_dt0()
4587 ret = do_device_access(sip, scp, 0, lba, num, 0, false, false); in resp_read_dt0()
4593 scsi_set_resid(scp, scsi_bufflen(scp) - ret); in resp_read_dt0()
4598 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_read_dt0()
4603 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
4607 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
4769 static int resp_write_tape(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_tape() argument
4772 u8 *cmd = scp->cmnd; in resp_write_tape()
4773 struct scsi_data_buffer *sdb = &scp->sdb; in resp_write_tape()
4780 mk_sense_invalid_opcode(scp); in resp_write_tape()
4792 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_write_tape()
4799 scsi_set_resid(scp, num * transfer); in resp_write_tape()
4806 scsi_set_resid(scp, num * transfer - written); in resp_write_tape()
4813 mk_sense_info_tape(scp, VOLUME_OVERFLOW, in resp_write_tape()
4820 mk_sense_info_tape(scp, NO_SENSE, in resp_write_tape()
4830 static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_dt0() argument
4839 u8 *cmd = scp->cmnd; in resp_write_dt0()
4843 return resp_write_tape(scp, devip); in resp_write_dt0()
4892 mk_sense_invalid_opcode(scp); in resp_write_dt0()
4898 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_write_dt0()
4903 (sdebug_dix && scsi_prot_sg_count(scp)) || in resp_write_dt0()
4909 ret = check_device_access_params(scp, lba, num, true); in resp_write_dt0()
4917 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_dt0()
4918 switch (prot_verify_write(scp, lba, num, ei_lba)) { in resp_write_dt0()
4920 if (scp->prot_flags & SCSI_PROT_GUARD_CHECK) { in resp_write_dt0()
4922 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
4924 } else if (scp->cmnd[1] >> 5 != 3) { /* WRPROTECT != 3 */ in resp_write_dt0()
4926 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
4931 if (scp->prot_flags & SCSI_PROT_REF_CHECK) { in resp_write_dt0()
4933 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 3); in resp_write_dt0()
4935 } else if (scp->cmnd[1] >> 5 != 3) { /* WRPROTECT != 3 */ in resp_write_dt0()
4937 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 3); in resp_write_dt0()
4944 ret = do_device_access(sip, scp, 0, lba, num, group, true, false); in resp_write_dt0()
4958 sdev_printk(KERN_INFO, scp->device, in resp_write_dt0()
4965 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_write_dt0()
4970 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
4974 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
4986 static int resp_write_scat(struct scsi_cmnd *scp, in resp_write_scat() argument
4989 u8 *cmd = scp->cmnd; in resp_write_scat()
5021 mk_sense_invalid_opcode(scp); in resp_write_scat()
5027 sdev_printk(KERN_ERR, scp->device, in resp_write_scat()
5035 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
5038 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
5044 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
5047 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
5054 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
5057 res = fetch_to_dev_buffer(scp, lrdp, lbdof_blen); in resp_write_scat()
5072 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
5077 ret = check_device_access_params(scp, lba, num, true); in resp_write_scat()
5085 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
5088 mk_sense_buffer(scp, ILLEGAL_REQUEST, WRITE_ERROR_ASC, in resp_write_scat()
5095 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_scat()
5096 int prot_ret = prot_verify_write(scp, lba, num, in resp_write_scat()
5100 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, in resp_write_scat()
5111 ret = do_device_access(sip, scp, sg_off, lba, num, group, true, true); in resp_write_scat()
5121 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
5128 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_write_scat()
5134 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_scat()
5139 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_scat()
5156 static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num, in resp_write_same() argument
5159 struct scsi_device *sdp = scp->device; in resp_write_same()
5166 scp->device->hostdata, true); in resp_write_same()
5176 ret = check_device_access_params(scp, lba, num, true); in resp_write_same()
5194 ret = fetch_to_dev_buffer(scp, fs1p, lb_size); in resp_write_same()
5200 sdev_printk(KERN_INFO, scp->device, in resp_write_same()
5223 static int resp_write_same_10(struct scsi_cmnd *scp, in resp_write_same_10() argument
5226 u8 *cmd = scp->cmnd; in resp_write_same_10()
5234 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_10()
5242 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_write_same_10()
5245 return resp_write_same(scp, lba, num, ei_lba, unmap, false); in resp_write_same_10()
5248 static int resp_write_same_16(struct scsi_cmnd *scp, in resp_write_same_16() argument
5251 u8 *cmd = scp->cmnd; in resp_write_same_16()
5260 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_16()
5270 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 10, -1); in resp_write_same_16()
5273 return resp_write_same(scp, lba, num, ei_lba, unmap, ndob); in resp_write_same_16()
5279 static int resp_write_buffer(struct scsi_cmnd *scp, in resp_write_buffer() argument
5282 u8 *cmd = scp->cmnd; in resp_write_buffer()
5283 struct scsi_device *sdp = scp->device; in resp_write_buffer()
5325 static int resp_comp_write(struct scsi_cmnd *scp, in resp_comp_write() argument
5328 u8 *cmd = scp->cmnd; in resp_comp_write()
5344 mk_sense_invalid_opcode(scp); in resp_comp_write()
5350 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_comp_write()
5352 ret = check_device_access_params(scp, lba, num, false); in resp_comp_write()
5358 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_comp_write()
5363 ret = do_dout_fetch(scp, dnum, arr); in resp_comp_write()
5368 sdev_printk(KERN_INFO, scp->device, "%s: compare_write: cdb " in resp_comp_write()
5375 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_comp_write()
5397 static int resp_unmap(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_unmap() argument
5407 payload_len = get_unaligned_be16(scp->cmnd + 7); in resp_unmap()
5408 BUG_ON(scsi_bufflen(scp) != payload_len); in resp_unmap()
5412 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_unmap()
5416 buf = kzalloc(scsi_bufflen(scp), GFP_ATOMIC); in resp_unmap()
5418 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_unmap()
5423 scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); in resp_unmap()
5436 ret = check_device_access_params(scp, lba, num, true); in resp_unmap()
5454 static int resp_get_lba_status(struct scsi_cmnd *scp, in resp_get_lba_status() argument
5457 u8 *cmd = scp->cmnd; in resp_get_lba_status()
5469 ret = check_device_access_params(scp, lba, 1, false); in resp_get_lba_status()
5493 return fill_from_dev_buffer(scp, arr, SDEBUG_GET_LBA_STATUS_LEN); in resp_get_lba_status()
5496 static int resp_get_stream_status(struct scsi_cmnd *scp, in resp_get_stream_status() argument
5500 const u8 *cmd = scp->cmnd; in resp_get_stream_status()
5509 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 10, -1); in resp_get_stream_status()
5514 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, -1); in resp_get_stream_status()
5538 return fill_from_dev_buffer(scp, arr, min(offset, alloc_len)); in resp_get_stream_status()
5541 static int resp_sync_cache(struct scsi_cmnd *scp, in resp_sync_cache() argument
5547 u8 *cmd = scp->cmnd; in resp_sync_cache()
5557 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_sync_cache()
5577 static int resp_pre_fetch(struct scsi_cmnd *scp, in resp_pre_fetch() argument
5584 u8 *cmd = scp->cmnd; in resp_pre_fetch()
5597 mk_sense_invalid_fld(scp, SDEB_IN_CDB, in resp_pre_fetch()
5606 return fill_from_dev_buffer(scp, arr, in resp_pre_fetch()
5609 mk_sense_invalid_opcode(scp); in resp_pre_fetch()
5621 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_pre_fetch()
5655 static int resp_report_luns(struct scsi_cmnd *scp, in resp_report_luns() argument
5658 unsigned char *cmd = scp->cmnd; in resp_report_luns()
5679 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_report_luns()
5701 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_report_luns()
5710 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_report_luns()
5734 res = p_fill_from_dev_buffer(scp, arr, n, off_rsp); in resp_report_luns()
5744 res = p_fill_from_dev_buffer(scp, arr, j * sz_lun, off_rsp); in resp_report_luns()
5748 static int resp_verify(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_verify() argument
5757 u8 *cmd = scp->cmnd; in resp_verify()
5764 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_verify()
5779 mk_sense_invalid_opcode(scp); in resp_verify()
5786 ret = check_device_access_params(scp, lba, a_num, false); in resp_verify()
5792 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_verify()
5799 ret = do_dout_fetch(scp, a_num, arr); in resp_verify()
5804 sdev_printk(KERN_INFO, scp->device, in resp_verify()
5814 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_verify()
5827 static int resp_report_zones(struct scsi_cmnd *scp, in resp_report_zones() argument
5836 u8 *cmd = scp->cmnd; in resp_report_zones()
5841 mk_sense_invalid_opcode(scp); in resp_report_zones()
5852 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_report_zones()
5860 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_report_zones()
5926 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_report_zones()
5960 ret = fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, rep_len)); in resp_report_zones()
5968 static int resp_atomic_write(struct scsi_cmnd *scp, in resp_atomic_write() argument
5972 u8 *cmd = scp->cmnd; in resp_atomic_write()
5978 mk_sense_invalid_opcode(scp); in resp_atomic_write()
5992 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_atomic_write()
5998 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_atomic_write()
6004 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 12, -1); in resp_atomic_write()
6009 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 12, -1); in resp_atomic_write()
6014 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 12, -1); in resp_atomic_write()
6019 ret = do_device_access(sip, scp, 0, lba, len, 0, true, true); in resp_atomic_write()
6039 static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_open_zone() argument
6044 u8 *cmd = scp->cmnd; in resp_open_zone()
6050 mk_sense_invalid_opcode(scp); in resp_open_zone()
6059 mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC, in resp_open_zone()
6072 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_open_zone()
6079 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_open_zone()
6084 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_open_zone()
6094 mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC, in resp_open_zone()
6114 static int resp_close_zone(struct scsi_cmnd *scp, in resp_close_zone() argument
6119 u8 *cmd = scp->cmnd; in resp_close_zone()
6125 mk_sense_invalid_opcode(scp); in resp_close_zone()
6139 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_close_zone()
6146 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_close_zone()
6151 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_close_zone()
6186 static int resp_finish_zone(struct scsi_cmnd *scp, in resp_finish_zone() argument
6192 u8 *cmd = scp->cmnd; in resp_finish_zone()
6197 mk_sense_invalid_opcode(scp); in resp_finish_zone()
6211 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_finish_zone()
6218 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_finish_zone()
6223 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_finish_zone()
6267 static int resp_rwp_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_rwp_zone() argument
6272 u8 *cmd = scp->cmnd; in resp_rwp_zone()
6277 mk_sense_invalid_opcode(scp); in resp_rwp_zone()
6290 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_rwp_zone()
6297 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_rwp_zone()
6302 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_rwp_zone()
6323 struct scsi_cmnd *scp = (struct scsi_cmnd *)sdsc - 1; in sdebug_q_cmd_complete() local
6333 if (!scp) { in sdebug_q_cmd_complete()
6347 blk_abort_request(scsi_cmd_to_rq(scp)); in sdebug_q_cmd_complete()
6351 scsi_done(scp); /* callback to mid level */ in sdebug_q_cmd_complete()
8904 static bool fake_timeout(struct scsi_cmnd *scp) in fake_timeout() argument
8912 scsi_medium_access_command(scp)) in fake_timeout()
8919 static int resp_not_ready(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_not_ready() argument
8924 struct scsi_device *sdp = scp->device; in resp_not_ready()
8936 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x1); in resp_not_ready()
8940 if (scp->cmnd[0] == TEST_UNIT_READY) { in resp_not_ready()
8949 scsi_set_sense_information(scp->sense_buffer, SCSI_SENSE_BUFFERSIZE, in resp_not_ready()
8954 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x2); in resp_not_ready()
9160 struct scsi_cmnd *scp) in scsi_debug_queuecommand() argument
9163 struct scsi_device *sdp = scp->device; in scsi_debug_queuecommand()
9167 u8 *cmd = scp->cmnd; in scsi_debug_queuecommand()
9181 scsi_set_resid(scp, 0); in scsi_debug_queuecommand()
9193 len = scp->cmd_len; in scsi_debug_queuecommand()
9203 blk_mq_unique_tag(scsi_cmd_to_rq(scp)), b); in scsi_debug_queuecommand()
9220 if (sdebug_timeout_cmd(scp)) { in scsi_debug_queuecommand()
9221 scmd_printk(KERN_INFO, scp, "timeout command 0x%x\n", opcode); in scsi_debug_queuecommand()
9225 ret = sdebug_fail_queue_cmd(scp); in scsi_debug_queuecommand()
9227 scmd_printk(KERN_INFO, scp, "fail queue command 0x%x with 0x%x\n", in scsi_debug_queuecommand()
9232 if (sdebug_fail_cmd(scp, &ret, &err)) { in scsi_debug_queuecommand()
9233 scmd_printk(KERN_INFO, scp, in scsi_debug_queuecommand()
9266 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 4); in scsi_debug_queuecommand()
9268 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 8, 7); in scsi_debug_queuecommand()
9270 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
9276 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
9283 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
9297 mk_sense_invalid_fld(scp, SDEB_IN_CDB, k, j); in scsi_debug_queuecommand()
9305 errsts = make_ua(scp, devip); in scsi_debug_queuecommand()
9309 if (unlikely(((F_M_ACCESS & flags) || scp->cmnd[0] == TEST_UNIT_READY) && in scsi_debug_queuecommand()
9311 errsts = resp_not_ready(scp, devip); in scsi_debug_queuecommand()
9318 if (fake_timeout(scp)) in scsi_debug_queuecommand()
9328 return schedule_resp(scp, devip, errsts, pfp, 0, 0); in scsi_debug_queuecommand()
9341 return schedule_resp(scp, devip, errsts, pfp, jdelay, 0); in scsi_debug_queuecommand()
9343 return schedule_resp(scp, devip, errsts, pfp, sdebug_jdelay, in scsi_debug_queuecommand()
9346 return schedule_resp(scp, devip, check_condition_result, NULL, 0, 0); in scsi_debug_queuecommand()
9348 return schedule_resp(scp, NULL, DID_NO_CONNECT << 16, NULL, 0, 0); in scsi_debug_queuecommand()