Blame view

drivers/scsi/BusLogic.h 33.8 KB
58751759a   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-only */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
6
  /*
  
    Linux Driver for BusLogic MultiMaster and FlashPoint SCSI Host Adapters
  
    Copyright 1995-1998 by Leonard N. Zubkoff <lnz@dandelion.com>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  
    The author respectfully requests that any modifications to this software be
    sent directly to him for evaluation and testing.
  
    Special thanks to Wayne Yen, Jin-Lon Hon, and Alex Win of BusLogic, whose
    advice has been invaluable, to David Gentzel, for writing the original Linux
    BusLogic driver, and to Paul Gortmaker, for being such a dedicated test site.
  
    Finally, special thanks to Mylex/BusLogic for making the FlashPoint SCCB
    Manager available as freely redistributable source code.
  
  */
  
  #ifndef _BUSLOGIC_H
  #define _BUSLOGIC_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22
23
24
25
26
27
  
  #ifndef PACKED
  #define PACKED __attribute__((packed))
  #endif
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28
29
    Define the maximum number of BusLogic Host Adapters supported by this driver.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
30
  #define BLOGIC_MAX_ADAPTERS		16
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
32
33
34
35
  
  
  /*
    Define the maximum number of Target Devices supported by this driver.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
36
  #define BLOGIC_MAXDEV			16
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
38
39
40
41
42
43
  
  
  /*
    Define the maximum number of Scatter/Gather Segments used by this driver.
    For optimal performance, it is important that this limit be at least as
    large as the largest single request generated by the I/O Subsystem.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
44
  #define BLOGIC_SG_LIMIT		128
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
45
46
47
48
49
50
51
  
  
  /*
    Define the maximum, maximum automatic, minimum automatic, and default Queue
    Depth to allow for Target Devices depending on whether or not they support
    Tagged Queuing and whether or not ISA Bounce Buffers are required.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
52
53
54
55
56
57
  #define BLOGIC_MAX_TAG_DEPTH		64
  #define BLOGIC_MAX_AUTO_TAG_DEPTH	28
  #define BLOGIC_MIN_AUTO_TAG_DEPTH	7
  #define BLOGIC_TAG_DEPTH_BB		3
  #define BLOGIC_UNTAG_DEPTH		3
  #define BLOGIC_UNTAG_DEPTH_BB		2
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
58
59
60
61
62
63
64
65
  
  
  /*
    Define the default amount of time in seconds to wait between a Host Adapter
    Hard Reset which initiates a SCSI Bus Reset and issuing any SCSI commands.
    Some SCSI devices get confused if they receive SCSI commands too soon after
    a SCSI Bus Reset.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
66
  #define BLOGIC_BUS_SETTLE_TIME		2
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
67
68
69
70
71
72
73
74
  
  
  /*
    Define the maximum number of Mailboxes that should be used for MultiMaster
    Host Adapters.  This number is chosen to be larger than the maximum Host
    Adapter Queue Depth and small enough so that the Host Adapter structure
    does not cross an allocation block size boundary.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
75
  #define BLOGIC_MAX_MAILBOX		211
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
76
77
78
79
80
81
  
  
  /*
    Define the number of CCBs that should be allocated as a group to optimize
    Kernel memory allocation.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
82
  #define BLOGIC_CCB_GRP_ALLOCSIZE	7
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
83
84
85
86
87
  
  
  /*
    Define the Host Adapter Line and Message Buffer Sizes.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
88
89
  #define BLOGIC_LINEBUF_SIZE		100
  #define BLOGIC_MSGBUF_SIZE		9700
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
90
91
92
93
94
  
  
  /*
    Define the Driver Message Levels.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
95
96
97
98
99
100
  enum blogic_msglevel {
  	BLOGIC_ANNOUNCE_LEVEL = 0,
  	BLOGIC_INFO_LEVEL = 1,
  	BLOGIC_NOTICE_LEVEL = 2,
  	BLOGIC_WARN_LEVEL = 3,
  	BLOGIC_ERR_LEVEL = 4
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
101
  };
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
102
  static char *blogic_msglevelmap[] = { KERN_NOTICE, KERN_NOTICE, KERN_NOTICE, KERN_WARNING, KERN_ERR };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
103
104
105
106
107
  
  
  /*
    Define Driver Message macros.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
108
109
  #define blogic_announce(format, args...) \
  	blogic_msg(BLOGIC_ANNOUNCE_LEVEL, format, ##args)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110

839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
111
112
  #define blogic_info(format, args...) \
  	blogic_msg(BLOGIC_INFO_LEVEL, format, ##args)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113

839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
114
115
  #define blogic_notice(format, args...) \
  	blogic_msg(BLOGIC_NOTICE_LEVEL, format, ##args)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
116

839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
117
118
  #define blogic_warn(format, args...) \
  	blogic_msg(BLOGIC_WARN_LEVEL, format, ##args)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
119

839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
120
121
  #define blogic_err(format, args...) \
  	blogic_msg(BLOGIC_ERR_LEVEL, format, ##args)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
122
123
124
125
126
127
  
  
  /*
    Define the types of BusLogic Host Adapters that are supported and the number
    of I/O Addresses required by each type.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
128
129
130
  enum blogic_adapter_type {
  	BLOGIC_MULTIMASTER = 1,
  	BLOGIC_FLASHPOINT = 2
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
131
  } PACKED;
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
132
133
  #define BLOGIC_MULTIMASTER_ADDR_COUNT	4
  #define BLOGIC_FLASHPOINT_ADDR_COUNT	256
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
134

839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
135
  static int blogic_adapter_addr_count[3] = { 0, BLOGIC_MULTIMASTER_ADDR_COUNT, BLOGIC_FLASHPOINT_ADDR_COUNT };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
136
137
138
139
140
  
  
  /*
    Define macros for testing the Host Adapter Type.
  */
78b4b05db   Matthew Wilcox   [SCSI] BusLogic: ...
141
  #ifdef CONFIG_SCSI_FLASHPOINT
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
142

839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
143
144
  #define blogic_multimaster_type(adapter) \
  	(adapter->adapter_type == BLOGIC_MULTIMASTER)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
145

839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
146
147
  #define blogic_flashpoint_type(adapter) \
  	(adapter->adapter_type == BLOGIC_FLASHPOINT)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
148
149
  
  #else
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
150
151
  #define blogic_multimaster_type(adapter)	(true)
  #define blogic_flashpoint_type(adapter)		(false)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
152
153
154
155
156
157
158
  
  #endif
  
  
  /*
    Define the possible Host Adapter Bus Types.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
159
160
161
162
163
164
165
  enum blogic_adapter_bus_type {
  	BLOGIC_UNKNOWN_BUS = 0,
  	BLOGIC_ISA_BUS = 1,
  	BLOGIC_EISA_BUS = 2,
  	BLOGIC_PCI_BUS = 3,
  	BLOGIC_VESA_BUS = 4,
  	BLOGIC_MCA_BUS = 5
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
166
  } PACKED;
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
167
  static char *blogic_adapter_busnames[] = { "Unknown", "ISA", "EISA", "PCI", "VESA", "MCA" };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
168

839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
169
170
171
172
173
174
175
  static enum blogic_adapter_bus_type blogic_adater_bus_types[] = {
  	BLOGIC_VESA_BUS,	/* BT-4xx */
  	BLOGIC_ISA_BUS,		/* BT-5xx */
  	BLOGIC_MCA_BUS,		/* BT-6xx */
  	BLOGIC_EISA_BUS,	/* BT-7xx */
  	BLOGIC_UNKNOWN_BUS,	/* BT-8xx */
  	BLOGIC_PCI_BUS		/* BT-9xx */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
176
177
178
179
180
  };
  
  /*
    Define the possible Host Adapter BIOS Disk Geometry Translations.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
181
182
183
184
185
  enum blogic_bios_diskgeometry {
  	BLOGIC_BIOS_NODISK = 0,
  	BLOGIC_BIOS_DISK64x32 = 1,
  	BLOGIC_BIOS_DISK128x32 = 2,
  	BLOGIC_BIOS_DISK255x63 = 3
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
186
187
188
189
  } PACKED;
  
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
190
191
    Define a 10^18 Statistics Byte Counter data type.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
192
193
194
  struct blogic_byte_count {
  	unsigned int units;
  	unsigned int billions;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
195
196
197
198
199
200
  };
  
  
  /*
    Define the structure for I/O Address and Bus Probing Information.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
201
202
203
204
205
206
207
208
209
  struct blogic_probeinfo {
  	enum blogic_adapter_type adapter_type;
  	enum blogic_adapter_bus_type adapter_bus_type;
  	unsigned long io_addr;
  	unsigned long pci_addr;
  	struct pci_dev *pci_device;
  	unsigned char bus;
  	unsigned char dev;
  	unsigned char irq_ch;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
210
211
212
213
214
  };
  
  /*
    Define the Probe Options.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
215
216
217
218
219
220
221
222
223
224
225
226
227
228
  struct blogic_probe_options {
  	bool noprobe:1;			/* Bit 0 */
  	bool noprobe_isa:1;		/* Bit 1 */
  	bool noprobe_pci:1;		/* Bit 2 */
  	bool nosort_pci:1;		/* Bit 3 */
  	bool multimaster_first:1;	/* Bit 4 */
  	bool flashpoint_first:1;	/* Bit 5 */
  	bool limited_isa:1;		/* Bit 6 */
  	bool probe330:1;		/* Bit 7 */
  	bool probe334:1;		/* Bit 8 */
  	bool probe230:1;		/* Bit 9 */
  	bool probe234:1;		/* Bit 10 */
  	bool probe130:1;		/* Bit 11 */
  	bool probe134:1;		/* Bit 12 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
229
230
231
232
233
  };
  
  /*
    Define the Global Options.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
234
235
236
237
238
  struct blogic_global_options {
  	bool trace_probe:1;	/* Bit 0 */
  	bool trace_hw_reset:1;	/* Bit 1 */
  	bool trace_config:1;	/* Bit 2 */
  	bool trace_err:1;	/* Bit 3 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
239
240
241
242
243
  };
  
  /*
    Define the BusLogic SCSI Host Adapter I/O Register Offsets.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
244
245
246
247
248
249
  #define BLOGIC_CNTRL_REG	0	/* WO register */
  #define BLOGIC_STATUS_REG	0	/* RO register */
  #define BLOGIC_CMD_PARM_REG	1	/* WO register */
  #define BLOGIC_DATAIN_REG	1	/* RO register */
  #define BLOGIC_INT_REG		2	/* RO register */
  #define BLOGIC_GEOMETRY_REG	3	/* RO register */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
250
251
252
253
  
  /*
    Define the structure of the write-only Control Register.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
254
255
  union blogic_cntrl_reg {
  	unsigned char all;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
256
257
  	struct {
  		unsigned char:4;	/* Bits 0-3 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
258
259
260
261
  		bool bus_reset:1;	/* Bit 4 */
  		bool int_reset:1;	/* Bit 5 */
  		bool soft_reset:1;	/* Bit 6 */
  		bool hard_reset:1;	/* Bit 7 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
262
263
264
265
266
267
  	} cr;
  };
  
  /*
    Define the structure of the read-only Status Register.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
268
269
  union blogic_stat_reg {
  	unsigned char all;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
270
  	struct {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
271
272
273
274
275
276
277
278
  		bool cmd_invalid:1;	/* Bit 0 */
  		bool rsvd:1;		/* Bit 1 */
  		bool datain_ready:1;	/* Bit 2 */
  		bool cmd_param_busy:1;	/* Bit 3 */
  		bool adapter_ready:1;	/* Bit 4 */
  		bool init_reqd:1;	/* Bit 5 */
  		bool diag_failed:1;	/* Bit 6 */
  		bool diag_active:1;	/* Bit 7 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
279
280
281
282
283
284
  	} sr;
  };
  
  /*
    Define the structure of the read-only Interrupt Register.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
285
286
  union blogic_int_reg {
  	unsigned char all;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
287
  	struct {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
288
289
290
291
292
293
  		bool mailin_loaded:1;	/* Bit 0 */
  		bool mailout_avail:1;	/* Bit 1 */
  		bool cmd_complete:1;	/* Bit 2 */
  		bool ext_busreset:1;	/* Bit 3 */
  		unsigned char rsvd:3;	/* Bits 4-6 */
  		bool int_valid:1;	/* Bit 7 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
294
295
296
297
298
299
  	} ir;
  };
  
  /*
    Define the structure of the read-only Geometry Register.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
300
301
  union blogic_geo_reg {
  	unsigned char all;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
302
  	struct {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
303
304
  		enum blogic_bios_diskgeometry d0_geo:2;	/* Bits 0-1 */
  		enum blogic_bios_diskgeometry d1_geo:2;	/* Bits 2-3 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
305
  		unsigned char:3;	/* Bits 4-6 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
306
  		bool ext_trans_enable:1;	/* Bit 7 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
307
308
309
310
311
312
  	} gr;
  };
  
  /*
    Define the BusLogic SCSI Host Adapter Command Register Operation Codes.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
  enum blogic_opcode {
  	BLOGIC_TEST_CMP_COMPLETE = 0x00,
  	BLOGIC_INIT_MBOX = 0x01,
  	BLOGIC_EXEC_MBOX_CMD = 0x02,
  	BLOGIC_EXEC_BIOS_CMD = 0x03,
  	BLOGIC_GET_BOARD_ID = 0x04,
  	BLOGIC_ENABLE_OUTBOX_AVAIL_INT = 0x05,
  	BLOGIC_SET_SELECT_TIMEOUT = 0x06,
  	BLOGIC_SET_PREEMPT_TIME = 0x07,
  	BLOGIC_SET_TIMEOFF_BUS = 0x08,
  	BLOGIC_SET_TXRATE = 0x09,
  	BLOGIC_INQ_DEV0TO7 = 0x0A,
  	BLOGIC_INQ_CONFIG = 0x0B,
  	BLOGIC_TGT_MODE = 0x0C,
  	BLOGIC_INQ_SETUPINFO = 0x0D,
  	BLOGIC_WRITE_LOCALRAM = 0x1A,
  	BLOGIC_READ_LOCALRAM = 0x1B,
  	BLOGIC_WRITE_BUSMASTER_FIFO = 0x1C,
  	BLOGIC_READ_BUSMASTER_FIFO = 0x1D,
  	BLOGIC_ECHO_CMDDATA = 0x1F,
  	BLOGIC_ADAPTER_DIAG = 0x20,
  	BLOGIC_SET_OPTIONS = 0x21,
  	BLOGIC_INQ_DEV8TO15 = 0x23,
  	BLOGIC_INQ_DEV = 0x24,
  	BLOGIC_DISABLE_INT = 0x25,
  	BLOGIC_INIT_EXT_MBOX = 0x81,
  	BLOGIC_EXEC_SCS_CMD = 0x83,
  	BLOGIC_INQ_FWVER_D3 = 0x84,
  	BLOGIC_INQ_FWVER_LETTER = 0x85,
  	BLOGIC_INQ_PCI_INFO = 0x86,
  	BLOGIC_INQ_MODELNO = 0x8B,
  	BLOGIC_INQ_SYNC_PERIOD = 0x8C,
  	BLOGIC_INQ_EXTSETUP = 0x8D,
  	BLOGIC_STRICT_RR = 0x8F,
  	BLOGIC_STORE_LOCALRAM = 0x90,
  	BLOGIC_FETCH_LOCALRAM = 0x91,
  	BLOGIC_STORE_TO_EEPROM = 0x92,
  	BLOGIC_LOAD_AUTOSCSICODE = 0x94,
  	BLOGIC_MOD_IOADDR = 0x95,
  	BLOGIC_SETCCB_FMT = 0x96,
  	BLOGIC_WRITE_INQBUF = 0x9A,
  	BLOGIC_READ_INQBUF = 0x9B,
  	BLOGIC_FLASH_LOAD = 0xA7,
  	BLOGIC_READ_SCAMDATA = 0xA8,
  	BLOGIC_WRITE_SCAMDATA = 0xA9
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
358
359
360
361
362
  };
  
  /*
    Define the Inquire Board ID reply structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
363
364
365
366
367
  struct blogic_board_id {
  	unsigned char type;		/* Byte 0 */
  	unsigned char custom_features;	/* Byte 1 */
  	unsigned char fw_ver_digit1;	/* Byte 2 */
  	unsigned char fw_ver_digit2;	/* Byte 3 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
368
369
370
371
372
  };
  
  /*
    Define the Inquire Configuration reply structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
373
  struct blogic_config {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
374
  	unsigned char:5;	/* Byte 0 Bits 0-4 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
375
376
377
378
379
380
381
  	bool dma_ch5:1;		/* Byte 0 Bit 5 */
  	bool dma_ch6:1;		/* Byte 0 Bit 6 */
  	bool dma_ch7:1;		/* Byte 0 Bit 7 */
  	bool irq_ch9:1;		/* Byte 1 Bit 0 */
  	bool irq_ch10:1;	/* Byte 1 Bit 1 */
  	bool irq_ch11:1;	/* Byte 1 Bit 2 */
  	bool irq_ch12:1;	/* Byte 1 Bit 3 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
382
  	unsigned char:1;	/* Byte 1 Bit 4 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
383
384
  	bool irq_ch14:1;	/* Byte 1 Bit 5 */
  	bool irq_ch15:1;	/* Byte 1 Bit 6 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
385
  	unsigned char:1;	/* Byte 1 Bit 7 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
386
  	unsigned char id:4;	/* Byte 2 Bits 0-3 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
387
388
389
390
391
392
  	unsigned char:4;	/* Byte 2 Bits 4-7 */
  };
  
  /*
    Define the Inquire Setup Information reply structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
393
394
395
396
  struct blogic_syncval {
  	unsigned char offset:4;		/* Bits 0-3 */
  	unsigned char tx_period:3;	/* Bits 4-6 */
  	bool sync:1;			/* Bit 7 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
397
  };
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
  struct blogic_setup_info {
  	bool sync:1;				/* Byte 0 Bit 0 */
  	bool parity:1;				/* Byte 0 Bit 1 */
  	unsigned char:6;			/* Byte 0 Bits 2-7 */
  	unsigned char tx_rate;			/* Byte 1 */
  	unsigned char preempt_time;		/* Byte 2 */
  	unsigned char timeoff_bus;		/* Byte 3 */
  	unsigned char mbox_count;		/* Byte 4 */
  	unsigned char mbox_addr[3];		/* Bytes 5-7 */
  	struct blogic_syncval sync0to7[8];	/* Bytes 8-15 */
  	unsigned char disconnect_ok0to7;	/* Byte 16 */
  	unsigned char sig;			/* Byte 17 */
  	unsigned char char_d;			/* Byte 18 */
  	unsigned char bus_type;			/* Byte 19 */
  	unsigned char wide_tx_ok0to7;		/* Byte 20 */
  	unsigned char wide_tx_active0to7;	/* Byte 21 */
  	struct blogic_syncval sync8to15[8];	/* Bytes 22-29 */
  	unsigned char disconnect_ok8to15;	/* Byte 30 */
  	unsigned char:8;			/* Byte 31 */
  	unsigned char wide_tx_ok8to15;		/* Byte 32 */
  	unsigned char wide_tx_active8to15;	/* Byte 33 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
419
420
421
422
423
  };
  
  /*
    Define the Initialize Extended Mailbox request structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
424
425
426
  struct blogic_extmbox_req {
  	unsigned char mbox_count;	/* Byte 0 */
  	u32 base_mbox_addr;		/* Bytes 1-4 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
427
428
429
430
431
432
433
434
  } PACKED;
  
  
  /*
    Define the Inquire PCI Host Adapter Information reply type.  The ISA
    Compatible I/O Port values are defined here and are also used with
    the Modify I/O Address command.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
435
436
437
438
439
440
441
442
443
  enum blogic_isa_ioport {
  	BLOGIC_IO_330 = 0,
  	BLOGIC_IO_334 = 1,
  	BLOGIC_IO_230 = 2,
  	BLOGIC_IO_234 = 3,
  	BLOGIC_IO_130 = 4,
  	BLOGIC_IO_134 = 5,
  	BLOGIC_IO_DISABLE = 6,
  	BLOGIC_IO_DISABLE2 = 7
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
444
  } PACKED;
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
445
446
447
448
449
450
451
452
453
454
455
  struct blogic_adapter_info {
  	enum blogic_isa_ioport isa_port;	/* Byte 0 */
  	unsigned char irq_ch;		/* Byte 1 */
  	bool low_term:1;		/* Byte 2 Bit 0 */
  	bool high_term:1;		/* Byte 2 Bit 1 */
  	unsigned char:2;		/* Byte 2 Bits 2-3 */
  	bool JP1:1;			/* Byte 2 Bit 4 */
  	bool JP2:1;			/* Byte 2 Bit 5 */
  	bool JP3:1;			/* Byte 2 Bit 6 */
  	bool genericinfo_valid:1;	/* Byte 2 Bit 7 */
  	unsigned char:8;		/* Byte 3 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
456
457
458
459
460
  };
  
  /*
    Define the Inquire Extended Setup Information reply structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
461
462
463
464
465
466
  struct blogic_ext_setup {
  	unsigned char bus_type;		/* Byte 0 */
  	unsigned char bios_addr;	/* Byte 1 */
  	unsigned short sg_limit;	/* Bytes 2-3 */
  	unsigned char mbox_count;	/* Byte 4 */
  	u32 base_mbox_addr;		/* Bytes 5-8 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
467
468
  	struct {
  		unsigned char:2;	/* Byte 9 Bits 0-1 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
469
  		bool fast_on_eisa:1;	/* Byte 9 Bit 2 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
470
  		unsigned char:3;	/* Byte 9 Bits 3-5 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
471
  		bool level_int:1;	/* Byte 9 Bit 6 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
472
  		unsigned char:1;	/* Byte 9 Bit 7 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
473
474
475
476
477
478
479
480
  	} misc;
  	unsigned char fw_rev[3];	/* Bytes 10-12 */
  	bool wide:1;			/* Byte 13 Bit 0 */
  	bool differential:1;		/* Byte 13 Bit 1 */
  	bool scam:1;			/* Byte 13 Bit 2 */
  	bool ultra:1;			/* Byte 13 Bit 3 */
  	bool smart_term:1;		/* Byte 13 Bit 4 */
  	unsigned char:3;		/* Byte 13 Bits 5-7 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
481
482
483
484
485
  } PACKED;
  
  /*
    Define the Enable Strict Round Robin Mode request type.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
486
487
488
  enum blogic_rr_req {
  	BLOGIC_AGGRESSIVE_RR = 0,
  	BLOGIC_STRICT_RR_MODE = 1
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
489
490
491
492
493
494
  } PACKED;
  
  
  /*
    Define the Fetch Host Adapter Local RAM request type.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
495
496
  #define BLOGIC_BIOS_BASE		0
  #define BLOGIC_AUTOSCSI_BASE		64
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
497

839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
498
499
500
  struct blogic_fetch_localram {
  	unsigned char offset;	/* Byte 0 */
  	unsigned char count;	/* Byte 1 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
501
502
503
504
505
  };
  
  /*
    Define the Host Adapter Local RAM AutoSCSI structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
  struct blogic_autoscsi {
  	unsigned char factory_sig[2];		/* Bytes 0-1 */
  	unsigned char info_bytes;		/* Byte 2 */
  	unsigned char adapter_type[6];		/* Bytes 3-8 */
  	unsigned char:8;			/* Byte 9 */
  	bool floppy:1;				/* Byte 10 Bit 0 */
  	bool floppy_sec:1;			/* Byte 10 Bit 1 */
  	bool level_int:1;			/* Byte 10 Bit 2 */
  	unsigned char:2;			/* Byte 10 Bits 3-4 */
  	unsigned char systemram_bios:3;		/* Byte 10 Bits 5-7 */
  	unsigned char dma_ch:7;			/* Byte 11 Bits 0-6 */
  	bool dma_autoconf:1;			/* Byte 11 Bit 7 */
  	unsigned char irq_ch:7;			/* Byte 12 Bits 0-6 */
  	bool irq_autoconf:1;			/* Byte 12 Bit 7 */
  	unsigned char dma_tx_rate;		/* Byte 13 */
  	unsigned char scsi_id;			/* Byte 14 */
  	bool low_term:1;			/* Byte 15 Bit 0 */
  	bool parity:1;				/* Byte 15 Bit 1 */
  	bool high_term:1;			/* Byte 15 Bit 2 */
  	bool noisy_cable:1;			/* Byte 15 Bit 3 */
  	bool fast_sync_neg:1;			/* Byte 15 Bit 4 */
  	bool reset_enabled:1;			/* Byte 15 Bit 5 */
  	bool:1;					/* Byte 15 Bit 6 */
  	bool active_negation:1;			/* Byte 15 Bit 7 */
  	unsigned char bus_on_delay;		/* Byte 16 */
  	unsigned char bus_off_delay;		/* Byte 17 */
  	bool bios_enabled:1;			/* Byte 18 Bit 0 */
  	bool int19_redir_enabled:1;		/* Byte 18 Bit 1 */
  	bool ext_trans_enable:1;		/* Byte 18 Bit 2 */
  	bool removable_as_fixed:1;		/* Byte 18 Bit 3 */
  	bool:1;					/* Byte 18 Bit 4 */
  	bool morethan2_drives:1;		/* Byte 18 Bit 5 */
  	bool bios_int:1;			/* Byte 18 Bit 6 */
  	bool floptical:1;			/* Byte 19 Bit 7 */
  	unsigned short dev_enabled;		/* Bytes 19-20 */
  	unsigned short wide_ok;			/* Bytes 21-22 */
  	unsigned short fast_ok;			/* Bytes 23-24 */
  	unsigned short sync_ok;			/* Bytes 25-26 */
  	unsigned short discon_ok;		/* Bytes 27-28 */
  	unsigned short send_start_unit;		/* Bytes 29-30 */
  	unsigned short ignore_bios_scan;	/* Bytes 31-32 */
  	unsigned char pci_int_pin:2;		/* Byte 33 Bits 0-1 */
  	unsigned char adapter_ioport:2;		/* Byte 33 Bits 2-3 */
  	bool strict_rr_enabled:1;		/* Byte 33 Bit 4 */
  	bool vesabus_33mhzplus:1;		/* Byte 33 Bit 5 */
  	bool vesa_burst_write:1;		/* Byte 33 Bit 6 */
  	bool vesa_burst_read:1;			/* Byte 33 Bit 7 */
  	unsigned short ultra_ok;		/* Bytes 34-35 */
  	unsigned int:32;			/* Bytes 36-39 */
  	unsigned char:8;			/* Byte 40 */
  	unsigned char autoscsi_maxlun;		/* Byte 41 */
  	bool:1;					/* Byte 42 Bit 0 */
  	bool scam_dominant:1;			/* Byte 42 Bit 1 */
  	bool scam_enabled:1;			/* Byte 42 Bit 2 */
  	bool scam_lev2:1;			/* Byte 42 Bit 3 */
  	unsigned char:4;			/* Byte 42 Bits 4-7 */
  	bool int13_exten:1;			/* Byte 43 Bit 0 */
  	bool:1;					/* Byte 43 Bit 1 */
  	bool cd_boot:1;				/* Byte 43 Bit 2 */
  	unsigned char:5;			/* Byte 43 Bits 3-7 */
  	unsigned char boot_id:4;		/* Byte 44 Bits 0-3 */
  	unsigned char boot_ch:4;		/* Byte 44 Bits 4-7 */
  	unsigned char force_scan_order:1;	/* Byte 45 Bit 0 */
  	unsigned char:7;			/* Byte 45 Bits 1-7 */
  	unsigned short nontagged_to_alt_ok;	/* Bytes 46-47 */
  	unsigned short reneg_sync_on_check;	/* Bytes 48-49 */
  	unsigned char rsvd[10];			/* Bytes 50-59 */
  	unsigned char manuf_diag[2];		/* Bytes 60-61 */
  	unsigned short cksum;			/* Bytes 62-63 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
575
576
577
578
579
  } PACKED;
  
  /*
    Define the Host Adapter Local RAM Auto SCSI Byte 45 structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
580
581
  struct blogic_autoscsi_byte45 {
  	unsigned char force_scan_order:1;	/* Bit 0 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
582
583
584
585
586
587
  	unsigned char:7;	/* Bits 1-7 */
  };
  
  /*
    Define the Host Adapter Local RAM BIOS Drive Map Byte structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
588
  #define BLOGIC_BIOS_DRVMAP		17
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
589

839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
590
591
592
593
594
  struct blogic_bios_drvmap {
  	unsigned char tgt_idbit3:1;			/* Bit 0 */
  	unsigned char:2;				/* Bits 1-2 */
  	enum blogic_bios_diskgeometry diskgeom:2;	/* Bits 3-4 */
  	unsigned char tgt_id:3;				/* Bits 5-7 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
595
596
597
598
599
600
  };
  
  /*
    Define the Set CCB Format request type.  Extended LUN Format CCBs are
    necessary to support more than 8 Logical Units per Target Device.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
601
602
603
  enum blogic_setccb_fmt {
  	BLOGIC_LEGACY_LUN_CCB = 0,
  	BLOGIC_EXT_LUN_CCB = 1
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
604
605
606
607
608
  } PACKED;
  
  /*
    Define the Outgoing Mailbox Action Codes.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
609
610
611
612
  enum blogic_action {
  	BLOGIC_OUTBOX_FREE = 0x00,
  	BLOGIC_MBOX_START = 0x01,
  	BLOGIC_MBOX_ABORT = 0x02
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
613
614
615
616
617
618
619
620
  } PACKED;
  
  
  /*
    Define the Incoming Mailbox Completion Codes.  The MultiMaster Firmware
    only uses codes 0 - 4.  The FlashPoint SCCB Manager has no mailboxes, so
    completion codes are stored in the CCB; it only uses codes 1, 2, 4, and 5.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
621
622
623
624
625
626
627
  enum blogic_cmplt_code {
  	BLOGIC_INBOX_FREE = 0x00,
  	BLOGIC_CMD_COMPLETE_GOOD = 0x01,
  	BLOGIC_CMD_ABORT_BY_HOST = 0x02,
  	BLOGIC_CMD_NOTFOUND = 0x03,
  	BLOGIC_CMD_COMPLETE_ERROR = 0x04,
  	BLOGIC_INVALID_CCB = 0x05
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
628
629
630
631
632
  } PACKED;
  
  /*
    Define the Command Control Block (CCB) Opcodes.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
633
634
635
636
637
638
639
  enum blogic_ccb_opcode {
  	BLOGIC_INITIATOR_CCB = 0x00,
  	BLOGIC_TGT_CCB = 0x01,
  	BLOGIC_INITIATOR_CCB_SG = 0x02,
  	BLOGIC_INITIATOR_CCBB_RESIDUAL = 0x03,
  	BLOGIC_INITIATOR_CCB_SG_RESIDUAL = 0x04,
  	BLOGIC_BDR = 0x81
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
640
641
642
643
644
645
  } PACKED;
  
  
  /*
    Define the CCB Data Direction Codes.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
646
647
648
649
650
  enum blogic_datadir {
  	BLOGIC_UNCHECKED_TX = 0,
  	BLOGIC_DATAIN_CHECKED = 1,
  	BLOGIC_DATAOUT_CHECKED = 2,
  	BLOGIC_NOTX = 3
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
651
652
653
654
655
656
657
  };
  
  
  /*
    Define the Host Adapter Status Codes.  The MultiMaster Firmware does not
    return status code 0x0C; it uses 0x12 for both overruns and underruns.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
  enum blogic_adapter_status {
  	BLOGIC_CMD_CMPLT_NORMAL = 0x00,
  	BLOGIC_LINK_CMD_CMPLT = 0x0A,
  	BLOGIC_LINK_CMD_CMPLT_FLAG = 0x0B,
  	BLOGIC_DATA_UNDERRUN = 0x0C,
  	BLOGIC_SELECT_TIMEOUT = 0x11,
  	BLOGIC_DATA_OVERRUN = 0x12,
  	BLOGIC_NOEXPECT_BUSFREE = 0x13,
  	BLOGIC_INVALID_BUSPHASE = 0x14,
  	BLOGIC_INVALID_OUTBOX_CODE = 0x15,
  	BLOGIC_INVALID_CMD_CODE = 0x16,
  	BLOGIC_LINKCCB_BADLUN = 0x17,
  	BLOGIC_BAD_CMD_PARAM = 0x1A,
  	BLOGIC_AUTOREQSENSE_FAIL = 0x1B,
  	BLOGIC_TAGQUEUE_REJECT = 0x1C,
  	BLOGIC_BAD_MSG_RCVD = 0x1D,
  	BLOGIC_HW_FAIL = 0x20,
  	BLOGIC_NORESPONSE_TO_ATN = 0x21,
  	BLOGIC_HW_RESET = 0x22,
  	BLOGIC_RST_FROM_OTHERDEV = 0x23,
  	BLOGIC_BAD_RECONNECT = 0x24,
  	BLOGIC_HW_BDR = 0x25,
  	BLOGIC_ABRT_QUEUE = 0x26,
  	BLOGIC_ADAPTER_SW_ERROR = 0x27,
  	BLOGIC_HW_TIMEOUT = 0x30,
  	BLOGIC_PARITY_ERR = 0x34
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
684
685
686
687
688
689
  } PACKED;
  
  
  /*
    Define the SCSI Target Device Status Codes.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
690
691
692
693
  enum blogic_tgt_status {
  	BLOGIC_OP_GOOD = 0x00,
  	BLOGIC_CHECKCONDITION = 0x02,
  	BLOGIC_DEVBUSY = 0x08
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
694
695
696
697
698
  } PACKED;
  
  /*
    Define the Queue Tag Codes.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
699
700
701
702
703
  enum blogic_queuetag {
  	BLOGIC_SIMPLETAG = 0,
  	BLOGIC_HEADTAG = 1,
  	BLOGIC_ORDEREDTAG = 2,
  	BLOGIC_RSVDTAG = 3
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
704
705
706
707
708
  };
  
  /*
    Define the SCSI Command Descriptor Block (CDB).
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
709
  #define BLOGIC_CDB_MAXLEN			12
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
710
711
712
713
714
715
  
  
  /*
    Define the Scatter/Gather Segment structure required by the MultiMaster
    Firmware Interface and the FlashPoint SCCB Manager.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
716
717
718
  struct blogic_sg_seg {
  	u32 segbytes;	/* Bytes 0-3 */
  	u32 segdata;	/* Bytes 4-7 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
719
720
721
722
723
  };
  
  /*
    Define the Driver CCB Status Codes.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
724
725
726
727
728
  enum blogic_ccb_status {
  	BLOGIC_CCB_FREE = 0,
  	BLOGIC_CCB_ACTIVE = 1,
  	BLOGIC_CCB_COMPLETE = 2,
  	BLOGIC_CCB_RESET = 3
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
  } PACKED;
  
  
  /*
    Define the 32 Bit Mode Command Control Block (CCB) structure.  The first 40
    bytes are defined by and common to both the MultiMaster Firmware and the
    FlashPoint SCCB Manager.  The next 60 bytes are defined by the FlashPoint
    SCCB Manager.  The remaining components are defined by the Linux BusLogic
    Driver.  Extended LUN Format CCBs differ from Legacy LUN Format 32 Bit Mode
    CCBs only in having the TagEnable and QueueTag fields moved from byte 17 to
    byte 1, and the Logical Unit field in byte 17 expanded to 6 bits.  In theory,
    Extended LUN Format CCBs can support up to 64 Logical Units, but in practice
    many devices will respond improperly to Logical Units between 32 and 63, and
    the SCSI-2 specification defines Bit 5 as LUNTAR.  Extended LUN Format CCBs
    are used by recent versions of the MultiMaster Firmware, as well as by the
    FlashPoint SCCB Manager; the FlashPoint SCCB Manager only supports 32 Logical
    Units.  Since 64 Logical Units are unlikely to be needed in practice, and
    since they are problematic for the above reasons, and since limiting them to
    5 bits simplifies the CCB structure definition, this driver only supports
    32 Logical Units per Target Device.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
750
  struct blogic_ccb {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
751
752
753
  	/*
  	   MultiMaster Firmware and FlashPoint SCCB Manager Common Portion.
  	 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
754
755
756
757
758
759
760
761
  	enum blogic_ccb_opcode opcode;			/* Byte 0 */
  	unsigned char:3;				/* Byte 1 Bits 0-2 */
  	enum blogic_datadir datadir:2;			/* Byte 1 Bits 3-4 */
  	bool tag_enable:1;				/* Byte 1 Bit 5 */
  	enum blogic_queuetag queuetag:2;		/* Byte 1 Bits 6-7 */
  	unsigned char cdblen;				/* Byte 2 */
  	unsigned char sense_datalen;			/* Byte 3 */
  	u32 datalen;					/* Bytes 4-7 */
391e2f256   Khalid Aziz   [SCSI] BusLogic: ...
762
  	void *data;					/* Bytes 8-11 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
763
764
765
766
767
768
769
770
771
772
773
  	unsigned char:8;				/* Byte 12 */
  	unsigned char:8;				/* Byte 13 */
  	enum blogic_adapter_status adapter_status;	/* Byte 14 */
  	enum blogic_tgt_status tgt_status;		/* Byte 15 */
  	unsigned char tgt_id;				/* Byte 16 */
  	unsigned char lun:5;				/* Byte 17 Bits 0-4 */
  	bool legacytag_enable:1;			/* Byte 17 Bit 5 */
  	enum blogic_queuetag legacy_tag:2;		/* Byte 17 Bits 6-7 */
  	unsigned char cdb[BLOGIC_CDB_MAXLEN];		/* Bytes 18-29 */
  	unsigned char:8;				/* Byte 30 */
  	unsigned char:8;				/* Byte 31 */
391e2f256   Khalid Aziz   [SCSI] BusLogic: ...
774
  	u32 rsvd_int;					/* Bytes 32-35 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
775
  	u32 sensedata;					/* Bytes 36-39 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
776
777
778
  	/*
  	   FlashPoint SCCB Manager Defined Portion.
  	 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
779
780
781
  	void (*callback) (struct blogic_ccb *);		/* Bytes 40-43 */
  	u32 base_addr;					/* Bytes 44-47 */
  	enum blogic_cmplt_code comp_code;		/* Byte 48 */
78b4b05db   Matthew Wilcox   [SCSI] BusLogic: ...
782
  #ifdef CONFIG_SCSI_FLASHPOINT
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
783
  	unsigned char:8;				/* Byte 49 */
391e2f256   Khalid Aziz   [SCSI] BusLogic: ...
784
785
786
787
788
  	u16 os_flags;					/* Bytes 50-51 */
  	unsigned char private[24];			/* Bytes 52-99 */
  	void *rsvd1;
  	void *rsvd2;
  	unsigned char private2[16];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
789
790
791
792
  #endif
  	/*
  	   BusLogic Linux Driver Defined Portion.
  	 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
793
794
795
796
797
798
799
800
801
802
  	dma_addr_t allocgrp_head;
  	unsigned int allocgrp_size;
  	u32 dma_handle;
  	enum blogic_ccb_status status;
  	unsigned long serial;
  	struct scsi_cmnd *command;
  	struct blogic_adapter *adapter;
  	struct blogic_ccb *next;
  	struct blogic_ccb *next_all;
  	struct blogic_sg_seg sglist[BLOGIC_SG_LIMIT];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
803
804
805
806
807
  };
  
  /*
    Define the 32 Bit Mode Outgoing Mailbox structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
808
809
  struct blogic_outbox {
  	u32 ccb;			/* Bytes 0-3 */
391e2f256   Khalid Aziz   [SCSI] BusLogic: ...
810
  	u32:24;				/* Bytes 4-6 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
811
  	enum blogic_action action;	/* Byte 7 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
812
813
814
815
816
  };
  
  /*
    Define the 32 Bit Mode Incoming Mailbox structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
817
  struct blogic_inbox {
391e2f256   Khalid Aziz   [SCSI] BusLogic: ...
818
  	u32 ccb;					/* Bytes 0-3 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
819
  	enum blogic_adapter_status adapter_status;	/* Byte 4 */
391e2f256   Khalid Aziz   [SCSI] BusLogic: ...
820
821
822
  	enum blogic_tgt_status tgt_status;		/* Byte 5 */
  	unsigned char:8;				/* Byte 6 */
  	enum blogic_cmplt_code comp_code;		/* Byte 7 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
823
824
825
826
827
828
  };
  
  
  /*
    Define the BusLogic Driver Options structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
829
830
831
832
833
834
835
  struct blogic_drvr_options {
  	unsigned short tagq_ok;
  	unsigned short tagq_ok_mask;
  	unsigned short bus_settle_time;
  	unsigned short stop_tgt_inquiry;
  	unsigned char common_qdepth;
  	unsigned char qdepth[BLOGIC_MAXDEV];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
836
837
838
839
840
  };
  
  /*
    Define the Host Adapter Target Flags structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
841
842
843
844
845
846
847
848
  struct blogic_tgt_flags {
  	bool tgt_exists:1;
  	bool tagq_ok:1;
  	bool wide_ok:1;
  	bool tagq_active:1;
  	bool wide_active:1;
  	bool cmd_good:1;
  	bool tgt_info_in:1;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
849
850
851
852
853
  };
  
  /*
    Define the Host Adapter Target Statistics structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
  #define BLOGIC_SZ_BUCKETS			10
  
  struct blogic_tgt_stats {
  	unsigned int cmds_tried;
  	unsigned int cmds_complete;
  	unsigned int read_cmds;
  	unsigned int write_cmds;
  	struct blogic_byte_count bytesread;
  	struct blogic_byte_count byteswritten;
  	unsigned int read_sz_buckets[BLOGIC_SZ_BUCKETS];
  	unsigned int write_sz_buckets[BLOGIC_SZ_BUCKETS];
  	unsigned short aborts_request;
  	unsigned short aborts_tried;
  	unsigned short aborts_done;
  	unsigned short bdr_request;
  	unsigned short bdr_tried;
  	unsigned short bdr_done;
20961065a   Colin Ian King   scsi: BusLogic: f...
871
  	unsigned short adapter_reset_req;
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
872
873
  	unsigned short adapter_reset_attempt;
  	unsigned short adapter_reset_done;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
874
875
876
877
878
  };
  
  /*
    Define the FlashPoint Card Handle data type.
  */
391e2f256   Khalid Aziz   [SCSI] BusLogic: ...
879
  #define FPOINT_BADCARD_HANDLE		0xFFFFFFFFL
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
880
881
882
883
884
885
  
  
  /*
    Define the FlashPoint Information structure.  This structure is defined
    by the FlashPoint SCCB Manager.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
886
887
888
889
890
891
  struct fpoint_info {
  	u32 base_addr;				/* Bytes 0-3 */
  	bool present;				/* Byte 4 */
  	unsigned char irq_ch;			/* Byte 5 */
  	unsigned char scsi_id;			/* Byte 6 */
  	unsigned char scsi_lun;			/* Byte 7 */
391e2f256   Khalid Aziz   [SCSI] BusLogic: ...
892
893
894
895
896
897
  	u16 fw_rev;				/* Bytes 8-9 */
  	u16 sync_ok;				/* Bytes 10-11 */
  	u16 fast_ok;				/* Bytes 12-13 */
  	u16 ultra_ok;				/* Bytes 14-15 */
  	u16 discon_ok;				/* Bytes 16-17 */
  	u16 wide_ok;				/* Bytes 18-19 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
  	bool parity:1;				/* Byte 20 Bit 0 */
  	bool wide:1;				/* Byte 20 Bit 1 */
  	bool softreset:1;			/* Byte 20 Bit 2 */
  	bool ext_trans_enable:1;		/* Byte 20 Bit 3 */
  	bool low_term:1;			/* Byte 20 Bit 4 */
  	bool high_term:1;			/* Byte 20 Bit 5 */
  	bool report_underrun:1;			/* Byte 20 Bit 6 */
  	bool scam_enabled:1;			/* Byte 20 Bit 7 */
  	bool scam_lev2:1;			/* Byte 21 Bit 0 */
  	unsigned char:7;			/* Byte 21 Bits 1-7 */
  	unsigned char family;			/* Byte 22 */
  	unsigned char bus_type;			/* Byte 23 */
  	unsigned char model[3];			/* Bytes 24-26 */
  	unsigned char relative_cardnum;		/* Byte 27 */
  	unsigned char rsvd[4];			/* Bytes 28-31 */
391e2f256   Khalid Aziz   [SCSI] BusLogic: ...
913
  	u32 os_rsvd;				/* Bytes 32-35 */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
914
  	unsigned char translation_info[4];	/* Bytes 36-39 */
391e2f256   Khalid Aziz   [SCSI] BusLogic: ...
915
916
  	u32 rsvd2[5];				/* Bytes 40-59 */
  	u32 sec_range;				/* Bytes 60-63 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
917
918
919
920
921
  };
  
  /*
    Define the BusLogic Driver Host Adapter structure.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
  struct blogic_adapter {
  	struct Scsi_Host *scsi_host;
  	struct pci_dev *pci_device;
  	enum blogic_adapter_type adapter_type;
  	enum blogic_adapter_bus_type adapter_bus_type;
  	unsigned long io_addr;
  	unsigned long pci_addr;
  	unsigned short addr_count;
  	unsigned char host_no;
  	unsigned char model[9];
  	unsigned char fw_ver[6];
  	unsigned char full_model[18];
  	unsigned char bus;
  	unsigned char dev;
  	unsigned char irq_ch;
  	unsigned char dma_ch;
  	unsigned char scsi_id;
  	bool irq_acquired:1;
  	bool dma_chan_acquired:1;
  	bool ext_trans_enable:1;
  	bool parity:1;
  	bool reset_enabled:1;
  	bool level_int:1;
  	bool wide:1;
  	bool differential:1;
  	bool scam:1;
  	bool ultra:1;
  	bool ext_lun:1;
  	bool terminfo_valid:1;
  	bool low_term:1;
  	bool high_term:1;
  	bool need_bouncebuf:1;
  	bool strict_rr:1;
  	bool scam_enabled:1;
  	bool scam_lev2:1;
  	bool adapter_initd:1;
  	bool adapter_extreset:1;
  	bool adapter_intern_err:1;
  	bool processing_ccbs;
  	volatile bool adapter_cmd_complete;
  	unsigned short adapter_sglimit;
  	unsigned short drvr_sglimit;
  	unsigned short maxdev;
  	unsigned short maxlun;
  	unsigned short mbox_count;
  	unsigned short initccbs;
  	unsigned short inc_ccbs;
  	unsigned short alloc_ccbs;
  	unsigned short drvr_qdepth;
  	unsigned short adapter_qdepth;
  	unsigned short untag_qdepth;
  	unsigned short common_qdepth;
  	unsigned short bus_settle_time;
  	unsigned short sync_ok;
  	unsigned short fast_ok;
  	unsigned short ultra_ok;
  	unsigned short wide_ok;
  	unsigned short discon_ok;
  	unsigned short tagq_ok;
  	unsigned short ext_resets;
  	unsigned short adapter_intern_errors;
  	unsigned short tgt_count;
  	unsigned short msgbuflen;
  	u32 bios_addr;
  	struct blogic_drvr_options *drvr_opts;
  	struct fpoint_info fpinfo;
391e2f256   Khalid Aziz   [SCSI] BusLogic: ...
988
  	void *cardhandle;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
989
  	struct list_head host_list;
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
  	struct blogic_ccb *all_ccbs;
  	struct blogic_ccb *free_ccbs;
  	struct blogic_ccb *firstccb;
  	struct blogic_ccb *lastccb;
  	struct blogic_ccb *bdr_pend[BLOGIC_MAXDEV];
  	struct blogic_tgt_flags tgt_flags[BLOGIC_MAXDEV];
  	unsigned char qdepth[BLOGIC_MAXDEV];
  	unsigned char sync_period[BLOGIC_MAXDEV];
  	unsigned char sync_offset[BLOGIC_MAXDEV];
  	unsigned char active_cmds[BLOGIC_MAXDEV];
  	unsigned int cmds_since_rst[BLOGIC_MAXDEV];
  	unsigned long last_seqpoint[BLOGIC_MAXDEV];
  	unsigned long last_resettried[BLOGIC_MAXDEV];
  	unsigned long last_resetdone[BLOGIC_MAXDEV];
  	struct blogic_outbox *first_outbox;
  	struct blogic_outbox *last_outbox;
  	struct blogic_outbox *next_outbox;
  	struct blogic_inbox *first_inbox;
  	struct blogic_inbox *last_inbox;
  	struct blogic_inbox *next_inbox;
  	struct blogic_tgt_stats tgt_stats[BLOGIC_MAXDEV];
  	unsigned char *mbox_space;
  	dma_addr_t mbox_space_handle;
  	unsigned int mbox_sz;
  	unsigned long ccb_offset;
  	char msgbuf[BLOGIC_MSGBUF_SIZE];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1016
1017
1018
1019
1020
  };
  
  /*
    Define a structure for the BIOS Disk Parameters.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1021
1022
1023
1024
  struct bios_diskparam {
  	int heads;
  	int sectors;
  	int cylinders;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1025
1026
1027
1028
1029
  };
  
  /*
    Define a structure for the SCSI Inquiry command results.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
  struct scsi_inquiry {
  	unsigned char devtype:5;	/* Byte 0 Bits 0-4 */
  	unsigned char dev_qual:3;	/* Byte 0 Bits 5-7 */
  	unsigned char dev_modifier:7;	/* Byte 1 Bits 0-6 */
  	bool rmb:1;			/* Byte 1 Bit 7 */
  	unsigned char ansi_ver:3;	/* Byte 2 Bits 0-2 */
  	unsigned char ecma_ver:3;	/* Byte 2 Bits 3-5 */
  	unsigned char iso_ver:2;	/* Byte 2 Bits 6-7 */
  	unsigned char resp_fmt:4;	/* Byte 3 Bits 0-3 */
  	unsigned char:2;		/* Byte 3 Bits 4-5 */
  	bool TrmIOP:1;			/* Byte 3 Bit 6 */
  	bool AENC:1;			/* Byte 3 Bit 7 */
  	unsigned char addl_len;		/* Byte 4 */
  	unsigned char:8;		/* Byte 5 */
  	unsigned char:8;		/* Byte 6 */
  	bool SftRe:1;			/* Byte 7 Bit 0 */
  	bool CmdQue:1;			/* Byte 7 Bit 1 */
  	bool:1;				/* Byte 7 Bit 2 */
  	bool linked:1;			/* Byte 7 Bit 3 */
  	bool sync:1;			/* Byte 7 Bit 4 */
  	bool WBus16:1;			/* Byte 7 Bit 5 */
  	bool WBus32:1;			/* Byte 7 Bit 6 */
  	bool RelAdr:1;			/* Byte 7 Bit 7 */
  	unsigned char vendor[8];	/* Bytes 8-15 */
  	unsigned char product[16];	/* Bytes 16-31 */
  	unsigned char product_rev[4];	/* Bytes 32-35 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1056
1057
1058
1059
1060
1061
1062
  };
  
  
  /*
    Define functions to provide an abstraction for reading and writing the
    Host Adapter I/O Registers.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1063
  static inline void blogic_busreset(struct blogic_adapter *adapter)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1064
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1065
1066
1067
1068
  	union blogic_cntrl_reg cr;
  	cr.all = 0;
  	cr.cr.bus_reset = true;
  	outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1069
  }
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1070
  static inline void blogic_intreset(struct blogic_adapter *adapter)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1071
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1072
1073
1074
1075
  	union blogic_cntrl_reg cr;
  	cr.all = 0;
  	cr.cr.int_reset = true;
  	outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1076
  }
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1077
  static inline void blogic_softreset(struct blogic_adapter *adapter)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1078
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1079
1080
1081
1082
  	union blogic_cntrl_reg cr;
  	cr.all = 0;
  	cr.cr.soft_reset = true;
  	outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1083
  }
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1084
  static inline void blogic_hardreset(struct blogic_adapter *adapter)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1085
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1086
1087
1088
1089
  	union blogic_cntrl_reg cr;
  	cr.all = 0;
  	cr.cr.hard_reset = true;
  	outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1090
  }
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1091
  static inline unsigned char blogic_rdstatus(struct blogic_adapter *adapter)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1092
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1093
  	return inb(adapter->io_addr + BLOGIC_STATUS_REG);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1094
  }
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1095
1096
  static inline void blogic_setcmdparam(struct blogic_adapter *adapter,
  					unsigned char value)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1097
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1098
  	outb(value, adapter->io_addr + BLOGIC_CMD_PARM_REG);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1099
  }
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1100
  static inline unsigned char blogic_rddatain(struct blogic_adapter *adapter)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1101
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1102
  	return inb(adapter->io_addr + BLOGIC_DATAIN_REG);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1103
  }
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1104
  static inline unsigned char blogic_rdint(struct blogic_adapter *adapter)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1105
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1106
  	return inb(adapter->io_addr + BLOGIC_INT_REG);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1107
  }
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1108
  static inline unsigned char blogic_rdgeom(struct blogic_adapter *adapter)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1109
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1110
  	return inb(adapter->io_addr + BLOGIC_GEOMETRY_REG);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1111
1112
1113
  }
  
  /*
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1114
    blogic_execmbox issues an Execute Mailbox Command, which
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1115
1116
1117
    notifies the Host Adapter that an entry has been made in an Outgoing
    Mailbox.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1118
  static inline void blogic_execmbox(struct blogic_adapter *adapter)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1119
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1120
  	blogic_setcmdparam(adapter, BLOGIC_EXEC_MBOX_CMD);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1121
1122
1123
  }
  
  /*
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1124
    blogic_delay waits for Seconds to elapse.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1125
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1126
  static inline void blogic_delay(int seconds)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1127
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1128
  	mdelay(1000 * seconds);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1129
1130
1131
  }
  
  /*
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1132
    virt_to_32bit_virt maps between Kernel Virtual Addresses and
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1133
1134
1135
    32 bit Kernel Virtual Addresses.  This avoids compilation warnings
    on 64 bit architectures.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1136
  static inline u32 virt_to_32bit_virt(void *virt_addr)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1137
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1138
  	return (u32) (unsigned long) virt_addr;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1139
1140
1141
  }
  
  /*
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1142
    blogic_inc_count increments counter by 1, stopping at
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1143
1144
    65535 rather than wrapping around to 0.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1145
  static inline void blogic_inc_count(unsigned short *count)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1146
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1147
1148
  	if (*count < 65535)
  		(*count)++;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1149
1150
1151
  }
  
  /*
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1152
    blogic_addcount increments Byte Counter by Amount.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1153
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1154
1155
  static inline void blogic_addcount(struct blogic_byte_count *bytecount,
  					unsigned int amount)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1156
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1157
1158
1159
1160
  	bytecount->units += amount;
  	if (bytecount->units > 999999999) {
  		bytecount->units -= 1000000000;
  		bytecount->billions++;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1161
1162
1163
1164
  	}
  }
  
  /*
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1165
    blogic_incszbucket increments the Bucket for Amount.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1166
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1167
1168
  static inline void blogic_incszbucket(unsigned int *cmdsz_buckets,
  					unsigned int amount)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1169
  {
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1170
1171
1172
1173
  	int index = 0;
  	if (amount < 8 * 1024) {
  		if (amount < 2 * 1024)
  			index = (amount < 1 * 1024 ? 0 : 1);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1174
  		else
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1175
1176
1177
1178
  			index = (amount < 4 * 1024 ? 2 : 3);
  	} else if (amount < 128 * 1024) {
  		if (amount < 32 * 1024)
  			index = (amount < 16 * 1024 ? 4 : 5);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1179
  		else
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1180
  			index = (amount < 64 * 1024 ? 6 : 7);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1181
  	} else
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1182
1183
  		index = (amount < 256 * 1024 ? 8 : 9);
  	cmdsz_buckets[index]++;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1184
1185
1186
1187
1188
  }
  
  /*
    Define the version number of the FlashPoint Firmware (SCCB Manager).
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1189
  #define FLASHPOINT_FW_VER		"5.02"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1190
1191
1192
1193
  
  /*
    Define the possible return values from FlashPoint_HandleInterrupt.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1194
1195
1196
  #define FPOINT_NORMAL_INT		0x00
  #define FPOINT_INTERN_ERR		0xFE
  #define FPOINT_EXT_RESET		0xFF
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1197
1198
1199
1200
1201
  
  /*
    Define prototypes for the forward referenced BusLogic Driver
    Internal Functions.
  */
839cb99e8   Khalid Aziz   [SCSI] BusLogic: ...
1202
1203
1204
1205
1206
1207
1208
1209
1210
  static const char *blogic_drvr_info(struct Scsi_Host *);
  static int blogic_qcmd(struct Scsi_Host *h, struct scsi_cmnd *);
  static int blogic_diskparam(struct scsi_device *, struct block_device *, sector_t, int *);
  static int blogic_slaveconfig(struct scsi_device *);
  static void blogic_qcompleted_ccb(struct blogic_ccb *);
  static irqreturn_t blogic_inthandler(int, void *);
  static int blogic_resetadapter(struct blogic_adapter *, bool hard_reset);
  static void blogic_msg(enum blogic_msglevel, char *, struct blogic_adapter *, ...);
  static int __init blogic_setup(char *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1211
1212
  
  #endif				/* _BUSLOGIC_H */