File: sedopal_spec.h

package info (click to toggle)
nvme-cli 2.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,664 kB
  • sloc: ansic: 80,727; sh: 2,257; python: 975; makefile: 70; ruby: 25
file content (368 lines) | stat: -rw-r--r-- 9,697 bytes parent folder | download | duplicates (2)
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
/* SPDX-License-Identifier: GPL-2.0-or-later */

#ifndef _SED_OPAL_SPEC_H
#define _SED_OPAL_SPEC_H

#include <common.h>

/*
 * TCP Storage Architecture Core Specification Version 2.01
 * section 5.1.5 Method Status Codes
 */
enum sed_status_codes {
	SED_STATUS_SUCCESS =			0x00,
	SED_STATUS_NOT_AUTHORIZED =		0x01,
	SED_STATUS_OBSOLETE_1 =			0x02,
	SED_STATUS_SP_BUSY =			0x03,
	SED_STATUS_SP_FAILED =			0x04,
	SED_STATUS_SP_DISABLED =		0x05,
	SED_STATUS_SP_FROZEN =			0x06,
	SED_STATUS_NO_SESSIONS_AVAILABLE =	0x07,
	SED_STATUS_UNIQUENESS_CONFLICT =	0x08,
	SED_STATUS_INSUFFICIENT_SPACE =		0x09,
	SED_STATUS_INSUFFICIENT_ROWS =		0x0A,
	SED_STATUS_OBSOLETE_2 =			0x0B,
	SED_STATUS_INVALID_PARAMETER =		0x0C,
	SED_STATUS_OBSOLETE_3 =			0x0D,
	SED_STATUS_OBSOLETE_4 =			0x0E,
	SED_STATUS_TPER_MALFUNCTION =		0x0F,
	SED_STATUS_TRANSACTION_FAILURE =	0x10,
	SED_STATUS_RESPONSE_OVERFLOW =		0x11,
	SED_STATUS_AUTHORITY_LOCKED_OUT =	0x12,
	SED_STATUS_FAIL =			0x3F,
	SED_STATUS_NO_METHOD_STATUS =		0x89,
};

/*
 * level 0 feature flags
 */
#define OPAL_FEATURE_TPER                       0x0001
#define OPAL_FEATURE_LOCKING                    0x0002
#define OPAL_FEATURE_GEOMETRY                   0x0004
#define OPAL_FEATURE_OPALV1                     0x0008
#define OPAL_FEATURE_SINGLE_USER_MODE           0x0010
#define OPAL_FEATURE_DATA_STORE                 0x0020
#define OPAL_FEATURE_OPALV2                     0x0040
#define OPAL_FEATURE_OPALITE                    0x0080
#define OPAL_FEATURE_PYRITE_V1                  0x0100
#define OPAL_FEATURE_PYRITE_V2                  0x0200
#define OPAL_FEATURE_RUBY                       0x0400
#define OPAL_FEATURE_LOCKING_LBA                0x0800
#define OPAL_FEATURE_BLOCK_SID_AUTH             0x1000
#define OPAL_FEATURE_CONFIG_NS_LOCKING          0x2000
#define OPAL_FEATURE_DATA_REMOVAL               0x4000
#define OPAL_FEATURE_NS_GEOMETRY                0x8000

#define OPAL_SED_LOCKING_SUPPORT \
		(OPAL_FEATURE_OPALV1 | OPAL_FEATURE_OPALV2 |  \
		OPAL_FEATURE_RUBY | OPAL_FEATURE_PYRITE_V1 | \
		OPAL_FEATURE_PYRITE_V2 | OPAL_FEATURE_LOCKING)

/*
 * Definitions from TCG Opal Specification v2.0.2
 */

/*
 * level 0 feature codes - section 3.1.1
 */
#define OPAL_FEATURE_CODE_TPER                  0x0001
#define OPAL_FEATURE_CODE_LOCKING               0x0002
#define OPAL_FEATURE_CODE_GEOMETRY              0x0003

#define OPAL_FEATURE_CODE_OPALV1                0x0200
#define OPAL_FEATURE_CODE_SINGLE_USER_MODE      0x0201
#define OPAL_FEATURE_CODE_DATA_STORE            0x0202
#define OPAL_FEATURE_CODE_OPALV2                0x0203

#define OPAL_FEATURE_CODE_OPALITE               0x0301
#define OPAL_FEATURE_CODE_PYRITE_V1             0x0302
#define OPAL_FEATURE_CODE_PYRITE_V2             0x0303
#define OPAL_FEATURE_CODE_RUBY                  0x0304

#define OPAL_FEATURE_CODE_LOCKING_LBA           0x0401
#define OPAL_FEATURE_CODE_BLOCK_SID_AUTH        0x0402
#define OPAL_FEATURE_CODE_CONFIG_NS_LOCKING     0x0403
#define OPAL_FEATURE_CODE_DATA_REMOVAL          0x0404
#define OPAL_FEATURE_CODE_NS_GEOMETRY           0x0405

/* locking features */
#define OPAL_FEATURE_LOCKING_SUPPORTED		0x01
#define OPAL_FEATURE_LOCKING_ENABLED		0x02
#define OPAL_FEATURE_LOCKED			0x04
#define OPAL_FEATURE_MEDIA_ENCRYPT              0x08
#define OPAL_FEATURE_MBR_ENABLED                0x10
#define OPAL_FEATURE_MBR_DONE                   0x20

/*
 * discovery header as specified in section 3.1.1
 */
struct level_0_discovery_header {
	__be32		parameter_length;
	__be32		revision;
	__be64		reserved;
	uint8_t		vendor_specific[32];
} __packed;

/*
 * level 0 features as specified in section 3.1.1.3
 */
struct level_0_discovery_features {
	__be16		code;
	uint8_t		version;
	uint8_t		length;
} __packed;

#define TPER_FEATURE_SYNC       0x0001
#define TPER_FEATURE_ASYNC      0x0002
#define TPER_FEATURE_ACKNAK     0x0004
#define TPER_FEATURE_BUF_MGMT   0x0008
#define TPER_FEATURE_STREAMING  0x0010
#define TPER_FEATURE_COMID_MGMT 0x0040

/*
 * 3.1.1.2
 *
 * feature code 0x0001
 */
struct tper_desc {
	uint8_t         feature;
	uint8_t         reserved[11];
} __packed;

/*
 * 3.1.1.3
 *
 * feature code 0x0002
 */
struct locking_desc {
	uint8_t         features;
	uint8_t         reserved[11];
} __packed;

/*
 * 3.1.1.4
 *
 * feature code 0x0003
 */
#define GEOMETRY_ALIGNMENT_REQUIRED    0x01

struct geometry_reporting_desc {
	uint8_t         align;
	uint8_t         reserved[7];
	__be32          logical_block_size;
	__be64          alignment_granularity;
	__be64          lowest_aligned_lba;
} __packed;

/*
 * 3.1.1.5
 *
 * feature code 0x0203
 */
#define OPAL_V2_RANGE_CROSSING 0x01

struct opalv2_desc {
	__be16          base_comid;
	__be16          num_comids;
	uint8_t         flags;
	__be16          num_locking_sp_admin_auth;
	__be16          num_locking_sp_user_auth;
	uint8_t         initial_cpin_sid_ind;
	uint8_t         initial_cpin_sid_revert;
	uint8_t         reserved_future[5];
} __packed;

/*
 * 3.1.1.5
 *
 * feature code 0x0200
 */
struct opalv1_desc {
	__be16          base_comid;
	__be16          num_comids;
} __packed;

/*
 * TCG Opal SSC Feature Set v1.00 : Single User Mode
 * section 4.2.1
 *
 * feature code 0x0201
 */
#define SUM_FEATURE_ANY         0x0001
#define SUM_FEATURE_ALL         0x0002
#define SUM_FEATURE_POLICY      0x0004

struct single_user_mode_desc {
	__be32          num_locking_objects;
	uint8_t         flags;
	uint8_t         reserved[7];
} __packed;

/*
 * TCG Opal SSC Feature Set v1.00 : Additional DataStore Tables
 * section 4.2.1
 *
 * feature code 0x0202
 */
struct datastore_desc {
	__be16          reserved;
	__be16          max_tables;
	__be32          max_table_size;
	__be32          table_alignment;
} __packed;

/*
 * TCG Storage Security Subsystem Class: Opalite
 * section 3.1.1.4
 *
 * feature code 0x0301
 */
struct opalite_desc {
	__be16          base_comid;
	__be16          num_comids;
	uint8_t         reserved[5];
	uint8_t         initial_cpin_sid_ind;
	uint8_t         initial_cpin_sid_revert;
	uint8_t         reserved_future[5];
} __packed;

/*
 * TCG Storage Security Subsystem Class: Pyrite version 1
 * section 3.1.1.4
 *
 * feature code 0x0302
 */
struct pyrite_v1_desc {
	__be16          base_comid;
	__be16          num_comids;
	uint8_t         reserved[5];
	uint8_t         initial_cpin_sid_ind;
	uint8_t         initial_cpin_sid_revert;
	uint8_t         reserved_future[5];
} __packed;

/*
 * TCG Storage Security Subsystem Class: Pyrite version 2
 * section 3.1.1.4
 *
 * feature code 0x0303
 */
struct pyrite_v2_desc {
	__be16          base_comid;
	__be16          num_comids;
	uint8_t         reserved[5];
	uint8_t         initial_cpin_sid_ind;
	uint8_t         initial_cpin_sid_revert;
	uint8_t         reserved_future[5];
} __packed;

/*
 * TCG Ruby SSC Feature Set v1.00
 * section 3.1.1.5
 *
 * feature code 0x0304
 */
#define RUBY_RANGE_CROSSING    0x01

struct ruby_desc {
	__be16          base_comid;
	__be16          num_comids;
	uint8_t         flags;
	__be16          num_locking_sp_admin_auth;
	__be16          num_locking_sp_user_auth;
	uint8_t         initial_cpin_sid_ind;
	uint8_t         initial_cpin_sid_revert;
	uint8_t         reserved_future[5];
} __packed;

/*
 * TCG Storage Enterprise SSC Feature Set Locking LBA Ranges Control
 * section 4.1.1
 *
 * feature code 0x0401
 */
struct locking_lba_desc {
	uint8_t         reserved;
	uint8_t         reserved_range_control[11];
} __packed;

/*
 * TCG Storage Feature Set: Block SID Authentication
 * section 4.1.1
 *
 * feature code 0x0402
 */
#define BLOCK_SID_VALUE_STATE           0x0001
#define BLOCK_SID_BLOCKED_STATE         0x0002
#define BLOCK_SID_HW_RESET              0x0001

struct block_sid_auth_desc {
	uint8_t         states;
	uint8_t         hw_reset;
} __packed;

/*
 * TCG Storage Opal SSC Feature Set: Configurable Namespace Locking
 * section 4.2.1
 *
 * feature code 0x0403
 */
#define CONFIG_NS_RANGE_C               0x0080
#define CONFIG_NS_RANGE_P               0x0040

struct config_ns_desc {
	uint8_t         flags;
	uint8_t         reserved[3];
	__be32          max_key_count;
	__be32          unused_key_count;
	__be32          max_ranges_per_ns;
} __packed;

/*
 * TCG Storage Security Subsystem Class: Opal version 2.02
 * section 3.1.1.6
 *
 * feature code 0x0404
 */
#define DATA_REMOVAL_OPER_PROCESSING                    0x01
#define DATA_REMOVAL_OPER_INTERRUPTED                   0x02
#define DATA_REMOVAL_TIME_BIT0                          0x01
#define DATA_REMOVAL_TIME_BIT1                          0x02
#define DATA_REMOVAL_TIME_BIT2                          0x04
#define DATA_REMOVAL_TIME_BIT5                          0x20

#define DATA_REMOVAL_MECHANISM_OVERWRITE                0x01
#define DATA_REMOVAL_MECHANISM_BLOCK_ERASE              0x02
#define DATA_REMOVAL_MECHANISM_CRYPTO_ERASE             0x04
#define DATA_REMOVAL_MECHANISM_VENDOR_ERASE             0x10

struct data_removal_desc {
	uint8_t         reserved;
	uint8_t         flags;
	uint8_t         removal_mechanism;
	uint8_t         format;
	__be16          time_mechanism_bit0;
	__be16          time_mechanism_bit1;
	__be16          time_mechanism_bit2;
	uint8_t         reserved_mech[4];
	__be16          time_mechanism_bit5;
	uint8_t         future_reserved[16];
} __packed;

/*
 * TCG Storage Opal SSC Feature Set: Configurable Namespace Locking
 * section 4.2.1
 *
 * feature code 0x0405
 */
#define NS_GEOMETRY_ALIGNMENT_REQUIRED 0x01

struct ns_geometry_desc {
	uint8_t         align;
	uint8_t         reserved[7];
	__be32          logical_block_size;
	__be64          alignment_granularity;
	__be64          lowest_aligned_lba;
} __packed;

#endif /* _SED_OPAL_SPEC_H */