1101100Ssos/*- 2114154Ssos * Copyright (c) 2001,2002,2003 S�ren Schmidt <sos@FreeBSD.org> 3101100Ssos * All rights reserved. 4101100Ssos * 5101100Ssos * Redistribution and use in source and binary forms, with or without 6101100Ssos * modification, are permitted provided that the following conditions 7101100Ssos * are met: 8101100Ssos * 1. Redistributions of source code must retain the above copyright 9101100Ssos * notice, this list of conditions and the following disclaimer, 10101100Ssos * without modification, immediately at the beginning of the file. 11101100Ssos * 2. Redistributions in binary form must reproduce the above copyright 12101100Ssos * notice, this list of conditions and the following disclaimer in the 13101100Ssos * documentation and/or other materials provided with the distribution. 14101100Ssos * 3. The name of the author may not be used to endorse or promote products 15101100Ssos * derived from this software without specific prior written permission. 16101100Ssos * 17101100Ssos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18101100Ssos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19101100Ssos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20101100Ssos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21101100Ssos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22101100Ssos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23101100Ssos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24101100Ssos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25101100Ssos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26101100Ssos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27101100Ssos * 28101100Ssos * $FreeBSD$ 29101100Ssos */ 30101100Ssos 31101100Ssos/* misc defines */ 32101100SsosMALLOC_DECLARE(M_PSTIOP); 33101100Ssos#define I2O_IOP_OUTBOUND_FRAME_COUNT 32 34101100Ssos#define I2O_IOP_OUTBOUND_FRAME_SIZE 0x20 35101100Ssos 36101100Ssos/* structure defs */ 37101100Ssosstruct out_mfa_buf { 38101100Ssos u_int32_t buf[I2O_IOP_OUTBOUND_FRAME_SIZE]; 39101100Ssos}; 40101100Ssos 41101100Ssosstruct iop_softc { 42102058Ssos struct resource *r_mem; 43102058Ssos struct resource *r_irq; 44102058Ssos caddr_t ibase; 45102058Ssos caddr_t obase; 46102058Ssos u_int32_t phys_obase; 47102058Ssos struct i2o_registers *reg; 48102058Ssos struct i2o_status_get_reply *status; 49102058Ssos int lct_count; 50102058Ssos struct i2o_lct_entry *lct; 51114154Ssos int ism; 52102058Ssos device_t dev; 53114154Ssos struct mtx mtx; 54114154Ssos int outstanding; 55102058Ssos void *handle; 56102058Ssos struct intr_config_hook *iop_delayed_attach; 57101100Ssos}; 58101100Ssos 59101100Ssos/* structure at start of IOP shared mem */ 60101100Ssosstruct i2o_registers { 61101100Ssos volatile u_int32_t apic_select; 62101100Ssos volatile u_int32_t reserved0; 63101100Ssos volatile u_int32_t apic_winreg; 64101100Ssos volatile u_int32_t reserved1; 65101100Ssos volatile u_int32_t iqueue_reg0; 66101100Ssos volatile u_int32_t iqueue_reg1; 67101100Ssos volatile u_int32_t oqueue_reg0; 68101100Ssos volatile u_int32_t oqueue_reg1; 69101100Ssos volatile u_int32_t iqueue_event; 70101100Ssos volatile u_int32_t iqueue_intr_status; 71101100Ssos volatile u_int32_t iqueue_intr_mask; 72101100Ssos volatile u_int32_t oqueue_event; 73101100Ssos volatile u_int32_t oqueue_intr_status; 74101100Ssos volatile u_int32_t oqueue_intr_mask; 75102058Ssos#define I2O_OUT_INTR_QUEUE 0x08 76102058Ssos#define I2O_OUT_INTR_BELL 0x04 77102058Ssos#define I2O_OUT_INTR_MSG1 0x02 78102058Ssos#define I2O_OUT_INTR_MSG0 0x01 79101100Ssos 80101100Ssos volatile u_int64_t reserved2; 81101100Ssos volatile u_int32_t iqueue; 82101100Ssos volatile u_int32_t oqueue; 83101100Ssos volatile u_int64_t reserved3; 84101100Ssos volatile u_int64_t mac_addr; 85101100Ssos volatile u_int32_t ip_addr; 86101100Ssos volatile u_int32_t ip_mask; 87101100Ssos}; 88101100Ssos 89101100Ssos/* Scatter/Gather List management */ 90101100Ssosstruct i2o_sgl { 91102058Ssos u_int32_t count:24; 92102058Ssos#define I2O_SGL_CNT_MASK 0xffffff 93101100Ssos 94102058Ssos u_int32_t flags:8; 95102058Ssos#define I2O_SGL_SIMPLE 0x10 96102058Ssos#define I2O_SGL_PAGELIST 0x20 97102058Ssos#define I2O_SGL_CHAIN 0x30 98102058Ssos#define I2O_SGL_ATTRIBUTE 0x7c 99102058Ssos#define I2O_SGL_BC0 0x01 100102058Ssos#define I2O_SGL_BC1 0x02 101102058Ssos#define I2O_SGL_DIR 0x04 102102058Ssos#define I2O_SGL_LA 0x08 103102058Ssos#define I2O_SGL_EOB 0x40 104102058Ssos#define I2O_SGL_END 0x80 105101100Ssos 106102058Ssos u_int32_t phys_addr[1]; 107103870Salfred} __packed; 108101100Ssos 109101100Ssos#define I2O_SGL_MAX_SEGS ((I2O_IOP_OUTBOUND_FRAME_SIZE - (8 + 2)) + 1) 110101100Ssos 111101100Ssos/* i2o command codes */ 112102058Ssos#define I2O_UTIL_NOP 0x00 113102058Ssos#define I2O_UTIL_PARAMS_GET 0x06 114102058Ssos#define I2O_UTIL_CLAIM 0x09 115102058Ssos#define I2O_UTIL_CONFIG_DIALOG 0x10 116102058Ssos#define I2O_UTIL_EVENT_REGISTER 0x13 117102058Ssos#define I2O_BSA_BLOCK_READ 0x30 118102058Ssos#define I2O_BSA_BLOCK_WRITE 0x31 119102058Ssos#define I2O_BSA_CACHE_FLUSH 0x37 120102058Ssos#define I2O_EXEC_STATUS_GET 0xa0 121102058Ssos#define I2O_EXEC_OUTBOUND_INIT 0xa1 122102058Ssos#define I2O_EXEC_LCT_NOTIFY 0xa2 123102058Ssos#define I2O_EXEC_SYSTAB_SET 0xa3 124102058Ssos#define I2O_EXEC_IOP_RESET 0xbd 125102058Ssos#define I2O_EXEC_SYS_ENABLE 0xd1 126114154Ssos#define I2O_PRIVATE_MESSAGE 0xff 127101100Ssos 128101100Ssos/* basic message layout */ 129101100Ssosstruct i2o_basic_message { 130101100Ssos u_int8_t version:4; 131101100Ssos u_int8_t offset:4; 132101100Ssos u_int8_t message_flags; 133101100Ssos u_int16_t message_size; 134101100Ssos u_int32_t target_address:12; 135101100Ssos u_int32_t initiator_address:12; 136101100Ssos u_int32_t function:8; 137101100Ssos u_int32_t initiator_context; 138102058Ssos u_int32_t transaction_context; 139103870Salfred} __packed; 140101100Ssos 141101100Ssos/* basic reply layout */ 142101100Ssosstruct i2o_single_reply { 143101100Ssos u_int8_t version_offset; 144101100Ssos u_int8_t message_flags; 145101100Ssos#define I2O_MESSAGE_FLAGS_STATIC 0x01 146101100Ssos#define I2O_MESSAGE_FLAGS_64BIT 0x02 147101100Ssos#define I2O_MESSAGE_FLAGS_MULTIPLE 0x10 148101100Ssos#define I2O_MESSAGE_FLAGS_FAIL 0x20 149101100Ssos#define I2O_MESSAGE_FLAGS_LAST 0x40 150101100Ssos#define I2O_MESSAGE_FLAGS_REPLY 0x80 151101100Ssos 152101100Ssos u_int16_t message_size; 153101100Ssos u_int32_t target_address:12; 154101100Ssos u_int32_t initiator_address:12; 155101100Ssos u_int32_t function:8; 156101100Ssos u_int32_t initiator_context; 157101100Ssos u_int32_t transaction_context; 158101100Ssos u_int16_t detailed_status; 159101100Ssos#define I2O_DETAIL_STATUS_SUCCESS 0x0000 160101100Ssos#define I2O_DETAIL_STATUS_BAD_KEY 0x0002 161101100Ssos#define I2O_DETAIL_STATUS_TCL_ERROR 0x0003 162101100Ssos#define I2O_DETAIL_STATUS_REPLY_BUFFER_FULL 0x0004 163101100Ssos#define I2O_DETAIL_STATUS_NO_SUCH_PAGE 0x0005 164101100Ssos#define I2O_DETAIL_STATUS_INSUFFICIENT_RESOURCE_SOFT 0x0006 165101100Ssos#define I2O_DETAIL_STATUS_INSUFFICIENT_RESOURCE_HARD 0x0007 166101100Ssos#define I2O_DETAIL_STATUS_CHAIN_BUFFER_TOO_LARGE 0x0009 167101100Ssos#define I2O_DETAIL_STATUS_UNSUPPORTED_FUNCTION 0x000a 168101100Ssos#define I2O_DETAIL_STATUS_DEVICE_LOCKED 0x000b 169101100Ssos#define I2O_DETAIL_STATUS_DEVICE_RESET 0x000c 170101100Ssos#define I2O_DETAIL_STATUS_INAPPROPRIATE_FUNCTION 0x000d 171101100Ssos#define I2O_DETAIL_STATUS_INVALID_INITIATOR_ADDRESS 0x000e 172101100Ssos#define I2O_DETAIL_STATUS_INVALID_MESSAGE_FLAGS 0x000f 173101100Ssos#define I2O_DETAIL_STATUS_INVALID_OFFSET 0x0010 174101100Ssos#define I2O_DETAIL_STATUS_INVALID_PARAMETER 0x0011 175101100Ssos#define I2O_DETAIL_STATUS_INVALID_REQUEST 0x0012 176101100Ssos#define I2O_DETAIL_STATUS_INVALID_TARGET_ADDRESS 0x0013 177101100Ssos#define I2O_DETAIL_STATUS_MESSAGE_TOO_LARGE 0x0014 178101100Ssos#define I2O_DETAIL_STATUS_MESSAGE_TOO_SMALL 0x0015 179101100Ssos#define I2O_DETAIL_STATUS_MISSING_PARAMETER 0x0016 180101100Ssos#define I2O_DETAIL_STATUS_TIMEOUT 0x0017 181101100Ssos#define I2O_DETAIL_STATUS_UNKNOWN_ERROR 0x0018 182101100Ssos#define I2O_DETAIL_STATUS_UNKNOWN_FUNCTION 0x0019 183101100Ssos#define I2O_DETAIL_STATUS_UNSUPPORTED_VERSION 0x001a 184101100Ssos#define I2O_DETAIL_STATUS_DEVICE_BUSY 0x001b 185101100Ssos#define I2O_DETAIL_STATUS_DEVICE_NOT_AVAILABLE 0x001c 186101100Ssos 187101100Ssos u_int8_t retry_count; 188101100Ssos u_int8_t status; 189101100Ssos#define I2O_REPLY_STATUS_SUCCESS 0x00 190101100Ssos#define I2O_REPLY_STATUS_ABORT_DIRTY 0x01 191101100Ssos#define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02 192101100Ssos#define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03 193101100Ssos#define I2O_REPLY_STATUS_ERROR_DIRTY 0x04 194101100Ssos#define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05 195101100Ssos#define I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER 0x06 196101100Ssos#define I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY 0x08 197101100Ssos#define I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x09 198101100Ssos#define I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x0a 199101100Ssos#define I2O_REPLY_STATUS_TRANSACTION_ERROR 0x0b 200101100Ssos#define I2O_REPLY_STATUS_PROGRESS_REPORT 0x80 201101100Ssos 202101100Ssos u_int32_t donecount; 203103870Salfred} __packed; 204101100Ssos 205101100Ssosstruct i2o_fault_reply { 206101100Ssos u_int8_t version_offset; 207101100Ssos u_int8_t message_flags; 208101100Ssos u_int16_t message_size; 209101100Ssos u_int32_t target_address:12; 210101100Ssos u_int32_t initiator_address:12; 211101100Ssos u_int32_t function:8; 212101100Ssos u_int32_t initiator_context; 213101100Ssos u_int32_t transaction_context; 214101100Ssos u_int8_t lowest_version; 215101100Ssos u_int8_t highest_version; 216101100Ssos u_int8_t severity; 217101100Ssos#define I2O_SEVERITY_FORMAT_ERROR 0x01 218101100Ssos#define I2O_SEVERITY_PATH_ERROR 0x02 219101100Ssos#define I2O_SEVERITY_PATH_STATE 0x04 220101100Ssos#define I2O_SEVERITY_CONGESTION 0x08 221101100Ssos 222101100Ssos u_int8_t failure_code; 223101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_SERVICE_SUSPENDED 0x81 224101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_SERVICE_TERMINATED 0x82 225101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_CONGESTION 0x83 226101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_FAIL 0x84 227101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_STATE_ERROR 0x85 228101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_TIME_OUT 0x86 229101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_ROUTING_FAILURE 0x87 230101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_INVALID_VERSION 0x88 231101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_INVALID_OFFSET 0x89 232101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_INVALID_MSG_FLAGS 0x8A 233101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_FRAME_TOO_SMALL 0x8B 234101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_FRAME_TOO_LARGE 0x8C 235101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_INVALID_TARGET_ID 0x8D 236101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_INVALID_INITIATOR_ID 0x8E 237101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_INVALID_INITIATOR_CONTEXT 0x8F 238101100Ssos#define I2O_FAILURE_CODE_TRANSPORT_UNKNOWN_FAILURE 0xFF 239101100Ssos 240101100Ssos u_int32_t failing_iop_id:12; 241101100Ssos u_int32_t reserved:4; 242101100Ssos u_int32_t failing_host_unit_id:16; 243101100Ssos u_int32_t age_limit; 244101100Ssos u_int64_t preserved_mfa; 245103870Salfred} __packed; 246101100Ssos 247101100Ssosstruct i2o_exec_iop_reset_message { 248101100Ssos u_int8_t version_offset; 249101100Ssos u_int8_t message_flags; 250101100Ssos u_int16_t message_size; 251101100Ssos u_int32_t target_address:12; 252101100Ssos u_int32_t initiator_address:12; 253101100Ssos u_int32_t function:8; 254101100Ssos u_int8_t reserved[16]; 255101100Ssos u_int32_t status_word_low_addr; 256101100Ssos u_int32_t status_word_high_addr; 257103870Salfred} __packed; 258101100Ssos 259101100Ssosstruct i2o_exec_status_get_message { 260101100Ssos u_int8_t version_offset; 261101100Ssos u_int8_t message_flags; 262101100Ssos u_int16_t message_size; 263101100Ssos u_int32_t target_address:12; 264101100Ssos u_int32_t initiator_address:12; 265101100Ssos u_int32_t function:8; 266101100Ssos u_int8_t reserved[16]; 267101100Ssos u_int32_t reply_buf_low_addr; 268101100Ssos u_int32_t reply_buf_high_addr; 269101100Ssos u_int32_t reply_buf_length; 270103870Salfred} __packed; 271101100Ssos 272101100Ssosstruct i2o_status_get_reply { 273101100Ssos u_int16_t organization_id; 274101100Ssos u_int16_t reserved; 275101100Ssos u_int32_t iop_id:12; 276101100Ssos u_int32_t reserved1:4; 277101100Ssos u_int32_t host_unit_id:16; 278101100Ssos u_int32_t segment_number:12; 279101100Ssos u_int32_t i2o_version:4; 280101100Ssos u_int32_t iop_state:8; 281101100Ssos#define I2O_IOP_STATE_INITIALIZING 0x01 282101100Ssos#define I2O_IOP_STATE_RESET 0x02 283101100Ssos#define I2O_IOP_STATE_HOLD 0x04 284101100Ssos#define I2O_IOP_STATE_READY 0x05 285101100Ssos#define I2O_IOP_STATE_OPERATIONAL 0x08 286101100Ssos#define I2O_IOP_STATE_FAILED 0x10 287101100Ssos#define I2O_IOP_STATE_FAULTED 0x11 288101100Ssos 289101100Ssos u_int32_t messenger_type:8; 290101100Ssos u_int16_t inbound_mframe_size; 291101100Ssos u_int8_t init_code; 292101100Ssos u_int8_t reserved2; 293101100Ssos u_int32_t max_inbound_mframes; 294101100Ssos u_int32_t current_ibound_mframes; 295101100Ssos u_int32_t max_outbound_mframes; 296101100Ssos u_int8_t product_idstring[24]; 297101100Ssos u_int32_t expected_lct_size; 298101100Ssos u_int32_t iop_capabilities; 299101100Ssos u_int32_t desired_private_memsize; 300101100Ssos u_int32_t current_private_memsize; 301101100Ssos u_int32_t current_private_membase; 302101100Ssos u_int32_t desired_private_iosize; 303101100Ssos u_int32_t current_private_iosize; 304101100Ssos u_int32_t current_private_iobase; 305101100Ssos u_int8_t reserved3[3]; 306101100Ssos u_int8_t sync_byte; 307103870Salfred} __packed; 308101100Ssos 309101100Ssosstruct i2o_exec_init_outqueue_message { 310101100Ssos u_int8_t version_offset; 311101100Ssos u_int8_t message_flags; 312101100Ssos u_int16_t message_size; 313101100Ssos u_int32_t target_address:12; 314101100Ssos u_int32_t initiator_address:12; 315101100Ssos u_int32_t function:8; 316101100Ssos u_int32_t initiator_context; 317101100Ssos u_int32_t transaction_context; 318101100Ssos u_int32_t host_pagesize; 319101100Ssos u_int8_t init_code; 320101100Ssos u_int8_t reserved; 321101100Ssos u_int16_t queue_framesize; 322101100Ssos struct i2o_sgl sgl[2]; 323103870Salfred} __packed; 324101100Ssos 325101100Ssos#define I2O_EXEC_OUTBOUND_INIT_IN_PROGRESS 0x01 326101100Ssos#define I2O_EXEC_OUTBOUND_INIT_REJECTED 0x02 327101100Ssos#define I2O_EXEC_OUTBOUND_INIT_FAILED 0x03 328101100Ssos#define I2O_EXEC_OUTBOUND_INIT_COMPLETE 0x04 329101100Ssos 330101100Ssosstruct i2o_exec_systab_set_message { 331101100Ssos u_int8_t version_offset; 332101100Ssos u_int8_t message_flags; 333101100Ssos u_int16_t message_size; 334101100Ssos u_int32_t target_address:12; 335101100Ssos u_int32_t initiator_address:12; 336101100Ssos u_int32_t function:8; 337101100Ssos u_int32_t initiator_context; 338101100Ssos u_int32_t transaction_context; 339101100Ssos u_int32_t iop_id:12; 340101100Ssos#define I2O_EXEC_SYS_TAB_IOP_ID_LOCAL_IOP 0x000 341101100Ssos#define I2O_EXEC_SYS_TAB_IOP_ID_LOCAL_HOST 0x001 342101100Ssos#define I2O_EXEC_SYS_TAB_IOP_ID_UNKNOWN_IOP 0xfff 343101100Ssos 344101100Ssos u_int32_t reserved1:4; 345101100Ssos u_int32_t host_unit_id:16; 346101100Ssos#define I2O_EXEC_SYS_TAB_HOST_UNIT_ID_LOCAL_UNIT 0x0000 347101100Ssos#define I2O_EXEC_SYS_TAB_HOST_UNIT_ID_UNKNOWN_UNIT 0xffff 348101100Ssos 349101100Ssos u_int32_t segment_number:12; 350101100Ssos#define I2O_EXEC_SYS_TAB_SEG_NUMBER_LOCAL_SEGMENT 0x000 351101100Ssos#define I2O_EXEC_SYS_TAB_SEG_NUMBER_UNKNOWN_SEGMENT 0xfff 352101100Ssos 353101100Ssos u_int32_t reserved2:4; 354101100Ssos u_int32_t reserved3:8; 355101100Ssos struct i2o_sgl sgl[3]; 356103870Salfred} __packed; 357101100Ssos 358101100Ssosstruct i2o_exec_systab { 359101100Ssos u_int8_t entries; 360101100Ssos u_int8_t version; 361101100Ssos#define I2O_RESOURCE_MANAGER_VERSION 0 362101100Ssos 363101100Ssos u_int16_t reserved1; 364101100Ssos u_int32_t change_id; 365101100Ssos u_int64_t reserved2; 366101100Ssos u_int16_t organization_id; 367101100Ssos u_int16_t reserved3; 368101100Ssos u_int32_t iop_id:12; 369101100Ssos u_int32_t reserved4:20; 370101100Ssos u_int32_t segment_number:12; 371101100Ssos u_int32_t i2o_version:4; 372101100Ssos u_int32_t iop_state:8; 373101100Ssos u_int32_t messenger_type:8; 374101100Ssos u_int16_t inbound_mframe_size; 375101100Ssos u_int16_t reserved5; 376101100Ssos u_int32_t last_changed; 377101100Ssos u_int32_t iop_capabilities; 378101100Ssos u_int64_t messenger_info; 379103870Salfred} __packed; 380101100Ssos 381101100Ssosstruct i2o_exec_get_lct_message { 382101100Ssos u_int8_t version_offset; 383101100Ssos u_int8_t message_flags; 384101100Ssos u_int16_t message_size; 385101100Ssos u_int32_t target_address:12; 386101100Ssos u_int32_t initiator_address:12; 387101100Ssos u_int32_t function:8; 388101100Ssos u_int32_t initiator_context; 389101100Ssos u_int32_t transaction_context; 390101100Ssos u_int32_t class; 391101100Ssos u_int32_t last_change_id; 392101100Ssos struct i2o_sgl sgl; 393103870Salfred} __packed; 394101100Ssos 395101100Ssos#define I2O_TID_IOP 0x000 396101100Ssos#define I2O_TID_HOST 0x001 397101100Ssos#define I2O_TID_NONE 0xfff 398101100Ssos 399101100Ssosstruct i2o_lct_entry { 400101100Ssos u_int32_t entry_size:16; 401101100Ssos u_int32_t local_tid:12; 402101100Ssos u_int32_t reserved:4; 403101100Ssos u_int32_t change_id; 404101100Ssos u_int32_t device_flags; 405101100Ssos u_int32_t class:12; 406101100Ssos#define I2O_CLASS_EXECUTIVE 0x000 407101100Ssos#define I2O_CLASS_DDM 0x001 408101100Ssos#define I2O_CLASS_RANDOM_BLOCK_STORAGE 0x010 409101100Ssos#define I2O_CLASS_SEQUENTIAL_STORAGE 0x011 410101100Ssos#define I2O_CLASS_LAN 0x020 411101100Ssos#define I2O_CLASS_WAN 0x030 412101100Ssos#define I2O_CLASS_FIBRE_CHANNEL_PORT 0x040 413101100Ssos#define I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL 0x041 414101100Ssos#define I2O_CLASS_SCSI_PERIPHERAL 0x051 415101100Ssos#define I2O_CLASS_ATE_PORT 0x060 416101100Ssos#define I2O_CLASS_ATE_PERIPHERAL 0x061 417101100Ssos#define I2O_CLASS_FLOPPY_CONTROLLER 0x070 418101100Ssos#define I2O_CLASS_FLOPPY_DEVICE 0x071 419101100Ssos#define I2O_CLASS_BUS_ADAPTER_PORT 0x080 420101100Ssos#define I2O_CLASS_MATCH_ANYCLASS 0xffffffff 421101100Ssos 422101100Ssos u_int32_t class_version:4; 423101100Ssos u_int32_t class_org:16; 424101100Ssos u_int32_t sub_class; 425101100Ssos#define I2O_SUBCLASS_i960 0x001 426101100Ssos#define I2O_SUBCLASS_HDM 0x020 427101100Ssos#define I2O_SUBCLASS_ISM 0x021 428101100Ssos 429101100Ssos u_int32_t user_tid:12; 430101100Ssos u_int32_t parent_tid:12; 431101100Ssos u_int32_t bios_info:8; 432101100Ssos u_int8_t identity_tag[8]; 433101100Ssos u_int32_t event_capabilities; 434103870Salfred} __packed; 435101100Ssos 436101100Ssos#define I2O_LCT_ENTRYSIZE (sizeof(struct i2o_lct_entry)/sizeof(u_int32_t)) 437101100Ssos 438101100Ssosstruct i2o_get_lct_reply { 439101100Ssos u_int32_t table_size:16; 440101100Ssos u_int32_t boot_device:12; 441101100Ssos u_int32_t lct_version:4; 442101100Ssos u_int32_t iop_flags; 443101100Ssos u_int32_t current_change_id; 444101100Ssos struct i2o_lct_entry entry[1]; 445103870Salfred} __packed; 446101100Ssos 447101100Ssosstruct i2o_util_get_param_message { 448101100Ssos u_int8_t version_offset; 449101100Ssos u_int8_t message_flags; 450101100Ssos u_int16_t message_size; 451101100Ssos u_int32_t target_address:12; 452101100Ssos u_int32_t initiator_address:12; 453101100Ssos u_int32_t function:8; 454101100Ssos u_int32_t initiator_context; 455101100Ssos u_int32_t transaction_context; 456101100Ssos u_int32_t operation_flags; 457101100Ssos struct i2o_sgl sgl[2]; 458103870Salfred} __packed; 459101100Ssos 460101100Ssosstruct i2o_get_param_template { 461101100Ssos u_int16_t operation; 462101100Ssos#define I2O_PARAMS_OPERATION_FIELD_GET 0x0001 463101100Ssos#define I2O_PARAMS_OPERATION_LIST_GET 0x0002 464101100Ssos#define I2O_PARAMS_OPERATION_MORE_GET 0x0003 465101100Ssos#define I2O_PARAMS_OPERATION_SIZE_GET 0x0004 466101100Ssos#define I2O_PARAMS_OPERATION_TABLE_GET 0x0005 467101100Ssos#define I2O_PARAMS_OPERATION_FIELD_SET 0x0006 468101100Ssos#define I2O_PARAMS_OPERATION_LIST_SET 0x0007 469101100Ssos#define I2O_PARAMS_OPERATION_ROW_ADD 0x0008 470101100Ssos#define I2O_PARAMS_OPERATION_ROW_DELETE 0x0009 471101100Ssos#define I2O_PARAMS_OPERATION_TABLE_CLEAR 0x000A 472101100Ssos 473101100Ssos u_int16_t group; 474101100Ssos#define I2O_BSA_DEVICE_INFO_GROUP_NO 0x0000 475101100Ssos#define I2O_BSA_OPERATIONAL_CONTROL_GROUP_NO 0x0001 476101100Ssos#define I2O_BSA_POWER_CONTROL_GROUP_NO 0x0002 477101100Ssos#define I2O_BSA_CACHE_CONTROL_GROUP_NO 0x0003 478101100Ssos#define I2O_BSA_MEDIA_INFO_GROUP_NO 0x0004 479101100Ssos#define I2O_BSA_ERROR_LOG_GROUP_NO 0x0005 480101100Ssos 481101100Ssos#define I2O_UTIL_PARAMS_DESCRIPTOR_GROUP_NO 0xF000 482101100Ssos#define I2O_UTIL_PHYSICAL_DEVICE_TABLE_GROUP_NO 0xF001 483101100Ssos#define I2O_UTIL_CLAIMED_TABLE_GROUP_NO 0xF002 484101100Ssos#define I2O_UTIL_USER_TABLE_GROUP_NO 0xF003 485101100Ssos#define I2O_UTIL_PRIVATE_MESSAGE_EXTENSIONS_GROUP_NO 0xF005 486101100Ssos#define I2O_UTIL_AUTHORIZED_USER_TABLE_GROUP_NO 0xF006 487101100Ssos#define I2O_UTIL_DEVICE_IDENTITY_GROUP_NO 0xF100 488101100Ssos#define I2O_UTIL_DDM_IDENTITY_GROUP_NO 0xF101 489101100Ssos#define I2O_UTIL_USER_INFORMATION_GROUP_NO 0xF102 490101100Ssos#define I2O_UTIL_SGL_OPERATING_LIMITS_GROUP_NO 0xF103 491101100Ssos#define I2O_UTIL_SENSORS_GROUP_NO 0xF200 492101100Ssos 493101100Ssos u_int16_t field_count; 494101100Ssos u_int16_t pad; 495103870Salfred} __packed; 496101100Ssos 497101100Ssosstruct i2o_get_param_operation { 498101100Ssos u_int16_t operation_count; 499101100Ssos u_int16_t reserved; 500101100Ssos struct i2o_get_param_template operation[1]; 501103870Salfred} __packed; 502101100Ssos 503101100Ssosstruct i2o_get_param_reply { 504114154Ssos u_int16_t result_count; 505101100Ssos u_int16_t reserved; 506101100Ssos u_int16_t block_size; 507101100Ssos u_int8_t block_status; 508101100Ssos u_int8_t error_info_size; 509101100Ssos u_int32_t result[1]; 510103870Salfred} __packed; 511101100Ssos 512101100Ssosstruct i2o_device_identity { 513101100Ssos u_int32_t class; 514101100Ssos u_int16_t owner; 515101100Ssos u_int16_t parent; 516101100Ssos u_int8_t vendor[16]; 517101100Ssos u_int8_t product[16]; 518101100Ssos u_int8_t description[16]; 519101100Ssos u_int8_t revision[8]; 520101100Ssos u_int8_t sn_format; 521101100Ssos u_int8_t serial[256]; 522103870Salfred} __packed; 523101100Ssos 524101100Ssosstruct i2o_bsa_device { 525101100Ssos u_int8_t device_type; 526101100Ssos u_int8_t path_count; 527101100Ssos u_int16_t power_state; 528101100Ssos u_int32_t block_size; 529101100Ssos u_int64_t capacity; 530101100Ssos u_int32_t capabilities; 531101100Ssos u_int32_t state; 532103870Salfred} __packed; 533101100Ssos 534101100Ssosstruct i2o_util_claim_message { 535101100Ssos u_int8_t version_offset; 536101100Ssos u_int8_t message_flags; 537101100Ssos u_int16_t message_size; 538101100Ssos u_int32_t target_address:12; 539101100Ssos u_int32_t initiator_address:12; 540101100Ssos u_int32_t function:8; 541101100Ssos u_int32_t initiator_context; 542101100Ssos u_int32_t transaction_context; 543101100Ssos u_int16_t claim_flags; 544101100Ssos u_int8_t reserved; 545101100Ssos u_int8_t claim_type; 546103870Salfred} __packed; 547101100Ssos 548101100Ssosstruct i2o_util_event_register_message { 549101100Ssos u_int8_t version_offset; 550101100Ssos u_int8_t message_flags; 551101100Ssos u_int16_t message_size; 552101100Ssos u_int32_t target_address:12; 553101100Ssos u_int32_t initiator_address:12; 554101100Ssos u_int32_t function:8; 555101100Ssos u_int32_t initiator_context; 556101100Ssos u_int32_t transaction_context; 557101100Ssos u_int32_t event_mask; 558103870Salfred} __packed; 559101100Ssos 560101100Ssosstruct i2o_util_event_reply_message { 561101100Ssos u_int8_t version_offset; 562101100Ssos u_int8_t message_flags; 563101100Ssos u_int16_t message_size; 564101100Ssos u_int32_t target_address:12; 565101100Ssos u_int32_t initiator_address:12; 566101100Ssos u_int32_t function:8; 567101100Ssos u_int32_t initiator_context; 568101100Ssos u_int32_t transaction_context; 569101100Ssos u_int32_t event_mask; 570101100Ssos u_int32_t event_data[1]; 571103870Salfred} __packed; 572101100Ssos 573101100Ssosstruct i2o_util_config_dialog_message { 574101100Ssos u_int8_t version_offset; 575101100Ssos u_int8_t message_flags; 576101100Ssos u_int16_t message_size; 577101100Ssos u_int32_t target_address:12; 578101100Ssos u_int32_t initiator_address:12; 579101100Ssos u_int32_t function:8; 580101100Ssos u_int32_t initiator_context; 581101100Ssos u_int32_t transaction_context; 582101100Ssos u_int32_t page_number; 583101100Ssos struct i2o_sgl sgl[2]; 584103870Salfred} __packed; 585101100Ssos 586114154Ssosstruct i2o_private_message { 587114154Ssos u_int8_t version_offset; 588114154Ssos u_int8_t message_flags; 589114154Ssos u_int16_t message_size; 590114154Ssos u_int32_t target_address:12; 591114154Ssos u_int32_t initiator_address:12; 592114154Ssos u_int32_t function:8; 593114154Ssos u_int32_t initiator_context; 594114154Ssos u_int32_t transaction_context; 595114154Ssos u_int16_t function_code; 596114154Ssos u_int16_t organization_id; 597114154Ssos struct i2o_sgl in_sgl; 598114154Ssos struct i2o_sgl out_sgl; 599114154Ssos} __packed; 600114154Ssos 601101100Ssosstruct i2o_bsa_rw_block_message { 602101100Ssos u_int8_t version_offset; 603101100Ssos u_int8_t message_flags; 604101100Ssos u_int16_t message_size; 605101100Ssos u_int32_t target_address:12; 606101100Ssos u_int32_t initiator_address:12; 607101100Ssos u_int32_t function:8; 608101100Ssos u_int32_t initiator_context; 609101100Ssos u_int32_t transaction_context; 610101100Ssos u_int16_t control_flags; 611101100Ssos u_int8_t time_multiplier; 612101100Ssos u_int8_t fetch_ahead; 613101100Ssos u_int32_t bytecount; 614101100Ssos u_int64_t lba; 615101100Ssos struct i2o_sgl sgl; 616103870Salfred} __packed; 617101100Ssos 618101100Ssosstruct i2o_bsa_cache_flush_message { 619101100Ssos u_int8_t version_offset; 620101100Ssos u_int8_t message_flags; 621101100Ssos u_int16_t message_size; 622101100Ssos u_int32_t target_address:12; 623101100Ssos u_int32_t initiator_address:12; 624101100Ssos u_int32_t function:8; 625101100Ssos u_int32_t initiator_context; 626101100Ssos u_int32_t transaction_context; 627101100Ssos u_int16_t control_flags; 628101100Ssos u_int8_t time_multiplier; 629101100Ssos u_int8_t reserved; 630103870Salfred} __packed; 631101100Ssos 632101100Ssos/* prototypes */ 633101100Ssosint iop_init(struct iop_softc *); 634136094Sstefanfvoid iop_attach(void *); 635101100Ssosvoid iop_intr(void *); 636101100Ssosint iop_reset(struct iop_softc *); 637101100Ssosint iop_init_outqueue(struct iop_softc *); 638101100Ssosint iop_get_lct(struct iop_softc *); 639101100Ssosstruct i2o_get_param_reply *iop_get_util_params(struct iop_softc *,int,int,int); 640101100Ssosu_int32_t iop_get_mfa(struct iop_softc *); 641101100Ssosvoid iop_free_mfa(struct iop_softc *, int); 642101100Ssosint iop_queue_wait_msg(struct iop_softc *, int, struct i2o_basic_message *); 643101100Ssosint iop_create_sgl(struct i2o_basic_message *, caddr_t, int, int); 644101100Ssos 645101100Ssos/* global prototypes */ 646101100Ssosint pst_add_raid(struct iop_softc *, struct i2o_lct_entry *); 647