Lines Matching refs:scp
713 mk_sense_invalid_fld(struct scsi_cmnd *scp, enum sdeb_cmd_data c_d, in mk_sense_invalid_fld() argument
720 sbuff = scp->sense_buffer; in mk_sense_invalid_fld()
722 sdev_printk(KERN_ERR, scp->device, in mk_sense_invalid_fld()
748 sdev_printk(KERN_INFO, scp->device, "%s: [sense_key,asc,ascq" in mk_sense_invalid_fld()
753 static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) in mk_sense_buffer() argument
757 sbuff = scp->sense_buffer; in mk_sense_buffer()
759 sdev_printk(KERN_ERR, scp->device, in mk_sense_buffer()
768 sdev_printk(KERN_INFO, scp->device, in mk_sense_buffer()
774 mk_sense_invalid_opcode(struct scsi_cmnd *scp) in mk_sense_invalid_opcode() argument
776 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_OPCODE, 0); in mk_sense_invalid_opcode()
905 static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fill_from_dev_buffer() argument
909 struct scsi_data_buffer *sdb = scsi_in(scp); in fill_from_dev_buffer()
913 if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_FROM_DEVICE)) in fill_from_dev_buffer()
918 sdb->resid = scsi_bufflen(scp) - act_len; in fill_from_dev_buffer()
924 static int fetch_to_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fetch_to_dev_buffer() argument
927 if (!scsi_bufflen(scp)) in fetch_to_dev_buffer()
929 if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_TO_DEVICE)) in fetch_to_dev_buffer()
932 return scsi_sg_copy_to_buffer(scp, arr, arr_len); in fetch_to_dev_buffer()
1282 static int resp_inquiry(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_inquiry() argument
1286 unsigned char *cmd = scp->cmnd; in resp_inquiry()
1294 have_wlun = (scp->device->lun == SCSI_W_LUN_REPORT_LUNS); in resp_inquiry()
1303 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 1); in resp_inquiry()
1387 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_inquiry()
1392 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
1421 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
1427 static int resp_requests(struct scsi_cmnd * scp, in resp_requests() argument
1431 unsigned char *cmd = scp->cmnd; in resp_requests()
1438 sbuff = scp->sense_buffer; in resp_requests()
1484 mk_sense_buffer(scp, 0, NO_ADDITIONAL_SENSE, 0); in resp_requests()
1485 return fill_from_dev_buffer(scp, arr, len); in resp_requests()
1488 static int resp_start_stop(struct scsi_cmnd * scp, in resp_start_stop() argument
1491 unsigned char *cmd = scp->cmnd; in resp_start_stop()
1496 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 7); in resp_start_stop()
1515 static int resp_readcap(struct scsi_cmnd * scp, in resp_readcap() argument
1538 return fill_from_dev_buffer(scp, arr, SDEBUG_READCAP_ARR_SZ); in resp_readcap()
1542 static int resp_readcap16(struct scsi_cmnd * scp, in resp_readcap16() argument
1545 unsigned char *cmd = scp->cmnd; in resp_readcap16()
1578 return fill_from_dev_buffer(scp, arr, in resp_readcap16()
1584 static int resp_report_tgtpgs(struct scsi_cmnd * scp, in resp_report_tgtpgs() argument
1587 unsigned char *cmd = scp->cmnd; in resp_report_tgtpgs()
1659 ret = fill_from_dev_buffer(scp, arr, in resp_report_tgtpgs()
1666 resp_rsup_opcodes(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_rsup_opcodes() argument
1676 u8 *cmd = scp->cmnd; in resp_rsup_opcodes()
1684 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_opcodes()
1693 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_rsup_opcodes()
1754 mk_sense_invalid_fld(scp, SDEB_IN_CDB, in resp_rsup_opcodes()
1762 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, -1); in resp_rsup_opcodes()
1805 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_rsup_opcodes()
1811 errsts = fill_from_dev_buffer(scp, arr, len); in resp_rsup_opcodes()
1817 resp_rsup_tmfs(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_rsup_tmfs() argument
1822 u8 *cmd = scp->cmnd; in resp_rsup_tmfs()
1828 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_tmfs()
1840 return fill_from_dev_buffer(scp, arr, len); in resp_rsup_tmfs()
2003 resp_mode_sense(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_mode_sense() argument
2009 int target = scp->device->id; in resp_mode_sense()
2012 unsigned char *cmd = scp->cmnd; in resp_mode_sense()
2027 mk_sense_buffer(scp, ILLEGAL_REQUEST, SAVING_PARAMS_UNSUP, 0); in resp_mode_sense()
2083 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2109 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2141 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2147 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_mode_sense()
2156 return fill_from_dev_buffer(scp, arr, min(alloc_len, offset)); in resp_mode_sense()
2162 resp_mode_select(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_mode_select() argument
2167 unsigned char *cmd = scp->cmnd; in resp_mode_select()
2175 mk_sense_invalid_fld(scp, SDEB_IN_CDB, mselect6 ? 4 : 7, -1); in resp_mode_select()
2178 res = fetch_to_dev_buffer(scp, arr, param_len); in resp_mode_select()
2183 sdev_printk(KERN_INFO, scp->device, in resp_mode_select()
2189 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 0, -1); in resp_mode_select()
2196 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 7); in resp_mode_select()
2203 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_mode_select()
2233 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 5); in resp_mode_select()
2265 static int resp_log_sense(struct scsi_cmnd * scp, in resp_log_sense() argument
2270 unsigned char *cmd = scp->cmnd; in resp_log_sense()
2276 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, ppc ? 1 : 0); in resp_log_sense()
2300 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2332 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2336 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_log_sense()
2340 return fill_from_dev_buffer(scp, arr, in resp_log_sense()
2344 static int check_device_access_params(struct scsi_cmnd *scp, in check_device_access_params() argument
2348 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in check_device_access_params()
2354 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in check_device_access_params()
2545 resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_read_dt0() argument
2547 u8 *cmd = scp->cmnd; in resp_read_dt0()
2597 mk_sense_invalid_opcode(scp); in resp_read_dt0()
2603 sdev_printk(KERN_ERR, scp->device, "Unprotected RD " in resp_read_dt0()
2607 struct sdebug_scmd_extra_t *ep = scsi_cmd_priv(scp); in resp_read_dt0()
2615 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_read_dt0()
2621 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_read_dt0()
2629 mk_sense_buffer(scp, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 0); in resp_read_dt0()
2631 if (0x70 == (scp->sense_buffer[0] & 0x7f)) { in resp_read_dt0()
2632 scp->sense_buffer[0] |= 0x80; /* Valid bit */ in resp_read_dt0()
2635 put_unaligned_be32(ret, scp->sense_buffer + 3); in resp_read_dt0()
2637 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_read_dt0()
2644 if (scsi_debug_dix && scsi_prot_sg_count(scp)) { in resp_read_dt0()
2645 int prot_ret = prot_verify_read(scp, lba, num, ei_lba); in resp_read_dt0()
2649 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, prot_ret); in resp_read_dt0()
2654 ret = do_device_access(scp, lba, num, false); in resp_read_dt0()
2659 scsi_in(scp)->resid = scsi_bufflen(scp) - ret; in resp_read_dt0()
2662 struct sdebug_scmd_extra_t *ep = scsi_cmd_priv(scp); in resp_read_dt0()
2665 mk_sense_buffer(scp, RECOVERED_ERROR, in resp_read_dt0()
2669 mk_sense_buffer(scp, ABORTED_COMMAND, in resp_read_dt0()
2674 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
2677 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
2864 resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_dt0() argument
2866 u8 *cmd = scp->cmnd; in resp_write_dt0()
2916 mk_sense_invalid_opcode(scp); in resp_write_dt0()
2922 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_write_dt0()
2928 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_write_dt0()
2934 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_dt0()
2941 if (scsi_debug_dix && scsi_prot_sg_count(scp)) { in resp_write_dt0()
2942 int prot_ret = prot_verify_write(scp, lba, num, ei_lba); in resp_write_dt0()
2946 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, prot_ret); in resp_write_dt0()
2951 ret = do_device_access(scp, lba, num, true); in resp_write_dt0()
2959 sdev_printk(KERN_INFO, scp->device, in resp_write_dt0()
2964 struct sdebug_scmd_extra_t *ep = scsi_cmd_priv(scp); in resp_write_dt0()
2967 mk_sense_buffer(scp, RECOVERED_ERROR, in resp_write_dt0()
2972 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
2975 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
2983 resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num, u32 ei_lba, in resp_write_same() argument
2990 ret = check_device_access_params(scp, lba, num); in resp_write_same()
3007 ret = fetch_to_dev_buffer(scp, fake_storep + in resp_write_same()
3016 sdev_printk(KERN_INFO, scp->device, in resp_write_same()
3036 resp_write_same_10(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_same_10() argument
3038 u8 *cmd = scp->cmnd; in resp_write_same_10()
3046 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_10()
3054 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_write_same_10()
3057 return resp_write_same(scp, lba, num, ei_lba, unmap, false); in resp_write_same_10()
3061 resp_write_same_16(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_same_16() argument
3063 u8 *cmd = scp->cmnd; in resp_write_same_16()
3072 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_16()
3082 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 10, -1); in resp_write_same_16()
3085 return resp_write_same(scp, lba, num, ei_lba, unmap, ndob); in resp_write_same_16()
3092 resp_write_buffer(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_buffer() argument
3094 u8 *cmd = scp->cmnd; in resp_write_buffer()
3095 struct scsi_device *sdp = scp->device; in resp_write_buffer()
3138 resp_comp_write(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_comp_write() argument
3140 u8 *cmd = scp->cmnd; in resp_comp_write()
3157 mk_sense_invalid_opcode(scp); in resp_comp_write()
3163 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_comp_write()
3168 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_comp_write()
3174 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_comp_write()
3180 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_comp_write()
3191 ret = do_device_access(scp, 0, dnum, true); in resp_comp_write()
3198 sdev_printk(KERN_INFO, scp->device, "%s: compare_write: cdb " in resp_comp_write()
3202 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_comp_write()
3221 resp_unmap(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_unmap() argument
3232 payload_len = get_unaligned_be16(scp->cmnd + 7); in resp_unmap()
3233 BUG_ON(scsi_bufflen(scp) != payload_len); in resp_unmap()
3237 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_unmap()
3241 buf = kmalloc(scsi_bufflen(scp), GFP_ATOMIC); in resp_unmap()
3243 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_unmap()
3248 scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); in resp_unmap()
3261 ret = check_device_access_params(scp, lba, num); in resp_unmap()
3280 resp_get_lba_status(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_get_lba_status() argument
3282 u8 *cmd = scp->cmnd; in resp_get_lba_status()
3294 ret = check_device_access_params(scp, lba, 1); in resp_get_lba_status()
3316 return fill_from_dev_buffer(scp, arr, SDEBUG_GET_LBA_STATUS_LEN); in resp_get_lba_status()
3321 static int resp_report_luns(struct scsi_cmnd * scp, in resp_report_luns() argument
3327 unsigned char *cmd = scp->cmnd; in resp_report_luns()
3337 mk_sense_invalid_fld(scp, SDEB_IN_CDB, shortish ? 6 : 2, -1); in resp_report_luns()
3374 return fill_from_dev_buffer(scp, arr, in resp_report_luns()
3378 static int resp_xdwriteread(struct scsi_cmnd *scp, unsigned long long lba, in resp_xdwriteread() argument
3384 struct scsi_data_buffer *sdb = scsi_in(scp); in resp_xdwriteread()
3388 buf = kmalloc(scsi_bufflen(scp), GFP_ATOMIC); in resp_xdwriteread()
3390 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_xdwriteread()
3395 scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); in resp_xdwriteread()
3415 resp_xdwriteread_10(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_xdwriteread_10() argument
3417 u8 *cmd = scp->cmnd; in resp_xdwriteread_10()
3422 if (!scsi_bidi_cmnd(scp)) { in resp_xdwriteread_10()
3423 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_xdwriteread_10()
3427 errsts = resp_read_dt0(scp, devip); in resp_xdwriteread_10()
3431 errsts = resp_write_dt0(scp, devip); in resp_xdwriteread_10()
3437 return resp_xdwriteread(scp, lba, num, devip); in resp_xdwriteread_10()
3447 struct scsi_cmnd *scp; in sdebug_q_cmd_complete() local
3458 scp = sqcp->a_cmnd; in sdebug_q_cmd_complete()
3459 if (NULL == scp) { in sdebug_q_cmd_complete()
3464 devip = (struct sdebug_dev_info *)scp->device->hostdata; in sdebug_q_cmd_complete()
3495 scp->scsi_done(scp); /* callback to mid level */ in sdebug_q_cmd_complete()
3507 struct scsi_cmnd *scp; in sdebug_q_cmd_hrt_complete() local
3518 scp = sqcp->a_cmnd; in sdebug_q_cmd_hrt_complete()
3519 if (NULL == scp) { in sdebug_q_cmd_hrt_complete()
3524 devip = (struct sdebug_dev_info *)scp->device->hostdata; in sdebug_q_cmd_hrt_complete()
3555 scp->scsi_done(scp); /* callback to mid level */ in sdebug_q_cmd_hrt_complete()
5103 check_inject(struct scsi_cmnd *scp) in check_inject() argument
5105 struct sdebug_scmd_extra_t *ep = scsi_cmd_priv(scp); in check_inject()
5117 scsi_medium_access_command(scp)) in check_inject()
5138 scsi_debug_queuecommand(struct scsi_cmnd *scp) in scsi_debug_queuecommand() argument
5141 struct scsi_device *sdp = scp->device; in scsi_debug_queuecommand()
5145 u8 *cmd = scp->cmnd; in scsi_debug_queuecommand()
5156 scsi_set_resid(scp, 0); in scsi_debug_queuecommand()
5161 len = scp->cmd_len; in scsi_debug_queuecommand()
5174 return schedule_resp(scp, NULL, errsts_no_connect, 0); in scsi_debug_queuecommand()
5182 return schedule_resp(scp, NULL, errsts_no_connect, 0); in scsi_debug_queuecommand()
5205 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 4); in scsi_debug_queuecommand()
5207 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 8, 7); in scsi_debug_queuecommand()
5209 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
5215 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
5222 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
5236 mk_sense_invalid_fld(scp, SDEB_IN_CDB, k, j); in scsi_debug_queuecommand()
5243 errsts = check_readiness(scp, UAS_ONLY, devip); in scsi_debug_queuecommand()
5248 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x2); in scsi_debug_queuecommand()
5259 if (check_inject(scp)) in scsi_debug_queuecommand()
5263 errsts = oip->pfp(scp, devip); in scsi_debug_queuecommand()
5265 errsts = r_pfp(scp, devip); in scsi_debug_queuecommand()
5268 return schedule_resp(scp, devip, errsts, in scsi_debug_queuecommand()
5271 return schedule_resp(scp, devip, check_condition_result, 0); in scsi_debug_queuecommand()