Merge with Linux 2.5.74.
[linux-2.6/linux-mips.git] / drivers / scsi / scsi.h
blob3ff36ab847445dba7e00e602991b3e1cadfb35f0
1 /*
2 * scsi.h Copyright (C) 1992 Drew Eckhardt
3 * Copyright (C) 1993, 1994, 1995, 1998, 1999 Eric Youngdale
4 * generic SCSI package header file by
5 * Initial versions: Drew Eckhardt
6 * Subsequent revisions: Eric Youngdale
8 * <drew@colorado.edu>
10 * Modified by Eric Youngdale eric@andante.org to
11 * add scatter-gather, multiple outstanding request, and other
12 * enhancements.
15 #ifndef _SCSI_H
16 #define _SCSI_H
18 #include <linux/config.h> /* for CONFIG_SCSI_LOGGING */
20 #include <scsi/scsi_cmnd.h>
21 #include <scsi/scsi_device.h>
22 #include <scsi/scsi_eh.h>
23 #include <scsi/scsi_request.h>
24 #include <scsi/scsi_tcq.h>
25 #include <scsi/scsi.h>
28 * Some defs, in case these are not defined elsewhere.
30 #ifndef TRUE
31 #define TRUE 1
32 #endif
33 #ifndef FALSE
34 #define FALSE 0
35 #endif
37 #define MAX_SCSI_DEVICE_CODE 14
38 extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE];
40 #ifdef DEBUG
41 #define SCSI_TIMEOUT (5*HZ)
42 #else
43 #define SCSI_TIMEOUT (2*HZ)
44 #endif
47 * Use these to separate status msg and our bytes
49 * These are set by:
51 * status byte = set from target device
52 * msg_byte = return status from host adapter itself.
53 * host_byte = set by low-level driver to indicate status.
54 * driver_byte = set by mid-level.
56 #define status_byte(result) (((result) >> 1) & 0x1f)
57 #define msg_byte(result) (((result) >> 8) & 0xff)
58 #define host_byte(result) (((result) >> 16) & 0xff)
59 #define driver_byte(result) (((result) >> 24) & 0xff)
60 #define suggestion(result) (driver_byte(result) & SUGGEST_MASK)
62 #define sense_class(sense) (((sense) >> 4) & 0x7)
63 #define sense_error(sense) ((sense) & 0xf)
64 #define sense_valid(sense) ((sense) & 0x80);
66 #define NEEDS_RETRY 0x2001
67 #define SUCCESS 0x2002
68 #define FAILED 0x2003
69 #define QUEUED 0x2004
70 #define SOFT_ERROR 0x2005
71 #define ADD_TO_MLQUEUE 0x2006
73 #define IDENTIFY_BASE 0x80
74 #define IDENTIFY(can_disconnect, lun) (IDENTIFY_BASE |\
75 ((can_disconnect) ? 0x40 : 0) |\
76 ((lun) & 0x07))
78 /* host byte codes */
79 #define DID_OK 0x00 /* NO error */
80 #define DID_NO_CONNECT 0x01 /* Couldn't connect before timeout period */
81 #define DID_BUS_BUSY 0x02 /* BUS stayed busy through time out period */
82 #define DID_TIME_OUT 0x03 /* TIMED OUT for other reason */
83 #define DID_BAD_TARGET 0x04 /* BAD target. */
84 #define DID_ABORT 0x05 /* Told to abort for some other reason */
85 #define DID_PARITY 0x06 /* Parity error */
86 #define DID_ERROR 0x07 /* Internal error */
87 #define DID_RESET 0x08 /* Reset by somebody. */
88 #define DID_BAD_INTR 0x09 /* Got an interrupt we weren't expecting. */
89 #define DID_PASSTHROUGH 0x0a /* Force command past mid-layer */
90 #define DID_SOFT_ERROR 0x0b /* The low level driver just wish a retry */
91 #define DRIVER_OK 0x00 /* Driver status */
94 * These indicate the error that occurred, and what is available.
97 #define DRIVER_BUSY 0x01
98 #define DRIVER_SOFT 0x02
99 #define DRIVER_MEDIA 0x03
100 #define DRIVER_ERROR 0x04
102 #define DRIVER_INVALID 0x05
103 #define DRIVER_TIMEOUT 0x06
104 #define DRIVER_HARD 0x07
105 #define DRIVER_SENSE 0x08
107 #define SUGGEST_RETRY 0x10
108 #define SUGGEST_ABORT 0x20
109 #define SUGGEST_REMAP 0x30
110 #define SUGGEST_DIE 0x40
111 #define SUGGEST_SENSE 0x80
112 #define SUGGEST_IS_OK 0xff
114 #define DRIVER_MASK 0x0f
115 #define SUGGEST_MASK 0xf0
118 * SCSI command sets
121 #define SCSI_UNKNOWN 0
122 #define SCSI_1 1
123 #define SCSI_1_CCS 2
124 #define SCSI_2 3
125 #define SCSI_3 4
128 * Every SCSI command starts with a one byte OP-code.
129 * The next byte's high three bits are the LUN of the
130 * device. Any multi-byte quantities are stored high byte
131 * first, and may have a 5 bit MSB in the same byte
132 * as the LUN.
136 * As the scsi do command functions are intelligent, and may need to
137 * redo a command, we need to keep track of the last command
138 * executed on each one.
141 #define WAS_RESET 0x01
142 #define WAS_TIMEDOUT 0x02
143 #define WAS_SENSE 0x04
144 #define IS_RESETTING 0x08
145 #define IS_ABORTING 0x10
146 #define ASKED_FOR_SENSE 0x20
147 #define SYNC_RESET 0x40
149 struct Scsi_Host;
150 struct scsi_cmnd;
151 struct scsi_device;
152 struct scsi_target;
153 struct scatterlist;
156 * Prototypes for functions in constants.c
157 * Some of these used to live in constants.h
159 extern void print_Scsi_Cmnd(struct scsi_cmnd *);
160 extern void print_command(unsigned char *);
161 extern void print_sense(const char *, struct scsi_cmnd *);
162 extern void print_req_sense(const char *, struct scsi_request *);
163 extern void print_driverbyte(int scsiresult);
164 extern void print_hostbyte(int scsiresult);
165 extern void print_status(unsigned char status);
166 extern int print_msg(const unsigned char *);
167 extern const char *scsi_sense_key_string(unsigned char);
168 extern const char *scsi_extd_sense_format(unsigned char, unsigned char);
171 * Definitions and prototypes used for scsi mid-level queue.
173 #define SCSI_MLQUEUE_HOST_BUSY 0x1055
174 #define SCSI_MLQUEUE_DEVICE_BUSY 0x1056
175 #define SCSI_MLQUEUE_EH_RETRY 0x1057
177 extern int scsi_sysfs_modify_sdev_attribute(struct device_attribute ***dev_attrs,
178 struct device_attribute *attr);
179 extern int scsi_sysfs_modify_shost_attribute(struct class_device_attribute ***class_attrs,
180 struct class_device_attribute *attr);
183 * Legacy dma direction interfaces.
185 * This assumes the pci/sbus dma mapping flags have the same numercial
186 * values as the generic dma-mapping ones. Currently they have but there's
187 * no way to check. Better don't use these interfaces!
189 #define SCSI_DATA_UNKNOWN (DMA_BIDIRECTIONAL)
190 #define SCSI_DATA_WRITE (DMA_TO_DEVICE)
191 #define SCSI_DATA_READ (DMA_FROM_DEVICE)
192 #define SCSI_DATA_NONE (DMA_NONE)
194 #define scsi_to_pci_dma_dir(scsi_dir) ((int)(scsi_dir))
195 #define scsi_to_sbus_dma_dir(scsi_dir) ((int)(scsi_dir))
198 * This is the crap from the old error handling code. We have it in a special
199 * place so that we can more easily delete it later on.
201 #include "scsi_obsolete.h"
203 /* obsolete typedef junk. */
204 #include "scsi_typedefs.h"
206 #endif /* _SCSI_H */