1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright © 2016 Intel Corporation
6 * Rafael Antognolli <rafael.antognolli@intel.com>
7 * Scott Bauer <scott.bauer@intel.com>
9 #include <linux/types.h>
15 * These constant values come from:
17 * 6.30 SECURITY PROTOCOL IN command / table 265.
25 * Token defs derived from:
26 * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
27 * 3.2.2 Data Stream Encoding
29 enum 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
37 #define DTAERROR_NO_METHOD_STATUS 0x89
38 #define GENERIC_HOST_SESSION_NUM 0x41
39 #define FIRST_TPER_SESSION_NUM 4096
41 #define TPER_SYNC_SUPPORTED 0x01
42 /* FC_LOCKING features */
43 #define LOCKING_SUPPORTED_MASK 0x01
44 #define LOCKING_ENABLED_MASK 0x02
45 #define LOCKED_MASK 0x04
46 #define MBR_ENABLED_MASK 0x10
47 #define MBR_DONE_MASK 0x20
49 #define TINY_ATOM_DATA_MASK 0x3F
50 #define TINY_ATOM_SIGNED 0x40
52 #define SHORT_ATOM_ID 0x80
53 #define SHORT_ATOM_BYTESTRING 0x20
54 #define SHORT_ATOM_SIGNED 0x10
55 #define SHORT_ATOM_LEN_MASK 0xF
57 #define MEDIUM_ATOM_ID 0xC0
58 #define MEDIUM_ATOM_BYTESTRING 0x10
59 #define MEDIUM_ATOM_SIGNED 0x8
60 #define MEDIUM_ATOM_LEN_MASK 0x7
62 #define LONG_ATOM_ID 0xe0
63 #define LONG_ATOM_BYTESTRING 0x2
64 #define LONG_ATOM_SIGNED 0x1
66 /* Derived from TCG Core spec 2.01 Section:
70 #define TINY_ATOM_BYTE 0x7F
71 #define SHORT_ATOM_BYTE 0xBF
72 #define MEDIUM_ATOM_BYTE 0xDF
73 #define LONG_ATOM_BYTE 0xE3
74 #define EMPTY_ATOM_BYTE 0xFF
76 #define OPAL_INVAL_PARAM 12
77 #define OPAL_MANUFACTURED_INACTIVE 0x08
78 #define OPAL_DISCOVERY_COMID 0x0001
80 #define LOCKING_RANGE_NON_GLOBAL 0x03
82 * User IDs used in the TCG storage SSCs
83 * Derived from: TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
84 * Section: 6.3 Assigned UIDs
86 #define OPAL_METHOD_LENGTH 8
87 #define OPAL_MSID_KEYLEN 15
88 #define OPAL_UID_LENGTH_HALF 4
91 * Boolean operators from TCG Core spec 2.01 Section:
95 #define OPAL_BOOLEAN_AND 0
96 #define OPAL_BOOLEAN_OR 1
97 #define OPAL_BOOLEAN_NOT 2
99 /* Enum to index OPALUID array */
106 OPAL_ENTERPRISE_LOCKINGSP_UID
,
113 OPAL_ENTERPRISE_BANDMASTER0_UID
,
114 OPAL_ENTERPRISE_ERASEMASTER_UID
,
117 OPAL_LOCKINGRANGE_GLOBAL
,
118 OPAL_LOCKINGRANGE_ACE_START_TO_KEY
,
119 OPAL_LOCKINGRANGE_ACE_RDLOCKED
,
120 OPAL_LOCKINGRANGE_ACE_WRLOCKED
,
123 OPAL_AUTHORITY_TABLE
,
125 OPAL_LOCKING_INFO_TABLE
,
126 OPAL_ENTERPRISE_LOCKING_INFO_TABLE
,
128 /* C_PIN_TABLE object ID's */
132 /* half UID's (only first 4 bytes used) */
133 OPAL_HALF_UID_AUTHORITY_OBJ_REF
,
134 OPAL_HALF_UID_BOOLEAN_ACE
,
135 /* omitted optional parameter */
139 /* Enum for indexing the OPALMETHOD array */
163 OPAL_BOOLEAN_EXPR
= 0x03,
166 OPAL_STARTROW
= 0x01,
168 OPAL_STARTCOLUMN
= 0x03,
169 OPAL_ENDCOLUMN
= 0x04,
172 OPAL_TABLE_UID
= 0x00,
173 OPAL_TABLE_NAME
= 0x01,
174 OPAL_TABLE_COMMON
= 0x02,
175 OPAL_TABLE_TEMPLATE
= 0x03,
176 OPAL_TABLE_KIND
= 0x04,
177 OPAL_TABLE_COLUMN
= 0x05,
178 OPAL_TABLE_COLUMNS
= 0x06,
179 OPAL_TABLE_ROWS
= 0x07,
180 OPAL_TABLE_ROWS_FREE
= 0x08,
181 OPAL_TABLE_ROW_BYTES
= 0x09,
182 OPAL_TABLE_LASTID
= 0x0A,
183 OPAL_TABLE_MIN
= 0x0B,
184 OPAL_TABLE_MAX
= 0x0C,
185 /* authority table */
188 OPAL_RANGESTART
= 0x03,
189 OPAL_RANGELENGTH
= 0x04,
190 OPAL_READLOCKENABLED
= 0x05,
191 OPAL_WRITELOCKENABLED
= 0x06,
192 OPAL_READLOCKED
= 0x07,
193 OPAL_WRITELOCKED
= 0x08,
194 OPAL_ACTIVEKEY
= 0x0A,
195 /* lockingsp table */
196 OPAL_LIFECYCLE
= 0x06,
197 /* locking info table */
198 OPAL_MAXRANGES
= 0x04,
200 OPAL_MBRENABLE
= 0x01,
203 OPAL_HOSTPROPERTIES
= 0x00,
205 OPAL_STARTLIST
= 0xf0,
207 OPAL_STARTNAME
= 0xf2,
210 OPAL_ENDOFDATA
= 0xf9,
211 OPAL_ENDOFSESSION
= 0xfa,
212 OPAL_STARTTRANSACTON
= 0xfb,
213 OPAL_ENDTRANSACTON
= 0xfC,
214 OPAL_EMPTYATOM
= 0xff,
218 /* Locking state for a locking range */
219 enum opal_lockingstate
{
220 OPAL_LOCKING_READWRITE
= 0x01,
221 OPAL_LOCKING_READONLY
= 0x02,
222 OPAL_LOCKING_LOCKED
= 0x03,
225 enum opal_parameter
{
226 OPAL_SUM_SET_LIST
= 0x060000,
229 enum opal_revertlsp
{
230 OPAL_KEEP_GLOBAL_RANGE_KEY
= 0x060000,
233 /* Packets derived from:
234 * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
235 * Secion: 3.2.3 ComPackets, Packets & Subpackets
238 /* Comm Packet (header) for transmissions. */
239 struct opal_compacket
{
242 __be32 outstandingData
;
247 /* Packet structure. */
254 __be32 acknowledgment
;
258 /* Data sub packet header */
259 struct opal_data_subpacket
{
265 /* header of a response */
267 struct opal_compacket cp
;
268 struct opal_packet pkt
;
269 struct opal_data_subpacket subpkt
;
272 #define FC_TPER 0x0001
273 #define FC_LOCKING 0x0002
274 #define FC_GEOMETRY 0x0003
275 #define FC_ENTERPRISE 0x0100
276 #define FC_DATASTORE 0x0202
277 #define FC_SINGLEUSER 0x0201
278 #define FC_OPALV100 0x0200
279 #define FC_OPALV200 0x0203
282 * The Discovery 0 Header. As defined in
283 * Opal SSC Documentation
284 * Section: 3.3.5 Capability Discovery
287 __be32 length
; /* the length of the header 48 in 2.00.100 */
288 __be32 revision
; /**< revision of the header 1 in 2.00.100 */
292 * the remainder of the structure is vendor specific and will not be
299 * TPer Feature Descriptor. Contains flags indicating support for the
300 * TPer features described in the OPAL specification. The names match the
303 * code == 0x001 in 2.00.100
305 struct d0_tper_features
{
307 * supported_features bits:
309 * bit 6: com ID management
311 * bit 4: streaming support
312 * bit 3: buffer management
317 u8 supported_features
;
319 * bytes 5 through 15 are reserved, but we represent the first 3 as
320 * u8 to keep the other two 32bits integers aligned.
328 * Locking Feature Descriptor. Contains flags indicating support for the
329 * locking features described in the OPAL specification. The names match the
332 * code == 0x0002 in 2.00.100
334 struct d0_locking_features
{
336 * supported_features bits:
340 * bit 3: media encryption
342 * bit 1: locking enabled
343 * bit 0: locking supported
345 u8 supported_features
;
347 * bytes 5 through 15 are reserved, but we represent the first 3 as
348 * u8 to keep the other two 32bits integers aligned.
356 * Geometry Feature Descriptor. Contains flags indicating support for the
357 * geometry features described in the OPAL specification. The names match the
360 * code == 0x0003 in 2.00.100
362 struct d0_geometry_features
{
364 * skip 32 bits from header, needed to align the struct to 64 bits.
374 __be32 logical_block_size
;
375 __be64 alignment_granularity
;
376 __be64 lowest_aligned_lba
;
380 * Enterprise SSC Feature
384 struct d0_enterprise_ssc
{
389 * bit 0: range crossing
403 struct d0_opal_v100
{
409 * Single User Mode feature
413 struct d0_single_user_mode
{
414 __be32 num_locking_objects
;
428 * Additonal Datastores feature
432 struct d0_datastore_table
{
435 __be32 max_size_tables
;
436 __be32 table_size_alignment
;
444 struct d0_opal_v200
{
449 * bit 0: range crossing
452 /* num_locking_admin_auth:
453 * not aligned to 16 bits, so use two u8.
454 * stored in big endian:
458 u8 num_locking_admin_auth
[2];
459 /* num_locking_user_auth:
460 * not aligned to 16 bits, so use two u8.
461 * stored in big endian:
465 u8 num_locking_user_auth
[2];
472 /* Union of features used to parse the discovery 0 response */
485 #endif /* _OPAL_PROTO_H */