cleanup
[linux-2.4.21-pre4.git] / drivers / message / fusion / mptscsih.h
1 /*
2  *  linux/drivers/message/fusion/mptscsih.h
3  *      High performance SCSI / Fibre Channel SCSI Host device driver.
4  *      For use with PCI chip/adapter(s):
5  *          LSIFC9xx/LSI409xx Fibre Channel
6  *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
7  *
8  *  Credits:
9  *      This driver would not exist if not for Alan Cox's development
10  *      of the linux i2o driver.
11  *
12  *      A huge debt of gratitude is owed to David S. Miller (DaveM)
13  *      for fixing much of the stupid and broken stuff in the early
14  *      driver while porting to sparc64 platform.  THANK YOU!
15  *
16  *      (see also mptbase.c)
17  *
18  *  Copyright (c) 1999-2002 LSI Logic Corporation
19  *  Originally By: Steven J. Ralston
20  *  (mailto:netscape.net)
21  *  (mailto:Pam.Delaney@lsil.com)
22  *
23  *  $Id: mptscsih.h,v 1.1.1.1 2005/04/11 02:50:25 jack Exp $
24  */
25 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
26 /*
27     This program is free software; you can redistribute it and/or modify
28     it under the terms of the GNU General Public License as published by
29     the Free Software Foundation; version 2 of the License.
30
31     This program is distributed in the hope that it will be useful,
32     but WITHOUT ANY WARRANTY; without even the implied warranty of
33     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34     GNU General Public License for more details.
35
36     NO WARRANTY
37     THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
38     CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
39     LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
40     MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
41     solely responsible for determining the appropriateness of using and
42     distributing the Program and assumes all risks associated with its
43     exercise of rights under this Agreement, including but not limited to
44     the risks and costs of program errors, damage to or loss of data,
45     programs or equipment, and unavailability or interruption of operations.
46
47     DISCLAIMER OF LIABILITY
48     NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
49     DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50     DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
51     ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
52     TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
53     USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
54     HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
55
56     You should have received a copy of the GNU General Public License
57     along with this program; if not, write to the Free Software
58     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
59 */
60
61 #ifndef SCSIHOST_H_INCLUDED
62 #define SCSIHOST_H_INCLUDED
63 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
64
65 #include "linux/version.h"
66
67 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
68 /*
69  *      SCSI Public stuff...
70  */
71
72 /*
73  *      Try to keep these at 2^N-1
74  */
75 #define MPT_FC_CAN_QUEUE        63
76 //#define MPT_SCSI_CAN_QUEUE    31
77 #define MPT_SCSI_CAN_QUEUE      MPT_FC_CAN_QUEUE
78 #define MPT_SCSI_CMD_PER_LUN     7
79
80 #define MPT_SCSI_MAX_SECTORS    8192
81
82 /*
83  * Set the MAX_SGE value based on user input.
84  */
85 #ifdef  CONFIG_FUSION_MAX_SGE
86 #if     CONFIG_FUSION_MAX_SGE  < 16
87 #define MPT_SCSI_SG_DEPTH       16
88 #elif   CONFIG_FUSION_MAX_SGE  > 128
89 #define MPT_SCSI_SG_DEPTH       128
90 #else
91 #define MPT_SCSI_SG_DEPTH       CONFIG_FUSION_MAX_SGE
92 #endif
93 #else
94 #define MPT_SCSI_SG_DEPTH       40
95 #endif
96
97 /* To disable domain validation, uncomment the
98  * following line. No effect for FC devices.
99  * For SCSI devices, driver will negotiate to
100  * NVRAM settings (if available) or to maximum adapter
101  * capabilities.
102  */
103 /* #define MPTSCSIH_DISABLE_DOMAIN_VALIDATION */
104
105
106 /* SCSI driver setup structure. Settings can be overridden
107  * by command line options.
108  */
109 #define MPTSCSIH_DOMAIN_VALIDATION      1
110 #define MPTSCSIH_MAX_WIDTH              1
111 #define MPTSCSIH_MIN_SYNC               0x08
112
113 struct mptscsih_driver_setup
114 {
115         u8      dv;
116         u8      max_width;
117         u8      min_sync_fac;
118 };
119
120
121 #define MPTSCSIH_DRIVER_SETUP                   \
122 {                                               \
123         MPTSCSIH_DOMAIN_VALIDATION,             \
124         MPTSCSIH_MAX_WIDTH,                     \
125         MPTSCSIH_MIN_SYNC,                      \
126 }
127
128
129
130 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
131 /*
132  *      Various bits and pieces broke within the lk-2.4.0-testN series:-(
133  *      So here are various HACKS to work around them.
134  */
135
136 /*
137  *      Conditionalizing with "#ifdef MODULE/#endif" around:
138  *              static Scsi_Host_Template driver_template = XX;
139  *              #include <../../scsi/scsi_module.c>
140  *      lines was REMOVED @ lk-2.4.0-test9
141  *      Issue discovered 20001213 by: sshirron
142  */
143 #define MPT_SCSIHOST_NEED_ENTRY_EXIT_HOOKUPS                    1
144 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,0)
145 #       if LINUX_VERSION_CODE == KERNEL_VERSION(2,4,0)
146                 /*
147                  *      Super HACK!  -by sralston:-(
148                  *      (good grief; heaven help me!)
149                  */
150 #               include <linux/capability.h>
151 #               if !defined(CAP_LEASE) && !defined(MODULE)
152 #                       undef MPT_SCSIHOST_NEED_ENTRY_EXIT_HOOKUPS
153 #               endif
154 #       else
155 #               ifndef MODULE
156 #                       undef MPT_SCSIHOST_NEED_ENTRY_EXIT_HOOKUPS
157 #               endif
158 #       endif
159 #endif
160
161 /*
162  *      tq_scheduler disappeared @ lk-2.4.0-test12
163  *      (right when <linux/sched.h> newly defined TQ_ACTIVE)
164  *      tq_struct reworked in 2.5.41. Include workqueue.h.
165  */
166 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,41)
167 #       include <linux/sched.h>
168 #       include <linux/workqueue.h>
169 #define SCHEDULE_TASK(x)                \
170         if (schedule_work(x) == 0) {    \
171                 /*MOD_DEC_USE_COUNT*/;  \
172         }
173 #else
174 #define HAVE_TQ_SCHED   1
175 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
176 #       include <linux/sched.h>
177 #       ifdef TQ_ACTIVE
178 #               undef HAVE_TQ_SCHED
179 #       endif
180 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,40)
181 #               undef HAVE_TQ_SCHED
182 #endif
183 #endif
184 #ifdef HAVE_TQ_SCHED
185 #define SCHEDULE_TASK(x)                \
186         /*MOD_INC_USE_COUNT*/;          \
187         (x)->next = NULL;               \
188         queue_task(x, &tq_scheduler)
189 #else
190 #define SCHEDULE_TASK(x)                \
191         /*MOD_INC_USE_COUNT*/;          \
192         if (schedule_task(x) == 0) {    \
193                 /*MOD_DEC_USE_COUNT*/;  \
194         }
195 #endif
196 #endif
197
198 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
199
200 #define x_scsi_detect           mptscsih_detect
201 #define x_scsi_release          mptscsih_release
202 #define x_scsi_info             mptscsih_info
203 #define x_scsi_queuecommand     mptscsih_qcmd
204 #define x_scsi_abort            mptscsih_abort
205 #define x_scsi_bus_reset        mptscsih_bus_reset
206 #define x_scsi_dev_reset        mptscsih_dev_reset
207 #define x_scsi_host_reset       mptscsih_host_reset
208 #define x_scsi_bios_param       mptscsih_bios_param
209 #define x_scsi_select_queue_depths      mptscsih_select_queue_depths
210
211 #define x_scsi_taskmgmt_bh      mptscsih_taskmgmt_bh
212 #define x_scsi_old_abort        mptscsih_old_abort
213 #define x_scsi_old_reset        mptscsih_old_reset
214
215 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
216 /*
217  *      MPT SCSI Host / Initiator decls...
218  */
219 extern  int              x_scsi_detect(Scsi_Host_Template *);
220 extern  int              x_scsi_release(struct Scsi_Host *host);
221 extern  const char      *x_scsi_info(struct Scsi_Host *);
222 extern  int              x_scsi_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
223 #ifdef MPT_SCSI_USE_NEW_EH
224 extern  int              x_scsi_abort(Scsi_Cmnd *);
225 extern  int              x_scsi_bus_reset(Scsi_Cmnd *);
226 extern  int              x_scsi_dev_reset(Scsi_Cmnd *);
227 extern  int              x_scsi_host_reset(Scsi_Cmnd *);
228 #else
229 extern  int              x_scsi_old_abort(Scsi_Cmnd *);
230 extern  int              x_scsi_old_reset(Scsi_Cmnd *, unsigned int);
231 #endif
232 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,28)
233 extern  int              x_scsi_bios_param(Disk *, struct block_device *, int *);
234 #else
235 extern  int              x_scsi_bios_param(Disk *, kdev_t, int *);
236 #endif
237 extern  void             x_scsi_select_queue_depths(struct Scsi_Host *, Scsi_Device *);
238 extern  void             x_scsi_taskmgmt_bh(void *);
239
240 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
241 #define PROC_SCSI_DECL
242 #else
243 #define PROC_SCSI_DECL  proc_name: "mptscsih",
244 #endif
245
246 #ifdef MPT_SCSI_USE_NEW_EH
247
248 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,1)
249
250 #define MPT_SCSIHOST {                                          \
251         next:                           NULL,                   \
252         PROC_SCSI_DECL                                          \
253         name:                           "MPT SCSI Host",        \
254         detect:                         x_scsi_detect,          \
255         release:                        x_scsi_release,         \
256         info:                           x_scsi_info,            \
257         command:                        NULL,                   \
258         queuecommand:                   x_scsi_queuecommand,    \
259         eh_strategy_handler:            NULL,                   \
260         eh_abort_handler:               x_scsi_abort,           \
261         eh_device_reset_handler:        x_scsi_dev_reset,       \
262         eh_bus_reset_handler:           x_scsi_bus_reset,       \
263         eh_host_reset_handler:          x_scsi_host_reset,      \
264         bios_param:                     x_scsi_bios_param,      \
265         can_queue:                      MPT_SCSI_CAN_QUEUE,     \
266         this_id:                        -1,                     \
267         sg_tablesize:                   MPT_SCSI_SG_DEPTH,      \
268         max_sectors:                    MPT_SCSI_MAX_SECTORS,   \
269         cmd_per_lun:                    MPT_SCSI_CMD_PER_LUN,   \
270         unchecked_isa_dma:              0,                      \
271         use_clustering:                 ENABLE_CLUSTERING,      \
272 }
273
274 #else  /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,1) */
275
276 #define MPT_SCSIHOST {                                          \
277         next:                           NULL,                   \
278         PROC_SCSI_DECL                                          \
279         name:                           "MPT SCSI Host",        \
280         detect:                         x_scsi_detect,          \
281         release:                        x_scsi_release,         \
282         info:                           x_scsi_info,            \
283         command:                        NULL,                   \
284         queuecommand:                   x_scsi_queuecommand,    \
285         eh_strategy_handler:            NULL,                   \
286         eh_abort_handler:               x_scsi_abort,           \
287         eh_device_reset_handler:        x_scsi_dev_reset,       \
288         eh_bus_reset_handler:           x_scsi_bus_reset,       \
289         eh_host_reset_handler:          NULL,                   \
290         bios_param:                     x_scsi_bios_param,      \
291         can_queue:                      MPT_SCSI_CAN_QUEUE,     \
292         this_id:                        -1,                     \
293         sg_tablesize:                   MPT_SCSI_SG_DEPTH,      \
294         cmd_per_lun:                    MPT_SCSI_CMD_PER_LUN,   \
295         unchecked_isa_dma:              0,                      \
296         use_clustering:                 ENABLE_CLUSTERING,      \
297         use_new_eh_code:                1                       \
298 }
299
300 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,1) */
301
302 #else /* MPT_SCSI_USE_NEW_EH */
303
304 #define MPT_SCSIHOST {                                          \
305         next:                           NULL,                   \
306         PROC_SCSI_DECL                                          \
307         name:                           "MPT SCSI Host",        \
308         detect:                         x_scsi_detect,          \
309         release:                        x_scsi_release,         \
310         info:                           x_scsi_info,            \
311         command:                        NULL,                   \
312         queuecommand:                   x_scsi_queuecommand,    \
313         abort:                          x_scsi_old_abort,       \
314         reset:                          x_scsi_old_reset,       \
315         bios_param:                     x_scsi_bios_param,      \
316         can_queue:                      MPT_SCSI_CAN_QUEUE,     \
317         this_id:                        -1,                     \
318         sg_tablesize:                   MPT_SCSI_SG_DEPTH,      \
319         cmd_per_lun:                    MPT_SCSI_CMD_PER_LUN,   \
320         unchecked_isa_dma:              0,                      \
321         use_clustering:                 ENABLE_CLUSTERING       \
322 }
323 #endif  /* MPT_SCSI_USE_NEW_EH */
324
325
326 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
327
328 /*  include/scsi/scsi.h may not be quite complete...  */
329 #ifndef RESERVE_10
330 #define RESERVE_10              0x56
331 #endif
332 #ifndef RELEASE_10
333 #define RELEASE_10              0x57
334 #endif
335 #ifndef PERSISTENT_RESERVE_IN
336 #define PERSISTENT_RESERVE_IN   0x5e
337 #endif
338 #ifndef PERSISTENT_RESERVE_OUT
339 #define PERSISTENT_RESERVE_OUT  0x5f
340 #endif
341
342 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
343
344 #endif
345