Lines Matching refs:scp

766 static void mk_sense_invalid_fld(struct scsi_cmnd *scp,  in mk_sense_invalid_fld()  argument
774 sbuff = scp->sense_buffer; in mk_sense_invalid_fld()
776 sdev_printk(KERN_ERR, scp->device, in mk_sense_invalid_fld()
801 sdev_printk(KERN_INFO, scp->device, "%s: [sense_key,asc,ascq" in mk_sense_invalid_fld()
806 static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) in mk_sense_buffer() argument
810 sbuff = scp->sense_buffer; in mk_sense_buffer()
812 sdev_printk(KERN_ERR, scp->device, in mk_sense_buffer()
821 sdev_printk(KERN_INFO, scp->device, in mk_sense_buffer()
826 static void mk_sense_invalid_opcode(struct scsi_cmnd *scp) in mk_sense_invalid_opcode() argument
828 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_OPCODE, 0); in mk_sense_invalid_opcode()
921 static int make_ua(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in make_ua() argument
931 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
937 mk_sense_buffer(scp, UNIT_ATTENTION, UA_RESET_ASC, in make_ua()
943 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
949 mk_sense_buffer(scp, UNIT_ATTENTION, UA_CHANGED_ASC, in make_ua()
955 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
962 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
979 mk_sense_buffer(scp, UNIT_ATTENTION, in make_ua()
993 sdev_printk(KERN_INFO, scp->device, in make_ua()
1002 static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fill_from_dev_buffer() argument
1006 struct scsi_data_buffer *sdb = &scp->sdb; in fill_from_dev_buffer()
1010 if (scp->sc_data_direction != DMA_FROM_DEVICE) in fill_from_dev_buffer()
1015 scsi_set_resid(scp, scsi_bufflen(scp) - act_len); in fill_from_dev_buffer()
1025 static int p_fill_from_dev_buffer(struct scsi_cmnd *scp, const void *arr, in p_fill_from_dev_buffer() argument
1029 struct scsi_data_buffer *sdb = &scp->sdb; in p_fill_from_dev_buffer()
1034 if (scp->sc_data_direction != DMA_FROM_DEVICE) in p_fill_from_dev_buffer()
1040 __func__, off_dst, scsi_bufflen(scp), act_len, in p_fill_from_dev_buffer()
1041 scsi_get_resid(scp)); in p_fill_from_dev_buffer()
1042 n = (int)scsi_bufflen(scp) - ((int)off_dst + act_len); in p_fill_from_dev_buffer()
1043 scsi_set_resid(scp, min(scsi_get_resid(scp), n)); in p_fill_from_dev_buffer()
1050 static int fetch_to_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr, in fetch_to_dev_buffer() argument
1053 if (!scsi_bufflen(scp)) in fetch_to_dev_buffer()
1055 if (scp->sc_data_direction != DMA_TO_DEVICE) in fetch_to_dev_buffer()
1058 return scsi_sg_copy_to_buffer(scp, arr, arr_len); in fetch_to_dev_buffer()
1389 static int resp_inquiry(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_inquiry() argument
1393 unsigned char *cmd = scp->cmnd; in resp_inquiry()
1402 have_wlun = scsi_is_wlun(scp->device->lun); in resp_inquiry()
1411 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 1); in resp_inquiry()
1496 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_inquiry()
1501 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
1534 ret = fill_from_dev_buffer(scp, arr, in resp_inquiry()
1543 static int resp_requests(struct scsi_cmnd *scp, in resp_requests() argument
1547 unsigned char *cmd = scp->cmnd; in resp_requests()
1554 sbuff = scp->sense_buffer; in resp_requests()
1600 mk_sense_buffer(scp, 0, NO_ADDITIONAL_SENSE, 0); in resp_requests()
1601 return fill_from_dev_buffer(scp, arr, len); in resp_requests()
1604 static int resp_start_stop(struct scsi_cmnd *scp, in resp_start_stop() argument
1607 unsigned char *cmd = scp->cmnd; in resp_start_stop()
1613 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, 7); in resp_start_stop()
1637 static int resp_readcap(struct scsi_cmnd *scp, in resp_readcap() argument
1652 return fill_from_dev_buffer(scp, arr, SDEBUG_READCAP_ARR_SZ); in resp_readcap()
1656 static int resp_readcap16(struct scsi_cmnd *scp, in resp_readcap16() argument
1659 unsigned char *cmd = scp->cmnd; in resp_readcap16()
1689 return fill_from_dev_buffer(scp, arr, in resp_readcap16()
1695 static int resp_report_tgtpgs(struct scsi_cmnd *scp, in resp_report_tgtpgs() argument
1698 unsigned char *cmd = scp->cmnd; in resp_report_tgtpgs()
1765 ret = fill_from_dev_buffer(scp, arr, in resp_report_tgtpgs()
1771 static int resp_rsup_opcodes(struct scsi_cmnd *scp, in resp_rsup_opcodes() argument
1782 u8 *cmd = scp->cmnd; in resp_rsup_opcodes()
1790 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_opcodes()
1799 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_rsup_opcodes()
1860 mk_sense_invalid_fld(scp, SDEB_IN_CDB, in resp_rsup_opcodes()
1868 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, -1); in resp_rsup_opcodes()
1911 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 2); in resp_rsup_opcodes()
1917 errsts = fill_from_dev_buffer(scp, arr, len); in resp_rsup_opcodes()
1922 static int resp_rsup_tmfs(struct scsi_cmnd *scp, in resp_rsup_tmfs() argument
1928 u8 *cmd = scp->cmnd; in resp_rsup_tmfs()
1934 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_tmfs()
1946 return fill_from_dev_buffer(scp, arr, len); in resp_rsup_tmfs()
2111 static int resp_mode_sense(struct scsi_cmnd *scp, in resp_mode_sense() argument
2117 int target = scp->device->id; in resp_mode_sense()
2120 unsigned char *cmd = scp->cmnd; in resp_mode_sense()
2137 mk_sense_buffer(scp, ILLEGAL_REQUEST, SAVING_PARAMS_UNSUP, 0); in resp_mode_sense()
2181 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2215 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2252 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2261 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_mode_sense()
2268 return fill_from_dev_buffer(scp, arr, min(alloc_len, offset)); in resp_mode_sense()
2273 static int resp_mode_select(struct scsi_cmnd *scp, in resp_mode_select() argument
2279 unsigned char *cmd = scp->cmnd; in resp_mode_select()
2287 mk_sense_invalid_fld(scp, SDEB_IN_CDB, mselect6 ? 4 : 7, -1); in resp_mode_select()
2290 res = fetch_to_dev_buffer(scp, arr, param_len); in resp_mode_select()
2294 sdev_printk(KERN_INFO, scp->device, in resp_mode_select()
2300 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 0, -1); in resp_mode_select()
2307 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 7); in resp_mode_select()
2314 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_mode_select()
2348 mk_sense_invalid_fld(scp, SDEB_IN_DATA, off, 5); in resp_mode_select()
2380 static int resp_log_sense(struct scsi_cmnd *scp, in resp_log_sense() argument
2385 unsigned char *cmd = scp->cmnd; in resp_log_sense()
2391 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, ppc ? 1 : 0); in resp_log_sense()
2414 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2446 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5); in resp_log_sense()
2450 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_log_sense()
2454 return fill_from_dev_buffer(scp, arr, in resp_log_sense()
2458 static inline int check_device_access_params(struct scsi_cmnd *scp, in check_device_access_params() argument
2462 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in check_device_access_params()
2468 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in check_device_access_params()
2472 mk_sense_buffer(scp, DATA_PROTECT, WRITE_PROTECTED, 0x2); in check_device_access_params()
2661 static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_read_dt0() argument
2663 u8 *cmd = scp->cmnd; in resp_read_dt0()
2714 mk_sense_invalid_opcode(scp); in resp_read_dt0()
2720 sdev_printk(KERN_ERR, scp->device, "Unprotected RD " in resp_read_dt0()
2724 sqcp = (struct sdebug_queued_cmd *)scp->host_scribble; in resp_read_dt0()
2733 ret = check_device_access_params(scp, lba, num, false); in resp_read_dt0()
2740 mk_sense_buffer(scp, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 0); in resp_read_dt0()
2742 if (0x70 == (scp->sense_buffer[0] & 0x7f)) { in resp_read_dt0()
2743 scp->sense_buffer[0] |= 0x80; /* Valid bit */ in resp_read_dt0()
2746 put_unaligned_be32(ret, scp->sense_buffer + 3); in resp_read_dt0()
2748 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_read_dt0()
2755 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_read_dt0()
2756 int prot_ret = prot_verify_read(scp, lba, num, ei_lba); in resp_read_dt0()
2760 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, prot_ret); in resp_read_dt0()
2765 ret = do_device_access(scp, 0, lba, num, false); in resp_read_dt0()
2770 scsi_set_resid(scp, scsi_bufflen(scp) - ret); in resp_read_dt0()
2774 mk_sense_buffer(scp, RECOVERED_ERROR, in resp_read_dt0()
2778 mk_sense_buffer(scp, ABORTED_COMMAND, in resp_read_dt0()
2783 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_read_dt0()
2786 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_read_dt0()
2966 static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_write_dt0() argument
2968 u8 *cmd = scp->cmnd; in resp_write_dt0()
3018 mk_sense_invalid_opcode(scp); in resp_write_dt0()
3024 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_write_dt0()
3027 ret = check_device_access_params(scp, lba, num, true); in resp_write_dt0()
3033 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_dt0()
3034 int prot_ret = prot_verify_write(scp, lba, num, ei_lba); in resp_write_dt0()
3038 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, prot_ret); in resp_write_dt0()
3043 ret = do_device_access(scp, 0, lba, num, true); in resp_write_dt0()
3051 sdev_printk(KERN_INFO, scp->device, in resp_write_dt0()
3057 (struct sdebug_queued_cmd *)scp->host_scribble; in resp_write_dt0()
3061 mk_sense_buffer(scp, RECOVERED_ERROR, in resp_write_dt0()
3066 mk_sense_buffer(scp, ABORTED_COMMAND, 0x10, 1); in resp_write_dt0()
3069 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, 1); in resp_write_dt0()
3081 static int resp_write_scat(struct scsi_cmnd *scp, in resp_write_scat() argument
3084 u8 *cmd = scp->cmnd; in resp_write_scat()
3113 mk_sense_invalid_opcode(scp); in resp_write_scat()
3119 sdev_printk(KERN_ERR, scp->device, in resp_write_scat()
3127 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3130 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
3136 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3139 mk_sense_buffer(scp, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 0); in resp_write_scat()
3146 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3149 res = fetch_to_dev_buffer(scp, lrdp, lbdof_blen); in resp_write_scat()
3163 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3168 ret = check_device_access_params(scp, lba, num, true); in resp_write_scat()
3176 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3179 mk_sense_buffer(scp, ILLEGAL_REQUEST, WRITE_ERROR_ASC, in resp_write_scat()
3186 if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) { in resp_write_scat()
3187 int prot_ret = prot_verify_write(scp, lba, num, in resp_write_scat()
3191 mk_sense_buffer(scp, ILLEGAL_REQUEST, 0x10, in resp_write_scat()
3198 ret = do_device_access(scp, sg_off, lba, num, true); in resp_write_scat()
3205 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3211 (struct sdebug_queued_cmd *)scp->host_scribble; in resp_write_scat()
3215 mk_sense_buffer(scp, RECOVERED_ERROR, in resp_write_scat()
3221 mk_sense_buffer(scp, ABORTED_COMMAND, in resp_write_scat()
3226 mk_sense_buffer(scp, ILLEGAL_REQUEST, in resp_write_scat()
3244 static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num, in resp_write_same() argument
3254 ret = check_device_access_params(scp, lba, num, true); in resp_write_same()
3272 ret = fetch_to_dev_buffer(scp, fs1p, lb_size); in resp_write_same()
3278 sdev_printk(KERN_INFO, scp->device, in resp_write_same()
3296 static int resp_write_same_10(struct scsi_cmnd *scp, in resp_write_same_10() argument
3299 u8 *cmd = scp->cmnd; in resp_write_same_10()
3307 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_10()
3315 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_write_same_10()
3318 return resp_write_same(scp, lba, num, ei_lba, unmap, false); in resp_write_same_10()
3321 static int resp_write_same_16(struct scsi_cmnd *scp, in resp_write_same_16() argument
3324 u8 *cmd = scp->cmnd; in resp_write_same_16()
3333 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 3); in resp_write_same_16()
3343 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 10, -1); in resp_write_same_16()
3346 return resp_write_same(scp, lba, num, ei_lba, unmap, ndob); in resp_write_same_16()
3352 static int resp_write_buffer(struct scsi_cmnd *scp, in resp_write_buffer() argument
3355 u8 *cmd = scp->cmnd; in resp_write_buffer()
3356 struct scsi_device *sdp = scp->device; in resp_write_buffer()
3398 static int resp_comp_write(struct scsi_cmnd *scp, in resp_comp_write() argument
3401 u8 *cmd = scp->cmnd; in resp_comp_write()
3418 mk_sense_invalid_opcode(scp); in resp_comp_write()
3424 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_comp_write()
3426 ret = check_device_access_params(scp, lba, num, false); in resp_comp_write()
3432 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_comp_write()
3443 ret = do_device_access(scp, 0, 0, dnum, true); in resp_comp_write()
3449 sdev_printk(KERN_INFO, scp->device, "%s: compare_write: cdb " in resp_comp_write()
3453 mk_sense_buffer(scp, MISCOMPARE, MISCOMPARE_VERIFY_ASC, 0); in resp_comp_write()
3471 static int resp_unmap(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) in resp_unmap() argument
3482 payload_len = get_unaligned_be16(scp->cmnd + 7); in resp_unmap()
3483 BUG_ON(scsi_bufflen(scp) != payload_len); in resp_unmap()
3487 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_unmap()
3491 buf = kzalloc(scsi_bufflen(scp), GFP_ATOMIC); in resp_unmap()
3493 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, in resp_unmap()
3498 scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); in resp_unmap()
3511 ret = check_device_access_params(scp, lba, num, true); in resp_unmap()
3529 static int resp_get_lba_status(struct scsi_cmnd *scp, in resp_get_lba_status() argument
3532 u8 *cmd = scp->cmnd; in resp_get_lba_status()
3544 ret = check_device_access_params(scp, lba, 1, false); in resp_get_lba_status()
3566 return fill_from_dev_buffer(scp, arr, SDEBUG_GET_LBA_STATUS_LEN); in resp_get_lba_status()
3569 static int resp_sync_cache(struct scsi_cmnd *scp, in resp_sync_cache() argument
3575 u8 *cmd = scp->cmnd; in resp_sync_cache()
3585 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, 0); in resp_sync_cache()
3605 static int resp_report_luns(struct scsi_cmnd *scp, in resp_report_luns() argument
3608 unsigned char *cmd = scp->cmnd; in resp_report_luns()
3629 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_report_luns()
3651 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_report_luns()
3660 scsi_set_resid(scp, scsi_bufflen(scp)); in resp_report_luns()
3682 res = p_fill_from_dev_buffer(scp, arr, n, off_rsp); in resp_report_luns()
3692 res = p_fill_from_dev_buffer(scp, arr, j * sz_lun, off_rsp); in resp_report_luns()
3716 struct scsi_cmnd *scp; in sdebug_q_cmd_complete() local
3735 scp = sqcp->a_cmnd; in sdebug_q_cmd_complete()
3736 if (unlikely(scp == NULL)) { in sdebug_q_cmd_complete()
3742 devip = (struct sdebug_dev_info *)scp->device->hostdata; in sdebug_q_cmd_complete()
3778 scp->scsi_done(scp); /* callback to mid level */ in sdebug_q_cmd_complete()
5564 static bool fake_timeout(struct scsi_cmnd *scp) in fake_timeout() argument
5572 scsi_medium_access_command(scp)) in fake_timeout()
5578 static bool fake_host_busy(struct scsi_cmnd *scp) in fake_host_busy() argument
5585 struct scsi_cmnd *scp) in scsi_debug_queuecommand() argument
5588 struct scsi_device *sdp = scp->device; in scsi_debug_queuecommand()
5592 u8 *cmd = scp->cmnd; in scsi_debug_queuecommand()
5602 scsi_set_resid(scp, 0); in scsi_debug_queuecommand()
5610 len = scp->cmd_len; in scsi_debug_queuecommand()
5620 blk_mq_unique_tag(scp->request), b); in scsi_debug_queuecommand()
5622 if (fake_host_busy(scp)) in scsi_debug_queuecommand()
5657 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 4); in scsi_debug_queuecommand()
5659 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 8, 7); in scsi_debug_queuecommand()
5661 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
5667 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
5674 mk_sense_invalid_opcode(scp); in scsi_debug_queuecommand()
5688 mk_sense_invalid_fld(scp, SDEB_IN_CDB, k, j); in scsi_debug_queuecommand()
5696 errsts = make_ua(scp, devip); in scsi_debug_queuecommand()
5701 mk_sense_buffer(scp, NOT_READY, LOGICAL_UNIT_NOT_READY, 0x2); in scsi_debug_queuecommand()
5712 if (fake_timeout(scp)) in scsi_debug_queuecommand()
5722 return schedule_resp(scp, devip, errsts, pfp, 0, 0); in scsi_debug_queuecommand()
5735 return schedule_resp(scp, devip, errsts, pfp, jdelay, 0); in scsi_debug_queuecommand()
5737 return schedule_resp(scp, devip, errsts, pfp, sdebug_jdelay, in scsi_debug_queuecommand()
5740 return schedule_resp(scp, devip, check_condition_result, NULL, 0, 0); in scsi_debug_queuecommand()
5742 return schedule_resp(scp, NULL, DID_NO_CONNECT << 16, NULL, 0, 0); in scsi_debug_queuecommand()