xref: /linux/block/opal_proto.h (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
18c16567dSChristoph Hellwig /* SPDX-License-Identifier: GPL-2.0 */
2455a7b23SScott Bauer /*
3455a7b23SScott Bauer  * Copyright © 2016 Intel Corporation
4455a7b23SScott Bauer  *
5455a7b23SScott Bauer  * Authors:
6455a7b23SScott Bauer  *    Rafael Antognolli <rafael.antognolli@intel.com>
7455a7b23SScott Bauer  *    Scott  Bauer      <scott.bauer@intel.com>
8455a7b23SScott Bauer  */
9455a7b23SScott Bauer #include <linux/types.h>
10455a7b23SScott Bauer 
11455a7b23SScott Bauer #ifndef _OPAL_PROTO_H
12455a7b23SScott Bauer #define _OPAL_PROTO_H
13455a7b23SScott Bauer 
144f1244c8SChristoph Hellwig /*
154f1244c8SChristoph Hellwig  * These constant values come from:
164f1244c8SChristoph Hellwig  * SPC-4 section
174f1244c8SChristoph Hellwig  * 6.30 SECURITY PROTOCOL IN command / table 265.
184f1244c8SChristoph Hellwig  */
194f1244c8SChristoph Hellwig enum {
204f1244c8SChristoph Hellwig 	TCG_SECP_00 = 0,
214f1244c8SChristoph Hellwig 	TCG_SECP_01,
224f1244c8SChristoph Hellwig };
234f1244c8SChristoph Hellwig 
244f1244c8SChristoph Hellwig /*
254f1244c8SChristoph Hellwig  * Token defs derived from:
264f1244c8SChristoph Hellwig  * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
274f1244c8SChristoph Hellwig  * 3.2.2 Data Stream Encoding
284f1244c8SChristoph Hellwig  */
294f1244c8SChristoph Hellwig enum opal_response_token {
304f1244c8SChristoph Hellwig 	OPAL_DTA_TOKENID_BYTESTRING = 0xe0,
314f1244c8SChristoph Hellwig 	OPAL_DTA_TOKENID_SINT = 0xe1,
324f1244c8SChristoph Hellwig 	OPAL_DTA_TOKENID_UINT = 0xe2,
334f1244c8SChristoph Hellwig 	OPAL_DTA_TOKENID_TOKEN = 0xe3, /* actual token is returned */
344f1244c8SChristoph Hellwig 	OPAL_DTA_TOKENID_INVALID = 0X0
354f1244c8SChristoph Hellwig };
364f1244c8SChristoph Hellwig 
37455a7b23SScott Bauer #define DTAERROR_NO_METHOD_STATUS 0x89
38455a7b23SScott Bauer #define GENERIC_HOST_SESSION_NUM 0x41
3988d6041dSRevanth Rajashekar #define FIRST_TPER_SESSION_NUM	4096
40455a7b23SScott Bauer 
41455a7b23SScott Bauer #define TPER_SYNC_SUPPORTED 0x01
42c6ea7060Sdougmill@linux.vnet.ibm.com /* FC_LOCKING features */
43c6ea7060Sdougmill@linux.vnet.ibm.com #define LOCKING_SUPPORTED_MASK 0x01
44c6ea7060Sdougmill@linux.vnet.ibm.com #define LOCKING_ENABLED_MASK 0x02
45c6ea7060Sdougmill@linux.vnet.ibm.com #define LOCKED_MASK 0x04
46dbec491bSScott Bauer #define MBR_ENABLED_MASK 0x10
47c6ea7060Sdougmill@linux.vnet.ibm.com #define MBR_DONE_MASK 0x20
48455a7b23SScott Bauer 
49455a7b23SScott Bauer #define TINY_ATOM_DATA_MASK 0x3F
50455a7b23SScott Bauer #define TINY_ATOM_SIGNED 0x40
51455a7b23SScott Bauer 
52455a7b23SScott Bauer #define SHORT_ATOM_ID 0x80
53455a7b23SScott Bauer #define SHORT_ATOM_BYTESTRING 0x20
54455a7b23SScott Bauer #define SHORT_ATOM_SIGNED 0x10
55455a7b23SScott Bauer #define SHORT_ATOM_LEN_MASK 0xF
56455a7b23SScott Bauer 
57455a7b23SScott Bauer #define MEDIUM_ATOM_ID 0xC0
58455a7b23SScott Bauer #define MEDIUM_ATOM_BYTESTRING 0x10
59455a7b23SScott Bauer #define MEDIUM_ATOM_SIGNED 0x8
60455a7b23SScott Bauer #define MEDIUM_ATOM_LEN_MASK 0x7
61455a7b23SScott Bauer 
62455a7b23SScott Bauer #define LONG_ATOM_ID 0xe0
63455a7b23SScott Bauer #define LONG_ATOM_BYTESTRING 0x2
64455a7b23SScott Bauer #define LONG_ATOM_SIGNED 0x1
65455a7b23SScott Bauer 
66455a7b23SScott Bauer /* Derived from TCG Core spec 2.01 Section:
67455a7b23SScott Bauer  * 3.2.2.1
68455a7b23SScott Bauer  * Data Type
69455a7b23SScott Bauer  */
70455a7b23SScott Bauer #define TINY_ATOM_BYTE   0x7F
71455a7b23SScott Bauer #define SHORT_ATOM_BYTE  0xBF
72455a7b23SScott Bauer #define MEDIUM_ATOM_BYTE 0xDF
73455a7b23SScott Bauer #define LONG_ATOM_BYTE   0xE3
74*5429c8deSGreg Joyce #define EMPTY_ATOM_BYTE  0xFF
75455a7b23SScott Bauer 
76455a7b23SScott Bauer #define OPAL_INVAL_PARAM 12
77455a7b23SScott Bauer #define OPAL_MANUFACTURED_INACTIVE 0x08
78455a7b23SScott Bauer #define OPAL_DISCOVERY_COMID 0x0001
79455a7b23SScott Bauer 
80455a7b23SScott Bauer #define LOCKING_RANGE_NON_GLOBAL 0x03
81455a7b23SScott Bauer /*
82455a7b23SScott Bauer  * User IDs used in the TCG storage SSCs
83455a7b23SScott Bauer  * Derived from: TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
84455a7b23SScott Bauer  * Section: 6.3 Assigned UIDs
85455a7b23SScott Bauer  */
86455a7b23SScott Bauer #define OPAL_METHOD_LENGTH 8
87455a7b23SScott Bauer #define OPAL_MSID_KEYLEN 15
88455a7b23SScott Bauer #define OPAL_UID_LENGTH_HALF 4
89455a7b23SScott Bauer 
90175b6544SOndrej Kozina /*
91175b6544SOndrej Kozina  * Boolean operators from TCG Core spec 2.01 Section:
92175b6544SOndrej Kozina  * 5.1.3.11
93175b6544SOndrej Kozina  * Table 61
94175b6544SOndrej Kozina  */
95175b6544SOndrej Kozina #define OPAL_BOOLEAN_AND 0
96175b6544SOndrej Kozina #define OPAL_BOOLEAN_OR  1
97175b6544SOndrej Kozina #define OPAL_BOOLEAN_NOT 2
98175b6544SOndrej Kozina 
99455a7b23SScott Bauer /* Enum to index OPALUID array */
100455a7b23SScott Bauer enum opal_uid {
101455a7b23SScott Bauer 	/* users */
102455a7b23SScott Bauer 	OPAL_SMUID_UID,
103455a7b23SScott Bauer 	OPAL_THISSP_UID,
104455a7b23SScott Bauer 	OPAL_ADMINSP_UID,
105455a7b23SScott Bauer 	OPAL_LOCKINGSP_UID,
106455a7b23SScott Bauer 	OPAL_ENTERPRISE_LOCKINGSP_UID,
107455a7b23SScott Bauer 	OPAL_ANYBODY_UID,
108455a7b23SScott Bauer 	OPAL_SID_UID,
109455a7b23SScott Bauer 	OPAL_ADMIN1_UID,
110455a7b23SScott Bauer 	OPAL_USER1_UID,
111455a7b23SScott Bauer 	OPAL_USER2_UID,
112455a7b23SScott Bauer 	OPAL_PSID_UID,
113455a7b23SScott Bauer 	OPAL_ENTERPRISE_BANDMASTER0_UID,
114455a7b23SScott Bauer 	OPAL_ENTERPRISE_ERASEMASTER_UID,
115455a7b23SScott Bauer 	/* tables */
116ff91064eSJonas Rabenstein 	OPAL_TABLE_TABLE,
117455a7b23SScott Bauer 	OPAL_LOCKINGRANGE_GLOBAL,
1188be19a02SOndrej Kozina 	OPAL_LOCKINGRANGE_ACE_START_TO_KEY,
119455a7b23SScott Bauer 	OPAL_LOCKINGRANGE_ACE_RDLOCKED,
120455a7b23SScott Bauer 	OPAL_LOCKINGRANGE_ACE_WRLOCKED,
121455a7b23SScott Bauer 	OPAL_MBRCONTROL,
122455a7b23SScott Bauer 	OPAL_MBR,
123455a7b23SScott Bauer 	OPAL_AUTHORITY_TABLE,
124455a7b23SScott Bauer 	OPAL_C_PIN_TABLE,
125455a7b23SScott Bauer 	OPAL_LOCKING_INFO_TABLE,
126455a7b23SScott Bauer 	OPAL_ENTERPRISE_LOCKING_INFO_TABLE,
12762c441c6SRevanth Rajashekar 	OPAL_DATASTORE,
128455a7b23SScott Bauer 	/* C_PIN_TABLE object ID's */
129455a7b23SScott Bauer 	OPAL_C_PIN_MSID,
130455a7b23SScott Bauer 	OPAL_C_PIN_SID,
131455a7b23SScott Bauer 	OPAL_C_PIN_ADMIN1,
132455a7b23SScott Bauer 	/* half UID's (only first 4 bytes used) */
133455a7b23SScott Bauer 	OPAL_HALF_UID_AUTHORITY_OBJ_REF,
134455a7b23SScott Bauer 	OPAL_HALF_UID_BOOLEAN_ACE,
135455a7b23SScott Bauer 	/* omitted optional parameter */
136455a7b23SScott Bauer 	OPAL_UID_HEXFF,
137455a7b23SScott Bauer };
138455a7b23SScott Bauer 
139455a7b23SScott Bauer /* Enum for indexing the OPALMETHOD array */
140455a7b23SScott Bauer enum opal_method {
141455a7b23SScott Bauer 	OPAL_PROPERTIES,
142455a7b23SScott Bauer 	OPAL_STARTSESSION,
143455a7b23SScott Bauer 	OPAL_REVERT,
144455a7b23SScott Bauer 	OPAL_ACTIVATE,
145455a7b23SScott Bauer 	OPAL_EGET,
146455a7b23SScott Bauer 	OPAL_ESET,
147455a7b23SScott Bauer 	OPAL_NEXT,
148455a7b23SScott Bauer 	OPAL_EAUTHENTICATE,
149455a7b23SScott Bauer 	OPAL_GETACL,
150455a7b23SScott Bauer 	OPAL_GENKEY,
151455a7b23SScott Bauer 	OPAL_REVERTSP,
152455a7b23SScott Bauer 	OPAL_GET,
153455a7b23SScott Bauer 	OPAL_SET,
154455a7b23SScott Bauer 	OPAL_AUTHENTICATE,
155455a7b23SScott Bauer 	OPAL_RANDOM,
156455a7b23SScott Bauer 	OPAL_ERASE,
157455a7b23SScott Bauer };
158455a7b23SScott Bauer 
159455a7b23SScott Bauer enum opal_token {
160455a7b23SScott Bauer 	/* Boolean */
161455a7b23SScott Bauer 	OPAL_TRUE = 0x01,
162455a7b23SScott Bauer 	OPAL_FALSE = 0x00,
163455a7b23SScott Bauer 	OPAL_BOOLEAN_EXPR = 0x03,
164455a7b23SScott Bauer 	/* cellblocks */
165455a7b23SScott Bauer 	OPAL_TABLE = 0x00,
166455a7b23SScott Bauer 	OPAL_STARTROW = 0x01,
167455a7b23SScott Bauer 	OPAL_ENDROW = 0x02,
168455a7b23SScott Bauer 	OPAL_STARTCOLUMN = 0x03,
169455a7b23SScott Bauer 	OPAL_ENDCOLUMN = 0x04,
170455a7b23SScott Bauer 	OPAL_VALUES = 0x01,
171ff91064eSJonas Rabenstein 	/* table table */
172ff91064eSJonas Rabenstein 	OPAL_TABLE_UID = 0x00,
173ff91064eSJonas Rabenstein 	OPAL_TABLE_NAME = 0x01,
174ff91064eSJonas Rabenstein 	OPAL_TABLE_COMMON = 0x02,
175ff91064eSJonas Rabenstein 	OPAL_TABLE_TEMPLATE = 0x03,
176ff91064eSJonas Rabenstein 	OPAL_TABLE_KIND = 0x04,
177ff91064eSJonas Rabenstein 	OPAL_TABLE_COLUMN = 0x05,
178ff91064eSJonas Rabenstein 	OPAL_TABLE_COLUMNS = 0x06,
179ff91064eSJonas Rabenstein 	OPAL_TABLE_ROWS = 0x07,
180ff91064eSJonas Rabenstein 	OPAL_TABLE_ROWS_FREE = 0x08,
181ff91064eSJonas Rabenstein 	OPAL_TABLE_ROW_BYTES = 0x09,
182ff91064eSJonas Rabenstein 	OPAL_TABLE_LASTID = 0x0A,
183ff91064eSJonas Rabenstein 	OPAL_TABLE_MIN = 0x0B,
184ff91064eSJonas Rabenstein 	OPAL_TABLE_MAX = 0x0C,
185455a7b23SScott Bauer 	/* authority table */
186455a7b23SScott Bauer 	OPAL_PIN = 0x03,
187455a7b23SScott Bauer 	/* locking tokens */
188455a7b23SScott Bauer 	OPAL_RANGESTART = 0x03,
189455a7b23SScott Bauer 	OPAL_RANGELENGTH = 0x04,
190455a7b23SScott Bauer 	OPAL_READLOCKENABLED = 0x05,
191455a7b23SScott Bauer 	OPAL_WRITELOCKENABLED = 0x06,
192455a7b23SScott Bauer 	OPAL_READLOCKED = 0x07,
193455a7b23SScott Bauer 	OPAL_WRITELOCKED = 0x08,
194455a7b23SScott Bauer 	OPAL_ACTIVEKEY = 0x0A,
195a4ddbd1bSDavid Kozub 	/* lockingsp table */
196a4ddbd1bSDavid Kozub 	OPAL_LIFECYCLE = 0x06,
197455a7b23SScott Bauer 	/* locking info table */
198455a7b23SScott Bauer 	OPAL_MAXRANGES = 0x04,
199455a7b23SScott Bauer 	/* mbr control */
200455a7b23SScott Bauer 	OPAL_MBRENABLE = 0x01,
201455a7b23SScott Bauer 	OPAL_MBRDONE = 0x02,
202455a7b23SScott Bauer 	/* properties */
203455a7b23SScott Bauer 	OPAL_HOSTPROPERTIES = 0x00,
204455a7b23SScott Bauer 	/* atoms */
205455a7b23SScott Bauer 	OPAL_STARTLIST = 0xf0,
206455a7b23SScott Bauer 	OPAL_ENDLIST = 0xf1,
207455a7b23SScott Bauer 	OPAL_STARTNAME = 0xf2,
208455a7b23SScott Bauer 	OPAL_ENDNAME = 0xf3,
209455a7b23SScott Bauer 	OPAL_CALL = 0xf8,
210455a7b23SScott Bauer 	OPAL_ENDOFDATA = 0xf9,
211455a7b23SScott Bauer 	OPAL_ENDOFSESSION = 0xfa,
212455a7b23SScott Bauer 	OPAL_STARTTRANSACTON = 0xfb,
213455a7b23SScott Bauer 	OPAL_ENDTRANSACTON = 0xfC,
214455a7b23SScott Bauer 	OPAL_EMPTYATOM = 0xff,
215455a7b23SScott Bauer 	OPAL_WHERE = 0x00,
216455a7b23SScott Bauer };
217455a7b23SScott Bauer 
218455a7b23SScott Bauer /* Locking state for a locking range */
219455a7b23SScott Bauer enum opal_lockingstate {
220455a7b23SScott Bauer 	OPAL_LOCKING_READWRITE = 0x01,
221455a7b23SScott Bauer 	OPAL_LOCKING_READONLY = 0x02,
222455a7b23SScott Bauer 	OPAL_LOCKING_LOCKED = 0x03,
223455a7b23SScott Bauer };
224455a7b23SScott Bauer 
225c6da429eSRevanth Rajashekar enum opal_parameter {
226c6da429eSRevanth Rajashekar 	OPAL_SUM_SET_LIST = 0x060000,
227c6da429eSRevanth Rajashekar };
228c6da429eSRevanth Rajashekar 
2295c82efc1SGreg Joyce enum opal_revertlsp {
2305c82efc1SGreg Joyce 	OPAL_KEEP_GLOBAL_RANGE_KEY = 0x060000,
2315c82efc1SGreg Joyce };
2325c82efc1SGreg Joyce 
233455a7b23SScott Bauer /* Packets derived from:
234455a7b23SScott Bauer  * TCG_Storage_Architecture_Core_Spec_v2.01_r1.00
235455a7b23SScott Bauer  * Secion: 3.2.3 ComPackets, Packets & Subpackets
236455a7b23SScott Bauer  */
237455a7b23SScott Bauer 
238455a7b23SScott Bauer /* Comm Packet (header) for transmissions. */
239455a7b23SScott Bauer struct opal_compacket {
240455a7b23SScott Bauer 	__be32 reserved0;
241455a7b23SScott Bauer 	u8 extendedComID[4];
242455a7b23SScott Bauer 	__be32 outstandingData;
243455a7b23SScott Bauer 	__be32 minTransfer;
244455a7b23SScott Bauer 	__be32 length;
245455a7b23SScott Bauer };
246455a7b23SScott Bauer 
247455a7b23SScott Bauer /* Packet structure. */
248455a7b23SScott Bauer struct opal_packet {
249455a7b23SScott Bauer 	__be32 tsn;
250455a7b23SScott Bauer 	__be32 hsn;
251455a7b23SScott Bauer 	__be32 seq_number;
252455a7b23SScott Bauer 	__be16 reserved0;
253455a7b23SScott Bauer 	__be16 ack_type;
254455a7b23SScott Bauer 	__be32 acknowledgment;
255455a7b23SScott Bauer 	__be32 length;
256455a7b23SScott Bauer };
257455a7b23SScott Bauer 
258455a7b23SScott Bauer /* Data sub packet header */
259455a7b23SScott Bauer struct opal_data_subpacket {
260455a7b23SScott Bauer 	u8 reserved0[6];
261455a7b23SScott Bauer 	__be16 kind;
262455a7b23SScott Bauer 	__be32 length;
263455a7b23SScott Bauer };
264455a7b23SScott Bauer 
265455a7b23SScott Bauer /* header of a response */
266455a7b23SScott Bauer struct opal_header {
267455a7b23SScott Bauer 	struct opal_compacket cp;
268455a7b23SScott Bauer 	struct opal_packet pkt;
269455a7b23SScott Bauer 	struct opal_data_subpacket subpkt;
270455a7b23SScott Bauer };
271455a7b23SScott Bauer 
272455a7b23SScott Bauer #define FC_TPER       0x0001
273455a7b23SScott Bauer #define FC_LOCKING    0x0002
274455a7b23SScott Bauer #define FC_GEOMETRY   0x0003
275455a7b23SScott Bauer #define FC_ENTERPRISE 0x0100
276455a7b23SScott Bauer #define FC_DATASTORE  0x0202
277455a7b23SScott Bauer #define FC_SINGLEUSER 0x0201
278455a7b23SScott Bauer #define FC_OPALV100   0x0200
279455a7b23SScott Bauer #define FC_OPALV200   0x0203
280455a7b23SScott Bauer 
281455a7b23SScott Bauer /*
282455a7b23SScott Bauer  * The Discovery 0 Header. As defined in
283455a7b23SScott Bauer  * Opal SSC Documentation
284455a7b23SScott Bauer  * Section: 3.3.5 Capability Discovery
285455a7b23SScott Bauer  */
286455a7b23SScott Bauer struct d0_header {
287455a7b23SScott Bauer 	__be32 length; /* the length of the header 48 in 2.00.100 */
288455a7b23SScott Bauer 	__be32 revision; /**< revision of the header 1 in 2.00.100 */
289455a7b23SScott Bauer 	__be32 reserved01;
290455a7b23SScott Bauer 	__be32 reserved02;
291455a7b23SScott Bauer 	/*
292455a7b23SScott Bauer 	 * the remainder of the structure is vendor specific and will not be
293455a7b23SScott Bauer 	 * addressed now
294455a7b23SScott Bauer 	 */
295455a7b23SScott Bauer 	u8 ignored[32];
296455a7b23SScott Bauer };
297455a7b23SScott Bauer 
298455a7b23SScott Bauer /*
299455a7b23SScott Bauer  * TPer Feature Descriptor. Contains flags indicating support for the
300455a7b23SScott Bauer  * TPer features described in the OPAL specification. The names match the
301455a7b23SScott Bauer  * OPAL terminology
302455a7b23SScott Bauer  *
303455a7b23SScott Bauer  * code == 0x001 in 2.00.100
304455a7b23SScott Bauer  */
305455a7b23SScott Bauer struct d0_tper_features {
306455a7b23SScott Bauer 	/*
307455a7b23SScott Bauer 	 * supported_features bits:
308455a7b23SScott Bauer 	 * bit 7: reserved
309455a7b23SScott Bauer 	 * bit 6: com ID management
310455a7b23SScott Bauer 	 * bit 5: reserved
311455a7b23SScott Bauer 	 * bit 4: streaming support
312455a7b23SScott Bauer 	 * bit 3: buffer management
313455a7b23SScott Bauer 	 * bit 2: ACK/NACK
314455a7b23SScott Bauer 	 * bit 1: async
315455a7b23SScott Bauer 	 * bit 0: sync
316455a7b23SScott Bauer 	 */
317455a7b23SScott Bauer 	u8 supported_features;
318455a7b23SScott Bauer 	/*
319455a7b23SScott Bauer 	 * bytes 5 through 15 are reserved, but we represent the first 3 as
320455a7b23SScott Bauer 	 * u8 to keep the other two 32bits integers aligned.
321455a7b23SScott Bauer 	 */
322455a7b23SScott Bauer 	u8 reserved01[3];
323455a7b23SScott Bauer 	__be32 reserved02;
324455a7b23SScott Bauer 	__be32 reserved03;
325455a7b23SScott Bauer };
326455a7b23SScott Bauer 
327455a7b23SScott Bauer /*
328455a7b23SScott Bauer  * Locking Feature Descriptor. Contains flags indicating support for the
329455a7b23SScott Bauer  * locking features described in the OPAL specification. The names match the
330455a7b23SScott Bauer  * OPAL terminology
331455a7b23SScott Bauer  *
332455a7b23SScott Bauer  * code == 0x0002 in 2.00.100
333455a7b23SScott Bauer  */
334455a7b23SScott Bauer struct d0_locking_features {
335455a7b23SScott Bauer 	/*
336455a7b23SScott Bauer 	 * supported_features bits:
337455a7b23SScott Bauer 	 * bits 6-7: reserved
338455a7b23SScott Bauer 	 * bit 5: MBR done
339455a7b23SScott Bauer 	 * bit 4: MBR enabled
340455a7b23SScott Bauer 	 * bit 3: media encryption
341455a7b23SScott Bauer 	 * bit 2: locked
342455a7b23SScott Bauer 	 * bit 1: locking enabled
343455a7b23SScott Bauer 	 * bit 0: locking supported
344455a7b23SScott Bauer 	 */
345455a7b23SScott Bauer 	u8 supported_features;
346455a7b23SScott Bauer 	/*
347455a7b23SScott Bauer 	 * bytes 5 through 15 are reserved, but we represent the first 3 as
348455a7b23SScott Bauer 	 * u8 to keep the other two 32bits integers aligned.
349455a7b23SScott Bauer 	 */
350455a7b23SScott Bauer 	u8 reserved01[3];
351455a7b23SScott Bauer 	__be32 reserved02;
352455a7b23SScott Bauer 	__be32 reserved03;
353455a7b23SScott Bauer };
354455a7b23SScott Bauer 
355455a7b23SScott Bauer /*
356455a7b23SScott Bauer  * Geometry Feature Descriptor. Contains flags indicating support for the
357455a7b23SScott Bauer  * geometry features described in the OPAL specification. The names match the
358455a7b23SScott Bauer  * OPAL terminology
359455a7b23SScott Bauer  *
360455a7b23SScott Bauer  * code == 0x0003 in 2.00.100
361455a7b23SScott Bauer  */
362455a7b23SScott Bauer struct d0_geometry_features {
363455a7b23SScott Bauer 	/*
364455a7b23SScott Bauer 	 * skip 32 bits from header, needed to align the struct to 64 bits.
365455a7b23SScott Bauer 	 */
366455a7b23SScott Bauer 	u8 header[4];
367455a7b23SScott Bauer 	/*
368455a7b23SScott Bauer 	 * reserved01:
369455a7b23SScott Bauer 	 * bits 1-6: reserved
370455a7b23SScott Bauer 	 * bit 0: align
371455a7b23SScott Bauer 	 */
372455a7b23SScott Bauer 	u8 reserved01;
373455a7b23SScott Bauer 	u8 reserved02[7];
374455a7b23SScott Bauer 	__be32 logical_block_size;
375455a7b23SScott Bauer 	__be64 alignment_granularity;
376455a7b23SScott Bauer 	__be64 lowest_aligned_lba;
377455a7b23SScott Bauer };
378455a7b23SScott Bauer 
379455a7b23SScott Bauer /*
380455a7b23SScott Bauer  * Enterprise SSC Feature
381455a7b23SScott Bauer  *
382455a7b23SScott Bauer  * code == 0x0100
383455a7b23SScott Bauer  */
384455a7b23SScott Bauer struct d0_enterprise_ssc {
385455a7b23SScott Bauer 	__be16 baseComID;
386455a7b23SScott Bauer 	__be16 numComIDs;
387455a7b23SScott Bauer 	/* range_crossing:
388455a7b23SScott Bauer 	 * bits 1-6: reserved
389455a7b23SScott Bauer 	 * bit 0: range crossing
390455a7b23SScott Bauer 	 */
391455a7b23SScott Bauer 	u8 range_crossing;
392455a7b23SScott Bauer 	u8 reserved01;
393455a7b23SScott Bauer 	__be16 reserved02;
394455a7b23SScott Bauer 	__be32 reserved03;
395455a7b23SScott Bauer 	__be32 reserved04;
396455a7b23SScott Bauer };
397455a7b23SScott Bauer 
398455a7b23SScott Bauer /*
399455a7b23SScott Bauer  * Opal V1 feature
400455a7b23SScott Bauer  *
401455a7b23SScott Bauer  * code == 0x0200
402455a7b23SScott Bauer  */
403455a7b23SScott Bauer struct d0_opal_v100 {
404455a7b23SScott Bauer 	__be16 baseComID;
405455a7b23SScott Bauer 	__be16 numComIDs;
406455a7b23SScott Bauer };
407455a7b23SScott Bauer 
408455a7b23SScott Bauer /*
409455a7b23SScott Bauer  * Single User Mode feature
410455a7b23SScott Bauer  *
411455a7b23SScott Bauer  * code == 0x0201
412455a7b23SScott Bauer  */
413455a7b23SScott Bauer struct d0_single_user_mode {
414455a7b23SScott Bauer 	__be32 num_locking_objects;
415455a7b23SScott Bauer 	/* reserved01:
416455a7b23SScott Bauer 	 * bit 0: any
417455a7b23SScott Bauer 	 * bit 1: all
418455a7b23SScott Bauer 	 * bit 2: policy
419455a7b23SScott Bauer 	 * bits 3-7: reserved
420455a7b23SScott Bauer 	 */
421455a7b23SScott Bauer 	u8 reserved01;
422455a7b23SScott Bauer 	u8 reserved02;
423455a7b23SScott Bauer 	__be16 reserved03;
424455a7b23SScott Bauer 	__be32 reserved04;
425455a7b23SScott Bauer };
426455a7b23SScott Bauer 
427455a7b23SScott Bauer /*
428455a7b23SScott Bauer  * Additonal Datastores feature
429455a7b23SScott Bauer  *
430455a7b23SScott Bauer  * code == 0x0202
431455a7b23SScott Bauer  */
432455a7b23SScott Bauer struct d0_datastore_table {
433455a7b23SScott Bauer 	__be16 reserved01;
434455a7b23SScott Bauer 	__be16 max_tables;
435455a7b23SScott Bauer 	__be32 max_size_tables;
436455a7b23SScott Bauer 	__be32 table_size_alignment;
437455a7b23SScott Bauer };
438455a7b23SScott Bauer 
439455a7b23SScott Bauer /*
440455a7b23SScott Bauer  * OPAL 2.0 feature
441455a7b23SScott Bauer  *
442455a7b23SScott Bauer  * code == 0x0203
443455a7b23SScott Bauer  */
444455a7b23SScott Bauer struct d0_opal_v200 {
445455a7b23SScott Bauer 	__be16 baseComID;
446455a7b23SScott Bauer 	__be16 numComIDs;
447455a7b23SScott Bauer 	/* range_crossing:
448455a7b23SScott Bauer 	 * bits 1-6: reserved
449455a7b23SScott Bauer 	 * bit 0: range crossing
450455a7b23SScott Bauer 	 */
451455a7b23SScott Bauer 	u8 range_crossing;
452455a7b23SScott Bauer 	/* num_locking_admin_auth:
453455a7b23SScott Bauer 	 * not aligned to 16 bits, so use two u8.
454455a7b23SScott Bauer 	 * stored in big endian:
455455a7b23SScott Bauer 	 * 0: MSB
456455a7b23SScott Bauer 	 * 1: LSB
457455a7b23SScott Bauer 	 */
458455a7b23SScott Bauer 	u8 num_locking_admin_auth[2];
459455a7b23SScott Bauer 	/* num_locking_user_auth:
460455a7b23SScott Bauer 	 * not aligned to 16 bits, so use two u8.
461455a7b23SScott Bauer 	 * stored in big endian:
462455a7b23SScott Bauer 	 * 0: MSB
463455a7b23SScott Bauer 	 * 1: LSB
464455a7b23SScott Bauer 	 */
465455a7b23SScott Bauer 	u8 num_locking_user_auth[2];
466455a7b23SScott Bauer 	u8 initialPIN;
467455a7b23SScott Bauer 	u8 revertedPIN;
468455a7b23SScott Bauer 	u8 reserved01;
469455a7b23SScott Bauer 	__be32 reserved02;
470455a7b23SScott Bauer };
471455a7b23SScott Bauer 
472455a7b23SScott Bauer /* Union of features used to parse the discovery 0 response */
473455a7b23SScott Bauer struct d0_features {
474455a7b23SScott Bauer 	__be16 code;
475455a7b23SScott Bauer 	/*
476455a7b23SScott Bauer 	 * r_version bits:
477455a7b23SScott Bauer 	 * bits 4-7: version
478455a7b23SScott Bauer 	 * bits 0-3: reserved
479455a7b23SScott Bauer 	 */
480455a7b23SScott Bauer 	u8 r_version;
481455a7b23SScott Bauer 	u8 length;
482455a7b23SScott Bauer 	u8 features[];
483455a7b23SScott Bauer };
484455a7b23SScott Bauer 
485455a7b23SScott Bauer #endif /* _OPAL_PROTO_H */
486