]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - block/opal_proto.h
block/sed-opal: tone down not supported warnings
[mirror_ubuntu-artful-kernel.git] / block / opal_proto.h
CommitLineData
455a7b23
SB
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#define DTAERROR_NO_METHOD_STATUS 0x89
23#define GENERIC_HOST_SESSION_NUM 0x41
24
25#define TPER_SYNC_SUPPORTED 0x01
26
27#define TINY_ATOM_DATA_MASK 0x3F
28#define TINY_ATOM_SIGNED 0x40
29
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
34
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
39
40#define LONG_ATOM_ID 0xe0
41#define LONG_ATOM_BYTESTRING 0x2
42#define LONG_ATOM_SIGNED 0x1
43
44/* Derived from TCG Core spec 2.01 Section:
45 * 3.2.2.1
46 * Data Type
47 */
48#define TINY_ATOM_BYTE 0x7F
49#define SHORT_ATOM_BYTE 0xBF
50#define MEDIUM_ATOM_BYTE 0xDF
51#define LONG_ATOM_BYTE 0xE3
52
53#define OPAL_INVAL_PARAM 12
54#define OPAL_MANUFACTURED_INACTIVE 0x08
55#define OPAL_DISCOVERY_COMID 0x0001
56
57#define LOCKING_RANGE_NON_GLOBAL 0x03
58/*
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
62 */
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
67
68/* Enum to index OPALUID array */
69enum opal_uid {
70 /* users */
71 OPAL_SMUID_UID,
72 OPAL_THISSP_UID,
73 OPAL_ADMINSP_UID,
74 OPAL_LOCKINGSP_UID,
75 OPAL_ENTERPRISE_LOCKINGSP_UID,
76 OPAL_ANYBODY_UID,
77 OPAL_SID_UID,
78 OPAL_ADMIN1_UID,
79 OPAL_USER1_UID,
80 OPAL_USER2_UID,
81 OPAL_PSID_UID,
82 OPAL_ENTERPRISE_BANDMASTER0_UID,
83 OPAL_ENTERPRISE_ERASEMASTER_UID,
84 /* tables */
85 OPAL_LOCKINGRANGE_GLOBAL,
86 OPAL_LOCKINGRANGE_ACE_RDLOCKED,
87 OPAL_LOCKINGRANGE_ACE_WRLOCKED,
88 OPAL_MBRCONTROL,
89 OPAL_MBR,
90 OPAL_AUTHORITY_TABLE,
91 OPAL_C_PIN_TABLE,
92 OPAL_LOCKING_INFO_TABLE,
93 OPAL_ENTERPRISE_LOCKING_INFO_TABLE,
94 /* C_PIN_TABLE object ID's */
95 OPAL_C_PIN_MSID,
96 OPAL_C_PIN_SID,
97 OPAL_C_PIN_ADMIN1,
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 */
102 OPAL_UID_HEXFF,
103};
104
105#define OPAL_METHOD_LENGTH 8
106
107/* Enum for indexing the OPALMETHOD array */
108enum opal_method {
109 OPAL_PROPERTIES,
110 OPAL_STARTSESSION,
111 OPAL_REVERT,
112 OPAL_ACTIVATE,
113 OPAL_EGET,
114 OPAL_ESET,
115 OPAL_NEXT,
116 OPAL_EAUTHENTICATE,
117 OPAL_GETACL,
118 OPAL_GENKEY,
119 OPAL_REVERTSP,
120 OPAL_GET,
121 OPAL_SET,
122 OPAL_AUTHENTICATE,
123 OPAL_RANDOM,
124 OPAL_ERASE,
125};
126
127enum opal_token {
128 /* Boolean */
129 OPAL_TRUE = 0x01,
130 OPAL_FALSE = 0x00,
131 OPAL_BOOLEAN_EXPR = 0x03,
132 /* cellblocks */
133 OPAL_TABLE = 0x00,
134 OPAL_STARTROW = 0x01,
135 OPAL_ENDROW = 0x02,
136 OPAL_STARTCOLUMN = 0x03,
137 OPAL_ENDCOLUMN = 0x04,
138 OPAL_VALUES = 0x01,
139 /* authority table */
140 OPAL_PIN = 0x03,
141 /* locking tokens */
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,
151 /* mbr control */
152 OPAL_MBRENABLE = 0x01,
153 OPAL_MBRDONE = 0x02,
154 /* properties */
155 OPAL_HOSTPROPERTIES = 0x00,
156 /* atoms */
157 OPAL_STARTLIST = 0xf0,
158 OPAL_ENDLIST = 0xf1,
159 OPAL_STARTNAME = 0xf2,
160 OPAL_ENDNAME = 0xf3,
161 OPAL_CALL = 0xf8,
162 OPAL_ENDOFDATA = 0xf9,
163 OPAL_ENDOFSESSION = 0xfa,
164 OPAL_STARTTRANSACTON = 0xfb,
165 OPAL_ENDTRANSACTON = 0xfC,
166 OPAL_EMPTYATOM = 0xff,
167 OPAL_WHERE = 0x00,
168};
169
170/* Locking state for a locking range */
171enum opal_lockingstate {
172 OPAL_LOCKING_READWRITE = 0x01,
173 OPAL_LOCKING_READONLY = 0x02,
174 OPAL_LOCKING_LOCKED = 0x03,
175};
176
177/* Packets derived from:
178 * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
179 * Secion: 3.2.3 ComPackets, Packets & Subpackets
180 */
181
182/* Comm Packet (header) for transmissions. */
183struct opal_compacket {
184 __be32 reserved0;
185 u8 extendedComID[4];
186 __be32 outstandingData;
187 __be32 minTransfer;
188 __be32 length;
189};
190
191/* Packet structure. */
192struct opal_packet {
193 __be32 tsn;
194 __be32 hsn;
195 __be32 seq_number;
196 __be16 reserved0;
197 __be16 ack_type;
198 __be32 acknowledgment;
199 __be32 length;
200};
201
202/* Data sub packet header */
203struct opal_data_subpacket {
204 u8 reserved0[6];
205 __be16 kind;
206 __be32 length;
207};
208
209/* header of a response */
210struct opal_header {
211 struct opal_compacket cp;
212 struct opal_packet pkt;
213 struct opal_data_subpacket subpkt;
214};
215
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
224
225/*
226 * The Discovery 0 Header. As defined in
227 * Opal SSC Documentation
228 * Section: 3.3.5 Capability Discovery
229 */
230struct d0_header {
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 */
233 __be32 reserved01;
234 __be32 reserved02;
235 /*
236 * the remainder of the structure is vendor specific and will not be
237 * addressed now
238 */
239 u8 ignored[32];
240};
241
242/*
243 * TPer Feature Descriptor. Contains flags indicating support for the
244 * TPer features described in the OPAL specification. The names match the
245 * OPAL terminology
246 *
247 * code == 0x001 in 2.00.100
248 */
249struct d0_tper_features {
250 /*
251 * supported_features bits:
252 * bit 7: reserved
253 * bit 6: com ID management
254 * bit 5: reserved
255 * bit 4: streaming support
256 * bit 3: buffer management
257 * bit 2: ACK/NACK
258 * bit 1: async
259 * bit 0: sync
260 */
261 u8 supported_features;
262 /*
263 * bytes 5 through 15 are reserved, but we represent the first 3 as
264 * u8 to keep the other two 32bits integers aligned.
265 */
266 u8 reserved01[3];
267 __be32 reserved02;
268 __be32 reserved03;
269};
270
271/*
272 * Locking Feature Descriptor. Contains flags indicating support for the
273 * locking features described in the OPAL specification. The names match the
274 * OPAL terminology
275 *
276 * code == 0x0002 in 2.00.100
277 */
278struct d0_locking_features {
279 /*
280 * supported_features bits:
281 * bits 6-7: reserved
282 * bit 5: MBR done
283 * bit 4: MBR enabled
284 * bit 3: media encryption
285 * bit 2: locked
286 * bit 1: locking enabled
287 * bit 0: locking supported
288 */
289 u8 supported_features;
290 /*
291 * bytes 5 through 15 are reserved, but we represent the first 3 as
292 * u8 to keep the other two 32bits integers aligned.
293 */
294 u8 reserved01[3];
295 __be32 reserved02;
296 __be32 reserved03;
297};
298
299/*
300 * Geometry Feature Descriptor. Contains flags indicating support for the
301 * geometry features described in the OPAL specification. The names match the
302 * OPAL terminology
303 *
304 * code == 0x0003 in 2.00.100
305 */
306struct d0_geometry_features {
307 /*
308 * skip 32 bits from header, needed to align the struct to 64 bits.
309 */
310 u8 header[4];
311 /*
312 * reserved01:
313 * bits 1-6: reserved
314 * bit 0: align
315 */
316 u8 reserved01;
317 u8 reserved02[7];
318 __be32 logical_block_size;
319 __be64 alignment_granularity;
320 __be64 lowest_aligned_lba;
321};
322
323/*
324 * Enterprise SSC Feature
325 *
326 * code == 0x0100
327 */
328struct d0_enterprise_ssc {
329 __be16 baseComID;
330 __be16 numComIDs;
331 /* range_crossing:
332 * bits 1-6: reserved
333 * bit 0: range crossing
334 */
335 u8 range_crossing;
336 u8 reserved01;
337 __be16 reserved02;
338 __be32 reserved03;
339 __be32 reserved04;
340};
341
342/*
343 * Opal V1 feature
344 *
345 * code == 0x0200
346 */
347struct d0_opal_v100 {
348 __be16 baseComID;
349 __be16 numComIDs;
350};
351
352/*
353 * Single User Mode feature
354 *
355 * code == 0x0201
356 */
357struct d0_single_user_mode {
358 __be32 num_locking_objects;
359 /* reserved01:
360 * bit 0: any
361 * bit 1: all
362 * bit 2: policy
363 * bits 3-7: reserved
364 */
365 u8 reserved01;
366 u8 reserved02;
367 __be16 reserved03;
368 __be32 reserved04;
369};
370
371/*
372 * Additonal Datastores feature
373 *
374 * code == 0x0202
375 */
376struct d0_datastore_table {
377 __be16 reserved01;
378 __be16 max_tables;
379 __be32 max_size_tables;
380 __be32 table_size_alignment;
381};
382
383/*
384 * OPAL 2.0 feature
385 *
386 * code == 0x0203
387 */
388struct d0_opal_v200 {
389 __be16 baseComID;
390 __be16 numComIDs;
391 /* range_crossing:
392 * bits 1-6: reserved
393 * bit 0: range crossing
394 */
395 u8 range_crossing;
396 /* num_locking_admin_auth:
397 * not aligned to 16 bits, so use two u8.
398 * stored in big endian:
399 * 0: MSB
400 * 1: LSB
401 */
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:
406 * 0: MSB
407 * 1: LSB
408 */
409 u8 num_locking_user_auth[2];
410 u8 initialPIN;
411 u8 revertedPIN;
412 u8 reserved01;
413 __be32 reserved02;
414};
415
416/* Union of features used to parse the discovery 0 response */
417struct d0_features {
418 __be16 code;
419 /*
420 * r_version bits:
421 * bits 4-7: version
422 * bits 0-3: reserved
423 */
424 u8 r_version;
425 u8 length;
426 u8 features[];
427};
428
429#endif /* _OPAL_PROTO_H */