1 /*
2 * hosts.h Copyright (C) 1992 Drew Eckhardt
3 * mid to low-level SCSI driver interface header by
4 * Drew Eckhardt
5 *
6 * <drew@colorado.edu>
7 *
8 * Modified by Eric Youngdale eric@tantalus.nrl.navy.mil to
9 * add scatter-gather, multiple outstanding request, and other
10 * enhancements.
11 *
12 * Further modified by Eric Youngdale to support multiple host adapters
13 * of the same type.
14 */
15
16 #ifndef _HOSTS_H
17 #define _HOSTS_H
18
19 /*
20 $Header: /usr/src/linux/kernel/blk_drv/scsi/RCS/hosts.h,v 1.3 1993/09/24 12:21:00 drew Exp drew $
21 */
22
23
24 /* It is senseless to set SG_ALL any higher than this - the performance
25 does not get any better, and it wastes memory */
26 #define SG_NONE 0
27 #define SG_ALL 0xff
28
29 #define DISABLE_CLUSTERING 0
30 #define ENABLE_CLUSTERING 1
31
32 /* The various choices mean:
33 NONE: Self evident. Host adapter is not capable of scatter-gather.
34 ALL: Means that the host adapter module can do scatter-gather,
35 and that there is no limit to the size of the table to which
36 we scatter/gather data.
37 Anything else: Indicates the maximum number of chains that can be
38 used in one scatter-gather request.
39 */
40
41 /*
42 The Scsi_Host_Template type has all that is needed to interface with a SCSI
43 host in a device independant matter. There is one entry for each different
44 type of host adapter that is supported on the system.
45 */
46
47 typedef struct scsi_disk Disk;
48
49 typedef struct
50 {
51 /*
52 The name pointer is a pointer to the name of the SCSI
53 device detected.
54 */
55
56 char *name;
57
58 /*
59 The detect function shall return non zero on detection,
60 indicating the number of host adapters of this particular
61 type were found. It should also
62 initialize all data necessary for this particular
63 SCSI driver. It is passed the host number, so this host
64 knows where the first entry is in the scsi_hosts[] array.
65
66 Note that the detect routine MUST not call any of the mid level
67 functions to queue commands because things are not guaranteed
68 to be set up yet. The detect routine can send commands to
69 the host adapter as long as the program control will not be
70 passed to scsi.c in the processesing of the command. Note
71 especially that scsi_malloc/scsi_free must not be called.
72 */
73
74 int (* detect)(int);
75
76 /*
77 The info function will return whatever useful
78 information the developer sees fit.
79 */
80
81 const char *(* info)(void);
82
83 /*
84 The command function takes a target, a command (this is a SCSI
85 command formatted as per the SCSI spec, nothing strange), a
86 data buffer pointer, and data buffer length pointer. The return
87 is a status int, bit fielded as follows :
88 Byte What
89 0 SCSI status code
90 1 SCSI 1 byte message
91 2 host error return.
92 3 mid level error return
93 */
94
95 int (* command)(Scsi_Cmnd *);
96
97 /*
98 The QueueCommand function works in a similar manner
99 to the command function. It takes an additional parameter,
100 void (* done)(int host, int code) which is passed the host
101 # and exit result when the command is complete.
102 Host number is the POSITION IN THE hosts array of THIS
103 host adapter.
104 */
105
106 int (* queuecommand)(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
107
108 /*
109 Since the mid level driver handles time outs, etc, we want to
110 be able to abort the current command. Abort returns 0 if the
111 abortion was successful. The field SCpnt->abort reason
112 can be filled in with the appropriate reason why we wanted
113 the abort in the first place, and this will be used
114 in the mid-level code instead of the host_byte().
115 If non-zero, the code passed to it
116 will be used as the return code, otherwise
117 DID_ABORT should be returned.
118
119 Note that the scsi driver should "clean up" after itself,
120 resetting the bus, etc. if necessary.
121 */
122
123 int (* abort)(Scsi_Cmnd *);
124
125 /*
126 The reset function will reset the SCSI bus. Any executing
127 commands should fail with a DID_RESET in the host byte.
128 The Scsi_Cmnd is passed so that the reset routine can figure
129 out which host adapter should be reset, and also which command
130 within the command block was responsible for the reset in
131 the first place. Some hosts do not implement a reset function,
132 and these hosts must call scsi_request_sense(SCpnt) to keep
133 the command alive.
134 */
135
136 int (* reset)(Scsi_Cmnd *);
137 /*
138 This function is used to select synchronous communications,
139 which will result in a higher data throughput. Not implemented
140 yet.
141 */
142
143 int (* slave_attach)(int, int);
144 /*
145 This function determines the bios parameters for a given
146 harddisk. These tend to be numbers that are made up by
147 the host adapter. Parameters:
148 size, device number, list (heads, sectors, cylinders)
149 */
150
151 int (* bios_param)(Disk *, int, int []);
152
153 /*
154 This determines if we will use a non-interrupt driven
155 or an interrupt driven scheme, It is set to the maximum number
156 of simulataneous commands a given host adapter will accept.
157 */
158 int can_queue;
159
160 /*
161 In many instances, especially where disconnect / reconnect are
162 supported, our host also has an ID on the SCSI bus. If this is
163 the case, then it must be reserved. Please set this_id to -1 if
164 your settup is in single initiator mode, and the host lacks an
165 ID.
166 */
167
168 int this_id;
169
170 /*
171 This determines the degree to which the host adapter is capable
172 of scatter-gather.
173 */
174
175 short unsigned int sg_tablesize;
176
177 /*
178 True if this host adapter can make good use of linked commands.
179 This will allow more than one command to be queued to a given
180 unit on a given host. Set this to the maximum number of command
181 blocks to be provided for each device. Set this to 1 for one
182 command block per lun, 2 for two, etc. Do not set this to 0.
183 You should make sure that the host adapter will do the right thing
184 before you try setting this above 1.
185 */
186
187 short cmd_per_lun;
188 /*
189 present contains counter indicating how many boards of this
190 type were found when we did the scan.
191 */
192
193 unsigned char present;
194 /*
195 true if this host adapter uses unchecked DMA onto an ISA bus.
196 */
197 unsigned unchecked_isa_dma:1;
198 /*
199 true if this host adapter can make good use of clustering.
200 I originally thought that if the tablesize was large that it
201 was a waste of CPU cycles to prepare a cluster list, but
202 it works out that the Buslogic is faster if you use a smaller
203 number of segments (i.e. use clustering). I guess it is
204 inefficient.
205 */
206 unsigned use_clustering:1;
207 } Scsi_Host_Template;
208
209 /*
210 The scsi_hosts array is the array containing the data for all
211 possible <supported> scsi hosts. This is similar to the
212 Scsi_Host_Template, except that we have one entry for each
213 actual physical host adapter on the system, stored as a linked
214 list. Note that if there are 2 aha1542 boards, then there will
215 be two Scsi_Host entries, but only 1 Scsi_Host_Template entries.
216 */
217
218 struct Scsi_Host
219 {
220 struct Scsi_Host * next;
221 volatile unsigned char host_busy;
222 char host_no; /* Used for IOCTL_GET_IDLUN */
223 int last_reset;
224 struct wait_queue *host_wait;
225 Scsi_Cmnd *host_queue;
226 Scsi_Host_Template * hostt;
227
228 /* These parameters should be set by the detect routine */
229 unsigned char *base;
230 short unsigned int io_port;
231 unsigned char irq;
232 unsigned char dma_channel;
233 /*
234 The rest can be copied from the template, or specifically
235 initialized, as required.
236 */
237
238 int this_id;
239 short unsigned int sg_tablesize;
240 unsigned unchecked_isa_dma:1;
241 int hostdata[0]; /* Used for storage of host specific stuff */
242 };
243
244 extern struct Scsi_Host * scsi_hostlist;
245
246 extern Scsi_Host_Template scsi_hosts[];
247
248 /*
249 scsi_init initializes the scsi hosts.
250 */
251
252
253 unsigned int scsi_init(unsigned long memory_start,unsigned long memory_end);
254 extern struct Scsi_Host * scsi_register(int i, int j);
255 extern void scsi_unregister(struct Scsi_Host * i, int j);
256
257 #define BLANK_HOST {"", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
258 #endif