xref: /freebsd/sys/dev/ciss/cissreg.h (revision c61314601b8644dee2562d50700d8a87d7aca2e5)
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 
623a31b7ebSMike Smith struct ciss_header
633a31b7ebSMike Smith {
643a31b7ebSMike Smith     u_int8_t	:8;			/* reserved */
653a31b7ebSMike Smith     u_int8_t	sg_in_list;		/* SG's in the command structure */
663a31b7ebSMike Smith     u_int16_t	sg_total;		/* total count of SGs for this command */
673a31b7ebSMike Smith     u_int32_t	host_tag;		/* host identifier, bits 0&1 must be clear */
683a31b7ebSMike Smith #define CISS_HDR_HOST_TAG_ERROR	(1<<1)
693a31b7ebSMike Smith     u_int32_t	host_tag_zeroes;	/* tag is 64 bits, but interface only supports 32 */
703a31b7ebSMike Smith     union ciss_device_address address;
714f492bfaSAlfred Perlstein } __packed;
723a31b7ebSMike Smith 
733a31b7ebSMike Smith struct ciss_cdb
743a31b7ebSMike Smith {
753a31b7ebSMike Smith     u_int8_t	cdb_length;		/* valid CDB bytes */
763a31b7ebSMike Smith     u_int8_t	type:3;
773a31b7ebSMike Smith #define CISS_CDB_TYPE_COMMAND			0
783a31b7ebSMike Smith #define CISS_CDB_TYPE_MESSAGE			1
793a31b7ebSMike Smith     u_int8_t	attribute:3;
803a31b7ebSMike Smith #define CISS_CDB_ATTRIBUTE_UNTAGGED		0
813a31b7ebSMike Smith #define CISS_CDB_ATTRIBUTE_SIMPLE		4
823a31b7ebSMike Smith #define CISS_CDB_ATTRIBUTE_HEAD_OF_QUEUE	5
833a31b7ebSMike Smith #define CISS_CDB_ATTRIBUTE_ORDERED		6
843a31b7ebSMike Smith #define CISS_CDB_ATTRIBUTE_AUTO_CONTINGENT	7
853a31b7ebSMike Smith     u_int8_t	direction:2;
863a31b7ebSMike Smith #define CISS_CDB_DIRECTION_NONE			0
87307e0460SPaul Saab #define CISS_CDB_DIRECTION_WRITE		1
88307e0460SPaul Saab #define CISS_CDB_DIRECTION_READ			2
893a31b7ebSMike Smith     u_int16_t	timeout;		/* seconds */
903a31b7ebSMike Smith #define CISS_CDB_BUFFER_SIZE	16
913a31b7ebSMike Smith     u_int8_t	cdb[CISS_CDB_BUFFER_SIZE];
924f492bfaSAlfred Perlstein } __packed;
933a31b7ebSMike Smith 
943a31b7ebSMike Smith struct ciss_error_info_pointer
953a31b7ebSMike Smith {
963a31b7ebSMike Smith     u_int64_t	error_info_address;	/* points to ciss_error_info structure */
973a31b7ebSMike Smith     u_int32_t	error_info_length;
984f492bfaSAlfred Perlstein } __packed;
993a31b7ebSMike Smith 
1003a31b7ebSMike Smith struct ciss_error_info
1013a31b7ebSMike Smith {
1023a31b7ebSMike Smith     u_int8_t	scsi_status;
1033a31b7ebSMike Smith #define CISS_SCSI_STATUS_GOOD			0x00	/* these are scsi-standard values */
1043a31b7ebSMike Smith #define CISS_SCSI_STATUS_CHECK_CONDITION	0x02
1053a31b7ebSMike Smith #define CISS_SCSI_STATUS_CONDITION_MET		0x04
1063a31b7ebSMike Smith #define CISS_SCSI_STATUS_BUSY			0x08
1073a31b7ebSMike Smith #define CISS_SCSI_STATUS_INDETERMINATE		0x10
1083a31b7ebSMike Smith #define CISS_SCSI_STATUS_INDETERMINATE_CM	0x14
1093a31b7ebSMike Smith #define CISS_SCSI_STATUS_RESERVATION_CONFLICT	0x18
1103a31b7ebSMike Smith #define CISS_SCSI_STATUS_COMMAND_TERMINATED	0x22
1113a31b7ebSMike Smith #define CISS_SCSI_STATUS_QUEUE_FULL		0x28
1123a31b7ebSMike Smith #define CISS_SCSI_STATUS_ACA_ACTIVE		0x30
1133a31b7ebSMike Smith     u_int8_t	sense_length;
1143a31b7ebSMike Smith     u_int16_t	command_status;
1153a31b7ebSMike Smith #define CISS_CMD_STATUS_SUCCESS			0
1163a31b7ebSMike Smith #define CISS_CMD_STATUS_TARGET_STATUS		1
1173a31b7ebSMike Smith #define CISS_CMD_STATUS_DATA_UNDERRUN		2
1183a31b7ebSMike Smith #define CISS_CMD_STATUS_DATA_OVERRUN		3
1193a31b7ebSMike Smith #define CISS_CMD_STATUS_INVALID_COMMAND		4
1203a31b7ebSMike Smith #define CISS_CMD_STATUS_PROTOCOL_ERROR		5
1213a31b7ebSMike Smith #define CISS_CMD_STATUS_HARDWARE_ERROR		6
1223a31b7ebSMike Smith #define CISS_CMD_STATUS_CONNECTION_LOST		7
1233a31b7ebSMike Smith #define CISS_CMD_STATUS_ABORTED			8
1243a31b7ebSMike Smith #define CISS_CMD_STATUS_ABORT_FAILED		9
1253a31b7ebSMike Smith #define CISS_CMD_STATUS_UNSOLICITED_ABORT	10
1263a31b7ebSMike Smith #define CISS_CMD_STATUS_TIMEOUT			11
1273a31b7ebSMike Smith #define CISS_CMD_STATUS_UNABORTABLE		12
1283a31b7ebSMike Smith     u_int32_t	residual_count;
1293a31b7ebSMike Smith     union {
1303a31b7ebSMike Smith 	struct {
1313a31b7ebSMike Smith 	    u_int8_t	res1[3];
1323a31b7ebSMike Smith 	    u_int8_t	type;
1333a31b7ebSMike Smith 	    u_int32_t	error_info;
1344f492bfaSAlfred Perlstein 	} common_info __packed;
1353a31b7ebSMike Smith 	struct {
1363a31b7ebSMike Smith 	    u_int8_t	res1[2];
1373a31b7ebSMike Smith 	    u_int8_t	offense_size;
1383a31b7ebSMike Smith 	    u_int8_t	offense_offset;
1393a31b7ebSMike Smith 	    u_int32_t	offense_value;
1404f492bfaSAlfred Perlstein 	} invalid_command __packed;
1413a31b7ebSMike Smith     } additional_error_info;
1423a31b7ebSMike Smith     u_int8_t	sense_info[0];
1434f492bfaSAlfred Perlstein } __packed;
1443a31b7ebSMike Smith 
1453a31b7ebSMike Smith struct ciss_sg_entry
1463a31b7ebSMike Smith {
1473a31b7ebSMike Smith     u_int64_t	address;
1483a31b7ebSMike Smith #define CISS_SG_ADDRESS_BITBUCKET	(~(u_int64_t)0)
1493a31b7ebSMike Smith     u_int32_t	length;
1503a31b7ebSMike Smith     u_int32_t	:31;
1513a31b7ebSMike Smith     u_int32_t	extension:1;		/* address points to another s/g chain */
1524f492bfaSAlfred Perlstein } __packed;
1533a31b7ebSMike Smith 
1543a31b7ebSMike Smith struct ciss_command
1553a31b7ebSMike Smith {
1563a31b7ebSMike Smith     struct ciss_header			header;
1573a31b7ebSMike Smith     struct ciss_cdb			cdb;
1583a31b7ebSMike Smith     struct ciss_error_info_pointer	error_info;
1593a31b7ebSMike Smith     struct ciss_sg_entry		sg[0];
1604f492bfaSAlfred Perlstein } __packed;
1613a31b7ebSMike Smith 
1623a31b7ebSMike Smith #define CISS_OPCODE_REPORT_LOGICAL_LUNS		0xc2
1633a31b7ebSMike Smith #define CISS_OPCODE_REPORT_PHYSICAL_LUNS	0xc3
1643a31b7ebSMike Smith 
1653a31b7ebSMike Smith struct ciss_lun_report
1663a31b7ebSMike Smith {
1673a31b7ebSMike Smith     u_int32_t	list_size;		/* big-endian */
1683a31b7ebSMike Smith     u_int32_t	:32;
1693a31b7ebSMike Smith     union ciss_device_address lun[0];
1704f492bfaSAlfred Perlstein } __packed;
1713a31b7ebSMike Smith 
172440baa08SPaul Saab #define	CISS_VPD_LOGICAL_DRIVE_GEOMETRY		0xc1
173440baa08SPaul Saab struct ciss_ldrive_geometry
174440baa08SPaul Saab {
175440baa08SPaul Saab     u_int8_t	periph_qualifier:3;
176440baa08SPaul Saab     u_int8_t	periph_devtype:5;
177440baa08SPaul Saab     u_int8_t	page_code;
178440baa08SPaul Saab     u_int8_t	res1;
179440baa08SPaul Saab     u_int8_t	page_length;
180440baa08SPaul Saab     u_int16_t	cylinders;		/* big-endian */
181440baa08SPaul Saab     u_int8_t	heads;
182440baa08SPaul Saab     u_int8_t	sectors;
183440baa08SPaul Saab     u_int8_t	fault_tolerance;
184440baa08SPaul Saab     u_int8_t	res2[3];
185440baa08SPaul Saab } __attribute__ ((packed));
186440baa08SPaul Saab 
1873a31b7ebSMike Smith struct ciss_report_cdb
1883a31b7ebSMike Smith {
1893a31b7ebSMike Smith     u_int8_t	opcode;
1903a31b7ebSMike Smith     u_int8_t	reserved[5];
1913a31b7ebSMike Smith     u_int32_t	length;			/* big-endian */
1923a31b7ebSMike Smith     u_int8_t	:8;
1933a31b7ebSMike Smith     u_int8_t	control;
1944f492bfaSAlfred Perlstein } __packed;
1953a31b7ebSMike Smith 
1963a31b7ebSMike Smith /*
1973a31b7ebSMike Smith  * Note that it's not clear whether we have to set the detail field to
1983a31b7ebSMike Smith  * the tag of the command to be aborted, or the tag field in the command itself;
1993a31b7ebSMike Smith  * documentation conflicts on this.
2003a31b7ebSMike Smith  */
2013a31b7ebSMike Smith #define CISS_OPCODE_MESSAGE_ABORT		0x00
2023a31b7ebSMike Smith #define CISS_MESSAGE_ABORT_TASK			0x00
2033a31b7ebSMike Smith #define CISS_MESSAGE_ABORT_TASK_SET		0x01
2043a31b7ebSMike Smith #define CISS_MESSAGE_ABORT_CLEAR_ACA		0x02
2053a31b7ebSMike Smith #define CISS_MESSAGE_ABORT_CLEAR_TASK_SET	0x03
2063a31b7ebSMike Smith 
2073a31b7ebSMike Smith #define CISS_OPCODE_MESSAGE_RESET		0x01
2083a31b7ebSMike Smith #define CISS_MESSAGE_RESET_CONTROLLER		0x00
2093a31b7ebSMike Smith #define CISS_MESSAGE_RESET_BUS			0x01
2103a31b7ebSMike Smith #define CISS_MESSAGE_RESET_TARGET		0x03
2113a31b7ebSMike Smith #define CISS_MESSAGE_RESET_LOGICAL_UNIT		0x04
2123a31b7ebSMike Smith 
2133a31b7ebSMike Smith #define CISS_OPCODE_MESSAGE_SCAN		0x02
2143a31b7ebSMike Smith #define CISS_MESSAGE_SCAN_CONTROLLER		0x00
2153a31b7ebSMike Smith #define CISS_MESSAGE_SCAN_BUS			0x01
2163a31b7ebSMike Smith #define CISS_MESSAGE_SCAN_TARGET		0x03
2173a31b7ebSMike Smith #define CISS_MESSAGE_SCAN_LOGICAL_UNIT		0x04
2183a31b7ebSMike Smith 
2193a31b7ebSMike Smith #define CISS_OPCODE_MESSAGE_NOP			0x03
2203a31b7ebSMike Smith 
2213a31b7ebSMike Smith struct ciss_message_cdb
2223a31b7ebSMike Smith {
2233a31b7ebSMike Smith     u_int8_t	opcode;
2243a31b7ebSMike Smith     u_int8_t	type;
2253a31b7ebSMike Smith     u_int16_t	:16;
2263a31b7ebSMike Smith     u_int32_t	abort_tag;					/* XXX endianness? */
2273a31b7ebSMike Smith     u_int8_t	reserved[8];
2284f492bfaSAlfred Perlstein } __packed;
2293a31b7ebSMike Smith 
2303a31b7ebSMike Smith /*
2313a31b7ebSMike Smith  * CISS vendor-specific commands/messages.
2323a31b7ebSMike Smith  *
2333a31b7ebSMike Smith  * Note that while messages and vendor-specific commands are
2343a31b7ebSMike Smith  * differentiated, they are handled in basically the same way and can
2353a31b7ebSMike Smith  * be considered to be basically the same thing, as long as the cdb
2363a31b7ebSMike Smith  * type field is set correctly.
2373a31b7ebSMike Smith  */
2383a31b7ebSMike Smith #define CISS_OPCODE_READ		0xc0
2393a31b7ebSMike Smith #define CISS_OPCODE_WRITE		0xc1
2403a31b7ebSMike Smith #define CISS_COMMAND_NOTIFY_ON_EVENT	0xd0
2413a31b7ebSMike Smith #define CISS_COMMAND_ABORT_NOTIFY	0xd1
2423a31b7ebSMike Smith 
2433a31b7ebSMike Smith struct ciss_notify_cdb
2443a31b7ebSMike Smith {
2453a31b7ebSMike Smith     u_int8_t	opcode;
2463a31b7ebSMike Smith     u_int8_t	command;
2473a31b7ebSMike Smith     u_int8_t	res1[2];
2483a31b7ebSMike Smith     u_int16_t	timeout;		/* seconds, little-endian */
2493a31b7ebSMike Smith     u_int8_t	res2;			/* reserved */
2503a31b7ebSMike Smith     u_int8_t	synchronous:1;		/* return immediately */
2513a31b7ebSMike Smith     u_int8_t	ordered:1;		/* return events in recorded order */
2523a31b7ebSMike Smith     u_int8_t	seek_to_oldest:1;	/* reset read counter to oldest event */
2533a31b7ebSMike Smith     u_int8_t	new_only:1;		/* ignore any queued events */
2543a31b7ebSMike Smith     u_int8_t	:4;
2553a31b7ebSMike Smith     u_int32_t	length;			/* must be 512, little-endian */
2563a31b7ebSMike Smith #define CISS_NOTIFY_DATA_SIZE	512
2573a31b7ebSMike Smith     u_int8_t	control;
2584f492bfaSAlfred Perlstein } __packed;
2593a31b7ebSMike Smith 
2603a31b7ebSMike Smith #define CISS_NOTIFY_NOTIFIER		0
2613a31b7ebSMike Smith #define CISS_NOTIFY_NOTIFIER_STATUS		0
2623a31b7ebSMike Smith #define CISS_NOTIFY_NOTIFIER_PROTOCOL		1
2633a31b7ebSMike Smith 
2643a31b7ebSMike Smith #define CISS_NOTIFY_HOTPLUG		1
2653a31b7ebSMike Smith #define CISS_NOTIFY_HOTPLUG_PHYSICAL		0
2663a31b7ebSMike Smith #define CISS_NOTIFY_HOTPLUG_POWERSUPPLY		1
2673a31b7ebSMike Smith #define CISS_NOTIFY_HOTPLUG_FAN			2
2683a31b7ebSMike Smith #define CISS_NOTIFY_HOTPLUG_POWER		3
2693a31b7ebSMike Smith #define CISS_NOTIFY_HOTPLUG_REDUNDANT		4
2703a31b7ebSMike Smith 
2713a31b7ebSMike Smith #define CISS_NOTIFY_HARDWARE		2
2723a31b7ebSMike Smith #define CISS_NOTIFY_HARDWARE_CABLES		0
2733a31b7ebSMike Smith #define CISS_NOTIFY_HARDWARE_MEMORY		1
2743a31b7ebSMike Smith #define CISS_NOTIFY_HARDWARE_FAN		2
2753a31b7ebSMike Smith #define CISS_NOTIFY_HARDWARE_VRM		3
2763a31b7ebSMike Smith 
2773a31b7ebSMike Smith #define CISS_NOTIFY_ENVIRONMENT		3
2783a31b7ebSMike Smith #define CISS_NOTIFY_ENVIRONMENT_TEMPERATURE	0
2793a31b7ebSMike Smith #define CISS_NOTIFY_ENVIRONMENT_POWERSUPPLY	1
2803a31b7ebSMike Smith #define CISS_NOTIFY_ENVIRONMENT_CHASSIS		2
2813a31b7ebSMike Smith #define CISS_NOTIFY_ENVIRONMENT_POWER		3
2823a31b7ebSMike Smith 
2833a31b7ebSMike Smith #define CISS_NOTIFY_PHYSICAL		4
2843a31b7ebSMike Smith #define CISS_NOTIFY_PHYSICAL_STATE		0
2853a31b7ebSMike Smith 
2863a31b7ebSMike Smith #define CISS_NOTIFY_LOGICAL		5
2873a31b7ebSMike Smith #define CISS_NOTIFY_LOGICAL_STATUS		0
2883a31b7ebSMike Smith #define CISS_NOTIFY_LOGICAL_ERROR		1
2893a31b7ebSMike Smith #define CISS_NOTIFY_LOGICAL_SURFACE		2
2903a31b7ebSMike Smith 
2913a31b7ebSMike Smith #define CISS_NOTIFY_REDUNDANT		6
2923a31b7ebSMike Smith #define CISS_NOTIFY_REDUNDANT_STATUS		0
2933a31b7ebSMike Smith 
2943a31b7ebSMike Smith #define CISS_NOTIFY_CISS		8
2953a31b7ebSMike Smith #define CISS_NOTIFY_CISS_REDUNDANT_CHANGE	0
2963a31b7ebSMike Smith #define CISS_NOTIFY_CISS_PATH_STATUS		1
2973a31b7ebSMike Smith #define CISS_NOTIFY_CISS_HARDWARE_ERROR		2
2983a31b7ebSMike Smith #define CISS_NOTIFY_CISS_LOGICAL		3
2993a31b7ebSMike Smith 
3003a31b7ebSMike Smith struct ciss_notify_drive
3013a31b7ebSMike Smith {
3023a31b7ebSMike Smith     u_int16_t	physical_drive_number;
3033a31b7ebSMike Smith     u_int8_t	configured_drive_flag;
3043a31b7ebSMike Smith     u_int8_t	spare_drive_flag;
3053a31b7ebSMike Smith     u_int8_t	big_physical_drive_number;
3063a31b7ebSMike Smith     u_int8_t	enclosure_bay_number;
3074f492bfaSAlfred Perlstein } __packed;
3083a31b7ebSMike Smith 
3093a31b7ebSMike Smith struct ciss_notify_locator
3103a31b7ebSMike Smith {
3113a31b7ebSMike Smith     u_int16_t	port;
3123a31b7ebSMike Smith     u_int16_t	id;
3133a31b7ebSMike Smith     u_int16_t	box;
3144f492bfaSAlfred Perlstein } __packed;
3153a31b7ebSMike Smith 
3163a31b7ebSMike Smith struct ciss_notify_redundant_controller
3173a31b7ebSMike Smith {
3183a31b7ebSMike Smith     u_int16_t	slot;
3194f492bfaSAlfred Perlstein } __packed;
3203a31b7ebSMike Smith 
3213a31b7ebSMike Smith struct ciss_notify_logical_status
3223a31b7ebSMike Smith {
3233a31b7ebSMike Smith     u_int16_t	logical_drive;
3243a31b7ebSMike Smith     u_int8_t	previous_state;
3253a31b7ebSMike Smith     u_int8_t	new_state;
3263a31b7ebSMike Smith     u_int8_t	spare_state;
3274f492bfaSAlfred Perlstein } __packed;
3283a31b7ebSMike Smith 
3293a31b7ebSMike Smith struct ciss_notify_rebuild_aborted
3303a31b7ebSMike Smith {
3313a31b7ebSMike Smith     u_int16_t	logical_drive;
3323a31b7ebSMike Smith     u_int8_t	replacement_drive;
3333a31b7ebSMike Smith     u_int8_t	error_drive;
3343a31b7ebSMike Smith     u_int8_t	big_replacement_drive;
3353a31b7ebSMike Smith     u_int8_t	big_error_drive;
3364f492bfaSAlfred Perlstein } __packed;
3373a31b7ebSMike Smith 
3383a31b7ebSMike Smith struct ciss_notify_io_error
3393a31b7ebSMike Smith {
3403a31b7ebSMike Smith     u_int16_t	logical_drive;
3413a31b7ebSMike Smith     u_int32_t	lba;
3423a31b7ebSMike Smith     u_int16_t	block_count;
3433a31b7ebSMike Smith     u_int8_t	command;
3443a31b7ebSMike Smith     u_int8_t	failure_bus;
3453a31b7ebSMike Smith     u_int8_t	failure_drive;
3463a31b7ebSMike Smith     u_int64_t	big_lba;
3474f492bfaSAlfred Perlstein } __packed;
3483a31b7ebSMike Smith 
3493a31b7ebSMike Smith struct ciss_notify_consistency_completed
3503a31b7ebSMike Smith {
3513a31b7ebSMike Smith     u_int16_t	logical_drive;
3524f492bfaSAlfred Perlstein } __packed;
3533a31b7ebSMike Smith 
3543a31b7ebSMike Smith struct ciss_notify
3553a31b7ebSMike Smith {
3563a31b7ebSMike Smith     u_int32_t	timestamp;		/* seconds since controller power-on */
3573a31b7ebSMike Smith     u_int16_t	class;
3583a31b7ebSMike Smith     u_int16_t	subclass;
3593a31b7ebSMike Smith     u_int16_t	detail;
3603a31b7ebSMike Smith     union
3613a31b7ebSMike Smith     {
3623a31b7ebSMike Smith 	struct ciss_notify_drive		drive;
3633a31b7ebSMike Smith 	struct ciss_notify_locator		location;
3643a31b7ebSMike Smith 	struct ciss_notify_redundant_controller	redundant_controller;
3653a31b7ebSMike Smith 	struct ciss_notify_logical_status	logical_status;
3663a31b7ebSMike Smith 	struct ciss_notify_rebuild_aborted	rebuild_aborted;
3673a31b7ebSMike Smith 	struct ciss_notify_io_error		io_error;
3683a31b7ebSMike Smith 	struct ciss_notify_consistency_completed consistency_completed;
3693a31b7ebSMike Smith 	u_int8_t	data[64];
3703a31b7ebSMike Smith     } data;
3713a31b7ebSMike Smith     char	message[80];
3723a31b7ebSMike Smith     u_int32_t	tag;
3733a31b7ebSMike Smith     u_int16_t	date;
3743a31b7ebSMike Smith     u_int16_t	year;
3753a31b7ebSMike Smith     u_int32_t	time;
3763a31b7ebSMike Smith     u_int16_t	pre_power_up_time;
3773a31b7ebSMike Smith     union ciss_device_address	device;
3783a31b7ebSMike Smith     /* XXX pads to 512 bytes */
3794f492bfaSAlfred Perlstein } __packed;
3803a31b7ebSMike Smith 
3813a31b7ebSMike Smith /*
3823a31b7ebSMike Smith  * CISS config table, which describes the controller's
3833a31b7ebSMike Smith  * supported interface(s) and capabilities.
3843a31b7ebSMike Smith  *
3853a31b7ebSMike Smith  * This is mapped directly via PCI.
3863a31b7ebSMike Smith  */
3873a31b7ebSMike Smith struct ciss_config_table
3883a31b7ebSMike Smith {
3893a31b7ebSMike Smith     char	signature[4];		/* "CISS" */
3903a31b7ebSMike Smith     u_int32_t	valence;
3913a31b7ebSMike Smith #define CISS_MIN_VALENCE	1	/* only value currently supported */
3923a31b7ebSMike Smith #define CISS_MAX_VALENCE	1
3933a31b7ebSMike Smith     u_int32_t	supported_methods;
3943a31b7ebSMike Smith #define CISS_TRANSPORT_METHOD_READY	(1<<0)
3953a31b7ebSMike Smith #define CISS_TRANSPORT_METHOD_SIMPLE	(1<<1)
3963a31b7ebSMike Smith     u_int32_t	active_method;
3973a31b7ebSMike Smith     u_int32_t	requested_method;
3983a31b7ebSMike Smith     u_int32_t	command_physlimit;
3993a31b7ebSMike Smith     u_int32_t	interrupt_coalesce_delay;
4003a31b7ebSMike Smith     u_int32_t	interrupt_coalesce_count;
4013a31b7ebSMike Smith     u_int32_t	max_outstanding_commands;
4023a31b7ebSMike Smith     u_int32_t	bus_types;
4033a31b7ebSMike Smith #define CISS_TRANSPORT_BUS_TYPE_ULTRA2	(1<<0)
4043a31b7ebSMike Smith #define CISS_TRANSPORT_BUS_TYPE_ULTRA3	(1<<1)
4053a31b7ebSMike Smith #define CISS_TRANSPORT_BUS_TYPE_FIBRE1	(1<<8)
4063a31b7ebSMike Smith #define CISS_TRANSPORT_BUS_TYPE_FIBRE2	(1<<9)
4073a31b7ebSMike Smith     u_int32_t	host_driver;
4083a31b7ebSMike Smith #define CISS_DRIVER_SUPPORT_UNIT_ATTENTION	(1<<0)
4093a31b7ebSMike Smith #define CISS_DRIVER_QUICK_INIT			(1<<1)
4103a31b7ebSMike Smith #define CISS_DRIVER_INTERRUPT_ON_LOCKUP		(1<<2)
4113a31b7ebSMike Smith #define CISS_DRIVER_SUPPORT_MIXED_Q_TAGS	(1<<3)
4123a31b7ebSMike Smith #define CISS_DRIVER_HOST_IS_ALPHA		(1<<4)
4133a31b7ebSMike Smith     char	server_name[16];
4143a31b7ebSMike Smith     u_int32_t	heartbeat;
4154f492bfaSAlfred Perlstein } __packed;
4163a31b7ebSMike Smith 
4173a31b7ebSMike Smith /*
4183a31b7ebSMike Smith  * In a flagrant violation of what CISS seems to be meant to be about,
4193a31b7ebSMike Smith  * Compaq recycle a goodly portion of their previous generation's
4203a31b7ebSMike Smith  * command set (and all the legacy baggage related to a design
4213a31b7ebSMike Smith  * originally aimed at narrow SCSI) through the Array Controller Read
4223a31b7ebSMike Smith  * and Array Controller Write interface.
4233a31b7ebSMike Smith  *
4243a31b7ebSMike Smith  * Command ID values here can be looked up for in the
4253a31b7ebSMike Smith  * publically-available documentation for the older controllers; note
4263a31b7ebSMike Smith  * that the command layout is necessarily different to fit within the
4273a31b7ebSMike Smith  * CDB.
4283a31b7ebSMike Smith  */
4293a31b7ebSMike Smith #define CISS_ARRAY_CONTROLLER_READ	0x26
4303a31b7ebSMike Smith #define CISS_ARRAY_CONTROLLER_WRITE	0x27
4313a31b7ebSMike Smith 
4323a31b7ebSMike Smith #define CISS_BMIC_ID_LDRIVE		0x10
4333a31b7ebSMike Smith #define CISS_BMIC_ID_CTLR		0x11
4343a31b7ebSMike Smith #define CISS_BMIC_ID_LSTATUS		0x12
4353a31b7ebSMike Smith #define CISS_BMIC_ID_PDRIVE		0x15
4363a31b7ebSMike Smith #define CISS_BMIC_BLINK_PDRIVE		0x16
4373a31b7ebSMike Smith #define CISS_BMIC_SENSE_BLINK_PDRIVE	0x17
4383a31b7ebSMike Smith #define CISS_BMIC_FLUSH_CACHE		0xc2
4393a31b7ebSMike Smith #define CISS_BMIC_ACCEPT_MEDIA		0xe0
4403a31b7ebSMike Smith 
4413a31b7ebSMike Smith /*
4423a31b7ebSMike Smith  * When numbering drives, the original design assumed that
4433a31b7ebSMike Smith  * drives 0-7 are on the first SCSI bus, 8-15 on the second,
4443a31b7ebSMike Smith  * and so forth.  In order to handle modern SCSI configurations,
4453a31b7ebSMike Smith  * the MSB is set in the drive ID field, in which case the
4463a31b7ebSMike Smith  * modulus changes from 8 to the number of supported drives
4473a31b7ebSMike Smith  * per SCSI bus (as obtained from the ID_CTLR command).
4483a31b7ebSMike Smith  * This feature is referred to as BIG_MAP support, and we assume
4493a31b7ebSMike Smith  * that all CISS controllers support it.
4503a31b7ebSMike Smith  */
4513a31b7ebSMike Smith 
4523a31b7ebSMike Smith #define CISS_BIG_MAP_ID(sc, bus, target)		\
4533a31b7ebSMike Smith 	(0x80 | 					\
4543a31b7ebSMike Smith 	 ((sc)->ciss_id->drives_per_scsi_bus * (bus)) |	\
4553a31b7ebSMike Smith 	 (target))
4563a31b7ebSMike Smith 
4573a31b7ebSMike Smith #define CISS_BIG_MAP_BUS(sc, id)			\
4583a31b7ebSMike Smith 	(((id) & 0x80) ? (((id) & ~0x80) / (sc)->ciss_id->drives_per_scsi_bus) : -1)
4593a31b7ebSMike Smith 
4603a31b7ebSMike Smith #define CISS_BIG_MAP_TARGET(sc, id)			\
4613a31b7ebSMike Smith 	(((id) & 0x80) ? (((id) & ~0x80) % (sc)->ciss_id->drives_per_scsi_bus) : -1)
4623a31b7ebSMike Smith 
4633a31b7ebSMike Smith #define CISS_BIG_MAP_ENTRIES	128	/* number of entries in a BIG_MAP */
4643a31b7ebSMike Smith 
4653a31b7ebSMike Smith /*
466c6131460SPaul Saab  * In the device address of a logical volume, the bus number
467c6131460SPaul Saab  * is encoded into the logical lun volume number starting
468c6131460SPaul Saab  * at the second byte, with the first byte defining the
469c6131460SPaul Saab  * logical drive number.
470c6131460SPaul Saab  */
471c6131460SPaul Saab #define CISS_LUN_TO_BUS(x)    (((x) >> 16) & 0xFF)
472c6131460SPaul Saab #define CISS_LUN_TO_TARGET(x) ((x) & 0xFF)
473c6131460SPaul Saab 
474c6131460SPaul Saab /*
4753a31b7ebSMike Smith  * BMIC CDB
4763a31b7ebSMike Smith  *
4773a31b7ebSMike Smith  * Note that the phys_drive/res1 field is nominally the 32-bit
4783a31b7ebSMike Smith  * "block number" field, but the only BMIC command(s) of interest
4793a31b7ebSMike Smith  * implemented overload the MSB (note big-endian format here)
4803a31b7ebSMike Smith  * to be the physical drive ID, so we define accordingly.
4813a31b7ebSMike Smith  */
4823a31b7ebSMike Smith struct ciss_bmic_cdb {
4833a31b7ebSMike Smith     u_int8_t	opcode;
4843a31b7ebSMike Smith     u_int8_t	log_drive;
4853a31b7ebSMike Smith     u_int8_t	phys_drive;
4863a31b7ebSMike Smith     u_int8_t	res1[3];
4873a31b7ebSMike Smith     u_int8_t	bmic_opcode;
4883a31b7ebSMike Smith     u_int16_t	size;			/* big-endian */
4893a31b7ebSMike Smith     u_int8_t	res2;
4904f492bfaSAlfred Perlstein } __packed;
4913a31b7ebSMike Smith 
4923a31b7ebSMike Smith /*
4933a31b7ebSMike Smith  * BMIC command command/return structures.
4943a31b7ebSMike Smith  */
4953a31b7ebSMike Smith 
4963a31b7ebSMike Smith /* CISS_BMIC_ID_LDRIVE */
4973a31b7ebSMike Smith struct ciss_bmic_id_ldrive {
4983a31b7ebSMike Smith     u_int16_t	block_size;
4993a31b7ebSMike Smith     u_int32_t	blocks_available;
5003a31b7ebSMike Smith     u_int8_t	drive_parameter_table[16];	/* XXX define */
5013a31b7ebSMike Smith     u_int8_t	fault_tolerance;
5023a31b7ebSMike Smith #define CISS_LDRIVE_RAID0	0
5033a31b7ebSMike Smith #define CISS_LDRIVE_RAID4	1
5043a31b7ebSMike Smith #define CISS_LDRIVE_RAID1	2
5053a31b7ebSMike Smith #define CISS_LDRIVE_RAID5	3
506aaf8327bSPaul Saab #define CISS_LDRIVE_RAID51	4
507aaf8327bSPaul Saab #define CISS_LDRIVE_RAIDADG	5
5083a31b7ebSMike Smith     u_int8_t	res1[2];
5093a31b7ebSMike Smith #if 0	/* only for identify logical drive extended (0x18) */
5103a31b7ebSMike Smith     u_int32_t	logical_drive_identifier;
5113a31b7ebSMike Smith     char	logical_drive_label[64];
5123a31b7ebSMike Smith #endif
5134f492bfaSAlfred Perlstein } __packed;
5143a31b7ebSMike Smith 
5153a31b7ebSMike Smith /* CISS_BMIC_ID_LSTATUS */
5163a31b7ebSMike Smith struct ciss_bmic_id_lstatus {
5173a31b7ebSMike Smith     u_int8_t	status;
5183a31b7ebSMike Smith #define CISS_LSTATUS_OK				0
5193a31b7ebSMike Smith #define CISS_LSTATUS_FAILED			1
5203a31b7ebSMike Smith #define CISS_LSTATUS_NOT_CONFIGURED		2
5213a31b7ebSMike Smith #define CISS_LSTATUS_INTERIM_RECOVERY		3
5223a31b7ebSMike Smith #define CISS_LSTATUS_READY_RECOVERY		4
5233a31b7ebSMike Smith #define CISS_LSTATUS_RECOVERING			5
5243a31b7ebSMike Smith #define CISS_LSTATUS_WRONG_PDRIVE		6
5253a31b7ebSMike Smith #define CISS_LSTATUS_MISSING_PDRIVE		7
5263a31b7ebSMike Smith #define CISS_LSTATUS_EXPANDING			10
5273a31b7ebSMike Smith #define CISS_LSTATUS_BECOMING_READY		11
5283a31b7ebSMike Smith #define CISS_LSTATUS_QUEUED_FOR_EXPANSION	12
5293a31b7ebSMike Smith     u_int32_t	deprecated_drive_failure_map;
5303a31b7ebSMike Smith     u_int8_t	res1[416];
5313a31b7ebSMike Smith     u_int32_t	blocks_to_recover;
5323a31b7ebSMike Smith     u_int8_t	deprecated_drive_rebuilding;
5333a31b7ebSMike Smith     u_int16_t	deprecated_remap_count[32];
5343a31b7ebSMike Smith     u_int32_t	deprecated_replacement_map;
5353a31b7ebSMike Smith     u_int32_t	deprecated_active_spare_map;
5363a31b7ebSMike Smith     u_int8_t	spare_configured:1;
5373a31b7ebSMike Smith     u_int8_t	spare_rebuilding:1;
5383a31b7ebSMike Smith     u_int8_t	spare_rebuilt:1;
5393a31b7ebSMike Smith     u_int8_t	spare_failed:1;
5403a31b7ebSMike Smith     u_int8_t	spare_switched:1;
5413a31b7ebSMike Smith     u_int8_t	spare_available:1;
5423a31b7ebSMike Smith     u_int8_t	res2:2;
5433a31b7ebSMike Smith     u_int8_t	deprecated_spare_to_replace_map[32];
5443a31b7ebSMike Smith     u_int32_t	deprecated_replaced_marked_ok_map;
5453a31b7ebSMike Smith     u_int8_t	media_exchanged;
5463a31b7ebSMike Smith     u_int8_t	cache_failure;
5473a31b7ebSMike Smith     u_int8_t	expand_failure;
5483a31b7ebSMike Smith     u_int8_t	rebuild_read_failure:1;
5493a31b7ebSMike Smith     u_int8_t	rebuild_write_failure:1;
5503a31b7ebSMike Smith     u_int8_t	res3:6;
5513a31b7ebSMike Smith     u_int8_t	drive_failure_map[CISS_BIG_MAP_ENTRIES / 8];
5523a31b7ebSMike Smith     u_int16_t	remap_count[CISS_BIG_MAP_ENTRIES];
5533a31b7ebSMike Smith     u_int8_t	replacement_map[CISS_BIG_MAP_ENTRIES / 8];
5543a31b7ebSMike Smith     u_int8_t	active_spare_map[CISS_BIG_MAP_ENTRIES / 8];
5553a31b7ebSMike Smith     u_int8_t	spare_to_replace_map[CISS_BIG_MAP_ENTRIES];
5563a31b7ebSMike Smith     u_int8_t	replaced_marked_ok_map[CISS_BIG_MAP_ENTRIES / 8];
5573a31b7ebSMike Smith     u_int8_t	drive_rebuilding;
5584f492bfaSAlfred Perlstein } __packed;
5593a31b7ebSMike Smith 
5603a31b7ebSMike Smith /* CISS_BMIC_ID_CTLR */
5613a31b7ebSMike Smith struct ciss_bmic_id_table {
5623a31b7ebSMike Smith     u_int8_t	configured_logical_drives;
5633a31b7ebSMike Smith     u_int32_t	config_signature;
5643a31b7ebSMike Smith     char	running_firmware_revision[4];
5653a31b7ebSMike Smith     char	stored_firmware_revision[4];
5663a31b7ebSMike Smith     u_int8_t	hardware_revision;
5673a31b7ebSMike Smith     u_int8_t	res1[4];
5683a31b7ebSMike Smith     u_int32_t	deprecated_drive_present_map;
5693a31b7ebSMike Smith     u_int32_t	deprecated_external_drive_present_map;
5703a31b7ebSMike Smith     u_int32_t	board_id;
5713a31b7ebSMike Smith     u_int8_t	res2;
5723a31b7ebSMike Smith     u_int32_t	deprecated_non_disk_map;
5733a31b7ebSMike Smith     u_int8_t	res3[5];
5743a31b7ebSMike Smith     char	marketting_revision;
5753a31b7ebSMike Smith     u_int8_t	res4:3;
5763a31b7ebSMike Smith     u_int8_t	more_than_seven_supported:1;
5773a31b7ebSMike Smith     u_int8_t	res5:3;
5783a31b7ebSMike Smith     u_int8_t	big_map_supported:1;		/* must be set! */
5793a31b7ebSMike Smith     u_int8_t	res6[2];
5803a31b7ebSMike Smith     u_int8_t	scsi_bus_count;
5813a31b7ebSMike Smith     u_int32_t	res7;
5823a31b7ebSMike Smith     u_int32_t	controller_clock;
5833a31b7ebSMike Smith     u_int8_t	drives_per_scsi_bus;
5843a31b7ebSMike Smith     u_int8_t	big_drive_present_map[CISS_BIG_MAP_ENTRIES / 8];
5853a31b7ebSMike Smith     u_int8_t	big_external_drive_present_map[CISS_BIG_MAP_ENTRIES / 8];
5863a31b7ebSMike Smith     u_int8_t	big_non_disk_map[CISS_BIG_MAP_ENTRIES / 8];
5874f492bfaSAlfred Perlstein } __packed;
5883a31b7ebSMike Smith 
5893a31b7ebSMike Smith /* CISS_BMIC_ID_PDRIVE */
5903a31b7ebSMike Smith struct ciss_bmic_id_pdrive {
5913a31b7ebSMike Smith     u_int8_t	scsi_bus;
5923a31b7ebSMike Smith     u_int8_t	scsi_id;
5933a31b7ebSMike Smith     u_int16_t	block_size;
5943a31b7ebSMike Smith     u_int32_t	total_blocks;
5953a31b7ebSMike Smith     u_int32_t	reserved_blocks;
5963a31b7ebSMike Smith     char	model[40];
5973a31b7ebSMike Smith     char	serial[40];
5983a31b7ebSMike Smith     char	revision[8];
5993a31b7ebSMike Smith     u_int8_t	inquiry_bits;
6003a31b7ebSMike Smith     u_int8_t	res1[2];
6013a31b7ebSMike Smith     u_int8_t	drive_present:1;
6023a31b7ebSMike Smith     u_int8_t	non_disk:1;
6033a31b7ebSMike Smith     u_int8_t	wide:1;
6043a31b7ebSMike Smith     u_int8_t	synchronous:1;
6053a31b7ebSMike Smith     u_int8_t	narrow:1;
6063a31b7ebSMike Smith     u_int8_t	wide_downgraded_to_narrow:1;
6073a31b7ebSMike Smith     u_int8_t	ultra:1;
6083a31b7ebSMike Smith     u_int8_t	ultra2:1;
6093a31b7ebSMike Smith     u_int8_t	SMART:1;
6103a31b7ebSMike Smith     u_int8_t	SMART_errors_recorded:1;
6113a31b7ebSMike Smith     u_int8_t	SMART_errors_enabled:1;
6123a31b7ebSMike Smith     u_int8_t	SMART_errors_detected:1;
6133a31b7ebSMike Smith     u_int8_t	external:1;
6143a31b7ebSMike Smith     u_int8_t	configured:1;
6153a31b7ebSMike Smith     u_int8_t	configured_spare:1;
6163a31b7ebSMike Smith     u_int8_t	cache_saved_enabled:1;
6173a31b7ebSMike Smith     u_int8_t	res2;
6183a31b7ebSMike Smith     u_int8_t	res3:6;
6193a31b7ebSMike Smith     u_int8_t	cache_currently_enabled:1;
6203a31b7ebSMike Smith     u_int8_t	cache_safe:1;
6213a31b7ebSMike Smith     u_int8_t	res4[5];
6223a31b7ebSMike Smith     char	connector[2];
6233a31b7ebSMike Smith     u_int8_t	res5;
6243a31b7ebSMike Smith     u_int8_t	bay;
6254f492bfaSAlfred Perlstein } __packed;
6263a31b7ebSMike Smith 
6273a31b7ebSMike Smith /* CISS_BMIC_BLINK_PDRIVE */
6283a31b7ebSMike Smith /* CISS_BMIC_SENSE_BLINK_PDRIVE */
6293a31b7ebSMike Smith struct ciss_bmic_blink_pdrive {
6303a31b7ebSMike Smith     u_int32_t	blink_duration;		/* 10ths of a second */
6313a31b7ebSMike Smith     u_int32_t	duration_elapsed;	/* only for sense command  */
6323a31b7ebSMike Smith     u_int8_t	blinktab[256];
6333a31b7ebSMike Smith #define CISS_BMIC_BLINK_ALL	1
6343a31b7ebSMike Smith #define CISS_BMIC_BLINK_TIMED	2
6353a31b7ebSMike Smith     u_int8_t	res2[248];
6364f492bfaSAlfred Perlstein } __packed;
6373a31b7ebSMike Smith 
6383a31b7ebSMike Smith /* CISS_BMIC_FLUSH_CACHE */
6393a31b7ebSMike Smith struct ciss_bmic_flush_cache {
6403a31b7ebSMike Smith     u_int16_t	flag;
6413a31b7ebSMike Smith #define CISS_BMIC_FLUSH_AND_ENABLE	0
6423a31b7ebSMike Smith #define CISS_BMIC_FLUSH_AND_DISABLE	1
6433a31b7ebSMike Smith     u_int8_t	res1[510];
6444f492bfaSAlfred Perlstein } __packed;
6453a31b7ebSMike Smith 
6463a31b7ebSMike Smith #ifdef _KERNEL
6473a31b7ebSMike Smith /*
6483a31b7ebSMike Smith  * CISS "simple" transport layer.
6493a31b7ebSMike Smith  *
6503a31b7ebSMike Smith  * Note that there are two slightly different versions of this interface
6513a31b7ebSMike Smith  * with different interrupt mask bits.  There's nothing like consistency...
6523a31b7ebSMike Smith  */
6533a31b7ebSMike Smith #define CISS_TL_SIMPLE_BAR_REGS	0x10	/* BAR pointing to register space */
6543a31b7ebSMike Smith #define CISS_TL_SIMPLE_BAR_CFG	0x14	/* BAR pointing to space containing config table */
6553a31b7ebSMike Smith 
6563a31b7ebSMike Smith #define CISS_TL_SIMPLE_IDBR	0x20	/* inbound doorbell register */
6573a31b7ebSMike Smith #define CISS_TL_SIMPLE_IDBR_CFG_TABLE	(1<<0)	/* notify controller of config table update */
6583a31b7ebSMike Smith 
6593a31b7ebSMike Smith #define CISS_TL_SIMPLE_ISR	0x30	/* interrupt status register */
6603a31b7ebSMike Smith #define CISS_TL_SIMPLE_IMR	0x34	/* interrupt mask register */
6613a31b7ebSMike Smith #define CISS_TL_SIMPLE_INTR_OPQ_SA5	(1<<3)	/* OPQ not empty interrupt, SA5 boards */
6623a31b7ebSMike Smith #define CISS_TL_SIMPLE_INTR_OPQ_SA5B	(1<<2)	/* OPQ not empty interrupt, SA5B boards */
6633a31b7ebSMike Smith 
6643a31b7ebSMike Smith #define CISS_TL_SIMPLE_IPQ	0x40	/* inbound post queue */
6653a31b7ebSMike Smith #define CISS_TL_SIMPLE_OPQ	0x44	/* outbound post queue */
6663a31b7ebSMike Smith #define CISS_TL_SIMPLE_OPQ_EMPTY	(~(u_int32_t)0)
6673a31b7ebSMike Smith 
6683a31b7ebSMike Smith #define CISS_TL_SIMPLE_CFG_BAR	0xb4	/* should be 0x14 */
6693a31b7ebSMike Smith #define CISS_TL_SIMPLE_CFG_OFF	0xb8	/* offset in BAR at which config table is located */
6703a31b7ebSMike Smith 
6713a31b7ebSMike Smith /*
6723a31b7ebSMike Smith  * Register access primitives.
6733a31b7ebSMike Smith  */
6743a31b7ebSMike Smith #define CISS_TL_SIMPLE_READ(sc, ofs) \
6753a31b7ebSMike Smith 	bus_space_read_4(sc->ciss_regs_btag, sc->ciss_regs_bhandle, ofs)
6763a31b7ebSMike Smith #define CISS_TL_SIMPLE_WRITE(sc, ofs, val) \
6773a31b7ebSMike Smith 	bus_space_write_4(sc->ciss_regs_btag, sc->ciss_regs_bhandle, ofs, val)
6783a31b7ebSMike Smith 
6793a31b7ebSMike Smith #define CISS_TL_SIMPLE_POST_CMD(sc, phys)	CISS_TL_SIMPLE_WRITE(sc, CISS_TL_SIMPLE_IPQ, phys)
6803a31b7ebSMike Smith #define CISS_TL_SIMPLE_FETCH_CMD(sc)		CISS_TL_SIMPLE_READ(sc, CISS_TL_SIMPLE_OPQ)
6813a31b7ebSMike Smith 
6823a31b7ebSMike Smith /*
6833a31b7ebSMike Smith  * XXX documentation conflicts with the Linux driver as to whether setting or clearing
6843a31b7ebSMike Smith  *     bits masks interrupts
6853a31b7ebSMike Smith  */
6863a31b7ebSMike Smith #define CISS_TL_SIMPLE_DISABLE_INTERRUPTS(sc) \
6873a31b7ebSMike Smith 	CISS_TL_SIMPLE_WRITE(sc, CISS_TL_SIMPLE_IMR, \
6883a31b7ebSMike Smith 			     CISS_TL_SIMPLE_READ(sc, CISS_TL_SIMPLE_IMR) | (sc)->ciss_interrupt_mask)
6893a31b7ebSMike Smith #define CISS_TL_SIMPLE_ENABLE_INTERRUPTS(sc) \
6903a31b7ebSMike Smith 	CISS_TL_SIMPLE_WRITE(sc, CISS_TL_SIMPLE_IMR, \
6913a31b7ebSMike Smith 			     CISS_TL_SIMPLE_READ(sc, CISS_TL_SIMPLE_IMR) & ~(sc)->ciss_interrupt_mask)
6923a31b7ebSMike Smith 
6933a31b7ebSMike Smith #define CISS_TL_SIMPLE_OPQ_INTERRUPT(sc) \
6943a31b7ebSMike Smith 	(CISS_TL_SIMPLE_READ(sc, CISS_TL_SIMPLE_ISR) & (sc)->ciss_interrupt_mask)
6953a31b7ebSMike Smith 
6963a31b7ebSMike Smith #endif /* _KERNEL */
697