Lines Matching full:scp

918 static void mk_sense_invalid_fld(struct scsi_cmnd *scp,  in mk_sense_invalid_fld()  argument
926 sbuff = scp->sense_buffer; in mk_sense_invalid_fld()
928 sdev_printk(KERN_ERR, scp->device, in mk_sense_invalid_fld()
934 scsi_build_sense(scp, sdebug_dsense, ILLEGAL_REQUEST, asc, 0); in mk_sense_invalid_fld()
953 sdev_printk(KERN_INFO, scp->device, "%s: [sense_key,asc,ascq" in mk_sense_invalid_fld()
958 static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) in mk_sense_buffer() argument
960 if (!scp->sense_buffer) { in mk_sense_buffer()
961 sdev_printk(KERN_ERR, scp->device, in mk_sense_buffer()
965 memset(scp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in mk_sense_buffer()
967 scsi_build_sense(scp, sdebug_dsense, key, asc, asq); in mk_sense_buffer()
970 sdev_printk(KERN_INFO, scp->device, in mk_sense_buffer()
975 static void mk_sense_invalid_opcode(struct scsi_cmnd *scp) in mk_sense_invalid_opcode() argument
977 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_OPCODE, 0); in mk_sense_invalid_opcode()
1070 static int make_ua(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in make_ua() argument
1080 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1086 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
1092 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
1098 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
1104 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1111 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1128 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
1142 sdev_printk(KERN_INFO, scp->device, in make_ua()
1151 static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fill_from_dev_buffer() argument
1155 struct scsi_data_buffer *sdb = &scp->sdb; in fill_from_dev_buffer()
1159 if (scp->sc_data_direction != DMA_FROM_DEVICE) in fill_from_dev_buffer()
1164 scsi_set_resid(scp, scsi_bufflen(scp) - act_len); in fill_from_dev_buffer()
1174 static int p_fill_from_dev_buffer(struct scsi_cmnd *scp, const void *arr, in p_fill_from_dev_buffer() argument
1178 struct scsi_data_buffer *sdb = &scp->sdb; in p_fill_from_dev_buffer()
1183 if (scp->sc_data_direction != DMA_FROM_DEVICE) in p_fill_from_dev_buffer()
1189 __func__, off_dst, scsi_bufflen(scp), act_len, in p_fill_from_dev_buffer()
1190 scsi_get_resid(scp)); in p_fill_from_dev_buffer()
1191 n = scsi_bufflen(scp) - (off_dst + act_len); in p_fill_from_dev_buffer()
1192 scsi_set_resid(scp, min_t(int, scsi_get_resid(scp), n)); in p_fill_from_dev_buffer()
1199 static int fetch_to_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fetch_to_dev_buffer() argument
1202 if (!scsi_bufflen(scp)) in fetch_to_dev_buffer()
1204 if (scp->sc_data_direction != DMA_TO_DEVICE) in fetch_to_dev_buffer()
1207 return scsi_sg_copy_to_buffer(scp, arr, arr_len); in fetch_to_dev_buffer()
1560 static int resp_inquiry(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_inquiry() argument
1564 unsigned char *cmd = scp->cmnd; in resp_inquiry()
1575 have_wlun = scsi_is_wlun(scp->device->lun); in resp_inquiry()
1584 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 1); in resp_inquiry()
1675 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_inquiry()
1680 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
1716 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
1726 static int resp_requests(struct scsi_cmnd *scp, in resp_requests() argument
1729 unsigned char *cmd = scp->cmnd; in resp_requests()
1777 return fill_from_dev_buffer(scp, arr, min_t(int, len, alloc_len)); in resp_requests()
1780 static int resp_start_stop(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_start_stop() argument
1782 unsigned char *cmd = scp->cmnd; in resp_start_stop()
1788 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 7); in resp_start_stop()
1809 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 0 /* START bit */); in resp_start_stop()
1835 static int resp_readcap(struct scsi_cmnd *scp, in resp_readcap() argument
1850 return fill_from_dev_buffer(scp, arr, SDEBUG_READCAP_ARR_SZ); in resp_readcap()
1854 static int resp_readcap16(struct scsi_cmnd *scp, in resp_readcap16() argument
1857 unsigned char *cmd = scp->cmnd; in resp_readcap16()
1887 return fill_from_dev_buffer(scp, arr, in resp_readcap16()
1893 static int resp_report_tgtpgs(struct scsi_cmnd *scp, in resp_report_tgtpgs() argument
1896 unsigned char *cmd = scp->cmnd; in resp_report_tgtpgs()
1963 ret = fill_from_dev_buffer(scp, arr, in resp_report_tgtpgs()
1969 static int resp_rsup_opcodes(struct scsi_cmnd *scp, in resp_rsup_opcodes() argument
1980 u8 *cmd = scp->cmnd; in resp_rsup_opcodes()
1988 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_opcodes()
1997 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_rsup_opcodes()
2058 mk_sense_invalid_fld(scp, SDEB_IN_CDB, in resp_rsup_opcodes()
2066 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, -1); in resp_rsup_opcodes()
2109 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_rsup_opcodes()
2115 errsts = fill_from_dev_buffer(scp, arr, len); in resp_rsup_opcodes()
2120 static int resp_rsup_tmfs(struct scsi_cmnd *scp, in resp_rsup_tmfs() argument
2126 u8 *cmd = scp->cmnd; in resp_rsup_tmfs()
2132 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_tmfs()
2144 return fill_from_dev_buffer(scp, arr, len); in resp_rsup_tmfs()
2309 static int resp_mode_sense(struct scsi_cmnd *scp, in resp_mode_sense() argument
2315 int target = scp->device->id; in resp_mode_sense()
2318 unsigned char *cmd = scp->cmnd; in resp_mode_sense()
2336 mk_sense_buffer(scp, ILLEGAL_REQUEST, SAVING_PARAMS_UNSUP, 0); in resp_mode_sense()
2380 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2414 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2454 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2463 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_mode_sense()
2470 return fill_from_dev_buffer(scp, arr, min_t(int, alloc_len, offset)); in resp_mode_sense()
2475 static int resp_mode_select(struct scsi_cmnd *scp, in resp_mode_select() argument
2481 unsigned char *cmd = scp->cmnd; in resp_mode_select()
2489 mk_sense_invalid_fld(scp, SDEB_IN_CDB, mselect6 ? 4 : 7, -1); in resp_mode_select()
2492 res = fetch_to_dev_buffer(scp, arr, param_len); in resp_mode_select()
2496 sdev_printk(KERN_INFO, scp->device, in resp_mode_select()
2502 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 0, -1); in resp_mode_select()
2509 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 7); in resp_mode_select()
2516 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_mode_select()
2550 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 5); in resp_mode_select()
2582 static int resp_log_sense(struct scsi_cmnd *scp, in resp_log_sense() argument
2587 unsigned char *cmd = scp->cmnd; in resp_log_sense()
2593 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, ppc ? 1 : 0); in resp_log_sense()
2616 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2648 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2652 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_log_sense()
2656 return fill_from_dev_buffer(scp, arr, in resp_log_sense()
2787 static int check_zbc_access_params(struct scsi_cmnd *scp, in check_zbc_access_params() argument
2790 struct scsi_device *sdp = scp->device; in check_zbc_access_params()
2802 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2813 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2824 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2831 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2837 mk_sense_buffer(scp, ILLEGAL_REQUEST, in check_zbc_access_params()
2848 mk_sense_buffer(scp, DATA_PROTECT, in check_zbc_access_params()
2860 (struct scsi_cmnd *scp, unsigned long long lba, in check_device_access_params() argument
2863 struct scsi_device *sdp = scp->device; in check_device_access_params()
2867 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in check_device_access_params()
2873 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in check_device_access_params()
2877 mk_sense_buffer(scp, DATA_PROTECT, WRITE_PROTECTED, 0x2); in check_device_access_params()
2881 return check_zbc_access_params(scp, lba, num, write); in check_device_access_params()
2903 static int do_device_access(struct sdeb_store_info *sip, struct scsi_cmnd *scp, in do_device_access() argument
2909 struct scsi_data_buffer *sdb = &scp->sdb; in do_device_access()
2921 if (scp->sc_data_direction != dir) in do_device_access()
2946 static int do_dout_fetch(struct scsi_cmnd *scp, u32 num, u8 *doutp) in do_dout_fetch() argument
2948 struct scsi_data_buffer *sdb = &scp->sdb; in do_dout_fetch()
2952 if (scp->sc_data_direction != DMA_TO_DEVICE) in do_dout_fetch()
3030 static void dif_copy_prot(struct scsi_cmnd *scp, sector_t sector, in dif_copy_prot() argument
3036 scp->device->hostdata, true); in dif_copy_prot()
3044 sg_miter_start(&miter, scsi_prot_sglist(scp), in dif_copy_prot()
3045 scsi_prot_sg_count(scp), SG_MITER_ATOMIC | in dif_copy_prot()
3076 static int prot_verify_read(struct scsi_cmnd *scp, sector_t start_sec, in prot_verify_read() argument
3083 scp->device->hostdata, true); in prot_verify_read()
3100 if (scp->cmnd[1] >> 5) { /* RDPROTECT */ in prot_verify_read()
3110 dif_copy_prot(scp, start_sec, sectors, true); in prot_verify_read()
3116 static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_read_dt0() argument
3125 u8 *cmd = scp->cmnd; in resp_read_dt0()
3169 mk_sense_invalid_opcode(scp); in resp_read_dt0()
3175 sdev_printk(KERN_ERR, scp->device, "Unprotected RD " in resp_read_dt0()
3184 ret = check_device_access_params(scp, lba, num, false); in resp_read_dt0()
3191 mk_sense_buffer(scp, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 0); in resp_read_dt0()
3193 if (0x70 == (scp->sense_buffer[0] & 0x7f)) { in resp_read_dt0()
3194 scp->sense_buffer[0] |= 0x80; /* Valid bit */ in resp_read_dt0()
3197 put_unaligned_be32(ret, scp->sense_buffer + 3); in resp_read_dt0()
3199 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_read_dt0()
3206 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_read_dt0()
3207 switch (prot_verify_read(scp, lba, num, ei_lba)) { in resp_read_dt0()
3211 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
3213 } else if (scp->prot_flags & SCSI_PROT_GUARD_CHECK) { in resp_read_dt0()
3215 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
3222 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 3); in resp_read_dt0()
3224 } else if (scp->prot_flags & SCSI_PROT_REF_CHECK) { in resp_read_dt0()
3226 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 3); in resp_read_dt0()
3233 ret = do_device_access(sip, scp, 0, lba, num, false); in resp_read_dt0()
3238 scsi_set_resid(scp, scsi_bufflen(scp) - ret); in resp_read_dt0()
3243 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_read_dt0()
3248 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
3252 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
3414 static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_dt0() argument
3423 u8 *cmd = scp->cmnd; in resp_write_dt0()
3467 mk_sense_invalid_opcode(scp); in resp_write_dt0()
3473 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_write_dt0()
3478 ret = check_device_access_params(scp, lba, num, true); in resp_write_dt0()
3485 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_dt0()
3486 switch (prot_verify_write(scp, lba, num, ei_lba)) { in resp_write_dt0()
3488 if (scp->prot_flags & SCSI_PROT_GUARD_CHECK) { in resp_write_dt0()
3490 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
3492 } else if (scp->cmnd[1] >> 5 != 3) { /* WRPROTECT != 3 */ in resp_write_dt0()
3494 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
3499 if (scp->prot_flags & SCSI_PROT_REF_CHECK) { in resp_write_dt0()
3501 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 3); in resp_write_dt0()
3503 } else if (scp->cmnd[1] >> 5 != 3) { /* WRPROTECT != 3 */ in resp_write_dt0()
3505 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 3); in resp_write_dt0()
3512 ret = do_device_access(sip, scp, 0, lba, num, true); in resp_write_dt0()
3523 sdev_printk(KERN_INFO, scp->device, in resp_write_dt0()
3530 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_write_dt0()
3535 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
3539 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
3551 static int resp_write_scat(struct scsi_cmnd *scp, in resp_write_scat() argument
3554 u8 *cmd = scp->cmnd; in resp_write_scat()
3584 mk_sense_invalid_opcode(scp); in resp_write_scat()
3590 sdev_printk(KERN_ERR, scp->device, in resp_write_scat()
3598 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3601 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
3607 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3610 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
3617 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3620 res = fetch_to_dev_buffer(scp, lrdp, lbdof_blen); in resp_write_scat()
3634 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3639 ret = check_device_access_params(scp, lba, num, true); in resp_write_scat()
3647 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3650 mk_sense_buffer(scp, ILLEGAL_REQUEST, WRITE_ERROR_ASC, in resp_write_scat()
3657 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_scat()
3658 int prot_ret = prot_verify_write(scp, lba, num, in resp_write_scat()
3662 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, in resp_write_scat()
3669 ret = do_device_access(sip, scp, sg_off, lba, num, true); in resp_write_scat()
3679 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3686 mk_sense_buffer(scp, RECOVERED_ERROR, THRESHOLD_EXCEEDED, 0); in resp_write_scat()
3692 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_scat()
3697 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_scat()
3714 static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num, in resp_write_same() argument
3717 struct scsi_device *sdp = scp->device; in resp_write_same()
3724 scp->device->hostdata, true); in resp_write_same()
3731 ret = check_device_access_params(scp, lba, num, true); in resp_write_same()
3750 ret = fetch_to_dev_buffer(scp, fs1p, lb_size); in resp_write_same()
3756 sdev_printk(KERN_INFO, scp->device, in resp_write_same()
3777 static int resp_write_same_10(struct scsi_cmnd *scp, in resp_write_same_10() argument
3780 u8 *cmd = scp->cmnd; in resp_write_same_10()
3788 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_10()
3796 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_write_same_10()
3799 return resp_write_same(scp, lba, num, ei_lba, unmap, false); in resp_write_same_10()
3802 static int resp_write_same_16(struct scsi_cmnd *scp, in resp_write_same_16() argument
3805 u8 *cmd = scp->cmnd; in resp_write_same_16()
3814 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_16()
3824 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 10, -1); in resp_write_same_16()
3827 return resp_write_same(scp, lba, num, ei_lba, unmap, ndob); in resp_write_same_16()
3833 static int resp_write_buffer(struct scsi_cmnd *scp, in resp_write_buffer() argument
3836 u8 *cmd = scp->cmnd; in resp_write_buffer()
3837 struct scsi_device *sdp = scp->device; in resp_write_buffer()
3879 static int resp_comp_write(struct scsi_cmnd *scp, in resp_comp_write() argument
3882 u8 *cmd = scp->cmnd; in resp_comp_write()
3899 mk_sense_invalid_opcode(scp); in resp_comp_write()
3905 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_comp_write()
3907 ret = check_device_access_params(scp, lba, num, false); in resp_comp_write()
3913 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_comp_write()
3920 ret = do_dout_fetch(scp, dnum, arr); in resp_comp_write()
3925 sdev_printk(KERN_INFO, scp->device, "%s: compare_write: cdb " in resp_comp_write()
3929 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_comp_write()
3947 static int resp_unmap(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_unmap() argument
3958 payload_len = get_unaligned_be16(scp->cmnd + 7); in resp_unmap()
3959 BUG_ON(scsi_bufflen(scp) != payload_len); in resp_unmap()
3963 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_unmap()
3967 buf = kzalloc(scsi_bufflen(scp), GFP_ATOMIC); in resp_unmap()
3969 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_unmap()
3974 scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); in resp_unmap()
3987 ret = check_device_access_params(scp, lba, num, true); in resp_unmap()
4005 static int resp_get_lba_status(struct scsi_cmnd *scp, in resp_get_lba_status() argument
4008 u8 *cmd = scp->cmnd; in resp_get_lba_status()
4020 ret = check_device_access_params(scp, lba, 1, false); in resp_get_lba_status()
4044 return fill_from_dev_buffer(scp, arr, SDEBUG_GET_LBA_STATUS_LEN); in resp_get_lba_status()
4047 static int resp_sync_cache(struct scsi_cmnd *scp, in resp_sync_cache() argument
4053 u8 *cmd = scp->cmnd; in resp_sync_cache()
4063 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_sync_cache()
4080 static int resp_pre_fetch(struct scsi_cmnd *scp, in resp_pre_fetch() argument
4087 u8 *cmd = scp->cmnd; in resp_pre_fetch()
4100 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_pre_fetch()
4133 static int resp_report_luns(struct scsi_cmnd *scp, in resp_report_luns() argument
4136 unsigned char *cmd = scp->cmnd; in resp_report_luns()
4157 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_report_luns()
4179 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_report_luns()
4188 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_report_luns()
4212 res = p_fill_from_dev_buffer(scp, arr, n, off_rsp); in resp_report_luns()
4222 res = p_fill_from_dev_buffer(scp, arr, j * sz_lun, off_rsp); in resp_report_luns()
4226 static int resp_verify(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_verify() argument
4235 u8 *cmd = scp->cmnd; in resp_verify()
4243 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_verify()
4258 mk_sense_invalid_opcode(scp); in resp_verify()
4263 ret = check_device_access_params(scp, lba, a_num, false); in resp_verify()
4269 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_verify()
4276 ret = do_dout_fetch(scp, a_num, arr); in resp_verify()
4281 sdev_printk(KERN_INFO, scp->device, in resp_verify()
4291 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_verify()
4304 static int resp_report_zones(struct scsi_cmnd *scp, in resp_report_zones() argument
4313 u8 *cmd = scp->cmnd; in resp_report_zones()
4319 mk_sense_invalid_opcode(scp); in resp_report_zones()
4328 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_report_zones()
4338 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_report_zones()
4399 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_report_zones()
4428 ret = fill_from_dev_buffer(scp, arr, min_t(int, alloc_len, rep_len)); in resp_report_zones()
4448 static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_open_zone() argument
4453 u8 *cmd = scp->cmnd; in resp_open_zone()
4460 mk_sense_invalid_opcode(scp); in resp_open_zone()
4470 mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC, in resp_open_zone()
4483 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_open_zone()
4490 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_open_zone()
4495 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_open_zone()
4505 mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC, in resp_open_zone()
4525 static int resp_close_zone(struct scsi_cmnd *scp, in resp_close_zone() argument
4530 u8 *cmd = scp->cmnd; in resp_close_zone()
4537 mk_sense_invalid_opcode(scp); in resp_close_zone()
4551 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_close_zone()
4558 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_close_zone()
4563 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_close_zone()
4598 static int resp_finish_zone(struct scsi_cmnd *scp, in resp_finish_zone() argument
4604 u8 *cmd = scp->cmnd; in resp_finish_zone()
4610 mk_sense_invalid_opcode(scp); in resp_finish_zone()
4624 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_finish_zone()
4631 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_finish_zone()
4636 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_finish_zone()
4675 static int resp_rwp_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_rwp_zone() argument
4680 u8 *cmd = scp->cmnd; in resp_rwp_zone()
4686 mk_sense_invalid_opcode(scp); in resp_rwp_zone()
4699 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_rwp_zone()
4706 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_rwp_zone()
4711 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_rwp_zone()
4750 struct scsi_cmnd *scp; in sdebug_q_cmd_complete() local
4769 scp = sqcp->a_cmnd; in sdebug_q_cmd_complete()
4770 if (unlikely(scp == NULL)) { in sdebug_q_cmd_complete()
4772 pr_err("scp is NULL, sqa_idx=%d, qc_idx=%d, hc_idx=%d\n", in sdebug_q_cmd_complete()
4776 devip = (struct sdebug_dev_info *)scp->device->hostdata; in sdebug_q_cmd_complete()
4812 scp->scsi_done(scp); /* callback to mid level */ in sdebug_q_cmd_complete()
7204 static bool fake_timeout(struct scsi_cmnd *scp) in fake_timeout() argument
7212 scsi_medium_access_command(scp)) in fake_timeout()
7219 static int resp_not_ready(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_not_ready() argument
7224 struct scsi_device *sdp = scp->device; in resp_not_ready()
7236 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x1); in resp_not_ready()
7240 if (scp->cmnd[0] == TEST_UNIT_READY) { in resp_not_ready()
7249 scsi_set_sense_information(scp->sense_buffer, SCSI_SENSE_BUFFERSIZE, in resp_not_ready()
7254 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x2); in resp_not_ready()
7303 struct scsi_cmnd *scp; in sdebug_blk_mq_poll() local
7324 scp = sqcp->a_cmnd; in sdebug_blk_mq_poll()
7325 if (unlikely(scp == NULL)) { in sdebug_blk_mq_poll()
7326 pr_err("scp is NULL, queue_num=%d, qc_idx=%u from %s\n", in sdebug_blk_mq_poll()
7336 devip = (struct sdebug_dev_info *)scp->device->hostdata; in sdebug_blk_mq_poll()
7366 scp->scsi_done(scp); /* callback to mid level */ in sdebug_blk_mq_poll()
7377 struct scsi_cmnd *scp) in scsi_debug_queuecommand() argument
7380 struct scsi_device *sdp = scp->device; in scsi_debug_queuecommand()
7384 u8 *cmd = scp->cmnd; in scsi_debug_queuecommand()
7396 scsi_set_resid(scp, 0); in scsi_debug_queuecommand()
7408 len = scp->cmd_len; in scsi_debug_queuecommand()
7418 blk_mq_unique_tag(scsi_cmd_to_rq(scp)), b); in scsi_debug_queuecommand()
7458 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 4); in scsi_debug_queuecommand()
7460 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 8, 7); in scsi_debug_queuecommand()
7462 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
7468 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
7475 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
7489 mk_sense_invalid_fld(scp, SDEB_IN_CDB, k, j); in scsi_debug_queuecommand()
7497 errsts = make_ua(scp, devip); in scsi_debug_queuecommand()
7501 if (unlikely(((F_M_ACCESS & flags) || scp->cmnd[0] == TEST_UNIT_READY) && in scsi_debug_queuecommand()
7503 errsts = resp_not_ready(scp, devip); in scsi_debug_queuecommand()
7510 if (fake_timeout(scp)) in scsi_debug_queuecommand()
7520 return schedule_resp(scp, devip, errsts, pfp, 0, 0); in scsi_debug_queuecommand()
7533 return schedule_resp(scp, devip, errsts, pfp, jdelay, 0); in scsi_debug_queuecommand()
7535 return schedule_resp(scp, devip, errsts, pfp, sdebug_jdelay, in scsi_debug_queuecommand()
7538 return schedule_resp(scp, devip, check_condition_result, NULL, 0, 0); in scsi_debug_queuecommand()
7540 return schedule_resp(scp, NULL, DID_NO_CONNECT << 16, NULL, 0, 0); in scsi_debug_queuecommand()