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>
22 #define DTAERROR_NO_METHOD_STATUS 0x89
23 #define GENERIC_HOST_SESSION_NUM 0x41
25 #define TPER_SYNC_SUPPORTED 0x01
27 #define TINY_ATOM_DATA_MASK 0x3F
28 #define TINY_ATOM_SIGNED 0x40
30 #define SHORT_ATOM_ID 0x80
31 #define SHORT_ATOM_BYTESTRING 0x20
32 #define SHORT_ATOM_SIGNED 0x10
33 #define SHORT_ATOM_LEN_MASK 0xF
35 #define MEDIUM_ATOM_ID 0xC0
36 #define MEDIUM_ATOM_BYTESTRING 0x10
37 #define MEDIUM_ATOM_SIGNED 0x8
38 #define MEDIUM_ATOM_LEN_MASK 0x7
40 #define LONG_ATOM_ID 0xe0
41 #define LONG_ATOM_BYTESTRING 0x2
42 #define LONG_ATOM_SIGNED 0x1
44 /* Derived from TCG Core spec 2.01 Section:
48 #define TINY_ATOM_BYTE 0x7F
49 #define SHORT_ATOM_BYTE 0xBF
50 #define MEDIUM_ATOM_BYTE 0xDF
51 #define LONG_ATOM_BYTE 0xE3
53 #define OPAL_INVAL_PARAM 12
54 #define OPAL_MANUFACTURED_INACTIVE 0x08
55 #define OPAL_DISCOVERY_COMID 0x0001
57 #define LOCKING_RANGE_NON_GLOBAL 0x03
59 * User IDs used in the TCG storage SSCs
60 * Derived from: TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
61 * Section: 6.3 Assigned UIDs
63 #define OPAL_UID_LENGTH 8
64 #define OPAL_METHOD_LENGTH 8
65 #define OPAL_MSID_KEYLEN 15
66 #define OPAL_UID_LENGTH_HALF 4
68 /* Enum to index OPALUID array */
75 OPAL_ENTERPRISE_LOCKINGSP_UID,
82 OPAL_ENTERPRISE_BANDMASTER0_UID,
83 OPAL_ENTERPRISE_ERASEMASTER_UID,
85 OPAL_LOCKINGRANGE_GLOBAL,
86 OPAL_LOCKINGRANGE_ACE_RDLOCKED,
87 OPAL_LOCKINGRANGE_ACE_WRLOCKED,
92 OPAL_LOCKING_INFO_TABLE,
93 OPAL_ENTERPRISE_LOCKING_INFO_TABLE,
94 /* C_PIN_TABLE object ID's */
98 /* half UID's (only first 4 bytes used) */
99 OPAL_HALF_UID_AUTHORITY_OBJ_REF,
100 OPAL_HALF_UID_BOOLEAN_ACE,
101 /* omitted optional parameter */
105 #define OPAL_METHOD_LENGTH 8
107 /* Enum for indexing the OPALMETHOD array */
131 OPAL_BOOLEAN_EXPR = 0x03,
134 OPAL_STARTROW = 0x01,
136 OPAL_STARTCOLUMN = 0x03,
137 OPAL_ENDCOLUMN = 0x04,
139 /* authority table */
142 OPAL_RANGESTART = 0x03,
143 OPAL_RANGELENGTH = 0x04,
144 OPAL_READLOCKENABLED = 0x05,
145 OPAL_WRITELOCKENABLED = 0x06,
146 OPAL_READLOCKED = 0x07,
147 OPAL_WRITELOCKED = 0x08,
148 OPAL_ACTIVEKEY = 0x0A,
149 /* locking info table */
150 OPAL_MAXRANGES = 0x04,
152 OPAL_MBRENABLE = 0x01,
155 OPAL_HOSTPROPERTIES = 0x00,
157 OPAL_STARTLIST = 0xf0,
159 OPAL_STARTNAME = 0xf2,
162 OPAL_ENDOFDATA = 0xf9,
163 OPAL_ENDOFSESSION = 0xfa,
164 OPAL_STARTTRANSACTON = 0xfb,
165 OPAL_ENDTRANSACTON = 0xfC,
166 OPAL_EMPTYATOM = 0xff,
170 /* Locking state for a locking range */
171 enum opal_lockingstate {
172 OPAL_LOCKING_READWRITE = 0x01,
173 OPAL_LOCKING_READONLY = 0x02,
174 OPAL_LOCKING_LOCKED = 0x03,
177 /* Packets derived from:
178 * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
179 * Secion: 3.2.3 ComPackets, Packets & Subpackets
182 /* Comm Packet (header) for transmissions. */
183 struct opal_compacket {
186 __be32 outstandingData;
191 /* Packet structure. */
198 __be32 acknowledgment;
202 /* Data sub packet header */
203 struct opal_data_subpacket {
209 /* header of a response */
211 struct opal_compacket cp;
212 struct opal_packet pkt;
213 struct opal_data_subpacket subpkt;
216 #define FC_TPER 0x0001
217 #define FC_LOCKING 0x0002
218 #define FC_GEOMETRY 0x0003
219 #define FC_ENTERPRISE 0x0100
220 #define FC_DATASTORE 0x0202
221 #define FC_SINGLEUSER 0x0201
222 #define FC_OPALV100 0x0200
223 #define FC_OPALV200 0x0203
226 * The Discovery 0 Header. As defined in
227 * Opal SSC Documentation
228 * Section: 3.3.5 Capability Discovery
231 __be32 length; /* the length of the header 48 in 2.00.100 */
232 __be32 revision; /**< revision of the header 1 in 2.00.100 */
236 * the remainder of the structure is vendor specific and will not be
243 * TPer Feature Descriptor. Contains flags indicating support for the
244 * TPer features described in the OPAL specification. The names match the
247 * code == 0x001 in 2.00.100
249 struct d0_tper_features {
251 * supported_features bits:
253 * bit 6: com ID management
255 * bit 4: streaming support
256 * bit 3: buffer management
261 u8 supported_features;
263 * bytes 5 through 15 are reserved, but we represent the first 3 as
264 * u8 to keep the other two 32bits integers aligned.
272 * Locking Feature Descriptor. Contains flags indicating support for the
273 * locking features described in the OPAL specification. The names match the
276 * code == 0x0002 in 2.00.100
278 struct d0_locking_features {
280 * supported_features bits:
284 * bit 3: media encryption
286 * bit 1: locking enabled
287 * bit 0: locking supported
289 u8 supported_features;
291 * bytes 5 through 15 are reserved, but we represent the first 3 as
292 * u8 to keep the other two 32bits integers aligned.
300 * Geometry Feature Descriptor. Contains flags indicating support for the
301 * geometry features described in the OPAL specification. The names match the
304 * code == 0x0003 in 2.00.100
306 struct d0_geometry_features {
308 * skip 32 bits from header, needed to align the struct to 64 bits.
318 __be32 logical_block_size;
319 __be64 alignment_granularity;
320 __be64 lowest_aligned_lba;
324 * Enterprise SSC Feature
328 struct d0_enterprise_ssc {
333 * bit 0: range crossing
347 struct d0_opal_v100 {
353 * Single User Mode feature
357 struct d0_single_user_mode {
358 __be32 num_locking_objects;
372 * Additonal Datastores feature
376 struct d0_datastore_table {
379 __be32 max_size_tables;
380 __be32 table_size_alignment;
388 struct d0_opal_v200 {
393 * bit 0: range crossing
396 /* num_locking_admin_auth:
397 * not aligned to 16 bits, so use two u8.
398 * stored in big endian:
402 u8 num_locking_admin_auth[2];
403 /* num_locking_user_auth:
404 * not aligned to 16 bits, so use two u8.
405 * stored in big endian:
409 u8 num_locking_user_auth[2];
416 /* Union of features used to parse the discovery 0 response */
429 #endif /* _OPAL_PROTO_H */