2 * Copyright © 2016 Intel Corporation
5 * Rafael Antognolli <rafael.antognolli@intel.com>
6 * Scott Bauer <scott.bauer@intel.com>
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.
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
17 #include <linux/types.h>
23 * These constant values come from:
25 * 6.30 SECURITY PROTOCOL IN command / table 265.
33 * Token defs derived from:
34 * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
35 * 3.2.2 Data Stream Encoding
37 enum 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
45 #define DTAERROR_NO_METHOD_STATUS 0x89
46 #define GENERIC_HOST_SESSION_NUM 0x41
48 #define TPER_SYNC_SUPPORTED 0x01
49 #define MBR_ENABLED_MASK 0x10
51 #define TINY_ATOM_DATA_MASK 0x3F
52 #define TINY_ATOM_SIGNED 0x40
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
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
64 #define LONG_ATOM_ID 0xe0
65 #define LONG_ATOM_BYTESTRING 0x2
66 #define LONG_ATOM_SIGNED 0x1
68 /* Derived from TCG Core spec 2.01 Section:
72 #define TINY_ATOM_BYTE 0x7F
73 #define SHORT_ATOM_BYTE 0xBF
74 #define MEDIUM_ATOM_BYTE 0xDF
75 #define LONG_ATOM_BYTE 0xE3
77 #define OPAL_INVAL_PARAM 12
78 #define OPAL_MANUFACTURED_INACTIVE 0x08
79 #define OPAL_DISCOVERY_COMID 0x0001
81 #define LOCKING_RANGE_NON_GLOBAL 0x03
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
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
92 /* Enum to index OPALUID array */
99 OPAL_ENTERPRISE_LOCKINGSP_UID
,
106 OPAL_ENTERPRISE_BANDMASTER0_UID
,
107 OPAL_ENTERPRISE_ERASEMASTER_UID
,
109 OPAL_LOCKINGRANGE_GLOBAL
,
110 OPAL_LOCKINGRANGE_ACE_RDLOCKED
,
111 OPAL_LOCKINGRANGE_ACE_WRLOCKED
,
114 OPAL_AUTHORITY_TABLE
,
116 OPAL_LOCKING_INFO_TABLE
,
117 OPAL_ENTERPRISE_LOCKING_INFO_TABLE
,
118 /* C_PIN_TABLE object ID's */
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 */
129 #define OPAL_METHOD_LENGTH 8
131 /* Enum for indexing the OPALMETHOD array */
155 OPAL_BOOLEAN_EXPR
= 0x03,
158 OPAL_STARTROW
= 0x01,
160 OPAL_STARTCOLUMN
= 0x03,
161 OPAL_ENDCOLUMN
= 0x04,
163 /* authority table */
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,
176 OPAL_MBRENABLE
= 0x01,
179 OPAL_HOSTPROPERTIES
= 0x00,
181 OPAL_STARTLIST
= 0xf0,
183 OPAL_STARTNAME
= 0xf2,
186 OPAL_ENDOFDATA
= 0xf9,
187 OPAL_ENDOFSESSION
= 0xfa,
188 OPAL_STARTTRANSACTON
= 0xfb,
189 OPAL_ENDTRANSACTON
= 0xfC,
190 OPAL_EMPTYATOM
= 0xff,
194 /* Locking state for a locking range */
195 enum opal_lockingstate
{
196 OPAL_LOCKING_READWRITE
= 0x01,
197 OPAL_LOCKING_READONLY
= 0x02,
198 OPAL_LOCKING_LOCKED
= 0x03,
201 /* Packets derived from:
202 * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
203 * Secion: 3.2.3 ComPackets, Packets & Subpackets
206 /* Comm Packet (header) for transmissions. */
207 struct opal_compacket
{
210 __be32 outstandingData
;
215 /* Packet structure. */
222 __be32 acknowledgment
;
226 /* Data sub packet header */
227 struct opal_data_subpacket
{
233 /* header of a response */
235 struct opal_compacket cp
;
236 struct opal_packet pkt
;
237 struct opal_data_subpacket subpkt
;
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
250 * The Discovery 0 Header. As defined in
251 * Opal SSC Documentation
252 * Section: 3.3.5 Capability Discovery
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 */
260 * the remainder of the structure is vendor specific and will not be
267 * TPer Feature Descriptor. Contains flags indicating support for the
268 * TPer features described in the OPAL specification. The names match the
271 * code == 0x001 in 2.00.100
273 struct d0_tper_features
{
275 * supported_features bits:
277 * bit 6: com ID management
279 * bit 4: streaming support
280 * bit 3: buffer management
285 u8 supported_features
;
287 * bytes 5 through 15 are reserved, but we represent the first 3 as
288 * u8 to keep the other two 32bits integers aligned.
296 * Locking Feature Descriptor. Contains flags indicating support for the
297 * locking features described in the OPAL specification. The names match the
300 * code == 0x0002 in 2.00.100
302 struct d0_locking_features
{
304 * supported_features bits:
308 * bit 3: media encryption
310 * bit 1: locking enabled
311 * bit 0: locking supported
313 u8 supported_features
;
315 * bytes 5 through 15 are reserved, but we represent the first 3 as
316 * u8 to keep the other two 32bits integers aligned.
324 * Geometry Feature Descriptor. Contains flags indicating support for the
325 * geometry features described in the OPAL specification. The names match the
328 * code == 0x0003 in 2.00.100
330 struct d0_geometry_features
{
332 * skip 32 bits from header, needed to align the struct to 64 bits.
342 __be32 logical_block_size
;
343 __be64 alignment_granularity
;
344 __be64 lowest_aligned_lba
;
348 * Enterprise SSC Feature
352 struct d0_enterprise_ssc
{
357 * bit 0: range crossing
371 struct d0_opal_v100
{
377 * Single User Mode feature
381 struct d0_single_user_mode
{
382 __be32 num_locking_objects
;
396 * Additonal Datastores feature
400 struct d0_datastore_table
{
403 __be32 max_size_tables
;
404 __be32 table_size_alignment
;
412 struct d0_opal_v200
{
417 * bit 0: range crossing
420 /* num_locking_admin_auth:
421 * not aligned to 16 bits, so use two u8.
422 * stored in big endian:
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:
433 u8 num_locking_user_auth
[2];
440 /* Union of features used to parse the discovery 0 response */
453 #endif /* _OPAL_PROTO_H */