Linux Audio

Check our new training course

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