patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / include / linux / i2o.h
1 /*
2  * I2O kernel space accessible structures/APIs
3  * 
4  * (c) Copyright 1999, 2000 Red Hat Software
5  *
6  * This program is free software; you can redistribute it and/or 
7  * modify it under the terms of the GNU General Public License 
8  * as published by the Free Software Foundation; either version 
9  * 2 of the License, or (at your option) any later version.  
10  * 
11  *************************************************************************
12  *
13  * This header file defined the I2O APIs/structures for use by 
14  * the I2O kernel modules.
15  *
16  */
17
18 #ifndef _I2O_H
19 #define _I2O_H
20
21 #ifdef __KERNEL__ /* This file to be included by kernel only */
22
23 #include <linux/i2o-dev.h>
24
25 /* How many different OSM's are we allowing */
26 #define MAX_I2O_MODULES         4
27
28 /* How many OSMs can register themselves for device status updates? */
29 #define I2O_MAX_MANAGERS        4
30
31 #include <asm/semaphore.h>      /* Needed for MUTEX init macros */
32 #include <linux/config.h>
33 #include <linux/notifier.h>
34 #include <asm/atomic.h>
35
36 /*
37  *      Message structures
38  */
39 struct i2o_message
40 {
41         u8      version_offset;
42         u8      flags;
43         u16     size;
44         u32     target_tid:12;
45         u32     init_tid:12;
46         u32     function:8;
47         u32     initiator_context;
48         /* List follows */
49 };
50
51 /*
52  *      Each I2O device entity has one or more of these. There is one
53  *      per device.
54  */
55 struct i2o_device
56 {
57         i2o_lct_entry lct_data;         /* Device LCT information */
58         u32 flags;
59         int i2oversion;                 /* I2O version supported. Actually
60                                          * there should be high and low
61                                          * version */
62
63         struct proc_dir_entry *proc_entry;      /* /proc dir */
64
65         /* Primary user */
66         struct i2o_handler *owner;
67
68         /* Management users */
69         struct i2o_handler *managers[I2O_MAX_MANAGERS];
70         int num_managers;
71
72         struct i2o_controller *controller;      /* Controlling IOP */
73         struct i2o_device *next;        /* Chain */
74         struct i2o_device *prev;
75         char dev_name[8];               /* linux /dev name if available */
76 };
77
78 /*
79  * context queue entry, used for 32-bit context on 64-bit systems
80  */
81 struct i2o_context_list_element {
82         struct i2o_context_list_element *next;
83         u32 context;
84         void *ptr;
85         unsigned int flags;
86 };
87
88 /*
89  * Each I2O controller has one of these objects
90  */
91 struct i2o_controller
92 {
93         char name[16];
94         int unit;
95         int type;
96         int enabled;
97         
98         struct pci_dev *pdev;           /* PCI device */
99         int             irq;
100         int             short_req:1;    /* Use small block sizes        */
101         int             dpt:1;          /* Don't quiesce                */
102         int             promise:1;      /* Promise controller           */
103 #ifdef CONFIG_MTRR
104         int             mtrr_reg0;
105         int             mtrr_reg1;
106 #endif
107
108         struct notifier_block *event_notifer;   /* Events */
109         atomic_t users;
110         struct i2o_device *devices;             /* I2O device chain */
111         struct i2o_controller *next;            /* Controller chain */
112         unsigned long post_port;                /* Inbout port address */
113         unsigned long reply_port;               /* Outbound port address */
114         unsigned long irq_mask;                 /* Interrupt register address */
115
116         /* Dynamic LCT related data */
117         struct semaphore lct_sem;
118         int lct_pid;
119         int lct_running;
120
121         i2o_status_block *status_block;         /* IOP status block */
122         dma_addr_t status_block_phys;
123         i2o_lct *lct;                           /* Logical Config Table */
124         dma_addr_t lct_phys;
125         i2o_lct *dlct;                          /* Temp LCT */
126         dma_addr_t dlct_phys;
127         i2o_hrt *hrt;                           /* HW Resource Table */
128         dma_addr_t hrt_phys;
129         u32 hrt_len;
130
131         unsigned long mem_offset;               /* MFA offset */
132         unsigned long mem_phys;                 /* MFA physical */
133
134         int battery:1;                          /* Has a battery backup */
135         int io_alloc:1;                         /* An I/O resource was allocated */
136         int mem_alloc:1;                        /* A memory resource was allocated */
137
138         struct resource io_resource;            /* I/O resource allocated to the IOP */
139         struct resource mem_resource;           /* Mem resource allocated to the IOP */
140
141         struct proc_dir_entry *proc_entry;      /* /proc dir */
142
143
144         void *page_frame;                       /* Message buffers */
145         dma_addr_t page_frame_map;              /* Cache map */
146 #if BITS_PER_LONG == 64
147         spinlock_t context_list_lock;           /* lock for context_list */
148         struct i2o_context_list_element *context_list; /* list of context id's
149                                                     and pointers */
150 #endif
151 };
152
153 /*
154  * OSM resgistration block
155  *
156  * Each OSM creates at least one of these and registers it with the
157  * I2O core through i2o_register_handler.  An OSM may want to
158  * register more than one if it wants a fast path to a reply
159  * handler by having a separate initiator context for each 
160  * class function.
161  */
162 struct i2o_handler
163 {
164         /* Message reply handler */
165         void (*reply)(struct i2o_handler *, struct i2o_controller *,
166                       struct i2o_message *);
167
168         /* New device notification handler */
169         void (*new_dev_notify)(struct i2o_controller *, struct i2o_device *);
170
171         /* Device deltion handler */
172         void (*dev_del_notify)(struct i2o_controller *, struct i2o_device *);
173
174         /* Reboot notification handler */
175         void (*reboot_notify)(void);
176
177         char *name;             /* OSM name */
178         int context;            /* Low 8 bits of the transaction info */
179         u32 class;              /* I2O classes that this driver handles */
180         /* User data follows */
181 };
182
183 #ifdef MODULE
184 /*
185  * Used by bus specific modules to communicate with the core
186  *
187  * This is needed because the bus modules cannot make direct
188  * calls to the core as this results in the i2o_bus_specific_module
189  * being dependent on the core, not the otherway around.
190  * In that case, a 'modprobe i2o_lan' loads i2o_core & i2o_lan,
191  * but _not_ i2o_pci...which makes the whole thing pretty useless :)
192  *
193  */
194 struct i2o_core_func_table
195 {
196         int     (*install)(struct i2o_controller *);
197         int     (*activate)(struct i2o_controller *);
198         struct i2o_controller *(*find)(int);
199         void    (*unlock)(struct i2o_controller *);
200         void    (*run_queue)(struct i2o_controller * c);
201         int     (*delete)(struct i2o_controller *);
202 };
203 #endif /* MODULE */
204
205 /*
206  * I2O System table entry
207  *
208  * The system table contains information about all the IOPs in the
209  * system.  It is sent to all IOPs so that they can create peer2peer
210  * connections between them.
211  */
212 struct i2o_sys_tbl_entry
213 {
214         u16     org_id;
215         u16     reserved1;
216         u32     iop_id:12;
217         u32     reserved2:20;
218         u16     seg_num:12;
219         u16     i2o_version:4;
220         u8      iop_state;
221         u8      msg_type;
222         u16     frame_size;
223         u16     reserved3;
224         u32     last_changed;
225         u32     iop_capabilities;
226         u32     inbound_low;
227         u32     inbound_high;
228 };
229
230 struct i2o_sys_tbl
231 {
232         u8      num_entries;
233         u8      version;
234         u16     reserved1;
235         u32     change_ind;
236         u32     reserved2;
237         u32     reserved3;
238         struct i2o_sys_tbl_entry iops[0];
239 };
240
241 /*
242  *      Messenger inlines
243  */
244 static inline u32 I2O_POST_READ32(struct i2o_controller *c)
245 {
246         return readl(c->post_port);
247 }
248
249 static inline void I2O_POST_WRITE32(struct i2o_controller *c, u32 val)
250 {
251         writel(val, c->post_port);
252 }
253
254
255 static inline u32 I2O_REPLY_READ32(struct i2o_controller *c)
256 {
257         return readl(c->reply_port);
258 }
259
260 static inline void I2O_REPLY_WRITE32(struct i2o_controller *c, u32 val)
261 {
262         writel(val, c->reply_port);
263 }
264
265
266 static inline u32 I2O_IRQ_READ32(struct i2o_controller *c)
267 {
268         return readl(c->irq_mask);
269 }
270
271 static inline void I2O_IRQ_WRITE32(struct i2o_controller *c, u32 val)
272 {
273         writel(val, c->irq_mask);
274 }
275
276
277 static inline void i2o_post_message(struct i2o_controller *c, u32 m)
278 {
279         /* The second line isnt spurious - thats forcing PCI posting */
280         I2O_POST_WRITE32(c, m);
281         (void) I2O_IRQ_READ32(c);
282 }
283
284 static inline void i2o_flush_reply(struct i2o_controller *c, u32 m)
285 {
286         I2O_REPLY_WRITE32(c, m);
287 }
288
289 /*
290  *      Endian handling wrapped into the macro - keeps the core code
291  *      cleaner.
292  */
293  
294 #define i2o_raw_writel(val, mem)        __raw_writel(cpu_to_le32(val), mem)
295
296 extern struct i2o_controller *i2o_find_controller(int);
297 extern void i2o_unlock_controller(struct i2o_controller *);
298 extern struct i2o_controller *i2o_controller_chain;
299 extern int i2o_num_controllers;
300 extern int i2o_status_get(struct i2o_controller *);
301
302 extern int i2o_install_handler(struct i2o_handler *);
303 extern int i2o_remove_handler(struct i2o_handler *);
304
305 extern int i2o_claim_device(struct i2o_device *, struct i2o_handler *);
306 extern int i2o_release_device(struct i2o_device *, struct i2o_handler *);
307 extern int i2o_device_notify_on(struct i2o_device *, struct i2o_handler *);
308 extern int i2o_device_notify_off(struct i2o_device *,
309                                  struct i2o_handler *);
310
311 extern int i2o_post_this(struct i2o_controller *, u32 *, int);
312 extern int i2o_post_wait(struct i2o_controller *, u32 *, int, int);
313 extern int i2o_post_wait_mem(struct i2o_controller *, u32 *, int, int,
314                              void *, void *, dma_addr_t, dma_addr_t, int, int);
315
316 extern int i2o_query_scalar(struct i2o_controller *, int, int, int, void *,
317                             int);
318 extern int i2o_set_scalar(struct i2o_controller *, int, int, int, void *,
319                           int);
320 extern int i2o_query_table(int, struct i2o_controller *, int, int, int,
321                            void *, int, void *, int);
322 extern int i2o_clear_table(struct i2o_controller *, int, int);
323 extern int i2o_row_add_table(struct i2o_controller *, int, int, int,
324                              void *, int);
325 extern int i2o_issue_params(int, struct i2o_controller *, int, void *, int,
326                             void *, int);
327
328 extern int i2o_event_register(struct i2o_controller *, u32, u32, u32, u32);
329 extern int i2o_event_ack(struct i2o_controller *, u32 *);
330
331 extern void i2o_report_status(const char *, const char *, u32 *);
332 extern void i2o_dump_message(u32 *);
333 extern const char *i2o_get_class_name(int);
334
335 extern int i2o_install_controller(struct i2o_controller *);
336 extern int i2o_activate_controller(struct i2o_controller *);
337 extern void i2o_run_queue(struct i2o_controller *);
338 extern int i2o_delete_controller(struct i2o_controller *);
339
340 #if BITS_PER_LONG == 64
341 extern u32 i2o_context_list_add(void *, struct i2o_controller *);
342 extern void *i2o_context_list_get(u32, struct i2o_controller *);
343 extern u32 i2o_context_list_remove(void *, struct i2o_controller *);
344 #else
345 static inline u32 i2o_context_list_add(void *ptr, struct i2o_controller *c)
346 {
347         return (u32)ptr;
348 }
349
350 static inline void *i2o_context_list_get(u32 context, struct i2o_controller *c)
351 {
352         return (void *)context;
353 }
354
355 static inline u32 i2o_context_list_remove(void *ptr, struct i2o_controller *c)
356 {
357         return (u32)ptr;
358 }
359 #endif
360
361 /*
362  *      Cache strategies
363  */
364  
365  
366 /*      The NULL strategy leaves everything up to the controller. This tends to be a
367  *      pessimal but functional choice.
368  */
369 #define CACHE_NULL              0
370 /*      Prefetch data when reading. We continually attempt to load the next 32 sectors
371  *      into the controller cache. 
372  */
373 #define CACHE_PREFETCH          1
374 /*      Prefetch data when reading. We sometimes attempt to load the next 32 sectors
375  *      into the controller cache. When an I/O is less <= 8K we assume its probably
376  *      not sequential and don't prefetch (default)
377  */
378 #define CACHE_SMARTFETCH        2
379 /*      Data is written to the cache and then out on to the disk. The I/O must be
380  *      physically on the medium before the write is acknowledged (default without
381  *      NVRAM)
382  */
383 #define CACHE_WRITETHROUGH      17
384 /*      Data is written to the cache and then out on to the disk. The controller
385  *      is permitted to write back the cache any way it wants. (default if battery
386  *      backed NVRAM is present). It can be useful to set this for swap regardless of
387  *      battery state.
388  */
389 #define CACHE_WRITEBACK         18
390 /*      Optimise for under powered controllers, especially on RAID1 and RAID0. We
391  *      write large I/O's directly to disk bypassing the cache to avoid the extra
392  *      memory copy hits. Small writes are writeback cached
393  */
394 #define CACHE_SMARTBACK         19
395 /*      Optimise for under powered controllers, especially on RAID1 and RAID0. We
396  *      write large I/O's directly to disk bypassing the cache to avoid the extra
397  *      memory copy hits. Small writes are writethrough cached. Suitable for devices
398  *      lacking battery backup
399  */
400 #define CACHE_SMARTTHROUGH      20
401
402 /*
403  *      Ioctl structures
404  */
405  
406
407 #define         BLKI2OGRSTRAT   _IOR('2', 1, int) 
408 #define         BLKI2OGWSTRAT   _IOR('2', 2, int) 
409 #define         BLKI2OSRSTRAT   _IOW('2', 3, int) 
410 #define         BLKI2OSWSTRAT   _IOW('2', 4, int) 
411
412
413
414
415 /*
416  *      I2O Function codes
417  */
418
419 /*
420  *      Executive Class
421  */
422 #define I2O_CMD_ADAPTER_ASSIGN          0xB3
423 #define I2O_CMD_ADAPTER_READ            0xB2
424 #define I2O_CMD_ADAPTER_RELEASE         0xB5
425 #define I2O_CMD_BIOS_INFO_SET           0xA5
426 #define I2O_CMD_BOOT_DEVICE_SET         0xA7
427 #define I2O_CMD_CONFIG_VALIDATE         0xBB
428 #define I2O_CMD_CONN_SETUP              0xCA
429 #define I2O_CMD_DDM_DESTROY             0xB1
430 #define I2O_CMD_DDM_ENABLE              0xD5
431 #define I2O_CMD_DDM_QUIESCE             0xC7
432 #define I2O_CMD_DDM_RESET               0xD9
433 #define I2O_CMD_DDM_SUSPEND             0xAF
434 #define I2O_CMD_DEVICE_ASSIGN           0xB7
435 #define I2O_CMD_DEVICE_RELEASE          0xB9
436 #define I2O_CMD_HRT_GET                 0xA8
437 #define I2O_CMD_ADAPTER_CLEAR           0xBE
438 #define I2O_CMD_ADAPTER_CONNECT         0xC9
439 #define I2O_CMD_ADAPTER_RESET           0xBD
440 #define I2O_CMD_LCT_NOTIFY              0xA2
441 #define I2O_CMD_OUTBOUND_INIT           0xA1
442 #define I2O_CMD_PATH_ENABLE             0xD3
443 #define I2O_CMD_PATH_QUIESCE            0xC5
444 #define I2O_CMD_PATH_RESET              0xD7
445 #define I2O_CMD_STATIC_MF_CREATE        0xDD
446 #define I2O_CMD_STATIC_MF_RELEASE       0xDF
447 #define I2O_CMD_STATUS_GET              0xA0
448 #define I2O_CMD_SW_DOWNLOAD             0xA9
449 #define I2O_CMD_SW_UPLOAD               0xAB
450 #define I2O_CMD_SW_REMOVE               0xAD
451 #define I2O_CMD_SYS_ENABLE              0xD1
452 #define I2O_CMD_SYS_MODIFY              0xC1
453 #define I2O_CMD_SYS_QUIESCE             0xC3
454 #define I2O_CMD_SYS_TAB_SET             0xA3
455
456 /*
457  * Utility Class
458  */
459 #define I2O_CMD_UTIL_NOP                0x00
460 #define I2O_CMD_UTIL_ABORT              0x01
461 #define I2O_CMD_UTIL_CLAIM              0x09
462 #define I2O_CMD_UTIL_RELEASE            0x0B
463 #define I2O_CMD_UTIL_PARAMS_GET         0x06
464 #define I2O_CMD_UTIL_PARAMS_SET         0x05
465 #define I2O_CMD_UTIL_EVT_REGISTER       0x13
466 #define I2O_CMD_UTIL_EVT_ACK            0x14
467 #define I2O_CMD_UTIL_CONFIG_DIALOG      0x10
468 #define I2O_CMD_UTIL_DEVICE_RESERVE     0x0D
469 #define I2O_CMD_UTIL_DEVICE_RELEASE     0x0F
470 #define I2O_CMD_UTIL_LOCK               0x17
471 #define I2O_CMD_UTIL_LOCK_RELEASE       0x19
472 #define I2O_CMD_UTIL_REPLY_FAULT_NOTIFY 0x15
473
474 /*
475  * SCSI Host Bus Adapter Class
476  */
477 #define I2O_CMD_SCSI_EXEC               0x81
478 #define I2O_CMD_SCSI_ABORT              0x83
479 #define I2O_CMD_SCSI_BUSRESET           0x27
480
481 /*
482  * Random Block Storage Class
483  */
484 #define I2O_CMD_BLOCK_READ              0x30
485 #define I2O_CMD_BLOCK_WRITE             0x31
486 #define I2O_CMD_BLOCK_CFLUSH            0x37
487 #define I2O_CMD_BLOCK_MLOCK             0x49
488 #define I2O_CMD_BLOCK_MUNLOCK           0x4B
489 #define I2O_CMD_BLOCK_MMOUNT            0x41
490 #define I2O_CMD_BLOCK_MEJECT            0x43
491 #define I2O_CMD_BLOCK_POWER             0x70
492
493 #define I2O_PRIVATE_MSG                 0xFF
494
495 /* Command status values  */
496
497 #define I2O_CMD_IN_PROGRESS     0x01
498 #define I2O_CMD_REJECTED        0x02
499 #define I2O_CMD_FAILED          0x03
500 #define I2O_CMD_COMPLETED       0x04
501
502 /* I2O API function return values */
503
504 #define I2O_RTN_NO_ERROR                        0
505 #define I2O_RTN_NOT_INIT                        1
506 #define I2O_RTN_FREE_Q_EMPTY                    2
507 #define I2O_RTN_TCB_ERROR                       3
508 #define I2O_RTN_TRANSACTION_ERROR               4
509 #define I2O_RTN_ADAPTER_ALREADY_INIT            5
510 #define I2O_RTN_MALLOC_ERROR                    6
511 #define I2O_RTN_ADPTR_NOT_REGISTERED            7
512 #define I2O_RTN_MSG_REPLY_TIMEOUT               8
513 #define I2O_RTN_NO_STATUS                       9
514 #define I2O_RTN_NO_FIRM_VER                     10
515 #define I2O_RTN_NO_LINK_SPEED                   11
516
517 /* Reply message status defines for all messages */
518
519 #define I2O_REPLY_STATUS_SUCCESS                        0x00
520 #define I2O_REPLY_STATUS_ABORT_DIRTY                    0x01
521 #define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER         0x02
522 #define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER         0x03
523 #define I2O_REPLY_STATUS_ERROR_DIRTY                    0x04
524 #define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER         0x05
525 #define I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER         0x06
526 #define I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY            0x08
527 #define I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x09
528 #define I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x0A
529 #define I2O_REPLY_STATUS_TRANSACTION_ERROR              0x0B
530 #define I2O_REPLY_STATUS_PROGRESS_REPORT                0x80
531
532 /* Status codes and Error Information for Parameter functions */
533
534 #define I2O_PARAMS_STATUS_SUCCESS               0x00
535 #define I2O_PARAMS_STATUS_BAD_KEY_ABORT         0x01
536 #define I2O_PARAMS_STATUS_BAD_KEY_CONTINUE      0x02
537 #define I2O_PARAMS_STATUS_BUFFER_FULL           0x03
538 #define I2O_PARAMS_STATUS_BUFFER_TOO_SMALL      0x04
539 #define I2O_PARAMS_STATUS_FIELD_UNREADABLE      0x05
540 #define I2O_PARAMS_STATUS_FIELD_UNWRITEABLE     0x06
541 #define I2O_PARAMS_STATUS_INSUFFICIENT_FIELDS   0x07
542 #define I2O_PARAMS_STATUS_INVALID_GROUP_ID      0x08
543 #define I2O_PARAMS_STATUS_INVALID_OPERATION     0x09
544 #define I2O_PARAMS_STATUS_NO_KEY_FIELD          0x0A
545 #define I2O_PARAMS_STATUS_NO_SUCH_FIELD         0x0B
546 #define I2O_PARAMS_STATUS_NON_DYNAMIC_GROUP     0x0C
547 #define I2O_PARAMS_STATUS_OPERATION_ERROR       0x0D
548 #define I2O_PARAMS_STATUS_SCALAR_ERROR          0x0E
549 #define I2O_PARAMS_STATUS_TABLE_ERROR           0x0F
550 #define I2O_PARAMS_STATUS_WRONG_GROUP_TYPE      0x10
551
552 /* DetailedStatusCode defines for Executive, DDM, Util and Transaction error
553  * messages: Table 3-2 Detailed Status Codes.*/
554
555 #define I2O_DSC_SUCCESS                        0x0000
556 #define I2O_DSC_BAD_KEY                        0x0002
557 #define I2O_DSC_TCL_ERROR                      0x0003
558 #define I2O_DSC_REPLY_BUFFER_FULL              0x0004
559 #define I2O_DSC_NO_SUCH_PAGE                   0x0005
560 #define I2O_DSC_INSUFFICIENT_RESOURCE_SOFT     0x0006
561 #define I2O_DSC_INSUFFICIENT_RESOURCE_HARD     0x0007
562 #define I2O_DSC_CHAIN_BUFFER_TOO_LARGE         0x0009
563 #define I2O_DSC_UNSUPPORTED_FUNCTION           0x000A
564 #define I2O_DSC_DEVICE_LOCKED                  0x000B
565 #define I2O_DSC_DEVICE_RESET                   0x000C
566 #define I2O_DSC_INAPPROPRIATE_FUNCTION         0x000D
567 #define I2O_DSC_INVALID_INITIATOR_ADDRESS      0x000E
568 #define I2O_DSC_INVALID_MESSAGE_FLAGS          0x000F
569 #define I2O_DSC_INVALID_OFFSET                 0x0010
570 #define I2O_DSC_INVALID_PARAMETER              0x0011
571 #define I2O_DSC_INVALID_REQUEST                0x0012
572 #define I2O_DSC_INVALID_TARGET_ADDRESS         0x0013
573 #define I2O_DSC_MESSAGE_TOO_LARGE              0x0014
574 #define I2O_DSC_MESSAGE_TOO_SMALL              0x0015
575 #define I2O_DSC_MISSING_PARAMETER              0x0016
576 #define I2O_DSC_TIMEOUT                        0x0017
577 #define I2O_DSC_UNKNOWN_ERROR                  0x0018
578 #define I2O_DSC_UNKNOWN_FUNCTION               0x0019
579 #define I2O_DSC_UNSUPPORTED_VERSION            0x001A
580 #define I2O_DSC_DEVICE_BUSY                    0x001B
581 #define I2O_DSC_DEVICE_NOT_AVAILABLE           0x001C
582
583 /* DetailedStatusCode defines for Block Storage Operation: Table 6-7 Detailed
584    Status Codes.*/
585
586 #define I2O_BSA_DSC_SUCCESS               0x0000
587 #define I2O_BSA_DSC_MEDIA_ERROR           0x0001
588 #define I2O_BSA_DSC_ACCESS_ERROR          0x0002
589 #define I2O_BSA_DSC_DEVICE_FAILURE        0x0003
590 #define I2O_BSA_DSC_DEVICE_NOT_READY      0x0004
591 #define I2O_BSA_DSC_MEDIA_NOT_PRESENT     0x0005
592 #define I2O_BSA_DSC_MEDIA_LOCKED          0x0006
593 #define I2O_BSA_DSC_MEDIA_FAILURE         0x0007
594 #define I2O_BSA_DSC_PROTOCOL_FAILURE      0x0008
595 #define I2O_BSA_DSC_BUS_FAILURE           0x0009
596 #define I2O_BSA_DSC_ACCESS_VIOLATION      0x000A
597 #define I2O_BSA_DSC_WRITE_PROTECTED       0x000B
598 #define I2O_BSA_DSC_DEVICE_RESET          0x000C
599 #define I2O_BSA_DSC_VOLUME_CHANGED        0x000D
600 #define I2O_BSA_DSC_TIMEOUT               0x000E
601
602 /* FailureStatusCodes, Table 3-3 Message Failure Codes */
603
604 #define I2O_FSC_TRANSPORT_SERVICE_SUSPENDED             0x81
605 #define I2O_FSC_TRANSPORT_SERVICE_TERMINATED            0x82
606 #define I2O_FSC_TRANSPORT_CONGESTION                    0x83
607 #define I2O_FSC_TRANSPORT_FAILURE                       0x84
608 #define I2O_FSC_TRANSPORT_STATE_ERROR                   0x85
609 #define I2O_FSC_TRANSPORT_TIME_OUT                      0x86
610 #define I2O_FSC_TRANSPORT_ROUTING_FAILURE               0x87
611 #define I2O_FSC_TRANSPORT_INVALID_VERSION               0x88
612 #define I2O_FSC_TRANSPORT_INVALID_OFFSET                0x89
613 #define I2O_FSC_TRANSPORT_INVALID_MSG_FLAGS             0x8A
614 #define I2O_FSC_TRANSPORT_FRAME_TOO_SMALL               0x8B
615 #define I2O_FSC_TRANSPORT_FRAME_TOO_LARGE               0x8C
616 #define I2O_FSC_TRANSPORT_INVALID_TARGET_ID             0x8D
617 #define I2O_FSC_TRANSPORT_INVALID_INITIATOR_ID          0x8E
618 #define I2O_FSC_TRANSPORT_INVALID_INITIATOR_CONTEXT     0x8F
619 #define I2O_FSC_TRANSPORT_UNKNOWN_FAILURE               0xFF
620
621 /* Device Claim Types */
622 #define I2O_CLAIM_PRIMARY                                       0x01000000
623 #define I2O_CLAIM_MANAGEMENT                                    0x02000000
624 #define I2O_CLAIM_AUTHORIZED                                    0x03000000
625 #define I2O_CLAIM_SECONDARY                                     0x04000000
626
627 /* Message header defines for VersionOffset */
628 #define I2OVER15        0x0001
629 #define I2OVER20        0x0002
630
631 /* Default is 1.5, FIXME: Need support for both 1.5 and 2.0 */
632 #define I2OVERSION      I2OVER15
633
634 #define SGL_OFFSET_0    I2OVERSION
635 #define SGL_OFFSET_4    (0x0040 | I2OVERSION)
636 #define SGL_OFFSET_5    (0x0050 | I2OVERSION)
637 #define SGL_OFFSET_6    (0x0060 | I2OVERSION)
638 #define SGL_OFFSET_7    (0x0070 | I2OVERSION)
639 #define SGL_OFFSET_8    (0x0080 | I2OVERSION)
640 #define SGL_OFFSET_9    (0x0090 | I2OVERSION)
641 #define SGL_OFFSET_10   (0x00A0 | I2OVERSION)
642
643 #define TRL_OFFSET_5    (0x0050 | I2OVERSION)
644 #define TRL_OFFSET_6    (0x0060 | I2OVERSION)
645
646 /* Transaction Reply Lists (TRL) Control Word structure */
647 #define TRL_SINGLE_FIXED_LENGTH         0x00
648 #define TRL_SINGLE_VARIABLE_LENGTH      0x40
649 #define TRL_MULTIPLE_FIXED_LENGTH       0x80
650
651
652  /* msg header defines for MsgFlags */
653 #define MSG_STATIC      0x0100
654 #define MSG_64BIT_CNTXT 0x0200
655 #define MSG_MULTI_TRANS 0x1000
656 #define MSG_FAIL        0x2000
657 #define MSG_FINAL       0x4000
658 #define MSG_REPLY       0x8000
659
660  /* minimum size msg */
661 #define THREE_WORD_MSG_SIZE     0x00030000
662 #define FOUR_WORD_MSG_SIZE      0x00040000
663 #define FIVE_WORD_MSG_SIZE      0x00050000
664 #define SIX_WORD_MSG_SIZE       0x00060000
665 #define SEVEN_WORD_MSG_SIZE     0x00070000
666 #define EIGHT_WORD_MSG_SIZE     0x00080000
667 #define NINE_WORD_MSG_SIZE      0x00090000
668 #define TEN_WORD_MSG_SIZE       0x000A0000
669 #define ELEVEN_WORD_MSG_SIZE    0x000B0000
670 #define I2O_MESSAGE_SIZE(x)     ((x)<<16)
671
672
673 /* Special TID Assignments */
674
675 #define ADAPTER_TID             0
676 #define HOST_TID                1
677
678 #define MSG_FRAME_SIZE          64      /* i2o_scsi assumes >= 32 */
679 #define REPLY_FRAME_SIZE        17
680 #define SG_TABLESIZE            30
681 #define NMBR_MSG_FRAMES         128
682
683 #define MSG_POOL_SIZE           (MSG_FRAME_SIZE*NMBR_MSG_FRAMES*sizeof(u32))
684
685 #define I2O_POST_WAIT_OK        0
686 #define I2O_POST_WAIT_TIMEOUT   -ETIMEDOUT
687
688 #define I2O_CONTEXT_LIST_MIN_LENGTH     15
689 #define I2O_CONTEXT_LIST_USED           0x01
690 #define I2O_CONTEXT_LIST_DELETED        0x02
691
692 #endif /* __KERNEL__ */
693 #endif /* _I2O_H */