[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / drivers / scsi / dpti.h
blob426e15dd490ed192fbdc4e303519eb21b18fc5e4
1 /***************************************************************************
2 dpti.h - description
3 -------------------
4 begin : Thu Sep 7 2000
5 copyright : (C) 2001 by Adaptec
7 See Documentation/scsi/dpti.txt for history, notes, license info
8 and credits
9 ***************************************************************************/
11 /***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
20 #ifndef _DPT_H
21 #define _DPT_H
23 #ifndef LINUX_VERSION_CODE
24 #include <linux/version.h>
25 #endif
27 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,00)
28 #define MAX_TO_IOP_MESSAGES (210)
29 #else
30 #define MAX_TO_IOP_MESSAGES (255)
31 #endif
32 #define MAX_FROM_IOP_MESSAGES (255)
36 * SCSI interface function Prototypes
39 static int adpt_detect(struct scsi_host_template * sht);
40 static int adpt_queue(struct scsi_cmnd * cmd, void (*cmdcomplete) (struct scsi_cmnd *));
41 static int adpt_abort(struct scsi_cmnd * cmd);
42 static int adpt_reset(struct scsi_cmnd* cmd);
43 static int adpt_release(struct Scsi_Host *host);
44 static int adpt_slave_configure(struct scsi_device *);
46 static const char *adpt_info(struct Scsi_Host *pSHost);
47 static int adpt_bios_param(struct scsi_device * sdev, struct block_device *dev,
48 sector_t, int geom[]);
50 static int adpt_bus_reset(struct scsi_cmnd* cmd);
51 static int adpt_device_reset(struct scsi_cmnd* cmd);
55 * Scsi_Host_Template (see hosts.h)
58 #define DPT_DRIVER_NAME "Adaptec I2O RAID"
60 #ifndef HOSTS_C
62 #include "dpt/sys_info.h"
63 #include <linux/wait.h>
64 #include "dpt/dpti_i2o.h"
65 #include "dpt/dpti_ioctl.h"
67 #define DPT_I2O_VERSION "2.4 Build 5go"
68 #define DPT_VERSION 2
69 #define DPT_REVISION '4'
70 #define DPT_SUBREVISION '5'
71 #define DPT_BETA ""
72 #define DPT_MONTH 8
73 #define DPT_DAY 7
74 #define DPT_YEAR (2001-1980)
76 #define DPT_DRIVER "dpt_i2o"
77 #define DPTI_I2O_MAJOR (151)
78 #define DPT_ORGANIZATION_ID (0x1B) /* For Private Messages */
79 #define DPTI_MAX_HBA (16)
80 #define MAX_CHANNEL (5) // Maximum Channel # Supported
81 #define MAX_ID (128) // Maximum Target ID Supported
83 /* Sizes in 4 byte words */
84 #define REPLY_FRAME_SIZE (17)
85 #define MAX_MESSAGE_SIZE (128)
86 #define SG_LIST_ELEMENTS (56)
88 #define EMPTY_QUEUE 0xffffffff
89 #define I2O_INTERRUPT_PENDING_B (0x08)
91 #define PCI_DPT_VENDOR_ID (0x1044) // DPT PCI Vendor ID
92 #define PCI_DPT_DEVICE_ID (0xA501) // DPT PCI I2O Device ID
93 #define PCI_DPT_RAPTOR_DEVICE_ID (0xA511)
95 //#define REBOOT_NOTIFIER 1
96 /* Debugging macro from Linux Device Drivers - Rubini */
97 #undef PDEBUG
98 #ifdef DEBUG
99 //TODO add debug level switch
100 # define PDEBUG(fmt, args...) printk(KERN_DEBUG "dpti: " fmt, ##args)
101 # define PDEBUGV(fmt, args...) printk(KERN_DEBUG "dpti: " fmt, ##args)
102 #else
103 # define PDEBUG(fmt, args...) /* not debugging: nothing */
104 # define PDEBUGV(fmt, args...) /* not debugging: nothing */
105 #endif
107 #define PERROR(fmt, args...) printk(KERN_ERR fmt, ##args)
108 #define PWARN(fmt, args...) printk(KERN_WARNING fmt, ##args)
109 #define PINFO(fmt, args...) printk(KERN_INFO fmt, ##args)
110 #define PCRIT(fmt, args...) printk(KERN_CRIT fmt, ##args)
112 #define SHUTDOWN_SIGS (sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGTERM))
114 // Command timeouts
115 #define FOREVER (0)
116 #define TMOUT_INQUIRY (20)
117 #define TMOUT_FLUSH (360/45)
118 #define TMOUT_ABORT (30)
119 #define TMOUT_SCSI (300)
120 #define TMOUT_IOPRESET (360)
121 #define TMOUT_GETSTATUS (15)
122 #define TMOUT_INITOUTBOUND (15)
123 #define TMOUT_LCT (360)
126 #define I2O_SCSI_DEVICE_DSC_MASK 0x00FF
128 #define I2O_DETAIL_STATUS_UNSUPPORTED_FUNCTION 0x000A
130 #define I2O_SCSI_DSC_MASK 0xFF00
131 #define I2O_SCSI_DSC_SUCCESS 0x0000
132 #define I2O_SCSI_DSC_REQUEST_ABORTED 0x0200
133 #define I2O_SCSI_DSC_UNABLE_TO_ABORT 0x0300
134 #define I2O_SCSI_DSC_COMPLETE_WITH_ERROR 0x0400
135 #define I2O_SCSI_DSC_ADAPTER_BUSY 0x0500
136 #define I2O_SCSI_DSC_REQUEST_INVALID 0x0600
137 #define I2O_SCSI_DSC_PATH_INVALID 0x0700
138 #define I2O_SCSI_DSC_DEVICE_NOT_PRESENT 0x0800
139 #define I2O_SCSI_DSC_UNABLE_TO_TERMINATE 0x0900
140 #define I2O_SCSI_DSC_SELECTION_TIMEOUT 0x0A00
141 #define I2O_SCSI_DSC_COMMAND_TIMEOUT 0x0B00
142 #define I2O_SCSI_DSC_MR_MESSAGE_RECEIVED 0x0D00
143 #define I2O_SCSI_DSC_SCSI_BUS_RESET 0x0E00
144 #define I2O_SCSI_DSC_PARITY_ERROR_FAILURE 0x0F00
145 #define I2O_SCSI_DSC_AUTOSENSE_FAILED 0x1000
146 #define I2O_SCSI_DSC_NO_ADAPTER 0x1100
147 #define I2O_SCSI_DSC_DATA_OVERRUN 0x1200
148 #define I2O_SCSI_DSC_UNEXPECTED_BUS_FREE 0x1300
149 #define I2O_SCSI_DSC_SEQUENCE_FAILURE 0x1400
150 #define I2O_SCSI_DSC_REQUEST_LENGTH_ERROR 0x1500
151 #define I2O_SCSI_DSC_PROVIDE_FAILURE 0x1600
152 #define I2O_SCSI_DSC_BDR_MESSAGE_SENT 0x1700
153 #define I2O_SCSI_DSC_REQUEST_TERMINATED 0x1800
154 #define I2O_SCSI_DSC_IDE_MESSAGE_SENT 0x3300
155 #define I2O_SCSI_DSC_RESOURCE_UNAVAILABLE 0x3400
156 #define I2O_SCSI_DSC_UNACKNOWLEDGED_EVENT 0x3500
157 #define I2O_SCSI_DSC_MESSAGE_RECEIVED 0x3600
158 #define I2O_SCSI_DSC_INVALID_CDB 0x3700
159 #define I2O_SCSI_DSC_LUN_INVALID 0x3800
160 #define I2O_SCSI_DSC_SCSI_TID_INVALID 0x3900
161 #define I2O_SCSI_DSC_FUNCTION_UNAVAILABLE 0x3A00
162 #define I2O_SCSI_DSC_NO_NEXUS 0x3B00
163 #define I2O_SCSI_DSC_SCSI_IID_INVALID 0x3C00
164 #define I2O_SCSI_DSC_CDB_RECEIVED 0x3D00
165 #define I2O_SCSI_DSC_LUN_ALREADY_ENABLED 0x3E00
166 #define I2O_SCSI_DSC_BUS_BUSY 0x3F00
167 #define I2O_SCSI_DSC_QUEUE_FROZEN 0x4000
170 #ifndef TRUE
171 #define TRUE 1
172 #define FALSE 0
173 #endif
175 #define HBA_FLAGS_INSTALLED_B 0x00000001 // Adapter Was Installed
176 #define HBA_FLAGS_BLINKLED_B 0x00000002 // Adapter In Blink LED State
177 #define HBA_FLAGS_IN_RESET 0x00000040 /* in reset */
178 #define HBA_HOSTRESET_FAILED 0x00000080 /* adpt_resethost failed */
181 // Device state flags
182 #define DPTI_DEV_ONLINE 0x00
183 #define DPTI_DEV_UNSCANNED 0x01
184 #define DPTI_DEV_RESET 0x02
185 #define DPTI_DEV_OFFLINE 0x04
188 struct adpt_device {
189 struct adpt_device* next_lun;
190 u32 flags;
191 u32 type;
192 u32 capacity;
193 u32 block_size;
194 u8 scsi_channel;
195 u8 scsi_id;
196 u8 scsi_lun;
197 u8 state;
198 u16 tid;
199 struct i2o_device* pI2o_dev;
200 struct scsi_device *pScsi_dev;
203 struct adpt_channel {
204 struct adpt_device* device[MAX_ID]; /* used as an array of 128 scsi ids */
205 u8 scsi_id;
206 u8 type;
207 u16 tid;
208 u32 state;
209 struct i2o_device* pI2o_dev;
212 // HBA state flags
213 #define DPTI_STATE_RESET (0x01)
214 #define DPTI_STATE_IOCTL (0x02)
216 typedef struct _adpt_hba {
217 struct _adpt_hba *next;
218 struct pci_dev *pDev;
219 struct Scsi_Host *host;
220 u32 state;
221 spinlock_t state_lock;
222 int unit;
223 int host_no; /* SCSI host number */
224 u8 initialized;
225 u8 in_use; /* is the management node open*/
227 char name[32];
228 char detail[55];
230 void __iomem *base_addr_virt;
231 void __iomem *msg_addr_virt;
232 ulong base_addr_phys;
233 void __iomem *post_port;
234 void __iomem *reply_port;
235 void __iomem *irq_mask;
236 u16 post_count;
237 u32 post_fifo_size;
238 u32 reply_fifo_size;
239 u32* reply_pool;
240 u32 sg_tablesize; // Scatter/Gather List Size.
241 u8 top_scsi_channel;
242 u8 top_scsi_id;
243 u8 top_scsi_lun;
245 i2o_status_block* status_block;
246 i2o_hrt* hrt;
247 i2o_lct* lct;
248 uint lct_size;
249 struct i2o_device* devices;
250 struct adpt_channel channel[MAX_CHANNEL];
251 struct proc_dir_entry* proc_entry; /* /proc dir */
253 void __iomem *FwDebugBuffer_P; // Virtual Address Of FW Debug Buffer
254 u32 FwDebugBufferSize; // FW Debug Buffer Size In Bytes
255 void __iomem *FwDebugStrLength_P;// Virtual Addr Of FW Debug String Len
256 void __iomem *FwDebugFlags_P; // Virtual Address Of FW Debug Flags
257 void __iomem *FwDebugBLEDflag_P;// Virtual Addr Of FW Debug BLED
258 void __iomem *FwDebugBLEDvalue_P;// Virtual Addr Of FW Debug BLED
259 u32 FwDebugFlags;
260 } adpt_hba;
262 struct sg_simple_element {
263 u32 flag_count;
264 u32 addr_bus;
268 * Function Prototypes
271 static void adpt_i2o_sys_shutdown(void);
272 static int adpt_init(void);
273 static int adpt_i2o_build_sys_table(void);
274 static irqreturn_t adpt_isr(int irq, void *dev_id, struct pt_regs *regs);
275 #ifdef REBOOT_NOTIFIER
276 static int adpt_reboot_event(struct notifier_block *n, ulong code, void *p);
277 #endif
279 static void adpt_i2o_report_hba_unit(adpt_hba* pHba, struct i2o_device *d);
280 static int adpt_i2o_query_scalar(adpt_hba* pHba, int tid,
281 int group, int field, void *buf, int buflen);
282 #ifdef DEBUG
283 static const char *adpt_i2o_get_class_name(int class);
284 #endif
285 static int adpt_i2o_issue_params(int cmd, adpt_hba* pHba, int tid,
286 void *opblk, int oplen, void *resblk, int reslen);
287 static int adpt_i2o_post_wait(adpt_hba* pHba, u32* msg, int len, int timeout);
288 static int adpt_i2o_lct_get(adpt_hba* pHba);
289 static int adpt_i2o_parse_lct(adpt_hba* pHba);
290 static int adpt_i2o_activate_hba(adpt_hba* pHba);
291 static int adpt_i2o_enable_hba(adpt_hba* pHba);
292 static int adpt_i2o_install_device(adpt_hba* pHba, struct i2o_device *d);
293 static s32 adpt_i2o_post_this(adpt_hba* pHba, u32* data, int len);
294 static s32 adpt_i2o_quiesce_hba(adpt_hba* pHba);
295 static s32 adpt_i2o_status_get(adpt_hba* pHba);
296 static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba);
297 static s32 adpt_i2o_hrt_get(adpt_hba* pHba);
298 static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_device* dptdevice);
299 static s32 adpt_i2o_to_scsi(ulong reply, struct scsi_cmnd* cmd);
300 static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht);
301 static s32 adpt_hba_reset(adpt_hba* pHba);
302 static s32 adpt_i2o_reset_hba(adpt_hba* pHba);
303 static s32 adpt_rescan(adpt_hba* pHba);
304 static s32 adpt_i2o_reparse_lct(adpt_hba* pHba);
305 static s32 adpt_send_nop(adpt_hba*pHba,u32 m);
306 static void adpt_i2o_delete_hba(adpt_hba* pHba);
307 static void adpt_inquiry(adpt_hba* pHba);
308 static void adpt_fail_posted_scbs(adpt_hba* pHba);
309 static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun);
310 static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) ;
311 static int adpt_i2o_online_hba(adpt_hba* pHba);
312 static void adpt_i2o_post_wait_complete(u32, int);
313 static int adpt_i2o_systab_send(adpt_hba* pHba);
315 static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg);
316 static int adpt_open(struct inode *inode, struct file *file);
317 static int adpt_close(struct inode *inode, struct file *file);
320 #ifdef UARTDELAY
321 static void adpt_delay(int millisec);
322 #endif
324 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
325 static struct pci_dev* adpt_pci_find_device(uint vendor, struct pci_dev* from);
326 #endif
328 #if defined __ia64__
329 static void adpt_ia64_info(sysInfo_S* si);
330 #endif
331 #if defined __sparc__
332 static void adpt_sparc_info(sysInfo_S* si);
333 #endif
334 #if defined __alpha__
335 static void adpt_sparc_info(sysInfo_S* si);
336 #endif
337 #if defined __i386__
338 static void adpt_i386_info(sysInfo_S* si);
339 #endif
341 #define PRINT_BUFFER_SIZE 512
343 #define HBA_FLAGS_DBG_FLAGS_MASK 0xffff0000 // Mask for debug flags
344 #define HBA_FLAGS_DBG_KERNEL_PRINT_B 0x00010000 // Kernel Debugger Print
345 #define HBA_FLAGS_DBG_FW_PRINT_B 0x00020000 // Firmware Debugger Print
346 #define HBA_FLAGS_DBG_FUNCTION_ENTRY_B 0x00040000 // Function Entry Point
347 #define HBA_FLAGS_DBG_FUNCTION_EXIT_B 0x00080000 // Function Exit
348 #define HBA_FLAGS_DBG_ERROR_B 0x00100000 // Error Conditions
349 #define HBA_FLAGS_DBG_INIT_B 0x00200000 // Init Prints
350 #define HBA_FLAGS_DBG_OS_COMMANDS_B 0x00400000 // OS Command Info
351 #define HBA_FLAGS_DBG_SCAN_B 0x00800000 // Device Scan
353 #define FW_DEBUG_STR_LENGTH_OFFSET 0
354 #define FW_DEBUG_FLAGS_OFFSET 4
355 #define FW_DEBUG_BLED_OFFSET 8
357 #define FW_DEBUG_FLAGS_NO_HEADERS_B 0x01
358 #endif /* !HOSTS_C */
359 #endif /* _DPT_H */