Loading...
1/*
2 * Copyright © 2016 Intel Corporation
3 *
4 * Authors:
5 * Rafael Antognolli <rafael.antognolli@intel.com>
6 * Scott Bauer <scott.bauer@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 */
17#include <linux/types.h>
18
19#ifndef _OPAL_PROTO_H
20#define _OPAL_PROTO_H
21
22/*
23 * These constant values come from:
24 * SPC-4 section
25 * 6.30 SECURITY PROTOCOL IN command / table 265.
26 */
27enum {
28 TCG_SECP_00 = 0,
29 TCG_SECP_01,
30};
31
32/*
33 * Token defs derived from:
34 * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
35 * 3.2.2 Data Stream Encoding
36 */
37enum opal_response_token {
38 OPAL_DTA_TOKENID_BYTESTRING = 0xe0,
39 OPAL_DTA_TOKENID_SINT = 0xe1,
40 OPAL_DTA_TOKENID_UINT = 0xe2,
41 OPAL_DTA_TOKENID_TOKEN = 0xe3, /* actual token is returned */
42 OPAL_DTA_TOKENID_INVALID = 0X0
43};
44
45#define DTAERROR_NO_METHOD_STATUS 0x89
46#define GENERIC_HOST_SESSION_NUM 0x41
47
48#define TPER_SYNC_SUPPORTED 0x01
49#define MBR_ENABLED_MASK 0x10
50
51#define TINY_ATOM_DATA_MASK 0x3F
52#define TINY_ATOM_SIGNED 0x40
53
54#define SHORT_ATOM_ID 0x80
55#define SHORT_ATOM_BYTESTRING 0x20
56#define SHORT_ATOM_SIGNED 0x10
57#define SHORT_ATOM_LEN_MASK 0xF
58
59#define MEDIUM_ATOM_ID 0xC0
60#define MEDIUM_ATOM_BYTESTRING 0x10
61#define MEDIUM_ATOM_SIGNED 0x8
62#define MEDIUM_ATOM_LEN_MASK 0x7
63
64#define LONG_ATOM_ID 0xe0
65#define LONG_ATOM_BYTESTRING 0x2
66#define LONG_ATOM_SIGNED 0x1
67
68/* Derived from TCG Core spec 2.01 Section:
69 * 3.2.2.1
70 * Data Type
71 */
72#define TINY_ATOM_BYTE 0x7F
73#define SHORT_ATOM_BYTE 0xBF
74#define MEDIUM_ATOM_BYTE 0xDF
75#define LONG_ATOM_BYTE 0xE3
76
77#define OPAL_INVAL_PARAM 12
78#define OPAL_MANUFACTURED_INACTIVE 0x08
79#define OPAL_DISCOVERY_COMID 0x0001
80
81#define LOCKING_RANGE_NON_GLOBAL 0x03
82/*
83 * User IDs used in the TCG storage SSCs
84 * Derived from: TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
85 * Section: 6.3 Assigned UIDs
86 */
87#define OPAL_UID_LENGTH 8
88#define OPAL_METHOD_LENGTH 8
89#define OPAL_MSID_KEYLEN 15
90#define OPAL_UID_LENGTH_HALF 4
91
92/* Enum to index OPALUID array */
93enum opal_uid {
94 /* users */
95 OPAL_SMUID_UID,
96 OPAL_THISSP_UID,
97 OPAL_ADMINSP_UID,
98 OPAL_LOCKINGSP_UID,
99 OPAL_ENTERPRISE_LOCKINGSP_UID,
100 OPAL_ANYBODY_UID,
101 OPAL_SID_UID,
102 OPAL_ADMIN1_UID,
103 OPAL_USER1_UID,
104 OPAL_USER2_UID,
105 OPAL_PSID_UID,
106 OPAL_ENTERPRISE_BANDMASTER0_UID,
107 OPAL_ENTERPRISE_ERASEMASTER_UID,
108 /* tables */
109 OPAL_LOCKINGRANGE_GLOBAL,
110 OPAL_LOCKINGRANGE_ACE_RDLOCKED,
111 OPAL_LOCKINGRANGE_ACE_WRLOCKED,
112 OPAL_MBRCONTROL,
113 OPAL_MBR,
114 OPAL_AUTHORITY_TABLE,
115 OPAL_C_PIN_TABLE,
116 OPAL_LOCKING_INFO_TABLE,
117 OPAL_ENTERPRISE_LOCKING_INFO_TABLE,
118 /* C_PIN_TABLE object ID's */
119 OPAL_C_PIN_MSID,
120 OPAL_C_PIN_SID,
121 OPAL_C_PIN_ADMIN1,
122 /* half UID's (only first 4 bytes used) */
123 OPAL_HALF_UID_AUTHORITY_OBJ_REF,
124 OPAL_HALF_UID_BOOLEAN_ACE,
125 /* omitted optional parameter */
126 OPAL_UID_HEXFF,
127};
128
129#define OPAL_METHOD_LENGTH 8
130
131/* Enum for indexing the OPALMETHOD array */
132enum opal_method {
133 OPAL_PROPERTIES,
134 OPAL_STARTSESSION,
135 OPAL_REVERT,
136 OPAL_ACTIVATE,
137 OPAL_EGET,
138 OPAL_ESET,
139 OPAL_NEXT,
140 OPAL_EAUTHENTICATE,
141 OPAL_GETACL,
142 OPAL_GENKEY,
143 OPAL_REVERTSP,
144 OPAL_GET,
145 OPAL_SET,
146 OPAL_AUTHENTICATE,
147 OPAL_RANDOM,
148 OPAL_ERASE,
149};
150
151enum opal_token {
152 /* Boolean */
153 OPAL_TRUE = 0x01,
154 OPAL_FALSE = 0x00,
155 OPAL_BOOLEAN_EXPR = 0x03,
156 /* cellblocks */
157 OPAL_TABLE = 0x00,
158 OPAL_STARTROW = 0x01,
159 OPAL_ENDROW = 0x02,
160 OPAL_STARTCOLUMN = 0x03,
161 OPAL_ENDCOLUMN = 0x04,
162 OPAL_VALUES = 0x01,
163 /* authority table */
164 OPAL_PIN = 0x03,
165 /* locking tokens */
166 OPAL_RANGESTART = 0x03,
167 OPAL_RANGELENGTH = 0x04,
168 OPAL_READLOCKENABLED = 0x05,
169 OPAL_WRITELOCKENABLED = 0x06,
170 OPAL_READLOCKED = 0x07,
171 OPAL_WRITELOCKED = 0x08,
172 OPAL_ACTIVEKEY = 0x0A,
173 /* locking info table */
174 OPAL_MAXRANGES = 0x04,
175 /* mbr control */
176 OPAL_MBRENABLE = 0x01,
177 OPAL_MBRDONE = 0x02,
178 /* properties */
179 OPAL_HOSTPROPERTIES = 0x00,
180 /* atoms */
181 OPAL_STARTLIST = 0xf0,
182 OPAL_ENDLIST = 0xf1,
183 OPAL_STARTNAME = 0xf2,
184 OPAL_ENDNAME = 0xf3,
185 OPAL_CALL = 0xf8,
186 OPAL_ENDOFDATA = 0xf9,
187 OPAL_ENDOFSESSION = 0xfa,
188 OPAL_STARTTRANSACTON = 0xfb,
189 OPAL_ENDTRANSACTON = 0xfC,
190 OPAL_EMPTYATOM = 0xff,
191 OPAL_WHERE = 0x00,
192};
193
194/* Locking state for a locking range */
195enum opal_lockingstate {
196 OPAL_LOCKING_READWRITE = 0x01,
197 OPAL_LOCKING_READONLY = 0x02,
198 OPAL_LOCKING_LOCKED = 0x03,
199};
200
201/* Packets derived from:
202 * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
203 * Secion: 3.2.3 ComPackets, Packets & Subpackets
204 */
205
206/* Comm Packet (header) for transmissions. */
207struct opal_compacket {
208 __be32 reserved0;
209 u8 extendedComID[4];
210 __be32 outstandingData;
211 __be32 minTransfer;
212 __be32 length;
213};
214
215/* Packet structure. */
216struct opal_packet {
217 __be32 tsn;
218 __be32 hsn;
219 __be32 seq_number;
220 __be16 reserved0;
221 __be16 ack_type;
222 __be32 acknowledgment;
223 __be32 length;
224};
225
226/* Data sub packet header */
227struct opal_data_subpacket {
228 u8 reserved0[6];
229 __be16 kind;
230 __be32 length;
231};
232
233/* header of a response */
234struct opal_header {
235 struct opal_compacket cp;
236 struct opal_packet pkt;
237 struct opal_data_subpacket subpkt;
238};
239
240#define FC_TPER 0x0001
241#define FC_LOCKING 0x0002
242#define FC_GEOMETRY 0x0003
243#define FC_ENTERPRISE 0x0100
244#define FC_DATASTORE 0x0202
245#define FC_SINGLEUSER 0x0201
246#define FC_OPALV100 0x0200
247#define FC_OPALV200 0x0203
248
249/*
250 * The Discovery 0 Header. As defined in
251 * Opal SSC Documentation
252 * Section: 3.3.5 Capability Discovery
253 */
254struct d0_header {
255 __be32 length; /* the length of the header 48 in 2.00.100 */
256 __be32 revision; /**< revision of the header 1 in 2.00.100 */
257 __be32 reserved01;
258 __be32 reserved02;
259 /*
260 * the remainder of the structure is vendor specific and will not be
261 * addressed now
262 */
263 u8 ignored[32];
264};
265
266/*
267 * TPer Feature Descriptor. Contains flags indicating support for the
268 * TPer features described in the OPAL specification. The names match the
269 * OPAL terminology
270 *
271 * code == 0x001 in 2.00.100
272 */
273struct d0_tper_features {
274 /*
275 * supported_features bits:
276 * bit 7: reserved
277 * bit 6: com ID management
278 * bit 5: reserved
279 * bit 4: streaming support
280 * bit 3: buffer management
281 * bit 2: ACK/NACK
282 * bit 1: async
283 * bit 0: sync
284 */
285 u8 supported_features;
286 /*
287 * bytes 5 through 15 are reserved, but we represent the first 3 as
288 * u8 to keep the other two 32bits integers aligned.
289 */
290 u8 reserved01[3];
291 __be32 reserved02;
292 __be32 reserved03;
293};
294
295/*
296 * Locking Feature Descriptor. Contains flags indicating support for the
297 * locking features described in the OPAL specification. The names match the
298 * OPAL terminology
299 *
300 * code == 0x0002 in 2.00.100
301 */
302struct d0_locking_features {
303 /*
304 * supported_features bits:
305 * bits 6-7: reserved
306 * bit 5: MBR done
307 * bit 4: MBR enabled
308 * bit 3: media encryption
309 * bit 2: locked
310 * bit 1: locking enabled
311 * bit 0: locking supported
312 */
313 u8 supported_features;
314 /*
315 * bytes 5 through 15 are reserved, but we represent the first 3 as
316 * u8 to keep the other two 32bits integers aligned.
317 */
318 u8 reserved01[3];
319 __be32 reserved02;
320 __be32 reserved03;
321};
322
323/*
324 * Geometry Feature Descriptor. Contains flags indicating support for the
325 * geometry features described in the OPAL specification. The names match the
326 * OPAL terminology
327 *
328 * code == 0x0003 in 2.00.100
329 */
330struct d0_geometry_features {
331 /*
332 * skip 32 bits from header, needed to align the struct to 64 bits.
333 */
334 u8 header[4];
335 /*
336 * reserved01:
337 * bits 1-6: reserved
338 * bit 0: align
339 */
340 u8 reserved01;
341 u8 reserved02[7];
342 __be32 logical_block_size;
343 __be64 alignment_granularity;
344 __be64 lowest_aligned_lba;
345};
346
347/*
348 * Enterprise SSC Feature
349 *
350 * code == 0x0100
351 */
352struct d0_enterprise_ssc {
353 __be16 baseComID;
354 __be16 numComIDs;
355 /* range_crossing:
356 * bits 1-6: reserved
357 * bit 0: range crossing
358 */
359 u8 range_crossing;
360 u8 reserved01;
361 __be16 reserved02;
362 __be32 reserved03;
363 __be32 reserved04;
364};
365
366/*
367 * Opal V1 feature
368 *
369 * code == 0x0200
370 */
371struct d0_opal_v100 {
372 __be16 baseComID;
373 __be16 numComIDs;
374};
375
376/*
377 * Single User Mode feature
378 *
379 * code == 0x0201
380 */
381struct d0_single_user_mode {
382 __be32 num_locking_objects;
383 /* reserved01:
384 * bit 0: any
385 * bit 1: all
386 * bit 2: policy
387 * bits 3-7: reserved
388 */
389 u8 reserved01;
390 u8 reserved02;
391 __be16 reserved03;
392 __be32 reserved04;
393};
394
395/*
396 * Additonal Datastores feature
397 *
398 * code == 0x0202
399 */
400struct d0_datastore_table {
401 __be16 reserved01;
402 __be16 max_tables;
403 __be32 max_size_tables;
404 __be32 table_size_alignment;
405};
406
407/*
408 * OPAL 2.0 feature
409 *
410 * code == 0x0203
411 */
412struct d0_opal_v200 {
413 __be16 baseComID;
414 __be16 numComIDs;
415 /* range_crossing:
416 * bits 1-6: reserved
417 * bit 0: range crossing
418 */
419 u8 range_crossing;
420 /* num_locking_admin_auth:
421 * not aligned to 16 bits, so use two u8.
422 * stored in big endian:
423 * 0: MSB
424 * 1: LSB
425 */
426 u8 num_locking_admin_auth[2];
427 /* num_locking_user_auth:
428 * not aligned to 16 bits, so use two u8.
429 * stored in big endian:
430 * 0: MSB
431 * 1: LSB
432 */
433 u8 num_locking_user_auth[2];
434 u8 initialPIN;
435 u8 revertedPIN;
436 u8 reserved01;
437 __be32 reserved02;
438};
439
440/* Union of features used to parse the discovery 0 response */
441struct d0_features {
442 __be16 code;
443 /*
444 * r_version bits:
445 * bits 4-7: version
446 * bits 0-3: reserved
447 */
448 u8 r_version;
449 u8 length;
450 u8 features[];
451};
452
453#endif /* _OPAL_PROTO_H */
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright © 2016 Intel Corporation
4 *
5 * Authors:
6 * Rafael Antognolli <rafael.antognolli@intel.com>
7 * Scott Bauer <scott.bauer@intel.com>
8 */
9#include <linux/types.h>
10
11#ifndef _OPAL_PROTO_H
12#define _OPAL_PROTO_H
13
14/*
15 * These constant values come from:
16 * SPC-4 section
17 * 6.30 SECURITY PROTOCOL IN command / table 265.
18 */
19enum {
20 TCG_SECP_00 = 0,
21 TCG_SECP_01,
22};
23
24/*
25 * Token defs derived from:
26 * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
27 * 3.2.2 Data Stream Encoding
28 */
29enum opal_response_token {
30 OPAL_DTA_TOKENID_BYTESTRING = 0xe0,
31 OPAL_DTA_TOKENID_SINT = 0xe1,
32 OPAL_DTA_TOKENID_UINT = 0xe2,
33 OPAL_DTA_TOKENID_TOKEN = 0xe3, /* actual token is returned */
34 OPAL_DTA_TOKENID_INVALID = 0X0
35};
36
37#define DTAERROR_NO_METHOD_STATUS 0x89
38#define GENERIC_HOST_SESSION_NUM 0x41
39#define FIRST_TPER_SESSION_NUM 4096
40
41#define TPER_SYNC_SUPPORTED 0x01
42#define MBR_ENABLED_MASK 0x10
43
44#define TINY_ATOM_DATA_MASK 0x3F
45#define TINY_ATOM_SIGNED 0x40
46
47#define SHORT_ATOM_ID 0x80
48#define SHORT_ATOM_BYTESTRING 0x20
49#define SHORT_ATOM_SIGNED 0x10
50#define SHORT_ATOM_LEN_MASK 0xF
51
52#define MEDIUM_ATOM_ID 0xC0
53#define MEDIUM_ATOM_BYTESTRING 0x10
54#define MEDIUM_ATOM_SIGNED 0x8
55#define MEDIUM_ATOM_LEN_MASK 0x7
56
57#define LONG_ATOM_ID 0xe0
58#define LONG_ATOM_BYTESTRING 0x2
59#define LONG_ATOM_SIGNED 0x1
60
61/* Derived from TCG Core spec 2.01 Section:
62 * 3.2.2.1
63 * Data Type
64 */
65#define TINY_ATOM_BYTE 0x7F
66#define SHORT_ATOM_BYTE 0xBF
67#define MEDIUM_ATOM_BYTE 0xDF
68#define LONG_ATOM_BYTE 0xE3
69
70#define OPAL_INVAL_PARAM 12
71#define OPAL_MANUFACTURED_INACTIVE 0x08
72#define OPAL_DISCOVERY_COMID 0x0001
73
74#define LOCKING_RANGE_NON_GLOBAL 0x03
75/*
76 * User IDs used in the TCG storage SSCs
77 * Derived from: TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
78 * Section: 6.3 Assigned UIDs
79 */
80#define OPAL_METHOD_LENGTH 8
81#define OPAL_MSID_KEYLEN 15
82#define OPAL_UID_LENGTH_HALF 4
83
84/* Enum to index OPALUID array */
85enum opal_uid {
86 /* users */
87 OPAL_SMUID_UID,
88 OPAL_THISSP_UID,
89 OPAL_ADMINSP_UID,
90 OPAL_LOCKINGSP_UID,
91 OPAL_ENTERPRISE_LOCKINGSP_UID,
92 OPAL_ANYBODY_UID,
93 OPAL_SID_UID,
94 OPAL_ADMIN1_UID,
95 OPAL_USER1_UID,
96 OPAL_USER2_UID,
97 OPAL_PSID_UID,
98 OPAL_ENTERPRISE_BANDMASTER0_UID,
99 OPAL_ENTERPRISE_ERASEMASTER_UID,
100 /* tables */
101 OPAL_TABLE_TABLE,
102 OPAL_LOCKINGRANGE_GLOBAL,
103 OPAL_LOCKINGRANGE_ACE_RDLOCKED,
104 OPAL_LOCKINGRANGE_ACE_WRLOCKED,
105 OPAL_MBRCONTROL,
106 OPAL_MBR,
107 OPAL_AUTHORITY_TABLE,
108 OPAL_C_PIN_TABLE,
109 OPAL_LOCKING_INFO_TABLE,
110 OPAL_ENTERPRISE_LOCKING_INFO_TABLE,
111 OPAL_DATASTORE,
112 /* C_PIN_TABLE object ID's */
113 OPAL_C_PIN_MSID,
114 OPAL_C_PIN_SID,
115 OPAL_C_PIN_ADMIN1,
116 /* half UID's (only first 4 bytes used) */
117 OPAL_HALF_UID_AUTHORITY_OBJ_REF,
118 OPAL_HALF_UID_BOOLEAN_ACE,
119 /* omitted optional parameter */
120 OPAL_UID_HEXFF,
121};
122
123/* Enum for indexing the OPALMETHOD array */
124enum opal_method {
125 OPAL_PROPERTIES,
126 OPAL_STARTSESSION,
127 OPAL_REVERT,
128 OPAL_ACTIVATE,
129 OPAL_EGET,
130 OPAL_ESET,
131 OPAL_NEXT,
132 OPAL_EAUTHENTICATE,
133 OPAL_GETACL,
134 OPAL_GENKEY,
135 OPAL_REVERTSP,
136 OPAL_GET,
137 OPAL_SET,
138 OPAL_AUTHENTICATE,
139 OPAL_RANDOM,
140 OPAL_ERASE,
141};
142
143enum opal_token {
144 /* Boolean */
145 OPAL_TRUE = 0x01,
146 OPAL_FALSE = 0x00,
147 OPAL_BOOLEAN_EXPR = 0x03,
148 /* cellblocks */
149 OPAL_TABLE = 0x00,
150 OPAL_STARTROW = 0x01,
151 OPAL_ENDROW = 0x02,
152 OPAL_STARTCOLUMN = 0x03,
153 OPAL_ENDCOLUMN = 0x04,
154 OPAL_VALUES = 0x01,
155 /* table table */
156 OPAL_TABLE_UID = 0x00,
157 OPAL_TABLE_NAME = 0x01,
158 OPAL_TABLE_COMMON = 0x02,
159 OPAL_TABLE_TEMPLATE = 0x03,
160 OPAL_TABLE_KIND = 0x04,
161 OPAL_TABLE_COLUMN = 0x05,
162 OPAL_TABLE_COLUMNS = 0x06,
163 OPAL_TABLE_ROWS = 0x07,
164 OPAL_TABLE_ROWS_FREE = 0x08,
165 OPAL_TABLE_ROW_BYTES = 0x09,
166 OPAL_TABLE_LASTID = 0x0A,
167 OPAL_TABLE_MIN = 0x0B,
168 OPAL_TABLE_MAX = 0x0C,
169 /* authority table */
170 OPAL_PIN = 0x03,
171 /* locking tokens */
172 OPAL_RANGESTART = 0x03,
173 OPAL_RANGELENGTH = 0x04,
174 OPAL_READLOCKENABLED = 0x05,
175 OPAL_WRITELOCKENABLED = 0x06,
176 OPAL_READLOCKED = 0x07,
177 OPAL_WRITELOCKED = 0x08,
178 OPAL_ACTIVEKEY = 0x0A,
179 /* lockingsp table */
180 OPAL_LIFECYCLE = 0x06,
181 /* locking info table */
182 OPAL_MAXRANGES = 0x04,
183 /* mbr control */
184 OPAL_MBRENABLE = 0x01,
185 OPAL_MBRDONE = 0x02,
186 /* properties */
187 OPAL_HOSTPROPERTIES = 0x00,
188 /* atoms */
189 OPAL_STARTLIST = 0xf0,
190 OPAL_ENDLIST = 0xf1,
191 OPAL_STARTNAME = 0xf2,
192 OPAL_ENDNAME = 0xf3,
193 OPAL_CALL = 0xf8,
194 OPAL_ENDOFDATA = 0xf9,
195 OPAL_ENDOFSESSION = 0xfa,
196 OPAL_STARTTRANSACTON = 0xfb,
197 OPAL_ENDTRANSACTON = 0xfC,
198 OPAL_EMPTYATOM = 0xff,
199 OPAL_WHERE = 0x00,
200};
201
202/* Locking state for a locking range */
203enum opal_lockingstate {
204 OPAL_LOCKING_READWRITE = 0x01,
205 OPAL_LOCKING_READONLY = 0x02,
206 OPAL_LOCKING_LOCKED = 0x03,
207};
208
209enum opal_parameter {
210 OPAL_SUM_SET_LIST = 0x060000,
211};
212
213/* Packets derived from:
214 * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
215 * Secion: 3.2.3 ComPackets, Packets & Subpackets
216 */
217
218/* Comm Packet (header) for transmissions. */
219struct opal_compacket {
220 __be32 reserved0;
221 u8 extendedComID[4];
222 __be32 outstandingData;
223 __be32 minTransfer;
224 __be32 length;
225};
226
227/* Packet structure. */
228struct opal_packet {
229 __be32 tsn;
230 __be32 hsn;
231 __be32 seq_number;
232 __be16 reserved0;
233 __be16 ack_type;
234 __be32 acknowledgment;
235 __be32 length;
236};
237
238/* Data sub packet header */
239struct opal_data_subpacket {
240 u8 reserved0[6];
241 __be16 kind;
242 __be32 length;
243};
244
245/* header of a response */
246struct opal_header {
247 struct opal_compacket cp;
248 struct opal_packet pkt;
249 struct opal_data_subpacket subpkt;
250};
251
252#define FC_TPER 0x0001
253#define FC_LOCKING 0x0002
254#define FC_GEOMETRY 0x0003
255#define FC_ENTERPRISE 0x0100
256#define FC_DATASTORE 0x0202
257#define FC_SINGLEUSER 0x0201
258#define FC_OPALV100 0x0200
259#define FC_OPALV200 0x0203
260
261/*
262 * The Discovery 0 Header. As defined in
263 * Opal SSC Documentation
264 * Section: 3.3.5 Capability Discovery
265 */
266struct d0_header {
267 __be32 length; /* the length of the header 48 in 2.00.100 */
268 __be32 revision; /**< revision of the header 1 in 2.00.100 */
269 __be32 reserved01;
270 __be32 reserved02;
271 /*
272 * the remainder of the structure is vendor specific and will not be
273 * addressed now
274 */
275 u8 ignored[32];
276};
277
278/*
279 * TPer Feature Descriptor. Contains flags indicating support for the
280 * TPer features described in the OPAL specification. The names match the
281 * OPAL terminology
282 *
283 * code == 0x001 in 2.00.100
284 */
285struct d0_tper_features {
286 /*
287 * supported_features bits:
288 * bit 7: reserved
289 * bit 6: com ID management
290 * bit 5: reserved
291 * bit 4: streaming support
292 * bit 3: buffer management
293 * bit 2: ACK/NACK
294 * bit 1: async
295 * bit 0: sync
296 */
297 u8 supported_features;
298 /*
299 * bytes 5 through 15 are reserved, but we represent the first 3 as
300 * u8 to keep the other two 32bits integers aligned.
301 */
302 u8 reserved01[3];
303 __be32 reserved02;
304 __be32 reserved03;
305};
306
307/*
308 * Locking Feature Descriptor. Contains flags indicating support for the
309 * locking features described in the OPAL specification. The names match the
310 * OPAL terminology
311 *
312 * code == 0x0002 in 2.00.100
313 */
314struct d0_locking_features {
315 /*
316 * supported_features bits:
317 * bits 6-7: reserved
318 * bit 5: MBR done
319 * bit 4: MBR enabled
320 * bit 3: media encryption
321 * bit 2: locked
322 * bit 1: locking enabled
323 * bit 0: locking supported
324 */
325 u8 supported_features;
326 /*
327 * bytes 5 through 15 are reserved, but we represent the first 3 as
328 * u8 to keep the other two 32bits integers aligned.
329 */
330 u8 reserved01[3];
331 __be32 reserved02;
332 __be32 reserved03;
333};
334
335/*
336 * Geometry Feature Descriptor. Contains flags indicating support for the
337 * geometry features described in the OPAL specification. The names match the
338 * OPAL terminology
339 *
340 * code == 0x0003 in 2.00.100
341 */
342struct d0_geometry_features {
343 /*
344 * skip 32 bits from header, needed to align the struct to 64 bits.
345 */
346 u8 header[4];
347 /*
348 * reserved01:
349 * bits 1-6: reserved
350 * bit 0: align
351 */
352 u8 reserved01;
353 u8 reserved02[7];
354 __be32 logical_block_size;
355 __be64 alignment_granularity;
356 __be64 lowest_aligned_lba;
357};
358
359/*
360 * Enterprise SSC Feature
361 *
362 * code == 0x0100
363 */
364struct d0_enterprise_ssc {
365 __be16 baseComID;
366 __be16 numComIDs;
367 /* range_crossing:
368 * bits 1-6: reserved
369 * bit 0: range crossing
370 */
371 u8 range_crossing;
372 u8 reserved01;
373 __be16 reserved02;
374 __be32 reserved03;
375 __be32 reserved04;
376};
377
378/*
379 * Opal V1 feature
380 *
381 * code == 0x0200
382 */
383struct d0_opal_v100 {
384 __be16 baseComID;
385 __be16 numComIDs;
386};
387
388/*
389 * Single User Mode feature
390 *
391 * code == 0x0201
392 */
393struct d0_single_user_mode {
394 __be32 num_locking_objects;
395 /* reserved01:
396 * bit 0: any
397 * bit 1: all
398 * bit 2: policy
399 * bits 3-7: reserved
400 */
401 u8 reserved01;
402 u8 reserved02;
403 __be16 reserved03;
404 __be32 reserved04;
405};
406
407/*
408 * Additonal Datastores feature
409 *
410 * code == 0x0202
411 */
412struct d0_datastore_table {
413 __be16 reserved01;
414 __be16 max_tables;
415 __be32 max_size_tables;
416 __be32 table_size_alignment;
417};
418
419/*
420 * OPAL 2.0 feature
421 *
422 * code == 0x0203
423 */
424struct d0_opal_v200 {
425 __be16 baseComID;
426 __be16 numComIDs;
427 /* range_crossing:
428 * bits 1-6: reserved
429 * bit 0: range crossing
430 */
431 u8 range_crossing;
432 /* num_locking_admin_auth:
433 * not aligned to 16 bits, so use two u8.
434 * stored in big endian:
435 * 0: MSB
436 * 1: LSB
437 */
438 u8 num_locking_admin_auth[2];
439 /* num_locking_user_auth:
440 * not aligned to 16 bits, so use two u8.
441 * stored in big endian:
442 * 0: MSB
443 * 1: LSB
444 */
445 u8 num_locking_user_auth[2];
446 u8 initialPIN;
447 u8 revertedPIN;
448 u8 reserved01;
449 __be32 reserved02;
450};
451
452/* Union of features used to parse the discovery 0 response */
453struct d0_features {
454 __be16 code;
455 /*
456 * r_version bits:
457 * bits 4-7: version
458 * bits 0-3: reserved
459 */
460 u8 r_version;
461 u8 length;
462 u8 features[];
463};
464
465#endif /* _OPAL_PROTO_H */