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
40 #define TPER_SYNC_SUPPORTED 0x01
41 #define MBR_ENABLED_MASK 0x10
43 #define TINY_ATOM_DATA_MASK 0x3F
44 #define TINY_ATOM_SIGNED 0x40
46 #define SHORT_ATOM_ID 0x80
47 #define SHORT_ATOM_BYTESTRING 0x20
48 #define SHORT_ATOM_SIGNED 0x10
49 #define SHORT_ATOM_LEN_MASK 0xF
51 #define MEDIUM_ATOM_ID 0xC0
52 #define MEDIUM_ATOM_BYTESTRING 0x10
53 #define MEDIUM_ATOM_SIGNED 0x8
54 #define MEDIUM_ATOM_LEN_MASK 0x7
56 #define LONG_ATOM_ID 0xe0
57 #define LONG_ATOM_BYTESTRING 0x2
58 #define LONG_ATOM_SIGNED 0x1
60 /* Derived from TCG Core spec 2.01 Section:
64 #define TINY_ATOM_BYTE 0x7F
65 #define SHORT_ATOM_BYTE 0xBF
66 #define MEDIUM_ATOM_BYTE 0xDF
67 #define LONG_ATOM_BYTE 0xE3
69 #define OPAL_INVAL_PARAM 12
70 #define OPAL_MANUFACTURED_INACTIVE 0x08
71 #define OPAL_DISCOVERY_COMID 0x0001
73 #define LOCKING_RANGE_NON_GLOBAL 0x03
75 * User IDs used in the TCG storage SSCs
76 * Derived from: TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
77 * Section: 6.3 Assigned UIDs
79 #define OPAL_UID_LENGTH 8
80 #define OPAL_METHOD_LENGTH 8
81 #define OPAL_MSID_KEYLEN 15
82 #define OPAL_UID_LENGTH_HALF 4
84 /* Enum to index OPALUID array */
91 OPAL_ENTERPRISE_LOCKINGSP_UID
,
98 OPAL_ENTERPRISE_BANDMASTER0_UID
,
99 OPAL_ENTERPRISE_ERASEMASTER_UID
,
102 OPAL_LOCKINGRANGE_GLOBAL
,
103 OPAL_LOCKINGRANGE_ACE_RDLOCKED
,
104 OPAL_LOCKINGRANGE_ACE_WRLOCKED
,
107 OPAL_AUTHORITY_TABLE
,
109 OPAL_LOCKING_INFO_TABLE
,
110 OPAL_ENTERPRISE_LOCKING_INFO_TABLE
,
111 /* C_PIN_TABLE object ID's */
115 /* half UID's (only first 4 bytes used) */
116 OPAL_HALF_UID_AUTHORITY_OBJ_REF
,
117 OPAL_HALF_UID_BOOLEAN_ACE
,
118 /* omitted optional parameter */
122 /* Enum for indexing the OPALMETHOD array */
146 OPAL_BOOLEAN_EXPR
= 0x03,
149 OPAL_STARTROW
= 0x01,
151 OPAL_STARTCOLUMN
= 0x03,
152 OPAL_ENDCOLUMN
= 0x04,
155 OPAL_TABLE_UID
= 0x00,
156 OPAL_TABLE_NAME
= 0x01,
157 OPAL_TABLE_COMMON
= 0x02,
158 OPAL_TABLE_TEMPLATE
= 0x03,
159 OPAL_TABLE_KIND
= 0x04,
160 OPAL_TABLE_COLUMN
= 0x05,
161 OPAL_TABLE_COLUMNS
= 0x06,
162 OPAL_TABLE_ROWS
= 0x07,
163 OPAL_TABLE_ROWS_FREE
= 0x08,
164 OPAL_TABLE_ROW_BYTES
= 0x09,
165 OPAL_TABLE_LASTID
= 0x0A,
166 OPAL_TABLE_MIN
= 0x0B,
167 OPAL_TABLE_MAX
= 0x0C,
168 /* authority table */
171 OPAL_RANGESTART
= 0x03,
172 OPAL_RANGELENGTH
= 0x04,
173 OPAL_READLOCKENABLED
= 0x05,
174 OPAL_WRITELOCKENABLED
= 0x06,
175 OPAL_READLOCKED
= 0x07,
176 OPAL_WRITELOCKED
= 0x08,
177 OPAL_ACTIVEKEY
= 0x0A,
178 /* lockingsp table */
179 OPAL_LIFECYCLE
= 0x06,
180 /* locking info table */
181 OPAL_MAXRANGES
= 0x04,
183 OPAL_MBRENABLE
= 0x01,
186 OPAL_HOSTPROPERTIES
= 0x00,
188 OPAL_STARTLIST
= 0xf0,
190 OPAL_STARTNAME
= 0xf2,
193 OPAL_ENDOFDATA
= 0xf9,
194 OPAL_ENDOFSESSION
= 0xfa,
195 OPAL_STARTTRANSACTON
= 0xfb,
196 OPAL_ENDTRANSACTON
= 0xfC,
197 OPAL_EMPTYATOM
= 0xff,
201 /* Locking state for a locking range */
202 enum opal_lockingstate
{
203 OPAL_LOCKING_READWRITE
= 0x01,
204 OPAL_LOCKING_READONLY
= 0x02,
205 OPAL_LOCKING_LOCKED
= 0x03,
208 /* Packets derived from:
209 * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
210 * Secion: 3.2.3 ComPackets, Packets & Subpackets
213 /* Comm Packet (header) for transmissions. */
214 struct opal_compacket
{
217 __be32 outstandingData
;
222 /* Packet structure. */
229 __be32 acknowledgment
;
233 /* Data sub packet header */
234 struct opal_data_subpacket
{
240 /* header of a response */
242 struct opal_compacket cp
;
243 struct opal_packet pkt
;
244 struct opal_data_subpacket subpkt
;
247 #define FC_TPER 0x0001
248 #define FC_LOCKING 0x0002
249 #define FC_GEOMETRY 0x0003
250 #define FC_ENTERPRISE 0x0100
251 #define FC_DATASTORE 0x0202
252 #define FC_SINGLEUSER 0x0201
253 #define FC_OPALV100 0x0200
254 #define FC_OPALV200 0x0203
257 * The Discovery 0 Header. As defined in
258 * Opal SSC Documentation
259 * Section: 3.3.5 Capability Discovery
262 __be32 length
; /* the length of the header 48 in 2.00.100 */
263 __be32 revision
; /**< revision of the header 1 in 2.00.100 */
267 * the remainder of the structure is vendor specific and will not be
274 * TPer Feature Descriptor. Contains flags indicating support for the
275 * TPer features described in the OPAL specification. The names match the
278 * code == 0x001 in 2.00.100
280 struct d0_tper_features
{
282 * supported_features bits:
284 * bit 6: com ID management
286 * bit 4: streaming support
287 * bit 3: buffer management
292 u8 supported_features
;
294 * bytes 5 through 15 are reserved, but we represent the first 3 as
295 * u8 to keep the other two 32bits integers aligned.
303 * Locking Feature Descriptor. Contains flags indicating support for the
304 * locking features described in the OPAL specification. The names match the
307 * code == 0x0002 in 2.00.100
309 struct d0_locking_features
{
311 * supported_features bits:
315 * bit 3: media encryption
317 * bit 1: locking enabled
318 * bit 0: locking supported
320 u8 supported_features
;
322 * bytes 5 through 15 are reserved, but we represent the first 3 as
323 * u8 to keep the other two 32bits integers aligned.
331 * Geometry Feature Descriptor. Contains flags indicating support for the
332 * geometry features described in the OPAL specification. The names match the
335 * code == 0x0003 in 2.00.100
337 struct d0_geometry_features
{
339 * skip 32 bits from header, needed to align the struct to 64 bits.
349 __be32 logical_block_size
;
350 __be64 alignment_granularity
;
351 __be64 lowest_aligned_lba
;
355 * Enterprise SSC Feature
359 struct d0_enterprise_ssc
{
364 * bit 0: range crossing
378 struct d0_opal_v100
{
384 * Single User Mode feature
388 struct d0_single_user_mode
{
389 __be32 num_locking_objects
;
403 * Additonal Datastores feature
407 struct d0_datastore_table
{
410 __be32 max_size_tables
;
411 __be32 table_size_alignment
;
419 struct d0_opal_v200
{
424 * bit 0: range crossing
427 /* num_locking_admin_auth:
428 * not aligned to 16 bits, so use two u8.
429 * stored in big endian:
433 u8 num_locking_admin_auth
[2];
434 /* num_locking_user_auth:
435 * not aligned to 16 bits, so use two u8.
436 * stored in big endian:
440 u8 num_locking_user_auth
[2];
447 /* Union of features used to parse the discovery 0 response */
460 #endif /* _OPAL_PROTO_H */