Lines Matching refs:scp
710 mk_sense_invalid_fld(struct scsi_cmnd *scp, enum sdeb_cmd_data c_d, in mk_sense_invalid_fld() argument
717 sbuff = scp->sense_buffer; in mk_sense_invalid_fld()
719 sdev_printk(KERN_ERR, scp->device, in mk_sense_invalid_fld()
745 sdev_printk(KERN_INFO, scp->device, "%s: [sense_key,asc,ascq" in mk_sense_invalid_fld()
750 static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) in mk_sense_buffer() argument
754 sbuff = scp->sense_buffer; in mk_sense_buffer()
756 sdev_printk(KERN_ERR, scp->device, in mk_sense_buffer()
765 sdev_printk(KERN_INFO, scp->device, in mk_sense_buffer()
771 mk_sense_invalid_opcode(struct scsi_cmnd *scp) in mk_sense_invalid_opcode() argument
773 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_OPCODE, 0); in mk_sense_invalid_opcode()
902 static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fill_from_dev_buffer() argument
906 struct scsi_data_buffer *sdb = scsi_in(scp); in fill_from_dev_buffer()
910 if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_FROM_DEVICE)) in fill_from_dev_buffer()
915 sdb->resid = scsi_bufflen(scp) - act_len; in fill_from_dev_buffer()
921 static int fetch_to_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fetch_to_dev_buffer() argument
924 if (!scsi_bufflen(scp)) in fetch_to_dev_buffer()
926 if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_TO_DEVICE)) in fetch_to_dev_buffer()
929 return scsi_sg_copy_to_buffer(scp, arr, arr_len); in fetch_to_dev_buffer()
1279 static int resp_inquiry(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_inquiry() argument
1283 unsigned char *cmd = scp->cmnd; in resp_inquiry()
1291 have_wlun = (scp->device->lun == SAM2_WLUN_REPORT_LUNS); in resp_inquiry()
1300 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 1); in resp_inquiry()
1384 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_inquiry()
1389 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
1418 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
1424 static int resp_requests(struct scsi_cmnd * scp, in resp_requests() argument
1428 unsigned char *cmd = scp->cmnd; in resp_requests()
1436 sbuff = scp->sense_buffer; in resp_requests()
1482 mk_sense_buffer(scp, 0, NO_ADDITIONAL_SENSE, 0); in resp_requests()
1483 return fill_from_dev_buffer(scp, arr, len); in resp_requests()
1486 static int resp_start_stop(struct scsi_cmnd * scp, in resp_start_stop() argument
1489 unsigned char *cmd = scp->cmnd; in resp_start_stop()
1494 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 7); in resp_start_stop()
1513 static int resp_readcap(struct scsi_cmnd * scp, in resp_readcap() argument
1536 return fill_from_dev_buffer(scp, arr, SDEBUG_READCAP_ARR_SZ); in resp_readcap()
1540 static int resp_readcap16(struct scsi_cmnd * scp, in resp_readcap16() argument
1543 unsigned char *cmd = scp->cmnd; in resp_readcap16()
1576 return fill_from_dev_buffer(scp, arr, in resp_readcap16()
1582 static int resp_report_tgtpgs(struct scsi_cmnd * scp, in resp_report_tgtpgs() argument
1585 unsigned char *cmd = scp->cmnd; in resp_report_tgtpgs()
1657 ret = fill_from_dev_buffer(scp, arr, in resp_report_tgtpgs()
1664 resp_rsup_opcodes(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_rsup_opcodes() argument
1674 u8 *cmd = scp->cmnd; in resp_rsup_opcodes()
1682 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_opcodes()
1691 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_rsup_opcodes()
1752 mk_sense_invalid_fld(scp, SDEB_IN_CDB, in resp_rsup_opcodes()
1760 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, -1); in resp_rsup_opcodes()
1803 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_rsup_opcodes()
1809 errsts = fill_from_dev_buffer(scp, arr, len); in resp_rsup_opcodes()
1815 resp_rsup_tmfs(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_rsup_tmfs() argument
1820 u8 *cmd = scp->cmnd; in resp_rsup_tmfs()
1826 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_tmfs()
1838 return fill_from_dev_buffer(scp, arr, len); in resp_rsup_tmfs()
2001 resp_mode_sense(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_mode_sense() argument
2007 int target = scp->device->id; in resp_mode_sense()
2010 unsigned char *cmd = scp->cmnd; in resp_mode_sense()
2025 mk_sense_buffer(scp, ILLEGAL_REQUEST, SAVING_PARAMS_UNSUP, 0); in resp_mode_sense()
2081 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2107 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2139 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2145 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_mode_sense()
2154 return fill_from_dev_buffer(scp, arr, min(alloc_len, offset)); in resp_mode_sense()
2160 resp_mode_select(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_mode_select() argument
2165 unsigned char *cmd = scp->cmnd; in resp_mode_select()
2173 mk_sense_invalid_fld(scp, SDEB_IN_CDB, mselect6 ? 4 : 7, -1); in resp_mode_select()
2176 res = fetch_to_dev_buffer(scp, arr, param_len); in resp_mode_select()
2181 sdev_printk(KERN_INFO, scp->device, in resp_mode_select()
2187 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 0, -1); in resp_mode_select()
2194 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 7); in resp_mode_select()
2201 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_mode_select()
2231 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 5); in resp_mode_select()
2263 static int resp_log_sense(struct scsi_cmnd * scp, in resp_log_sense() argument
2268 unsigned char *cmd = scp->cmnd; in resp_log_sense()
2274 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, ppc ? 1 : 0); in resp_log_sense()
2298 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2330 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2334 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_log_sense()
2338 return fill_from_dev_buffer(scp, arr, in resp_log_sense()
2342 static int check_device_access_params(struct scsi_cmnd *scp, in check_device_access_params() argument
2346 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in check_device_access_params()
2352 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in check_device_access_params()
2548 resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_read_dt0() argument
2550 u8 *cmd = scp->cmnd; in resp_read_dt0()
2600 mk_sense_invalid_opcode(scp); in resp_read_dt0()
2606 sdev_printk(KERN_ERR, scp->device, "Unprotected RD " in resp_read_dt0()
2610 struct sdebug_scmd_extra_t *ep = scsi_cmd_priv(scp); in resp_read_dt0()
2618 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_read_dt0()
2624 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_read_dt0()
2632 mk_sense_buffer(scp, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 0); in resp_read_dt0()
2634 if (0x70 == (scp->sense_buffer[0] & 0x7f)) { in resp_read_dt0()
2635 scp->sense_buffer[0] |= 0x80; /* Valid bit */ in resp_read_dt0()
2638 put_unaligned_be32(ret, scp->sense_buffer + 3); in resp_read_dt0()
2640 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_read_dt0()
2647 if (scsi_debug_dix && scsi_prot_sg_count(scp)) { in resp_read_dt0()
2648 int prot_ret = prot_verify_read(scp, lba, num, ei_lba); in resp_read_dt0()
2652 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, prot_ret); in resp_read_dt0()
2657 ret = do_device_access(scp, lba, num, false); in resp_read_dt0()
2662 scsi_in(scp)->resid = scsi_bufflen(scp) - ret; in resp_read_dt0()
2665 struct sdebug_scmd_extra_t *ep = scsi_cmd_priv(scp); in resp_read_dt0()
2668 mk_sense_buffer(scp, RECOVERED_ERROR, in resp_read_dt0()
2672 mk_sense_buffer(scp, ABORTED_COMMAND, in resp_read_dt0()
2677 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
2680 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
2867 resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_dt0() argument
2869 u8 *cmd = scp->cmnd; in resp_write_dt0()
2919 mk_sense_invalid_opcode(scp); in resp_write_dt0()
2925 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_write_dt0()
2931 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_write_dt0()
2937 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_dt0()
2944 if (scsi_debug_dix && scsi_prot_sg_count(scp)) { in resp_write_dt0()
2945 int prot_ret = prot_verify_write(scp, lba, num, ei_lba); in resp_write_dt0()
2949 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, prot_ret); in resp_write_dt0()
2954 ret = do_device_access(scp, lba, num, true); in resp_write_dt0()
2962 sdev_printk(KERN_INFO, scp->device, in resp_write_dt0()
2967 struct sdebug_scmd_extra_t *ep = scsi_cmd_priv(scp); in resp_write_dt0()
2970 mk_sense_buffer(scp, RECOVERED_ERROR, in resp_write_dt0()
2975 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
2978 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
2986 resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num, u32 ei_lba, in resp_write_same() argument
2993 ret = check_device_access_params(scp, lba, num); in resp_write_same()
3010 ret = fetch_to_dev_buffer(scp, fake_storep + in resp_write_same()
3019 sdev_printk(KERN_INFO, scp->device, in resp_write_same()
3039 resp_write_same_10(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_same_10() argument
3041 u8 *cmd = scp->cmnd; in resp_write_same_10()
3049 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_10()
3057 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_write_same_10()
3060 return resp_write_same(scp, lba, num, ei_lba, unmap, false); in resp_write_same_10()
3064 resp_write_same_16(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_same_16() argument
3066 u8 *cmd = scp->cmnd; in resp_write_same_16()
3075 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_16()
3085 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 10, -1); in resp_write_same_16()
3088 return resp_write_same(scp, lba, num, ei_lba, unmap, ndob); in resp_write_same_16()
3095 resp_write_buffer(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_buffer() argument
3097 u8 *cmd = scp->cmnd; in resp_write_buffer()
3098 struct scsi_device *sdp = scp->device; in resp_write_buffer()
3141 resp_comp_write(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_comp_write() argument
3143 u8 *cmd = scp->cmnd; in resp_comp_write()
3160 mk_sense_invalid_opcode(scp); in resp_comp_write()
3166 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_comp_write()
3171 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_comp_write()
3177 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_comp_write()
3183 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_comp_write()
3194 ret = do_device_access(scp, 0, dnum, true); in resp_comp_write()
3201 sdev_printk(KERN_INFO, scp->device, "%s: compare_write: cdb " in resp_comp_write()
3205 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_comp_write()
3224 resp_unmap(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_unmap() argument
3235 payload_len = get_unaligned_be16(scp->cmnd + 7); in resp_unmap()
3236 BUG_ON(scsi_bufflen(scp) != payload_len); in resp_unmap()
3240 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_unmap()
3244 buf = kmalloc(scsi_bufflen(scp), GFP_ATOMIC); in resp_unmap()
3246 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_unmap()
3251 scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); in resp_unmap()
3264 ret = check_device_access_params(scp, lba, num); in resp_unmap()
3283 resp_get_lba_status(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_get_lba_status() argument
3285 u8 *cmd = scp->cmnd; in resp_get_lba_status()
3297 ret = check_device_access_params(scp, lba, 1); in resp_get_lba_status()
3319 return fill_from_dev_buffer(scp, arr, SDEBUG_GET_LBA_STATUS_LEN); in resp_get_lba_status()
3324 static int resp_report_luns(struct scsi_cmnd * scp, in resp_report_luns() argument
3330 unsigned char *cmd = scp->cmnd; in resp_report_luns()
3340 mk_sense_invalid_fld(scp, SDEB_IN_CDB, shortish ? 6 : 2, -1); in resp_report_luns()
3377 return fill_from_dev_buffer(scp, arr, in resp_report_luns()
3381 static int resp_xdwriteread(struct scsi_cmnd *scp, unsigned long long lba, in resp_xdwriteread() argument
3387 struct scsi_data_buffer *sdb = scsi_in(scp); in resp_xdwriteread()
3391 buf = kmalloc(scsi_bufflen(scp), GFP_ATOMIC); in resp_xdwriteread()
3393 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_xdwriteread()
3398 scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); in resp_xdwriteread()
3418 resp_xdwriteread_10(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_xdwriteread_10() argument
3420 u8 *cmd = scp->cmnd; in resp_xdwriteread_10()
3425 if (!scsi_bidi_cmnd(scp)) { in resp_xdwriteread_10()
3426 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_xdwriteread_10()
3430 errsts = resp_read_dt0(scp, devip); in resp_xdwriteread_10()
3434 errsts = resp_write_dt0(scp, devip); in resp_xdwriteread_10()
3440 return resp_xdwriteread(scp, lba, num, devip); in resp_xdwriteread_10()
3450 struct scsi_cmnd *scp; in sdebug_q_cmd_complete() local
3461 scp = sqcp->a_cmnd; in sdebug_q_cmd_complete()
3462 if (NULL == scp) { in sdebug_q_cmd_complete()
3467 devip = (struct sdebug_dev_info *)scp->device->hostdata; in sdebug_q_cmd_complete()
3498 scp->scsi_done(scp); /* callback to mid level */ in sdebug_q_cmd_complete()
3510 struct scsi_cmnd *scp; in sdebug_q_cmd_hrt_complete() local
3521 scp = sqcp->a_cmnd; in sdebug_q_cmd_hrt_complete()
3522 if (NULL == scp) { in sdebug_q_cmd_hrt_complete()
3527 devip = (struct sdebug_dev_info *)scp->device->hostdata; in sdebug_q_cmd_hrt_complete()
3558 scp->scsi_done(scp); /* callback to mid level */ in sdebug_q_cmd_hrt_complete()
5116 check_inject(struct scsi_cmnd *scp) in check_inject() argument
5118 struct sdebug_scmd_extra_t *ep = scsi_cmd_priv(scp); in check_inject()
5130 scsi_medium_access_command(scp)) in check_inject()
5151 scsi_debug_queuecommand(struct scsi_cmnd *scp) in scsi_debug_queuecommand() argument
5154 struct scsi_device *sdp = scp->device; in scsi_debug_queuecommand()
5158 u8 *cmd = scp->cmnd; in scsi_debug_queuecommand()
5169 scsi_set_resid(scp, 0); in scsi_debug_queuecommand()
5174 len = scp->cmd_len; in scsi_debug_queuecommand()
5187 return schedule_resp(scp, NULL, errsts_no_connect, 0); in scsi_debug_queuecommand()
5195 return schedule_resp(scp, NULL, errsts_no_connect, 0); in scsi_debug_queuecommand()
5218 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 4); in scsi_debug_queuecommand()
5220 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 8, 7); in scsi_debug_queuecommand()
5222 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
5228 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
5235 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
5249 mk_sense_invalid_fld(scp, SDEB_IN_CDB, k, j); in scsi_debug_queuecommand()
5256 errsts = check_readiness(scp, UAS_ONLY, devip); in scsi_debug_queuecommand()
5261 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x2); in scsi_debug_queuecommand()
5272 if (check_inject(scp)) in scsi_debug_queuecommand()
5276 errsts = oip->pfp(scp, devip); in scsi_debug_queuecommand()
5278 errsts = r_pfp(scp, devip); in scsi_debug_queuecommand()
5281 return schedule_resp(scp, devip, errsts, in scsi_debug_queuecommand()
5284 return schedule_resp(scp, devip, check_condition_result, 0); in scsi_debug_queuecommand()