18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _SCSI_SCSI_DEVICE_H 38c2ecf20Sopenharmony_ci#define _SCSI_SCSI_DEVICE_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/list.h> 68c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 78c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 88c2ecf20Sopenharmony_ci#include <linux/blkdev.h> 98c2ecf20Sopenharmony_ci#include <scsi/scsi.h> 108c2ecf20Sopenharmony_ci#include <linux/atomic.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_cistruct device; 138c2ecf20Sopenharmony_cistruct request_queue; 148c2ecf20Sopenharmony_cistruct scsi_cmnd; 158c2ecf20Sopenharmony_cistruct scsi_lun; 168c2ecf20Sopenharmony_cistruct scsi_sense_hdr; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_citypedef __u64 __bitwise blist_flags_t; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define SCSI_SENSE_BUFFERSIZE 96 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistruct scsi_mode_data { 238c2ecf20Sopenharmony_ci __u32 length; 248c2ecf20Sopenharmony_ci __u16 block_descriptor_length; 258c2ecf20Sopenharmony_ci __u8 medium_type; 268c2ecf20Sopenharmony_ci __u8 device_specific; 278c2ecf20Sopenharmony_ci __u8 header_length; 288c2ecf20Sopenharmony_ci __u8 longlba:1; 298c2ecf20Sopenharmony_ci}; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci/* 328c2ecf20Sopenharmony_ci * sdev state: If you alter this, you also need to alter scsi_sysfs.c 338c2ecf20Sopenharmony_ci * (for the ascii descriptions) and the state model enforcer: 348c2ecf20Sopenharmony_ci * scsi_lib:scsi_device_set_state(). 358c2ecf20Sopenharmony_ci */ 368c2ecf20Sopenharmony_cienum scsi_device_state { 378c2ecf20Sopenharmony_ci SDEV_CREATED = 1, /* device created but not added to sysfs 388c2ecf20Sopenharmony_ci * Only internal commands allowed (for inq) */ 398c2ecf20Sopenharmony_ci SDEV_RUNNING, /* device properly configured 408c2ecf20Sopenharmony_ci * All commands allowed */ 418c2ecf20Sopenharmony_ci SDEV_CANCEL, /* beginning to delete device 428c2ecf20Sopenharmony_ci * Only error handler commands allowed */ 438c2ecf20Sopenharmony_ci SDEV_DEL, /* device deleted 448c2ecf20Sopenharmony_ci * no commands allowed */ 458c2ecf20Sopenharmony_ci SDEV_QUIESCE, /* Device quiescent. No block commands 468c2ecf20Sopenharmony_ci * will be accepted, only specials (which 478c2ecf20Sopenharmony_ci * originate in the mid-layer) */ 488c2ecf20Sopenharmony_ci SDEV_OFFLINE, /* Device offlined (by error handling or 498c2ecf20Sopenharmony_ci * user request */ 508c2ecf20Sopenharmony_ci SDEV_TRANSPORT_OFFLINE, /* Offlined by transport class error handler */ 518c2ecf20Sopenharmony_ci SDEV_BLOCK, /* Device blocked by scsi lld. No 528c2ecf20Sopenharmony_ci * scsi commands from user or midlayer 538c2ecf20Sopenharmony_ci * should be issued to the scsi 548c2ecf20Sopenharmony_ci * lld. */ 558c2ecf20Sopenharmony_ci SDEV_CREATED_BLOCK, /* same as above but for created devices */ 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cienum scsi_scan_mode { 598c2ecf20Sopenharmony_ci SCSI_SCAN_INITIAL = 0, 608c2ecf20Sopenharmony_ci SCSI_SCAN_RESCAN, 618c2ecf20Sopenharmony_ci SCSI_SCAN_MANUAL, 628c2ecf20Sopenharmony_ci}; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cienum scsi_device_event { 658c2ecf20Sopenharmony_ci SDEV_EVT_MEDIA_CHANGE = 1, /* media has changed */ 668c2ecf20Sopenharmony_ci SDEV_EVT_INQUIRY_CHANGE_REPORTED, /* 3F 03 UA reported */ 678c2ecf20Sopenharmony_ci SDEV_EVT_CAPACITY_CHANGE_REPORTED, /* 2A 09 UA reported */ 688c2ecf20Sopenharmony_ci SDEV_EVT_SOFT_THRESHOLD_REACHED_REPORTED, /* 38 07 UA reported */ 698c2ecf20Sopenharmony_ci SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED, /* 2A 01 UA reported */ 708c2ecf20Sopenharmony_ci SDEV_EVT_LUN_CHANGE_REPORTED, /* 3F 0E UA reported */ 718c2ecf20Sopenharmony_ci SDEV_EVT_ALUA_STATE_CHANGE_REPORTED, /* 2A 06 UA reported */ 728c2ecf20Sopenharmony_ci SDEV_EVT_POWER_ON_RESET_OCCURRED, /* 29 00 UA reported */ 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci SDEV_EVT_FIRST = SDEV_EVT_MEDIA_CHANGE, 758c2ecf20Sopenharmony_ci SDEV_EVT_LAST = SDEV_EVT_POWER_ON_RESET_OCCURRED, 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci SDEV_EVT_MAXBITS = SDEV_EVT_LAST + 1 788c2ecf20Sopenharmony_ci}; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_cistruct scsi_event { 818c2ecf20Sopenharmony_ci enum scsi_device_event evt_type; 828c2ecf20Sopenharmony_ci struct list_head node; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci /* put union of data structures, for non-simple event types, 858c2ecf20Sopenharmony_ci * here 868c2ecf20Sopenharmony_ci */ 878c2ecf20Sopenharmony_ci}; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci/** 908c2ecf20Sopenharmony_ci * struct scsi_vpd - SCSI Vital Product Data 918c2ecf20Sopenharmony_ci * @rcu: For kfree_rcu(). 928c2ecf20Sopenharmony_ci * @len: Length in bytes of @data. 938c2ecf20Sopenharmony_ci * @data: VPD data as defined in various T10 SCSI standard documents. 948c2ecf20Sopenharmony_ci */ 958c2ecf20Sopenharmony_cistruct scsi_vpd { 968c2ecf20Sopenharmony_ci struct rcu_head rcu; 978c2ecf20Sopenharmony_ci int len; 988c2ecf20Sopenharmony_ci unsigned char data[]; 998c2ecf20Sopenharmony_ci}; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_cistruct scsi_device { 1028c2ecf20Sopenharmony_ci struct Scsi_Host *host; 1038c2ecf20Sopenharmony_ci struct request_queue *request_queue; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci /* the next two are protected by the host->host_lock */ 1068c2ecf20Sopenharmony_ci struct list_head siblings; /* list of all devices on this host */ 1078c2ecf20Sopenharmony_ci struct list_head same_target_siblings; /* just the devices sharing same target id */ 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci atomic_t device_busy; /* commands actually active on LLDD */ 1108c2ecf20Sopenharmony_ci atomic_t device_blocked; /* Device returned QUEUE_FULL. */ 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci atomic_t restarts; 1138c2ecf20Sopenharmony_ci spinlock_t list_lock; 1148c2ecf20Sopenharmony_ci struct list_head starved_entry; 1158c2ecf20Sopenharmony_ci unsigned short queue_depth; /* How deep of a queue we want */ 1168c2ecf20Sopenharmony_ci unsigned short max_queue_depth; /* max queue depth */ 1178c2ecf20Sopenharmony_ci unsigned short last_queue_full_depth; /* These two are used by */ 1188c2ecf20Sopenharmony_ci unsigned short last_queue_full_count; /* scsi_track_queue_full() */ 1198c2ecf20Sopenharmony_ci unsigned long last_queue_full_time; /* last queue full time */ 1208c2ecf20Sopenharmony_ci unsigned long queue_ramp_up_period; /* ramp up period in jiffies */ 1218c2ecf20Sopenharmony_ci#define SCSI_DEFAULT_RAMP_UP_PERIOD (120 * HZ) 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci unsigned long last_queue_ramp_up; /* last queue ramp up time */ 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci unsigned int id, channel; 1268c2ecf20Sopenharmony_ci u64 lun; 1278c2ecf20Sopenharmony_ci unsigned int manufacturer; /* Manufacturer of device, for using 1288c2ecf20Sopenharmony_ci * vendor-specific cmd's */ 1298c2ecf20Sopenharmony_ci unsigned sector_size; /* size in bytes */ 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci void *hostdata; /* available to low-level driver */ 1328c2ecf20Sopenharmony_ci unsigned char type; 1338c2ecf20Sopenharmony_ci char scsi_level; 1348c2ecf20Sopenharmony_ci char inq_periph_qual; /* PQ from INQUIRY data */ 1358c2ecf20Sopenharmony_ci struct mutex inquiry_mutex; 1368c2ecf20Sopenharmony_ci unsigned char inquiry_len; /* valid bytes in 'inquiry' */ 1378c2ecf20Sopenharmony_ci unsigned char * inquiry; /* INQUIRY response data */ 1388c2ecf20Sopenharmony_ci const char * vendor; /* [back_compat] point into 'inquiry' ... */ 1398c2ecf20Sopenharmony_ci const char * model; /* ... after scan; point to static string */ 1408c2ecf20Sopenharmony_ci const char * rev; /* ... "nullnullnullnull" before scan */ 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci#define SCSI_VPD_PG_LEN 255 1438c2ecf20Sopenharmony_ci struct scsi_vpd __rcu *vpd_pg0; 1448c2ecf20Sopenharmony_ci struct scsi_vpd __rcu *vpd_pg83; 1458c2ecf20Sopenharmony_ci struct scsi_vpd __rcu *vpd_pg80; 1468c2ecf20Sopenharmony_ci struct scsi_vpd __rcu *vpd_pg89; 1478c2ecf20Sopenharmony_ci unsigned char current_tag; /* current tag */ 1488c2ecf20Sopenharmony_ci struct scsi_target *sdev_target; /* used only for single_lun */ 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci blist_flags_t sdev_bflags; /* black/white flags as also found in 1518c2ecf20Sopenharmony_ci * scsi_devinfo.[hc]. For now used only to 1528c2ecf20Sopenharmony_ci * pass settings from slave_alloc to scsi 1538c2ecf20Sopenharmony_ci * core. */ 1548c2ecf20Sopenharmony_ci unsigned int eh_timeout; /* Error handling timeout */ 1558c2ecf20Sopenharmony_ci unsigned removable:1; 1568c2ecf20Sopenharmony_ci unsigned changed:1; /* Data invalid due to media change */ 1578c2ecf20Sopenharmony_ci unsigned busy:1; /* Used to prevent races */ 1588c2ecf20Sopenharmony_ci unsigned lockable:1; /* Able to prevent media removal */ 1598c2ecf20Sopenharmony_ci unsigned locked:1; /* Media removal disabled */ 1608c2ecf20Sopenharmony_ci unsigned borken:1; /* Tell the Seagate driver to be 1618c2ecf20Sopenharmony_ci * painfully slow on this device */ 1628c2ecf20Sopenharmony_ci unsigned disconnect:1; /* can disconnect */ 1638c2ecf20Sopenharmony_ci unsigned soft_reset:1; /* Uses soft reset option */ 1648c2ecf20Sopenharmony_ci unsigned sdtr:1; /* Device supports SDTR messages */ 1658c2ecf20Sopenharmony_ci unsigned wdtr:1; /* Device supports WDTR messages */ 1668c2ecf20Sopenharmony_ci unsigned ppr:1; /* Device supports PPR messages */ 1678c2ecf20Sopenharmony_ci unsigned tagged_supported:1; /* Supports SCSI-II tagged queuing */ 1688c2ecf20Sopenharmony_ci unsigned simple_tags:1; /* simple queue tag messages are enabled */ 1698c2ecf20Sopenharmony_ci unsigned was_reset:1; /* There was a bus reset on the bus for 1708c2ecf20Sopenharmony_ci * this device */ 1718c2ecf20Sopenharmony_ci unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN 1728c2ecf20Sopenharmony_ci * because we did a bus reset. */ 1738c2ecf20Sopenharmony_ci unsigned use_10_for_rw:1; /* first try 10-byte read / write */ 1748c2ecf20Sopenharmony_ci unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ 1758c2ecf20Sopenharmony_ci unsigned set_dbd_for_ms:1; /* Set "DBD" field in mode sense */ 1768c2ecf20Sopenharmony_ci unsigned no_report_opcodes:1; /* no REPORT SUPPORTED OPERATION CODES */ 1778c2ecf20Sopenharmony_ci unsigned no_write_same:1; /* no WRITE SAME command */ 1788c2ecf20Sopenharmony_ci unsigned use_16_for_rw:1; /* Use read/write(16) over read/write(10) */ 1798c2ecf20Sopenharmony_ci unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */ 1808c2ecf20Sopenharmony_ci unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */ 1818c2ecf20Sopenharmony_ci unsigned skip_vpd_pages:1; /* do not read VPD pages */ 1828c2ecf20Sopenharmony_ci unsigned try_vpd_pages:1; /* attempt to read VPD pages */ 1838c2ecf20Sopenharmony_ci unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */ 1848c2ecf20Sopenharmony_ci unsigned no_start_on_add:1; /* do not issue start on add */ 1858c2ecf20Sopenharmony_ci unsigned allow_restart:1; /* issue START_UNIT in error handler */ 1868c2ecf20Sopenharmony_ci unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */ 1878c2ecf20Sopenharmony_ci unsigned start_stop_pwr_cond:1; /* Set power cond. in START_STOP_UNIT */ 1888c2ecf20Sopenharmony_ci unsigned no_uld_attach:1; /* disable connecting to upper level drivers */ 1898c2ecf20Sopenharmony_ci unsigned select_no_atn:1; 1908c2ecf20Sopenharmony_ci unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */ 1918c2ecf20Sopenharmony_ci unsigned guess_capacity:1; /* READ_CAPACITY might be too high by 1 */ 1928c2ecf20Sopenharmony_ci unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */ 1938c2ecf20Sopenharmony_ci unsigned last_sector_bug:1; /* do not use multisector accesses on 1948c2ecf20Sopenharmony_ci SD_LAST_BUGGY_SECTORS */ 1958c2ecf20Sopenharmony_ci unsigned no_read_disc_info:1; /* Avoid READ_DISC_INFO cmds */ 1968c2ecf20Sopenharmony_ci unsigned no_read_capacity_16:1; /* Avoid READ_CAPACITY_16 cmds */ 1978c2ecf20Sopenharmony_ci unsigned try_rc_10_first:1; /* Try READ_CAPACACITY_10 first */ 1988c2ecf20Sopenharmony_ci unsigned security_supported:1; /* Supports Security Protocols */ 1998c2ecf20Sopenharmony_ci unsigned is_visible:1; /* is the device visible in sysfs */ 2008c2ecf20Sopenharmony_ci unsigned wce_default_on:1; /* Cache is ON by default */ 2018c2ecf20Sopenharmony_ci unsigned no_dif:1; /* T10 PI (DIF) should be disabled */ 2028c2ecf20Sopenharmony_ci unsigned broken_fua:1; /* Don't set FUA bit */ 2038c2ecf20Sopenharmony_ci unsigned lun_in_cdb:1; /* Store LUN bits in CDB[1] */ 2048c2ecf20Sopenharmony_ci unsigned unmap_limit_for_ws:1; /* Use the UNMAP limit for WRITE SAME */ 2058c2ecf20Sopenharmony_ci unsigned rpm_autosuspend:1; /* Enable runtime autosuspend at device 2068c2ecf20Sopenharmony_ci * creation time */ 2078c2ecf20Sopenharmony_ci unsigned queue_stopped:1; /* request queue is quiesced */ 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci bool offline_already; /* Device offline message logged */ 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci atomic_t disk_events_disable_depth; /* disable depth for disk events */ 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */ 2148c2ecf20Sopenharmony_ci DECLARE_BITMAP(pending_events, SDEV_EVT_MAXBITS); /* pending events */ 2158c2ecf20Sopenharmony_ci struct list_head event_list; /* asserted events */ 2168c2ecf20Sopenharmony_ci struct work_struct event_work; 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci unsigned int max_device_blocked; /* what device_blocked counts down from */ 2198c2ecf20Sopenharmony_ci#define SCSI_DEFAULT_DEVICE_BLOCKED 3 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci atomic_t iorequest_cnt; 2228c2ecf20Sopenharmony_ci atomic_t iodone_cnt; 2238c2ecf20Sopenharmony_ci atomic_t ioerr_cnt; 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci struct device sdev_gendev, 2268c2ecf20Sopenharmony_ci sdev_dev; 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci struct execute_work ew; /* used to get process context on put */ 2298c2ecf20Sopenharmony_ci struct work_struct requeue_work; 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci struct scsi_device_handler *handler; 2328c2ecf20Sopenharmony_ci void *handler_data; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci size_t dma_drain_len; 2358c2ecf20Sopenharmony_ci void *dma_drain_buf; 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci unsigned char access_state; 2388c2ecf20Sopenharmony_ci struct mutex state_mutex; 2398c2ecf20Sopenharmony_ci enum scsi_device_state sdev_state; 2408c2ecf20Sopenharmony_ci struct task_struct *quiesced_by; 2418c2ecf20Sopenharmony_ci unsigned long sdev_data[]; 2428c2ecf20Sopenharmony_ci} __attribute__((aligned(sizeof(unsigned long)))); 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci#define to_scsi_device(d) \ 2458c2ecf20Sopenharmony_ci container_of(d, struct scsi_device, sdev_gendev) 2468c2ecf20Sopenharmony_ci#define class_to_sdev(d) \ 2478c2ecf20Sopenharmony_ci container_of(d, struct scsi_device, sdev_dev) 2488c2ecf20Sopenharmony_ci#define transport_class_to_sdev(class_dev) \ 2498c2ecf20Sopenharmony_ci to_scsi_device(class_dev->parent) 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci#define sdev_dbg(sdev, fmt, a...) \ 2528c2ecf20Sopenharmony_ci dev_dbg(&(sdev)->sdev_gendev, fmt, ##a) 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci/* 2558c2ecf20Sopenharmony_ci * like scmd_printk, but the device name is passed in 2568c2ecf20Sopenharmony_ci * as a string pointer 2578c2ecf20Sopenharmony_ci */ 2588c2ecf20Sopenharmony_ci__printf(4, 5) void 2598c2ecf20Sopenharmony_cisdev_prefix_printk(const char *, const struct scsi_device *, const char *, 2608c2ecf20Sopenharmony_ci const char *, ...); 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci#define sdev_printk(l, sdev, fmt, a...) \ 2638c2ecf20Sopenharmony_ci sdev_prefix_printk(l, sdev, NULL, fmt, ##a) 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci__printf(3, 4) void 2668c2ecf20Sopenharmony_ciscmd_printk(const char *, const struct scsi_cmnd *, const char *, ...); 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci#define scmd_dbg(scmd, fmt, a...) \ 2698c2ecf20Sopenharmony_ci do { \ 2708c2ecf20Sopenharmony_ci if ((scmd)->request->rq_disk) \ 2718c2ecf20Sopenharmony_ci sdev_dbg((scmd)->device, "[%s] " fmt, \ 2728c2ecf20Sopenharmony_ci (scmd)->request->rq_disk->disk_name, ##a);\ 2738c2ecf20Sopenharmony_ci else \ 2748c2ecf20Sopenharmony_ci sdev_dbg((scmd)->device, fmt, ##a); \ 2758c2ecf20Sopenharmony_ci } while (0) 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_cienum scsi_target_state { 2788c2ecf20Sopenharmony_ci STARGET_CREATED = 1, 2798c2ecf20Sopenharmony_ci STARGET_RUNNING, 2808c2ecf20Sopenharmony_ci STARGET_REMOVE, 2818c2ecf20Sopenharmony_ci STARGET_CREATED_REMOVE, 2828c2ecf20Sopenharmony_ci STARGET_DEL, 2838c2ecf20Sopenharmony_ci}; 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci/* 2868c2ecf20Sopenharmony_ci * scsi_target: representation of a scsi target, for now, this is only 2878c2ecf20Sopenharmony_ci * used for single_lun devices. If no one has active IO to the target, 2888c2ecf20Sopenharmony_ci * starget_sdev_user is NULL, else it points to the active sdev. 2898c2ecf20Sopenharmony_ci */ 2908c2ecf20Sopenharmony_cistruct scsi_target { 2918c2ecf20Sopenharmony_ci struct scsi_device *starget_sdev_user; 2928c2ecf20Sopenharmony_ci struct list_head siblings; 2938c2ecf20Sopenharmony_ci struct list_head devices; 2948c2ecf20Sopenharmony_ci struct device dev; 2958c2ecf20Sopenharmony_ci struct kref reap_ref; /* last put renders target invisible */ 2968c2ecf20Sopenharmony_ci unsigned int channel; 2978c2ecf20Sopenharmony_ci unsigned int id; /* target id ... replace 2988c2ecf20Sopenharmony_ci * scsi_device.id eventually */ 2998c2ecf20Sopenharmony_ci unsigned int create:1; /* signal that it needs to be added */ 3008c2ecf20Sopenharmony_ci unsigned int single_lun:1; /* Indicates we should only 3018c2ecf20Sopenharmony_ci * allow I/O to one of the luns 3028c2ecf20Sopenharmony_ci * for the device at a time. */ 3038c2ecf20Sopenharmony_ci unsigned int pdt_1f_for_no_lun:1; /* PDT = 0x1f 3048c2ecf20Sopenharmony_ci * means no lun present. */ 3058c2ecf20Sopenharmony_ci unsigned int no_report_luns:1; /* Don't use 3068c2ecf20Sopenharmony_ci * REPORT LUNS for scanning. */ 3078c2ecf20Sopenharmony_ci unsigned int expecting_lun_change:1; /* A device has reported 3088c2ecf20Sopenharmony_ci * a 3F/0E UA, other devices on 3098c2ecf20Sopenharmony_ci * the same target will also. */ 3108c2ecf20Sopenharmony_ci /* commands actually active on LLD. */ 3118c2ecf20Sopenharmony_ci atomic_t target_busy; 3128c2ecf20Sopenharmony_ci atomic_t target_blocked; 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci /* 3158c2ecf20Sopenharmony_ci * LLDs should set this in the slave_alloc host template callout. 3168c2ecf20Sopenharmony_ci * If set to zero then there is not limit. 3178c2ecf20Sopenharmony_ci */ 3188c2ecf20Sopenharmony_ci unsigned int can_queue; 3198c2ecf20Sopenharmony_ci unsigned int max_target_blocked; 3208c2ecf20Sopenharmony_ci#define SCSI_DEFAULT_TARGET_BLOCKED 3 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci char scsi_level; 3238c2ecf20Sopenharmony_ci enum scsi_target_state state; 3248c2ecf20Sopenharmony_ci void *hostdata; /* available to low-level driver */ 3258c2ecf20Sopenharmony_ci unsigned long starget_data[]; /* for the transport */ 3268c2ecf20Sopenharmony_ci /* starget_data must be the last element!!!! */ 3278c2ecf20Sopenharmony_ci} __attribute__((aligned(sizeof(unsigned long)))); 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci#define to_scsi_target(d) container_of(d, struct scsi_target, dev) 3308c2ecf20Sopenharmony_cistatic inline struct scsi_target *scsi_target(struct scsi_device *sdev) 3318c2ecf20Sopenharmony_ci{ 3328c2ecf20Sopenharmony_ci return to_scsi_target(sdev->sdev_gendev.parent); 3338c2ecf20Sopenharmony_ci} 3348c2ecf20Sopenharmony_ci#define transport_class_to_starget(class_dev) \ 3358c2ecf20Sopenharmony_ci to_scsi_target(class_dev->parent) 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci#define starget_printk(prefix, starget, fmt, a...) \ 3388c2ecf20Sopenharmony_ci dev_printk(prefix, &(starget)->dev, fmt, ##a) 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ciextern struct scsi_device *__scsi_add_device(struct Scsi_Host *, 3418c2ecf20Sopenharmony_ci uint, uint, u64, void *hostdata); 3428c2ecf20Sopenharmony_ciextern int scsi_add_device(struct Scsi_Host *host, uint channel, 3438c2ecf20Sopenharmony_ci uint target, u64 lun); 3448c2ecf20Sopenharmony_ciextern int scsi_register_device_handler(struct scsi_device_handler *scsi_dh); 3458c2ecf20Sopenharmony_ciextern void scsi_remove_device(struct scsi_device *); 3468c2ecf20Sopenharmony_ciextern int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh); 3478c2ecf20Sopenharmony_civoid scsi_attach_vpd(struct scsi_device *sdev); 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ciextern struct scsi_device *scsi_device_from_queue(struct request_queue *q); 3508c2ecf20Sopenharmony_ciextern int __must_check scsi_device_get(struct scsi_device *); 3518c2ecf20Sopenharmony_ciextern void scsi_device_put(struct scsi_device *); 3528c2ecf20Sopenharmony_ciextern struct scsi_device *scsi_device_lookup(struct Scsi_Host *, 3538c2ecf20Sopenharmony_ci uint, uint, u64); 3548c2ecf20Sopenharmony_ciextern struct scsi_device *__scsi_device_lookup(struct Scsi_Host *, 3558c2ecf20Sopenharmony_ci uint, uint, u64); 3568c2ecf20Sopenharmony_ciextern struct scsi_device *scsi_device_lookup_by_target(struct scsi_target *, 3578c2ecf20Sopenharmony_ci u64); 3588c2ecf20Sopenharmony_ciextern struct scsi_device *__scsi_device_lookup_by_target(struct scsi_target *, 3598c2ecf20Sopenharmony_ci u64); 3608c2ecf20Sopenharmony_ciextern void starget_for_each_device(struct scsi_target *, void *, 3618c2ecf20Sopenharmony_ci void (*fn)(struct scsi_device *, void *)); 3628c2ecf20Sopenharmony_ciextern void __starget_for_each_device(struct scsi_target *, void *, 3638c2ecf20Sopenharmony_ci void (*fn)(struct scsi_device *, 3648c2ecf20Sopenharmony_ci void *)); 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci/* only exposed to implement shost_for_each_device */ 3678c2ecf20Sopenharmony_ciextern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *, 3688c2ecf20Sopenharmony_ci struct scsi_device *); 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_ci/** 3718c2ecf20Sopenharmony_ci * shost_for_each_device - iterate over all devices of a host 3728c2ecf20Sopenharmony_ci * @sdev: the &struct scsi_device to use as a cursor 3738c2ecf20Sopenharmony_ci * @shost: the &struct scsi_host to iterate over 3748c2ecf20Sopenharmony_ci * 3758c2ecf20Sopenharmony_ci * Iterator that returns each device attached to @shost. This loop 3768c2ecf20Sopenharmony_ci * takes a reference on each device and releases it at the end. If 3778c2ecf20Sopenharmony_ci * you break out of the loop, you must call scsi_device_put(sdev). 3788c2ecf20Sopenharmony_ci */ 3798c2ecf20Sopenharmony_ci#define shost_for_each_device(sdev, shost) \ 3808c2ecf20Sopenharmony_ci for ((sdev) = __scsi_iterate_devices((shost), NULL); \ 3818c2ecf20Sopenharmony_ci (sdev); \ 3828c2ecf20Sopenharmony_ci (sdev) = __scsi_iterate_devices((shost), (sdev))) 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci/** 3858c2ecf20Sopenharmony_ci * __shost_for_each_device - iterate over all devices of a host (UNLOCKED) 3868c2ecf20Sopenharmony_ci * @sdev: the &struct scsi_device to use as a cursor 3878c2ecf20Sopenharmony_ci * @shost: the &struct scsi_host to iterate over 3888c2ecf20Sopenharmony_ci * 3898c2ecf20Sopenharmony_ci * Iterator that returns each device attached to @shost. It does _not_ 3908c2ecf20Sopenharmony_ci * take a reference on the scsi_device, so the whole loop must be 3918c2ecf20Sopenharmony_ci * protected by shost->host_lock. 3928c2ecf20Sopenharmony_ci * 3938c2ecf20Sopenharmony_ci * Note: The only reason to use this is because you need to access the 3948c2ecf20Sopenharmony_ci * device list in interrupt context. Otherwise you really want to use 3958c2ecf20Sopenharmony_ci * shost_for_each_device instead. 3968c2ecf20Sopenharmony_ci */ 3978c2ecf20Sopenharmony_ci#define __shost_for_each_device(sdev, shost) \ 3988c2ecf20Sopenharmony_ci list_for_each_entry((sdev), &((shost)->__devices), siblings) 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ciextern int scsi_change_queue_depth(struct scsi_device *, int); 4018c2ecf20Sopenharmony_ciextern int scsi_track_queue_full(struct scsi_device *, int); 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_ciextern int scsi_set_medium_removal(struct scsi_device *, char); 4048c2ecf20Sopenharmony_ci 4058c2ecf20Sopenharmony_ciextern int scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, 4068c2ecf20Sopenharmony_ci unsigned char *buffer, int len, int timeout, 4078c2ecf20Sopenharmony_ci int retries, struct scsi_mode_data *data, 4088c2ecf20Sopenharmony_ci struct scsi_sense_hdr *); 4098c2ecf20Sopenharmony_ciextern int scsi_mode_select(struct scsi_device *sdev, int pf, int sp, 4108c2ecf20Sopenharmony_ci int modepage, unsigned char *buffer, int len, 4118c2ecf20Sopenharmony_ci int timeout, int retries, 4128c2ecf20Sopenharmony_ci struct scsi_mode_data *data, 4138c2ecf20Sopenharmony_ci struct scsi_sense_hdr *); 4148c2ecf20Sopenharmony_ciextern int scsi_test_unit_ready(struct scsi_device *sdev, int timeout, 4158c2ecf20Sopenharmony_ci int retries, struct scsi_sense_hdr *sshdr); 4168c2ecf20Sopenharmony_ciextern int scsi_get_vpd_page(struct scsi_device *, u8 page, unsigned char *buf, 4178c2ecf20Sopenharmony_ci int buf_len); 4188c2ecf20Sopenharmony_ciextern int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer, 4198c2ecf20Sopenharmony_ci unsigned int len, unsigned char opcode); 4208c2ecf20Sopenharmony_ciextern int scsi_device_set_state(struct scsi_device *sdev, 4218c2ecf20Sopenharmony_ci enum scsi_device_state state); 4228c2ecf20Sopenharmony_ciextern struct scsi_event *sdev_evt_alloc(enum scsi_device_event evt_type, 4238c2ecf20Sopenharmony_ci gfp_t gfpflags); 4248c2ecf20Sopenharmony_ciextern void sdev_evt_send(struct scsi_device *sdev, struct scsi_event *evt); 4258c2ecf20Sopenharmony_ciextern void sdev_evt_send_simple(struct scsi_device *sdev, 4268c2ecf20Sopenharmony_ci enum scsi_device_event evt_type, gfp_t gfpflags); 4278c2ecf20Sopenharmony_ciextern int scsi_device_quiesce(struct scsi_device *sdev); 4288c2ecf20Sopenharmony_ciextern void scsi_device_resume(struct scsi_device *sdev); 4298c2ecf20Sopenharmony_ciextern void scsi_target_quiesce(struct scsi_target *); 4308c2ecf20Sopenharmony_ciextern void scsi_target_resume(struct scsi_target *); 4318c2ecf20Sopenharmony_ciextern void scsi_scan_target(struct device *parent, unsigned int channel, 4328c2ecf20Sopenharmony_ci unsigned int id, u64 lun, 4338c2ecf20Sopenharmony_ci enum scsi_scan_mode rescan); 4348c2ecf20Sopenharmony_ciextern void scsi_target_reap(struct scsi_target *); 4358c2ecf20Sopenharmony_ciextern void scsi_target_block(struct device *); 4368c2ecf20Sopenharmony_ciextern void scsi_target_unblock(struct device *, enum scsi_device_state); 4378c2ecf20Sopenharmony_ciextern void scsi_remove_target(struct device *); 4388c2ecf20Sopenharmony_ciextern const char *scsi_device_state_name(enum scsi_device_state); 4398c2ecf20Sopenharmony_ciextern int scsi_is_sdev_device(const struct device *); 4408c2ecf20Sopenharmony_ciextern int scsi_is_target_device(const struct device *); 4418c2ecf20Sopenharmony_ciextern void scsi_sanitize_inquiry_string(unsigned char *s, int len); 4428c2ecf20Sopenharmony_ciextern int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, 4438c2ecf20Sopenharmony_ci int data_direction, void *buffer, unsigned bufflen, 4448c2ecf20Sopenharmony_ci unsigned char *sense, struct scsi_sense_hdr *sshdr, 4458c2ecf20Sopenharmony_ci int timeout, int retries, u64 flags, 4468c2ecf20Sopenharmony_ci req_flags_t rq_flags, int *resid); 4478c2ecf20Sopenharmony_ci/* Make sure any sense buffer is the correct size. */ 4488c2ecf20Sopenharmony_ci#define scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ 4498c2ecf20Sopenharmony_ci sshdr, timeout, retries, flags, rq_flags, resid) \ 4508c2ecf20Sopenharmony_ci({ \ 4518c2ecf20Sopenharmony_ci BUILD_BUG_ON((sense) != NULL && \ 4528c2ecf20Sopenharmony_ci sizeof(sense) != SCSI_SENSE_BUFFERSIZE); \ 4538c2ecf20Sopenharmony_ci __scsi_execute(sdev, cmd, data_direction, buffer, bufflen, \ 4548c2ecf20Sopenharmony_ci sense, sshdr, timeout, retries, flags, rq_flags, \ 4558c2ecf20Sopenharmony_ci resid); \ 4568c2ecf20Sopenharmony_ci}) 4578c2ecf20Sopenharmony_cistatic inline int scsi_execute_req(struct scsi_device *sdev, 4588c2ecf20Sopenharmony_ci const unsigned char *cmd, int data_direction, void *buffer, 4598c2ecf20Sopenharmony_ci unsigned bufflen, struct scsi_sense_hdr *sshdr, int timeout, 4608c2ecf20Sopenharmony_ci int retries, int *resid) 4618c2ecf20Sopenharmony_ci{ 4628c2ecf20Sopenharmony_ci return scsi_execute(sdev, cmd, data_direction, buffer, 4638c2ecf20Sopenharmony_ci bufflen, NULL, sshdr, timeout, retries, 0, 0, resid); 4648c2ecf20Sopenharmony_ci} 4658c2ecf20Sopenharmony_ciextern void sdev_disable_disk_events(struct scsi_device *sdev); 4668c2ecf20Sopenharmony_ciextern void sdev_enable_disk_events(struct scsi_device *sdev); 4678c2ecf20Sopenharmony_ciextern int scsi_vpd_lun_id(struct scsi_device *, char *, size_t); 4688c2ecf20Sopenharmony_ciextern int scsi_vpd_tpg_id(struct scsi_device *, int *); 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci#ifdef CONFIG_PM 4718c2ecf20Sopenharmony_ciextern int scsi_autopm_get_device(struct scsi_device *); 4728c2ecf20Sopenharmony_ciextern void scsi_autopm_put_device(struct scsi_device *); 4738c2ecf20Sopenharmony_ci#else 4748c2ecf20Sopenharmony_cistatic inline int scsi_autopm_get_device(struct scsi_device *d) { return 0; } 4758c2ecf20Sopenharmony_cistatic inline void scsi_autopm_put_device(struct scsi_device *d) {} 4768c2ecf20Sopenharmony_ci#endif /* CONFIG_PM */ 4778c2ecf20Sopenharmony_ci 4788c2ecf20Sopenharmony_cistatic inline int __must_check scsi_device_reprobe(struct scsi_device *sdev) 4798c2ecf20Sopenharmony_ci{ 4808c2ecf20Sopenharmony_ci return device_reprobe(&sdev->sdev_gendev); 4818c2ecf20Sopenharmony_ci} 4828c2ecf20Sopenharmony_ci 4838c2ecf20Sopenharmony_cistatic inline unsigned int sdev_channel(struct scsi_device *sdev) 4848c2ecf20Sopenharmony_ci{ 4858c2ecf20Sopenharmony_ci return sdev->channel; 4868c2ecf20Sopenharmony_ci} 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_cistatic inline unsigned int sdev_id(struct scsi_device *sdev) 4898c2ecf20Sopenharmony_ci{ 4908c2ecf20Sopenharmony_ci return sdev->id; 4918c2ecf20Sopenharmony_ci} 4928c2ecf20Sopenharmony_ci 4938c2ecf20Sopenharmony_ci#define scmd_id(scmd) sdev_id((scmd)->device) 4948c2ecf20Sopenharmony_ci#define scmd_channel(scmd) sdev_channel((scmd)->device) 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci/* 4978c2ecf20Sopenharmony_ci * checks for positions of the SCSI state machine 4988c2ecf20Sopenharmony_ci */ 4998c2ecf20Sopenharmony_cistatic inline int scsi_device_online(struct scsi_device *sdev) 5008c2ecf20Sopenharmony_ci{ 5018c2ecf20Sopenharmony_ci return (sdev->sdev_state != SDEV_OFFLINE && 5028c2ecf20Sopenharmony_ci sdev->sdev_state != SDEV_TRANSPORT_OFFLINE && 5038c2ecf20Sopenharmony_ci sdev->sdev_state != SDEV_DEL); 5048c2ecf20Sopenharmony_ci} 5058c2ecf20Sopenharmony_cistatic inline int scsi_device_blocked(struct scsi_device *sdev) 5068c2ecf20Sopenharmony_ci{ 5078c2ecf20Sopenharmony_ci return sdev->sdev_state == SDEV_BLOCK || 5088c2ecf20Sopenharmony_ci sdev->sdev_state == SDEV_CREATED_BLOCK; 5098c2ecf20Sopenharmony_ci} 5108c2ecf20Sopenharmony_cistatic inline int scsi_device_created(struct scsi_device *sdev) 5118c2ecf20Sopenharmony_ci{ 5128c2ecf20Sopenharmony_ci return sdev->sdev_state == SDEV_CREATED || 5138c2ecf20Sopenharmony_ci sdev->sdev_state == SDEV_CREATED_BLOCK; 5148c2ecf20Sopenharmony_ci} 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ciint scsi_internal_device_block_nowait(struct scsi_device *sdev); 5178c2ecf20Sopenharmony_ciint scsi_internal_device_unblock_nowait(struct scsi_device *sdev, 5188c2ecf20Sopenharmony_ci enum scsi_device_state new_state); 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci/* accessor functions for the SCSI parameters */ 5218c2ecf20Sopenharmony_cistatic inline int scsi_device_sync(struct scsi_device *sdev) 5228c2ecf20Sopenharmony_ci{ 5238c2ecf20Sopenharmony_ci return sdev->sdtr; 5248c2ecf20Sopenharmony_ci} 5258c2ecf20Sopenharmony_cistatic inline int scsi_device_wide(struct scsi_device *sdev) 5268c2ecf20Sopenharmony_ci{ 5278c2ecf20Sopenharmony_ci return sdev->wdtr; 5288c2ecf20Sopenharmony_ci} 5298c2ecf20Sopenharmony_cistatic inline int scsi_device_dt(struct scsi_device *sdev) 5308c2ecf20Sopenharmony_ci{ 5318c2ecf20Sopenharmony_ci return sdev->ppr; 5328c2ecf20Sopenharmony_ci} 5338c2ecf20Sopenharmony_cistatic inline int scsi_device_dt_only(struct scsi_device *sdev) 5348c2ecf20Sopenharmony_ci{ 5358c2ecf20Sopenharmony_ci if (sdev->inquiry_len < 57) 5368c2ecf20Sopenharmony_ci return 0; 5378c2ecf20Sopenharmony_ci return (sdev->inquiry[56] & 0x0c) == 0x04; 5388c2ecf20Sopenharmony_ci} 5398c2ecf20Sopenharmony_cistatic inline int scsi_device_ius(struct scsi_device *sdev) 5408c2ecf20Sopenharmony_ci{ 5418c2ecf20Sopenharmony_ci if (sdev->inquiry_len < 57) 5428c2ecf20Sopenharmony_ci return 0; 5438c2ecf20Sopenharmony_ci return sdev->inquiry[56] & 0x01; 5448c2ecf20Sopenharmony_ci} 5458c2ecf20Sopenharmony_cistatic inline int scsi_device_qas(struct scsi_device *sdev) 5468c2ecf20Sopenharmony_ci{ 5478c2ecf20Sopenharmony_ci if (sdev->inquiry_len < 57) 5488c2ecf20Sopenharmony_ci return 0; 5498c2ecf20Sopenharmony_ci return sdev->inquiry[56] & 0x02; 5508c2ecf20Sopenharmony_ci} 5518c2ecf20Sopenharmony_cistatic inline int scsi_device_enclosure(struct scsi_device *sdev) 5528c2ecf20Sopenharmony_ci{ 5538c2ecf20Sopenharmony_ci return sdev->inquiry ? (sdev->inquiry[6] & (1<<6)) : 1; 5548c2ecf20Sopenharmony_ci} 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_cistatic inline int scsi_device_protection(struct scsi_device *sdev) 5578c2ecf20Sopenharmony_ci{ 5588c2ecf20Sopenharmony_ci if (sdev->no_dif) 5598c2ecf20Sopenharmony_ci return 0; 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ci return sdev->scsi_level > SCSI_2 && sdev->inquiry[5] & (1<<0); 5628c2ecf20Sopenharmony_ci} 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_cistatic inline int scsi_device_tpgs(struct scsi_device *sdev) 5658c2ecf20Sopenharmony_ci{ 5668c2ecf20Sopenharmony_ci return sdev->inquiry ? (sdev->inquiry[5] >> 4) & 0x3 : 0; 5678c2ecf20Sopenharmony_ci} 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ci/** 5708c2ecf20Sopenharmony_ci * scsi_device_supports_vpd - test if a device supports VPD pages 5718c2ecf20Sopenharmony_ci * @sdev: the &struct scsi_device to test 5728c2ecf20Sopenharmony_ci * 5738c2ecf20Sopenharmony_ci * If the 'try_vpd_pages' flag is set it takes precedence. 5748c2ecf20Sopenharmony_ci * Otherwise we will assume VPD pages are supported if the 5758c2ecf20Sopenharmony_ci * SCSI level is at least SPC-3 and 'skip_vpd_pages' is not set. 5768c2ecf20Sopenharmony_ci */ 5778c2ecf20Sopenharmony_cistatic inline int scsi_device_supports_vpd(struct scsi_device *sdev) 5788c2ecf20Sopenharmony_ci{ 5798c2ecf20Sopenharmony_ci /* Attempt VPD inquiry if the device blacklist explicitly calls 5808c2ecf20Sopenharmony_ci * for it. 5818c2ecf20Sopenharmony_ci */ 5828c2ecf20Sopenharmony_ci if (sdev->try_vpd_pages) 5838c2ecf20Sopenharmony_ci return 1; 5848c2ecf20Sopenharmony_ci /* 5858c2ecf20Sopenharmony_ci * Although VPD inquiries can go to SCSI-2 type devices, 5868c2ecf20Sopenharmony_ci * some USB ones crash on receiving them, and the pages 5878c2ecf20Sopenharmony_ci * we currently ask for are mandatory for SPC-2 and beyond 5888c2ecf20Sopenharmony_ci */ 5898c2ecf20Sopenharmony_ci if (sdev->scsi_level >= SCSI_SPC_2 && !sdev->skip_vpd_pages) 5908c2ecf20Sopenharmony_ci return 1; 5918c2ecf20Sopenharmony_ci return 0; 5928c2ecf20Sopenharmony_ci} 5938c2ecf20Sopenharmony_ci 5948c2ecf20Sopenharmony_ci#define MODULE_ALIAS_SCSI_DEVICE(type) \ 5958c2ecf20Sopenharmony_ci MODULE_ALIAS("scsi:t-" __stringify(type) "*") 5968c2ecf20Sopenharmony_ci#define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x" 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ci#endif /* _SCSI_SCSI_DEVICE_H */ 599