scsi.h 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648
  1. /*
  2. * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
  3. * All rights reserved
  4. * www.brocade.com
  5. *
  6. * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License (GPL) Version 2 as
  10. * published by the Free Software Foundation
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. #ifndef __SCSI_H__
  18. #define __SCSI_H__
  19. #include <protocol/types.h>
  20. #pragma pack(1)
  21. /*
  22. * generic SCSI cdb definition
  23. */
  24. #define SCSI_MAX_CDBLEN 16
  25. struct scsi_cdb_s{
  26. u8 scsi_cdb[SCSI_MAX_CDBLEN];
  27. };
  28. /*
  29. * scsi lun serial number definition
  30. */
  31. #define SCSI_LUN_SN_LEN 32
  32. struct scsi_lun_sn_s{
  33. u8 lun_sn[SCSI_LUN_SN_LEN];
  34. };
  35. /*
  36. * SCSI Direct Access Commands
  37. */
  38. enum {
  39. SCSI_OP_TEST_UNIT_READY = 0x00,
  40. SCSI_OP_REQUEST_SENSE = 0x03,
  41. SCSI_OP_FORMAT_UNIT = 0x04,
  42. SCSI_OP_READ6 = 0x08,
  43. SCSI_OP_WRITE6 = 0x0A,
  44. SCSI_OP_WRITE_FILEMARKS = 0x10,
  45. SCSI_OP_INQUIRY = 0x12,
  46. SCSI_OP_MODE_SELECT6 = 0x15,
  47. SCSI_OP_RESERVE6 = 0x16,
  48. SCSI_OP_RELEASE6 = 0x17,
  49. SCSI_OP_MODE_SENSE6 = 0x1A,
  50. SCSI_OP_START_STOP_UNIT = 0x1B,
  51. SCSI_OP_SEND_DIAGNOSTIC = 0x1D,
  52. SCSI_OP_READ_CAPACITY = 0x25,
  53. SCSI_OP_READ10 = 0x28,
  54. SCSI_OP_WRITE10 = 0x2A,
  55. SCSI_OP_VERIFY10 = 0x2F,
  56. SCSI_OP_READ_DEFECT_DATA = 0x37,
  57. SCSI_OP_LOG_SELECT = 0x4C,
  58. SCSI_OP_LOG_SENSE = 0x4D,
  59. SCSI_OP_MODE_SELECT10 = 0x55,
  60. SCSI_OP_RESERVE10 = 0x56,
  61. SCSI_OP_RELEASE10 = 0x57,
  62. SCSI_OP_MODE_SENSE10 = 0x5A,
  63. SCSI_OP_PER_RESERVE_IN = 0x5E,
  64. SCSI_OP_PER_RESERVE_OUR = 0x5E,
  65. SCSI_OP_READ16 = 0x88,
  66. SCSI_OP_WRITE16 = 0x8A,
  67. SCSI_OP_VERIFY16 = 0x8F,
  68. SCSI_OP_READ_CAPACITY16 = 0x9E,
  69. SCSI_OP_REPORT_LUNS = 0xA0,
  70. SCSI_OP_READ12 = 0xA8,
  71. SCSI_OP_WRITE12 = 0xAA,
  72. SCSI_OP_UNDEF = 0xFF,
  73. };
  74. /*
  75. * SCSI START_STOP_UNIT command
  76. */
  77. struct scsi_start_stop_unit_s{
  78. u8 opcode;
  79. #ifdef __BIGENDIAN
  80. u8 lun:3;
  81. u8 reserved1:4;
  82. u8 immed:1;
  83. #else
  84. u8 immed:1;
  85. u8 reserved1:4;
  86. u8 lun:3;
  87. #endif
  88. u8 reserved2;
  89. u8 reserved3;
  90. #ifdef __BIGENDIAN
  91. u8 power_conditions:4;
  92. u8 reserved4:2;
  93. u8 loEj:1;
  94. u8 start:1;
  95. #else
  96. u8 start:1;
  97. u8 loEj:1;
  98. u8 reserved4:2;
  99. u8 power_conditions:4;
  100. #endif
  101. u8 control;
  102. };
  103. /*
  104. * SCSI SEND_DIAGNOSTIC command
  105. */
  106. struct scsi_send_diagnostic_s{
  107. u8 opcode;
  108. #ifdef __BIGENDIAN
  109. u8 self_test_code:3;
  110. u8 pf:1;
  111. u8 reserved1:1;
  112. u8 self_test:1;
  113. u8 dev_offl:1;
  114. u8 unit_offl:1;
  115. #else
  116. u8 unit_offl:1;
  117. u8 dev_offl:1;
  118. u8 self_test:1;
  119. u8 reserved1:1;
  120. u8 pf:1;
  121. u8 self_test_code:3;
  122. #endif
  123. u8 reserved2;
  124. u8 param_list_length[2]; /* MSB first */
  125. u8 control;
  126. };
  127. /*
  128. * SCSI READ10/WRITE10 commands
  129. */
  130. struct scsi_rw10_s{
  131. u8 opcode;
  132. #ifdef __BIGENDIAN
  133. u8 lun:3;
  134. u8 dpo:1; /* Disable Page Out */
  135. u8 fua:1; /* Force Unit Access */
  136. u8 reserved1:2;
  137. u8 rel_adr:1; /* relative address */
  138. #else
  139. u8 rel_adr:1;
  140. u8 reserved1:2;
  141. u8 fua:1;
  142. u8 dpo:1;
  143. u8 lun:3;
  144. #endif
  145. u8 lba0; /* logical block address - MSB */
  146. u8 lba1;
  147. u8 lba2;
  148. u8 lba3; /* LSB */
  149. u8 reserved3;
  150. u8 xfer_length0; /* transfer length in blocks - MSB */
  151. u8 xfer_length1; /* LSB */
  152. u8 control;
  153. };
  154. #define SCSI_CDB10_GET_LBA(cdb) \
  155. (((cdb)->lba0 << 24) | ((cdb)->lba1 << 16) | \
  156. ((cdb)->lba2 << 8) | (cdb)->lba3)
  157. #define SCSI_CDB10_SET_LBA(cdb, lba) { \
  158. (cdb)->lba0 = lba >> 24; \
  159. (cdb)->lba1 = (lba >> 16) & 0xFF; \
  160. (cdb)->lba2 = (lba >> 8) & 0xFF; \
  161. (cdb)->lba3 = lba & 0xFF; \
  162. }
  163. #define SCSI_CDB10_GET_TL(cdb) \
  164. ((cdb)->xfer_length0 << 8 | (cdb)->xfer_length1)
  165. #define SCSI_CDB10_SET_TL(cdb, tl) { \
  166. (cdb)->xfer_length0 = tl >> 8; \
  167. (cdb)->xfer_length1 = tl & 0xFF; \
  168. }
  169. /*
  170. * SCSI READ6/WRITE6 commands
  171. */
  172. struct scsi_rw6_s{
  173. u8 opcode;
  174. #ifdef __BIGENDIAN
  175. u8 lun:3;
  176. u8 lba0:5; /* MSb */
  177. #else
  178. u8 lba0:5; /* MSb */
  179. u8 lun:3;
  180. #endif
  181. u8 lba1;
  182. u8 lba2; /* LSB */
  183. u8 xfer_length;
  184. u8 control;
  185. };
  186. #define SCSI_TAPE_CDB6_GET_TL(cdb) \
  187. (((cdb)->tl0 << 16) | ((cdb)->tl1 << 8) | (cdb)->tl2)
  188. #define SCSI_TAPE_CDB6_SET_TL(cdb, tl) { \
  189. (cdb)->tl0 = tl >> 16; \
  190. (cdb)->tl1 = (tl >> 8) & 0xFF; \
  191. (cdb)->tl2 = tl & 0xFF; \
  192. }
  193. /*
  194. * SCSI sequential (TAPE) wrtie command
  195. */
  196. struct scsi_tape_wr_s{
  197. u8 opcode;
  198. #ifdef __BIGENDIAN
  199. u8 rsvd:7;
  200. u8 fixed:1; /* MSb */
  201. #else
  202. u8 fixed:1; /* MSb */
  203. u8 rsvd:7;
  204. #endif
  205. u8 tl0; /* Msb */
  206. u8 tl1;
  207. u8 tl2; /* Lsb */
  208. u8 control;
  209. };
  210. #define SCSI_CDB6_GET_LBA(cdb) \
  211. (((cdb)->lba0 << 16) | ((cdb)->lba1 << 8) | (cdb)->lba2)
  212. #define SCSI_CDB6_SET_LBA(cdb, lba) { \
  213. (cdb)->lba0 = lba >> 16; \
  214. (cdb)->lba1 = (lba >> 8) & 0xFF; \
  215. (cdb)->lba2 = lba & 0xFF; \
  216. }
  217. #define SCSI_CDB6_GET_TL(cdb) ((cdb)->xfer_length)
  218. #define SCSI_CDB6_SET_TL(cdb, tl) { \
  219. (cdb)->xfer_length = tl; \
  220. }
  221. /*
  222. * SCSI sense data format
  223. */
  224. struct scsi_sense_s{
  225. #ifdef __BIGENDIAN
  226. u8 valid:1;
  227. u8 rsp_code:7;
  228. #else
  229. u8 rsp_code:7;
  230. u8 valid:1;
  231. #endif
  232. u8 seg_num;
  233. #ifdef __BIGENDIAN
  234. u8 file_mark:1;
  235. u8 eom:1; /* end of media */
  236. u8 ili:1; /* incorrect length indicator */
  237. u8 reserved:1;
  238. u8 sense_key:4;
  239. #else
  240. u8 sense_key:4;
  241. u8 reserved:1;
  242. u8 ili:1; /* incorrect length indicator */
  243. u8 eom:1; /* end of media */
  244. u8 file_mark:1;
  245. #endif
  246. u8 information[4]; /* device-type or command specific info
  247. */
  248. u8 add_sense_length;
  249. /* additional sense length */
  250. u8 command_info[4];/* command specific information
  251. */
  252. u8 asc; /* additional sense code */
  253. u8 ascq; /* additional sense code qualifier */
  254. u8 fru_code; /* field replaceable unit code */
  255. #ifdef __BIGENDIAN
  256. u8 sksv:1; /* sense key specific valid */
  257. u8 c_d:1; /* command/data bit */
  258. u8 res1:2;
  259. u8 bpv:1; /* bit pointer valid */
  260. u8 bpointer:3; /* bit pointer */
  261. #else
  262. u8 bpointer:3; /* bit pointer */
  263. u8 bpv:1; /* bit pointer valid */
  264. u8 res1:2;
  265. u8 c_d:1; /* command/data bit */
  266. u8 sksv:1; /* sense key specific valid */
  267. #endif
  268. u8 fpointer[2]; /* field pointer */
  269. };
  270. #define SCSI_SENSE_CUR_ERR 0x70
  271. #define SCSI_SENSE_DEF_ERR 0x71
  272. /*
  273. * SCSI sense key values
  274. */
  275. #define SCSI_SK_NO_SENSE 0x0
  276. #define SCSI_SK_REC_ERR 0x1 /* recovered error */
  277. #define SCSI_SK_NOT_READY 0x2
  278. #define SCSI_SK_MED_ERR 0x3 /* medium error */
  279. #define SCSI_SK_HW_ERR 0x4 /* hardware error */
  280. #define SCSI_SK_ILLEGAL_REQ 0x5
  281. #define SCSI_SK_UNIT_ATT 0x6 /* unit attention */
  282. #define SCSI_SK_DATA_PROTECT 0x7
  283. #define SCSI_SK_BLANK_CHECK 0x8
  284. #define SCSI_SK_VENDOR_SPEC 0x9
  285. #define SCSI_SK_COPY_ABORTED 0xA
  286. #define SCSI_SK_ABORTED_CMND 0xB
  287. #define SCSI_SK_VOL_OVERFLOW 0xD
  288. #define SCSI_SK_MISCOMPARE 0xE
  289. /*
  290. * SCSI additional sense codes
  291. */
  292. #define SCSI_ASC_NO_ADD_SENSE 0x00
  293. #define SCSI_ASC_LUN_NOT_READY 0x04
  294. #define SCSI_ASC_LUN_COMMUNICATION 0x08
  295. #define SCSI_ASC_WRITE_ERROR 0x0C
  296. #define SCSI_ASC_INVALID_CMND_CODE 0x20
  297. #define SCSI_ASC_BAD_LBA 0x21
  298. #define SCSI_ASC_INVALID_FIELD_IN_CDB 0x24
  299. #define SCSI_ASC_LUN_NOT_SUPPORTED 0x25
  300. #define SCSI_ASC_LUN_WRITE_PROTECT 0x27
  301. #define SCSI_ASC_POWERON_BDR 0x29 /* power on reset, bus reset,
  302. * bus device reset
  303. */
  304. #define SCSI_ASC_PARAMS_CHANGED 0x2A
  305. #define SCSI_ASC_CMND_CLEARED_BY_A_I 0x2F
  306. #define SCSI_ASC_SAVING_PARAM_NOTSUPP 0x39
  307. #define SCSI_ASC_TOCC 0x3F /* target operating condtions
  308. * changed
  309. */
  310. #define SCSI_ASC_PARITY_ERROR 0x47
  311. #define SCSI_ASC_CMND_PHASE_ERROR 0x4A
  312. #define SCSI_ASC_DATA_PHASE_ERROR 0x4B
  313. #define SCSI_ASC_VENDOR_SPEC 0x7F
  314. /*
  315. * SCSI additional sense code qualifiers
  316. */
  317. #define SCSI_ASCQ_CAUSE_NOT_REPORT 0x00
  318. #define SCSI_ASCQ_BECOMING_READY 0x01
  319. #define SCSI_ASCQ_INIT_CMD_REQ 0x02
  320. #define SCSI_ASCQ_FORMAT_IN_PROGRESS 0x04
  321. #define SCSI_ASCQ_OPERATION_IN_PROGRESS 0x07
  322. #define SCSI_ASCQ_SELF_TEST_IN_PROGRESS 0x09
  323. #define SCSI_ASCQ_WR_UNEXP_UNSOL_DATA 0x0C
  324. #define SCSI_ASCQ_WR_NOTENG_UNSOL_DATA 0x0D
  325. #define SCSI_ASCQ_LBA_OUT_OF_RANGE 0x00
  326. #define SCSI_ASCQ_INVALID_ELEMENT_ADDR 0x01
  327. #define SCSI_ASCQ_LUN_WRITE_PROTECTED 0x00
  328. #define SCSI_ASCQ_LUN_HW_WRITE_PROTECTED 0x01
  329. #define SCSI_ASCQ_LUN_SW_WRITE_PROTECTED 0x02
  330. #define SCSI_ASCQ_POR 0x01 /* power on reset */
  331. #define SCSI_ASCQ_SBR 0x02 /* scsi bus reset */
  332. #define SCSI_ASCQ_BDR 0x03 /* bus device reset */
  333. #define SCSI_ASCQ_DIR 0x04 /* device internal reset */
  334. #define SCSI_ASCQ_MODE_PARAMS_CHANGED 0x01
  335. #define SCSI_ASCQ_LOG_PARAMS_CHANGED 0x02
  336. #define SCSI_ASCQ_RESERVATIONS_PREEMPTED 0x03
  337. #define SCSI_ASCQ_RESERVATIONS_RELEASED 0x04
  338. #define SCSI_ASCQ_REGISTRATIONS_PREEMPTED 0x05
  339. #define SCSI_ASCQ_MICROCODE_CHANGED 0x01
  340. #define SCSI_ASCQ_CHANGED_OPER_COND 0x02
  341. #define SCSI_ASCQ_INQ_CHANGED 0x03 /* inquiry data changed */
  342. #define SCSI_ASCQ_DI_CHANGED 0x05 /* device id changed */
  343. #define SCSI_ASCQ_RL_DATA_CHANGED 0x0E /* report luns data changed */
  344. #define SCSI_ASCQ_DP_CRC_ERR 0x01 /* data phase crc error */
  345. #define SCSI_ASCQ_DP_SCSI_PARITY_ERR 0x02 /* data phase scsi parity error
  346. */
  347. #define SCSI_ASCQ_IU_CRC_ERR 0x03 /* information unit crc error */
  348. #define SCSI_ASCQ_PROTO_SERV_CRC_ERR 0x05
  349. #define SCSI_ASCQ_LUN_TIME_OUT 0x01
  350. /* ------------------------------------------------------------
  351. * SCSI INQUIRY
  352. * ------------------------------------------------------------*/
  353. struct scsi_inquiry_s{
  354. u8 opcode;
  355. #ifdef __BIGENDIAN
  356. u8 lun:3;
  357. u8 reserved1:3;
  358. u8 cmd_dt:1;
  359. u8 evpd:1;
  360. #else
  361. u8 evpd:1;
  362. u8 cmd_dt:1;
  363. u8 reserved1:3;
  364. u8 lun:3;
  365. #endif
  366. u8 page_code;
  367. u8 reserved2;
  368. u8 alloc_length;
  369. u8 control;
  370. };
  371. struct scsi_inquiry_vendor_s{
  372. u8 vendor_id[8];
  373. };
  374. struct scsi_inquiry_prodid_s{
  375. u8 product_id[16];
  376. };
  377. struct scsi_inquiry_prodrev_s{
  378. u8 product_rev[4];
  379. };
  380. struct scsi_inquiry_data_s{
  381. #ifdef __BIGENDIAN
  382. u8 peripheral_qual:3; /* peripheral qualifier */
  383. u8 device_type:5; /* peripheral device type */
  384. u8 rmb:1; /* removable medium bit */
  385. u8 device_type_mod:7; /* device type modifier */
  386. u8 version;
  387. u8 aenc:1; /* async event notification capability
  388. */
  389. u8 trm_iop:1; /* terminate I/O process */
  390. u8 norm_aca:1; /* normal ACA supported */
  391. u8 hi_support:1; /* SCSI-3: supports REPORT LUNS */
  392. u8 rsp_data_format:4;
  393. u8 additional_len;
  394. u8 sccs:1;
  395. u8 reserved1:7;
  396. u8 reserved2:1;
  397. u8 enc_serv:1; /* enclosure service component */
  398. u8 reserved3:1;
  399. u8 multi_port:1; /* multi-port device */
  400. u8 m_chngr:1; /* device in medium transport element */
  401. u8 ack_req_q:1; /* SIP specific bit */
  402. u8 addr32:1; /* SIP specific bit */
  403. u8 addr16:1; /* SIP specific bit */
  404. u8 rel_adr:1; /* relative address */
  405. u8 w_bus32:1;
  406. u8 w_bus16:1;
  407. u8 synchronous:1;
  408. u8 linked_commands:1;
  409. u8 trans_dis:1;
  410. u8 cmd_queue:1; /* command queueing supported */
  411. u8 soft_reset:1; /* soft reset alternative (VS) */
  412. #else
  413. u8 device_type:5; /* peripheral device type */
  414. u8 peripheral_qual:3;
  415. /* peripheral qualifier */
  416. u8 device_type_mod:7;
  417. /* device type modifier */
  418. u8 rmb:1; /* removable medium bit */
  419. u8 version;
  420. u8 rsp_data_format:4;
  421. u8 hi_support:1; /* SCSI-3: supports REPORT LUNS */
  422. u8 norm_aca:1; /* normal ACA supported */
  423. u8 terminate_iop:1;/* terminate I/O process */
  424. u8 aenc:1; /* async event notification capability
  425. */
  426. u8 additional_len;
  427. u8 reserved1:7;
  428. u8 sccs:1;
  429. u8 addr16:1; /* SIP specific bit */
  430. u8 addr32:1; /* SIP specific bit */
  431. u8 ack_req_q:1; /* SIP specific bit */
  432. u8 m_chngr:1; /* device in medium transport element */
  433. u8 multi_port:1; /* multi-port device */
  434. u8 reserved3:1; /* TBD - Vendor Specific */
  435. u8 enc_serv:1; /* enclosure service component */
  436. u8 reserved2:1;
  437. u8 soft_seset:1; /* soft reset alternative (VS) */
  438. u8 cmd_queue:1; /* command queueing supported */
  439. u8 trans_dis:1;
  440. u8 linked_commands:1;
  441. u8 synchronous:1;
  442. u8 w_bus16:1;
  443. u8 w_bus32:1;
  444. u8 rel_adr:1; /* relative address */
  445. #endif
  446. struct scsi_inquiry_vendor_s vendor_id;
  447. struct scsi_inquiry_prodid_s product_id;
  448. struct scsi_inquiry_prodrev_s product_rev;
  449. u8 vendor_specific[20];
  450. u8 reserved4[40];
  451. };
  452. /*
  453. * inquiry.peripheral_qual field values
  454. */
  455. #define SCSI_DEVQUAL_DEFAULT 0
  456. #define SCSI_DEVQUAL_NOT_CONNECTED 1
  457. #define SCSI_DEVQUAL_NOT_SUPPORTED 3
  458. /*
  459. * inquiry.device_type field values
  460. */
  461. #define SCSI_DEVICE_DIRECT_ACCESS 0x00
  462. #define SCSI_DEVICE_SEQ_ACCESS 0x01
  463. #define SCSI_DEVICE_ARRAY_CONTROLLER 0x0C
  464. #define SCSI_DEVICE_UNKNOWN 0x1F
  465. /*
  466. * inquiry.version
  467. */
  468. #define SCSI_VERSION_ANSI_X3131 2 /* ANSI X3.131 SCSI-2 */
  469. #define SCSI_VERSION_SPC 3 /* SPC (SCSI-3), ANSI X3.301:1997 */
  470. #define SCSI_VERSION_SPC_2 4 /* SPC-2 */
  471. /*
  472. * response data format
  473. */
  474. #define SCSI_RSP_DATA_FORMAT 2 /* SCSI-2 & SPC */
  475. /*
  476. * SCSI inquiry page codes
  477. */
  478. #define SCSI_INQ_PAGE_VPD_PAGES 0x00 /* supported vpd pages */
  479. #define SCSI_INQ_PAGE_USN_PAGE 0x80 /* unit serial number page */
  480. #define SCSI_INQ_PAGE_DEV_IDENT 0x83 /* device indentification page
  481. */
  482. #define SCSI_INQ_PAGES_MAX 3
  483. /*
  484. * supported vital product data pages
  485. */
  486. struct scsi_inq_page_vpd_pages_s{
  487. #ifdef __BIGENDIAN
  488. u8 peripheral_qual:3;
  489. u8 device_type:5;
  490. #else
  491. u8 device_type:5;
  492. u8 peripheral_qual:3;
  493. #endif
  494. u8 page_code;
  495. u8 reserved;
  496. u8 page_length;
  497. u8 pages[SCSI_INQ_PAGES_MAX];
  498. };
  499. /*
  500. * Unit serial number page
  501. */
  502. #define SCSI_INQ_USN_LEN 32
  503. struct scsi_inq_usn_s{
  504. char usn[SCSI_INQ_USN_LEN];
  505. };
  506. struct scsi_inq_page_usn_s{
  507. #ifdef __BIGENDIAN
  508. u8 peripheral_qual:3;
  509. u8 device_type:5;
  510. #else
  511. u8 device_type:5;
  512. u8 peripheral_qual:3;
  513. #endif
  514. u8 page_code;
  515. u8 reserved1;
  516. u8 page_length;
  517. struct scsi_inq_usn_s usn;
  518. };
  519. enum {
  520. SCSI_INQ_DIP_CODE_BINARY = 1, /* identifier has binary value */
  521. SCSI_INQ_DIP_CODE_ASCII = 2, /* identifier has ascii value */
  522. };
  523. enum {
  524. SCSI_INQ_DIP_ASSOC_LUN = 0, /* id is associated with device */
  525. SCSI_INQ_DIP_ASSOC_PORT = 1, /* id is associated with port that
  526. * received the request
  527. */
  528. };
  529. enum {
  530. SCSI_INQ_ID_TYPE_VENDOR = 1,
  531. SCSI_INQ_ID_TYPE_IEEE = 2,
  532. SCSI_INQ_ID_TYPE_FC_FS = 3,
  533. SCSI_INQ_ID_TYPE_OTHER = 4,
  534. };
  535. struct scsi_inq_dip_desc_s{
  536. #ifdef __BIGENDIAN
  537. u8 res0:4;
  538. u8 code_set:4;
  539. u8 res1:2;
  540. u8 association:2;
  541. u8 id_type:4;
  542. #else
  543. u8 code_set:4;
  544. u8 res0:4;
  545. u8 id_type:4;
  546. u8 association:2;
  547. u8 res1:2;
  548. #endif
  549. u8 res2;
  550. u8 id_len;
  551. struct scsi_lun_sn_s id;
  552. };
  553. /*
  554. * Device indentification page
  555. */
  556. struct scsi_inq_page_dev_ident_s{
  557. #ifdef __BIGENDIAN
  558. u8 peripheral_qual:3;
  559. u8 device_type:5;
  560. #else
  561. u8 device_type:5;
  562. u8 peripheral_qual:3;
  563. #endif
  564. u8 page_code;
  565. u8 reserved1;
  566. u8 page_length;
  567. struct scsi_inq_dip_desc_s desc;
  568. };
  569. /* ------------------------------------------------------------
  570. * READ CAPACITY
  571. * ------------------------------------------------------------
  572. */
  573. struct scsi_read_capacity_s{
  574. u8 opcode;
  575. #ifdef __BIGENDIAN
  576. u8 lun:3;
  577. u8 reserved1:4;
  578. u8 rel_adr:1;
  579. #else
  580. u8 rel_adr:1;
  581. u8 reserved1:4;
  582. u8 lun:3;
  583. #endif
  584. u8 lba0; /* MSB */
  585. u8 lba1;
  586. u8 lba2;
  587. u8 lba3; /* LSB */
  588. u8 reserved2;
  589. u8 reserved3;
  590. #ifdef __BIGENDIAN
  591. u8 reserved4:7;
  592. u8 pmi:1; /* partial medium indicator */
  593. #else
  594. u8 pmi:1; /* partial medium indicator */
  595. u8 reserved4:7;
  596. #endif
  597. u8 control;
  598. };
  599. struct scsi_read_capacity_data_s{
  600. u32 max_lba; /* maximum LBA available */
  601. u32 block_length; /* in bytes */
  602. };
  603. struct scsi_read_capacity16_data_s{
  604. u64 lba; /* maximum LBA available */
  605. u32 block_length; /* in bytes */
  606. #ifdef __BIGENDIAN
  607. u8 reserved1:4,
  608. p_type:3,
  609. prot_en:1;
  610. u8 reserved2:4,
  611. lb_pbe:4; /* logical blocks per physical block
  612. * exponent */
  613. u16 reserved3:2,
  614. lba_align:14; /* lowest aligned logical block
  615. * address */
  616. #else
  617. u16 lba_align:14, /* lowest aligned logical block
  618. * address */
  619. reserved3:2;
  620. u8 lb_pbe:4, /* logical blocks per physical block
  621. * exponent */
  622. reserved2:4;
  623. u8 prot_en:1,
  624. p_type:3,
  625. reserved1:4;
  626. #endif
  627. u64 reserved4;
  628. u64 reserved5;
  629. };
  630. /* ------------------------------------------------------------
  631. * REPORT LUNS command
  632. * ------------------------------------------------------------
  633. */
  634. struct scsi_report_luns_s{
  635. u8 opcode; /* A0h - REPORT LUNS opCode */
  636. u8 reserved1[5];
  637. u8 alloc_length[4];/* allocation length MSB first */
  638. u8 reserved2;
  639. u8 control;
  640. };
  641. #define SCSI_REPORT_LUN_ALLOC_LENGTH(rl) \
  642. ((rl->alloc_length[0] << 24) | (rl->alloc_length[1] << 16) | \
  643. (rl->alloc_length[2] << 8) | (rl->alloc_length[3]))
  644. #define SCSI_REPORT_LUNS_SET_ALLOCLEN(rl, alloc_len) { \
  645. (rl)->alloc_length[0] = (alloc_len) >> 24; \
  646. (rl)->alloc_length[1] = ((alloc_len) >> 16) & 0xFF; \
  647. (rl)->alloc_length[2] = ((alloc_len) >> 8) & 0xFF; \
  648. (rl)->alloc_length[3] = (alloc_len) & 0xFF; \
  649. }
  650. struct scsi_report_luns_data_s{
  651. u32 lun_list_length; /* length of LUN list length */
  652. u32 reserved;
  653. lun_t lun[1]; /* first LUN in lun list */
  654. };
  655. /* -------------------------------------------------------------
  656. * SCSI mode parameters
  657. * -----------------------------------------------------------
  658. */
  659. enum {
  660. SCSI_DA_MEDIUM_DEF = 0, /* direct access default medium type */
  661. SCSI_DA_MEDIUM_SS = 1, /* direct access single sided */
  662. SCSI_DA_MEDIUM_DS = 2, /* direct access double sided */
  663. };
  664. /*
  665. * SCSI Mode Select(6) cdb
  666. */
  667. struct scsi_mode_select6_s{
  668. u8 opcode;
  669. #ifdef __BIGENDIAN
  670. u8 reserved1:3;
  671. u8 pf:1; /* page format */
  672. u8 reserved2:3;
  673. u8 sp:1; /* save pages if set to 1 */
  674. #else
  675. u8 sp:1; /* save pages if set to 1 */
  676. u8 reserved2:3;
  677. u8 pf:1; /* page format */
  678. u8 reserved1:3;
  679. #endif
  680. u8 reserved3[2];
  681. u8 alloc_len;
  682. u8 control;
  683. };
  684. /*
  685. * SCSI Mode Select(10) cdb
  686. */
  687. struct scsi_mode_select10_s{
  688. u8 opcode;
  689. #ifdef __BIGENDIAN
  690. u8 reserved1:3;
  691. u8 pf:1; /* page format */
  692. u8 reserved2:3;
  693. u8 sp:1; /* save pages if set to 1 */
  694. #else
  695. u8 sp:1; /* save pages if set to 1 */
  696. u8 reserved2:3;
  697. u8 pf:1; /* page format */
  698. u8 reserved1:3;
  699. #endif
  700. u8 reserved3[5];
  701. u8 alloc_len_msb;
  702. u8 alloc_len_lsb;
  703. u8 control;
  704. };
  705. /*
  706. * SCSI Mode Sense(6) cdb
  707. */
  708. struct scsi_mode_sense6_s{
  709. u8 opcode;
  710. #ifdef __BIGENDIAN
  711. u8 reserved1:4;
  712. u8 dbd:1; /* disable block discriptors if set to 1 */
  713. u8 reserved2:3;
  714. u8 pc:2; /* page control */
  715. u8 page_code:6;
  716. #else
  717. u8 reserved2:3;
  718. u8 dbd:1; /* disable block descriptors if set to 1 */
  719. u8 reserved1:4;
  720. u8 page_code:6;
  721. u8 pc:2; /* page control */
  722. #endif
  723. u8 reserved3;
  724. u8 alloc_len;
  725. u8 control;
  726. };
  727. /*
  728. * SCSI Mode Sense(10) cdb
  729. */
  730. struct scsi_mode_sense10_s{
  731. u8 opcode;
  732. #ifdef __BIGENDIAN
  733. u8 reserved1:3;
  734. u8 LLBAA:1; /* long LBA accepted if set to 1 */
  735. u8 dbd:1; /* disable block descriptors if set
  736. * to 1
  737. */
  738. u8 reserved2:3;
  739. u8 pc:2; /* page control */
  740. u8 page_code:6;
  741. #else
  742. u8 reserved2:3;
  743. u8 dbd:1; /* disable block descriptors if set to
  744. * 1
  745. */
  746. u8 LLBAA:1; /* long LBA accepted if set to 1 */
  747. u8 reserved1:3;
  748. u8 page_code:6;
  749. u8 pc:2; /* page control */
  750. #endif
  751. u8 reserved3[4];
  752. u8 alloc_len_msb;
  753. u8 alloc_len_lsb;
  754. u8 control;
  755. };
  756. #define SCSI_CDB10_GET_AL(cdb) \
  757. ((cdb)->alloc_len_msb << 8 | (cdb)->alloc_len_lsb)
  758. #define SCSI_CDB10_SET_AL(cdb, al) { \
  759. (cdb)->alloc_len_msb = al >> 8; \
  760. (cdb)->alloc_len_lsb = al & 0xFF; \
  761. }
  762. #define SCSI_CDB6_GET_AL(cdb) ((cdb)->alloc_len)
  763. #define SCSI_CDB6_SET_AL(cdb, al) { \
  764. (cdb)->alloc_len = al; \
  765. }
  766. /*
  767. * page control field values
  768. */
  769. #define SCSI_PC_CURRENT_VALUES 0x0
  770. #define SCSI_PC_CHANGEABLE_VALUES 0x1
  771. #define SCSI_PC_DEFAULT_VALUES 0x2
  772. #define SCSI_PC_SAVED_VALUES 0x3
  773. /*
  774. * SCSI mode page codes
  775. */
  776. #define SCSI_MP_VENDOR_SPEC 0x00
  777. #define SCSI_MP_DISC_RECN 0x02 /* disconnect-reconnect page */
  778. #define SCSI_MP_FORMAT_DEVICE 0x03
  779. #define SCSI_MP_RDG 0x04 /* rigid disk geometry page */
  780. #define SCSI_MP_FDP 0x05 /* flexible disk page */
  781. #define SCSI_MP_CACHING 0x08 /* caching page */
  782. #define SCSI_MP_CONTROL 0x0A /* control mode page */
  783. #define SCSI_MP_MED_TYPES_SUP 0x0B /* medium types supported page */
  784. #define SCSI_MP_INFO_EXCP_CNTL 0x1C /* informational exception control */
  785. #define SCSI_MP_ALL 0x3F /* return all pages - mode sense only */
  786. /*
  787. * mode parameter header
  788. */
  789. struct scsi_mode_param_header6_s{
  790. u8 mode_datalen;
  791. u8 medium_type;
  792. /*
  793. * device specific parameters expanded for direct access devices
  794. */
  795. #ifdef __BIGENDIAN
  796. u32 wp:1; /* write protected */
  797. u32 reserved1:2;
  798. u32 dpofua:1; /* disable page out + force unit access
  799. */
  800. u32 reserved2:4;
  801. #else
  802. u32 reserved2:4;
  803. u32 dpofua:1; /* disable page out + force unit access
  804. */
  805. u32 reserved1:2;
  806. u32 wp:1; /* write protected */
  807. #endif
  808. u8 block_desclen;
  809. };
  810. struct scsi_mode_param_header10_s{
  811. u32 mode_datalen:16;
  812. u32 medium_type:8;
  813. /*
  814. * device specific parameters expanded for direct access devices
  815. */
  816. #ifdef __BIGENDIAN
  817. u32 wp:1; /* write protected */
  818. u32 reserved1:2;
  819. u32 dpofua:1; /* disable page out + force unit access
  820. */
  821. u32 reserved2:4;
  822. #else
  823. u32 reserved2:4;
  824. u32 dpofua:1; /* disable page out + force unit access
  825. */
  826. u32 reserved1:2;
  827. u32 wp:1; /* write protected */
  828. #endif
  829. #ifdef __BIGENDIAN
  830. u32 reserved3:7;
  831. u32 longlba:1;
  832. #else
  833. u32 longlba:1;
  834. u32 reserved3:7;
  835. #endif
  836. u32 reserved4:8;
  837. u32 block_desclen:16;
  838. };
  839. /*
  840. * mode parameter block descriptor
  841. */
  842. struct scsi_mode_param_desc_s{
  843. u32 nblks;
  844. u32 density_code:8;
  845. u32 block_length:24;
  846. };
  847. /*
  848. * Disconnect-reconnect mode page format
  849. */
  850. struct scsi_mp_disc_recn_s{
  851. #ifdef __BIGENDIAN
  852. u8 ps:1;
  853. u8 reserved1:1;
  854. u8 page_code:6;
  855. #else
  856. u8 page_code:6;
  857. u8 reserved1:1;
  858. u8 ps:1;
  859. #endif
  860. u8 page_len;
  861. u8 buf_full_ratio;
  862. u8 buf_empty_ratio;
  863. u8 bil_msb; /* bus inactivity limit -MSB */
  864. u8 bil_lsb; /* bus inactivity limit -LSB */
  865. u8 dtl_msb; /* disconnect time limit - MSB */
  866. u8 dtl_lsb; /* disconnect time limit - LSB */
  867. u8 ctl_msb; /* connect time limit - MSB */
  868. u8 ctl_lsb; /* connect time limit - LSB */
  869. u8 max_burst_len_msb;
  870. u8 max_burst_len_lsb;
  871. #ifdef __BIGENDIAN
  872. u8 emdp:1; /* enable modify data pointers */
  873. u8 fa:3; /* fair arbitration */
  874. u8 dimm:1; /* disconnect immediate */
  875. u8 dtdc:3; /* data transfer disconnect control */
  876. #else
  877. u8 dtdc:3; /* data transfer disconnect control */
  878. u8 dimm:1; /* disconnect immediate */
  879. u8 fa:3; /* fair arbitration */
  880. u8 emdp:1; /* enable modify data pointers */
  881. #endif
  882. u8 reserved3;
  883. u8 first_burst_len_msb;
  884. u8 first_burst_len_lsb;
  885. };
  886. /*
  887. * SCSI format device mode page
  888. */
  889. struct scsi_mp_format_device_s{
  890. #ifdef __BIGENDIAN
  891. u32 ps:1;
  892. u32 reserved1:1;
  893. u32 page_code:6;
  894. #else
  895. u32 page_code:6;
  896. u32 reserved1:1;
  897. u32 ps:1;
  898. #endif
  899. u32 page_len:8;
  900. u32 tracks_per_zone:16;
  901. u32 a_sec_per_zone:16;
  902. u32 a_tracks_per_zone:16;
  903. u32 a_tracks_per_lun:16; /* alternate tracks/lun-MSB */
  904. u32 sec_per_track:16; /* sectors/track-MSB */
  905. u32 bytes_per_sector:16;
  906. u32 interleave:16;
  907. u32 tsf:16; /* track skew factor-MSB */
  908. u32 csf:16; /* cylinder skew factor-MSB */
  909. #ifdef __BIGENDIAN
  910. u32 ssec:1; /* soft sector formatting */
  911. u32 hsec:1; /* hard sector formatting */
  912. u32 rmb:1; /* removable media */
  913. u32 surf:1; /* surface */
  914. u32 reserved2:4;
  915. #else
  916. u32 reserved2:4;
  917. u32 surf:1; /* surface */
  918. u32 rmb:1; /* removable media */
  919. u32 hsec:1; /* hard sector formatting */
  920. u32 ssec:1; /* soft sector formatting */
  921. #endif
  922. u32 reserved3:24;
  923. };
  924. /*
  925. * SCSI rigid disk device geometry page
  926. */
  927. struct scsi_mp_rigid_device_geometry_s{
  928. #ifdef __BIGENDIAN
  929. u32 ps:1;
  930. u32 reserved1:1;
  931. u32 page_code:6;
  932. #else
  933. u32 page_code:6;
  934. u32 reserved1:1;
  935. u32 ps:1;
  936. #endif
  937. u32 page_len:8;
  938. u32 num_cylinders0:8;
  939. u32 num_cylinders1:8;
  940. u32 num_cylinders2:8;
  941. u32 num_heads:8;
  942. u32 scwp0:8;
  943. u32 scwp1:8;
  944. u32 scwp2:8;
  945. u32 scrwc0:8;
  946. u32 scrwc1:8;
  947. u32 scrwc2:8;
  948. u32 dsr:16;
  949. u32 lscyl0:8;
  950. u32 lscyl1:8;
  951. u32 lscyl2:8;
  952. #ifdef __BIGENDIAN
  953. u32 reserved2:6;
  954. u32 rpl:2; /* rotational position locking */
  955. #else
  956. u32 rpl:2; /* rotational position locking */
  957. u32 reserved2:6;
  958. #endif
  959. u32 rot_off:8;
  960. u32 reserved3:8;
  961. u32 med_rot_rate:16;
  962. u32 reserved4:16;
  963. };
  964. /*
  965. * SCSI caching mode page
  966. */
  967. struct scsi_mp_caching_s{
  968. #ifdef __BIGENDIAN
  969. u8 ps:1;
  970. u8 res1:1;
  971. u8 page_code:6;
  972. #else
  973. u8 page_code:6;
  974. u8 res1:1;
  975. u8 ps:1;
  976. #endif
  977. u8 page_len;
  978. #ifdef __BIGENDIAN
  979. u8 ic:1; /* initiator control */
  980. u8 abpf:1; /* abort pre-fetch */
  981. u8 cap:1; /* caching analysis permitted */
  982. u8 disc:1; /* discontinuity */
  983. u8 size:1; /* size enable */
  984. u8 wce:1; /* write cache enable */
  985. u8 mf:1; /* multiplication factor */
  986. u8 rcd:1; /* read cache disable */
  987. u8 drrp:4; /* demand read retention priority */
  988. u8 wrp:4; /* write retention priority */
  989. #else
  990. u8 rcd:1; /* read cache disable */
  991. u8 mf:1; /* multiplication factor */
  992. u8 wce:1; /* write cache enable */
  993. u8 size:1; /* size enable */
  994. u8 disc:1; /* discontinuity */
  995. u8 cap:1; /* caching analysis permitted */
  996. u8 abpf:1; /* abort pre-fetch */
  997. u8 ic:1; /* initiator control */
  998. u8 wrp:4; /* write retention priority */
  999. u8 drrp:4; /* demand read retention priority */
  1000. #endif
  1001. u8 dptl[2];/* disable pre-fetch transfer length */
  1002. u8 min_prefetch[2];
  1003. u8 max_prefetch[2];
  1004. u8 max_prefetch_limit[2];
  1005. #ifdef __BIGENDIAN
  1006. u8 fsw:1; /* force sequential write */
  1007. u8 lbcss:1;/* logical block cache segment size */
  1008. u8 dra:1; /* disable read ahead */
  1009. u8 vs:2; /* vendor specific */
  1010. u8 res2:3;
  1011. #else
  1012. u8 res2:3;
  1013. u8 vs:2; /* vendor specific */
  1014. u8 dra:1; /* disable read ahead */
  1015. u8 lbcss:1;/* logical block cache segment size */
  1016. u8 fsw:1; /* force sequential write */
  1017. #endif
  1018. u8 num_cache_segs;
  1019. u8 cache_seg_size[2];
  1020. u8 res3;
  1021. u8 non_cache_seg_size[3];
  1022. };
  1023. /*
  1024. * SCSI control mode page
  1025. */
  1026. struct scsi_mp_control_page_s{
  1027. #ifdef __BIGENDIAN
  1028. u8 ps:1;
  1029. u8 reserved1:1;
  1030. u8 page_code:6;
  1031. #else
  1032. u8 page_code:6;
  1033. u8 reserved1:1;
  1034. u8 ps:1;
  1035. #endif
  1036. u8 page_len;
  1037. #ifdef __BIGENDIAN
  1038. u8 tst:3; /* task set type */
  1039. u8 reserved3:3;
  1040. u8 gltsd:1; /* global logging target save disable */
  1041. u8 rlec:1; /* report log exception condition */
  1042. u8 qalgo_mod:4; /* queue alogorithm modifier */
  1043. u8 reserved4:1;
  1044. u8 qerr:2; /* queue error management */
  1045. u8 dque:1; /* disable queuing */
  1046. u8 reserved5:1;
  1047. u8 rac:1; /* report a check */
  1048. u8 reserved6:2;
  1049. u8 swp:1; /* software write protect */
  1050. u8 raerp:1; /* ready AER permission */
  1051. u8 uaaerp:1; /* unit attenstion AER permission */
  1052. u8 eaerp:1; /* error AER permission */
  1053. u8 reserved7:5;
  1054. u8 autoload_mod:3;
  1055. #else
  1056. u8 rlec:1; /* report log exception condition */
  1057. u8 gltsd:1; /* global logging target save disable */
  1058. u8 reserved3:3;
  1059. u8 tst:3; /* task set type */
  1060. u8 dque:1; /* disable queuing */
  1061. u8 qerr:2; /* queue error management */
  1062. u8 reserved4:1;
  1063. u8 qalgo_mod:4; /* queue alogorithm modifier */
  1064. u8 eaerp:1; /* error AER permission */
  1065. u8 uaaerp:1; /* unit attenstion AER permission */
  1066. u8 raerp:1; /* ready AER permission */
  1067. u8 swp:1; /* software write protect */
  1068. u8 reserved6:2;
  1069. u8 rac:1; /* report a check */
  1070. u8 reserved5:1;
  1071. u8 autoload_mod:3;
  1072. u8 reserved7:5;
  1073. #endif
  1074. u8 rahp_msb; /* ready AER holdoff period - MSB */
  1075. u8 rahp_lsb; /* ready AER holdoff period - LSB */
  1076. u8 busy_timeout_period_msb;
  1077. u8 busy_timeout_period_lsb;
  1078. u8 ext_selftest_compl_time_msb;
  1079. u8 ext_selftest_compl_time_lsb;
  1080. };
  1081. /*
  1082. * SCSI medium types supported mode page
  1083. */
  1084. struct scsi_mp_medium_types_sup_s{
  1085. #ifdef __BIGENDIAN
  1086. u8 ps:1;
  1087. u8 reserved1:1;
  1088. u8 page_code:6;
  1089. #else
  1090. u8 page_code:6;
  1091. u8 reserved1:1;
  1092. u8 ps:1;
  1093. #endif
  1094. u8 page_len;
  1095. u8 reserved3[2];
  1096. u8 med_type1_sup; /* medium type one supported */
  1097. u8 med_type2_sup; /* medium type two supported */
  1098. u8 med_type3_sup; /* medium type three supported */
  1099. u8 med_type4_sup; /* medium type four supported */
  1100. };
  1101. /*
  1102. * SCSI informational exception control mode page
  1103. */
  1104. struct scsi_mp_info_excpt_cntl_s{
  1105. #ifdef __BIGENDIAN
  1106. u8 ps:1;
  1107. u8 reserved1:1;
  1108. u8 page_code:6;
  1109. #else
  1110. u8 page_code:6;
  1111. u8 reserved1:1;
  1112. u8 ps:1;
  1113. #endif
  1114. u8 page_len;
  1115. #ifdef __BIGENDIAN
  1116. u8 perf:1; /* performance */
  1117. u8 reserved3:1;
  1118. u8 ebf:1; /* enable background fucntion */
  1119. u8 ewasc:1; /* enable warning */
  1120. u8 dexcpt:1; /* disable exception control */
  1121. u8 test:1; /* enable test device failure
  1122. * notification
  1123. */
  1124. u8 reserved4:1;
  1125. u8 log_error:1;
  1126. u8 reserved5:4;
  1127. u8 mrie:4; /* method of reporting info
  1128. * exceptions
  1129. */
  1130. #else
  1131. u8 log_error:1;
  1132. u8 reserved4:1;
  1133. u8 test:1; /* enable test device failure
  1134. * notification
  1135. */
  1136. u8 dexcpt:1; /* disable exception control */
  1137. u8 ewasc:1; /* enable warning */
  1138. u8 ebf:1; /* enable background fucntion */
  1139. u8 reserved3:1;
  1140. u8 perf:1; /* performance */
  1141. u8 mrie:4; /* method of reporting info
  1142. * exceptions
  1143. */
  1144. u8 reserved5:4;
  1145. #endif
  1146. u8 interval_timer_msb;
  1147. u8 interval_timer_lsb;
  1148. u8 report_count_msb;
  1149. u8 report_count_lsb;
  1150. };
  1151. /*
  1152. * Methods of reporting informational exceptions
  1153. */
  1154. #define SCSI_MP_IEC_NO_REPORT 0x0 /* no reporting of exceptions */
  1155. #define SCSI_MP_IEC_AER 0x1 /* async event reporting */
  1156. #define SCSI_MP_IEC_UNIT_ATTN 0x2 /* generate unit attenstion */
  1157. #define SCSI_MO_IEC_COND_REC_ERR 0x3 /* conditionally generate recovered
  1158. * error
  1159. */
  1160. #define SCSI_MP_IEC_UNCOND_REC_ERR 0x4 /* unconditionally generate recovered
  1161. * error
  1162. */
  1163. #define SCSI_MP_IEC_NO_SENSE 0x5 /* generate no sense */
  1164. #define SCSI_MP_IEC_ON_REQUEST 0x6 /* only report exceptions on request */
  1165. /*
  1166. * SCSI flexible disk page
  1167. */
  1168. struct scsi_mp_flexible_disk_s{
  1169. #ifdef __BIGENDIAN
  1170. u8 ps:1;
  1171. u8 reserved1:1;
  1172. u8 page_code:6;
  1173. #else
  1174. u8 page_code:6;
  1175. u8 reserved1:1;
  1176. u8 ps:1;
  1177. #endif
  1178. u8 page_len;
  1179. u8 transfer_rate_msb;
  1180. u8 transfer_rate_lsb;
  1181. u8 num_heads;
  1182. u8 num_sectors;
  1183. u8 bytes_per_sector_msb;
  1184. u8 bytes_per_sector_lsb;
  1185. u8 num_cylinders_msb;
  1186. u8 num_cylinders_lsb;
  1187. u8 sc_wpc_msb; /* starting cylinder-write
  1188. * precompensation msb
  1189. */
  1190. u8 sc_wpc_lsb; /* starting cylinder-write
  1191. * precompensation lsb
  1192. */
  1193. u8 sc_rwc_msb; /* starting cylinder-reduced write
  1194. * current msb
  1195. */
  1196. u8 sc_rwc_lsb; /* starting cylinder-reduced write
  1197. * current lsb
  1198. */
  1199. u8 dev_step_rate_msb;
  1200. u8 dev_step_rate_lsb;
  1201. u8 dev_step_pulse_width;
  1202. u8 head_sd_msb; /* head settle delay msb */
  1203. u8 head_sd_lsb; /* head settle delay lsb */
  1204. u8 motor_on_delay;
  1205. u8 motor_off_delay;
  1206. #ifdef __BIGENDIAN
  1207. u8 trdy:1; /* true ready bit */
  1208. u8 ssn:1; /* start sector number bit */
  1209. u8 mo:1; /* motor on bit */
  1210. u8 reserved3:5;
  1211. u8 reserved4:4;
  1212. u8 spc:4; /* step pulse per cylinder */
  1213. #else
  1214. u8 reserved3:5;
  1215. u8 mo:1; /* motor on bit */
  1216. u8 ssn:1; /* start sector number bit */
  1217. u8 trdy:1; /* true ready bit */
  1218. u8 spc:4; /* step pulse per cylinder */
  1219. u8 reserved4:4;
  1220. #endif
  1221. u8 write_comp;
  1222. u8 head_load_delay;
  1223. u8 head_unload_delay;
  1224. #ifdef __BIGENDIAN
  1225. u8 pin34:4; /* pin34 usage */
  1226. u8 pin2:4; /* pin2 usage */
  1227. u8 pin4:4; /* pin4 usage */
  1228. u8 pin1:4; /* pin1 usage */
  1229. #else
  1230. u8 pin2:4; /* pin2 usage */
  1231. u8 pin34:4; /* pin34 usage */
  1232. u8 pin1:4; /* pin1 usage */
  1233. u8 pin4:4; /* pin4 usage */
  1234. #endif
  1235. u8 med_rot_rate_msb;
  1236. u8 med_rot_rate_lsb;
  1237. u8 reserved5[2];
  1238. };
  1239. struct scsi_mode_page_format_data6_s{
  1240. struct scsi_mode_param_header6_s mph; /* mode page header */
  1241. struct scsi_mode_param_desc_s desc; /* block descriptor */
  1242. struct scsi_mp_format_device_s format; /* format device data */
  1243. };
  1244. struct scsi_mode_page_format_data10_s{
  1245. struct scsi_mode_param_header10_s mph; /* mode page header */
  1246. struct scsi_mode_param_desc_s desc; /* block descriptor */
  1247. struct scsi_mp_format_device_s format; /* format device data */
  1248. };
  1249. struct scsi_mode_page_rdg_data6_s{
  1250. struct scsi_mode_param_header6_s mph; /* mode page header */
  1251. struct scsi_mode_param_desc_s desc; /* block descriptor */
  1252. struct scsi_mp_rigid_device_geometry_s rdg;
  1253. /* rigid geometry data */
  1254. };
  1255. struct scsi_mode_page_rdg_data10_s{
  1256. struct scsi_mode_param_header10_s mph; /* mode page header */
  1257. struct scsi_mode_param_desc_s desc; /* block descriptor */
  1258. struct scsi_mp_rigid_device_geometry_s rdg;
  1259. /* rigid geometry data */
  1260. };
  1261. struct scsi_mode_page_cache6_s{
  1262. struct scsi_mode_param_header6_s mph; /* mode page header */
  1263. struct scsi_mode_param_desc_s desc; /* block descriptor */
  1264. struct scsi_mp_caching_s cache; /* cache page data */
  1265. };
  1266. struct scsi_mode_page_cache10_s{
  1267. struct scsi_mode_param_header10_s mph; /* mode page header */
  1268. struct scsi_mode_param_desc_s desc; /* block descriptor */
  1269. struct scsi_mp_caching_s cache; /* cache page data */
  1270. };
  1271. /* --------------------------------------------------------------
  1272. * Format Unit command
  1273. * ------------------------------------------------------------
  1274. */
  1275. /*
  1276. * Format Unit CDB
  1277. */
  1278. struct scsi_format_unit_s{
  1279. u8 opcode;
  1280. #ifdef __BIGENDIAN
  1281. u8 res1:3;
  1282. u8 fmtdata:1; /* if set, data out phase has format
  1283. * data
  1284. */
  1285. u8 cmplst:1; /* if set, defect list is complete */
  1286. u8 def_list:3; /* format of defect descriptor is
  1287. * fmtdata =1
  1288. */
  1289. #else
  1290. u8 def_list:3; /* format of defect descriptor is
  1291. * fmtdata = 1
  1292. */
  1293. u8 cmplst:1; /* if set, defect list is complete */
  1294. u8 fmtdata:1; /* if set, data out phase has format
  1295. * data
  1296. */
  1297. u8 res1:3;
  1298. #endif
  1299. u8 interleave_msb;
  1300. u8 interleave_lsb;
  1301. u8 vendor_spec;
  1302. u8 control;
  1303. };
  1304. /*
  1305. * h
  1306. */
  1307. struct scsi_reserve6_s{
  1308. u8 opcode;
  1309. #ifdef __BIGENDIAN
  1310. u8 reserved:3;
  1311. u8 obsolete:4;
  1312. u8 extent:1;
  1313. #else
  1314. u8 extent:1;
  1315. u8 obsolete:4;
  1316. u8 reserved:3;
  1317. #endif
  1318. u8 reservation_id;
  1319. u16 param_list_len;
  1320. u8 control;
  1321. };
  1322. /*
  1323. * h
  1324. */
  1325. struct scsi_release6_s{
  1326. u8 opcode;
  1327. #ifdef __BIGENDIAN
  1328. u8 reserved1:3;
  1329. u8 obsolete:4;
  1330. u8 extent:1;
  1331. #else
  1332. u8 extent:1;
  1333. u8 obsolete:4;
  1334. u8 reserved1:3;
  1335. #endif
  1336. u8 reservation_id;
  1337. u16 reserved2;
  1338. u8 control;
  1339. };
  1340. /*
  1341. * h
  1342. */
  1343. struct scsi_reserve10_s{
  1344. u8 opcode;
  1345. #ifdef __BIGENDIAN
  1346. u8 reserved1:3;
  1347. u8 third_party:1;
  1348. u8 reserved2:2;
  1349. u8 long_id:1;
  1350. u8 extent:1;
  1351. #else
  1352. u8 extent:1;
  1353. u8 long_id:1;
  1354. u8 reserved2:2;
  1355. u8 third_party:1;
  1356. u8 reserved1:3;
  1357. #endif
  1358. u8 reservation_id;
  1359. u8 third_pty_dev_id;
  1360. u8 reserved3;
  1361. u8 reserved4;
  1362. u8 reserved5;
  1363. u16 param_list_len;
  1364. u8 control;
  1365. };
  1366. struct scsi_release10_s{
  1367. u8 opcode;
  1368. #ifdef __BIGENDIAN
  1369. u8 reserved1:3;
  1370. u8 third_party:1;
  1371. u8 reserved2:2;
  1372. u8 long_id:1;
  1373. u8 extent:1;
  1374. #else
  1375. u8 extent:1;
  1376. u8 long_id:1;
  1377. u8 reserved2:2;
  1378. u8 third_party:1;
  1379. u8 reserved1:3;
  1380. #endif
  1381. u8 reservation_id;
  1382. u8 third_pty_dev_id;
  1383. u8 reserved3;
  1384. u8 reserved4;
  1385. u8 reserved5;
  1386. u16 param_list_len;
  1387. u8 control;
  1388. };
  1389. struct scsi_verify10_s{
  1390. u8 opcode;
  1391. #ifdef __BIGENDIAN
  1392. u8 lun:3;
  1393. u8 dpo:1;
  1394. u8 reserved:2;
  1395. u8 bytchk:1;
  1396. u8 reladdr:1;
  1397. #else
  1398. u8 reladdr:1;
  1399. u8 bytchk:1;
  1400. u8 reserved:2;
  1401. u8 dpo:1;
  1402. u8 lun:3;
  1403. #endif
  1404. u8 lba0;
  1405. u8 lba1;
  1406. u8 lba2;
  1407. u8 lba3;
  1408. u8 reserved1;
  1409. u8 verification_len0;
  1410. u8 verification_len1;
  1411. u8 control_byte;
  1412. };
  1413. struct scsi_request_sense_s{
  1414. u8 opcode;
  1415. #ifdef __BIGENDIAN
  1416. u8 lun:3;
  1417. u8 reserved:5;
  1418. #else
  1419. u8 reserved:5;
  1420. u8 lun:3;
  1421. #endif
  1422. u8 reserved0;
  1423. u8 reserved1;
  1424. u8 alloc_len;
  1425. u8 control_byte;
  1426. };
  1427. /* ------------------------------------------------------------
  1428. * SCSI status byte values
  1429. * ------------------------------------------------------------
  1430. */
  1431. #define SCSI_STATUS_GOOD 0x00
  1432. #define SCSI_STATUS_CHECK_CONDITION 0x02
  1433. #define SCSI_STATUS_CONDITION_MET 0x04
  1434. #define SCSI_STATUS_BUSY 0x08
  1435. #define SCSI_STATUS_INTERMEDIATE 0x10
  1436. #define SCSI_STATUS_ICM 0x14 /* intermediate condition met */
  1437. #define SCSI_STATUS_RESERVATION_CONFLICT 0x18
  1438. #define SCSI_STATUS_COMMAND_TERMINATED 0x22
  1439. #define SCSI_STATUS_QUEUE_FULL 0x28
  1440. #define SCSI_STATUS_ACA_ACTIVE 0x30
  1441. #define SCSI_MAX_ALLOC_LEN 0xFF /* maximum allocarion length
  1442. * in CDBs
  1443. */
  1444. #define SCSI_OP_WRITE_VERIFY10 0x2E
  1445. #define SCSI_OP_WRITE_VERIFY12 0xAE
  1446. #define SCSI_OP_UNDEF 0xFF
  1447. /*
  1448. * SCSI WRITE-VERIFY(10) command
  1449. */
  1450. struct scsi_write_verify10_s{
  1451. u8 opcode;
  1452. #ifdef __BIGENDIAN
  1453. u8 reserved1:3;
  1454. u8 dpo:1; /* Disable Page Out */
  1455. u8 reserved2:1;
  1456. u8 ebp:1; /* erse by-pass */
  1457. u8 bytchk:1; /* byte check */
  1458. u8 rel_adr:1; /* relative address */
  1459. #else
  1460. u8 rel_adr:1; /* relative address */
  1461. u8 bytchk:1; /* byte check */
  1462. u8 ebp:1; /* erse by-pass */
  1463. u8 reserved2:1;
  1464. u8 dpo:1; /* Disable Page Out */
  1465. u8 reserved1:3;
  1466. #endif
  1467. u8 lba0; /* logical block address - MSB */
  1468. u8 lba1;
  1469. u8 lba2;
  1470. u8 lba3; /* LSB */
  1471. u8 reserved3;
  1472. u8 xfer_length0; /* transfer length in blocks - MSB */
  1473. u8 xfer_length1; /* LSB */
  1474. u8 control;
  1475. };
  1476. #pragma pack()
  1477. #endif /* __SCSI_H__ */