summaryrefslogtreecommitdiffstats
path: root/sys/dev/ata/ata-raid-ddf.h
blob: 30326bc3ff7afa47760b9fb1be24fffe3b252bad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
/*-
 * Copyright (c) 2008 Scott Long
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer,
 *    without modification, immediately at the beginning of the file.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * $FreeBSD$
 */

#ifndef ATA_RAID_DDF_H
#define ATA_RAID_DDF_H

/* Definitions from the SNIA DDF spec, rev 1.2 */

#define	DDF_HEADER_LENGTH		512
struct ddf_header {
	uint32_t	Signature;
#define	DDF_HEADER_SIGNATURE	0xde11de11
	uint32_t	CRC;
	uint8_t		DDF_Header_GUID[24];
	uint8_t		DDF_rev[8];
	uint32_t	Sequence_Number;
	uint32_t	TimeStamp;
	uint8_t		Open_Flag;
#define	DDF_HEADER_CLOSED	0x00
#define	DDF_HEADER_OPENED_MASK	0x0f
#define	DDF_HEADER_OPEN_ANCHOR	0xff
	uint8_t		Foreign_Flag;
	uint8_t		Diskgrouping;
	uint8_t		pad1[13];
	uint8_t		Header_ext[32];
	uint64_t	Primary_Header_LBA;
	uint64_t	Secondary_Header_LBA;
	uint8_t		Header_Type;
#define	DDF_HEADER_ANCHOR	0x00
#define	DDF_HEADER_PRIMARY	0x01
#define	DDF_HEADER_SECONDARY	0x02
	uint8_t		pad2[3];
	uint32_t	WorkSpace_Length;
	uint64_t	WorkSpace_LBA;
	uint16_t	Max_PD_Entries;
	uint16_t	Max_VD_Entries;
	uint16_t	Max_Partitions;
	uint16_t	Configuration_Record_Length;
	uint16_t	Max_Primary_Element_Entries;
	uint8_t		pad3[54];
	uint32_t	cd_section;	/* Controller_Data_Section */
	uint32_t	cd_length;	/* Controller_Data_Section_Length */
	uint32_t	pdr_section;	/* Physical_Drive_Records_Section */
	uint32_t	pdr_length;	/* Physical_Drive_Records_Length */
	uint32_t	vdr_section;	/* Virtual_Drive_Records_Section */
	uint32_t	vdr_length;	/* Virtual_Drive_Records_Length */
	uint32_t	cr_section;	/* Configuration_Records_Section */
	uint32_t	cr_length;	/* Configuration_Records_Length */
	uint32_t	pdd_section;	/* Physical_Drive_Data_Section */
	uint32_t	pdd_length;	/* Physical_Drive_Data_Length */
	uint32_t	bbmlog_section;	/* BBM_Log_Section */
	uint32_t	bbmlog_length;	/* BBM_Log_Section_Length */
	uint32_t	Diagnostic_Space;
	uint32_t	Diagnostic_Space_Length;
	uint32_t	Vendor_Specific_Logs;
	uint32_t	Vendor_Specific_Logs_Length;
	uint8_t		pad4[256];
} __packed;

struct ddf_cd_record {
	uint32_t	Signature;
#define	DDF_CONTROLLER_DATA_SIGNATURE	0xad111111
	uint32_t	CRC;
	uint8_t		Controller_GUID[24];
	struct {
		uint16_t	Vendor_ID;
		uint16_t	Device_ID;
		uint16_t	SubVendor_ID;
		uint16_t	SubDevice_ID;
	} Controller_Type __packed;
	uint8_t		Product_ID[16];
	uint8_t		pad1[8];
	uint8_t		Controller_Data[448];
} __packed;

struct ddf_device_scsi {
	uint8_t		Lun;
	uint8_t		Id;
	uint8_t		Channel;
	uint8_t		Path_Flags;
#define DDF_DEVICE_SCSI_FLAG_BROKEN	(1 << 7)
} __packed;

struct ddf_device_sas {
	uint64_t	Initiator_Path;
} __packed;

union ddf_pathinfo {
	struct {
		struct ddf_device_scsi	Path0;
		struct ddf_device_scsi	Path1;
		uint8_t			pad[10];
	} __packed scsi;
	struct {
		struct ddf_device_sas	Path0;
		struct ddf_device_sas	Path1;
		uint8_t			Path0_Flags;
		uint8_t			Path1_Flags;
#define DDF_DEVICE_SAS_FLAG_BROKEN	(1 << 7)
	} __packed sas;
} __packed;

struct ddf_pd_entry {
	uint8_t			PD_GUID[24];
	uint32_t		PD_Reference;
	uint16_t		PD_Type;
#define	DDF_PDE_GUID_FORCE	(1 << 0)
#define	DDF_PDE_PARTICIPATING	(1 << 1)
#define	DDF_PDE_GLOBAL_SPARE	(1 << 2)
#define	DDF_PDE_CONFIG_SPARE	(1 << 3)
#define	DDF_PDE_FOREIGN		(1 << 4)
#define	DDF_PDE_LEGACY		(1 << 5)
#define DDF_PDE_TYPE_MASK	(0x0f << 12)
#define DDF_PDE_UNKNOWN		(0x00 << 12)
#define DDF_PDE_SCSI		(0x01 << 12)
#define DDF_PDE_SAS		(0x02 << 12)
#define DDF_PDE_SATA		(0x03 << 12)
#define DDF_PDE_FC		(0x04 << 12)
	uint16_t		PD_State;
#define	DDF_PDE_ONLINE		(1 << 0)
#define	DDF_PDE_FAILED		(1 << 1)
#define	DDF_PDE_REBUILD		(1 << 2)
#define	DDF_PDE_TRANSITION	(1 << 3)
#define	DDF_PDE_PFA		(1 << 4)
#define	DDF_PDE_UNRECOVERED	(1 << 5)
#define	DDF_PDE_MISSING		(1 << 6)
	uint64_t		Configured_Size;
	union ddf_pathinfo	Path_Information;
	uint8_t			pad1[6];
} __packed;

struct ddf_pd_record {
	uint32_t		Signature;
#define	DDF_PDR_SIGNATURE	0x22222222
	uint32_t		CRC;
	uint16_t		Populated_PDEs;
	uint16_t		Max_PDE_Supported;
	uint8_t			pad1[52];
	struct ddf_pd_entry	entry[0];
} __packed;

struct ddf_vd_entry {
	uint8_t			VD_GUID[24];
	uint16_t		VD_Number;
	uint8_t			pad1[2];
	uint16_t		VD_Type;
#define DDF_VDE_SHARED		(1 << 0)
#define	DDF_VDE_ENFORCE_GROUP	(1 << 1)
#define	DDF_VDE_UNICODE_NAME	(1 << 2)
#define	DDF_VDE_OWNER_ID_VALID	(1 << 3)
	uint16_t		Controller_GUID_CRC;
	uint8_t			VD_State;
#define	DDF_VDE_OPTIMAL		0x00
#define	DDF_VDE_DEGRADED	0x01
#define	DDF_VDE_DELETED		0x02
#define	DDF_VDE_MISSING		0x03
#define	DDF_VDE_FAILED		0x04
#define DDF_VDE_PARTIAL		0x05
#define	DDF_VDE_STATE_MASK	0x07
#define	DDF_VDE_MORPH		(1 << 3)
#define	DDF_VDE_DIRTY		(1 << 4)
	uint8_t			Init_State;
#define	DDF_VDE_UNINTIALIZED	0x00
#define	DDF_VDE_INIT_QUICK	0x01
#define	DDF_VDE_INIT_FULL	0x02
#define	DDF_VDE_INIT_MASK	0x03
#define	DDF_VDE_UACCESS_RW	0x00
#define	DDF_VDE_UACCESS_RO	0x80
#define	DDF_VDE_UACCESS_BLOCKED	0xc0
#define	DDF_VDE_UACCESS_MASK	0xc0
	uint8_t			pad2[14];
	uint8_t			VD_Name[16];
} __packed;

struct ddf_vd_record {
	uint32_t		Signature;
#define	DDF_VD_RECORD_SIGNATURE	0xdddddddd
	uint32_t		CRC;
	uint16_t		Populated_VDEs;
	uint16_t		Max_VDE_Supported;
	uint8_t			pad1[52];
	struct ddf_vd_entry	entry[0];
} __packed;

#define DDF_CR_INVALID		0xffffffff

struct ddf_vdc_record {
	uint32_t	Signature;
#define	DDF_VDCR_SIGNATURE	0xeeeeeeee
	uint32_t	CRC;
	uint8_t		VD_GUID[24];
	uint32_t	Timestamp;
	uint32_t	Sequence_Number;
	uint8_t		pad1[24];
	uint16_t	Primary_Element_Count;
	uint8_t		Stripe_Size;
	uint8_t		Primary_RAID_Level;
#define DDF_VDCR_RAID0		0x00
#define DDF_VDCR_RAID1		0x01
#define DDF_VDCR_RAID3		0x03
#define DDF_VDCR_RAID4		0x04
#define DDF_VDCR_RAID5		0x05
#define DDF_VDCR_RAID6		0x06
#define DDF_VDCR_RAID1E		0x11
#define DDF_VDCR_SINGLE		0x0f
#define DDF_VDCR_CONCAT		0x1f
#define DDF_VDCR_RAID5E		0x15
#define DDF_VDCR_RAID5EE	0x25
	uint8_t		RLQ;
	uint8_t		Secondary_Element_Count;
	uint8_t		Secondary_Element_Seq;
	uint8_t		Secondary_RAID_Level;
	uint64_t	Block_Count;
	uint64_t	VD_Size;
	uint8_t		pad2[8];
	uint32_t	Associated_Spares[8];
	uint64_t	Cache_Flags;
#define DDF_VDCR_CACHE_WB		(1 << 0)
#define	DDF_VDCR_CACHE_WB_ADAPTIVE	(1 << 1)
#define	DDF_VDCR_CACHE_RA		(1 << 2)
#define	DDF_VDCR_CACHE_RA_ADAPTIVE	(1 << 3)
#define	DDF_VDCR_CACHE_WCACHE_NOBATTERY	(1 << 4)
#define	DDF_VDCR_CACHE_WCACHE_ALLOW	(1 << 5)
#define	DDF_VDCR_CACHE_RCACHE_ALLOW	(1 << 6)
#define	DDF_VDCR_CACHE_VENDOR		(1 << 7)
	uint8_t		BG_Rate;
	uint8_t		pad3[3];
	uint8_t		pad4[52];
	uint8_t		pad5[192];
	uint8_t		V0[32];
	uint8_t		V1[32];
	uint8_t		V2[16];
	uint8_t		V3[16];
	uint8_t		Vendor_Scratch[32];
	uint32_t	Physical_Disk_Sequence[0];
} __packed;

struct ddf_vuc_record {
	uint32_t	Signature;
#define	DDF_VUCR_SIGNATURE	0x88888888
	uint32_t	CRC;
	uint8_t		VD_GUID[24];
} __packed;

struct ddf_sa_entry {
	uint8_t		VD_GUID[24];
	uint16_t	Secondary_Element;
	uint8_t		rsrvd2[6];
} __packed;

struct ddf_sa_record {
	uint32_t	Signature;
#define	DDF_SA_SIGNATURE	0x55555555
	uint32_t	CRC;
	uint32_t	Timestamp;
	uint8_t		pad1[7];
	uint8_t		Spare_Type;
#define	DDF_SAR_TYPE_DEDICATED		(1 << 0)
#define	DDF_SAR_TYPE_REVERTIBLE		(1 << 1)
#define	DDF_SAR_TYPE_ACTIVE		(1 << 2)
#define	DDF_SAR_TYPE_ENCL_AFFINITY	(1 << 3)
	uint16_t	Populated_SAEs;
	uint16_t	MAX_SAE_Supported;
	uint8_t		pad2[8];
	struct ddf_sa_entry	entry[0];
} __packed;

struct ddf_pdd_record {
	uint32_t	Signature;
#define	DDF_PDD_SIGNATURE	0x33333333
	uint32_t	CRC;
	uint8_t		PD_GUID[24];
	uint32_t	PD_Reference;
	uint8_t		Forced_Ref_Flag;
#define	DDF_PDD_FORCED_REF	0x01
	uint8_t		Forced_PD_GUID_Flag;
#define	DDF_PDD_FORCED_GUID	0x01
	uint8_t		Vendor_Scratch[32];
	uint8_t		pad2[442];
} __packed;

struct ddf_bbm_entry {
	uint64_t	Defective_Block_Start;
	uint32_t	Spare_Block_Offset;
	uint16_t	Remapped_Count;
	uint8_t	pad[2];
};

struct ddf_bbm_log {
	uint32_t	Signature;
#define	DDF_BBML_SIGNATURE	0xabadb10c
	uint32_t	CRC;
	uint16_t	Entry_Count;
	uint32_t	Spare_Block_Count;
	uint8_t		pad1[10];
	uint64_t	First_Spare_LBA;
	uint64_t	Mapped_Block_Entry[0];
} __packed;

struct ddf_vendor_log {
	uint32_t	Signature;
#define	DDF_VENDOR_LOG_SIGNATURE	0x01dbeef0
	uint32_t	CRC;
	uint64_t	Log_Owner;
	uint8_t		pad1[16];
} __packed;

#endif
OpenPOWER on IntegriCloud