xref: /titanic_41/usr/src/lib/storage/libg_fc/common/hdrs/g_scsi.h (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * local SCSI definitions
28  */
29 
30 #ifndef	_G_SCSI_H
31 #define	_G_SCSI_H
32 
33 
34 /*
35  * Include any headers you depend on.
36  */
37 
38 /*
39  * I18N message number ranges
40  *  This file: 18500 - 18999
41  *  Shared common messages: 1 - 1999
42  */
43 
44 #ifdef	__cplusplus
45 extern "C" {
46 #endif
47 
48 #define	MODEPAGE_GEOMETRY	0x04
49 
50 /* NOTE: These command op codes are not defined in commands.h */
51 #define		SCMD_SYNC_CACHE			0x35
52 #define		SCMD_LOG_SENSE			0x4d
53 #define		SCMD_PERS_RESERV_IN		0x5e
54 #define		SCMD_PERS_RESERV_OUT		0x5f
55 
56 #define	MAX_MODE_SENSE_LEN		0xffff
57 
58 /*
59  *  Structure for MODE SELECT/SENSE 10 byte page header
60  *
61  */
62 typedef struct mode_header_10_struct {
63 	ushort_t length;
64 	uchar_t medium_type; /* device specific */
65 	uchar_t device_specific; /* device specfic parameters */
66 	ushort_t	rsvdl;	/* reserved */
67 	ushort_t bdesc_length;	/* length of block descriptor(s), if any */
68 } Mode_header_10;
69 
70 typedef	struct	mode_page_04_struct {
71 	struct	mode_page mode_page;	/* common mode page header */
72 	uchar_t	num_cylinders_hi;
73 	uchar_t	num_cylinders_mid;
74 	uchar_t	num_cylinders_lo;
75 	uchar_t	num_heads;
76 	uchar_t	write_precomp_hi;
77 	uchar_t	write_precomp_mid;
78 	uchar_t	write_precomp_lo;
79 	uchar_t	reduced_write_i_hi;
80 	uchar_t	reduced_write_i_mid;
81 	uchar_t	reduced_write_i_lo;
82 	ushort_t	step_rate;
83 	uchar_t	landing_zone_hi;
84 	uchar_t	landing_zone_mid;
85 	uchar_t	landing_zone_lo;
86 #if defined(_BIT_FIELDS_LTOH)
87 	uchar_t	rpl	: 2,	/* RPL */
88 			: 6;
89 #elif defined(_BIT_FIELDS_HTOL)
90 	uchar_t		: 6,
91 		rpl	: 2;    /* disable correction */
92 #else
93 #error  One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
94 #endif  /* _BIT_FIELDS_LTOH */
95 	uchar_t	rot_offset;
96 	uchar_t	: 8;	/* reserved */
97 	ushort_t	rpm;
98 	uchar_t	: 8;	/* reserved */
99 	uchar_t	: 8;	/* reserved */
100 } Mp_04;
101 
102 
103 typedef	struct	mode_page_01_struct {
104 	struct	mode_page mode_page;	/* common mode page header */
105 #if defined(_BIT_FIELDS_LTOH)
106 	uchar_t	dcr	: 1,	/* disable correction */
107 		dte	: 1,	/* disable transfer on error */
108 		per	: 1,	/* post error */
109 		eec	: 1,	/* enable early correction */
110 		rc	: 1,	/* read continuous */
111 		tb	: 1,	/* transfer block */
112 		arre	: 1,	/* auto read realloc enabled */
113 		awre	: 1;	/* auto write realloc enabled */
114 #elif defined(_BIT_FIELDS_HTOL)
115 	uchar_t	awre	: 1,	/* auto write realloc enabled */
116 		arre	: 1,	/* auto read realloc enabled */
117 		tb	: 1,	/* transfer block */
118 		rc	: 1,	/* read continuous */
119 		eec	: 1,	/* enable early correction */
120 		per	: 1,	/* post error */
121 		dte	: 1,	/* disable transfer on error */
122 		dcr	: 1;    /* disable correction */
123 #else
124 #error  One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
125 #endif  /* _BIT_FIELDS_LTOH */
126 	uchar_t	read_retry_count;
127 	uchar_t	correction_span;
128 	uchar_t	head_offset_count;
129 	uchar_t	strobe_offset_count;
130 	uchar_t			: 8;	/* reserved */
131 	uchar_t	write_retry_count;
132 	uchar_t			: 8;	/* reserved */
133 	ushort_t	recovery_time_limit;
134 } Mp_01;
135 
136 /*
137  * I define here for backward compatability
138  * with 2.5.1
139  * For 2.6 & above you can use "mode_caching"
140  */
141 struct my_mode_caching {
142 	struct	mode_page mode_page;	/* common mode page header */
143 #if defined(_BIT_FIELDS_LTOH)
144 	uchar_t	rcd		: 1,	/* Read Cache Disable */
145 		mf		: 1,	/* Multiplication Factor */
146 		wce		: 1,	/* Write Cache Enable */
147 				: 5;	/* Reserved */
148 	uchar_t	write_ret_prio	: 4,	/* Write Retention Priority */
149 		dmd_rd_ret_prio	: 4;	/* Demand Read Retention Priority */
150 #elif defined(_BIT_FIELDS_HTOL)
151 	uchar_t			: 5,	/* Reserved */
152 		wce		: 1,	/* Write Cache Enable */
153 		mf		: 1,	/* Multiplication Factor */
154 		rcd		: 1;	/* Read Cache Disable */
155 	uchar_t	dmd_rd_ret_prio	: 4,	/* Demand Read Retention Priority */
156 		write_ret_prio	: 4;	/* Write Retention Priority */
157 #else
158 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
159 #endif	/* _BIT_FIELDS_LTOH */
160 	ushort_t	pf_dsbl_trans_len;	/* Disable prefetch Xfer len. */
161 	ushort_t	min_prefetch;	/* Minimum Prefetch */
162 	ushort_t	max_prefetch;	/* Maximum Prefetch */
163 	ushort_t	max_prefetch_ceiling;	/* Maximum Prefetch Ceiling */
164 };
165 
166 /*
167  *              SCSI CDB structures
168  */
169 typedef	struct	my_cdb_g0 {
170 	unsigned	char	cmd;
171 	unsigned	char	lba_msb;
172 	unsigned	char	lba;
173 	unsigned	char	lba_lsb;
174 	unsigned	char	count;
175 	unsigned	char	control;
176 	}my_cdb_g0;
177 
178 typedef	struct {
179 	unsigned	char	cmd;
180 	unsigned	char	byte1;
181 	unsigned	char	byte2;
182 	unsigned	char	byte3;
183 	unsigned	char	byte4;
184 	unsigned	char	byte5;
185 	unsigned	char	byte6;
186 	unsigned	char	byte7;
187 	unsigned	char	byte8;
188 	unsigned	char	byte9;
189 	}my_cdb_g1;
190 
191 typedef struct l_inquiry80_struct {
192 	/*
193 	 * byte 0
194 	 *
195 	 * Bits 7-5 are the Peripheral Device Qualifier
196 	 * Bits 4-0 are the Peripheral Device Type
197 	 *
198 	 */
199 	uchar_t	inq_dtype;
200 	uchar_t	inq_page_code;
201 	uchar_t reserved;		/* reserved */
202 	uchar_t inq_page_len;
203 	uchar_t inq_serial[251];
204 } L_inquiry80;
205 
206 typedef struct l_inquiry00_struct {
207 	uchar_t		qual    :3,
208 			dtype   :5;
209 	uchar_t		page_code;
210 	uchar_t		reserved;
211 	uchar_t		len;
212 	uchar_t		page_list[251];
213 } L_inquiry00;
214 
215 #ifdef	__cplusplus
216 }
217 #endif
218 
219 #endif	/* _G_SCSI_H */
220