blob: c01580df4476bc1acc70a41bd23434cc067fdf67 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _SCSI_PRIV_H
2#define _SCSI_PRIV_H
3
4#include <linux/config.h>
5#include <linux/device.h>
6
7struct request_queue;
8struct scsi_cmnd;
9struct scsi_device;
10struct scsi_host_template;
11struct scsi_request;
12struct Scsi_Host;
13
14
15/*
16 * These are the values that the owner field can take.
17 * They are used as an indication of who the command belongs to.
18 */
19#define SCSI_OWNER_HIGHLEVEL 0x100
20#define SCSI_OWNER_MIDLEVEL 0x101
21#define SCSI_OWNER_LOWLEVEL 0x102
22#define SCSI_OWNER_ERROR_HANDLER 0x103
23#define SCSI_OWNER_BH_HANDLER 0x104
24#define SCSI_OWNER_NOBODY 0x105
25
26/*
27 * Magic values for certain scsi structs. Shouldn't ever be used.
28 */
29#define SCSI_CMND_MAGIC 0xE25C23A5
30#define SCSI_REQ_MAGIC 0x75F6D354
31
32/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 * Scsi Error Handler Flags
34 */
35#define scsi_eh_eflags_chk(scp, flags) \
36 ((scp)->eh_eflags & (flags))
37#define scsi_eh_eflags_set(scp, flags) \
38 do { (scp)->eh_eflags |= (flags); } while(0)
39#define scsi_eh_eflags_clr(scp, flags) \
40 do { (scp)->eh_eflags &= ~(flags); } while(0)
41#define scsi_eh_eflags_clr_all(scp) \
42 (scp->eh_eflags = 0)
43
44#define SCSI_EH_CANCEL_CMD 0x0001 /* Cancel this cmd */
45#define SCSI_EH_REC_TIMEOUT 0x0002 /* EH retry timed out */
46
47#define SCSI_SENSE_VALID(scmd) \
48 (((scmd)->sense_buffer[0] & 0x70) == 0x70)
49
50/*
51 * Special value for scanning to specify scanning or rescanning of all
52 * possible channels, (target) ids, or luns on a given shost.
53 */
54#define SCAN_WILD_CARD ~0
55
56/* hosts.c */
57extern int scsi_init_hosts(void);
58extern void scsi_exit_hosts(void);
59
60/* scsi.c */
61extern int scsi_dispatch_cmd(struct scsi_cmnd *cmd);
62extern int scsi_setup_command_freelist(struct Scsi_Host *shost);
63extern void scsi_destroy_command_freelist(struct Scsi_Host *shost);
64extern void scsi_done(struct scsi_cmnd *cmd);
65extern int scsi_retry_command(struct scsi_cmnd *cmd);
66extern int scsi_insert_special_req(struct scsi_request *sreq, int);
67extern void scsi_init_cmd_from_req(struct scsi_cmnd *cmd,
68 struct scsi_request *sreq);
69extern void __scsi_release_request(struct scsi_request *sreq);
70extern void __scsi_done(struct scsi_cmnd *cmd);
71#ifdef CONFIG_SCSI_LOGGING
72void scsi_log_send(struct scsi_cmnd *cmd);
73void scsi_log_completion(struct scsi_cmnd *cmd, int disposition);
74#else
75static inline void scsi_log_send(struct scsi_cmnd *cmd)
76 { };
77static inline void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
78 { };
79#endif
80
81/* scsi_devinfo.c */
82extern int scsi_get_device_flags(struct scsi_device *sdev,
83 unsigned char *vendor, unsigned char *model);
84extern int __init scsi_init_devinfo(void);
85extern void scsi_exit_devinfo(void);
86
87/* scsi_error.c */
88extern void scsi_times_out(struct scsi_cmnd *cmd);
89extern int scsi_error_handler(void *host);
90extern int scsi_decide_disposition(struct scsi_cmnd *cmd);
91extern void scsi_eh_wakeup(struct Scsi_Host *shost);
92extern int scsi_eh_scmd_add(struct scsi_cmnd *, int);
93
94/* scsi_lib.c */
95extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
96extern void scsi_setup_cmd_retry(struct scsi_cmnd *cmd);
97extern void scsi_device_unbusy(struct scsi_device *sdev);
98extern int scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
99extern void scsi_next_command(struct scsi_cmnd *cmd);
100extern void scsi_run_host_queues(struct Scsi_Host *shost);
101extern struct request_queue *scsi_alloc_queue(struct scsi_device *sdev);
102extern void scsi_free_queue(struct request_queue *q);
103extern int scsi_init_queue(void);
104extern void scsi_exit_queue(void);
105
106/* scsi_proc.c */
107#ifdef CONFIG_SCSI_PROC_FS
108extern void scsi_proc_hostdir_add(struct scsi_host_template *);
109extern void scsi_proc_hostdir_rm(struct scsi_host_template *);
110extern void scsi_proc_host_add(struct Scsi_Host *);
111extern void scsi_proc_host_rm(struct Scsi_Host *);
112extern int scsi_init_procfs(void);
113extern void scsi_exit_procfs(void);
114#else
115# define scsi_proc_hostdir_add(sht) do { } while (0)
116# define scsi_proc_hostdir_rm(sht) do { } while (0)
117# define scsi_proc_host_add(shost) do { } while (0)
118# define scsi_proc_host_rm(shost) do { } while (0)
119# define scsi_init_procfs() (0)
120# define scsi_exit_procfs() do { } while (0)
121#endif /* CONFIG_PROC_FS */
122
123/* scsi_scan.c */
124extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int,
125 unsigned int, unsigned int, int);
126extern void scsi_forget_host(struct Scsi_Host *);
127extern void scsi_rescan_device(struct device *);
128
129/* scsi_sysctl.c */
130#ifdef CONFIG_SYSCTL
131extern int scsi_init_sysctl(void);
132extern void scsi_exit_sysctl(void);
133#else
134# define scsi_init_sysctl() (0)
135# define scsi_exit_sysctl() do { } while (0)
136#endif /* CONFIG_SYSCTL */
137
138/* scsi_sysfs.c */
139extern void scsi_device_dev_release(struct device *);
140extern int scsi_sysfs_add_sdev(struct scsi_device *);
141extern int scsi_sysfs_add_host(struct Scsi_Host *);
142extern int scsi_sysfs_register(void);
143extern void scsi_sysfs_unregister(void);
144extern void scsi_sysfs_device_initialize(struct scsi_device *);
145extern int scsi_sysfs_target_initialize(struct scsi_device *);
146extern struct scsi_transport_template blank_transport_template;
147
148extern struct class sdev_class;
149extern struct bus_type scsi_bus_type;
150
151/*
152 * internal scsi timeout functions: for use by mid-layer and transport
153 * classes.
154 */
155
156#define SCSI_DEVICE_BLOCK_MAX_TIMEOUT (HZ*60)
157extern int scsi_internal_device_block(struct scsi_device *sdev);
158extern int scsi_internal_device_unblock(struct scsi_device *sdev);
159
160#endif /* _SCSI_PRIV_H */