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.
20 #ifdef __KERNEL__ /* This file to be included by kernel only */
22 #include <linux/i2o-dev.h>
24 /* How many different OSM's are we allowing */
25 #define MAX_I2O_MODULES 64
27 /* How many OSMs can register themselves for device status updates? */
28 #define I2O_MAX_MANAGERS 4
30 #include <asm/semaphore.h> /* Needed for MUTEX init macros */
31 #include <linux/config.h>
32 #include <linux/notifier.h>
33 #include <asm/atomic.h>
46 u32 initiator_context
;
51 * Each I2O device entity has one or more of these. There is one
56 i2o_lct_entry lct_data
; /* Device LCT information */
58 int i2oversion
; /* I2O version supported. Actually there
59 * should be high and low version */
61 struct proc_dir_entry
* proc_entry
; /* /proc dir */
64 struct i2o_handler
*owner
;
66 /* Management users */
67 struct i2o_handler
*managers
[I2O_MAX_MANAGERS
];
70 struct i2o_controller
*controller
; /* Controlling IOP */
71 struct i2o_device
*next
; /* Chain */
72 char dev_name
[8]; /* linux /dev name if available */
76 * Resource data for each PCI I2O controller
88 * Transport types supported by I2O stack
90 #define I2O_TYPE_PCI 0x01 /* PCI I2O controller */
94 * Each I2O controller has one of these objects
103 struct notifier_block
*event_notifer
; /* Events */
105 struct i2o_device
*devices
; /* I2O device chain */
106 struct i2o_controller
*next
; /* Controller chain */
107 volatile u32
*post_port
; /* Inbout port */
108 volatile u32
*reply_port
; /* Outbound port */
109 volatile u32
*irq_mask
; /* Interrupt register */
111 /* Dynamic LCT related data */
112 struct semaphore lct_sem
;
116 i2o_status_block
*status_block
; /* IOP status block */
117 i2o_lct
*lct
; /* Logical Config Table */
118 i2o_lct
*dlct
; /* Temp LCT */
119 i2o_hrt
*hrt
; /* HW Resource Table */
121 u32 mem_offset
; /* MFA offset */
122 u32 mem_phys
; /* MFA physical */
124 struct proc_dir_entry
* proc_entry
; /* /proc dir */
127 { /* Bus information */
131 /* Bus specific destructor */
132 void (*destructor
)(struct i2o_controller
*);
134 /* Bus specific attach/detach */
135 int (*bind
)(struct i2o_controller
*, struct i2o_device
*);
137 /* Bus specific initiator */
138 int (*unbind
)(struct i2o_controller
*, struct i2o_device
*);
140 /* Bus specific enable/disable */
141 void (*bus_enable
)(struct i2o_controller
*c
);
142 void (*bus_disable
)(struct i2o_controller
*c
);
144 void *page_frame
; /* Message buffers */
148 * OSM resgistration block
150 * Each OSM creates at least one of these and registers it with the
151 * I2O core through i2o_register_handler. An OSM may want to
152 * register more than one if it wants a fast path to a reply
153 * handler by having a separate initiator context for each
158 /* Message reply handler */
159 void (*reply
)(struct i2o_handler
*, struct i2o_controller
*, struct i2o_message
*);
161 /* New device notification handler */
162 void (*new_dev_notify
)(struct i2o_controller
*, struct i2o_device
*);
164 /* Device deltion handler */
165 void (*dev_del_notify
)(struct i2o_controller
*, struct i2o_device
*);
167 /* Reboot notification handler */
168 void (*reboot_notify
)(void);
170 char *name
; /* OSM name */
171 int context
; /* Low 8 bits of the transaction info */
172 u32
class; /* I2O classes that this driver handles */
173 /* User data follows */
178 * Used by bus specific modules to communicate with the core
180 * This is needed because the bus modules cannot make direct
181 * calls to the core as this results in the i2o_bus_specific_module
182 * being dependent on the core, not the otherway around.
183 * In that case, a 'modprobe i2o_lan' loads i2o_core & i2o_lan,
184 * but _not_ i2o_pci...which makes the whole thing pretty useless :)
187 struct i2o_core_func_table
189 int (*install
)(struct i2o_controller
*);
190 int (*activate
)(struct i2o_controller
*);
191 struct i2o_controller
* (*find
)(int);
192 void (*unlock
)(struct i2o_controller
*);
193 void (*run_queue
)(struct i2o_controller
*c
);
194 int (*delete)(struct i2o_controller
*);
199 * I2O System table entry
201 * The system table contains information about all the IOPs in the
202 * system. It is sent to all IOPs so that they can create peer2peer
203 * connections between them.
205 struct i2o_sys_tbl_entry
218 u32 iop_capabilities
;
231 struct i2o_sys_tbl_entry iops
[0];
237 extern inline u32
I2O_POST_READ32(struct i2o_controller
*c
)
239 return *c
->post_port
;
242 extern inline void I2O_POST_WRITE32(struct i2o_controller
*c
, u32 Val
)
248 extern inline u32
I2O_REPLY_READ32(struct i2o_controller
*c
)
250 return *c
->reply_port
;
253 extern inline void I2O_REPLY_WRITE32(struct i2o_controller
*c
, u32 Val
)
259 extern inline u32
I2O_IRQ_READ32(struct i2o_controller
*c
)
264 extern inline void I2O_IRQ_WRITE32(struct i2o_controller
*c
, u32 Val
)
270 extern inline void i2o_post_message(struct i2o_controller
*c
, u32 m
)
272 /* The second line isnt spurious - thats forcing PCI posting */
273 I2O_POST_WRITE32(c
,m
);
274 (void) I2O_IRQ_READ32(c
);
277 extern inline void i2o_flush_reply(struct i2o_controller
*c
, u32 m
)
279 I2O_REPLY_WRITE32(c
,m
);
282 extern struct i2o_controller
*i2o_find_controller(int);
283 extern void i2o_unlock_controller(struct i2o_controller
*);
284 extern struct i2o_controller
*i2o_controller_chain
;
285 extern int i2o_num_controllers
;
286 extern int i2o_status_get(struct i2o_controller
*);
288 extern int i2o_install_handler(struct i2o_handler
*);
289 extern int i2o_remove_handler(struct i2o_handler
*);
291 extern int i2o_claim_device(struct i2o_device
*, struct i2o_handler
*);
292 extern int i2o_release_device(struct i2o_device
*, struct i2o_handler
*);
293 extern int i2o_device_notify_on(struct i2o_device
*, struct i2o_handler
*);
294 extern int i2o_device_notify_off(struct i2o_device
*, struct i2o_handler
*);
296 extern int i2o_post_this(struct i2o_controller
*, u32
*, int);
297 extern int i2o_post_wait(struct i2o_controller
*, u32
*, int, int);
299 extern int i2o_query_scalar(struct i2o_controller
*, int, int, int, void *, int);
300 extern int i2o_set_scalar(struct i2o_controller
*, int, int, int, void *, int);
301 extern int i2o_query_table(int, struct i2o_controller
*, int, int, int, void *,
303 extern int i2o_clear_table(struct i2o_controller
*, int, int);
304 extern int i2o_row_add_table(struct i2o_controller
*, int, int, int, void *,
306 extern int i2o_issue_params(int, struct i2o_controller
*, int, void *,
309 extern int i2o_event_register(struct i2o_controller
*, u32
, u32
, u32
, u32
);
310 extern int i2o_event_ack(struct i2o_controller
*, u32
*);
312 extern void i2o_report_status(const char *, const char *, u32
*);
313 extern void i2o_dump_message(u32
*);
314 extern const char *i2o_get_class_name(int);
316 extern int i2o_install_controller(struct i2o_controller
*);
317 extern int i2o_activate_controller(struct i2o_controller
*);
318 extern void i2o_run_queue(struct i2o_controller
*);
319 extern int i2o_delete_controller(struct i2o_controller
*);
329 #define I2O_CMD_ADAPTER_ASSIGN 0xB3
330 #define I2O_CMD_ADAPTER_READ 0xB2
331 #define I2O_CMD_ADAPTER_RELEASE 0xB5
332 #define I2O_CMD_BIOS_INFO_SET 0xA5
333 #define I2O_CMD_BOOT_DEVICE_SET 0xA7
334 #define I2O_CMD_CONFIG_VALIDATE 0xBB
335 #define I2O_CMD_CONN_SETUP 0xCA
336 #define I2O_CMD_DDM_DESTROY 0xB1
337 #define I2O_CMD_DDM_ENABLE 0xD5
338 #define I2O_CMD_DDM_QUIESCE 0xC7
339 #define I2O_CMD_DDM_RESET 0xD9
340 #define I2O_CMD_DDM_SUSPEND 0xAF
341 #define I2O_CMD_DEVICE_ASSIGN 0xB7
342 #define I2O_CMD_DEVICE_RELEASE 0xB9
343 #define I2O_CMD_HRT_GET 0xA8
344 #define I2O_CMD_ADAPTER_CLEAR 0xBE
345 #define I2O_CMD_ADAPTER_CONNECT 0xC9
346 #define I2O_CMD_ADAPTER_RESET 0xBD
347 #define I2O_CMD_LCT_NOTIFY 0xA2
348 #define I2O_CMD_OUTBOUND_INIT 0xA1
349 #define I2O_CMD_PATH_ENABLE 0xD3
350 #define I2O_CMD_PATH_QUIESCE 0xC5
351 #define I2O_CMD_PATH_RESET 0xD7
352 #define I2O_CMD_STATIC_MF_CREATE 0xDD
353 #define I2O_CMD_STATIC_MF_RELEASE 0xDF
354 #define I2O_CMD_STATUS_GET 0xA0
355 #define I2O_CMD_SW_DOWNLOAD 0xA9
356 #define I2O_CMD_SW_UPLOAD 0xAB
357 #define I2O_CMD_SW_REMOVE 0xAD
358 #define I2O_CMD_SYS_ENABLE 0xD1
359 #define I2O_CMD_SYS_MODIFY 0xC1
360 #define I2O_CMD_SYS_QUIESCE 0xC3
361 #define I2O_CMD_SYS_TAB_SET 0xA3
366 #define I2O_CMD_UTIL_NOP 0x00
367 #define I2O_CMD_UTIL_ABORT 0x01
368 #define I2O_CMD_UTIL_CLAIM 0x09
369 #define I2O_CMD_UTIL_RELEASE 0x0B
370 #define I2O_CMD_UTIL_PARAMS_GET 0x06
371 #define I2O_CMD_UTIL_PARAMS_SET 0x05
372 #define I2O_CMD_UTIL_EVT_REGISTER 0x13
373 #define I2O_CMD_UTIL_EVT_ACK 0x14
374 #define I2O_CMD_UTIL_CONFIG_DIALOG 0x10
375 #define I2O_CMD_UTIL_DEVICE_RESERVE 0x0D
376 #define I2O_CMD_UTIL_DEVICE_RELEASE 0x0F
377 #define I2O_CMD_UTIL_LOCK 0x17
378 #define I2O_CMD_UTIL_LOCK_RELEASE 0x19
379 #define I2O_CMD_UTIL_REPLY_FAULT_NOTIFY 0x15
382 * SCSI Host Bus Adapter Class
384 #define I2O_CMD_SCSI_EXEC 0x81
385 #define I2O_CMD_SCSI_ABORT 0x83
386 #define I2O_CMD_SCSI_BUSRESET 0x27
389 * Random Block Storage Class
391 #define I2O_CMD_BLOCK_READ 0x30
392 #define I2O_CMD_BLOCK_WRITE 0x31
393 #define I2O_CMD_BLOCK_CFLUSH 0x37
394 #define I2O_CMD_BLOCK_MLOCK 0x49
395 #define I2O_CMD_BLOCK_MUNLOCK 0x4B
396 #define I2O_CMD_BLOCK_MMOUNT 0x41
397 #define I2O_CMD_BLOCK_MEJECT 0x43
399 #define I2O_PRIVATE_MSG 0xFF
401 /* Command status values */
403 #define I2O_CMD_IN_PROGRESS 0x01
404 #define I2O_CMD_REJECTED 0x02
405 #define I2O_CMD_FAILED 0x03
406 #define I2O_CMD_COMPLETED 0x04
408 /* I2O API function return values */
410 #define I2O_RTN_NO_ERROR 0
411 #define I2O_RTN_NOT_INIT 1
412 #define I2O_RTN_FREE_Q_EMPTY 2
413 #define I2O_RTN_TCB_ERROR 3
414 #define I2O_RTN_TRANSACTION_ERROR 4
415 #define I2O_RTN_ADAPTER_ALREADY_INIT 5
416 #define I2O_RTN_MALLOC_ERROR 6
417 #define I2O_RTN_ADPTR_NOT_REGISTERED 7
418 #define I2O_RTN_MSG_REPLY_TIMEOUT 8
419 #define I2O_RTN_NO_STATUS 9
420 #define I2O_RTN_NO_FIRM_VER 10
421 #define I2O_RTN_NO_LINK_SPEED 11
423 /* Reply message status defines for all messages */
425 #define I2O_REPLY_STATUS_SUCCESS 0x00
426 #define I2O_REPLY_STATUS_ABORT_DIRTY 0x01
427 #define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02
428 #define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03
429 #define I2O_REPLY_STATUS_ERROR_DIRTY 0x04
430 #define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05
431 #define I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER 0x06
432 #define I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY 0x08
433 #define I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x09
434 #define I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x0A
435 #define I2O_REPLY_STATUS_TRANSACTION_ERROR 0x0B
436 #define I2O_REPLY_STATUS_PROGRESS_REPORT 0x80
438 /* Status codes and Error Information for Parameter functions */
440 #define I2O_PARAMS_STATUS_SUCCESS 0x00
441 #define I2O_PARAMS_STATUS_BAD_KEY_ABORT 0x01
442 #define I2O_PARAMS_STATUS_BAD_KEY_CONTINUE 0x02
443 #define I2O_PARAMS_STATUS_BUFFER_FULL 0x03
444 #define I2O_PARAMS_STATUS_BUFFER_TOO_SMALL 0x04
445 #define I2O_PARAMS_STATUS_FIELD_UNREADABLE 0x05
446 #define I2O_PARAMS_STATUS_FIELD_UNWRITEABLE 0x06
447 #define I2O_PARAMS_STATUS_INSUFFICIENT_FIELDS 0x07
448 #define I2O_PARAMS_STATUS_INVALID_GROUP_ID 0x08
449 #define I2O_PARAMS_STATUS_INVALID_OPERATION 0x09
450 #define I2O_PARAMS_STATUS_NO_KEY_FIELD 0x0A
451 #define I2O_PARAMS_STATUS_NO_SUCH_FIELD 0x0B
452 #define I2O_PARAMS_STATUS_NON_DYNAMIC_GROUP 0x0C
453 #define I2O_PARAMS_STATUS_OPERATION_ERROR 0x0D
454 #define I2O_PARAMS_STATUS_SCALAR_ERROR 0x0E
455 #define I2O_PARAMS_STATUS_TABLE_ERROR 0x0F
456 #define I2O_PARAMS_STATUS_WRONG_GROUP_TYPE 0x10
458 /* DetailedStatusCode defines for Executive, DDM, Util and Transaction error
459 * messages: Table 3-2 Detailed Status Codes.*/
461 #define I2O_DSC_SUCCESS 0x0000
462 #define I2O_DSC_BAD_KEY 0x0002
463 #define I2O_DSC_TCL_ERROR 0x0003
464 #define I2O_DSC_REPLY_BUFFER_FULL 0x0004
465 #define I2O_DSC_NO_SUCH_PAGE 0x0005
466 #define I2O_DSC_INSUFFICIENT_RESOURCE_SOFT 0x0006
467 #define I2O_DSC_INSUFFICIENT_RESOURCE_HARD 0x0007
468 #define I2O_DSC_CHAIN_BUFFER_TOO_LARGE 0x0009
469 #define I2O_DSC_UNSUPPORTED_FUNCTION 0x000A
470 #define I2O_DSC_DEVICE_LOCKED 0x000B
471 #define I2O_DSC_DEVICE_RESET 0x000C
472 #define I2O_DSC_INAPPROPRIATE_FUNCTION 0x000D
473 #define I2O_DSC_INVALID_INITIATOR_ADDRESS 0x000E
474 #define I2O_DSC_INVALID_MESSAGE_FLAGS 0x000F
475 #define I2O_DSC_INVALID_OFFSET 0x0010
476 #define I2O_DSC_INVALID_PARAMETER 0x0011
477 #define I2O_DSC_INVALID_REQUEST 0x0012
478 #define I2O_DSC_INVALID_TARGET_ADDRESS 0x0013
479 #define I2O_DSC_MESSAGE_TOO_LARGE 0x0014
480 #define I2O_DSC_MESSAGE_TOO_SMALL 0x0015
481 #define I2O_DSC_MISSING_PARAMETER 0x0016
482 #define I2O_DSC_TIMEOUT 0x0017
483 #define I2O_DSC_UNKNOWN_ERROR 0x0018
484 #define I2O_DSC_UNKNOWN_FUNCTION 0x0019
485 #define I2O_DSC_UNSUPPORTED_VERSION 0x001A
486 #define I2O_DSC_DEVICE_BUSY 0x001B
487 #define I2O_DSC_DEVICE_NOT_AVAILABLE 0x001C
489 /* FailureStatusCodes, Table 3-3 Message Failure Codes */
491 #define I2O_FSC_TRANSPORT_SERVICE_SUSPENDED 0x81
492 #define I2O_FSC_TRANSPORT_SERVICE_TERMINATED 0x82
493 #define I2O_FSC_TRANSPORT_CONGESTION 0x83
494 #define I2O_FSC_TRANSPORT_FAILURE 0x84
495 #define I2O_FSC_TRANSPORT_STATE_ERROR 0x85
496 #define I2O_FSC_TRANSPORT_TIME_OUT 0x86
497 #define I2O_FSC_TRANSPORT_ROUTING_FAILURE 0x87
498 #define I2O_FSC_TRANSPORT_INVALID_VERSION 0x88
499 #define I2O_FSC_TRANSPORT_INVALID_OFFSET 0x89
500 #define I2O_FSC_TRANSPORT_INVALID_MSG_FLAGS 0x8A
501 #define I2O_FSC_TRANSPORT_FRAME_TOO_SMALL 0x8B
502 #define I2O_FSC_TRANSPORT_FRAME_TOO_LARGE 0x8C
503 #define I2O_FSC_TRANSPORT_INVALID_TARGET_ID 0x8D
504 #define I2O_FSC_TRANSPORT_INVALID_INITIATOR_ID 0x8E
505 #define I2O_FSC_TRANSPORT_INVALID_INITIATOR_CONTEXT 0x8F
506 #define I2O_FSC_TRANSPORT_UNKNOWN_FAILURE 0xFF
508 /* Device Claim Types */
509 #define I2O_CLAIM_PRIMARY 0x01000000
510 #define I2O_CLAIM_MANAGEMENT 0x02000000
511 #define I2O_CLAIM_AUTHORIZED 0x03000000
512 #define I2O_CLAIM_SECONDARY 0x04000000
514 /* Message header defines for VersionOffset */
515 #define I2OVER15 0x0001
516 #define I2OVER20 0x0002
518 /* Default is 1.5, FIXME: Need support for both 1.5 and 2.0 */
519 #define I2OVERSION I2OVER15
521 #define SGL_OFFSET_0 I2OVERSION
522 #define SGL_OFFSET_4 (0x0040 | I2OVERSION)
523 #define SGL_OFFSET_5 (0x0050 | I2OVERSION)
524 #define SGL_OFFSET_6 (0x0060 | I2OVERSION)
525 #define SGL_OFFSET_7 (0x0070 | I2OVERSION)
526 #define SGL_OFFSET_8 (0x0080 | I2OVERSION)
527 #define SGL_OFFSET_9 (0x0090 | I2OVERSION)
528 #define SGL_OFFSET_10 (0x00A0 | I2OVERSION)
530 #define TRL_OFFSET_5 (0x0050 | I2OVERSION)
531 #define TRL_OFFSET_6 (0x0060 | I2OVERSION)
533 /* Transaction Reply Lists (TRL) Control Word structure */
534 #define TRL_SINGLE_FIXED_LENGTH 0x00
535 #define TRL_SINGLE_VARIABLE_LENGTH 0x40
536 #define TRL_MULTIPLE_FIXED_LENGTH 0x80
539 /* msg header defines for MsgFlags */
540 #define MSG_STATIC 0x0100
541 #define MSG_64BIT_CNTXT 0x0200
542 #define MSG_MULTI_TRANS 0x1000
543 #define MSG_FAIL 0x2000
544 #define MSG_FINAL 0x4000
545 #define MSG_REPLY 0x8000
547 /* minimum size msg */
548 #define THREE_WORD_MSG_SIZE 0x00030000
549 #define FOUR_WORD_MSG_SIZE 0x00040000
550 #define FIVE_WORD_MSG_SIZE 0x00050000
551 #define SIX_WORD_MSG_SIZE 0x00060000
552 #define SEVEN_WORD_MSG_SIZE 0x00070000
553 #define EIGHT_WORD_MSG_SIZE 0x00080000
554 #define NINE_WORD_MSG_SIZE 0x00090000
555 #define TEN_WORD_MSG_SIZE 0x000A0000
556 #define I2O_MESSAGE_SIZE(x) ((x)<<16)
559 /* Special TID Assignments */
561 #define ADAPTER_TID 0
564 #define MSG_FRAME_SIZE 128
565 #define NMBR_MSG_FRAMES 128
567 #define MSG_POOL_SIZE 16384
569 #define I2O_POST_WAIT_OK 0
570 #define I2O_POST_WAIT_TIMEOUT -ETIMEDOUT
572 #endif /* __KERNEL__ */