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