2 * Copyright (c) 2008 Scott Long
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef ATA_RAID_DDF_H
30 #define ATA_RAID_DDF_H
32 /* Definitions from the SNIA DDF spec, rev 1.2 */
34 #define DDF_HEADER_LENGTH 512
37 #define DDF_HEADER_SIGNATURE 0xde11de11
39 uint8_t DDF_Header_GUID[24];
41 uint32_t Sequence_Number;
44 #define DDF_HEADER_CLOSED 0x00
45 #define DDF_HEADER_OPENED_MASK 0x0f
46 #define DDF_HEADER_OPEN_ANCHOR 0xff
50 uint8_t Header_ext[32];
51 uint64_t Primary_Header_LBA;
52 uint64_t Secondary_Header_LBA;
54 #define DDF_HEADER_ANCHOR 0x00
55 #define DDF_HEADER_PRIMARY 0x01
56 #define DDF_HEADER_SECONDARY 0x02
58 uint32_t WorkSpace_Length;
59 uint64_t WorkSpace_LBA;
60 uint16_t Max_PD_Entries;
61 uint16_t Max_VD_Entries;
62 uint16_t Max_Partitions;
63 uint16_t Configuration_Record_Length;
64 uint16_t Max_Primary_Element_Entries;
66 uint32_t cd_section; /* Controller_Data_Section */
67 uint32_t cd_length; /* Controller_Data_Section_Length */
68 uint32_t pdr_section; /* Physical_Drive_Records_Section */
69 uint32_t pdr_length; /* Physical_Drive_Records_Length */
70 uint32_t vdr_section; /* Virtual_Drive_Records_Section */
71 uint32_t vdr_length; /* Virtual_Drive_Records_Length */
72 uint32_t cr_section; /* Configuration_Records_Section */
73 uint32_t cr_length; /* Configuration_Records_Length */
74 uint32_t pdd_section; /* Physical_Drive_Data_Section */
75 uint32_t pdd_length; /* Physical_Drive_Data_Length */
76 uint32_t bbmlog_section; /* BBM_Log_Section */
77 uint32_t bbmlog_length; /* BBM_Log_Section_Length */
78 uint32_t Diagnostic_Space;
79 uint32_t Diagnostic_Space_Length;
80 uint32_t Vendor_Specific_Logs;
81 uint32_t Vendor_Specific_Logs_Length;
85 struct ddf_cd_record {
87 #define DDF_CONTROLLER_DATA_SIGNATURE 0xad111111
89 uint8_t Controller_GUID[24];
93 uint16_t SubVendor_ID;
94 uint16_t SubDevice_ID;
95 } Controller_Type __packed;
96 uint8_t Product_ID[16];
98 uint8_t Controller_Data[448];
101 struct ddf_device_scsi {
106 #define DDF_DEVICE_SCSI_FLAG_BROKEN (1 << 7)
109 struct ddf_device_sas {
110 uint64_t Initiator_Path;
115 struct ddf_device_scsi Path0;
116 struct ddf_device_scsi Path1;
120 struct ddf_device_sas Path0;
121 struct ddf_device_sas Path1;
124 #define DDF_DEVICE_SAS_FLAG_BROKEN (1 << 7)
128 struct ddf_pd_entry {
130 uint32_t PD_Reference;
132 #define DDF_PDE_GUID_FORCE (1 << 0)
133 #define DDF_PDE_PARTICIPATING (1 << 1)
134 #define DDF_PDE_GLOBAL_SPARE (1 << 2)
135 #define DDF_PDE_CONFIG_SPARE (1 << 3)
136 #define DDF_PDE_FOREIGN (1 << 4)
137 #define DDF_PDE_LEGACY (1 << 5)
138 #define DDF_PDE_TYPE_MASK (0x0f << 12)
139 #define DDF_PDE_UNKNOWN (0x00 << 12)
140 #define DDF_PDE_SCSI (0x01 << 12)
141 #define DDF_PDE_SAS (0x02 << 12)
142 #define DDF_PDE_SATA (0x03 << 12)
143 #define DDF_PDE_FC (0x04 << 12)
145 #define DDF_PDE_ONLINE (1 << 0)
146 #define DDF_PDE_FAILED (1 << 1)
147 #define DDF_PDE_REBUILD (1 << 2)
148 #define DDF_PDE_TRANSITION (1 << 3)
149 #define DDF_PDE_PFA (1 << 4)
150 #define DDF_PDE_UNRECOVERED (1 << 5)
151 #define DDF_PDE_MISSING (1 << 6)
152 uint64_t Configured_Size;
153 union ddf_pathinfo Path_Information;
157 struct ddf_pd_record {
159 #define DDF_PDR_SIGNATURE 0x22222222
161 uint16_t Populated_PDEs;
162 uint16_t Max_PDE_Supported;
164 struct ddf_pd_entry entry[0];
167 struct ddf_vd_entry {
172 #define DDF_VDE_SHARED (1 << 0)
173 #define DDF_VDE_ENFORCE_GROUP (1 << 1)
174 #define DDF_VDE_UNICODE_NAME (1 << 2)
175 #define DDF_VDE_OWNER_ID_VALID (1 << 3)
176 uint16_t Controller_GUID_CRC;
178 #define DDF_VDE_OPTIMAL 0x00
179 #define DDF_VDE_DEGRADED 0x01
180 #define DDF_VDE_DELETED 0x02
181 #define DDF_VDE_MISSING 0x03
182 #define DDF_VDE_FAILED 0x04
183 #define DDF_VDE_PARTIAL 0x05
184 #define DDF_VDE_STATE_MASK 0x07
185 #define DDF_VDE_MORPH (1 << 3)
186 #define DDF_VDE_DIRTY (1 << 4)
188 #define DDF_VDE_UNINTIALIZED 0x00
189 #define DDF_VDE_INIT_QUICK 0x01
190 #define DDF_VDE_INIT_FULL 0x02
191 #define DDF_VDE_INIT_MASK 0x03
192 #define DDF_VDE_UACCESS_RW 0x00
193 #define DDF_VDE_UACCESS_RO 0x80
194 #define DDF_VDE_UACCESS_BLOCKED 0xc0
195 #define DDF_VDE_UACCESS_MASK 0xc0
200 struct ddf_vd_record {
202 #define DDF_VD_RECORD_SIGNATURE 0xdddddddd
204 uint16_t Populated_VDEs;
205 uint16_t Max_VDE_Supported;
207 struct ddf_vd_entry entry[0];
210 #define DDF_CR_INVALID 0xffffffff
212 struct ddf_vdc_record {
214 #define DDF_VDCR_SIGNATURE 0xeeeeeeee
218 uint32_t Sequence_Number;
220 uint16_t Primary_Element_Count;
222 uint8_t Primary_RAID_Level;
223 #define DDF_VDCR_RAID0 0x00
224 #define DDF_VDCR_RAID1 0x01
225 #define DDF_VDCR_RAID3 0x03
226 #define DDF_VDCR_RAID4 0x04
227 #define DDF_VDCR_RAID5 0x05
228 #define DDF_VDCR_RAID6 0x06
229 #define DDF_VDCR_RAID1E 0x11
230 #define DDF_VDCR_SINGLE 0x0f
231 #define DDF_VDCR_CONCAT 0x1f
232 #define DDF_VDCR_RAID5E 0x15
233 #define DDF_VDCR_RAID5EE 0x25
235 uint8_t Secondary_Element_Count;
236 uint8_t Secondary_Element_Seq;
237 uint8_t Secondary_RAID_Level;
238 uint64_t Block_Count;
241 uint32_t Associated_Spares[8];
242 uint64_t Cache_Flags;
243 #define DDF_VDCR_CACHE_WB (1 << 0)
244 #define DDF_VDCR_CACHE_WB_ADAPTIVE (1 << 1)
245 #define DDF_VDCR_CACHE_RA (1 << 2)
246 #define DDF_VDCR_CACHE_RA_ADAPTIVE (1 << 3)
247 #define DDF_VDCR_CACHE_WCACHE_NOBATTERY (1 << 4)
248 #define DDF_VDCR_CACHE_WCACHE_ALLOW (1 << 5)
249 #define DDF_VDCR_CACHE_RCACHE_ALLOW (1 << 6)
250 #define DDF_VDCR_CACHE_VENDOR (1 << 7)
259 uint8_t Vendor_Scratch[32];
260 uint32_t Physical_Disk_Sequence[0];
263 struct ddf_vuc_record {
265 #define DDF_VUCR_SIGNATURE 0x88888888
270 struct ddf_sa_entry {
272 uint16_t Secondary_Element;
276 struct ddf_sa_record {
278 #define DDF_SA_SIGNATURE 0x55555555
283 #define DDF_SAR_TYPE_DEDICATED (1 << 0)
284 #define DDF_SAR_TYPE_REVERTIBLE (1 << 1)
285 #define DDF_SAR_TYPE_ACTIVE (1 << 2)
286 #define DDF_SAR_TYPE_ENCL_AFFINITY (1 << 3)
287 uint16_t Populated_SAEs;
288 uint16_t MAX_SAE_Supported;
290 struct ddf_sa_entry entry[0];
293 struct ddf_pdd_record {
295 #define DDF_PDD_SIGNATURE 0x33333333
298 uint32_t PD_Reference;
299 uint8_t Forced_Ref_Flag;
300 #define DDF_PDD_FORCED_REF 0x01
301 uint8_t Forced_PD_GUID_Flag;
302 #define DDF_PDD_FORCED_GUID 0x01
303 uint8_t Vendor_Scratch[32];
307 struct ddf_bbm_entry {
308 uint64_t Defective_Block_Start;
309 uint32_t Spare_Block_Offset;
310 uint16_t Remapped_Count;
316 #define DDF_BBML_SIGNATURE 0xabadb10c
318 uint16_t Entry_Count;
319 uint32_t Spare_Block_Count;
321 uint64_t First_Spare_LBA;
322 uint64_t Mapped_Block_Entry[0];
325 struct ddf_vendor_log {
327 #define DDF_VENDOR_LOG_SIGNATURE 0x01dbeef0