Merge tag 'drm-misc-next-fixes-2023-01-03' of git://anongit.freedesktop.org/drm/drm...
[linux-2.6-block.git] / drivers / scsi / scsi_priv.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
2#ifndef _SCSI_PRIV_H
3#define _SCSI_PRIV_H
4
1da177e4 5#include <linux/device.h>
5d9fb5cc 6#include <scsi/scsi_device.h>
020b0f0a 7#include <linux/sbitmap.h>
1da177e4 8
ead09dd3 9struct bsg_device;
1da177e4 10struct request_queue;
242f9dcb 11struct request;
1da177e4
LT
12struct scsi_cmnd;
13struct scsi_device;
bc4f2401 14struct scsi_target;
1da177e4 15struct scsi_host_template;
1da177e4 16struct Scsi_Host;
84314fd4 17struct scsi_nl_hdr;
1da177e4 18
2a242d59 19#define SCSI_CMD_RETRIES_NO_LIMIT -1
1da177e4 20
36ebf1e2
MC
21/*
22 * Error codes used by scsi-ml internally. These must not be used by drivers.
23 */
24enum scsi_ml_status {
25 SCSIML_STAT_OK = 0x00,
26 SCSIML_STAT_RESV_CONFLICT = 0x01, /* Reservation conflict */
27 SCSIML_STAT_NOSPC = 0x02, /* Space allocation on the dev failed */
28 SCSIML_STAT_MED_ERROR = 0x03, /* Medium error */
29 SCSIML_STAT_TGT_FAILURE = 0x04, /* Permanent target failure */
30};
31
1da177e4
LT
32/*
33 * Scsi Error Handler Flags
34 */
e494f6a7 35#define SCSI_EH_ABORT_SCHEDULED 0x0002 /* Abort has been scheduled */
1da177e4
LT
36
37#define SCSI_SENSE_VALID(scmd) \
38 (((scmd)->sense_buffer[0] & 0x70) == 0x70)
39
1da177e4
LT
40/* hosts.c */
41extern int scsi_init_hosts(void);
42extern void scsi_exit_hosts(void);
43
44/* scsi.c */
0a6ac4ee 45int scsi_init_sense_cache(struct Scsi_Host *shost);
e9c787e6 46void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd);
1da177e4
LT
47#ifdef CONFIG_SCSI_LOGGING
48void scsi_log_send(struct scsi_cmnd *cmd);
49void scsi_log_completion(struct scsi_cmnd *cmd, int disposition);
50#else
51static inline void scsi_log_send(struct scsi_cmnd *cmd)
52 { };
53static inline void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
54 { };
55#endif
56
57/* scsi_devinfo.c */
598fa4b7
JB
58
59/* list of keys for the lists */
4b1d8e78 60enum scsi_devinfo_key {
598fa4b7 61 SCSI_DEVINFO_GLOBAL = 0,
a9e0edb6 62 SCSI_DEVINFO_SPI,
598fa4b7
JB
63};
64
5ebde469
HR
65extern blist_flags_t scsi_get_device_flags(struct scsi_device *sdev,
66 const unsigned char *vendor,
67 const unsigned char *model);
68extern blist_flags_t scsi_get_device_flags_keyed(struct scsi_device *sdev,
69 const unsigned char *vendor,
70 const unsigned char *model,
4b1d8e78 71 enum scsi_devinfo_key key);
598fa4b7
JB
72extern int scsi_dev_info_list_add_keyed(int compatible, char *vendor,
73 char *model, char *strflags,
4b1d8e78
BVA
74 blist_flags_t flags,
75 enum scsi_devinfo_key key);
76extern int scsi_dev_info_list_del_keyed(char *vendor, char *model,
77 enum scsi_devinfo_key key);
78extern int scsi_dev_info_add_list(enum scsi_devinfo_key key, const char *name);
79extern int scsi_dev_info_remove_list(enum scsi_devinfo_key key);
598fa4b7 80
1da177e4
LT
81extern int __init scsi_init_devinfo(void);
82extern void scsi_exit_devinfo(void);
83
84/* scsi_error.c */
e494f6a7 85extern void scmd_eh_abort_handler(struct work_struct *work);
9bdb4833 86extern enum blk_eh_timer_return scsi_timeout(struct request *req);
1da177e4 87extern int scsi_error_handler(void *host);
b8e162f9 88extern enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *cmd);
1da177e4 89extern void scsi_eh_wakeup(struct Scsi_Host *shost);
a0658632 90extern void scsi_eh_scmd_add(struct scsi_cmnd *);
dca84e46
DW
91void scsi_eh_ready_devs(struct Scsi_Host *shost,
92 struct list_head *work_q,
93 struct list_head *done_q);
94int scsi_eh_get_sense(struct list_head *work_q,
95 struct list_head *done_q);
88b32c3c 96bool scsi_noretry_cmd(struct scsi_cmnd *scmd);
bf23e619 97void scsi_eh_done(struct scsi_cmnd *scmd);
1da177e4
LT
98
99/* scsi_lib.c */
100extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
6eb045e0 101extern void scsi_device_unbusy(struct scsi_device *sdev, struct scsi_cmnd *cmd);
84feb166 102extern void scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
7b3d9545 103extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
1da177e4 104extern void scsi_run_host_queues(struct Scsi_Host *shost);
d67e8b38 105extern void scsi_requeue_run_queue(struct work_struct *work);
66483a4a 106extern void scsi_start_queue(struct scsi_device *sdev);
d285203c 107extern int scsi_mq_setup_tags(struct Scsi_Host *shost);
8fe4ce58 108extern void scsi_mq_free_tags(struct kref *kref);
1da177e4 109extern void scsi_exit_queue(void);
d67e8b38 110extern void scsi_evt_thread(struct work_struct *work);
1da177e4
LT
111
112/* scsi_proc.c */
113#ifdef CONFIG_SCSI_PROC_FS
036abd61
BVA
114extern int scsi_proc_hostdir_add(const struct scsi_host_template *);
115extern void scsi_proc_hostdir_rm(const struct scsi_host_template *);
1da177e4
LT
116extern void scsi_proc_host_add(struct Scsi_Host *);
117extern void scsi_proc_host_rm(struct Scsi_Host *);
118extern int scsi_init_procfs(void);
119extern void scsi_exit_procfs(void);
120#else
ecca3f9b 121# define scsi_proc_hostdir_add(sht) 0
1da177e4
LT
122# define scsi_proc_hostdir_rm(sht) do { } while (0)
123# define scsi_proc_host_add(shost) do { } while (0)
124# define scsi_proc_host_rm(shost) do { } while (0)
125# define scsi_init_procfs() (0)
126# define scsi_exit_procfs() do { } while (0)
127#endif /* CONFIG_PROC_FS */
128
129/* scsi_scan.c */
a19a93e4 130void scsi_enable_async_suspend(struct device *dev);
fea6d607 131extern int scsi_complete_async_scans(void);
1da177e4 132extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int,
1d645088 133 unsigned int, u64, enum scsi_scan_mode);
1da177e4
LT
134extern void scsi_forget_host(struct Scsi_Host *);
135extern void scsi_rescan_device(struct device *);
136
137/* scsi_sysctl.c */
138#ifdef CONFIG_SYSCTL
139extern int scsi_init_sysctl(void);
140extern void scsi_exit_sysctl(void);
141#else
142# define scsi_init_sysctl() (0)
143# define scsi_exit_sysctl() do { } while (0)
144#endif /* CONFIG_SYSCTL */
145
146/* scsi_sysfs.c */
1da177e4
LT
147extern int scsi_sysfs_add_sdev(struct scsi_device *);
148extern int scsi_sysfs_add_host(struct Scsi_Host *);
149extern int scsi_sysfs_register(void);
150extern void scsi_sysfs_unregister(void);
151extern void scsi_sysfs_device_initialize(struct scsi_device *);
152extern int scsi_sysfs_target_initialize(struct scsi_device *);
153extern struct scsi_transport_template blank_transport_template;
903f4fed 154extern void __scsi_remove_device(struct scsi_device *);
1da177e4 155
1da177e4 156extern struct bus_type scsi_bus_type;
0a84486d 157extern const struct attribute_group *scsi_shost_groups[];
1da177e4 158
84314fd4
JS
159/* scsi_netlink.c */
160#ifdef CONFIG_SCSI_NETLINK
161extern void scsi_netlink_init(void);
162extern void scsi_netlink_exit(void);
163extern struct sock *scsi_nl_sock;
164#else
165static inline void scsi_netlink_init(void) {}
166static inline void scsi_netlink_exit(void) {}
167#endif
168
db5bd1e0 169/* scsi_pm.c */
aa338601 170#ifdef CONFIG_PM
db5bd1e0 171extern const struct dev_pm_ops scsi_bus_pm_ops;
4f7ad521 172
bc4f2401
AS
173extern void scsi_autopm_get_target(struct scsi_target *);
174extern void scsi_autopm_put_target(struct scsi_target *);
175extern int scsi_autopm_get_host(struct Scsi_Host *);
176extern void scsi_autopm_put_host(struct Scsi_Host *);
177#else
178static inline void scsi_autopm_get_target(struct scsi_target *t) {}
179static inline void scsi_autopm_put_target(struct scsi_target *t) {}
180static inline int scsi_autopm_get_host(struct Scsi_Host *h) { return 0; }
181static inline void scsi_autopm_put_host(struct Scsi_Host *h) {}
4f7ad521 182#endif /* CONFIG_PM */
db5bd1e0 183
086b91d0
CH
184/* scsi_dh.c */
185#ifdef CONFIG_SCSI_DH
2930f817 186void scsi_dh_add_device(struct scsi_device *sdev);
23695e41 187void scsi_dh_release_device(struct scsi_device *sdev);
086b91d0 188#else
2930f817 189static inline void scsi_dh_add_device(struct scsi_device *sdev) { }
23695e41 190static inline void scsi_dh_release_device(struct scsi_device *sdev) { }
086b91d0
CH
191#endif
192
ead09dd3 193struct bsg_device *scsi_bsg_register_queue(struct scsi_device *sdev);
78011042 194
020b0f0a
ML
195extern int scsi_device_max_queue_depth(struct scsi_device *sdev);
196
1da177e4
LT
197/*
198 * internal scsi timeout functions: for use by mid-layer and transport
199 * classes.
200 */
201
1c9e16e4 202#define SCSI_DEVICE_BLOCK_MAX_TIMEOUT 600 /* units in seconds */
1da177e4
LT
203
204#endif /* _SCSI_PRIV_H */