Lines Matching full:scp

919 static void mk_sense_invalid_fld(struct scsi_cmnd *scp,  in mk_sense_invalid_fld()  argument
927 sbuff = scp->sense_buffer; in mk_sense_invalid_fld()
929 sdev_printk(KERN_ERR, scp->device, in mk_sense_invalid_fld()
935 scsi_build_sense(scp, sdebug_dsense, ILLEGAL_REQUEST, asc, 0); in mk_sense_invalid_fld()
954 sdev_printk(KERN_INFO, scp->device, "%s: [sense_key,asc,ascq" in mk_sense_invalid_fld()
959 static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) in mk_sense_buffer() argument
961 if (!scp->sense_buffer) { in mk_sense_buffer()
962 sdev_printk(KERN_ERR, scp->device, in mk_sense_buffer()
966 memset(scp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in mk_sense_buffer()
968 scsi_build_sense(scp, sdebug_dsense, key, asc, asq); in mk_sense_buffer()
971 sdev_printk(KERN_INFO, scp->device, in mk_sense_buffer()
976 static void mk_sense_invalid_opcode(struct scsi_cmnd *scp) in mk_sense_invalid_opcode() argument
978 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_OPCODE, 0); in mk_sense_invalid_opcode()
1068 static int make_ua(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in make_ua() argument
1078 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1084 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1090 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1096 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
1102 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
1108 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1115 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1132 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1146 sdev_printk(KERN_INFO, scp->device, in make_ua()
1155 static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fill_from_dev_buffer() argument
1159 struct scsi_data_buffer *sdb = &scp->sdb; in fill_from_dev_buffer()
1163 if (scp->sc_data_direction != DMA_FROM_DEVICE) in fill_from_dev_buffer()
1168 scsi_set_resid(scp, scsi_bufflen(scp) - act_len); in fill_from_dev_buffer()
1178 static int p_fill_from_dev_buffer(struct scsi_cmnd *scp, const void *arr, in p_fill_from_dev_buffer() argument
1182 struct scsi_data_buffer *sdb = &scp->sdb; in p_fill_from_dev_buffer()
1187 if (scp->sc_data_direction != DMA_FROM_DEVICE) in p_fill_from_dev_buffer()
1193 __func__, off_dst, scsi_bufflen(scp), act_len, in p_fill_from_dev_buffer()
1194 scsi_get_resid(scp)); in p_fill_from_dev_buffer()
1195 n = scsi_bufflen(scp) - (off_dst + act_len); in p_fill_from_dev_buffer()
1196 scsi_set_resid(scp, min_t(u32, scsi_get_resid(scp), n)); in p_fill_from_dev_buffer()
1203 static int fetch_to_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fetch_to_dev_buffer() argument
1206 if (!scsi_bufflen(scp)) in fetch_to_dev_buffer()
1208 if (scp->sc_data_direction != DMA_TO_DEVICE) in fetch_to_dev_buffer()
1211 return scsi_sg_copy_to_buffer(scp, arr, arr_len); in fetch_to_dev_buffer()
1568 static int resp_inquiry(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_inquiry() argument
1572 unsigned char *cmd = scp->cmnd; in resp_inquiry()
1584 have_wlun = scsi_is_wlun(scp->device->lun); in resp_inquiry()
1593 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 1); in resp_inquiry()
1685 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_inquiry()
1690 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
1726 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
1736 static int resp_requests(struct scsi_cmnd *scp, in resp_requests() argument
1739 unsigned char *cmd = scp->cmnd; in resp_requests()
1787 return fill_from_dev_buffer(scp, arr, min_t(u32, len, alloc_len)); in resp_requests()
1790 static int resp_start_stop(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_start_stop() argument
1792 unsigned char *cmd = scp->cmnd; in resp_start_stop()
1798 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 7); in resp_start_stop()
1819 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 0 /* START bit */); in resp_start_stop()
1845 static int resp_readcap(struct scsi_cmnd *scp, in resp_readcap() argument
1860 return fill_from_dev_buffer(scp, arr, SDEBUG_READCAP_ARR_SZ); in resp_readcap()
1864 static int resp_readcap16(struct scsi_cmnd *scp, in resp_readcap16() argument
1867 unsigned char *cmd = scp->cmnd; in resp_readcap16()
1904 return fill_from_dev_buffer(scp, arr, in resp_readcap16()
1910 static int resp_report_tgtpgs(struct scsi_cmnd *scp, in resp_report_tgtpgs() argument
1913 unsigned char *cmd = scp->cmnd; in resp_report_tgtpgs()
1981 ret = fill_from_dev_buffer(scp, arr, in resp_report_tgtpgs()
1987 static int resp_rsup_opcodes(struct scsi_cmnd *scp, in resp_rsup_opcodes() argument
1998 u8 *cmd = scp->cmnd; in resp_rsup_opcodes()
2006 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_opcodes()
2015 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_rsup_opcodes()
2076 mk_sense_invalid_fld(scp, SDEB_IN_CDB, in resp_rsup_opcodes()
2084 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, -1); in resp_rsup_opcodes()
2127 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_rsup_opcodes()
2133 errsts = fill_from_dev_buffer(scp, arr, len); in resp_rsup_opcodes()
2138 static int resp_rsup_tmfs(struct scsi_cmnd *scp, in resp_rsup_tmfs() argument
2144 u8 *cmd = scp->cmnd; in resp_rsup_tmfs()
2150 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_tmfs()
2162 return fill_from_dev_buffer(scp, arr, len); in resp_rsup_tmfs()
2327 static int resp_mode_sense(struct scsi_cmnd *scp, in resp_mode_sense() argument
2334 int target = scp->device->id; in resp_mode_sense()
2337 unsigned char *cmd = scp->cmnd; in resp_mode_sense()
2355 mk_sense_buffer(scp, ILLEGAL_REQUEST, SAVING_PARAMS_UNSUP, 0); in resp_mode_sense()
2399 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2433 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2473 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2482 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_mode_sense()
2489 return fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, offset)); in resp_mode_sense()
2494 static int resp_mode_select(struct scsi_cmnd *scp, in resp_mode_select() argument
2500 unsigned char *cmd = scp->cmnd; in resp_mode_select()
2508 mk_sense_invalid_fld(scp, SDEB_IN_CDB, mselect6 ? 4 : 7, -1); in resp_mode_select()
2511 res = fetch_to_dev_buffer(scp, arr, param_len); in resp_mode_select()
2515 sdev_printk(KERN_INFO, scp->device, in resp_mode_select()
2522 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 0, -1); in resp_mode_select()
2528 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 7); in resp_mode_select()
2535 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_mode_select()
2569 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 5); in resp_mode_select()
2613 static int resp_log_sense(struct scsi_cmnd *scp, in resp_log_sense() argument
2619 unsigned char *cmd = scp->cmnd; in resp_log_sense()
2625 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, ppc ? 1 : 0); in resp_log_sense()
2648 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2692 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2701 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2705 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_log_sense()
2709 return fill_from_dev_buffer(scp, arr, in resp_log_sense()
2884 static int check_zbc_access_params(struct scsi_cmnd *scp, in check_zbc_access_params() argument
2887 struct scsi_device *sdp = scp->device; in check_zbc_access_params()
2897 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2907 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, in check_zbc_access_params()
2915 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2926 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2933 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2939 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2950 mk_sense_buffer(scp, DATA_PROTECT, in check_zbc_access_params()
2962 (struct scsi_cmnd *scp, unsigned long long lba, in check_device_access_params() argument
2965 struct scsi_device *sdp = scp->device; in check_device_access_params()
2969 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in check_device_access_params()
2975 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in check_device_access_params()
2979 mk_sense_buffer(scp, DATA_PROTECT, WRITE_PROTECTED, 0x2); in check_device_access_params()
2983 return check_zbc_access_params(scp, lba, num, write); in check_device_access_params()
3005 static int do_device_access(struct sdeb_store_info *sip, struct scsi_cmnd *scp, in do_device_access() argument
3011 struct scsi_data_buffer *sdb = &scp->sdb; in do_device_access()
3023 if (scp->sc_data_direction != dir) in do_device_access()
3048 static int do_dout_fetch(struct scsi_cmnd *scp, u32 num, u8 *doutp) in do_dout_fetch() argument
3050 struct scsi_data_buffer *sdb = &scp->sdb; in do_dout_fetch()
3054 if (scp->sc_data_direction != DMA_TO_DEVICE) in do_dout_fetch()
3132 static void dif_copy_prot(struct scsi_cmnd *scp, sector_t sector, in dif_copy_prot() argument
3138 scp->device->hostdata, true); in dif_copy_prot()
3146 sg_miter_start(&miter, scsi_prot_sglist(scp), in dif_copy_prot()
3147 scsi_prot_sg_count(scp), SG_MITER_ATOMIC | in dif_copy_prot()
3178 static int prot_verify_read(struct scsi_cmnd *scp, sector_t start_sec, in prot_verify_read() argument
3185 scp->device->hostdata, true); in prot_verify_read()
3202 if (scp->cmnd[1] >> 5) { /* RDPROTECT */ in prot_verify_read()
3212 dif_copy_prot(scp, start_sec, sectors, true); in prot_verify_read()
3282 static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_read_dt0() argument
3290 u8 *cmd = scp->cmnd; in resp_read_dt0()
3334 mk_sense_invalid_opcode(scp); in resp_read_dt0()
3340 sdev_printk(KERN_ERR, scp->device, "Unprotected RD " in resp_read_dt0()
3349 ret = check_device_access_params(scp, lba, num, false); in resp_read_dt0()
3356 mk_sense_buffer(scp, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 0); in resp_read_dt0()
3358 if (0x70 == (scp->sense_buffer[0] & 0x7f)) { in resp_read_dt0()
3359 scp->sense_buffer[0] |= 0x80; /* Valid bit */ in resp_read_dt0()
3362 put_unaligned_be32(ret, scp->sense_buffer + 3); in resp_read_dt0()
3364 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_read_dt0()
3371 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_read_dt0()
3372 switch (prot_verify_read(scp, lba, num, ei_lba)) { in resp_read_dt0()
3376 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
3378 } else if (scp->prot_flags & SCSI_PROT_GUARD_CHECK) { in resp_read_dt0()
3380 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
3387 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 3); in resp_read_dt0()
3389 } else if (scp->prot_flags & SCSI_PROT_REF_CHECK) { in resp_read_dt0()
3391 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 3); in resp_read_dt0()
3398 ret = do_device_access(sip, scp, 0, lba, num, false); in resp_read_dt0()
3403 scsi_set_resid(scp, scsi_bufflen(scp) - ret); in resp_read_dt0()
3408 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_read_dt0()
3413 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
3417 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
3579 static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_dt0() argument
3587 u8 *cmd = scp->cmnd; in resp_write_dt0()
3631 mk_sense_invalid_opcode(scp); in resp_write_dt0()
3637 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_write_dt0()
3642 ret = check_device_access_params(scp, lba, num, true); in resp_write_dt0()
3649 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_dt0()
3650 switch (prot_verify_write(scp, lba, num, ei_lba)) { in resp_write_dt0()
3652 if (scp->prot_flags & SCSI_PROT_GUARD_CHECK) { in resp_write_dt0()
3654 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
3656 } else if (scp->cmnd[1] >> 5 != 3) { /* WRPROTECT != 3 */ in resp_write_dt0()
3658 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
3663 if (scp->prot_flags & SCSI_PROT_REF_CHECK) { in resp_write_dt0()
3665 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 3); in resp_write_dt0()
3667 } else if (scp->cmnd[1] >> 5 != 3) { /* WRPROTECT != 3 */ in resp_write_dt0()
3669 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 3); in resp_write_dt0()
3676 ret = do_device_access(sip, scp, 0, lba, num, true); in resp_write_dt0()
3687 sdev_printk(KERN_INFO, scp->device, in resp_write_dt0()
3694 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_write_dt0()
3699 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
3703 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
3715 static int resp_write_scat(struct scsi_cmnd *scp, in resp_write_scat() argument
3718 u8 *cmd = scp->cmnd; in resp_write_scat()
3747 mk_sense_invalid_opcode(scp); in resp_write_scat()
3753 sdev_printk(KERN_ERR, scp->device, in resp_write_scat()
3761 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3764 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
3770 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3773 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
3780 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3783 res = fetch_to_dev_buffer(scp, lrdp, lbdof_blen); in resp_write_scat()
3797 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3802 ret = check_device_access_params(scp, lba, num, true); in resp_write_scat()
3810 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3813 mk_sense_buffer(scp, ILLEGAL_REQUEST, WRITE_ERROR_ASC, in resp_write_scat()
3820 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_scat()
3821 int prot_ret = prot_verify_write(scp, lba, num, in resp_write_scat()
3825 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, in resp_write_scat()
3832 ret = do_device_access(sip, scp, sg_off, lba, num, true); in resp_write_scat()
3842 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3849 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_write_scat()
3855 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_scat()
3860 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_scat()
3877 static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num, in resp_write_same() argument
3880 struct scsi_device *sdp = scp->device; in resp_write_same()
3887 scp->device->hostdata, true); in resp_write_same()
3893 ret = check_device_access_params(scp, lba, num, true); in resp_write_same()
3912 ret = fetch_to_dev_buffer(scp, fs1p, lb_size); in resp_write_same()
3918 sdev_printk(KERN_INFO, scp->device, in resp_write_same()
3939 static int resp_write_same_10(struct scsi_cmnd *scp, in resp_write_same_10() argument
3942 u8 *cmd = scp->cmnd; in resp_write_same_10()
3950 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_10()
3958 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_write_same_10()
3961 return resp_write_same(scp, lba, num, ei_lba, unmap, false); in resp_write_same_10()
3964 static int resp_write_same_16(struct scsi_cmnd *scp, in resp_write_same_16() argument
3967 u8 *cmd = scp->cmnd; in resp_write_same_16()
3976 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_16()
3986 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 10, -1); in resp_write_same_16()
3989 return resp_write_same(scp, lba, num, ei_lba, unmap, ndob); in resp_write_same_16()
3995 static int resp_write_buffer(struct scsi_cmnd *scp, in resp_write_buffer() argument
3998 u8 *cmd = scp->cmnd; in resp_write_buffer()
3999 struct scsi_device *sdp = scp->device; in resp_write_buffer()
4041 static int resp_comp_write(struct scsi_cmnd *scp, in resp_comp_write() argument
4044 u8 *cmd = scp->cmnd; in resp_comp_write()
4060 mk_sense_invalid_opcode(scp); in resp_comp_write()
4066 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_comp_write()
4068 ret = check_device_access_params(scp, lba, num, false); in resp_comp_write()
4074 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_comp_write()
4081 ret = do_dout_fetch(scp, dnum, arr); in resp_comp_write()
4086 sdev_printk(KERN_INFO, scp->device, "%s: compare_write: cdb " in resp_comp_write()
4090 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_comp_write()
4108 static int resp_unmap(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_unmap() argument
4118 payload_len = get_unaligned_be16(scp->cmnd + 7); in resp_unmap()
4119 BUG_ON(scsi_bufflen(scp) != payload_len); in resp_unmap()
4123 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_unmap()
4127 buf = kzalloc(scsi_bufflen(scp), GFP_ATOMIC); in resp_unmap()
4129 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_unmap()
4134 scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); in resp_unmap()
4147 ret = check_device_access_params(scp, lba, num, true); in resp_unmap()
4165 static int resp_get_lba_status(struct scsi_cmnd *scp, in resp_get_lba_status() argument
4168 u8 *cmd = scp->cmnd; in resp_get_lba_status()
4180 ret = check_device_access_params(scp, lba, 1, false); in resp_get_lba_status()
4204 return fill_from_dev_buffer(scp, arr, SDEBUG_GET_LBA_STATUS_LEN); in resp_get_lba_status()
4207 static int resp_sync_cache(struct scsi_cmnd *scp, in resp_sync_cache() argument
4213 u8 *cmd = scp->cmnd; in resp_sync_cache()
4223 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_sync_cache()
4240 static int resp_pre_fetch(struct scsi_cmnd *scp, in resp_pre_fetch() argument
4247 u8 *cmd = scp->cmnd; in resp_pre_fetch()
4259 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_pre_fetch()
4292 static int resp_report_luns(struct scsi_cmnd *scp, in resp_report_luns() argument
4295 unsigned char *cmd = scp->cmnd; in resp_report_luns()
4316 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_report_luns()
4338 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_report_luns()
4347 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_report_luns()
4371 res = p_fill_from_dev_buffer(scp, arr, n, off_rsp); in resp_report_luns()
4381 res = p_fill_from_dev_buffer(scp, arr, j * sz_lun, off_rsp); in resp_report_luns()
4385 static int resp_verify(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_verify() argument
4394 u8 *cmd = scp->cmnd; in resp_verify()
4401 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_verify()
4416 mk_sense_invalid_opcode(scp); in resp_verify()
4423 ret = check_device_access_params(scp, lba, a_num, false); in resp_verify()
4429 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_verify()
4436 ret = do_dout_fetch(scp, a_num, arr); in resp_verify()
4441 sdev_printk(KERN_INFO, scp->device, in resp_verify()
4451 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_verify()
4464 static int resp_report_zones(struct scsi_cmnd *scp, in resp_report_zones() argument
4473 u8 *cmd = scp->cmnd; in resp_report_zones()
4478 mk_sense_invalid_opcode(scp); in resp_report_zones()
4489 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_report_zones()
4497 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_report_zones()
4563 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_report_zones()
4597 ret = fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, rep_len)); in resp_report_zones()
4617 static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_open_zone() argument
4622 u8 *cmd = scp->cmnd; in resp_open_zone()
4628 mk_sense_invalid_opcode(scp); in resp_open_zone()
4638 mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC, in resp_open_zone()
4651 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_open_zone()
4658 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_open_zone()
4663 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_open_zone()
4673 mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC, in resp_open_zone()
4693 static int resp_close_zone(struct scsi_cmnd *scp, in resp_close_zone() argument
4698 u8 *cmd = scp->cmnd; in resp_close_zone()
4704 mk_sense_invalid_opcode(scp); in resp_close_zone()
4718 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_close_zone()
4725 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_close_zone()
4730 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_close_zone()
4765 static int resp_finish_zone(struct scsi_cmnd *scp, in resp_finish_zone() argument
4771 u8 *cmd = scp->cmnd; in resp_finish_zone()
4776 mk_sense_invalid_opcode(scp); in resp_finish_zone()
4790 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_finish_zone()
4797 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_finish_zone()
4802 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_finish_zone()
4846 static int resp_rwp_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_rwp_zone() argument
4851 u8 *cmd = scp->cmnd; in resp_rwp_zone()
4856 mk_sense_invalid_opcode(scp); in resp_rwp_zone()
4869 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_rwp_zone()
4876 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_rwp_zone()
4881 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_rwp_zone()
4902 struct scsi_cmnd *scp = sqcp->scmd; in sdebug_q_cmd_complete() local
4912 if (!scp) { in sdebug_q_cmd_complete()
4917 sdsc = scsi_cmd_priv(scp); in sdebug_q_cmd_complete()
4922 ASSIGN_QUEUED_CMD(scp, NULL); in sdebug_q_cmd_complete()
4928 blk_abort_request(scsi_cmd_to_rq(scp)); in sdebug_q_cmd_complete()
4932 scsi_done(scp); /* callback to mid level */ in sdebug_q_cmd_complete()
7331 static bool fake_timeout(struct scsi_cmnd *scp) in fake_timeout() argument
7339 scsi_medium_access_command(scp)) in fake_timeout()
7346 static int resp_not_ready(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_not_ready() argument
7351 struct scsi_device *sdp = scp->device; in resp_not_ready()
7363 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x1); in resp_not_ready()
7367 if (scp->cmnd[0] == TEST_UNIT_READY) { in resp_not_ready()
7376 scsi_set_sense_information(scp->sense_buffer, SCSI_SENSE_BUFFERSIZE, in resp_not_ready()
7381 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x2); in resp_not_ready()
7500 struct scsi_cmnd *scp) in scsi_debug_queuecommand() argument
7503 struct scsi_device *sdp = scp->device; in scsi_debug_queuecommand()
7507 u8 *cmd = scp->cmnd; in scsi_debug_queuecommand()
7519 scsi_set_resid(scp, 0); in scsi_debug_queuecommand()
7531 len = scp->cmd_len; in scsi_debug_queuecommand()
7541 blk_mq_unique_tag(scsi_cmd_to_rq(scp)), b); in scsi_debug_queuecommand()
7581 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 4); in scsi_debug_queuecommand()
7583 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 8, 7); in scsi_debug_queuecommand()
7585 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
7591 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
7598 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
7612 mk_sense_invalid_fld(scp, SDEB_IN_CDB, k, j); in scsi_debug_queuecommand()
7620 errsts = make_ua(scp, devip); in scsi_debug_queuecommand()
7624 if (unlikely(((F_M_ACCESS & flags) || scp->cmnd[0] == TEST_UNIT_READY) && in scsi_debug_queuecommand()
7626 errsts = resp_not_ready(scp, devip); in scsi_debug_queuecommand()
7633 if (fake_timeout(scp)) in scsi_debug_queuecommand()
7643 return schedule_resp(scp, devip, errsts, pfp, 0, 0); in scsi_debug_queuecommand()
7656 return schedule_resp(scp, devip, errsts, pfp, jdelay, 0); in scsi_debug_queuecommand()
7658 return schedule_resp(scp, devip, errsts, pfp, sdebug_jdelay, in scsi_debug_queuecommand()
7661 return schedule_resp(scp, devip, check_condition_result, NULL, 0, 0); in scsi_debug_queuecommand()
7663 return schedule_resp(scp, NULL, DID_NO_CONNECT << 16, NULL, 0, 0); in scsi_debug_queuecommand()