2 * I2O kernel space accessible structures/APIs
4 * (c) Copyright 1999, 2000 Red Hat Software
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.
11 *************************************************************************
13 * This header file defined the I2O APIs/structures for use by
14 * the I2O kernel modules.
21 #ifdef __KERNEL__ /* This file to be included by kernel only */
23 #include <linux/i2o-dev.h>
25 /* How many different OSM's are we allowing */
26 #define I2O_MAX_DRIVERS 4
29 #include <asm/semaphore.h> /* Needed for MUTEX init macros */
30 #include <linux/pci.h>
31 #include <linux/dma-mapping.h>
33 /* message queue empty */
34 #define I2O_QUEUE_EMPTY 0xffffffff
48 u32 icntxt
; /* initiator context */
49 u32 tcntxt
; /* transaction context */
58 * Each I2O device entity has one of these. There is one per device.
61 i2o_lct_entry lct_data
; /* Device LCT information */
63 struct i2o_controller
*iop
; /* Controlling IOP */
64 struct list_head list
; /* node in IOP devices list */
68 struct semaphore lock
; /* device lock */
70 struct class_device classdev
; /* i2o device class */
74 * Event structure provided to the event handling function
77 struct work_struct work
;
78 struct i2o_device
*i2o_dev
; /* I2O device pointer from which the
79 event reply was initiated */
80 u16 size
; /* Size of data in 32-bit words */
81 u32 tcntxt
; /* Transaction context used at
83 u32 event_indicator
; /* Event indicator from reply */
84 u32 data
[0]; /* Event data from reply */
88 * I2O classes which could be handled by the OSM
95 * I2O driver structure for OSMs
98 char *name
; /* OSM name */
99 int context
; /* Low 8 bits of the transaction info */
100 struct i2o_class_id
*classes
; /* I2O classes that this OSM handles */
102 /* Message reply handler */
103 int (*reply
) (struct i2o_controller
*, u32
, struct i2o_message
*);
106 void (*event
) (struct i2o_event
*);
108 struct workqueue_struct
*event_queue
; /* Event queue */
110 struct device_driver driver
;
112 /* notification of changes */
113 void (*notify_controller_add
) (struct i2o_controller
*);
114 void (*notify_controller_remove
) (struct i2o_controller
*);
115 void (*notify_device_add
) (struct i2o_device
*);
116 void (*notify_device_remove
) (struct i2o_device
*);
118 struct semaphore lock
;
122 * Contains all information which are necessary for DMA operations
131 * Context queue entry, used for 32-bit context on 64-bit systems
133 struct i2o_context_list_element
{
134 struct list_head list
;
137 unsigned long timestamp
;
141 * Each I2O controller has one of these objects
143 struct i2o_controller
{
148 struct pci_dev
*pdev
; /* PCI device */
150 int short_req
:1; /* use small block sizes */
151 int no_quiesce
:1; /* dont quiesce before reset */
152 int raptor
:1; /* split bar */
153 int promise
:1; /* Promise controller */
160 struct list_head devices
; /* list of I2O devices */
162 struct notifier_block
*event_notifer
; /* Events */
164 struct list_head list
; /* Controller list */
165 void *post_port
; /* Inbout port address */
166 void *reply_port
; /* Outbound port address */
167 void *irq_mask
; /* Interrupt register address */
169 /* Dynamic LCT related data */
171 struct i2o_dma status
; /* status of IOP */
173 struct i2o_dma hrt
; /* HW Resource Table */
174 i2o_lct
*lct
; /* Logical Config Table */
175 struct i2o_dma dlct
; /* Temp LCT */
176 struct semaphore lct_lock
; /* Lock for LCT updates */
177 struct i2o_dma status_block
; /* IOP status block */
179 struct i2o_dma base
; /* controller messaging unit */
180 struct i2o_dma in_queue
; /* inbound message queue Host->IOP */
181 struct i2o_dma out_queue
; /* outbound message queue IOP->Host */
183 int battery
:1; /* Has a battery backup */
184 int io_alloc
:1; /* An I/O resource was allocated */
185 int mem_alloc
:1; /* A memory resource was allocated */
187 struct resource io_resource
; /* I/O resource allocated to the IOP */
188 struct resource mem_resource
; /* Mem resource allocated to the IOP */
190 struct proc_dir_entry
*proc_entry
; /* /proc dir */
192 struct list_head bus_list
; /* list of busses on IOP */
193 struct device device
;
194 struct i2o_device
*exec
; /* Executive */
195 #if BITS_PER_LONG == 64
196 spinlock_t context_list_lock
; /* lock for context_list */
197 atomic_t context_list_counter
; /* needed for unique contexts */
198 struct list_head context_list
; /* list of context id's
201 spinlock_t lock
; /* lock for controller
204 void *driver_data
[I2O_MAX_DRIVERS
]; /* storage for drivers */
208 * I2O System table entry
210 * The system table contains information about all the IOPs in the
211 * system. It is sent to all IOPs so that they can create peer2peer
212 * connections between them.
214 struct i2o_sys_tbl_entry
{
226 u32 iop_capabilities
;
238 struct i2o_sys_tbl_entry iops
[0];
241 extern struct list_head i2o_controllers
;
243 /* Message functions */
244 static inline u32
i2o_msg_get(struct i2o_controller
*, struct i2o_message
**);
245 extern u32
i2o_msg_get_wait(struct i2o_controller
*, struct i2o_message
**,
247 static inline void i2o_msg_post(struct i2o_controller
*, u32
);
248 static inline int i2o_msg_post_wait(struct i2o_controller
*, u32
,
250 extern int i2o_msg_post_wait_mem(struct i2o_controller
*, u32
, unsigned long,
252 extern void i2o_msg_nop(struct i2o_controller
*, u32
);
253 static inline void i2o_flush_reply(struct i2o_controller
*, u32
);
255 /* DMA handling functions */
256 static inline int i2o_dma_alloc(struct device
*, struct i2o_dma
*, size_t,
258 static inline void i2o_dma_free(struct device
*, struct i2o_dma
*);
259 int i2o_dma_realloc(struct device
*, struct i2o_dma
*, size_t, unsigned int);
261 static inline int i2o_dma_map(struct device
*, struct i2o_dma
*);
262 static inline void i2o_dma_unmap(struct device
*, struct i2o_dma
*);
265 extern int i2o_status_get(struct i2o_controller
*);
266 extern int i2o_hrt_get(struct i2o_controller
*);
268 extern int i2o_event_register(struct i2o_device
*, struct i2o_driver
*, int,
270 extern struct i2o_device
*i2o_iop_find_device(struct i2o_controller
*, u16
);
271 extern struct i2o_controller
*i2o_find_iop(int);
273 /* Functions needed for handling 64-bit pointers in 32-bit context */
274 #if BITS_PER_LONG == 64
275 extern u32
i2o_cntxt_list_add(struct i2o_controller
*, void *);
276 extern void *i2o_cntxt_list_get(struct i2o_controller
*, u32
);
277 extern u32
i2o_cntxt_list_remove(struct i2o_controller
*, void *);
278 extern u32
i2o_cntxt_list_get_ptr(struct i2o_controller
*, void *);
280 static inline u32
i2o_ptr_low(void *ptr
)
282 return (u32
) (u64
) ptr
;
285 static inline u32
i2o_ptr_high(void *ptr
)
287 return (u32
) ((u64
) ptr
>> 32);
290 static inline u32
i2o_cntxt_list_add(struct i2o_controller
*c
, void *ptr
)
295 static inline void *i2o_cntxt_list_get(struct i2o_controller
*c
, u32 context
)
297 return (void *)context
;
300 static inline u32
i2o_cntxt_list_remove(struct i2o_controller
*c
, void *ptr
)
305 static inline u32
i2o_cntxt_list_get_ptr(struct i2o_controller
*c
, void *ptr
)
310 static inline u32
i2o_ptr_low(void *ptr
)
315 static inline u32
i2o_ptr_high(void *ptr
)
321 /* I2O driver (OSM) functions */
322 extern int i2o_driver_register(struct i2o_driver
*);
323 extern void i2o_driver_unregister(struct i2o_driver
*);
326 * i2o_driver_notify_controller_add - Send notification of added controller
327 * to a single I2O driver
329 * Send notification of added controller to a single registered driver.
331 static inline void i2o_driver_notify_controller_add(struct i2o_driver
*drv
,
332 struct i2o_controller
*c
)
334 if (drv
->notify_controller_add
)
335 drv
->notify_controller_add(c
);
339 * i2o_driver_notify_controller_remove - Send notification of removed
340 * controller to a single I2O driver
342 * Send notification of removed controller to a single registered driver.
344 static inline void i2o_driver_notify_controller_remove(struct i2o_driver
*drv
,
345 struct i2o_controller
*c
)
347 if (drv
->notify_controller_remove
)
348 drv
->notify_controller_remove(c
);
352 * i2o_driver_notify_device_add - Send notification of added device to a
355 * Send notification of added device to a single registered driver.
357 static inline void i2o_driver_notify_device_add(struct i2o_driver
*drv
,
358 struct i2o_device
*i2o_dev
)
360 if (drv
->notify_device_add
)
361 drv
->notify_device_add(i2o_dev
);
365 * i2o_driver_notify_device_remove - Send notification of removed device
366 * to a single I2O driver
368 * Send notification of removed device to a single registered driver.
370 static inline void i2o_driver_notify_device_remove(struct i2o_driver
*drv
,
371 struct i2o_device
*i2o_dev
)
373 if (drv
->notify_device_remove
)
374 drv
->notify_device_remove(i2o_dev
);
377 extern void i2o_driver_notify_controller_add_all(struct i2o_controller
*);
378 extern void i2o_driver_notify_controller_remove_all(struct i2o_controller
*);
379 extern void i2o_driver_notify_device_add_all(struct i2o_device
*);
380 extern void i2o_driver_notify_device_remove_all(struct i2o_device
*);
382 /* I2O device functions */
383 extern int i2o_device_claim(struct i2o_device
*);
384 extern int i2o_device_claim_release(struct i2o_device
*);
386 /* Exec OSM functions */
387 extern int i2o_exec_lct_get(struct i2o_controller
*);
388 extern int i2o_exec_lct_notify(struct i2o_controller
*, u32
);
390 /* device to i2o_device and driver to i2o_driver convertion functions */
391 #define to_i2o_driver(drv) container_of(drv,struct i2o_driver, driver)
392 #define to_i2o_device(dev) container_of(dev, struct i2o_device, device)
397 static inline u32
I2O_POST_READ32(struct i2o_controller
*c
)
400 return readl(c
->post_port
);
403 static inline void I2O_POST_WRITE32(struct i2o_controller
*c
, u32 val
)
406 writel(val
, c
->post_port
);
409 static inline u32
I2O_REPLY_READ32(struct i2o_controller
*c
)
412 return readl(c
->reply_port
);
415 static inline void I2O_REPLY_WRITE32(struct i2o_controller
*c
, u32 val
)
418 writel(val
, c
->reply_port
);
421 static inline u32
I2O_IRQ_READ32(struct i2o_controller
*c
)
424 return readl(c
->irq_mask
);
427 static inline void I2O_IRQ_WRITE32(struct i2o_controller
*c
, u32 val
)
430 writel(val
, c
->irq_mask
);
435 * i2o_msg_get - obtain an I2O message from the IOP
437 * @msg: pointer to a I2O message pointer
439 * This function tries to get a message slot. If no message slot is
440 * available do not wait until one is availabe (see also i2o_msg_get_wait).
442 * On a success the message is returned and the pointer to the message is
443 * set in msg. The returned message is the physical page frame offset
444 * address from the read port (see the i2o spec). If no message is
445 * available returns I2O_QUEUE_EMPTY and msg is leaved untouched.
447 static inline u32
i2o_msg_get(struct i2o_controller
*c
,
448 struct i2o_message
**msg
)
452 if ((m
= I2O_POST_READ32(c
)) != I2O_QUEUE_EMPTY
)
453 *msg
= c
->in_queue
.virt
+ m
;
459 * i2o_msg_post - Post I2O message to I2O controller
460 * @c: I2O controller to which the message should be send
461 * @m: the message identifier
463 * Post the message to the I2O controller.
465 static inline void i2o_msg_post(struct i2o_controller
*c
, u32 m
)
467 I2O_POST_WRITE32(c
, m
);
471 * i2o_msg_post_wait - Post and wait a message and wait until return
473 * @m: message to post
474 * @timeout: time in seconds to wait
476 * This API allows an OSM to post a message and then be told whether or
477 * not the system received a successful reply. If the message times out
478 * then the value '-ETIMEDOUT' is returned.
480 * Returns 0 on success or negative error code on failure.
482 static inline int i2o_msg_post_wait(struct i2o_controller
*c
, u32 m
,
483 unsigned long timeout
)
485 return i2o_msg_post_wait_mem(c
, m
, timeout
, NULL
);
489 * i2o_flush_reply - Flush reply from I2O controller
491 * @m: the message identifier
493 * The I2O controller must be informed that the reply message is not needed
494 * anymore. If you forget to flush the reply, the message frame can't be
495 * used by the controller anymore and is therefore lost.
497 * FIXME: is there a timeout after which the controller reuse the message?
499 static inline void i2o_flush_reply(struct i2o_controller
*c
, u32 m
)
501 I2O_REPLY_WRITE32(c
, m
);
505 * i2o_dma_alloc - Allocate DMA memory
506 * @dev: struct device pointer to the PCI device of the I2O controller
507 * @addr: i2o_dma struct which should get the DMA buffer
508 * @len: length of the new DMA memory
509 * @gfp_mask: GFP mask
511 * Allocate a coherent DMA memory and write the pointers into addr.
513 * Returns 0 on success or -ENOMEM on failure.
515 static inline int i2o_dma_alloc(struct device
*dev
, struct i2o_dma
*addr
,
516 size_t len
, unsigned int gfp_mask
)
518 addr
->virt
= dma_alloc_coherent(dev
, len
, &addr
->phys
, gfp_mask
);
522 memset(addr
->virt
, 0, len
);
529 * i2o_dma_free - Free DMA memory
530 * @dev: struct device pointer to the PCI device of the I2O controller
531 * @addr: i2o_dma struct which contains the DMA buffer
533 * Free a coherent DMA memory and set virtual address of addr to NULL.
535 static inline void i2o_dma_free(struct device
*dev
, struct i2o_dma
*addr
)
539 dma_free_coherent(dev
, addr
->len
, addr
->virt
,
548 * i2o_dma_map - Map the memory to DMA
549 * @dev: struct device pointer to the PCI device of the I2O controller
550 * @addr: i2o_dma struct which should be mapped
552 * Map the memory in addr->virt to coherent DMA memory and write the
553 * physical address into addr->phys.
555 * Returns 0 on success or -ENOMEM on failure.
557 static inline int i2o_dma_map(struct device
*dev
, struct i2o_dma
*addr
)
563 addr
->phys
= dma_map_single(dev
, addr
->virt
, addr
->len
,
572 * i2o_dma_unmap - Unmap the DMA memory
573 * @dev: struct device pointer to the PCI device of the I2O controller
574 * @addr: i2o_dma struct which should be unmapped
576 * Unmap the memory in addr->virt from DMA memory.
578 static inline void i2o_dma_unmap(struct device
*dev
, struct i2o_dma
*addr
)
584 dma_unmap_single(dev
, addr
->phys
, addr
->len
, DMA_BIDIRECTIONAL
);
590 * Endian handling wrapped into the macro - keeps the core code
594 #define i2o_raw_writel(val, mem) __raw_writel(cpu_to_le32(val), mem)
596 extern int i2o_parm_field_get(struct i2o_device
*, int, int, void *, int);
597 extern int i2o_parm_field_set(struct i2o_device
*, int, int, void *, int);
598 extern int i2o_parm_table_get(struct i2o_device
*, int, int, int, void *, int,
601 extern int i2o_query_table(int, struct i2o_controller *, int, int, int,
602 void *, int, void *, int);
603 extern int i2o_clear_table(struct i2o_controller *, int, int);
604 extern int i2o_row_add_table(struct i2o_controller *, int, int, int,
606 extern int i2o_issue_params(int, struct i2o_controller *, int, void *, int,
610 /* debugging functions */
611 extern void i2o_report_status(const char *, const char *, struct i2o_message
*);
612 extern void i2o_dump_message(struct i2o_message
*);
613 extern void i2o_dump_hrt(struct i2o_controller
*c
);
614 extern void i2o_debug_state(struct i2o_controller
*c
);
620 /* The NULL strategy leaves everything up to the controller. This tends to be a
621 * pessimal but functional choice.
624 /* Prefetch data when reading. We continually attempt to load the next 32 sectors
625 * into the controller cache.
627 #define CACHE_PREFETCH 1
628 /* Prefetch data when reading. We sometimes attempt to load the next 32 sectors
629 * into the controller cache. When an I/O is less <= 8K we assume its probably
630 * not sequential and don't prefetch (default)
632 #define CACHE_SMARTFETCH 2
633 /* Data is written to the cache and then out on to the disk. The I/O must be
634 * physically on the medium before the write is acknowledged (default without
637 #define CACHE_WRITETHROUGH 17
638 /* Data is written to the cache and then out on to the disk. The controller
639 * is permitted to write back the cache any way it wants. (default if battery
640 * backed NVRAM is present). It can be useful to set this for swap regardless of
643 #define CACHE_WRITEBACK 18
644 /* Optimise for under powered controllers, especially on RAID1 and RAID0. We
645 * write large I/O's directly to disk bypassing the cache to avoid the extra
646 * memory copy hits. Small writes are writeback cached
648 #define CACHE_SMARTBACK 19
649 /* Optimise for under powered controllers, especially on RAID1 and RAID0. We
650 * write large I/O's directly to disk bypassing the cache to avoid the extra
651 * memory copy hits. Small writes are writethrough cached. Suitable for devices
652 * lacking battery backup
654 #define CACHE_SMARTTHROUGH 20
660 #define BLKI2OGRSTRAT _IOR('2', 1, int)
661 #define BLKI2OGWSTRAT _IOR('2', 2, int)
662 #define BLKI2OSRSTRAT _IOW('2', 3, int)
663 #define BLKI2OSWSTRAT _IOW('2', 4, int)
672 #define I2O_CMD_ADAPTER_ASSIGN 0xB3
673 #define I2O_CMD_ADAPTER_READ 0xB2
674 #define I2O_CMD_ADAPTER_RELEASE 0xB5
675 #define I2O_CMD_BIOS_INFO_SET 0xA5
676 #define I2O_CMD_BOOT_DEVICE_SET 0xA7
677 #define I2O_CMD_CONFIG_VALIDATE 0xBB
678 #define I2O_CMD_CONN_SETUP 0xCA
679 #define I2O_CMD_DDM_DESTROY 0xB1
680 #define I2O_CMD_DDM_ENABLE 0xD5
681 #define I2O_CMD_DDM_QUIESCE 0xC7
682 #define I2O_CMD_DDM_RESET 0xD9
683 #define I2O_CMD_DDM_SUSPEND 0xAF
684 #define I2O_CMD_DEVICE_ASSIGN 0xB7
685 #define I2O_CMD_DEVICE_RELEASE 0xB9
686 #define I2O_CMD_HRT_GET 0xA8
687 #define I2O_CMD_ADAPTER_CLEAR 0xBE
688 #define I2O_CMD_ADAPTER_CONNECT 0xC9
689 #define I2O_CMD_ADAPTER_RESET 0xBD
690 #define I2O_CMD_LCT_NOTIFY 0xA2
691 #define I2O_CMD_OUTBOUND_INIT 0xA1
692 #define I2O_CMD_PATH_ENABLE 0xD3
693 #define I2O_CMD_PATH_QUIESCE 0xC5
694 #define I2O_CMD_PATH_RESET 0xD7
695 #define I2O_CMD_STATIC_MF_CREATE 0xDD
696 #define I2O_CMD_STATIC_MF_RELEASE 0xDF
697 #define I2O_CMD_STATUS_GET 0xA0
698 #define I2O_CMD_SW_DOWNLOAD 0xA9
699 #define I2O_CMD_SW_UPLOAD 0xAB
700 #define I2O_CMD_SW_REMOVE 0xAD
701 #define I2O_CMD_SYS_ENABLE 0xD1
702 #define I2O_CMD_SYS_MODIFY 0xC1
703 #define I2O_CMD_SYS_QUIESCE 0xC3
704 #define I2O_CMD_SYS_TAB_SET 0xA3
709 #define I2O_CMD_UTIL_NOP 0x00
710 #define I2O_CMD_UTIL_ABORT 0x01
711 #define I2O_CMD_UTIL_CLAIM 0x09
712 #define I2O_CMD_UTIL_RELEASE 0x0B
713 #define I2O_CMD_UTIL_PARAMS_GET 0x06
714 #define I2O_CMD_UTIL_PARAMS_SET 0x05
715 #define I2O_CMD_UTIL_EVT_REGISTER 0x13
716 #define I2O_CMD_UTIL_EVT_ACK 0x14
717 #define I2O_CMD_UTIL_CONFIG_DIALOG 0x10
718 #define I2O_CMD_UTIL_DEVICE_RESERVE 0x0D
719 #define I2O_CMD_UTIL_DEVICE_RELEASE 0x0F
720 #define I2O_CMD_UTIL_LOCK 0x17
721 #define I2O_CMD_UTIL_LOCK_RELEASE 0x19
722 #define I2O_CMD_UTIL_REPLY_FAULT_NOTIFY 0x15
725 * SCSI Host Bus Adapter Class
727 #define I2O_CMD_SCSI_EXEC 0x81
728 #define I2O_CMD_SCSI_ABORT 0x83
729 #define I2O_CMD_SCSI_BUSRESET 0x27
732 * Random Block Storage Class
734 #define I2O_CMD_BLOCK_READ 0x30
735 #define I2O_CMD_BLOCK_WRITE 0x31
736 #define I2O_CMD_BLOCK_CFLUSH 0x37
737 #define I2O_CMD_BLOCK_MLOCK 0x49
738 #define I2O_CMD_BLOCK_MUNLOCK 0x4B
739 #define I2O_CMD_BLOCK_MMOUNT 0x41
740 #define I2O_CMD_BLOCK_MEJECT 0x43
741 #define I2O_CMD_BLOCK_POWER 0x70
743 #define I2O_PRIVATE_MSG 0xFF
745 /* Command status values */
747 #define I2O_CMD_IN_PROGRESS 0x01
748 #define I2O_CMD_REJECTED 0x02
749 #define I2O_CMD_FAILED 0x03
750 #define I2O_CMD_COMPLETED 0x04
752 /* I2O API function return values */
754 #define I2O_RTN_NO_ERROR 0
755 #define I2O_RTN_NOT_INIT 1
756 #define I2O_RTN_FREE_Q_EMPTY 2
757 #define I2O_RTN_TCB_ERROR 3
758 #define I2O_RTN_TRANSACTION_ERROR 4
759 #define I2O_RTN_ADAPTER_ALREADY_INIT 5
760 #define I2O_RTN_MALLOC_ERROR 6
761 #define I2O_RTN_ADPTR_NOT_REGISTERED 7
762 #define I2O_RTN_MSG_REPLY_TIMEOUT 8
763 #define I2O_RTN_NO_STATUS 9
764 #define I2O_RTN_NO_FIRM_VER 10
765 #define I2O_RTN_NO_LINK_SPEED 11
767 /* Reply message status defines for all messages */
769 #define I2O_REPLY_STATUS_SUCCESS 0x00
770 #define I2O_REPLY_STATUS_ABORT_DIRTY 0x01
771 #define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02
772 #define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03
773 #define I2O_REPLY_STATUS_ERROR_DIRTY 0x04
774 #define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05
775 #define I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER 0x06
776 #define I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY 0x08
777 #define I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x09
778 #define I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x0A
779 #define I2O_REPLY_STATUS_TRANSACTION_ERROR 0x0B
780 #define I2O_REPLY_STATUS_PROGRESS_REPORT 0x80
782 /* Status codes and Error Information for Parameter functions */
784 #define I2O_PARAMS_STATUS_SUCCESS 0x00
785 #define I2O_PARAMS_STATUS_BAD_KEY_ABORT 0x01
786 #define I2O_PARAMS_STATUS_BAD_KEY_CONTINUE 0x02
787 #define I2O_PARAMS_STATUS_BUFFER_FULL 0x03
788 #define I2O_PARAMS_STATUS_BUFFER_TOO_SMALL 0x04
789 #define I2O_PARAMS_STATUS_FIELD_UNREADABLE 0x05
790 #define I2O_PARAMS_STATUS_FIELD_UNWRITEABLE 0x06
791 #define I2O_PARAMS_STATUS_INSUFFICIENT_FIELDS 0x07
792 #define I2O_PARAMS_STATUS_INVALID_GROUP_ID 0x08
793 #define I2O_PARAMS_STATUS_INVALID_OPERATION 0x09
794 #define I2O_PARAMS_STATUS_NO_KEY_FIELD 0x0A
795 #define I2O_PARAMS_STATUS_NO_SUCH_FIELD 0x0B
796 #define I2O_PARAMS_STATUS_NON_DYNAMIC_GROUP 0x0C
797 #define I2O_PARAMS_STATUS_OPERATION_ERROR 0x0D
798 #define I2O_PARAMS_STATUS_SCALAR_ERROR 0x0E
799 #define I2O_PARAMS_STATUS_TABLE_ERROR 0x0F
800 #define I2O_PARAMS_STATUS_WRONG_GROUP_TYPE 0x10
802 /* DetailedStatusCode defines for Executive, DDM, Util and Transaction error
803 * messages: Table 3-2 Detailed Status Codes.*/
805 #define I2O_DSC_SUCCESS 0x0000
806 #define I2O_DSC_BAD_KEY 0x0002
807 #define I2O_DSC_TCL_ERROR 0x0003
808 #define I2O_DSC_REPLY_BUFFER_FULL 0x0004
809 #define I2O_DSC_NO_SUCH_PAGE 0x0005
810 #define I2O_DSC_INSUFFICIENT_RESOURCE_SOFT 0x0006
811 #define I2O_DSC_INSUFFICIENT_RESOURCE_HARD 0x0007
812 #define I2O_DSC_CHAIN_BUFFER_TOO_LARGE 0x0009
813 #define I2O_DSC_UNSUPPORTED_FUNCTION 0x000A
814 #define I2O_DSC_DEVICE_LOCKED 0x000B
815 #define I2O_DSC_DEVICE_RESET 0x000C
816 #define I2O_DSC_INAPPROPRIATE_FUNCTION 0x000D
817 #define I2O_DSC_INVALID_INITIATOR_ADDRESS 0x000E
818 #define I2O_DSC_INVALID_MESSAGE_FLAGS 0x000F
819 #define I2O_DSC_INVALID_OFFSET 0x0010
820 #define I2O_DSC_INVALID_PARAMETER 0x0011
821 #define I2O_DSC_INVALID_REQUEST 0x0012
822 #define I2O_DSC_INVALID_TARGET_ADDRESS 0x0013
823 #define I2O_DSC_MESSAGE_TOO_LARGE 0x0014
824 #define I2O_DSC_MESSAGE_TOO_SMALL 0x0015
825 #define I2O_DSC_MISSING_PARAMETER 0x0016
826 #define I2O_DSC_TIMEOUT 0x0017
827 #define I2O_DSC_UNKNOWN_ERROR 0x0018
828 #define I2O_DSC_UNKNOWN_FUNCTION 0x0019
829 #define I2O_DSC_UNSUPPORTED_VERSION 0x001A
830 #define I2O_DSC_DEVICE_BUSY 0x001B
831 #define I2O_DSC_DEVICE_NOT_AVAILABLE 0x001C
833 /* DetailedStatusCode defines for Block Storage Operation: Table 6-7 Detailed
836 #define I2O_BSA_DSC_SUCCESS 0x0000
837 #define I2O_BSA_DSC_MEDIA_ERROR 0x0001
838 #define I2O_BSA_DSC_ACCESS_ERROR 0x0002
839 #define I2O_BSA_DSC_DEVICE_FAILURE 0x0003
840 #define I2O_BSA_DSC_DEVICE_NOT_READY 0x0004
841 #define I2O_BSA_DSC_MEDIA_NOT_PRESENT 0x0005
842 #define I2O_BSA_DSC_MEDIA_LOCKED 0x0006
843 #define I2O_BSA_DSC_MEDIA_FAILURE 0x0007
844 #define I2O_BSA_DSC_PROTOCOL_FAILURE 0x0008
845 #define I2O_BSA_DSC_BUS_FAILURE 0x0009
846 #define I2O_BSA_DSC_ACCESS_VIOLATION 0x000A
847 #define I2O_BSA_DSC_WRITE_PROTECTED 0x000B
848 #define I2O_BSA_DSC_DEVICE_RESET 0x000C
849 #define I2O_BSA_DSC_VOLUME_CHANGED 0x000D
850 #define I2O_BSA_DSC_TIMEOUT 0x000E
852 /* FailureStatusCodes, Table 3-3 Message Failure Codes */
854 #define I2O_FSC_TRANSPORT_SERVICE_SUSPENDED 0x81
855 #define I2O_FSC_TRANSPORT_SERVICE_TERMINATED 0x82
856 #define I2O_FSC_TRANSPORT_CONGESTION 0x83
857 #define I2O_FSC_TRANSPORT_FAILURE 0x84
858 #define I2O_FSC_TRANSPORT_STATE_ERROR 0x85
859 #define I2O_FSC_TRANSPORT_TIME_OUT 0x86
860 #define I2O_FSC_TRANSPORT_ROUTING_FAILURE 0x87
861 #define I2O_FSC_TRANSPORT_INVALID_VERSION 0x88
862 #define I2O_FSC_TRANSPORT_INVALID_OFFSET 0x89
863 #define I2O_FSC_TRANSPORT_INVALID_MSG_FLAGS 0x8A
864 #define I2O_FSC_TRANSPORT_FRAME_TOO_SMALL 0x8B
865 #define I2O_FSC_TRANSPORT_FRAME_TOO_LARGE 0x8C
866 #define I2O_FSC_TRANSPORT_INVALID_TARGET_ID 0x8D
867 #define I2O_FSC_TRANSPORT_INVALID_INITIATOR_ID 0x8E
868 #define I2O_FSC_TRANSPORT_INVALID_INITIATOR_CONTEXT 0x8F
869 #define I2O_FSC_TRANSPORT_UNKNOWN_FAILURE 0xFF
871 /* Device Claim Types */
872 #define I2O_CLAIM_PRIMARY 0x01000000
873 #define I2O_CLAIM_MANAGEMENT 0x02000000
874 #define I2O_CLAIM_AUTHORIZED 0x03000000
875 #define I2O_CLAIM_SECONDARY 0x04000000
877 /* Message header defines for VersionOffset */
878 #define I2OVER15 0x0001
879 #define I2OVER20 0x0002
881 /* Default is 1.5, FIXME: Need support for both 1.5 and 2.0 */
882 #define I2OVERSION I2OVER15
884 #define SGL_OFFSET_0 I2OVERSION
885 #define SGL_OFFSET_4 (0x0040 | I2OVERSION)
886 #define SGL_OFFSET_5 (0x0050 | I2OVERSION)
887 #define SGL_OFFSET_6 (0x0060 | I2OVERSION)
888 #define SGL_OFFSET_7 (0x0070 | I2OVERSION)
889 #define SGL_OFFSET_8 (0x0080 | I2OVERSION)
890 #define SGL_OFFSET_9 (0x0090 | I2OVERSION)
891 #define SGL_OFFSET_10 (0x00A0 | I2OVERSION)
893 #define TRL_OFFSET_5 (0x0050 | I2OVERSION)
894 #define TRL_OFFSET_6 (0x0060 | I2OVERSION)
896 /* Transaction Reply Lists (TRL) Control Word structure */
897 #define TRL_SINGLE_FIXED_LENGTH 0x00
898 #define TRL_SINGLE_VARIABLE_LENGTH 0x40
899 #define TRL_MULTIPLE_FIXED_LENGTH 0x80
901 /* msg header defines for MsgFlags */
902 #define MSG_STATIC 0x0100
903 #define MSG_64BIT_CNTXT 0x0200
904 #define MSG_MULTI_TRANS 0x1000
905 #define MSG_FAIL 0x2000
906 #define MSG_FINAL 0x4000
907 #define MSG_REPLY 0x8000
909 /* minimum size msg */
910 #define THREE_WORD_MSG_SIZE 0x00030000
911 #define FOUR_WORD_MSG_SIZE 0x00040000
912 #define FIVE_WORD_MSG_SIZE 0x00050000
913 #define SIX_WORD_MSG_SIZE 0x00060000
914 #define SEVEN_WORD_MSG_SIZE 0x00070000
915 #define EIGHT_WORD_MSG_SIZE 0x00080000
916 #define NINE_WORD_MSG_SIZE 0x00090000
917 #define TEN_WORD_MSG_SIZE 0x000A0000
918 #define ELEVEN_WORD_MSG_SIZE 0x000B0000
919 #define I2O_MESSAGE_SIZE(x) ((x)<<16)
921 /* Special TID Assignments */
923 #define ADAPTER_TID 0
926 #define MSG_FRAME_SIZE 128 /* i2o_scsi assumes >= 32 */
927 #define REPLY_FRAME_SIZE 17
928 #define SG_TABLESIZE 30
929 #define NMBR_MSG_FRAMES 128
931 #define MSG_POOL_SIZE (MSG_FRAME_SIZE*NMBR_MSG_FRAMES*sizeof(u32))
933 #define I2O_POST_WAIT_OK 0
934 #define I2O_POST_WAIT_TIMEOUT -ETIMEDOUT
936 #define I2O_CONTEXT_LIST_MIN_LENGTH 15
937 #define I2O_CONTEXT_LIST_USED 0x01
938 #define I2O_CONTEXT_LIST_DELETED 0x02
941 #define I2O_TIMEOUT_INIT_OUTBOUND_QUEUE 15
942 #define I2O_TIMEOUT_MESSAGE_GET 5
943 #define I2O_TIMEOUT_RESET 30
944 #define I2O_TIMEOUT_STATUS_GET 5
945 #define I2O_TIMEOUT_LCT_GET 20
946 #define I2O_TIMEOUT_SCSI_SCB_ABORT 240
949 #define I2O_HRT_GET_TRIES 3
950 #define I2O_LCT_GET_TRIES 3
952 /* request queue sizes */
953 #define I2O_MAX_SECTORS 1024
954 #define I2O_MAX_SEGMENTS 128
956 #define I2O_REQ_MEMPOOL_SIZE 32
958 #endif /* __KERNEL__ */