13a31b7ebSMike Smith /*- 23a31b7ebSMike Smith * Copyright (c) 2001 Michael Smith 33a31b7ebSMike Smith * All rights reserved. 43a31b7ebSMike Smith * 53a31b7ebSMike Smith * Redistribution and use in source and binary forms, with or without 63a31b7ebSMike Smith * modification, are permitted provided that the following conditions 73a31b7ebSMike Smith * are met: 83a31b7ebSMike Smith * 1. Redistributions of source code must retain the above copyright 93a31b7ebSMike Smith * notice, this list of conditions and the following disclaimer. 103a31b7ebSMike Smith * 2. Redistributions in binary form must reproduce the above copyright 113a31b7ebSMike Smith * notice, this list of conditions and the following disclaimer in the 123a31b7ebSMike Smith * documentation and/or other materials provided with the distribution. 133a31b7ebSMike Smith * 143a31b7ebSMike Smith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 153a31b7ebSMike Smith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 163a31b7ebSMike Smith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 173a31b7ebSMike Smith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 183a31b7ebSMike Smith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 193a31b7ebSMike Smith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 203a31b7ebSMike Smith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 213a31b7ebSMike Smith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 223a31b7ebSMike Smith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 233a31b7ebSMike Smith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 243a31b7ebSMike Smith * SUCH DAMAGE. 253a31b7ebSMike Smith * 263a31b7ebSMike Smith * $FreeBSD$ 273a31b7ebSMike Smith */ 283a31b7ebSMike Smith 293a31b7ebSMike Smith /* 303a31b7ebSMike Smith * Structure and I/O definitions for the Command Interface for SCSI-3 Support. 313a31b7ebSMike Smith * 323a31b7ebSMike Smith * Data in command CDBs are in big-endian format. All other data is little-endian. 333a31b7ebSMike Smith * This header only supports little-endian hosts at this time. 343a31b7ebSMike Smith */ 353a31b7ebSMike Smith 363a31b7ebSMike Smith union ciss_device_address 373a31b7ebSMike Smith { 383a31b7ebSMike Smith struct /* MODE_PERIPHERAL and MODE_MASK_PERIPHERAL */ 393a31b7ebSMike Smith { 403a31b7ebSMike Smith u_int32_t target:24; /* SCSI target */ 413a31b7ebSMike Smith u_int32_t bus:6; /* SCSI bus */ 423a31b7ebSMike Smith u_int32_t mode:2; /* CISS_HDR_ADDRESS_MODE_* */ 433a31b7ebSMike Smith u_int32_t extra_address; /* SCSI-3 level-2 and level-3 address bytes */ 443a31b7ebSMike Smith } physical; 453a31b7ebSMike Smith struct /* MODE_LOGICAL */ 463a31b7ebSMike Smith { 473a31b7ebSMike Smith u_int32_t lun:30; /* logical device ID */ 483a31b7ebSMike Smith u_int32_t mode:2; /* CISS_HDR_ADDRESS_MODE_LOGICAL */ 493a31b7ebSMike Smith u_int32_t :32; /* reserved */ 503a31b7ebSMike Smith } logical; 513a31b7ebSMike Smith struct 523a31b7ebSMike Smith { 533a31b7ebSMike Smith u_int32_t :30; 543a31b7ebSMike Smith u_int32_t mode:2; 553a31b7ebSMike Smith u_int32_t :32; 563a31b7ebSMike Smith } mode; 573a31b7ebSMike Smith }; 583a31b7ebSMike Smith #define CISS_HDR_ADDRESS_MODE_PERIPHERAL 0x0 593a31b7ebSMike Smith #define CISS_HDR_ADDRESS_MODE_LOGICAL 0x1 603a31b7ebSMike Smith #define CISS_HDR_ADDRESS_MODE_MASK_PERIPHERAL 0x3 613a31b7ebSMike Smith 621fe6c4eeSScott Long #define CISS_EXTRA_MODE2(extra) ((extra & 0xc0000000) >> 30) 631fe6c4eeSScott Long #define CISS_EXTRA_BUS2(extra) ((extra & 0x3f000000) >> 24) 641fe6c4eeSScott Long #define CISS_EXTRA_TARGET2(extra) ((extra & 0x00ff0000) >> 16) 651fe6c4eeSScott Long #define CISS_EXTRA_MODE3(extra) ((extra & 0x0000c000) >> 14) 661fe6c4eeSScott Long #define CISS_EXTRA_BUS3(extra) ((extra & 0x00003f00) >> 8) 671fe6c4eeSScott Long #define CISS_EXTRA_TARGET3(extra) ((extra & 0x000000ff)) 681fe6c4eeSScott Long 693a31b7ebSMike Smith struct ciss_header 703a31b7ebSMike Smith { 713a31b7ebSMike Smith u_int8_t :8; /* reserved */ 723a31b7ebSMike Smith u_int8_t sg_in_list; /* SG's in the command structure */ 733a31b7ebSMike Smith u_int16_t sg_total; /* total count of SGs for this command */ 743a31b7ebSMike Smith u_int32_t host_tag; /* host identifier, bits 0&1 must be clear */ 753a31b7ebSMike Smith #define CISS_HDR_HOST_TAG_ERROR (1<<1) 763a31b7ebSMike Smith u_int32_t host_tag_zeroes; /* tag is 64 bits, but interface only supports 32 */ 773a31b7ebSMike Smith union ciss_device_address address; 784f492bfaSAlfred Perlstein } __packed; 793a31b7ebSMike Smith 803a31b7ebSMike Smith struct ciss_cdb 813a31b7ebSMike Smith { 823a31b7ebSMike Smith u_int8_t cdb_length; /* valid CDB bytes */ 833a31b7ebSMike Smith u_int8_t type:3; 843a31b7ebSMike Smith #define CISS_CDB_TYPE_COMMAND 0 853a31b7ebSMike Smith #define CISS_CDB_TYPE_MESSAGE 1 863a31b7ebSMike Smith u_int8_t attribute:3; 873a31b7ebSMike Smith #define CISS_CDB_ATTRIBUTE_UNTAGGED 0 883a31b7ebSMike Smith #define CISS_CDB_ATTRIBUTE_SIMPLE 4 893a31b7ebSMike Smith #define CISS_CDB_ATTRIBUTE_HEAD_OF_QUEUE 5 903a31b7ebSMike Smith #define CISS_CDB_ATTRIBUTE_ORDERED 6 913a31b7ebSMike Smith #define CISS_CDB_ATTRIBUTE_AUTO_CONTINGENT 7 923a31b7ebSMike Smith u_int8_t direction:2; 933a31b7ebSMike Smith #define CISS_CDB_DIRECTION_NONE 0 94307e0460SPaul Saab #define CISS_CDB_DIRECTION_WRITE 1 95307e0460SPaul Saab #define CISS_CDB_DIRECTION_READ 2 963a31b7ebSMike Smith u_int16_t timeout; /* seconds */ 973a31b7ebSMike Smith #define CISS_CDB_BUFFER_SIZE 16 983a31b7ebSMike Smith u_int8_t cdb[CISS_CDB_BUFFER_SIZE]; 994f492bfaSAlfred Perlstein } __packed; 1003a31b7ebSMike Smith 1013a31b7ebSMike Smith struct ciss_error_info_pointer 1023a31b7ebSMike Smith { 1033a31b7ebSMike Smith u_int64_t error_info_address; /* points to ciss_error_info structure */ 1043a31b7ebSMike Smith u_int32_t error_info_length; 1054f492bfaSAlfred Perlstein } __packed; 1063a31b7ebSMike Smith 1073a31b7ebSMike Smith struct ciss_error_info 1083a31b7ebSMike Smith { 1093a31b7ebSMike Smith u_int8_t scsi_status; 1103a31b7ebSMike Smith #define CISS_SCSI_STATUS_GOOD 0x00 /* these are scsi-standard values */ 1113a31b7ebSMike Smith #define CISS_SCSI_STATUS_CHECK_CONDITION 0x02 1123a31b7ebSMike Smith #define CISS_SCSI_STATUS_CONDITION_MET 0x04 1133a31b7ebSMike Smith #define CISS_SCSI_STATUS_BUSY 0x08 1143a31b7ebSMike Smith #define CISS_SCSI_STATUS_INDETERMINATE 0x10 1153a31b7ebSMike Smith #define CISS_SCSI_STATUS_INDETERMINATE_CM 0x14 1163a31b7ebSMike Smith #define CISS_SCSI_STATUS_RESERVATION_CONFLICT 0x18 1173a31b7ebSMike Smith #define CISS_SCSI_STATUS_COMMAND_TERMINATED 0x22 1183a31b7ebSMike Smith #define CISS_SCSI_STATUS_QUEUE_FULL 0x28 1193a31b7ebSMike Smith #define CISS_SCSI_STATUS_ACA_ACTIVE 0x30 1203a31b7ebSMike Smith u_int8_t sense_length; 1213a31b7ebSMike Smith u_int16_t command_status; 1223a31b7ebSMike Smith #define CISS_CMD_STATUS_SUCCESS 0 1233a31b7ebSMike Smith #define CISS_CMD_STATUS_TARGET_STATUS 1 1243a31b7ebSMike Smith #define CISS_CMD_STATUS_DATA_UNDERRUN 2 1253a31b7ebSMike Smith #define CISS_CMD_STATUS_DATA_OVERRUN 3 1263a31b7ebSMike Smith #define CISS_CMD_STATUS_INVALID_COMMAND 4 1273a31b7ebSMike Smith #define CISS_CMD_STATUS_PROTOCOL_ERROR 5 1283a31b7ebSMike Smith #define CISS_CMD_STATUS_HARDWARE_ERROR 6 1293a31b7ebSMike Smith #define CISS_CMD_STATUS_CONNECTION_LOST 7 1303a31b7ebSMike Smith #define CISS_CMD_STATUS_ABORTED 8 1313a31b7ebSMike Smith #define CISS_CMD_STATUS_ABORT_FAILED 9 1323a31b7ebSMike Smith #define CISS_CMD_STATUS_UNSOLICITED_ABORT 10 1333a31b7ebSMike Smith #define CISS_CMD_STATUS_TIMEOUT 11 1343a31b7ebSMike Smith #define CISS_CMD_STATUS_UNABORTABLE 12 1353a31b7ebSMike Smith u_int32_t residual_count; 1363a31b7ebSMike Smith union { 1373a31b7ebSMike Smith struct { 1383a31b7ebSMike Smith u_int8_t res1[3]; 1393a31b7ebSMike Smith u_int8_t type; 1403a31b7ebSMike Smith u_int32_t error_info; 1414788ab33SPaul Saab } __packed common_info; 1423a31b7ebSMike Smith struct { 1433a31b7ebSMike Smith u_int8_t res1[2]; 1443a31b7ebSMike Smith u_int8_t offense_size; 1453a31b7ebSMike Smith u_int8_t offense_offset; 1463a31b7ebSMike Smith u_int32_t offense_value; 1474788ab33SPaul Saab } __packed invalid_command; 1483a31b7ebSMike Smith } additional_error_info; 1493a31b7ebSMike Smith u_int8_t sense_info[0]; 1504f492bfaSAlfred Perlstein } __packed; 1513a31b7ebSMike Smith 1523a31b7ebSMike Smith struct ciss_sg_entry 1533a31b7ebSMike Smith { 1543a31b7ebSMike Smith u_int64_t address; 1553a31b7ebSMike Smith #define CISS_SG_ADDRESS_BITBUCKET (~(u_int64_t)0) 1563a31b7ebSMike Smith u_int32_t length; 1573a31b7ebSMike Smith u_int32_t :31; 1583a31b7ebSMike Smith u_int32_t extension:1; /* address points to another s/g chain */ 1594f492bfaSAlfred Perlstein } __packed; 1603a31b7ebSMike Smith 1613a31b7ebSMike Smith struct ciss_command 1623a31b7ebSMike Smith { 1633a31b7ebSMike Smith struct ciss_header header; 1643a31b7ebSMike Smith struct ciss_cdb cdb; 1653a31b7ebSMike Smith struct ciss_error_info_pointer error_info; 1663a31b7ebSMike Smith struct ciss_sg_entry sg[0]; 1674f492bfaSAlfred Perlstein } __packed; 1683a31b7ebSMike Smith 1693a31b7ebSMike Smith #define CISS_OPCODE_REPORT_LOGICAL_LUNS 0xc2 1703a31b7ebSMike Smith #define CISS_OPCODE_REPORT_PHYSICAL_LUNS 0xc3 1713a31b7ebSMike Smith 1723a31b7ebSMike Smith struct ciss_lun_report 1733a31b7ebSMike Smith { 1743a31b7ebSMike Smith u_int32_t list_size; /* big-endian */ 1753a31b7ebSMike Smith u_int32_t :32; 1763a31b7ebSMike Smith union ciss_device_address lun[0]; 1774f492bfaSAlfred Perlstein } __packed; 1783a31b7ebSMike Smith 179440baa08SPaul Saab #define CISS_VPD_LOGICAL_DRIVE_GEOMETRY 0xc1 180440baa08SPaul Saab struct ciss_ldrive_geometry 181440baa08SPaul Saab { 182440baa08SPaul Saab u_int8_t periph_qualifier:3; 183440baa08SPaul Saab u_int8_t periph_devtype:5; 184440baa08SPaul Saab u_int8_t page_code; 185440baa08SPaul Saab u_int8_t res1; 186440baa08SPaul Saab u_int8_t page_length; 187440baa08SPaul Saab u_int16_t cylinders; /* big-endian */ 188440baa08SPaul Saab u_int8_t heads; 189440baa08SPaul Saab u_int8_t sectors; 190440baa08SPaul Saab u_int8_t fault_tolerance; 191440baa08SPaul Saab u_int8_t res2[3]; 192440baa08SPaul Saab } __attribute__ ((packed)); 193440baa08SPaul Saab 1943a31b7ebSMike Smith struct ciss_report_cdb 1953a31b7ebSMike Smith { 1963a31b7ebSMike Smith u_int8_t opcode; 1973a31b7ebSMike Smith u_int8_t reserved[5]; 1983a31b7ebSMike Smith u_int32_t length; /* big-endian */ 1993a31b7ebSMike Smith u_int8_t :8; 2003a31b7ebSMike Smith u_int8_t control; 2014f492bfaSAlfred Perlstein } __packed; 2023a31b7ebSMike Smith 2033a31b7ebSMike Smith /* 2043a31b7ebSMike Smith * Note that it's not clear whether we have to set the detail field to 2053a31b7ebSMike Smith * the tag of the command to be aborted, or the tag field in the command itself; 2063a31b7ebSMike Smith * documentation conflicts on this. 2073a31b7ebSMike Smith */ 2083a31b7ebSMike Smith #define CISS_OPCODE_MESSAGE_ABORT 0x00 2093a31b7ebSMike Smith #define CISS_MESSAGE_ABORT_TASK 0x00 2103a31b7ebSMike Smith #define CISS_MESSAGE_ABORT_TASK_SET 0x01 2113a31b7ebSMike Smith #define CISS_MESSAGE_ABORT_CLEAR_ACA 0x02 2123a31b7ebSMike Smith #define CISS_MESSAGE_ABORT_CLEAR_TASK_SET 0x03 2133a31b7ebSMike Smith 2143a31b7ebSMike Smith #define CISS_OPCODE_MESSAGE_RESET 0x01 2153a31b7ebSMike Smith #define CISS_MESSAGE_RESET_CONTROLLER 0x00 2163a31b7ebSMike Smith #define CISS_MESSAGE_RESET_BUS 0x01 2173a31b7ebSMike Smith #define CISS_MESSAGE_RESET_TARGET 0x03 2183a31b7ebSMike Smith #define CISS_MESSAGE_RESET_LOGICAL_UNIT 0x04 2193a31b7ebSMike Smith 2203a31b7ebSMike Smith #define CISS_OPCODE_MESSAGE_SCAN 0x02 2213a31b7ebSMike Smith #define CISS_MESSAGE_SCAN_CONTROLLER 0x00 2223a31b7ebSMike Smith #define CISS_MESSAGE_SCAN_BUS 0x01 2233a31b7ebSMike Smith #define CISS_MESSAGE_SCAN_TARGET 0x03 2243a31b7ebSMike Smith #define CISS_MESSAGE_SCAN_LOGICAL_UNIT 0x04 2253a31b7ebSMike Smith 2263a31b7ebSMike Smith #define CISS_OPCODE_MESSAGE_NOP 0x03 2273a31b7ebSMike Smith 2283a31b7ebSMike Smith struct ciss_message_cdb 2293a31b7ebSMike Smith { 2303a31b7ebSMike Smith u_int8_t opcode; 2313a31b7ebSMike Smith u_int8_t type; 2323a31b7ebSMike Smith u_int16_t :16; 2333a31b7ebSMike Smith u_int32_t abort_tag; /* XXX endianness? */ 2343a31b7ebSMike Smith u_int8_t reserved[8]; 2354f492bfaSAlfred Perlstein } __packed; 2363a31b7ebSMike Smith 2373a31b7ebSMike Smith /* 2383a31b7ebSMike Smith * CISS vendor-specific commands/messages. 2393a31b7ebSMike Smith * 2403a31b7ebSMike Smith * Note that while messages and vendor-specific commands are 2413a31b7ebSMike Smith * differentiated, they are handled in basically the same way and can 2423a31b7ebSMike Smith * be considered to be basically the same thing, as long as the cdb 2433a31b7ebSMike Smith * type field is set correctly. 2443a31b7ebSMike Smith */ 2453a31b7ebSMike Smith #define CISS_OPCODE_READ 0xc0 2463a31b7ebSMike Smith #define CISS_OPCODE_WRITE 0xc1 2473a31b7ebSMike Smith #define CISS_COMMAND_NOTIFY_ON_EVENT 0xd0 2483a31b7ebSMike Smith #define CISS_COMMAND_ABORT_NOTIFY 0xd1 2493a31b7ebSMike Smith 2503a31b7ebSMike Smith struct ciss_notify_cdb 2513a31b7ebSMike Smith { 2523a31b7ebSMike Smith u_int8_t opcode; 2533a31b7ebSMike Smith u_int8_t command; 2543a31b7ebSMike Smith u_int8_t res1[2]; 2553a31b7ebSMike Smith u_int16_t timeout; /* seconds, little-endian */ 2563a31b7ebSMike Smith u_int8_t res2; /* reserved */ 2573a31b7ebSMike Smith u_int8_t synchronous:1; /* return immediately */ 2583a31b7ebSMike Smith u_int8_t ordered:1; /* return events in recorded order */ 2593a31b7ebSMike Smith u_int8_t seek_to_oldest:1; /* reset read counter to oldest event */ 2603a31b7ebSMike Smith u_int8_t new_only:1; /* ignore any queued events */ 2613a31b7ebSMike Smith u_int8_t :4; 2623a31b7ebSMike Smith u_int32_t length; /* must be 512, little-endian */ 2633a31b7ebSMike Smith #define CISS_NOTIFY_DATA_SIZE 512 2643a31b7ebSMike Smith u_int8_t control; 2654f492bfaSAlfred Perlstein } __packed; 2663a31b7ebSMike Smith 2673a31b7ebSMike Smith #define CISS_NOTIFY_NOTIFIER 0 2683a31b7ebSMike Smith #define CISS_NOTIFY_NOTIFIER_STATUS 0 2693a31b7ebSMike Smith #define CISS_NOTIFY_NOTIFIER_PROTOCOL 1 2703a31b7ebSMike Smith 2713a31b7ebSMike Smith #define CISS_NOTIFY_HOTPLUG 1 2723a31b7ebSMike Smith #define CISS_NOTIFY_HOTPLUG_PHYSICAL 0 2733a31b7ebSMike Smith #define CISS_NOTIFY_HOTPLUG_POWERSUPPLY 1 2743a31b7ebSMike Smith #define CISS_NOTIFY_HOTPLUG_FAN 2 2753a31b7ebSMike Smith #define CISS_NOTIFY_HOTPLUG_POWER 3 2763a31b7ebSMike Smith #define CISS_NOTIFY_HOTPLUG_REDUNDANT 4 27710672bdfSPaul Saab #define CISS_NOTIFY_HOTPLUG_NONDISK 5 2783a31b7ebSMike Smith 2793a31b7ebSMike Smith #define CISS_NOTIFY_HARDWARE 2 2803a31b7ebSMike Smith #define CISS_NOTIFY_HARDWARE_CABLES 0 2813a31b7ebSMike Smith #define CISS_NOTIFY_HARDWARE_MEMORY 1 2823a31b7ebSMike Smith #define CISS_NOTIFY_HARDWARE_FAN 2 2833a31b7ebSMike Smith #define CISS_NOTIFY_HARDWARE_VRM 3 2843a31b7ebSMike Smith 2853a31b7ebSMike Smith #define CISS_NOTIFY_ENVIRONMENT 3 2863a31b7ebSMike Smith #define CISS_NOTIFY_ENVIRONMENT_TEMPERATURE 0 2873a31b7ebSMike Smith #define CISS_NOTIFY_ENVIRONMENT_POWERSUPPLY 1 2883a31b7ebSMike Smith #define CISS_NOTIFY_ENVIRONMENT_CHASSIS 2 2893a31b7ebSMike Smith #define CISS_NOTIFY_ENVIRONMENT_POWER 3 2903a31b7ebSMike Smith 2913a31b7ebSMike Smith #define CISS_NOTIFY_PHYSICAL 4 2923a31b7ebSMike Smith #define CISS_NOTIFY_PHYSICAL_STATE 0 2933a31b7ebSMike Smith 2943a31b7ebSMike Smith #define CISS_NOTIFY_LOGICAL 5 2953a31b7ebSMike Smith #define CISS_NOTIFY_LOGICAL_STATUS 0 2963a31b7ebSMike Smith #define CISS_NOTIFY_LOGICAL_ERROR 1 2973a31b7ebSMike Smith #define CISS_NOTIFY_LOGICAL_SURFACE 2 2983a31b7ebSMike Smith 2993a31b7ebSMike Smith #define CISS_NOTIFY_REDUNDANT 6 3003a31b7ebSMike Smith #define CISS_NOTIFY_REDUNDANT_STATUS 0 3013a31b7ebSMike Smith 3023a31b7ebSMike Smith #define CISS_NOTIFY_CISS 8 3033a31b7ebSMike Smith #define CISS_NOTIFY_CISS_REDUNDANT_CHANGE 0 3043a31b7ebSMike Smith #define CISS_NOTIFY_CISS_PATH_STATUS 1 3053a31b7ebSMike Smith #define CISS_NOTIFY_CISS_HARDWARE_ERROR 2 3063a31b7ebSMike Smith #define CISS_NOTIFY_CISS_LOGICAL 3 3073a31b7ebSMike Smith 3083a31b7ebSMike Smith struct ciss_notify_drive 3093a31b7ebSMike Smith { 3103a31b7ebSMike Smith u_int16_t physical_drive_number; 3113a31b7ebSMike Smith u_int8_t configured_drive_flag; 3123a31b7ebSMike Smith u_int8_t spare_drive_flag; 3133a31b7ebSMike Smith u_int8_t big_physical_drive_number; 3143a31b7ebSMike Smith u_int8_t enclosure_bay_number; 3154f492bfaSAlfred Perlstein } __packed; 3163a31b7ebSMike Smith 3173a31b7ebSMike Smith struct ciss_notify_locator 3183a31b7ebSMike Smith { 3193a31b7ebSMike Smith u_int16_t port; 3203a31b7ebSMike Smith u_int16_t id; 3213a31b7ebSMike Smith u_int16_t box; 3224f492bfaSAlfred Perlstein } __packed; 3233a31b7ebSMike Smith 3243a31b7ebSMike Smith struct ciss_notify_redundant_controller 3253a31b7ebSMike Smith { 3263a31b7ebSMike Smith u_int16_t slot; 3274f492bfaSAlfred Perlstein } __packed; 3283a31b7ebSMike Smith 3293a31b7ebSMike Smith struct ciss_notify_logical_status 3303a31b7ebSMike Smith { 3313a31b7ebSMike Smith u_int16_t logical_drive; 3323a31b7ebSMike Smith u_int8_t previous_state; 3333a31b7ebSMike Smith u_int8_t new_state; 3343a31b7ebSMike Smith u_int8_t spare_state; 3354f492bfaSAlfred Perlstein } __packed; 3363a31b7ebSMike Smith 3373a31b7ebSMike Smith struct ciss_notify_rebuild_aborted 3383a31b7ebSMike Smith { 3393a31b7ebSMike Smith u_int16_t logical_drive; 3403a31b7ebSMike Smith u_int8_t replacement_drive; 3413a31b7ebSMike Smith u_int8_t error_drive; 3423a31b7ebSMike Smith u_int8_t big_replacement_drive; 3433a31b7ebSMike Smith u_int8_t big_error_drive; 3444f492bfaSAlfred Perlstein } __packed; 3453a31b7ebSMike Smith 3463a31b7ebSMike Smith struct ciss_notify_io_error 3473a31b7ebSMike Smith { 3483a31b7ebSMike Smith u_int16_t logical_drive; 3493a31b7ebSMike Smith u_int32_t lba; 3503a31b7ebSMike Smith u_int16_t block_count; 3513a31b7ebSMike Smith u_int8_t command; 3523a31b7ebSMike Smith u_int8_t failure_bus; 3533a31b7ebSMike Smith u_int8_t failure_drive; 3543a31b7ebSMike Smith u_int64_t big_lba; 3554f492bfaSAlfred Perlstein } __packed; 3563a31b7ebSMike Smith 3573a31b7ebSMike Smith struct ciss_notify_consistency_completed 3583a31b7ebSMike Smith { 3593a31b7ebSMike Smith u_int16_t logical_drive; 3604f492bfaSAlfred Perlstein } __packed; 3613a31b7ebSMike Smith 3623a31b7ebSMike Smith struct ciss_notify 3633a31b7ebSMike Smith { 3643a31b7ebSMike Smith u_int32_t timestamp; /* seconds since controller power-on */ 3653a31b7ebSMike Smith u_int16_t class; 3663a31b7ebSMike Smith u_int16_t subclass; 3673a31b7ebSMike Smith u_int16_t detail; 3683a31b7ebSMike Smith union 3693a31b7ebSMike Smith { 3703a31b7ebSMike Smith struct ciss_notify_drive drive; 3713a31b7ebSMike Smith struct ciss_notify_locator location; 3723a31b7ebSMike Smith struct ciss_notify_redundant_controller redundant_controller; 3733a31b7ebSMike Smith struct ciss_notify_logical_status logical_status; 3743a31b7ebSMike Smith struct ciss_notify_rebuild_aborted rebuild_aborted; 3753a31b7ebSMike Smith struct ciss_notify_io_error io_error; 3763a31b7ebSMike Smith struct ciss_notify_consistency_completed consistency_completed; 3773a31b7ebSMike Smith u_int8_t data[64]; 3783a31b7ebSMike Smith } data; 3793a31b7ebSMike Smith char message[80]; 3803a31b7ebSMike Smith u_int32_t tag; 3813a31b7ebSMike Smith u_int16_t date; 3823a31b7ebSMike Smith u_int16_t year; 3833a31b7ebSMike Smith u_int32_t time; 3843a31b7ebSMike Smith u_int16_t pre_power_up_time; 3853a31b7ebSMike Smith union ciss_device_address device; 3863a31b7ebSMike Smith /* XXX pads to 512 bytes */ 3874f492bfaSAlfred Perlstein } __packed; 3883a31b7ebSMike Smith 3893a31b7ebSMike Smith /* 3903a31b7ebSMike Smith * CISS config table, which describes the controller's 3913a31b7ebSMike Smith * supported interface(s) and capabilities. 3923a31b7ebSMike Smith * 3933a31b7ebSMike Smith * This is mapped directly via PCI. 3943a31b7ebSMike Smith */ 3953a31b7ebSMike Smith struct ciss_config_table 3963a31b7ebSMike Smith { 3973a31b7ebSMike Smith char signature[4]; /* "CISS" */ 3983a31b7ebSMike Smith u_int32_t valence; 3993a31b7ebSMike Smith u_int32_t supported_methods; 4003a31b7ebSMike Smith #define CISS_TRANSPORT_METHOD_READY (1<<0) 4013a31b7ebSMike Smith #define CISS_TRANSPORT_METHOD_SIMPLE (1<<1) 40222657ce1SScott Long #define CISS_TRANSPORT_METHOD_PERF (1<<2) 4033a31b7ebSMike Smith u_int32_t active_method; 4043a31b7ebSMike Smith u_int32_t requested_method; 4053a31b7ebSMike Smith u_int32_t command_physlimit; 4063a31b7ebSMike Smith u_int32_t interrupt_coalesce_delay; 4073a31b7ebSMike Smith u_int32_t interrupt_coalesce_count; 4083a31b7ebSMike Smith u_int32_t max_outstanding_commands; 4093a31b7ebSMike Smith u_int32_t bus_types; 4103a31b7ebSMike Smith #define CISS_TRANSPORT_BUS_TYPE_ULTRA2 (1<<0) 4113a31b7ebSMike Smith #define CISS_TRANSPORT_BUS_TYPE_ULTRA3 (1<<1) 4123a31b7ebSMike Smith #define CISS_TRANSPORT_BUS_TYPE_FIBRE1 (1<<8) 4133a31b7ebSMike Smith #define CISS_TRANSPORT_BUS_TYPE_FIBRE2 (1<<9) 414a891a3bfSPaul Saab u_int32_t transport_offset; 415a891a3bfSPaul Saab char server_name[16]; 416a891a3bfSPaul Saab u_int32_t heartbeat; 4173a31b7ebSMike Smith u_int32_t host_driver; 4183a31b7ebSMike Smith #define CISS_DRIVER_SUPPORT_UNIT_ATTENTION (1<<0) 4193a31b7ebSMike Smith #define CISS_DRIVER_QUICK_INIT (1<<1) 4203a31b7ebSMike Smith #define CISS_DRIVER_INTERRUPT_ON_LOCKUP (1<<2) 4213a31b7ebSMike Smith #define CISS_DRIVER_SUPPORT_MIXED_Q_TAGS (1<<3) 4223a31b7ebSMike Smith #define CISS_DRIVER_HOST_IS_ALPHA (1<<4) 423a891a3bfSPaul Saab #define CISS_DRIVER_MULTI_LUN_SUPPORT (1<<5) 424a891a3bfSPaul Saab #define CISS_DRIVER_MESSAGE_REQUESTS_SUPPORTED (1<<7) 425a891a3bfSPaul Saab #define CISS_DRIVER_DAUGHTER_ATTACHED (1<<8) 426a891a3bfSPaul Saab #define CISS_DRIVER_SCSI_PREFETCH (1<<9) 427a891a3bfSPaul Saab u_int32_t max_sg_length; /* 31 in older firmware */ 4284f492bfaSAlfred Perlstein } __packed; 4293a31b7ebSMike Smith 4303a31b7ebSMike Smith /* 43122657ce1SScott Long * Configuration table for the Performant transport. Only 4 request queues 43222657ce1SScott Long * are mentioned in this table, though apparently up to 256 can exist. 43322657ce1SScott Long */ 43422657ce1SScott Long struct ciss_perf_config { 43522657ce1SScott Long uint32_t fetch_count[8]; 43622657ce1SScott Long #define CISS_SG_FETCH_MAX 0 43722657ce1SScott Long #define CISS_SG_FETCH_1 1 43822657ce1SScott Long #define CISS_SG_FETCH_2 2 43922657ce1SScott Long #define CISS_SG_FETCH_4 3 44022657ce1SScott Long #define CISS_SG_FETCH_8 4 44122657ce1SScott Long #define CISS_SG_FETCH_16 5 44222657ce1SScott Long #define CISS_SG_FETCH_32 6 44322657ce1SScott Long #define CISS_SG_FETCH_NONE 7 44422657ce1SScott Long uint32_t rq_size; 44522657ce1SScott Long uint32_t rq_count; 44622657ce1SScott Long uint32_t rq_bank_lo; 44722657ce1SScott Long uint32_t rq_bank_hi; 44822657ce1SScott Long struct { 44922657ce1SScott Long uint32_t rq_addr_lo; 45022657ce1SScott Long uint32_t rq_addr_hi; 45122657ce1SScott Long } __packed rq[4]; 45222657ce1SScott Long } __packed; 45322657ce1SScott Long 45422657ce1SScott Long /* 4553a31b7ebSMike Smith * In a flagrant violation of what CISS seems to be meant to be about, 4563a31b7ebSMike Smith * Compaq recycle a goodly portion of their previous generation's 4573a31b7ebSMike Smith * command set (and all the legacy baggage related to a design 4583a31b7ebSMike Smith * originally aimed at narrow SCSI) through the Array Controller Read 4593a31b7ebSMike Smith * and Array Controller Write interface. 4603a31b7ebSMike Smith * 4613a31b7ebSMike Smith * Command ID values here can be looked up for in the 4623a31b7ebSMike Smith * publically-available documentation for the older controllers; note 4633a31b7ebSMike Smith * that the command layout is necessarily different to fit within the 4643a31b7ebSMike Smith * CDB. 4653a31b7ebSMike Smith */ 4663a31b7ebSMike Smith #define CISS_ARRAY_CONTROLLER_READ 0x26 4673a31b7ebSMike Smith #define CISS_ARRAY_CONTROLLER_WRITE 0x27 4683a31b7ebSMike Smith 4693a31b7ebSMike Smith #define CISS_BMIC_ID_LDRIVE 0x10 4703a31b7ebSMike Smith #define CISS_BMIC_ID_CTLR 0x11 4713a31b7ebSMike Smith #define CISS_BMIC_ID_LSTATUS 0x12 4723a31b7ebSMike Smith #define CISS_BMIC_ID_PDRIVE 0x15 4733a31b7ebSMike Smith #define CISS_BMIC_BLINK_PDRIVE 0x16 4743a31b7ebSMike Smith #define CISS_BMIC_SENSE_BLINK_PDRIVE 0x17 47517c0792dSPaul Saab #define CISS_BMIC_SOFT_RESET 0x40 4763a31b7ebSMike Smith #define CISS_BMIC_FLUSH_CACHE 0xc2 4773a31b7ebSMike Smith #define CISS_BMIC_ACCEPT_MEDIA 0xe0 4783a31b7ebSMike Smith 4793a31b7ebSMike Smith /* 4803a31b7ebSMike Smith * When numbering drives, the original design assumed that 4813a31b7ebSMike Smith * drives 0-7 are on the first SCSI bus, 8-15 on the second, 4823a31b7ebSMike Smith * and so forth. In order to handle modern SCSI configurations, 4833a31b7ebSMike Smith * the MSB is set in the drive ID field, in which case the 4843a31b7ebSMike Smith * modulus changes from 8 to the number of supported drives 4853a31b7ebSMike Smith * per SCSI bus (as obtained from the ID_CTLR command). 4863a31b7ebSMike Smith * This feature is referred to as BIG_MAP support, and we assume 4873a31b7ebSMike Smith * that all CISS controllers support it. 4883a31b7ebSMike Smith */ 4893a31b7ebSMike Smith 4903a31b7ebSMike Smith #define CISS_BIG_MAP_ID(sc, bus, target) \ 4913a31b7ebSMike Smith (0x80 | \ 4923a31b7ebSMike Smith ((sc)->ciss_id->drives_per_scsi_bus * (bus)) | \ 4933a31b7ebSMike Smith (target)) 4943a31b7ebSMike Smith 4953a31b7ebSMike Smith #define CISS_BIG_MAP_BUS(sc, id) \ 4963a31b7ebSMike Smith (((id) & 0x80) ? (((id) & ~0x80) / (sc)->ciss_id->drives_per_scsi_bus) : -1) 4973a31b7ebSMike Smith 4983a31b7ebSMike Smith #define CISS_BIG_MAP_TARGET(sc, id) \ 4993a31b7ebSMike Smith (((id) & 0x80) ? (((id) & ~0x80) % (sc)->ciss_id->drives_per_scsi_bus) : -1) 5003a31b7ebSMike Smith 5013a31b7ebSMike Smith #define CISS_BIG_MAP_ENTRIES 128 /* number of entries in a BIG_MAP */ 5023a31b7ebSMike Smith 5033a31b7ebSMike Smith /* 504c6131460SPaul Saab * In the device address of a logical volume, the bus number 505c6131460SPaul Saab * is encoded into the logical lun volume number starting 506c6131460SPaul Saab * at the second byte, with the first byte defining the 507c6131460SPaul Saab * logical drive number. 508c6131460SPaul Saab */ 509c6131460SPaul Saab #define CISS_LUN_TO_BUS(x) (((x) >> 16) & 0xFF) 510c6131460SPaul Saab #define CISS_LUN_TO_TARGET(x) ((x) & 0xFF) 511c6131460SPaul Saab 512c6131460SPaul Saab /* 5133a31b7ebSMike Smith * BMIC CDB 5143a31b7ebSMike Smith * 5153a31b7ebSMike Smith * Note that the phys_drive/res1 field is nominally the 32-bit 5163a31b7ebSMike Smith * "block number" field, but the only BMIC command(s) of interest 5173a31b7ebSMike Smith * implemented overload the MSB (note big-endian format here) 5183a31b7ebSMike Smith * to be the physical drive ID, so we define accordingly. 5193a31b7ebSMike Smith */ 5203a31b7ebSMike Smith struct ciss_bmic_cdb { 5213a31b7ebSMike Smith u_int8_t opcode; 5223a31b7ebSMike Smith u_int8_t log_drive; 5233a31b7ebSMike Smith u_int8_t phys_drive; 5243a31b7ebSMike Smith u_int8_t res1[3]; 5253a31b7ebSMike Smith u_int8_t bmic_opcode; 5263a31b7ebSMike Smith u_int16_t size; /* big-endian */ 5273a31b7ebSMike Smith u_int8_t res2; 5284f492bfaSAlfred Perlstein } __packed; 5293a31b7ebSMike Smith 5303a31b7ebSMike Smith /* 5313a31b7ebSMike Smith * BMIC command command/return structures. 5323a31b7ebSMike Smith */ 5333a31b7ebSMike Smith 5343a31b7ebSMike Smith /* CISS_BMIC_ID_LDRIVE */ 5353a31b7ebSMike Smith struct ciss_bmic_id_ldrive { 5363a31b7ebSMike Smith u_int16_t block_size; 5373a31b7ebSMike Smith u_int32_t blocks_available; 5383a31b7ebSMike Smith u_int8_t drive_parameter_table[16]; /* XXX define */ 5393a31b7ebSMike Smith u_int8_t fault_tolerance; 5403a31b7ebSMike Smith #define CISS_LDRIVE_RAID0 0 5413a31b7ebSMike Smith #define CISS_LDRIVE_RAID4 1 5423a31b7ebSMike Smith #define CISS_LDRIVE_RAID1 2 5433a31b7ebSMike Smith #define CISS_LDRIVE_RAID5 3 544aaf8327bSPaul Saab #define CISS_LDRIVE_RAID51 4 545aaf8327bSPaul Saab #define CISS_LDRIVE_RAIDADG 5 546bbfb4528SPaul Saab u_int8_t res1; 547bbfb4528SPaul Saab u_int8_t bios_disable_flag; 548bbfb4528SPaul Saab u_int8_t res2; 5493a31b7ebSMike Smith u_int32_t logical_drive_identifier; 5503a31b7ebSMike Smith char logical_drive_label[64]; 551bbfb4528SPaul Saab u_int64_t big_blocks_available; 552bbfb4528SPaul Saab u_int8_t res3[410]; 5534f492bfaSAlfred Perlstein } __packed; 5543a31b7ebSMike Smith 5553a31b7ebSMike Smith /* CISS_BMIC_ID_LSTATUS */ 5563a31b7ebSMike Smith struct ciss_bmic_id_lstatus { 5573a31b7ebSMike Smith u_int8_t status; 5583a31b7ebSMike Smith #define CISS_LSTATUS_OK 0 5593a31b7ebSMike Smith #define CISS_LSTATUS_FAILED 1 5603a31b7ebSMike Smith #define CISS_LSTATUS_NOT_CONFIGURED 2 5613a31b7ebSMike Smith #define CISS_LSTATUS_INTERIM_RECOVERY 3 5623a31b7ebSMike Smith #define CISS_LSTATUS_READY_RECOVERY 4 5633a31b7ebSMike Smith #define CISS_LSTATUS_RECOVERING 5 5643a31b7ebSMike Smith #define CISS_LSTATUS_WRONG_PDRIVE 6 5653a31b7ebSMike Smith #define CISS_LSTATUS_MISSING_PDRIVE 7 5663a31b7ebSMike Smith #define CISS_LSTATUS_EXPANDING 10 5673a31b7ebSMike Smith #define CISS_LSTATUS_BECOMING_READY 11 5683a31b7ebSMike Smith #define CISS_LSTATUS_QUEUED_FOR_EXPANSION 12 5693a31b7ebSMike Smith u_int32_t deprecated_drive_failure_map; 5703a31b7ebSMike Smith u_int8_t res1[416]; 5713a31b7ebSMike Smith u_int32_t blocks_to_recover; 5723a31b7ebSMike Smith u_int8_t deprecated_drive_rebuilding; 5733a31b7ebSMike Smith u_int16_t deprecated_remap_count[32]; 5743a31b7ebSMike Smith u_int32_t deprecated_replacement_map; 5753a31b7ebSMike Smith u_int32_t deprecated_active_spare_map; 5763a31b7ebSMike Smith u_int8_t spare_configured:1; 5773a31b7ebSMike Smith u_int8_t spare_rebuilding:1; 5783a31b7ebSMike Smith u_int8_t spare_rebuilt:1; 5793a31b7ebSMike Smith u_int8_t spare_failed:1; 5803a31b7ebSMike Smith u_int8_t spare_switched:1; 5813a31b7ebSMike Smith u_int8_t spare_available:1; 5823a31b7ebSMike Smith u_int8_t res2:2; 5833a31b7ebSMike Smith u_int8_t deprecated_spare_to_replace_map[32]; 5843a31b7ebSMike Smith u_int32_t deprecated_replaced_marked_ok_map; 5853a31b7ebSMike Smith u_int8_t media_exchanged; 5863a31b7ebSMike Smith u_int8_t cache_failure; 5873a31b7ebSMike Smith u_int8_t expand_failure; 5883a31b7ebSMike Smith u_int8_t rebuild_read_failure:1; 5893a31b7ebSMike Smith u_int8_t rebuild_write_failure:1; 5903a31b7ebSMike Smith u_int8_t res3:6; 5913a31b7ebSMike Smith u_int8_t drive_failure_map[CISS_BIG_MAP_ENTRIES / 8]; 5923a31b7ebSMike Smith u_int16_t remap_count[CISS_BIG_MAP_ENTRIES]; 5933a31b7ebSMike Smith u_int8_t replacement_map[CISS_BIG_MAP_ENTRIES / 8]; 5943a31b7ebSMike Smith u_int8_t active_spare_map[CISS_BIG_MAP_ENTRIES / 8]; 5953a31b7ebSMike Smith u_int8_t spare_to_replace_map[CISS_BIG_MAP_ENTRIES]; 5963a31b7ebSMike Smith u_int8_t replaced_marked_ok_map[CISS_BIG_MAP_ENTRIES / 8]; 5973a31b7ebSMike Smith u_int8_t drive_rebuilding; 598a54e98d3SPaul Saab u_int64_t big_blocks_to_recover; 599a54e98d3SPaul Saab u_int8_t res4[28]; 6004f492bfaSAlfred Perlstein } __packed; 6013a31b7ebSMike Smith 6023a31b7ebSMike Smith /* CISS_BMIC_ID_CTLR */ 6033a31b7ebSMike Smith struct ciss_bmic_id_table { 6043a31b7ebSMike Smith u_int8_t configured_logical_drives; 6053a31b7ebSMike Smith u_int32_t config_signature; 6063a31b7ebSMike Smith char running_firmware_revision[4]; 6073a31b7ebSMike Smith char stored_firmware_revision[4]; 6083a31b7ebSMike Smith u_int8_t hardware_revision; 6093a31b7ebSMike Smith u_int8_t res1[4]; 6103a31b7ebSMike Smith u_int32_t deprecated_drive_present_map; 6113a31b7ebSMike Smith u_int32_t deprecated_external_drive_present_map; 6123a31b7ebSMike Smith u_int32_t board_id; 6133a31b7ebSMike Smith u_int8_t res2; 6143a31b7ebSMike Smith u_int32_t deprecated_non_disk_map; 6153a31b7ebSMike Smith u_int8_t res3[5]; 6163a31b7ebSMike Smith char marketting_revision; 6173a31b7ebSMike Smith u_int8_t res4:3; 6183a31b7ebSMike Smith u_int8_t more_than_seven_supported:1; 6193a31b7ebSMike Smith u_int8_t res5:3; 6203a31b7ebSMike Smith u_int8_t big_map_supported:1; /* must be set! */ 6213a31b7ebSMike Smith u_int8_t res6[2]; 6223a31b7ebSMike Smith u_int8_t scsi_bus_count; 6233a31b7ebSMike Smith u_int32_t res7; 6243a31b7ebSMike Smith u_int32_t controller_clock; 6253a31b7ebSMike Smith u_int8_t drives_per_scsi_bus; 6263a31b7ebSMike Smith u_int8_t big_drive_present_map[CISS_BIG_MAP_ENTRIES / 8]; 6273a31b7ebSMike Smith u_int8_t big_external_drive_present_map[CISS_BIG_MAP_ENTRIES / 8]; 6283a31b7ebSMike Smith u_int8_t big_non_disk_map[CISS_BIG_MAP_ENTRIES / 8]; 6294f492bfaSAlfred Perlstein } __packed; 6303a31b7ebSMike Smith 6313a31b7ebSMike Smith /* CISS_BMIC_ID_PDRIVE */ 6323a31b7ebSMike Smith struct ciss_bmic_id_pdrive { 6333a31b7ebSMike Smith u_int8_t scsi_bus; 6343a31b7ebSMike Smith u_int8_t scsi_id; 6353a31b7ebSMike Smith u_int16_t block_size; 6363a31b7ebSMike Smith u_int32_t total_blocks; 6373a31b7ebSMike Smith u_int32_t reserved_blocks; 6383a31b7ebSMike Smith char model[40]; 6393a31b7ebSMike Smith char serial[40]; 6403a31b7ebSMike Smith char revision[8]; 6413a31b7ebSMike Smith u_int8_t inquiry_bits; 6423a31b7ebSMike Smith u_int8_t res1[2]; 6433a31b7ebSMike Smith u_int8_t drive_present:1; 6443a31b7ebSMike Smith u_int8_t non_disk:1; 6453a31b7ebSMike Smith u_int8_t wide:1; 6463a31b7ebSMike Smith u_int8_t synchronous:1; 6473a31b7ebSMike Smith u_int8_t narrow:1; 6483a31b7ebSMike Smith u_int8_t wide_downgraded_to_narrow:1; 6493a31b7ebSMike Smith u_int8_t ultra:1; 6503a31b7ebSMike Smith u_int8_t ultra2:1; 6513a31b7ebSMike Smith u_int8_t SMART:1; 6523a31b7ebSMike Smith u_int8_t SMART_errors_recorded:1; 6533a31b7ebSMike Smith u_int8_t SMART_errors_enabled:1; 6543a31b7ebSMike Smith u_int8_t SMART_errors_detected:1; 6553a31b7ebSMike Smith u_int8_t external:1; 6563a31b7ebSMike Smith u_int8_t configured:1; 6573a31b7ebSMike Smith u_int8_t configured_spare:1; 6583a31b7ebSMike Smith u_int8_t cache_saved_enabled:1; 6593a31b7ebSMike Smith u_int8_t res2; 6603a31b7ebSMike Smith u_int8_t res3:6; 6613a31b7ebSMike Smith u_int8_t cache_currently_enabled:1; 6623a31b7ebSMike Smith u_int8_t cache_safe:1; 6633a31b7ebSMike Smith u_int8_t res4[5]; 6643a31b7ebSMike Smith char connector[2]; 6653a31b7ebSMike Smith u_int8_t res5; 6663a31b7ebSMike Smith u_int8_t bay; 667256588d2SPaul Saab u_int16_t rpm; 668256588d2SPaul Saab u_int8_t drive_type; 669256588d2SPaul Saab u_int8_t res6[393]; 6704f492bfaSAlfred Perlstein } __packed; 6713a31b7ebSMike Smith 6723a31b7ebSMike Smith /* CISS_BMIC_BLINK_PDRIVE */ 6733a31b7ebSMike Smith /* CISS_BMIC_SENSE_BLINK_PDRIVE */ 6743a31b7ebSMike Smith struct ciss_bmic_blink_pdrive { 6753a31b7ebSMike Smith u_int32_t blink_duration; /* 10ths of a second */ 6763a31b7ebSMike Smith u_int32_t duration_elapsed; /* only for sense command */ 6773a31b7ebSMike Smith u_int8_t blinktab[256]; 6783a31b7ebSMike Smith #define CISS_BMIC_BLINK_ALL 1 6793a31b7ebSMike Smith #define CISS_BMIC_BLINK_TIMED 2 6803a31b7ebSMike Smith u_int8_t res2[248]; 6814f492bfaSAlfred Perlstein } __packed; 6823a31b7ebSMike Smith 6833a31b7ebSMike Smith /* CISS_BMIC_FLUSH_CACHE */ 6843a31b7ebSMike Smith struct ciss_bmic_flush_cache { 6853a31b7ebSMike Smith u_int16_t flag; 6863a31b7ebSMike Smith #define CISS_BMIC_FLUSH_AND_ENABLE 0 6873a31b7ebSMike Smith #define CISS_BMIC_FLUSH_AND_DISABLE 1 6883a31b7ebSMike Smith u_int8_t res1[510]; 6894f492bfaSAlfred Perlstein } __packed; 6903a31b7ebSMike Smith 6913a31b7ebSMike Smith #ifdef _KERNEL 6923a31b7ebSMike Smith /* 6933a31b7ebSMike Smith * CISS "simple" transport layer. 6943a31b7ebSMike Smith * 6953a31b7ebSMike Smith * Note that there are two slightly different versions of this interface 6963a31b7ebSMike Smith * with different interrupt mask bits. There's nothing like consistency... 6973a31b7ebSMike Smith */ 6983a31b7ebSMike Smith #define CISS_TL_SIMPLE_BAR_REGS 0x10 /* BAR pointing to register space */ 6993a31b7ebSMike Smith #define CISS_TL_SIMPLE_BAR_CFG 0x14 /* BAR pointing to space containing config table */ 7003a31b7ebSMike Smith 7013a31b7ebSMike Smith #define CISS_TL_SIMPLE_IDBR 0x20 /* inbound doorbell register */ 7023a31b7ebSMike Smith #define CISS_TL_SIMPLE_IDBR_CFG_TABLE (1<<0) /* notify controller of config table update */ 7033a31b7ebSMike Smith 7043a31b7ebSMike Smith #define CISS_TL_SIMPLE_ISR 0x30 /* interrupt status register */ 7053a31b7ebSMike Smith #define CISS_TL_SIMPLE_IMR 0x34 /* interrupt mask register */ 7063a31b7ebSMike Smith #define CISS_TL_SIMPLE_INTR_OPQ_SA5 (1<<3) /* OPQ not empty interrupt, SA5 boards */ 7073a31b7ebSMike Smith #define CISS_TL_SIMPLE_INTR_OPQ_SA5B (1<<2) /* OPQ not empty interrupt, SA5B boards */ 7083a31b7ebSMike Smith 7093a31b7ebSMike Smith #define CISS_TL_SIMPLE_IPQ 0x40 /* inbound post queue */ 7103a31b7ebSMike Smith #define CISS_TL_SIMPLE_OPQ 0x44 /* outbound post queue */ 7113a31b7ebSMike Smith #define CISS_TL_SIMPLE_OPQ_EMPTY (~(u_int32_t)0) 7123a31b7ebSMike Smith 71322657ce1SScott Long #define CISS_TL_SIMPLE_OSR 0x9c /* outbound status register */ 71422657ce1SScott Long #define CISS_TL_SIMPLE_ODC 0xa0 /* outbound doorbell clear register */ 71522657ce1SScott Long #define CISS_TL_SIMPLE_ODC_CLEAR (0x1) 71622657ce1SScott Long 7173a31b7ebSMike Smith #define CISS_TL_SIMPLE_CFG_BAR 0xb4 /* should be 0x14 */ 7183a31b7ebSMike Smith #define CISS_TL_SIMPLE_CFG_OFF 0xb8 /* offset in BAR at which config table is located */ 7193a31b7ebSMike Smith 7203a31b7ebSMike Smith /* 7213a31b7ebSMike Smith * Register access primitives. 7223a31b7ebSMike Smith */ 7233a31b7ebSMike Smith #define CISS_TL_SIMPLE_READ(sc, ofs) \ 7243a31b7ebSMike Smith bus_space_read_4(sc->ciss_regs_btag, sc->ciss_regs_bhandle, ofs) 7253a31b7ebSMike Smith #define CISS_TL_SIMPLE_WRITE(sc, ofs, val) \ 7263a31b7ebSMike Smith bus_space_write_4(sc->ciss_regs_btag, sc->ciss_regs_bhandle, ofs, val) 7273a31b7ebSMike Smith 7283a31b7ebSMike Smith #define CISS_TL_SIMPLE_POST_CMD(sc, phys) CISS_TL_SIMPLE_WRITE(sc, CISS_TL_SIMPLE_IPQ, phys) 7293a31b7ebSMike Smith #define CISS_TL_SIMPLE_FETCH_CMD(sc) CISS_TL_SIMPLE_READ(sc, CISS_TL_SIMPLE_OPQ) 7303a31b7ebSMike Smith 731d69c9c78SScott Long #define CISS_TL_PERF_INTR_OPQ (CISS_TL_SIMPLE_INTR_OPQ_SA5 | CISS_TL_SIMPLE_INTR_OPQ_SA5B) 732d69c9c78SScott Long #define CISS_TL_PERF_INTR_MSI 0x01 733d69c9c78SScott Long 73422657ce1SScott Long #define CISS_TL_PERF_POST_CMD(sc, cr) CISS_TL_SIMPLE_WRITE(sc, CISS_TL_SIMPLE_IPQ, CISS_FIND_COMMANDPHYS(cr) | (cr)->cr_sg_tag) 73522657ce1SScott Long #define CISS_TL_PERF_FLUSH_INT(sc) CISS_TL_SIMPLE_READ(sc, CISS_TL_SIMPLE_OSR) 73622657ce1SScott Long #define CISS_TL_PERF_CLEAR_INT(sc) CISS_TL_SIMPLE_WRITE(sc, CISS_TL_SIMPLE_ODC, CISS_TL_SIMPLE_ODC_CLEAR) 73722657ce1SScott Long #define CISS_CYCLE_MASK 0x00000001 73822657ce1SScott Long 73922657ce1SScott Long #define CISS_MSI_COUNT 4 74022657ce1SScott Long 7413a31b7ebSMike Smith #define CISS_TL_SIMPLE_DISABLE_INTERRUPTS(sc) \ 742d69c9c78SScott Long CISS_TL_SIMPLE_WRITE(sc, CISS_TL_SIMPLE_IMR, \ 743d69c9c78SScott Long CISS_TL_SIMPLE_READ(sc, CISS_TL_SIMPLE_IMR) | (sc)->ciss_interrupt_mask) 7443a31b7ebSMike Smith #define CISS_TL_SIMPLE_ENABLE_INTERRUPTS(sc) \ 745d69c9c78SScott Long CISS_TL_SIMPLE_WRITE(sc, CISS_TL_SIMPLE_IMR, \ 746d69c9c78SScott Long CISS_TL_SIMPLE_READ(sc, CISS_TL_SIMPLE_IMR) & ~(sc)->ciss_interrupt_mask) 747d69c9c78SScott Long 7483a31b7ebSMike Smith 7493a31b7ebSMike Smith #endif /* _KERNEL */ 750