1*80c94ecdSKeith M Wesolowski /*
2*80c94ecdSKeith M Wesolowski  * This file and its contents are supplied under the terms of the
3*80c94ecdSKeith M Wesolowski  * Common Development and Distribution License ("CDDL"), version 1.0.
4*80c94ecdSKeith M Wesolowski  * You may only use this file in accordance with the terms of version
5*80c94ecdSKeith M Wesolowski  * 1.0 of the CDDL.
6*80c94ecdSKeith M Wesolowski  *
7*80c94ecdSKeith M Wesolowski  * A full copy of the text of the CDDL should have accompanied this
8*80c94ecdSKeith M Wesolowski  * source.  A copy of the CDDL is also available via the Internet at
9*80c94ecdSKeith M Wesolowski  * http://www.illumos.org/license/CDDL.
10*80c94ecdSKeith M Wesolowski  */
11*80c94ecdSKeith M Wesolowski 
12*80c94ecdSKeith M Wesolowski /*
13*80c94ecdSKeith M Wesolowski  * Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
14*80c94ecdSKeith M Wesolowski  */
15*80c94ecdSKeith M Wesolowski 
16*80c94ecdSKeith M Wesolowski #ifndef	_CPQARY3_SCSI_H
17*80c94ecdSKeith M Wesolowski #define	_CPQARY3_SCSI_H
18*80c94ecdSKeith M Wesolowski 
19*80c94ecdSKeith M Wesolowski #include <sys/types.h>
20*80c94ecdSKeith M Wesolowski #include "cpqary3_ciss.h"
21*80c94ecdSKeith M Wesolowski 
22*80c94ecdSKeith M Wesolowski #ifdef	__cplusplus
23*80c94ecdSKeith M Wesolowski extern "C" {
24*80c94ecdSKeith M Wesolowski #endif
25*80c94ecdSKeith M Wesolowski 
26*80c94ecdSKeith M Wesolowski /* CISS LUN Addressing MODEs */
27*80c94ecdSKeith M Wesolowski #define	PERIPHERIAL_DEV_ADDR 			0x0
28*80c94ecdSKeith M Wesolowski #define	LOGICAL_VOL_ADDR 				0x1
29*80c94ecdSKeith M Wesolowski #define	MASK_PERIPHERIAL_DEV_ADDR 		0x3
30*80c94ecdSKeith M Wesolowski #define	CISS_PHYS_MODE 					0x0
31*80c94ecdSKeith M Wesolowski 
32*80c94ecdSKeith M Wesolowski /*
33*80c94ecdSKeith M Wesolowski  * Definitions for compatibility with the old array BMIC interface
34*80c94ecdSKeith M Wesolowski  * CISS_OPCODE_RLL IS THE OPCODE FOR THE Report Logical Luns command
35*80c94ecdSKeith M Wesolowski  */
36*80c94ecdSKeith M Wesolowski #define	ARRAY_READ				0x26
37*80c94ecdSKeith M Wesolowski #define	ARRAY_WRITE				0x27
38*80c94ecdSKeith M Wesolowski #define	CISS_NEW_READ				0xC0
39*80c94ecdSKeith M Wesolowski #define	CISS_NEW_WRITE				0xC1
40*80c94ecdSKeith M Wesolowski #define	CISS_OPCODE_RLL				0xC2
41*80c94ecdSKeith M Wesolowski #define	CISS_OPCODE_RPL				0xC3
42*80c94ecdSKeith M Wesolowski #define	CISS_NO_TIMEOUT				0x0
43*80c94ecdSKeith M Wesolowski 
44*80c94ecdSKeith M Wesolowski /*
45*80c94ecdSKeith M Wesolowski  * BMIC commands
46*80c94ecdSKeith M Wesolowski  */
47*80c94ecdSKeith M Wesolowski #define	CISS_FLUSH_CACHE			0xC2
48*80c94ecdSKeith M Wesolowski #define	BMIC_IDENTIFY_LOGICAL_DRIVE		0x10
49*80c94ecdSKeith M Wesolowski #define	BMIC_SENSE_LOGICAL_DRIVE_STATUS		0x12
50*80c94ecdSKeith M Wesolowski 
51*80c94ecdSKeith M Wesolowski #define	CISS_MSG_ABORT				0x0
52*80c94ecdSKeith M Wesolowski #define	CISS_ABORT_TASK				0x0
53*80c94ecdSKeith M Wesolowski #define	CISS_ABORT_TASKSET			0x1
54*80c94ecdSKeith M Wesolowski #define	CISS_CTLR_INIT 				0xffff0000
55*80c94ecdSKeith M Wesolowski 
56*80c94ecdSKeith M Wesolowski #define	CISS_MSG_RESET				0x1
57*80c94ecdSKeith M Wesolowski #define	CISS_RESET_CTLR				0x0
58*80c94ecdSKeith M Wesolowski #define	CISS_RESET_TGT				0x3
59*80c94ecdSKeith M Wesolowski 
60*80c94ecdSKeith M Wesolowski /*
61*80c94ecdSKeith M Wesolowski  * The Controller SCSI ID is 7. Hence, when ever the OS issues a command
62*80c94ecdSKeith M Wesolowski  * for a target with ID greater than 7, the intended Logical Drive is
63*80c94ecdSKeith M Wesolowski  * actually one less than the issued ID.
64*80c94ecdSKeith M Wesolowski  * So, the allignment.
65*80c94ecdSKeith M Wesolowski  * The Mapping from OS to the HBA is as follows:
66*80c94ecdSKeith M Wesolowski  *	OS Target IDs		HBA taret IDs
67*80c94ecdSKeith M Wesolowski  *		0 - 6				0 - 6
68*80c94ecdSKeith M Wesolowski  *		7					- (Controller)
69*80c94ecdSKeith M Wesolowski  *		8 - 32				7 - 31
70*80c94ecdSKeith M Wesolowski  */
71*80c94ecdSKeith M Wesolowski 
72*80c94ecdSKeith M Wesolowski #define	CPQARY3_TGT_ALIGNMENT			0x1
73*80c94ecdSKeith M Wesolowski #define	CPQARY3_LEN_TAGINUSE			0x4
74*80c94ecdSKeith M Wesolowski 
75*80c94ecdSKeith M Wesolowski #define	CPQARY3_CDBLEN_12				12
76*80c94ecdSKeith M Wesolowski #define	CPQARY3_CDBLEN_16				16
77*80c94ecdSKeith M Wesolowski 
78*80c94ecdSKeith M Wesolowski /*
79*80c94ecdSKeith M Wesolowski  * possible values to fill in the cmdpvt_flag member
80*80c94ecdSKeith M Wesolowski  * in the cpqary3_cmdpvt_t structure
81*80c94ecdSKeith M Wesolowski  */
82*80c94ecdSKeith M Wesolowski #define	CPQARY3_TIMEOUT			1
83*80c94ecdSKeith M Wesolowski #define	CPQARY3_CV_TIMEOUT		2
84*80c94ecdSKeith M Wesolowski #define	CPQARY3_RESET			4
85*80c94ecdSKeith M Wesolowski #define	CPQARY3_SYNC_SUBMITTED		8
86*80c94ecdSKeith M Wesolowski #define	CPQARY3_SYNC_TIMEOUT		16
87*80c94ecdSKeith M Wesolowski 
88*80c94ecdSKeith M Wesolowski #define	CPQARY3_INTR_ENABLE 		1
89*80c94ecdSKeith M Wesolowski #define	CPQARY3_INTR_DISABLE 		2
90*80c94ecdSKeith M Wesolowski 
91*80c94ecdSKeith M Wesolowski #define	CPQARY3_LOCKUP_INTR_ENABLE 	1
92*80c94ecdSKeith M Wesolowski #define	CPQARY3_LOCKUP_INTR_DISABLE 	2
93*80c94ecdSKeith M Wesolowski 
94*80c94ecdSKeith M Wesolowski #define	CPQARY3_COALESCE_DELAY		0x0
95*80c94ecdSKeith M Wesolowski #define	CPQARY3_COALESCE_COUNT		0x00000001l
96*80c94ecdSKeith M Wesolowski 
97*80c94ecdSKeith M Wesolowski #define	CPQARY3_NO_MUTEX 		0
98*80c94ecdSKeith M Wesolowski #define	CPQARY3_HOLD_SW_MUTEX		1
99*80c94ecdSKeith M Wesolowski 
100*80c94ecdSKeith M Wesolowski /* Completed With NO Error */
101*80c94ecdSKeith M Wesolowski #define	CPQARY3_OSCMD_SUCCESS		0x0
102*80c94ecdSKeith M Wesolowski #define	CPQARY3_SELFCMD_SUCCESS		0x2
103*80c94ecdSKeith M Wesolowski #define	CPQARY3_NOECMD_SUCCESS		0x4
104*80c94ecdSKeith M Wesolowski #define	CPQARY3_SYNCCMD_SUCCESS		0x6
105*80c94ecdSKeith M Wesolowski 
106*80c94ecdSKeith M Wesolowski /* Completed With ERROR */
107*80c94ecdSKeith M Wesolowski #define	CPQARY3_OSCMD_FAILURE		0x1
108*80c94ecdSKeith M Wesolowski #define	CPQARY3_SELFCMD_FAILURE		0x3
109*80c94ecdSKeith M Wesolowski #define	CPQARY3_NOECMD_FAILURE		0x5
110*80c94ecdSKeith M Wesolowski #define	CPQARY3_SYNCCMD_FAILURE		0x7
111*80c94ecdSKeith M Wesolowski 
112*80c94ecdSKeith M Wesolowski /* Fatal SCSI Status */
113*80c94ecdSKeith M Wesolowski #define	SCSI_CHECK_CONDITION			0x2
114*80c94ecdSKeith M Wesolowski #define	SCSI_COMMAND_TERMINATED			0x22
115*80c94ecdSKeith M Wesolowski 
116*80c94ecdSKeith M Wesolowski #pragma pack(1)
117*80c94ecdSKeith M Wesolowski 
118*80c94ecdSKeith M Wesolowski typedef struct flushcache {
119*80c94ecdSKeith M Wesolowski 	uint16_t	disable_flag;
120*80c94ecdSKeith M Wesolowski 	uint8_t		reserved[510];
121*80c94ecdSKeith M Wesolowski } flushcache_buf_t;
122*80c94ecdSKeith M Wesolowski 
123*80c94ecdSKeith M Wesolowski typedef struct each_logical_lun_data {
124*80c94ecdSKeith M Wesolowski 	uint32_t	logical_id:30;
125*80c94ecdSKeith M Wesolowski 	uint32_t	mode:2;
126*80c94ecdSKeith M Wesolowski 	uint8_t		reserved[4];
127*80c94ecdSKeith M Wesolowski } each_ll_data_t;
128*80c94ecdSKeith M Wesolowski 
129*80c94ecdSKeith M Wesolowski typedef struct rll_data {
130*80c94ecdSKeith M Wesolowski 	uint8_t			lunlist_byte3;
131*80c94ecdSKeith M Wesolowski 	uint8_t			lunlist_byte2;
132*80c94ecdSKeith M Wesolowski 	uint8_t			lunlist_byte1;
133*80c94ecdSKeith M Wesolowski 	uint8_t			lunlist_byte0;
134*80c94ecdSKeith M Wesolowski 	uint32_t		reserved;
135*80c94ecdSKeith M Wesolowski 	each_ll_data_t	ll_data[MAX_LOGDRV];
136*80c94ecdSKeith M Wesolowski } rll_data_t;
137*80c94ecdSKeith M Wesolowski 
138*80c94ecdSKeith M Wesolowski typedef struct each_physical_lun_data {
139*80c94ecdSKeith M Wesolowski 	uint32_t	    DevID;
140*80c94ecdSKeith M Wesolowski 	uint32_t	    SecLevel;
141*80c94ecdSKeith M Wesolowski } each_pl_data_t;
142*80c94ecdSKeith M Wesolowski 
143*80c94ecdSKeith M Wesolowski typedef struct rpl_data {
144*80c94ecdSKeith M Wesolowski 	uint8_t			lunlist_byte3;
145*80c94ecdSKeith M Wesolowski 	uint8_t			lunlist_byte2;
146*80c94ecdSKeith M Wesolowski 	uint8_t			lunlist_byte1;
147*80c94ecdSKeith M Wesolowski 	uint8_t			lunlist_byte0;
148*80c94ecdSKeith M Wesolowski 	uint32_t		reserved;
149*80c94ecdSKeith M Wesolowski 	PhysDevAddr_t	pl_data[CPQARY3_MAX_TGT];
150*80c94ecdSKeith M Wesolowski } rpl_data_t;
151*80c94ecdSKeith M Wesolowski 
152*80c94ecdSKeith M Wesolowski 
153*80c94ecdSKeith M Wesolowski /*
154*80c94ecdSKeith M Wesolowski  * Format of the data returned for the IDENTIFY LOGICAL DRIVE Command
155*80c94ecdSKeith M Wesolowski  */
156*80c94ecdSKeith M Wesolowski 
157*80c94ecdSKeith M Wesolowski typedef struct Identify_Logical_Drive {
158*80c94ecdSKeith M Wesolowski 	uint16_t	block_size_in_bytes;
159*80c94ecdSKeith M Wesolowski 	uint32_t	blocks_available;
160*80c94ecdSKeith M Wesolowski 	uint16_t	cylinders;
161*80c94ecdSKeith M Wesolowski 	uint8_t		heads;
162*80c94ecdSKeith M Wesolowski 	uint8_t		general[11];
163*80c94ecdSKeith M Wesolowski 	uint8_t		sectors;
164*80c94ecdSKeith M Wesolowski 	uint8_t		checksum;
165*80c94ecdSKeith M Wesolowski 	uint8_t		fault_tolerance;
166*80c94ecdSKeith M Wesolowski 	uint8_t		reserved;
167*80c94ecdSKeith M Wesolowski 	uint8_t		bios_disable_flag;
168*80c94ecdSKeith M Wesolowski 	uint8_t		reserved1;
169*80c94ecdSKeith M Wesolowski 	uint32_t	logical_drive_identifier;
170*80c94ecdSKeith M Wesolowski 	uint8_t		logical_drive_label[64];
171*80c94ecdSKeith M Wesolowski 	uint8_t		reserved3[418];
172*80c94ecdSKeith M Wesolowski } IdLogDrive;
173*80c94ecdSKeith M Wesolowski 
174*80c94ecdSKeith M Wesolowski /* FORMAT */
175*80c94ecdSKeith M Wesolowski typedef struct Identify_Ld_Status {
176*80c94ecdSKeith M Wesolowski 	uint8_t		status;			/* Logical Drive Status */
177*80c94ecdSKeith M Wesolowski 	uint32_t	failure_map;		/* Drive Failure Map */
178*80c94ecdSKeith M Wesolowski 	uint16_t	read_error_count[32];	/* read error count */
179*80c94ecdSKeith M Wesolowski 	uint16_t	write_error_count[32];	/* write error count */
180*80c94ecdSKeith M Wesolowski 	uint8_t		drive_error_data[256];	/* drive error data */
181*80c94ecdSKeith M Wesolowski 	uint8_t		drq_time_out_count[32];	/* drq timeout count */
182*80c94ecdSKeith M Wesolowski 	uint32_t	blocks_left_to_recover;	/* blocks yet to recover */
183*80c94ecdSKeith M Wesolowski 	uint8_t		drive_recovering;	/* drive recovering */
184*80c94ecdSKeith M Wesolowski 	uint16_t	remap_count[32];	/* remap count */
185*80c94ecdSKeith M Wesolowski 	uint32_t	replacement_drive_map;	/* replacement drive map */
186*80c94ecdSKeith M Wesolowski 	uint32_t	active_spare_map;	/* active spare map */
187*80c94ecdSKeith M Wesolowski 	uint8_t		spare_status;		/* spare status */
188*80c94ecdSKeith M Wesolowski 	uint8_t		spare_to_replace_map[32];
189*80c94ecdSKeith M Wesolowski 	uint32_t	replace_ok_map;		/* Marked ok but no rebuild */
190*80c94ecdSKeith M Wesolowski 	uint8_t		media_exchanged;	/* Media exchanged (see 0xE0) */
191*80c94ecdSKeith M Wesolowski 	uint8_t		cache_failure;		/* volume failed cache fail */
192*80c94ecdSKeith M Wesolowski 	uint8_t		expand_failure;		/* volume failed for failure */
193*80c94ecdSKeith M Wesolowski 	uint8_t		unit_flags;		/* SMART-2 only */
194*80c94ecdSKeith M Wesolowski 
195*80c94ecdSKeith M Wesolowski 	/*
196*80c94ecdSKeith M Wesolowski 	 * The following fields are for firmware supporting > 7 drives per
197*80c94ecdSKeith M Wesolowski 	 * SCSI bus. The "Drives Per SCSI Bus" indicates how many bits /
198*80c94ecdSKeith M Wesolowski 	 * words (in case of remap count) correspond to each drive.
199*80c94ecdSKeith M Wesolowski 	 */
200*80c94ecdSKeith M Wesolowski 	uint16_t	big_failure_map[8];	/* Big Drive Failure Map */
201*80c94ecdSKeith M Wesolowski 	uint16_t	big_remap_cnt[128];	/* Big Drive Remap  Count */
202*80c94ecdSKeith M Wesolowski 	uint16_t	big_replace_map[8];	/* Big Replacement Drive Map */
203*80c94ecdSKeith M Wesolowski 	uint16_t	big_spare_map[8];	/* Big spare drive map */
204*80c94ecdSKeith M Wesolowski 	uint8_t		big_spare_replace_map[128]; /* Big spare replace map */
205*80c94ecdSKeith M Wesolowski 	uint16_t	big_replace_ok_map[8];	/* Big replaced marked OK map */
206*80c94ecdSKeith M Wesolowski 	uint8_t		big_drive_rebuild;	/* Drive Rebuilding - Drive # */
207*80c94ecdSKeith M Wesolowski 	uint8_t		reserved[36];
208*80c94ecdSKeith M Wesolowski } SenseLdStatus;
209*80c94ecdSKeith M Wesolowski /* FORMAT */
210*80c94ecdSKeith M Wesolowski 
211*80c94ecdSKeith M Wesolowski /*
212*80c94ecdSKeith M Wesolowski  * SCSI Command Opcodes
213*80c94ecdSKeith M Wesolowski  */
214*80c94ecdSKeith M Wesolowski #define	SCSI_READ_6		0x08	/* READ  - 6  byte command */
215*80c94ecdSKeith M Wesolowski #define	SCSI_READ_10		0x28	/* READ  - 10 byte command */
216*80c94ecdSKeith M Wesolowski #define	SCSI_READ_12		0xA8	/* READ  - 12 byte command */
217*80c94ecdSKeith M Wesolowski #define	SCSI_WRITE_6		0x0A	/* WRITE - 6  byte command */
218*80c94ecdSKeith M Wesolowski #define	SCSI_WRITE_10		0x2A	/* WRITE - 10 byte command */
219*80c94ecdSKeith M Wesolowski #define	SCSI_WRITE_12		0xAA	/* WRITE - 12 byte command */
220*80c94ecdSKeith M Wesolowski 
221*80c94ecdSKeith M Wesolowski /*
222*80c94ecdSKeith M Wesolowski  * SCSI Opcodes Not supported by FW
223*80c94ecdSKeith M Wesolowski  *
224*80c94ecdSKeith M Wesolowski  */
225*80c94ecdSKeith M Wesolowski #define	SCSI_LOG_SENSE			0x4D	/* LOG SENSE */
226*80c94ecdSKeith M Wesolowski #define	SCSI_MODE_SELECT		0x15	/* LOG SENSE */
227*80c94ecdSKeith M Wesolowski #define	SCSI_PERSISTENT_RESERVE_IN	0x5E	/* PERSISTENT RESERVE IN */
228*80c94ecdSKeith M Wesolowski 
229*80c94ecdSKeith M Wesolowski #pragma pack()
230*80c94ecdSKeith M Wesolowski 
231*80c94ecdSKeith M Wesolowski #ifdef	__cplusplus
232*80c94ecdSKeith M Wesolowski }
233*80c94ecdSKeith M Wesolowski #endif
234*80c94ecdSKeith M Wesolowski 
235*80c94ecdSKeith M Wesolowski #endif	/* _CPQARY3_SCSI_H */
236