Print this page
NEX-7503 backport illumos #7307
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Steve Peng <steve.peng@nexenta.com>
NEX-7048 COMSTAR MODE_SENSE support is broken
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Steve Peng <steve.peng@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/scsi/generic/mode.h
+++ new/usr/src/uts/common/sys/scsi/generic/mode.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 * Copyright 2017 Nexenta Systems, Inc.
26 26 */
27 27
28 28 #ifndef _SYS_SCSI_GENERIC_MODE_H
29 29 #define _SYS_SCSI_GENERIC_MODE_H
30 30
31 31 #ifdef __cplusplus
32 32 extern "C" {
33 33 #endif
34 34
35 35 /*
36 36 *
37 37 * Defines and Structures for SCSI Mode Sense/Select data - generic
38 38 *
39 39 */
40 40
41 41 /*
42 42 * Structures and defines common for all device types
43 43 */
44 44
45 45 /*
46 46 * Mode Sense/Select Header - Group 0 (6-byte).
47 47 *
48 48 * Mode Sense/Select data consists of a header, followed by zero or more
49 49 * block descriptors, followed by zero or more mode pages.
50 50 *
51 51 */
52 52
53 53 struct mode_header {
54 54 uchar_t length; /* number of bytes following */
55 55 uchar_t medium_type; /* device specific */
56 56 uchar_t device_specific; /* device specific parameters */
57 57 uchar_t bdesc_length; /* length of block descriptor(s), if any */
58 58 };
59 59
60 60 #define MODE_HEADER_LENGTH (sizeof (struct mode_header))
61 61
62 62 /*
63 63 * Mode Sense/Select Header - Group 1 (10-bytes)
64 64 */
65 65
66 66 struct mode_header_g1 {
67 67 ushort_t length; /* number of bytes following */
68 68 uchar_t medium_type; /* device specific */
69 69 uchar_t device_specific; /* device specific parameters */
70 70 uchar_t reserved[2]; /* device specific parameters */
71 71 ushort_t bdesc_length; /* len of block descriptor(s), if any */
72 72 };
73 73
74 74 #define MODE_HEADER_LENGTH_G1 (sizeof (struct mode_header_g1))
75 75
76 76 /*
77 77 * Block Descriptor. Zero, one, or more may normally follow the mode header.
78 78 *
79 79 * The density code is device specific.
80 80 *
81 81 * The 24-bit value described by blks_{hi, mid, lo} describes the number of
82 82 * blocks which this block descriptor applies to. A value of zero means
83 83 * 'the rest of the blocks on the device'.
84 84 *
85 85 * The 24-bit value described by blksize_{hi, mid, lo} describes the blocksize
86 86 * (in bytes) applicable for this block descriptor. For Sequential Access
87 87 * devices, if this value is zero, the block size will be derived from
88 88 * the transfer length in I/O operations.
89 89 *
90 90 */
91 91
92 92 struct block_descriptor {
93 93 uchar_t density_code; /* device specific */
94 94 uchar_t blks_hi; /* hi */
95 95 uchar_t blks_mid; /* mid */
96 96 uchar_t blks_lo; /* low */
97 97 uchar_t reserved; /* reserved */
98 98 uchar_t blksize_hi; /* hi */
99 99 uchar_t blksize_mid; /* mid */
100 100 uchar_t blksize_lo; /* low */
101 101 };
102 102
103 103 #define MODE_BLK_DESC_LENGTH (sizeof (struct block_descriptor))
104 104 #define MODE_PARAM_LENGTH (MODE_HEADER_LENGTH + MODE_BLK_DESC_LENGTH)
105 105
106 106 /*
107 107 * Define a macro to take an address of a mode header to the address
108 108 * of the nth (0..n) block_descriptor, or NULL if there either aren't any
109 109 * block descriptors or the nth block descriptor doesn't exist.
110 110 */
111 111
112 112 #define BLOCK_DESCRIPTOR_ADDR(mhdr, bdnum) \
113 113 ((mhdr)->bdesc_length && ((unsigned)(bdnum)) < \
114 114 ((mhdr)->bdesc_length/(sizeof (struct block_descriptor)))) ? \
115 115 ((struct block_descriptor *)(((ulong_t)(mhdr))+MODE_HEADER_LENGTH+ \
116 116 ((bdnum) * sizeof (struct block_descriptor)))) : \
117 117 ((struct block_descriptor *)0)
118 118
119 119 /*
120 120 * Mode page header. Zero or more Mode Pages follow either the block
121 121 * descriptors (if any), or the Mode Header.
122 122 *
123 123 * The 'ps' bit must be zero for mode select operations.
124 124 *
125 125 */
126 126
127 127 struct mode_page {
128 128 #if defined(_BIT_FIELDS_LTOH)
129 129 uchar_t code :6, /* page code number */
130 130 :1, /* reserved */
131 131 ps :1; /* 'Parameter Saveable' bit */
132 132 #elif defined(_BIT_FIELDS_HTOL)
133 133 uchar_t ps :1, /* 'Parameter Saveable' bit */
134 134 :1, /* reserved */
135 135 code :6; /* page code number */
136 136 #else
137 137 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
138 138 #endif /* _BIT_FIELDS_LTOH */
139 139 uchar_t length; /* length of bytes to follow */
140 140 /*
141 141 * Mode Page specific data follows right after this...
142 142 */
143 143 };
144 144
145 145 /*
146 146 * Define a macro to retrieve the first mode page. Could be more
147 147 * general (for multiple mode pages).
148 148 */
149 149
150 150 #define MODE_PAGE_ADDR(mhdr, type) \
151 151 ((type *)(((ulong_t)(mhdr))+MODE_HEADER_LENGTH+(mhdr)->bdesc_length))
152 152
153 153 /*
154 154 * Page Control field (bits 7 and 6) follows the following specification:
155 155 *
156 156 * Value Meaning
157 157 * ----------------------------------------------------------------------
158 158 * 00b current values
159 159 * 01b changeable values
160 160 * 10b default values
161 161 * 11b saved values
162 162 */
163 163
164 164 #define MODEPAGE_CURRENT 0x00
165 165 #define MODEPAGE_CHANGEABLE 0x40
166 166 #define MODEPAGE_DEFAULT 0x80
167 167 #define MODEPAGE_SAVED 0xC0
168 168
169 169 /*
170 170 * Page codes follow the following specification:
171 171 *
172 172 * Code Value(s) What
173 173 * ----------------------------------------------------------------------
174 174 * 0x00 Vendor Unique (does not require page format)
175 175 *
176 176 * 0x02, 0x09, 0x0A pages for all Device Types
177 177 * 0x1A, 0x1C
178 178 *
179 179 * 0x01, 0x03-0x08, pages for specific Device Type
180 180 * 0x0B-0x19, 0x1B,
181 181 * 0x1D-0x1F
182 182 *
183 183 * 0x20-0x3E Vendor Unique (requires page format)
|
↓ open down ↓ |
183 lines elided |
↑ open up ↑ |
184 184 *
185 185 * 0x3F Return all pages (valid for Mode Sense only)
186 186 *
187 187 */
188 188
189 189 /*
190 190 * Page codes and page length values (all device types)
191 191 */
192 192
193 193 #define MODEPAGE_DISCO_RECO 0x02
194 +#define MODEPAGE_FORMAT 0x03
195 +#define MODEPAGE_GEOMETRY 0x04
194 196 #define MODEPAGE_CACHING 0x08
195 197 #define MODEPAGE_PDEVICE 0x09
196 198 #define MODEPAGE_CTRL_MODE 0x0A
197 199 #define MODEPAGE_POWER_COND 0x1A
198 200 #define MODEPAGE_INFO_EXCPT 0x1C
199 201
200 202 #define MODEPAGE_ALLPAGES 0x3F
201 203
202 204 /*
203 205 * Mode Select/Sense page structures (for all device types)
204 206 */
205 207
206 208 /*
207 209 * Disconnect/Reconnect Page
208 210 */
209 211
210 212 struct mode_disco_reco {
211 213 struct mode_page mode_page; /* common mode page header */
212 214 uchar_t buffer_full_ratio; /* write, how full before reconnect? */
213 215 uchar_t buffer_empty_ratio; /* read, how full before reconnect? */
214 216 ushort_t bus_inactivity_limit; /* how much bus quiet time for BSY- */
215 217 ushort_t disconect_time_limit; /* min to remain disconnected */
216 218 ushort_t connect_time_limit; /* min to remain connected */
217 219 ushort_t max_burst_size; /* max data burst size */
218 220 #if defined(_BIT_FIELDS_LTOH)
219 221 uchar_t dtdc : 3, /* data transfer disconenct control */
220 222 dimm : 1, /* disconnect immediate */
221 223 fastat : 1, /* fair for status */
222 224 fawrt : 1, /* fair for write */
223 225 fard : 1, /* fair for read */
224 226 emdp : 1; /* enable modify data pointers */
225 227 #elif defined(_BIT_FIELDS_HTOL)
226 228 uchar_t emdp : 1, /* enable modify data pointers */
227 229 fard : 1, /* fair for read */
228 230 fawrt : 1, /* fair for write */
229 231 fastat : 1, /* fair for status */
230 232 dimm : 1, /* disconnect immediate */
231 233 dtdc : 3; /* data transfer disconenct control */
232 234 #else
233 235 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
234 236 #endif /* _BIT_FIELDS_LTOH */
235 237 uchar_t reserved;
236 238 ushort_t first_burst_sz; /* first burst size */
237 239 };
238 240
239 241 #define DTDC_DATADONE 0x01
240 242 /*
241 243 * Target may not disconnect once
242 244 * data transfer is started until
243 245 * all data successfully transferred.
244 246 */
245 247
246 248 #define DTDC_CMDDONE 0x03
247 249 /*
248 250 * Target may not disconnect once
249 251 * data transfer is started until
250 252 * command completed.
251 253 */
252 254 /*
253 255 * Caching Page
254 256 */
255 257
256 258 struct mode_caching {
257 259 struct mode_page mode_page; /* common mode page header */
258 260 #if defined(_BIT_FIELDS_LTOH)
259 261 uchar_t rcd : 1, /* Read Cache Disable */
260 262 mf : 1, /* Multiplication Factor */
261 263 wce : 1, /* Write Cache Enable */
262 264 : 5; /* Reserved */
263 265 uchar_t write_ret_prio : 4, /* Write Retention Priority */
264 266 dmd_rd_ret_prio : 4; /* Demand Read Retention Priority */
265 267 #elif defined(_BIT_FIELDS_HTOL)
266 268 uchar_t : 5, /* Reserved */
267 269 wce : 1, /* Write Cache Enable */
268 270 mf : 1, /* Multiplication Factor */
269 271 rcd : 1; /* Read Cache Disable */
270 272 uchar_t dmd_rd_ret_prio : 4, /* Demand Read Retention Priority */
271 273 write_ret_prio : 4; /* Write Retention Priority */
272 274 #else
273 275 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
274 276 #endif /* _BIT_FIELDS_LTOH */
275 277 ushort_t pf_dsbl_trans_len; /* Disable prefetch transfer length */
276 278 ushort_t min_prefetch; /* Minimum Prefetch */
277 279 ushort_t max_prefetch; /* Maximum Prefetch */
278 280 ushort_t max_prefetch_ceiling; /* Maximum Prefetch Ceiling */
279 281 };
280 282
281 283 /*
282 284 * Peripheral Device Page
283 285 */
284 286
285 287 struct mode_pdevice {
286 288 struct mode_page mode_page; /* common mode page header */
287 289 ushort_t if_ident; /* interface identifier */
288 290 uchar_t reserved[4]; /* reserved */
289 291 uchar_t vendor_uniqe[1]; /* vendor unique data */
290 292 };
291 293
292 294 #define PDEV_SCSI 0x0000 /* scsi interface */
293 295 #define PDEV_SMD 0x0001 /* SMD interface */
294 296 #define PDEV_ESDI 0x0002 /* ESDI interface */
295 297 #define PDEV_IPI2 0x0003 /* IPI-2 interface */
296 298 #define PDEV_IPI3 0x0004 /* IPI-3 interface */
297 299
298 300 /*
299 301 * Control Mode Page
300 302 *
301 303 * Note: This structure is incompatible with previous SCSI
302 304 * implementations. See <scsi/impl/mode.h> for an
303 305 * alternative form of this structure. They can be
304 306 * distinguished by the length of data returned
305 307 * from a MODE SENSE command.
306 308 */
307 309
308 310 #define PAGELENGTH_MODE_CONTROL_SCSI3 0x0A
309 311
310 312 struct mode_control_scsi3 {
311 313 struct mode_page mode_page; /* common mode page header */
312 314 #if defined(_BIT_FIELDS_LTOH)
313 315 uchar_t rlec : 1, /* Report Log Exception bit */
314 316 gltsd : 1, /* global logging target save disable */
315 317 d_sense : 1, /* Use descriptor sense data (SPC-3) */
316 318 : 5;
317 319 uchar_t qdisable: 1, /* Queue disable */
318 320 que_err : 1, /* Queue error */
319 321 : 2,
320 322 que_mod : 4; /* Queue algorithm modifier */
321 323 uchar_t eanp : 1, /* Enable AEN permission */
322 324 uaaenp : 1, /* Unit attention AEN permission */
323 325 raenp : 1, /* Ready AEN permission */
324 326 : 1,
325 327 bybths : 1, /* By both RESET signal */
326 328 byprtm : 1, /* By port message */
327 329 rac : 1, /* report a check */
328 330 eeca : 1; /* enable extended contingent */
329 331 /* allegiance (only pre-SCSI-3) */
330 332 #elif defined(_BIT_FIELDS_HTOL)
331 333 uchar_t : 5,
332 334 d_sense : 1, /* Use descriptor sense data (SPC-3) */
333 335 gltsd : 1, /* global logging target save disable */
334 336 rlec : 1; /* Report Log Exception bit */
335 337 uchar_t que_mod : 4, /* Queue algorithm modifier */
336 338 : 2,
337 339 que_err : 1, /* Queue error */
338 340 qdisable: 1; /* Queue disable */
339 341 uchar_t eeca : 1, /* enable extended contingent */
340 342 /* allegiance (only pre-SCSI-3) */
341 343 rac : 1, /* report a check */
342 344 byprtm : 1, /* By port message */
343 345 bybths : 1, /* By both RESET signal */
344 346 : 1,
345 347 raenp : 1, /* Ready AEN permission */
346 348 uaaenp : 1, /* Unit attention AEN permission */
347 349 eanp : 1; /* Enable AEN permission */
348 350 #else
349 351 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
350 352 #endif /* _BIT_FIELDS_LTOH */
351 353 uchar_t reserved;
352 354 ushort_t ready_aen_holdoff; /* Ready AEN holdoff period */
353 355 ushort_t busy_timeout; /* Busy timeout period */
354 356 uchar_t reserved_2[2];
355 357 };
356 358
357 359 #ifdef __lock_lint
358 360 _NOTE(SCHEME_PROTECTS_DATA("Unshared SCSI payload", \
359 361 mode_control_scsi3))
360 362 #endif
361 363
362 364 #define CTRL_QMOD_RESTRICT 0x0
363 365 #define CTRL_QMOD_UNRESTRICT 0x1
364 366
365 367 /*
366 368 * Informational Exceptions Control Mode Page
367 369 */
368 370
369 371 #define PAGELENGTH_INFO_EXCPT 0x0A
370 372
371 373 struct mode_info_excpt_page {
372 374 struct mode_page mode_page; /* common mode page header */
373 375 #if defined(_BIT_FIELDS_LTOH)
374 376 uchar_t log_err : 1; /* log errors */
375 377 uchar_t : 1; /* reserved */
376 378 uchar_t test : 1; /* create test failure */
377 379 uchar_t dexcpt : 1; /* disable exception */
378 380 uchar_t ewasc : 1; /* enable warning */
379 381 uchar_t ebf : 1; /* enable background function */
380 382 uchar_t : 1; /* reserved */
381 383 uchar_t perf : 1; /* performance */
382 384 uchar_t mrie : 4; /* method of reporting info. excpts. */
383 385 uchar_t : 4; /* reserved */
384 386 #elif defined(_BIT_FIELDS_HTOL)
385 387 uchar_t perf : 1; /* performance */
386 388 uchar_t : 1; /* reserved */
387 389 uchar_t ebf : 1; /* enable background function */
388 390 uchar_t ewasc : 1; /* enable warning */
389 391 uchar_t dexcpt : 1; /* disable exception */
390 392 uchar_t test : 1; /* create test failure */
391 393 uchar_t : 1; /* reserved */
392 394 uchar_t log_err : 1; /* log errors */
393 395 uchar_t : 4; /* reserved */
394 396 uchar_t mrie : 4; /* method of reporting info. excpts. */
395 397 #else
396 398 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
397 399 #endif
398 400 uchar_t interval_timer[4]; /* interval timer */
399 401 uchar_t report_count[4]; /* report count */
400 402 };
401 403
402 404 #define MRIE_NO_REPORT 0x0
403 405 #define MRIE_ASYNCH 0x1
404 406 #define MRIE_UNIT_ATTN 0x2
405 407 #define MRIE_COND_RECVD_ERR 0x3
406 408 #define MRIE_UNCOND_RECVD_ERR 0x4
407 409 #define MRIE_NO_SENSE 0x5
408 410 #define MRIE_ONLY_ON_REQUEST 0x6
409 411
410 412 struct mode_info_power_cond {
411 413 struct mode_page mode_page; /* common mode page header */
412 414 uchar_t reserved;
413 415 #if defined(_BIT_FIELDS_LTOH)
414 416 uchar_t standby :1, /* standby bit */
415 417 idle :1, /* idle bit */
416 418 :6; /* reserved */
417 419 #elif defined(_BIT_FIELDS_HTOL)
418 420 uchar_t :6, /* reserved */
419 421 idle :1, /* idle bit */
420 422 standby :1; /* standby bit */
421 423 #else
422 424 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
423 425 #endif
424 426 uchar_t idle_cond_timer_high;
425 427 uchar_t idle_cond_timer_low;
426 428 uchar_t standby_cond_timer[4];
427 429 };
428 430
429 431 struct parameter_control {
430 432 #if defined(_BIT_FIELDS_LTOH)
431 433 uchar_t fmt_link:2, /* format and link bit */
432 434 tmc :2, /* tmc bit */
433 435 etc :1, /* etc bit */
434 436 tsd :1, /* tsd bit */
435 437 reserv :1, /* obsolete */
436 438 du :1; /* du bit */
437 439 #elif defined(_BIT_FIELDS_HTOL)
438 440 uchar_t du :1, /* du bit */
439 441 reserv :1, /* obsolete */
440 442 tsd :1, /* tsd bit */
441 443 etc :1, /* etc bit */
442 444 tmc :2, /* tmc bit */
443 445 fmt_link:2; /* format and link bit */
444 446 #else
445 447 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
446 448 #endif
447 449 };
448 450
449 451 struct start_stop_cycle_counter_log {
450 452 #if defined(_BIT_FIELDS_LTOH)
451 453 uchar_t code :6, /* page code bit */
452 454 spf :1, /* spf bit */
453 455 ds :1; /* ds bit */
454 456 #elif defined(_BIT_FIELDS_HTOL)
455 457 uchar_t ds :1, /* ds bit */
456 458 spf :1, /* spf bit */
457 459 code :6; /* page code bit */
458 460 #else
459 461 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
460 462 #endif
461 463 uchar_t sub_page_code;
462 464 uchar_t page_len_high;
463 465 uchar_t page_len_low;
464 466
465 467 uchar_t manufactor_date_high;
466 468 uchar_t manufactor_date_low;
467 469 struct parameter_control param_1;
468 470 uchar_t param_len_1;
469 471 uchar_t year_manu[4];
470 472 uchar_t week_manu[2];
471 473
472 474 uchar_t account_date_high;
473 475 uchar_t account_date_low;
474 476 struct parameter_control param_2;
475 477 uchar_t param_len_2;
476 478 uchar_t year_account[4];
477 479 uchar_t week_account[2];
478 480
479 481 uchar_t lifetime_code_high;
480 482 uchar_t lifetime_code_low;
481 483 struct parameter_control param_3;
482 484 uchar_t param_len_3;
483 485 uchar_t cycle_lifetime[4];
484 486
485 487 uchar_t cycle_code_high;
486 488 uchar_t cycle_code_low;
487 489 struct parameter_control param_4;
488 490 uchar_t param_len_4;
489 491 uchar_t cycle_accumulated[4];
490 492 };
491 493
492 494
493 495 #ifdef __cplusplus
494 496 }
495 497 #endif
496 498
497 499 /*
498 500 * Include known generic device specific mode definitions and structures
499 501 */
500 502
501 503 #include <sys/scsi/generic/dad_mode.h>
502 504
503 505 /*
504 506 * Include implementation specific mode information
505 507 */
506 508
507 509 #include <sys/scsi/impl/mode.h>
508 510
509 511 #endif /* _SYS_SCSI_GENERIC_MODE_H */
|
↓ open down ↓ |
306 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX