osd_sense.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /*
  2. * osd_sense.h - OSD Related sense handling definitions.
  3. *
  4. * Copyright (C) 2008 Panasas Inc. All rights reserved.
  5. *
  6. * Authors:
  7. * Boaz Harrosh <ooo@electrozaur.com>
  8. * Benny Halevy <bhalevy@panasas.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2
  12. *
  13. * This file contains types and constants that are defined by the protocol
  14. * Note: All names and symbols are taken from the OSD standard's text.
  15. */
  16. #ifndef __OSD_SENSE_H__
  17. #define __OSD_SENSE_H__
  18. #include <scsi/osd_protocol.h>
  19. /* SPC3r23 4.5.6 Sense key and sense code definitions table 27 */
  20. enum scsi_sense_keys {
  21. scsi_sk_no_sense = 0x0,
  22. scsi_sk_recovered_error = 0x1,
  23. scsi_sk_not_ready = 0x2,
  24. scsi_sk_medium_error = 0x3,
  25. scsi_sk_hardware_error = 0x4,
  26. scsi_sk_illegal_request = 0x5,
  27. scsi_sk_unit_attention = 0x6,
  28. scsi_sk_data_protect = 0x7,
  29. scsi_sk_blank_check = 0x8,
  30. scsi_sk_vendor_specific = 0x9,
  31. scsi_sk_copy_aborted = 0xa,
  32. scsi_sk_aborted_command = 0xb,
  33. scsi_sk_volume_overflow = 0xd,
  34. scsi_sk_miscompare = 0xe,
  35. scsi_sk_reserved = 0xf,
  36. };
  37. /* SPC3r23 4.5.6 Sense key and sense code definitions table 28 */
  38. /* Note: only those which can be returned by an OSD target. Most of
  39. * these errors are taken care of by the generic scsi layer.
  40. */
  41. enum osd_additional_sense_codes {
  42. scsi_no_additional_sense_information = 0x0000,
  43. scsi_operation_in_progress = 0x0016,
  44. scsi_cleaning_requested = 0x0017,
  45. scsi_lunr_cause_not_reportable = 0x0400,
  46. scsi_logical_unit_is_in_process_of_becoming_ready = 0x0401,
  47. scsi_lunr_initializing_command_required = 0x0402,
  48. scsi_lunr_manual_intervention_required = 0x0403,
  49. scsi_lunr_operation_in_progress = 0x0407,
  50. scsi_lunr_selftest_in_progress = 0x0409,
  51. scsi_luna_asymmetric_access_state_transition = 0x040a,
  52. scsi_luna_target_port_in_standby_state = 0x040b,
  53. scsi_luna_target_port_in_unavailable_state = 0x040c,
  54. scsi_lunr_notify_enable_spinup_required = 0x0411,
  55. scsi_logical_unit_does_not_respond_to_selection = 0x0500,
  56. scsi_logical_unit_communication_failure = 0x0800,
  57. scsi_logical_unit_communication_timeout = 0x0801,
  58. scsi_logical_unit_communication_parity_error = 0x0802,
  59. scsi_error_log_overflow = 0x0a00,
  60. scsi_warning = 0x0b00,
  61. scsi_warning_specified_temperature_exceeded = 0x0b01,
  62. scsi_warning_enclosure_degraded = 0x0b02,
  63. scsi_write_error_unexpected_unsolicited_data = 0x0c0c,
  64. scsi_write_error_not_enough_unsolicited_data = 0x0c0d,
  65. scsi_invalid_information_unit = 0x0e00,
  66. scsi_invalid_field_in_command_information_unit = 0x0e03,
  67. scsi_read_error_failed_retransmission_request = 0x1113,
  68. scsi_parameter_list_length_error = 0x1a00,
  69. scsi_invalid_command_operation_code = 0x2000,
  70. scsi_invalid_field_in_cdb = 0x2400,
  71. osd_security_audit_value_frozen = 0x2404,
  72. osd_security_working_key_frozen = 0x2405,
  73. osd_nonce_not_unique = 0x2406,
  74. osd_nonce_timestamp_out_of_range = 0x2407,
  75. scsi_logical_unit_not_supported = 0x2500,
  76. scsi_invalid_field_in_parameter_list = 0x2600,
  77. scsi_parameter_not_supported = 0x2601,
  78. scsi_parameter_value_invalid = 0x2602,
  79. scsi_invalid_release_of_persistent_reservation = 0x2604,
  80. osd_invalid_dataout_buffer_integrity_check_value = 0x260f,
  81. scsi_not_ready_to_ready_change_medium_may_have_changed = 0x2800,
  82. scsi_power_on_reset_or_bus_device_reset_occurred = 0x2900,
  83. scsi_power_on_occurred = 0x2901,
  84. scsi_scsi_bus_reset_occurred = 0x2902,
  85. scsi_bus_device_reset_function_occurred = 0x2903,
  86. scsi_device_internal_reset = 0x2904,
  87. scsi_transceiver_mode_changed_to_single_ended = 0x2905,
  88. scsi_transceiver_mode_changed_to_lvd = 0x2906,
  89. scsi_i_t_nexus_loss_occurred = 0x2907,
  90. scsi_parameters_changed = 0x2a00,
  91. scsi_mode_parameters_changed = 0x2a01,
  92. scsi_asymmetric_access_state_changed = 0x2a06,
  93. scsi_priority_changed = 0x2a08,
  94. scsi_command_sequence_error = 0x2c00,
  95. scsi_previous_busy_status = 0x2c07,
  96. scsi_previous_task_set_full_status = 0x2c08,
  97. scsi_previous_reservation_conflict_status = 0x2c09,
  98. osd_partition_or_collection_contains_user_objects = 0x2c0a,
  99. scsi_commands_cleared_by_another_initiator = 0x2f00,
  100. scsi_cleaning_failure = 0x3007,
  101. scsi_enclosure_failure = 0x3400,
  102. scsi_enclosure_services_failure = 0x3500,
  103. scsi_unsupported_enclosure_function = 0x3501,
  104. scsi_enclosure_services_unavailable = 0x3502,
  105. scsi_enclosure_services_transfer_failure = 0x3503,
  106. scsi_enclosure_services_transfer_refused = 0x3504,
  107. scsi_enclosure_services_checksum_error = 0x3505,
  108. scsi_rounded_parameter = 0x3700,
  109. osd_read_past_end_of_user_object = 0x3b17,
  110. scsi_logical_unit_has_not_self_configured_yet = 0x3e00,
  111. scsi_logical_unit_failure = 0x3e01,
  112. scsi_timeout_on_logical_unit = 0x3e02,
  113. scsi_logical_unit_failed_selftest = 0x3e03,
  114. scsi_logical_unit_unable_to_update_selftest_log = 0x3e04,
  115. scsi_target_operating_conditions_have_changed = 0x3f00,
  116. scsi_microcode_has_been_changed = 0x3f01,
  117. scsi_inquiry_data_has_changed = 0x3f03,
  118. scsi_echo_buffer_overwritten = 0x3f0f,
  119. scsi_diagnostic_failure_on_component_nn_first = 0x4080,
  120. scsi_diagnostic_failure_on_component_nn_last = 0x40ff,
  121. scsi_message_error = 0x4300,
  122. scsi_internal_target_failure = 0x4400,
  123. scsi_select_or_reselect_failure = 0x4500,
  124. scsi_scsi_parity_error = 0x4700,
  125. scsi_data_phase_crc_error_detected = 0x4701,
  126. scsi_scsi_parity_error_detected_during_st_data_phase = 0x4702,
  127. scsi_asynchronous_information_protection_error_detected = 0x4704,
  128. scsi_protocol_service_crc_error = 0x4705,
  129. scsi_phy_test_function_in_progress = 0x4706,
  130. scsi_invalid_message_error = 0x4900,
  131. scsi_command_phase_error = 0x4a00,
  132. scsi_data_phase_error = 0x4b00,
  133. scsi_logical_unit_failed_self_configuration = 0x4c00,
  134. scsi_overlapped_commands_attempted = 0x4e00,
  135. osd_quota_error = 0x5507,
  136. scsi_failure_prediction_threshold_exceeded = 0x5d00,
  137. scsi_failure_prediction_threshold_exceeded_false = 0x5dff,
  138. scsi_voltage_fault = 0x6500,
  139. };
  140. enum scsi_descriptor_types {
  141. scsi_sense_information = 0x0,
  142. scsi_sense_command_specific_information = 0x1,
  143. scsi_sense_key_specific = 0x2,
  144. scsi_sense_field_replaceable_unit = 0x3,
  145. scsi_sense_stream_commands = 0x4,
  146. scsi_sense_block_commands = 0x5,
  147. osd_sense_object_identification = 0x6,
  148. osd_sense_response_integrity_check = 0x7,
  149. osd_sense_attribute_identification = 0x8,
  150. scsi_sense_ata_return = 0x9,
  151. scsi_sense_Reserved_first = 0x0A,
  152. scsi_sense_Reserved_last = 0x7F,
  153. scsi_sense_Vendor_specific_first = 0x80,
  154. scsi_sense_Vendor_specific_last = 0xFF,
  155. };
  156. struct scsi_sense_descriptor { /* for picking into desc type */
  157. u8 descriptor_type; /* one of enum scsi_descriptor_types */
  158. u8 additional_length; /* n - 1 */
  159. u8 data[];
  160. } __packed;
  161. /* OSD deploys only scsi descriptor_based sense buffers */
  162. struct scsi_sense_descriptor_based {
  163. /*0*/ u8 response_code; /* 0x72 or 0x73 */
  164. /*1*/ u8 sense_key; /* one of enum scsi_sense_keys (4 lower bits) */
  165. /*2*/ __be16 additional_sense_code; /* enum osd_additional_sense_codes */
  166. /*4*/ u8 Reserved[3];
  167. /*7*/ u8 additional_sense_length; /* n - 7 */
  168. /*8*/ struct scsi_sense_descriptor ssd[0]; /* variable length, 1 or more */
  169. } __packed;
  170. /* some descriptors deployed by OSD */
  171. /* SPC3r23 4.5.2.3 Command-specific information sense data descriptor */
  172. /* Note: this is the same for descriptor_type=00 but with type=00 the
  173. * Reserved[0] == 0x80 (ie. bit-7 set)
  174. */
  175. struct scsi_sense_command_specific_data_descriptor {
  176. /*0*/ u8 descriptor_type; /* (00h/01h) */
  177. /*1*/ u8 additional_length; /* (0Ah) */
  178. /*2*/ u8 Reserved[2];
  179. /*4*/ __be64 information;
  180. } __packed;
  181. /*12*/
  182. struct scsi_sense_key_specific_data_descriptor {
  183. /*0*/ u8 descriptor_type; /* (02h) */
  184. /*1*/ u8 additional_length; /* (06h) */
  185. /*2*/ u8 Reserved[2];
  186. /* SKSV, C/D, Reserved (2), BPV, BIT POINTER (3) */
  187. /*4*/ u8 sksv_cd_bpv_bp;
  188. /*5*/ __be16 value; /* field-pointer/progress-value/retry-count/... */
  189. /*7*/ u8 Reserved2;
  190. } __packed;
  191. /*8*/
  192. /* 4.16.2.1 OSD error identification sense data descriptor - table 52 */
  193. /* Note: these bits are defined LE order for easy definition, this way the BIT()
  194. * number is the same as in the documentation. Below members at
  195. * osd_sense_identification_data_descriptor are therefore defined __le32.
  196. */
  197. enum osd_command_functions_bits {
  198. OSD_CFB_COMMAND = BIT(4),
  199. OSD_CFB_CMD_CAP_VERIFIED = BIT(5),
  200. OSD_CFB_VALIDATION = BIT(7),
  201. OSD_CFB_IMP_ST_ATT = BIT(12),
  202. OSD_CFB_SET_ATT = BIT(20),
  203. OSD_CFB_SA_CAP_VERIFIED = BIT(21),
  204. OSD_CFB_GET_ATT = BIT(28),
  205. OSD_CFB_GA_CAP_VERIFIED = BIT(29),
  206. };
  207. struct osd_sense_identification_data_descriptor {
  208. /*0*/ u8 descriptor_type; /* (06h) */
  209. /*1*/ u8 additional_length; /* (1Eh) */
  210. /*2*/ u8 Reserved[6];
  211. /*8*/ __le32 not_initiated_functions; /*osd_command_functions_bits*/
  212. /*12*/ __le32 completed_functions; /*osd_command_functions_bits*/
  213. /*16*/ __be64 partition_id;
  214. /*24*/ __be64 object_id;
  215. } __packed;
  216. /*32*/
  217. struct osd_sense_response_integrity_check_descriptor {
  218. /*0*/ u8 descriptor_type; /* (07h) */
  219. /*1*/ u8 additional_length; /* (20h) */
  220. /*2*/ u8 integrity_check_value[32]; /*FIXME: OSDv2_CRYPTO_KEYID_SIZE*/
  221. } __packed;
  222. /*34*/
  223. struct osd_sense_attributes_data_descriptor {
  224. /*0*/ u8 descriptor_type; /* (08h) */
  225. /*1*/ u8 additional_length; /* (n-2) */
  226. /*2*/ u8 Reserved[6];
  227. struct osd_sense_attr {
  228. /*8*/ __be32 attr_page;
  229. /*12*/ __be32 attr_id;
  230. /*16*/ } sense_attrs[0]; /* 1 or more */
  231. } __packed;
  232. /*variable*/
  233. /* Dig into scsi_sk_illegal_request/scsi_invalid_field_in_cdb errors */
  234. /*FIXME: Support also field in CAPS*/
  235. #define OSD_CDB_OFFSET(F) offsetof(struct osd_cdb_head, F)
  236. enum osdv2_cdb_field_offset {
  237. OSDv1_CFO_STARTING_BYTE = OSD_CDB_OFFSET(v1.start_address),
  238. OSD_CFO_STARTING_BYTE = OSD_CDB_OFFSET(v2.start_address),
  239. OSD_CFO_PARTITION_ID = OSD_CDB_OFFSET(partition),
  240. OSD_CFO_OBJECT_ID = OSD_CDB_OFFSET(object),
  241. OSD_CFO_PERMISSIONS = sizeof(struct osd_cdb_head) +
  242. offsetof(struct osd_capability_head,
  243. permissions_bit_mask),
  244. };
  245. #endif /* ndef __OSD_SENSE_H__ */