• Home
  • Raw
  • Download

Lines Matching +full:tp +full:- +full:sensitive +full:- +full:adjust

9  * Copyright (C) 2001 - 2018 Douglas Gilbert
39 #include <linux/crc-t10dif.h>
45 #include <linux/t10-pi.h>
133 #define DEF_SCSI_LEVEL 7 /* INQUIRY, byte2 [6->SPC-4; 7->SPC-5] */
146 #define JDELAY_OVERRIDDEN -9999
177 * - a missing response is simulated if SDEBUG_OPT_TIMEOUT is set
178 * - a RECOVERED_ERROR is simulated on successful read and write
180 * - a TRANSPORT_ERROR is simulated on successful read and write
182 * - similarly for DIF_ERR, DIX_ERR, SHORT_TRANSFER, HOST_BUSY and
185 * When "every_nth" < 0 then after "- every_nth" commands the selected
188 * a new value (other than -1 or 1) to every_nth:
192 /* As indicated in SAM-5 and SPC-4 Unit Attentions (UAs) are returned in
217 * per-device DEF_CMD_PER_LUN can be changed via sysfs:
320 u32 flags; /* OR-ed set of SDEB_F_* */
323 u8 len_mask[16]; /* len_mask[0]-->cdb_len, then mask for cdb */
364 /* 0x0; 0x0->0x1f: 6 byte cdbs */
372 /* 0x20; 0x20->0x3f: 10 byte cdbs */
377 /* 0x40; 0x40->0x5f: 10 byte cdbs */
383 /* 0x60; 0x60->0x7d are reserved, 0x7e is "extended cdb" */
387 /* 0x80; 0x80->0x9f: 16 byte cdbs */
392 /* 0xa0; 0xa0->0xbf: 12 byte cdbs */
399 /* 0xc0; 0xc0->0xff: vendor specific */
407 * The following "response" functions return the SCSI mid-level's 4 byte
408 * tuple-in-an-int. To handle commands with an IMMED bit, for a faster
440 * the opcode_info_arr array. The most time sensitive (or commonly used) cdb
703 static int submit_queues = DEF_SUBMIT_QUEUES; /* > 1 for multi-queue (mq) */
759 hpnt = sdbg_host->shost; in sdebug_max_tgts_luns()
760 if ((hpnt->this_id >= 0) && in sdebug_max_tgts_luns()
761 (sdebug_num_tgts > hpnt->this_id)) in sdebug_max_tgts_luns()
762 hpnt->max_id = sdebug_num_tgts + 1; in sdebug_max_tgts_luns()
764 hpnt->max_id = sdebug_num_tgts; in sdebug_max_tgts_luns()
766 hpnt->max_lun = SCSI_W_LUN_REPORT_LUNS + 1; in sdebug_max_tgts_luns()
773 /* Set in_bit to -1 to indicate no bit position of invalid field */
782 sbuff = scp->sense_buffer; in mk_sense_invalid_fld()
784 sdev_printk(KERN_ERR, scp->device, in mk_sense_invalid_fld()
809 sdev_printk(KERN_INFO, scp->device, "%s: [sense_key,asc,ascq" in mk_sense_invalid_fld()
818 sbuff = scp->sense_buffer; in mk_sense_buffer()
820 sdev_printk(KERN_ERR, scp->device, in mk_sense_buffer()
829 sdev_printk(KERN_INFO, scp->device, in mk_sense_buffer()
853 return -EINVAL; in scsi_debug_ioctl()
854 /* return -ENOTTY; // correct return but upsets fdisk */ in scsi_debug_ioctl()
861 sdev->use_10_for_rw = false; in config_cdb_len()
862 sdev->use_16_for_rw = false; in config_cdb_len()
863 sdev->use_10_for_ms = false; in config_cdb_len()
866 sdev->use_10_for_rw = true; in config_cdb_len()
867 sdev->use_16_for_rw = false; in config_cdb_len()
868 sdev->use_10_for_ms = false; in config_cdb_len()
871 sdev->use_10_for_rw = true; in config_cdb_len()
872 sdev->use_16_for_rw = false; in config_cdb_len()
873 sdev->use_10_for_ms = true; in config_cdb_len()
876 sdev->use_10_for_rw = false; in config_cdb_len()
877 sdev->use_16_for_rw = true; in config_cdb_len()
878 sdev->use_10_for_ms = true; in config_cdb_len()
881 sdev->use_10_for_rw = false; in config_cdb_len()
882 sdev->use_16_for_rw = true; in config_cdb_len()
883 sdev->use_10_for_ms = true; in config_cdb_len()
888 sdev->use_10_for_rw = true; in config_cdb_len()
889 sdev->use_16_for_rw = false; in config_cdb_len()
890 sdev->use_10_for_ms = false; in config_cdb_len()
904 shost = sdbg_host->shost; in all_config_cdb_len()
919 list_for_each_entry(dp, &sdhp->dev_info_list, dev_list) { in clear_luns_changed_on_target()
920 if ((devip->sdbg_host == dp->sdbg_host) && in clear_luns_changed_on_target()
921 (devip->target == dp->target)) in clear_luns_changed_on_target()
922 clear_bit(SDEBUG_UA_LUNS_CHANGED, dp->uas_bm); in clear_luns_changed_on_target()
932 k = find_first_bit(devip->uas_bm, SDEBUG_NUM_UAS); in make_ua()
977 * SPC-3 behavior is to report a UNIT ATTENTION with in make_ua()
980 * received. SPC-4 behavior is to report it only once. in make_ua()
982 * values as struct scsi_device->scsi_level. in make_ua()
984 if (sdebug_scsi_level >= 6) /* SPC-4 and above */ in make_ua()
998 clear_bit(k, devip->uas_bm); in make_ua()
1000 sdev_printk(KERN_INFO, scp->device, in make_ua()
1008 /* Build SCSI "data-in" buffer. Returns 0 if ok else (DID_ERROR << 16). */
1015 if (!sdb->length) in fill_from_dev_buffer()
1017 if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_FROM_DEVICE)) in fill_from_dev_buffer()
1020 act_len = sg_copy_from_buffer(sdb->table.sgl, sdb->table.nents, in fill_from_dev_buffer()
1022 sdb->resid = scsi_bufflen(scp) - act_len; in fill_from_dev_buffer()
1027 /* Partial build of SCSI "data-in" buffer. Returns 0 if ok else
1028 * (DID_ERROR << 16). Can write to offset in data-in buffer. If multiple
1039 if (sdb->length <= off_dst) in p_fill_from_dev_buffer()
1041 if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_FROM_DEVICE)) in p_fill_from_dev_buffer()
1044 act_len = sg_pcopy_from_buffer(sdb->table.sgl, sdb->table.nents, in p_fill_from_dev_buffer()
1047 __func__, off_dst, scsi_bufflen(scp), act_len, sdb->resid); in p_fill_from_dev_buffer()
1048 n = (int)scsi_bufflen(scp) - ((int)off_dst + act_len); in p_fill_from_dev_buffer()
1049 sdb->resid = min(sdb->resid, n); in p_fill_from_dev_buffer()
1053 /* Fetches from SCSI "data-out" buffer. Returns number of bytes fetched into
1054 * 'arr' or -1 if error.
1061 if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_TO_DEVICE)) in fetch_to_dev_buffer()
1062 return -1; in fetch_to_dev_buffer()
1108 /* NAA-3, Logical unit identifier (binary) */ in inquiry_vpd_83()
1126 /* NAA-3, Target port identifier */ in inquiry_vpd_83()
1133 /* NAA-3, Target port group identifier */ in inquiry_vpd_83()
1142 /* NAA-3, Target device identifier */ in inquiry_vpd_83()
1150 arr[num++] = 0x63; /* proto=sas, UTF-8 */ in inquiry_vpd_83()
1194 memset(arr + num + olen, 0, plen - olen); in inquiry_vpd_85()
1206 memset(arr + num + olen, 0, plen - olen); in inquiry_vpd_85()
1227 arr[num++] = 12; /* length tp descriptor */ in inquiry_vpd_88()
1228 /* naa-5 target port identifier (A) */ in inquiry_vpd_88()
1242 arr[num++] = 12; /* length tp descriptor */ in inquiry_vpd_88()
1243 /* naa-5 target port identifier (B) */ in inquiry_vpd_88()
1314 /* Block limits VPD page (SBC-3) */
1361 /* Block device characteristics VPD page (SBC-3) */
1373 /* Logical block provisioning VPD page (SBC-4) */
1399 unsigned char *cmd = scp->cmnd; in resp_inquiry()
1408 have_wlun = scsi_is_wlun(scp->device->lun); in resp_inquiry()
1411 else if (sdebug_no_lun_0 && (devip->lun == SDEBUG_LUN_0_VAL)) in resp_inquiry()
1423 int host_no = devip->sdbg_host->shost->host_no; in resp_inquiry()
1426 (devip->channel & 0x7f); in resp_inquiry()
1429 lu_id_num = have_wlun ? -1 : (((host_no + 1) * 2000) + in resp_inquiry()
1430 (devip->target * 1000) + devip->lun); in resp_inquiry()
1432 (devip->target * 1000) - 3; in resp_inquiry()
1451 arr[3] = n - 4; /* number of supported VPD pages */ in resp_inquiry()
1461 &devip->lu_name); in resp_inquiry()
1481 arr[4] = 0x2; /* disconnect-reconnect mp */ in resp_inquiry()
1502 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_inquiry()
1516 arr[4] = SDEBUG_LONG_INQ_SZ - 5; in resp_inquiry()
1529 put_unaligned_be16(0xc0, arr + 58); /* SAM-6 no version claimed */ in resp_inquiry()
1530 put_unaligned_be16(0x5c0, arr + 60); /* SPC-5 no version claimed */ in resp_inquiry()
1532 if (is_disk) { /* SBC-4 no version claimed */ in resp_inquiry()
1535 } else if (sdebug_ptype == TYPE_TAPE) { /* SSC-4 rev 3 */ in resp_inquiry()
1539 put_unaligned_be16(0x2100, arr + n); /* SPL-4 no version claimed */ in resp_inquiry()
1553 unsigned char *cmd = scp->cmnd; in resp_requests()
1560 sbuff = scp->sense_buffer; in resp_requests()
1613 unsigned char *cmd = scp->cmnd; in resp_start_stop()
1623 changing = atomic_read(&devip->stopped) == !stop; in resp_start_stop()
1624 atomic_xchg(&devip->stopped, stop); in resp_start_stop()
1653 capac = (unsigned int)sdebug_capacity - 1; in resp_readcap()
1665 unsigned char *cmd = scp->cmnd; in resp_readcap16()
1673 put_unaligned_be64((u64)(sdebug_capacity - 1), arr + 0); in resp_readcap16()
1691 arr[12] = (sdebug_dif - 1) << 1; /* P_TYPE */ in resp_readcap16()
1704 unsigned char *cmd = scp->cmnd; in resp_report_tgtpgs()
1706 int host_no = devip->sdbg_host->shost->host_no; in resp_report_tgtpgs()
1723 (devip->channel & 0x7f); in resp_report_tgtpgs()
1725 (devip->channel & 0x7f) + 0x80; in resp_report_tgtpgs()
1761 rlen = n - 4; in resp_report_tgtpgs()
1766 * - The allocated length in resp_report_tgtpgs()
1767 * - The constructed command length in resp_report_tgtpgs()
1768 * - The maximum array size in resp_report_tgtpgs()
1788 u8 *cmd = scp->cmnd; in resp_rsup_opcodes()
1796 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_opcodes()
1813 oip->num_attached != 0xff; ++oip) { in resp_rsup_opcodes()
1814 if (F_INV_OP & oip->flags) in resp_rsup_opcodes()
1816 count += (oip->num_attached + 1); in resp_rsup_opcodes()
1821 oip->num_attached != 0xff && offset < a_len; ++oip) { in resp_rsup_opcodes()
1822 if (F_INV_OP & oip->flags) in resp_rsup_opcodes()
1824 na = oip->num_attached; in resp_rsup_opcodes()
1825 arr[offset] = oip->opcode; in resp_rsup_opcodes()
1826 put_unaligned_be16(oip->sa, arr + offset + 2); in resp_rsup_opcodes()
1829 if (FF_SA & oip->flags) in resp_rsup_opcodes()
1831 put_unaligned_be16(oip->len_mask[0], arr + offset + 6); in resp_rsup_opcodes()
1835 for (k = 0, oip = oip->arrp; k < na; ++k, ++oip) { in resp_rsup_opcodes()
1836 if (F_INV_OP & oip->flags) in resp_rsup_opcodes()
1839 arr[offset] = oip->opcode; in resp_rsup_opcodes()
1840 put_unaligned_be16(oip->sa, arr + offset + 2); in resp_rsup_opcodes()
1843 if (FF_SA & oip->flags) in resp_rsup_opcodes()
1845 put_unaligned_be16(oip->len_mask[0], in resp_rsup_opcodes()
1860 if (F_INV_OP & oip->flags) { in resp_rsup_opcodes()
1865 if (FF_SA & oip->flags) { in resp_rsup_opcodes()
1873 0 == (FF_SA & oip->flags)) { in resp_rsup_opcodes()
1874 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 4, -1); in resp_rsup_opcodes()
1878 if (0 == (FF_SA & oip->flags) && in resp_rsup_opcodes()
1879 req_opcode == oip->opcode) in resp_rsup_opcodes()
1881 else if (0 == (FF_SA & oip->flags)) { in resp_rsup_opcodes()
1882 na = oip->num_attached; in resp_rsup_opcodes()
1883 for (k = 0, oip = oip->arrp; k < na; in resp_rsup_opcodes()
1885 if (req_opcode == oip->opcode) in resp_rsup_opcodes()
1889 } else if (req_sa != oip->sa) { in resp_rsup_opcodes()
1890 na = oip->num_attached; in resp_rsup_opcodes()
1891 for (k = 0, oip = oip->arrp; k < na; in resp_rsup_opcodes()
1893 if (req_sa == oip->sa) in resp_rsup_opcodes()
1900 u = oip->len_mask[0]; in resp_rsup_opcodes()
1902 arr[4] = oip->opcode; in resp_rsup_opcodes()
1905 oip->len_mask[k] : 0xff; in resp_rsup_opcodes()
1934 u8 *cmd = scp->cmnd; in resp_rsup_tmfs()
1940 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_rsup_tmfs()
1958 { /* Read-Write Error Recovery page for mode_sense */ in resp_err_recov_pg()
1964 memset(p + 2, 0, sizeof(err_recov_pg) - 2); in resp_err_recov_pg()
1969 { /* Disconnect-Reconnect page for mode_sense */ in resp_disconnect_pg()
1975 memset(p + 2, 0, sizeof(disconnect_pg) - 2); in resp_disconnect_pg()
1991 memset(p + 2, 0, sizeof(format_pg) - 2); in resp_format_pg()
2059 { /* SAS SSP mode page - short format for mode_sense */ in resp_sas_sf_m_pg()
2065 memset(p + 2, 0, sizeof(sas_sf_m_pg) - 2); in resp_sas_sf_m_pg()
2099 memset(p + 4, 0, sizeof(sas_pcd_m_pg) - 4); in resp_sas_pcd_m_spg()
2111 memset(p + 4, 0, sizeof(sas_sha_m_pg) - 4); in resp_sas_sha_m_spg()
2123 int target = scp->device->id; in resp_mode_sense()
2126 unsigned char *cmd = scp->cmnd; in resp_mode_sense()
2146 target_dev_id = ((devip->sdbg_host->shost->host_no + 1) * 2000) + in resp_mode_sense()
2147 (devip->target * 1000) - 3; in resp_mode_sense()
2150 dev_spec = 0x10; /* =0x90 if WP=1 implies read-only */ in resp_mode_sense()
2185 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2191 case 0x1: /* Read-Write error recovery page, direct access */ in resp_mode_sense()
2195 case 0x2: /* Disconnect-Reconnect page, all devices */ in resp_mode_sense()
2219 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2256 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_mode_sense()
2269 arr[0] = offset - 1; in resp_mode_sense()
2271 put_unaligned_be16((offset - 2), arr + 0); in resp_mode_sense()
2283 unsigned char *cmd = scp->cmnd; in resp_mode_select()
2291 mk_sense_invalid_fld(scp, SDEB_IN_CDB, mselect6 ? 4 : 7, -1); in resp_mode_select()
2295 if (-1 == res) in resp_mode_select()
2298 sdev_printk(KERN_INFO, scp->device, in resp_mode_select()
2304 mk_sense_invalid_fld(scp, SDEB_IN_DATA, 0, -1); in resp_mode_select()
2326 sizeof(caching_pg) - 2); in resp_mode_select()
2333 sizeof(ctrl_m_pg) - 2); in resp_mode_select()
2341 sizeof(iec_m_pg) - 2); in resp_mode_select()
2351 set_bit(SDEBUG_UA_MODE_CHANGED, devip->uas_bm); in resp_mode_select()
2385 unsigned char *cmd = scp->cmnd; in resp_log_sense()
2405 arr[3] = n - 4; in resp_log_sense()
2431 arr[3] = n - 4; in resp_log_sense()
2437 arr[3] = n - 4; in resp_log_sense()
2443 arr[3] = n - 4; in resp_log_sense()
2450 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1); in resp_log_sense()
2474 /* Returns number of bytes copied or -1 if error. */
2492 if (!sdb->length) in do_device_access()
2494 if (!(scsi_bidi_cmnd(scmd) || scmd->sc_data_direction == dir)) in do_device_access()
2495 return -1; in do_device_access()
2499 rest = block + num - sdebug_store_sectors; in do_device_access()
2501 ret = sg_copy_buffer(sdb->table.sgl, sdb->table.nents, in do_device_access()
2503 (num - rest) * sdebug_sector_size, sg_skip, do_write); in do_device_access()
2504 if (ret != (num - rest) * sdebug_sector_size) in do_device_access()
2508 ret += sg_copy_buffer(sdb->table.sgl, sdb->table.nents, in do_device_access()
2510 sg_skip + ((num - rest) * sdebug_sector_size), in do_device_access()
2529 rest = block + num - store_blks; in comp_write_worker()
2532 (num - rest) * lb_size); in comp_write_worker()
2536 res = memcmp(fake_storep, arr + ((num - rest) * lb_size), in comp_write_worker()
2541 memcpy(fake_storep + (block * lb_size), arr, (num - rest) * lb_size); in comp_write_worker()
2543 memcpy(fake_storep, arr + ((num - rest) * lb_size), in comp_write_worker()
2565 if (sdt->guard_tag != csum) { in dif_verify()
2568 be16_to_cpu(sdt->guard_tag), in dif_verify()
2573 be32_to_cpu(sdt->ref_tag) != (sector & 0xffffffff)) { in dif_verify()
2579 be32_to_cpu(sdt->ref_tag) != ei_lba) { in dif_verify()
2608 rest = start + len - dif_store_end; in dif_copy_prot()
2613 memcpy(paddr, start, len - rest); in dif_copy_prot()
2615 memcpy(start, paddr, len - rest); in dif_copy_prot()
2619 memcpy(paddr + len - rest, dif_storep, rest); in dif_copy_prot()
2621 memcpy(dif_storep, paddr + len - rest, rest); in dif_copy_prot()
2625 resid -= len; in dif_copy_prot()
2643 if (sdt->app_tag == cpu_to_be16(0xffff)) in prot_verify_read()
2661 u8 *cmd = scp->cmnd; in resp_read_dt0()
2718 sdev_printk(KERN_ERR, scp->device, "Unprotected RD " in resp_read_dt0()
2722 sqcp = (struct sdebug_queued_cmd *)scp->host_scribble; in resp_read_dt0()
2725 if (sqcp->inj_short) in resp_read_dt0()
2744 (lba <= (sdebug_medium_error_start + sdebug_medium_error_count - 1)) && in resp_read_dt0()
2749 if (0x70 == (scp->sense_buffer[0] & 0x7f)) { in resp_read_dt0()
2750 scp->sense_buffer[0] |= 0x80; /* Valid bit */ in resp_read_dt0()
2753 put_unaligned_be32(ret, scp->sense_buffer + 3); in resp_read_dt0()
2774 if (unlikely(ret == -1)) in resp_read_dt0()
2777 scsi_in(scp)->resid = scsi_bufflen(scp) - ret; in resp_read_dt0()
2780 if (sqcp->inj_recovered) { in resp_read_dt0()
2784 } else if (sqcp->inj_transport) { in resp_read_dt0()
2788 } else if (sqcp->inj_dif) { in resp_read_dt0()
2792 } else if (sqcp->inj_dix) { in resp_read_dt0()
2812 n += scnprintf(b + n, sizeof(b) - n, in dump_sector()
2815 n += scnprintf(b + n, sizeof(b) - n, in dump_sector()
2897 lba += sdebug_unmap_granularity - sdebug_unmap_alignment; in lba_to_map_index()
2907 lba -= sdebug_unmap_granularity - sdebug_unmap_alignment; in map_index_to_lba()
2927 *num = end - lba; in map_state()
2975 u8 *cmd = scp->cmnd; in resp_write_dt0()
3031 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_write_dt0()
3064 if (unlikely(-1 == ret)) in resp_write_dt0()
3068 sdev_printk(KERN_INFO, scp->device, in resp_write_dt0()
3074 (struct sdebug_queued_cmd *)scp->host_scribble; in resp_write_dt0()
3077 if (sqcp->inj_recovered) { in resp_write_dt0()
3081 } else if (sqcp->inj_dif) { in resp_write_dt0()
3085 } else if (sqcp->inj_dix) { in resp_write_dt0()
3101 u8 *cmd = scp->cmnd; in resp_write_scat()
3136 sdev_printk(KERN_ERR, scp->device, in resp_write_scat()
3141 return 0; /* T10 says these do-nothings are not errors */ in resp_write_scat()
3144 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3153 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3163 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3167 if (res == -1) { in resp_write_scat()
3180 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3193 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3218 if (unlikely(-1 == ret)) { in resp_write_scat()
3222 sdev_printk(KERN_INFO, scp->device, in resp_write_scat()
3228 (struct sdebug_queued_cmd *)scp->host_scribble; in resp_write_scat()
3231 if (sqcp->inj_recovered) { in resp_write_scat()
3236 } else if (sqcp->inj_dif) { in resp_write_scat()
3242 } else if (sqcp->inj_dix) { in resp_write_scat()
3291 if (-1 == ret) { in resp_write_same()
3295 sdev_printk(KERN_INFO, scp->device, in resp_write_same()
3316 u8 *cmd = scp->cmnd; in resp_write_same_10()
3332 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_write_same_10()
3341 u8 *cmd = scp->cmnd; in resp_write_same_16()
3355 if (cmd[1] & 0x1) /* NDOB (no data-out buffer, assumes zeroes) */ in resp_write_same_16()
3360 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 10, -1); in resp_write_same_16()
3367 * field. For the Report supported operation codes command, SPC-4 suggests
3372 u8 *cmd = scp->cmnd; in resp_write_buffer()
3373 struct scsi_device *sdp = scp->device; in resp_write_buffer()
3381 set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm); in resp_write_buffer()
3382 set_bit(SDEBUG_UA_MICROCODE_CHANGED, devip->uas_bm); in resp_write_buffer()
3385 set_bit(SDEBUG_UA_MICROCODE_CHANGED_WO_RESET, devip->uas_bm); in resp_write_buffer()
3390 &devip->sdbg_host->dev_info_list, in resp_write_buffer()
3392 if (dp->target == sdp->id) { in resp_write_buffer()
3393 set_bit(SDEBUG_UA_BUS_RESET, dp->uas_bm); in resp_write_buffer()
3396 dp->uas_bm); in resp_write_buffer()
3402 &devip->sdbg_host->dev_info_list, in resp_write_buffer()
3404 if (dp->target == sdp->id) in resp_write_buffer()
3406 dp->uas_bm); in resp_write_buffer()
3418 u8 *cmd = scp->cmnd; in resp_comp_write()
3441 sdev_printk(KERN_ERR, scp->device, "Unprotected WR " in resp_comp_write()
3466 * from data-in into arr. Safe (atomic) since write_lock held. */ in resp_comp_write()
3471 if (ret == -1) { in resp_comp_write()
3475 sdev_printk(KERN_INFO, scp->device, "%s: compare_write: cdb " in resp_comp_write()
3508 payload_len = get_unaligned_be16(scp->cmnd + 7); in resp_unmap()
3511 descriptors = (payload_len - 8) / 16; in resp_unmap()
3513 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 7, -1); in resp_unmap()
3526 BUG_ON(get_unaligned_be16(&buf[0]) != payload_len - 2); in resp_unmap()
3558 u8 *cmd = scp->cmnd; in resp_get_lba_status()
3580 if (sdebug_capacity - lba <= 0xffffffff) in resp_get_lba_status()
3581 num = sdebug_capacity - lba; in resp_get_lba_status()
3601 u8 *cmd = scp->cmnd; in resp_sync_cache()
3624 * (W-LUN), the normal Linux scanning logic does not associate it with a
3626 * "cd /sys/class/scsi_host/host<n> ; echo '- - 49409' > scan"
3628 * the above will associate a W-LUN to each target. To only get a W-LUN
3629 * for target 2, then use "echo '- 2 49409' > scan" .
3634 unsigned char *cmd = scp->cmnd; in resp_report_luns()
3641 unsigned int wlun_cnt; /* report luns W-LUN count */ in resp_report_luns()
3655 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1); in resp_report_luns()
3660 case 0: /* all LUNs apart from W-LUNs */ in resp_report_luns()
3664 case 1: /* only W-LUNs */ in resp_report_luns()
3673 case 0x11: /* see SPC-5 */ in resp_report_luns()
3677 mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, -1); in resp_report_luns()
3682 --lun_cnt; in resp_report_luns()
3742 sg_miter_start(&miter, sdb->table.sgl, sdb->table.nents, in resp_xdwriteread()
3761 u8 *cmd = scp->cmnd; in resp_xdwriteread_10()
3786 u32 tag = blk_mq_unique_tag(cmnd->request); in get_queue()
3798 bool aborted = sd_dp->aborted; in sdebug_q_cmd_complete()
3807 sd_dp->defer_t = SDEB_DEFER_NONE; in sdebug_q_cmd_complete()
3809 sd_dp->aborted = false; in sdebug_q_cmd_complete()
3810 qc_idx = sd_dp->qc_idx; in sdebug_q_cmd_complete()
3811 sqp = sdebug_q_arr + sd_dp->sqa_idx; in sdebug_q_cmd_complete()
3814 if (raw_smp_processor_id() != sd_dp->issuing_cpu) in sdebug_q_cmd_complete()
3821 spin_lock_irqsave(&sqp->qc_lock, iflags); in sdebug_q_cmd_complete()
3822 sqcp = &sqp->qc_arr[qc_idx]; in sdebug_q_cmd_complete()
3823 scp = sqcp->a_cmnd; in sdebug_q_cmd_complete()
3825 spin_unlock_irqrestore(&sqp->qc_lock, iflags); in sdebug_q_cmd_complete()
3827 sd_dp->sqa_idx, qc_idx); in sdebug_q_cmd_complete()
3830 devip = (struct sdebug_dev_info *)scp->device->hostdata; in sdebug_q_cmd_complete()
3832 atomic_dec(&devip->num_in_q); in sdebug_q_cmd_complete()
3838 sqcp->a_cmnd = NULL; in sdebug_q_cmd_complete()
3839 if (unlikely(!test_and_clear_bit(qc_idx, sqp->in_use_bm))) { in sdebug_q_cmd_complete()
3840 spin_unlock_irqrestore(&sqp->qc_lock, iflags); in sdebug_q_cmd_complete()
3850 spin_unlock_irqrestore(&sqp->qc_lock, iflags); in sdebug_q_cmd_complete()
3854 k = find_last_bit(sqp->in_use_bm, retval); in sdebug_q_cmd_complete()
3860 spin_unlock_irqrestore(&sqp->qc_lock, iflags); in sdebug_q_cmd_complete()
3866 scp->scsi_done(scp); /* callback to mid level */ in sdebug_q_cmd_complete()
3897 uuid_gen(&devip->lu_name); in sdebug_device_create()
3900 devip->lu_name = shared_uuid; in sdebug_device_create()
3904 devip->lu_name = shared_uuid; in sdebug_device_create()
3907 devip->sdbg_host = sdbg_host; in sdebug_device_create()
3908 list_add_tail(&devip->dev_list, &sdbg_host->dev_info_list); in sdebug_device_create()
3919 sdbg_host = *(struct sdebug_host_info **)shost_priv(sdev->host); in find_build_dev_info()
3924 list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) { in find_build_dev_info()
3925 if ((devip->used) && (devip->channel == sdev->channel) && in find_build_dev_info()
3926 (devip->target == sdev->id) && in find_build_dev_info()
3927 (devip->lun == sdev->lun)) in find_build_dev_info()
3930 if ((!devip->used) && (!open_devip)) in find_build_dev_info()
3942 open_devip->channel = sdev->channel; in find_build_dev_info()
3943 open_devip->target = sdev->id; in find_build_dev_info()
3944 open_devip->lun = sdev->lun; in find_build_dev_info()
3945 open_devip->sdbg_host = sdbg_host; in find_build_dev_info()
3946 atomic_set(&open_devip->num_in_q, 0); in find_build_dev_info()
3947 set_bit(SDEBUG_UA_POR, open_devip->uas_bm); in find_build_dev_info()
3948 open_devip->used = true; in find_build_dev_info()
3956 sdp->host->host_no, sdp->channel, sdp->id, sdp->lun); in scsi_debug_slave_alloc()
3957 blk_queue_flag_set(QUEUE_FLAG_BIDI, sdp->request_queue); in scsi_debug_slave_alloc()
3964 (struct sdebug_dev_info *)sdp->hostdata; in scsi_debug_slave_configure()
3968 sdp->host->host_no, sdp->channel, sdp->id, sdp->lun); in scsi_debug_slave_configure()
3969 if (sdp->host->max_cmd_len != SDEBUG_MAX_CMD_LEN) in scsi_debug_slave_configure()
3970 sdp->host->max_cmd_len = SDEBUG_MAX_CMD_LEN; in scsi_debug_slave_configure()
3976 sdp->hostdata = devip; in scsi_debug_slave_configure()
3977 blk_queue_max_segment_size(sdp->request_queue, -1U); in scsi_debug_slave_configure()
3979 sdp->no_uld_attach = 1; in scsi_debug_slave_configure()
3987 (struct sdebug_dev_info *)sdp->hostdata; in scsi_debug_slave_destroy()
3991 sdp->host->host_no, sdp->channel, sdp->id, sdp->lun); in scsi_debug_slave_destroy()
3993 /* make this slot available for re-use */ in scsi_debug_slave_destroy()
3994 devip->used = false; in scsi_debug_slave_destroy()
3995 sdp->hostdata = NULL; in scsi_debug_slave_destroy()
4005 hrtimer_cancel(&sd_dp->hrt); in stop_qc_helper()
4007 cancel_work_sync(&sd_dp->ew.work); in stop_qc_helper()
4023 spin_lock_irqsave(&sqp->qc_lock, iflags); in stop_queued_cmnd()
4029 if (test_bit(k, sqp->in_use_bm)) { in stop_queued_cmnd()
4030 sqcp = &sqp->qc_arr[k]; in stop_queued_cmnd()
4031 if (cmnd != sqcp->a_cmnd) in stop_queued_cmnd()
4035 cmnd->device->hostdata; in stop_queued_cmnd()
4037 atomic_dec(&devip->num_in_q); in stop_queued_cmnd()
4038 sqcp->a_cmnd = NULL; in stop_queued_cmnd()
4039 sd_dp = sqcp->sd_dp; in stop_queued_cmnd()
4041 l_defer_t = sd_dp->defer_t; in stop_queued_cmnd()
4042 sd_dp->defer_t = SDEB_DEFER_NONE; in stop_queued_cmnd()
4045 spin_unlock_irqrestore(&sqp->qc_lock, iflags); in stop_queued_cmnd()
4047 clear_bit(k, sqp->in_use_bm); in stop_queued_cmnd()
4051 spin_unlock_irqrestore(&sqp->qc_lock, iflags); in stop_queued_cmnd()
4068 spin_lock_irqsave(&sqp->qc_lock, iflags); in stop_all_queued()
4070 if (test_bit(k, sqp->in_use_bm)) { in stop_all_queued()
4071 sqcp = &sqp->qc_arr[k]; in stop_all_queued()
4072 if (sqcp->a_cmnd == NULL) in stop_all_queued()
4075 sqcp->a_cmnd->device->hostdata; in stop_all_queued()
4077 atomic_dec(&devip->num_in_q); in stop_all_queued()
4078 sqcp->a_cmnd = NULL; in stop_all_queued()
4079 sd_dp = sqcp->sd_dp; in stop_all_queued()
4081 l_defer_t = sd_dp->defer_t; in stop_all_queued()
4082 sd_dp->defer_t = SDEB_DEFER_NONE; in stop_all_queued()
4085 spin_unlock_irqrestore(&sqp->qc_lock, iflags); in stop_all_queued()
4087 clear_bit(k, sqp->in_use_bm); in stop_all_queued()
4088 spin_lock_irqsave(&sqp->qc_lock, iflags); in stop_all_queued()
4091 spin_unlock_irqrestore(&sqp->qc_lock, iflags); in stop_all_queued()
4104 sqcp = &sqp->qc_arr[k]; in free_all_queued()
4105 kfree(sqcp->sd_dp); in free_all_queued()
4106 sqcp->sd_dp = NULL; in free_all_queued()
4118 if (SCpnt->device && (SDEBUG_OPT_ALL_NOISE & sdebug_opts)) in scsi_debug_abort()
4119 sdev_printk(KERN_INFO, SCpnt->device, in scsi_debug_abort()
4129 if (SCpnt && SCpnt->device) { in scsi_debug_device_reset()
4130 struct scsi_device *sdp = SCpnt->device; in scsi_debug_device_reset()
4132 (struct sdebug_dev_info *)sdp->hostdata; in scsi_debug_device_reset()
4137 set_bit(SDEBUG_UA_POR, devip->uas_bm); in scsi_debug_device_reset()
4153 sdp = SCpnt->device; in scsi_debug_target_reset()
4158 hp = sdp->host; in scsi_debug_target_reset()
4164 &sdbg_host->dev_info_list, in scsi_debug_target_reset()
4166 if (devip->target == sdp->id) { in scsi_debug_target_reset()
4167 set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm); in scsi_debug_target_reset()
4187 if (!(SCpnt && SCpnt->device)) in scsi_debug_bus_reset()
4189 sdp = SCpnt->device; in scsi_debug_bus_reset()
4192 hp = sdp->host; in scsi_debug_bus_reset()
4197 &sdbg_host->dev_info_list, in scsi_debug_bus_reset()
4199 set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm); in scsi_debug_bus_reset()
4218 if ((SCpnt->device) && (SDEBUG_OPT_ALL_NOISE & sdebug_opts)) in scsi_debug_host_reset()
4219 sdev_printk(KERN_INFO, SCpnt->device, "%s\n", __func__); in scsi_debug_host_reset()
4222 list_for_each_entry(devip, &sdbg_host->dev_info_list, in scsi_debug_host_reset()
4224 set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm); in scsi_debug_host_reset()
4231 sdev_printk(KERN_INFO, SCpnt->device, in scsi_debug_host_reset()
4252 sectors_per_part = (num_sectors - sdebug_sectors_per) in sdebug_build_parts()
4267 end_sec = starts[k + 1] - 1; in sdebug_build_parts()
4268 pp->boot_ind = 0; in sdebug_build_parts()
4270 pp->cyl = start_sec / heads_by_sects; in sdebug_build_parts()
4271 pp->head = (start_sec - (pp->cyl * heads_by_sects)) in sdebug_build_parts()
4273 pp->sector = (start_sec % sdebug_sectors_per) + 1; in sdebug_build_parts()
4275 pp->end_cyl = end_sec / heads_by_sects; in sdebug_build_parts()
4276 pp->end_head = (end_sec - (pp->end_cyl * heads_by_sects)) in sdebug_build_parts()
4278 pp->end_sector = (end_sec % sdebug_sectors_per) + 1; in sdebug_build_parts()
4280 pp->start_sect = cpu_to_le32(start_sec); in sdebug_build_parts()
4281 pp->nr_sects = cpu_to_le32(end_sec - start_sec + 1); in sdebug_build_parts()
4282 pp->sys_ind = 0x83; /* plain Linux partition */ in sdebug_build_parts()
4292 atomic_set(&sqp->blocked, (int)block); in block_unblock_all_queues()
4295 /* Adjust (by rounding down) the sdebug_cmnd_count so abs(every_nth)-1
4324 sqcp->inj_recovered = sqcp->inj_transport in setup_inject()
4325 = sqcp->inj_dif in setup_inject()
4326 = sqcp->inj_dix = sqcp->inj_short in setup_inject()
4327 = sqcp->inj_host_busy = sqcp->inj_cmd_abort = 0; in setup_inject()
4330 sqcp->inj_recovered = !!(SDEBUG_OPT_RECOVERED_ERR & sdebug_opts); in setup_inject()
4331 sqcp->inj_transport = !!(SDEBUG_OPT_TRANSPORT_ERR & sdebug_opts); in setup_inject()
4332 sqcp->inj_dif = !!(SDEBUG_OPT_DIF_ERR & sdebug_opts); in setup_inject()
4333 sqcp->inj_dix = !!(SDEBUG_OPT_DIX_ERR & sdebug_opts); in setup_inject()
4334 sqcp->inj_short = !!(SDEBUG_OPT_SHORT_TRANSFER & sdebug_opts); in setup_inject()
4335 sqcp->inj_host_busy = !!(SDEBUG_OPT_HOST_BUSY & sdebug_opts); in setup_inject()
4336 sqcp->inj_cmd_abort = !!(SDEBUG_OPT_CMD_ABORT & sdebug_opts); in setup_inject()
4362 sdp = cmnd->device; in schedule_resp()
4369 spin_lock_irqsave(&sqp->qc_lock, iflags); in schedule_resp()
4370 if (unlikely(atomic_read(&sqp->blocked))) { in schedule_resp()
4371 spin_unlock_irqrestore(&sqp->qc_lock, iflags); in schedule_resp()
4374 num_in_q = atomic_read(&devip->num_in_q); in schedule_resp()
4375 qdepth = cmnd->device->queue_depth; in schedule_resp()
4379 spin_unlock_irqrestore(&sqp->qc_lock, iflags); in schedule_resp()
4386 if ((num_in_q == (qdepth - 1)) && in schedule_resp()
4395 k = find_first_zero_bit(sqp->in_use_bm, sdebug_max_queue); in schedule_resp()
4397 spin_unlock_irqrestore(&sqp->qc_lock, iflags); in schedule_resp()
4413 __set_bit(k, sqp->in_use_bm); in schedule_resp()
4414 atomic_inc(&devip->num_in_q); in schedule_resp()
4415 sqcp = &sqp->qc_arr[k]; in schedule_resp()
4416 sqcp->a_cmnd = cmnd; in schedule_resp()
4417 cmnd->host_scribble = (unsigned char *)sqcp; in schedule_resp()
4418 sd_dp = sqcp->sd_dp; in schedule_resp()
4419 spin_unlock_irqrestore(&sqp->qc_lock, iflags); in schedule_resp()
4428 cmnd->result = pfp != NULL ? pfp(cmnd, devip) : 0; in schedule_resp()
4429 if (cmnd->result & SDEG_RES_IMMED_MASK) { in schedule_resp()
4433 cmnd->result &= ~SDEG_RES_IMMED_MASK; in schedule_resp()
4436 if (cmnd->result == 0 && scsi_result != 0) in schedule_resp()
4437 cmnd->result = scsi_result; in schedule_resp()
4439 if (unlikely(sdebug_verbose && cmnd->result)) in schedule_resp()
4440 sdev_printk(KERN_INFO, sdp, "%s: non-zero result=0x%x\n", in schedule_resp()
4441 __func__, cmnd->result); in schedule_resp()
4450 if (!sd_dp->init_hrt) { in schedule_resp()
4451 sd_dp->init_hrt = true; in schedule_resp()
4452 sqcp->sd_dp = sd_dp; in schedule_resp()
4453 hrtimer_init(&sd_dp->hrt, CLOCK_MONOTONIC, in schedule_resp()
4455 sd_dp->hrt.function = sdebug_q_cmd_hrt_complete; in schedule_resp()
4456 sd_dp->sqa_idx = sqp - sdebug_q_arr; in schedule_resp()
4457 sd_dp->qc_idx = k; in schedule_resp()
4460 sd_dp->issuing_cpu = raw_smp_processor_id(); in schedule_resp()
4461 sd_dp->defer_t = SDEB_DEFER_HRT; in schedule_resp()
4462 hrtimer_start(&sd_dp->hrt, kt, HRTIMER_MODE_REL_PINNED); in schedule_resp()
4464 if (!sd_dp->init_wq) { in schedule_resp()
4465 sd_dp->init_wq = true; in schedule_resp()
4466 sqcp->sd_dp = sd_dp; in schedule_resp()
4467 sd_dp->sqa_idx = sqp - sdebug_q_arr; in schedule_resp()
4468 sd_dp->qc_idx = k; in schedule_resp()
4469 INIT_WORK(&sd_dp->ew.work, sdebug_q_cmd_wq_complete); in schedule_resp()
4472 sd_dp->issuing_cpu = raw_smp_processor_id(); in schedule_resp()
4473 sd_dp->defer_t = SDEB_DEFER_WQ; in schedule_resp()
4474 if (unlikely(sqcp->inj_cmd_abort)) in schedule_resp()
4475 sd_dp->aborted = true; in schedule_resp()
4476 schedule_work(&sd_dp->ew.work); in schedule_resp()
4477 if (unlikely(sqcp->inj_cmd_abort)) { in schedule_resp()
4479 cmnd->request->tag); in schedule_resp()
4480 blk_abort_request(cmnd->request); in schedule_resp()
4491 respond_in_thread: /* call back to mid-layer using invocation thread */ in schedule_resp()
4492 cmnd->result = pfp != NULL ? pfp(cmnd, devip) : 0; in schedule_resp()
4493 cmnd->result &= ~SDEG_RES_IMMED_MASK; in schedule_resp()
4494 if (cmnd->result == 0 && scsi_result != 0) in schedule_resp()
4495 cmnd->result = scsi_result; in schedule_resp()
4496 cmnd->scsi_done(cmnd); in schedule_resp()
4570 MODULE_PARM_DESC(delay, "response delay (def=1 jiffy); 0:imm, -1,-2:tiny");
4572 MODULE_PARM_DESC(dif, "data integrity field type: 0-3 (def=0)");
4574 MODULE_PARM_DESC(dsense, "use descriptor sense format(def=0 -> fixed)");
4593 MODULE_PARM_DESC(ndelay, "response delay in nanoseconds (def=0 -> ignore)");
4594 MODULE_PARM_DESC(no_lun_0, "no LU number 0 (def=0 -> have lun 0)");
4599 MODULE_PARM_DESC(opts, "1->noise, 2->medium_err, 4->timeout, 8->recovered_err... (def=0)");
4604 MODULE_PARM_DESC(scsi_level, "SCSI level to simulate(def=7[SPC-5])");
4608 MODULE_PARM_DESC(submit_queues, "support for block multi-queue (def=1)");
4614 "1->use uuid for lu name, 0->don't, 2->all use same (def=0)");
4615 MODULE_PARM_DESC(virtual_gb, "virtual gigabyte (GiB) size (def=0 -> use dev_size_mb)");
4616 MODULE_PARM_DESC(vpd_use_hostno, "0 -> dev ids ignore hostno (def=1 -> unique dev ids)");
4628 if (k >= (SDEBUG_INFO_LEN - 1)) in scsi_debug_info()
4630 scnprintf(sdebug_info + k, SDEBUG_INFO_LEN - k, in scsi_debug_info()
4646 return -EACCES; in scsi_debug_write_info()
4650 return -EINVAL; in scsi_debug_write_info()
4694 f = find_first_bit(sqp->in_use_bm, sdebug_max_queue); in scsi_debug_show_info()
4696 l = find_last_bit(sqp->in_use_bm, sdebug_max_queue); in scsi_debug_show_info()
4708 /* Returns -EBUSY if jdelay is being changed and commands are queued. The unit
4725 k = find_first_bit(sqp->in_use_bm, in delay_store()
4728 res = -EBUSY; /* queued commands */ in delay_store()
4740 return -EINVAL; in delay_store()
4748 /* Returns -EBUSY if ndelay is being changed and commands are queued */
4765 k = find_first_bit(sqp->in_use_bm, in ndelay_store()
4768 res = -EBUSY; /* queued commands */ in ndelay_store()
4781 return -EINVAL; in ndelay_store()
4805 return -EINVAL; in opts_store()
4828 return -EINVAL; in ptype_store()
4845 return -EINVAL; in dsense_store()
4870 return -ENOMEM; in fake_rw_store()
4877 return -EINVAL; in fake_rw_store()
4894 return -EINVAL; in no_lun_0_store()
4912 return -EINVAL; in num_tgts_store()
4946 return -EINVAL; in every_nth_store()
4963 return -EINVAL; in max_luns_store()
4968 if (changed && (sdebug_scsi_level >= 5)) { /* >= SPC-3 */ in max_luns_store()
4975 list_for_each_entry(dp, &sdhp->dev_info_list, in max_luns_store()
4978 dp->uas_bm); in max_luns_store()
4985 return -EINVAL; in max_luns_store()
5007 a = find_last_bit(sqp->in_use_bm, SDEBUG_CANQUEUE); in max_queue_store()
5021 return -EINVAL; in max_queue_store()
5058 list_for_each_entry(dp, &sdhp->dev_info_list, in virtual_gb_store()
5061 dp->uas_bm); in virtual_gb_store()
5068 return -EINVAL; in virtual_gb_store()
5086 return -EINVAL; in add_host_store()
5090 } while (--delta_hosts); in add_host_store()
5113 return -EINVAL; in vpd_use_hostno_store()
5135 return -EINVAL; in statistics_store()
5180 return scnprintf(buf, PAGE_SIZE, "0-%u\n", in map_show()
5183 count = scnprintf(buf, PAGE_SIZE - 1, "%*pbl", in map_show()
5205 return -EINVAL; in removable_store()
5223 return -EINVAL; in host_lock_store()
5240 return -EINVAL; in strict_store()
5337 return -EINVAL; in scsi_debug_init()
5351 return -EINVAL; in scsi_debug_init()
5356 return -EINVAL; in scsi_debug_init()
5361 return -EINVAL; in scsi_debug_init()
5366 return -EINVAL; in scsi_debug_init()
5371 return -EINVAL; in scsi_debug_init()
5380 return -EINVAL; in scsi_debug_init()
5385 return -EINVAL; in scsi_debug_init()
5390 return -EINVAL; in scsi_debug_init()
5396 return -ENOMEM; in scsi_debug_init()
5427 ret = -ENOMEM; in scsi_debug_init()
5444 ret = -ENOMEM; in scsi_debug_init()
5466 ret = -EINVAL; in scsi_debug_init()
5470 map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1; in scsi_debug_init()
5478 ret = -ENOMEM; in scsi_debug_init()
5539 for (; k; k--) in scsi_debug_exit()
5573 return -ENOMEM; in sdebug_add_adapter()
5576 INIT_LIST_HEAD(&sdbg_host->dev_info_list); in sdebug_add_adapter()
5583 error = -ENOMEM; in sdebug_add_adapter()
5589 list_add_tail(&sdbg_host->host_list, &sdebug_host_list); in sdebug_add_adapter()
5592 sdbg_host->dev.bus = &pseudo_lld_bus; in sdebug_add_adapter()
5593 sdbg_host->dev.parent = pseudo_primary; in sdebug_add_adapter()
5594 sdbg_host->dev.release = &sdebug_release_adapter; in sdebug_add_adapter()
5595 dev_set_name(&sdbg_host->dev, "adapter%d", sdebug_add_host); in sdebug_add_adapter()
5597 error = device_register(&sdbg_host->dev); in sdebug_add_adapter()
5606 list_for_each_entry_safe(sdbg_devinfo, tmp, &sdbg_host->dev_info_list, in sdebug_add_adapter()
5608 list_del(&sdbg_devinfo->dev_list); in sdebug_add_adapter()
5624 list_del(&sdbg_host->host_list); in sdebug_remove_adapter()
5631 device_unregister(&sdbg_host->dev); in sdebug_remove_adapter()
5632 --sdebug_add_host; in sdebug_remove_adapter()
5641 devip = (struct sdebug_dev_info *)sdev->hostdata; in sdebug_change_qdepth()
5644 return -ENODEV; in sdebug_change_qdepth()
5646 num_in_q = atomic_read(&devip->num_in_q); in sdebug_change_qdepth()
5660 return sdev->queue_depth; in sdebug_change_qdepth()
5666 if (sdebug_every_nth < -1) in fake_timeout()
5667 sdebug_every_nth = -1; in fake_timeout()
5687 struct scsi_device *sdp = scp->device; in scsi_debug_queuecommand()
5691 u8 *cmd = scp->cmnd; in scsi_debug_queuecommand()
5709 len = scp->cmd_len; in scsi_debug_queuecommand()
5715 n += scnprintf(b + n, sb - n, "%02x ", in scsi_debug_queuecommand()
5719 blk_mq_unique_tag(scp->request), b); in scsi_debug_queuecommand()
5723 has_wlun_rl = (sdp->lun == SCSI_W_LUN_REPORT_LUNS); in scsi_debug_queuecommand()
5724 if (unlikely((sdp->lun >= sdebug_max_luns) && !has_wlun_rl)) in scsi_debug_queuecommand()
5729 devip = (struct sdebug_dev_info *)sdp->hostdata; in scsi_debug_queuecommand()
5735 na = oip->num_attached; in scsi_debug_queuecommand()
5736 r_pfp = oip->pfp; in scsi_debug_queuecommand()
5739 if (FF_SA & r_oip->flags) { in scsi_debug_queuecommand()
5740 if (F_SA_LOW & oip->flags) in scsi_debug_queuecommand()
5744 for (k = 0; k <= na; oip = r_oip->arrp + k++) { in scsi_debug_queuecommand()
5745 if (opcode == oip->opcode && sa == oip->sa) in scsi_debug_queuecommand()
5749 for (k = 0; k <= na; oip = r_oip->arrp + k++) { in scsi_debug_queuecommand()
5750 if (opcode == oip->opcode) in scsi_debug_queuecommand()
5755 if (F_SA_LOW & r_oip->flags) in scsi_debug_queuecommand()
5757 else if (F_SA_HIGH & r_oip->flags) in scsi_debug_queuecommand()
5764 flags = oip->flags; in scsi_debug_queuecommand()
5780 for (k = 1; k < oip->len_mask[0] && k < 16; ++k) { in scsi_debug_queuecommand()
5781 rem = ~oip->len_mask[k] & cmd[k]; in scsi_debug_queuecommand()
5783 for (j = 7; j >= 0; --j, rem <<= 1) { in scsi_debug_queuecommand()
5793 find_first_bit(devip->uas_bm, in scsi_debug_queuecommand()
5799 if (unlikely((F_M_ACCESS & flags) && atomic_read(&devip->stopped))) { in scsi_debug_queuecommand()
5814 if (likely(oip->pfp)) in scsi_debug_queuecommand()
5815 pfp = oip->pfp; /* calls a resp_* function */ in scsi_debug_queuecommand()
5865 .max_sectors = -1U,
5886 error = -ENODEV; in sdebug_driver_probe()
5897 hpnt->nr_hw_queues = submit_queues; in sdebug_driver_probe()
5899 sdbg_host->shost = hpnt; in sdebug_driver_probe()
5900 *((struct sdebug_host_info **)hpnt->hostdata) = sdbg_host; in sdebug_driver_probe()
5901 if ((hpnt->this_id >= 0) && (sdebug_num_tgts > hpnt->this_id)) in sdebug_driver_probe()
5902 hpnt->max_id = sdebug_num_tgts + 1; in sdebug_driver_probe()
5904 hpnt->max_id = sdebug_num_tgts; in sdebug_driver_probe()
5906 hpnt->max_lun = SCSI_W_LUN_REPORT_LUNS + 1; in sdebug_driver_probe()
5957 error = scsi_add_host(hpnt, &sdbg_host->dev); in sdebug_driver_probe()
5960 error = -ENODEV; in sdebug_driver_probe()
5977 return -ENODEV; in sdebug_driver_remove()
5980 scsi_remove_host(sdbg_host->shost); in sdebug_driver_remove()
5982 list_for_each_entry_safe(sdbg_devinfo, tmp, &sdbg_host->dev_info_list, in sdebug_driver_remove()
5984 list_del(&sdbg_devinfo->dev_list); in sdebug_driver_remove()
5988 scsi_host_put(sdbg_host->shost); in sdebug_driver_remove()