Merge branch 'topic/asoc' into for-linus
[linux-2.6-block.git] / include / scsi / osd_protocol.h
CommitLineData
de258bf5
BH
1/*
2 * osd_protocol.h - OSD T10 standard C definitions.
3 *
4 * Copyright (C) 2008 Panasas Inc. All rights reserved.
5 *
6 * Authors:
7 * Boaz Harrosh <bharrosh@panasas.com>
8 * Benny Halevy <bhalevy@panasas.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 *
13 * This file contains types and constants that are defined by the protocol
14 * Note: All names and symbols are taken from the OSD standard's text.
15 */
16#ifndef __OSD_PROTOCOL_H__
17#define __OSD_PROTOCOL_H__
18
19#include <linux/types.h>
20#include <asm/unaligned.h>
21#include <scsi/scsi.h>
22
23enum {
24 OSDv1_ADDITIONAL_CDB_LENGTH = 192,
25 OSDv1_TOTAL_CDB_LEN = OSDv1_ADDITIONAL_CDB_LENGTH + 8,
26 OSDv1_CAP_LEN = 80,
e9da4d7f 27
de258bf5 28 /* Latest supported version */
e9da4d7f 29 OSDv2_ADDITIONAL_CDB_LENGTH = 228,
c6572c98 30 OSD_ADDITIONAL_CDB_LENGTH =
e9da4d7f 31 OSDv2_ADDITIONAL_CDB_LENGTH,
c6572c98 32 OSD_TOTAL_CDB_LEN = OSD_ADDITIONAL_CDB_LENGTH + 8,
e9da4d7f 33 OSD_CAP_LEN = 104,
de258bf5
BH
34
35 OSD_SYSTEMID_LEN = 20,
f8d3a644 36 OSDv1_CRYPTO_KEYID_SIZE = 20,
e9da4d7f 37 OSDv2_CRYPTO_KEYID_SIZE = 32,
f8d3a644 38 OSD_CRYPTO_KEYID_SIZE = OSDv2_CRYPTO_KEYID_SIZE,
de258bf5
BH
39 OSD_CRYPTO_SEED_SIZE = 4,
40 OSD_CRYPTO_NONCE_SIZE = 12,
41 OSD_MAX_SENSE_LEN = 252, /* from SPC-3 */
42
43 OSD_PARTITION_FIRST_ID = 0x10000,
44 OSD_OBJECT_FIRST_ID = 0x10000,
45};
46
47/* (osd-r10 5.2.4)
48 * osd2r03: 5.2.3 Caching control bits
49 */
50enum osd_options_byte {
51 OSD_CDB_FUA = 0x08, /* Force Unit Access */
52 OSD_CDB_DPO = 0x10, /* Disable Page Out */
53};
54
55/*
56 * osd2r03: 5.2.5 Isolation.
57 * First 3 bits, V2-only.
58 * Also for attr 110h "default isolation method" at Root Information page
59 */
60enum osd_options_byte_isolation {
61 OSD_ISOLATION_DEFAULT = 0,
62 OSD_ISOLATION_NONE = 1,
63 OSD_ISOLATION_STRICT = 2,
64 OSD_ISOLATION_RANGE = 4,
65 OSD_ISOLATION_FUNCTIONAL = 5,
66 OSD_ISOLATION_VENDOR = 7,
67};
68
69/* (osd-r10: 6.7)
70 * osd2r03: 6.8 FLUSH, FLUSH COLLECTION, FLUSH OSD, FLUSH PARTITION
71 */
72enum osd_options_flush_scope_values {
73 OSD_CDB_FLUSH_ALL = 0,
74 OSD_CDB_FLUSH_ATTR_ONLY = 1,
75
76 OSD_CDB_FLUSH_ALL_RECURSIVE = 2,
77 /* V2-only */
78 OSD_CDB_FLUSH_ALL_RANGE = 2,
79};
80
81/* osd2r03: 5.2.10 Timestamps control */
82enum {
83 OSD_CDB_NORMAL_TIMESTAMPS = 0,
84 OSD_CDB_BYPASS_TIMESTAMPS = 0x7f,
85};
86
87/* (osd-r10: 5.2.2.1)
88 * osd2r03: 5.2.4.1 Get and set attributes CDB format selection
89 * 2 bits at second nibble of command_specific_options byte
90 */
91enum osd_attributes_mode {
92 /* V2-only */
93 OSD_CDB_SET_ONE_ATTR = 0x10,
94
95 OSD_CDB_GET_ATTR_PAGE_SET_ONE = 0x20,
96 OSD_CDB_GET_SET_ATTR_LISTS = 0x30,
97
98 OSD_CDB_GET_SET_ATTR_MASK = 0x30,
99};
100
101/* (osd-r10: 4.12.5)
102 * osd2r03: 4.14.5 Data-In and Data-Out buffer offsets
103 * byte offset = mantissa * (2^(exponent+8))
104 * struct {
105 * unsigned mantissa: 28;
106 * int exponent: 04;
107 * }
108 */
109typedef __be32 __bitwise osd_cdb_offset;
110
111enum {
112 OSD_OFFSET_UNUSED = 0xFFFFFFFF,
113 OSD_OFFSET_MAX_BITS = 28,
114
115 OSDv1_OFFSET_MIN_SHIFT = 8,
c6572c98 116 OSD_OFFSET_MIN_SHIFT = 3,
de258bf5
BH
117 OSD_OFFSET_MAX_SHIFT = 16,
118};
119
120/* Return the smallest allowed encoded offset that contains @offset.
121 *
122 * The actual encoded offset returned is @offset + *padding.
123 * (up to max_shift, non-inclusive)
124 */
125osd_cdb_offset __osd_encode_offset(u64 offset, unsigned *padding,
126 int min_shift, int max_shift);
127
128/* Minimum alignment is 256 bytes
129 * Note: Seems from std v1 that exponent can be from 0+8 to 0xE+8 (inclusive)
130 * which is 8 to 23 but IBM code restricts it to 16, so be it.
131 */
132static inline osd_cdb_offset osd_encode_offset_v1(u64 offset, unsigned *padding)
133{
134 return __osd_encode_offset(offset, padding,
135 OSDv1_OFFSET_MIN_SHIFT, OSD_OFFSET_MAX_SHIFT);
136}
137
c6572c98
BH
138/* Minimum 8 bytes alignment
139 * Same as v1 but since exponent can be signed than a less than
140 * 256 alignment can be reached with small offsets (<2GB)
141 */
142static inline osd_cdb_offset osd_encode_offset_v2(u64 offset, unsigned *padding)
143{
144 return __osd_encode_offset(offset, padding,
145 OSD_OFFSET_MIN_SHIFT, OSD_OFFSET_MAX_SHIFT);
146}
147
de258bf5
BH
148/* osd2r03: 5.2.1 Overview */
149struct osd_cdb_head {
150 struct scsi_varlen_cdb_hdr varlen_cdb;
151/*10*/ u8 options;
152 u8 command_specific_options;
153 u8 timestamp_control;
154/*13*/ u8 reserved1[3];
155/*16*/ __be64 partition;
156/*24*/ __be64 object;
157/*32*/ union { /* V1 vs V2 alignment differences */
158 struct __osdv1_cdb_addr_len {
159/*32*/ __be32 list_identifier;/* Rarely used */
160/*36*/ __be64 length;
161/*44*/ __be64 start_address;
162 } __packed v1;
c6572c98
BH
163
164 struct __osdv2_cdb_addr_len {
165 /* called allocation_length in some commands */
166/*32*/ __be64 length;
167/*40*/ __be64 start_address;
e9da4d7f
BH
168 union {
169/*48*/ __be32 list_identifier;/* Rarely used */
170 /* OSD2r05 5.2.5 CDB continuation length */
171/*48*/ __be32 cdb_continuation_length;
172 };
c6572c98 173 } __packed v2;
de258bf5
BH
174 };
175/*52*/ union { /* selected attributes mode Page/List/Single */
176 struct osd_attributes_page_mode {
177/*52*/ __be32 get_attr_page;
178/*56*/ __be32 get_attr_alloc_length;
179/*60*/ osd_cdb_offset get_attr_offset;
180
181/*64*/ __be32 set_attr_page;
182/*68*/ __be32 set_attr_id;
183/*72*/ __be32 set_attr_length;
184/*76*/ osd_cdb_offset set_attr_offset;
185/*80*/ } __packed attrs_page;
186
187 struct osd_attributes_list_mode {
188/*52*/ __be32 get_attr_desc_bytes;
189/*56*/ osd_cdb_offset get_attr_desc_offset;
190
191/*60*/ __be32 get_attr_alloc_length;
192/*64*/ osd_cdb_offset get_attr_offset;
193
194/*68*/ __be32 set_attr_bytes;
195/*72*/ osd_cdb_offset set_attr_offset;
196 __be32 not_used;
197/*80*/ } __packed attrs_list;
198
199 /* osd2r03:5.2.4.2 Set one attribute value using CDB fields */
200 struct osd_attributes_cdb_mode {
201/*52*/ __be32 set_attr_page;
202/*56*/ __be32 set_attr_id;
203/*60*/ __be16 set_attr_len;
204/*62*/ u8 set_attr_val[18];
205/*80*/ } __packed attrs_cdb;
206/*52*/ u8 get_set_attributes_parameters[28];
207 };
208} __packed;
209/*80*/
210
211/*160 v1*/
f8d3a644
BH
212struct osdv1_security_parameters {
213/*160*/u8 integrity_check_value[OSDv1_CRYPTO_KEYID_SIZE];
de258bf5
BH
214/*180*/u8 request_nonce[OSD_CRYPTO_NONCE_SIZE];
215/*192*/osd_cdb_offset data_in_integrity_check_offset;
216/*196*/osd_cdb_offset data_out_integrity_check_offset;
217} __packed;
218/*200 v1*/
c6572c98 219
f8d3a644
BH
220/*184 v2*/
221struct osdv2_security_parameters {
222/*184*/u8 integrity_check_value[OSDv2_CRYPTO_KEYID_SIZE];
223/*216*/u8 request_nonce[OSD_CRYPTO_NONCE_SIZE];
224/*228*/osd_cdb_offset data_in_integrity_check_offset;
225/*232*/osd_cdb_offset data_out_integrity_check_offset;
226} __packed;
227/*236 v2*/
228
229struct osd_security_parameters {
230 union {
231 struct osdv1_security_parameters v1;
232 struct osdv2_security_parameters v2;
233 };
234};
de258bf5
BH
235
236struct osdv1_cdb {
237 struct osd_cdb_head h;
238 u8 caps[OSDv1_CAP_LEN];
f8d3a644 239 struct osdv1_security_parameters sec_params;
de258bf5
BH
240} __packed;
241
c6572c98
BH
242struct osdv2_cdb {
243 struct osd_cdb_head h;
244 u8 caps[OSD_CAP_LEN];
f8d3a644 245 struct osdv2_security_parameters sec_params;
c6572c98
BH
246} __packed;
247
de258bf5
BH
248struct osd_cdb {
249 union {
250 struct osdv1_cdb v1;
c6572c98 251 struct osdv2_cdb v2;
de258bf5
BH
252 u8 buff[OSD_TOTAL_CDB_LEN];
253 };
254} __packed;
255
256static inline struct osd_cdb_head *osd_cdb_head(struct osd_cdb *ocdb)
257{
258 return (struct osd_cdb_head *)ocdb->buff;
259}
260
261/* define both version actions
262 * Ex name = FORMAT_OSD we have OSD_ACT_FORMAT_OSD && OSDv1_ACT_FORMAT_OSD
263 */
264#define OSD_ACT___(Name, Num) \
265 OSD_ACT_##Name = __constant_cpu_to_be16(0x8880 + Num), \
266 OSDv1_ACT_##Name = __constant_cpu_to_be16(0x8800 + Num),
267
268/* V2 only actions */
269#define OSD_ACT_V2(Name, Num) \
270 OSD_ACT_##Name = __constant_cpu_to_be16(0x8880 + Num),
271
272#define OSD_ACT_V1_V2(Name, Num1, Num2) \
273 OSD_ACT_##Name = __constant_cpu_to_be16(Num2), \
274 OSDv1_ACT_##Name = __constant_cpu_to_be16(Num1),
275
276enum osd_service_actions {
277 OSD_ACT_V2(OBJECT_STRUCTURE_CHECK, 0x00)
278 OSD_ACT___(FORMAT_OSD, 0x01)
279 OSD_ACT___(CREATE, 0x02)
280 OSD_ACT___(LIST, 0x03)
281 OSD_ACT_V2(PUNCH, 0x04)
282 OSD_ACT___(READ, 0x05)
283 OSD_ACT___(WRITE, 0x06)
284 OSD_ACT___(APPEND, 0x07)
285 OSD_ACT___(FLUSH, 0x08)
286 OSD_ACT_V2(CLEAR, 0x09)
287 OSD_ACT___(REMOVE, 0x0A)
288 OSD_ACT___(CREATE_PARTITION, 0x0B)
289 OSD_ACT___(REMOVE_PARTITION, 0x0C)
290 OSD_ACT___(GET_ATTRIBUTES, 0x0E)
291 OSD_ACT___(SET_ATTRIBUTES, 0x0F)
292 OSD_ACT___(CREATE_AND_WRITE, 0x12)
293 OSD_ACT___(CREATE_COLLECTION, 0x15)
294 OSD_ACT___(REMOVE_COLLECTION, 0x16)
295 OSD_ACT___(LIST_COLLECTION, 0x17)
296 OSD_ACT___(SET_KEY, 0x18)
297 OSD_ACT___(SET_MASTER_KEY, 0x19)
298 OSD_ACT___(FLUSH_COLLECTION, 0x1A)
299 OSD_ACT___(FLUSH_PARTITION, 0x1B)
300 OSD_ACT___(FLUSH_OSD, 0x1C)
301
302 OSD_ACT_V2(QUERY, 0x20)
303 OSD_ACT_V2(REMOVE_MEMBER_OBJECTS, 0x21)
304 OSD_ACT_V2(GET_MEMBER_ATTRIBUTES, 0x22)
305 OSD_ACT_V2(SET_MEMBER_ATTRIBUTES, 0x23)
feb6118d
BH
306
307 OSD_ACT_V2(CREATE_CLONE, 0x28)
308 OSD_ACT_V2(CREATE_SNAPSHOT, 0x29)
309 OSD_ACT_V2(DETACH_CLONE, 0x2A)
310 OSD_ACT_V2(REFRESH_SNAPSHOT_CLONE, 0x2B)
311 OSD_ACT_V2(RESTORE_PARTITION_FROM_SNAPSHOT, 0x2C)
312
de258bf5 313 OSD_ACT_V2(READ_MAP, 0x31)
feb6118d 314 OSD_ACT_V2(READ_MAPS_COMPARE, 0x32)
de258bf5
BH
315
316 OSD_ACT_V1_V2(PERFORM_SCSI_COMMAND, 0x8F7E, 0x8F7C)
317 OSD_ACT_V1_V2(SCSI_TASK_MANAGEMENT, 0x8F7F, 0x8F7D)
318 /* 0x8F80 to 0x8FFF are Vendor specific */
319};
320
321/* osd2r03: 7.1.3.2 List entry format for retrieving attributes */
322struct osd_attributes_list_attrid {
323 __be32 attr_page;
324 __be32 attr_id;
325} __packed;
326
71f32e31
BH
327/*
328 * NOTE: v1: is not aligned.
329 */
330struct osdv1_attributes_list_element {
331 __be32 attr_page;
332 __be32 attr_id;
333 __be16 attr_bytes; /* valid bytes at attr_val without padding */
334 u8 attr_val[0];
335} __packed;
336
de258bf5
BH
337/*
338 * osd2r03: 7.1.3.3 List entry format for retrieved attributes and
339 * for setting attributes
71f32e31 340 * NOTE: v2 is 8-bytes aligned
de258bf5 341 */
71f32e31 342struct osdv2_attributes_list_element {
de258bf5
BH
343 __be32 attr_page;
344 __be32 attr_id;
e9da4d7f 345 u8 reserved[6];
71f32e31 346 __be16 attr_bytes; /* valid bytes at attr_val without padding */
de258bf5
BH
347 u8 attr_val[0];
348} __packed;
349
350enum {
351 OSDv1_ATTRIBUTES_ELEM_ALIGN = 1,
c6572c98 352 OSD_ATTRIBUTES_ELEM_ALIGN = 8,
de258bf5
BH
353};
354
355enum {
356 OSD_ATTR_LIST_ALL_PAGES = 0xFFFFFFFF,
357 OSD_ATTR_LIST_ALL_IN_PAGE = 0xFFFFFFFF,
358};
359
360static inline unsigned osdv1_attr_list_elem_size(unsigned len)
361{
71f32e31 362 return ALIGN(len + sizeof(struct osdv1_attributes_list_element),
de258bf5
BH
363 OSDv1_ATTRIBUTES_ELEM_ALIGN);
364}
365
c6572c98
BH
366static inline unsigned osdv2_attr_list_elem_size(unsigned len)
367{
71f32e31 368 return ALIGN(len + sizeof(struct osdv2_attributes_list_element),
c6572c98
BH
369 OSD_ATTRIBUTES_ELEM_ALIGN);
370}
371
de258bf5
BH
372/*
373 * osd2r03: 7.1.3 OSD attributes lists (Table 184) — List type values
374 */
375enum osd_attr_list_types {
376 OSD_ATTR_LIST_GET = 0x1, /* descriptors only */
377 OSD_ATTR_LIST_SET_RETRIEVE = 0x9, /*descriptors/values variable-length*/
378 OSD_V2_ATTR_LIST_MULTIPLE = 0xE, /* ver2, Multiple Objects lists*/
379 OSD_V1_ATTR_LIST_CREATE_MULTIPLE = 0xF,/*ver1, used by create_multple*/
380};
381
382/* osd2r03: 7.1.3.4 Multi-object retrieved attributes format */
383struct osd_attributes_list_multi_header {
384 __be64 object_id;
385 u8 object_type; /* object_type enum below */
386 u8 reserved[5];
387 __be16 list_bytes;
388 /* followed by struct osd_attributes_list_element's */
389};
390
391struct osdv1_attributes_list_header {
392 u8 type; /* low 4-bit only */
393 u8 pad;
394 __be16 list_bytes; /* Initiator shall set to Zero. Only set by target */
395 /*
396 * type=9 followed by struct osd_attributes_list_element's
397 * type=E followed by struct osd_attributes_list_multi_header's
398 */
399} __packed;
400
401static inline unsigned osdv1_list_size(struct osdv1_attributes_list_header *h)
402{
403 return be16_to_cpu(h->list_bytes);
404}
405
c6572c98
BH
406struct osdv2_attributes_list_header {
407 u8 type; /* lower 4-bits only */
408 u8 pad[3];
409/*4*/ __be32 list_bytes; /* Initiator shall set to zero. Only set by target */
410 /*
411 * type=9 followed by struct osd_attributes_list_element's
412 * type=E followed by struct osd_attributes_list_multi_header's
413 */
414} __packed;
415
416static inline unsigned osdv2_list_size(struct osdv2_attributes_list_header *h)
417{
418 return be32_to_cpu(h->list_bytes);
419}
420
de258bf5
BH
421/* (osd-r10 6.13)
422 * osd2r03: 6.15 LIST (Table 79) LIST command parameter data.
423 * for root_lstchg below
424 */
425enum {
426 OSD_OBJ_ID_LIST_PAR = 0x1, /* V1-only. Not used in V2 */
427 OSD_OBJ_ID_LIST_LSTCHG = 0x2,
428};
429
430/*
431 * osd2r03: 6.15.2 LIST command parameter data
432 * (Also for LIST COLLECTION)
433 */
434struct osd_obj_id_list {
435 __be64 list_bytes; /* bytes in list excluding list_bytes (-8) */
436 __be64 continuation_id;
437 __be32 list_identifier;
438 u8 pad[3];
439 u8 root_lstchg;
440 __be64 object_ids[0];
441} __packed;
442
443static inline bool osd_is_obj_list_done(struct osd_obj_id_list *list,
444 bool *is_changed)
445{
446 *is_changed = (0 != (list->root_lstchg & OSD_OBJ_ID_LIST_LSTCHG));
447 return 0 != list->continuation_id;
448}
449
450/*
451 * osd2r03: 4.12.4.5 The ALLDATA security method
452 */
453struct osd_data_out_integrity_info {
454 __be64 data_bytes;
455 __be64 set_attributes_bytes;
456 __be64 get_attributes_bytes;
f8d3a644 457 __u8 integrity_check_value[OSD_CRYPTO_KEYID_SIZE];
de258bf5
BH
458} __packed;
459
f8d3a644
BH
460/* Same osd_data_out_integrity_info is used for OSD2/OSD1. The only difference
461 * Is the sizeof the structure since in OSD1 the last array is smaller. Use
462 * below for version independent handling of this structure
463 */
464static inline int osd_data_out_integrity_info_sizeof(bool is_ver1)
465{
466 return sizeof(struct osd_data_out_integrity_info) -
467 (is_ver1 * (OSDv2_CRYPTO_KEYID_SIZE - OSDv1_CRYPTO_KEYID_SIZE));
468}
469
de258bf5
BH
470struct osd_data_in_integrity_info {
471 __be64 data_bytes;
472 __be64 retrieved_attributes_bytes;
f8d3a644 473 __u8 integrity_check_value[OSD_CRYPTO_KEYID_SIZE];
de258bf5
BH
474} __packed;
475
f8d3a644
BH
476/* Same osd_data_in_integrity_info is used for OSD2/OSD1. The only difference
477 * Is the sizeof the structure since in OSD1 the last array is smaller. Use
478 * below for version independent handling of this structure
479 */
480static inline int osd_data_in_integrity_info_sizeof(bool is_ver1)
481{
482 return sizeof(struct osd_data_in_integrity_info) -
483 (is_ver1 * (OSDv2_CRYPTO_KEYID_SIZE - OSDv1_CRYPTO_KEYID_SIZE));
484}
485
de258bf5
BH
486struct osd_timestamp {
487 u8 time[6]; /* number of milliseconds since 1/1/1970 UT (big endian) */
488} __packed;
489/* FIXME: define helper functions to convert to/from osd time format */
490
491/*
492 * Capability & Security definitions
493 * osd2r03: 4.11.2.2 Capability format
494 * osd2r03: 5.2.8 Security parameters
495 */
496
497struct osd_key_identifier {
498 u8 id[7]; /* if you know why 7 please email bharrosh@panasas.com */
499} __packed;
500
501/* for osd_capability.format */
502enum {
503 OSD_SEC_CAP_FORMAT_NO_CAPS = 0,
504 OSD_SEC_CAP_FORMAT_VER1 = 1,
505 OSD_SEC_CAP_FORMAT_VER2 = 2,
506};
507
508/* security_method */
509enum {
510 OSD_SEC_NOSEC = 0,
511 OSD_SEC_CAPKEY = 1,
512 OSD_SEC_CMDRSP = 2,
513 OSD_SEC_ALLDATA = 3,
514};
515
516enum object_type {
517 OSD_SEC_OBJ_ROOT = 0x1,
518 OSD_SEC_OBJ_PARTITION = 0x2,
519 OSD_SEC_OBJ_COLLECTION = 0x40,
520 OSD_SEC_OBJ_USER = 0x80,
521};
522
523enum osd_capability_bit_masks {
524 OSD_SEC_CAP_APPEND = BIT(0),
525 OSD_SEC_CAP_OBJ_MGMT = BIT(1),
526 OSD_SEC_CAP_REMOVE = BIT(2),
527 OSD_SEC_CAP_CREATE = BIT(3),
528 OSD_SEC_CAP_SET_ATTR = BIT(4),
529 OSD_SEC_CAP_GET_ATTR = BIT(5),
530 OSD_SEC_CAP_WRITE = BIT(6),
531 OSD_SEC_CAP_READ = BIT(7),
532
533 OSD_SEC_CAP_NONE1 = BIT(8),
534 OSD_SEC_CAP_NONE2 = BIT(9),
e9da4d7f 535 OSD_SEC_GBL_REM = BIT(10), /*v2 only*/
de258bf5
BH
536 OSD_SEC_CAP_QUERY = BIT(11), /*v2 only*/
537 OSD_SEC_CAP_M_OBJECT = BIT(12), /*v2 only*/
538 OSD_SEC_CAP_POL_SEC = BIT(13),
539 OSD_SEC_CAP_GLOBAL = BIT(14),
540 OSD_SEC_CAP_DEV_MGMT = BIT(15),
541};
542
543/* for object_descriptor_type (hi nibble used) */
544enum {
545 OSD_SEC_OBJ_DESC_NONE = 0, /* Not allowed */
546 OSD_SEC_OBJ_DESC_OBJ = 1 << 4, /* v1: also collection */
547 OSD_SEC_OBJ_DESC_PAR = 2 << 4, /* also root */
548 OSD_SEC_OBJ_DESC_COL = 3 << 4, /* v2 only */
549};
550
551/* (osd-r10:4.9.2.2)
552 * osd2r03:4.11.2.2 Capability format
553 */
554struct osd_capability_head {
555 u8 format; /* low nibble */
556 u8 integrity_algorithm__key_version; /* MAKE_BYTE(integ_alg, key_ver) */
557 u8 security_method;
558 u8 reserved1;
559/*04*/ struct osd_timestamp expiration_time;
560/*10*/ u8 audit[20];
561/*30*/ u8 discriminator[12];
562/*42*/ struct osd_timestamp object_created_time;
563/*48*/ u8 object_type;
564/*49*/ u8 permissions_bit_mask[5];
565/*54*/ u8 reserved2;
566/*55*/ u8 object_descriptor_type; /* high nibble */
567} __packed;
568
569/*56 v1*/
570struct osdv1_cap_object_descriptor {
571 union {
572 struct {
573/*56*/ __be32 policy_access_tag;
574/*60*/ __be64 allowed_partition_id;
575/*68*/ __be64 allowed_object_id;
576/*76*/ __be32 reserved;
577 } __packed obj_desc;
578
579/*56*/ u8 object_descriptor[24];
580 };
581} __packed;
582/*80 v1*/
583
c6572c98
BH
584/*56 v2*/
585struct osd_cap_object_descriptor {
586 union {
587 struct {
588/*56*/ __be32 allowed_attributes_access;
589/*60*/ __be32 policy_access_tag;
590/*64*/ __be16 boot_epoch;
591/*66*/ u8 reserved[6];
592/*72*/ __be64 allowed_partition_id;
593/*80*/ __be64 allowed_object_id;
594/*88*/ __be64 allowed_range_length;
595/*96*/ __be64 allowed_range_start;
596 } __packed obj_desc;
597
598/*56*/ u8 object_descriptor[48];
599 };
600} __packed;
601/*104 v2*/
602
603struct osdv1_capability {
de258bf5
BH
604 struct osd_capability_head h;
605 struct osdv1_cap_object_descriptor od;
606} __packed;
607
c6572c98
BH
608struct osd_capability {
609 struct osd_capability_head h;
e9da4d7f 610 struct osd_cap_object_descriptor od;
c6572c98
BH
611} __packed;
612
de258bf5
BH
613/**
614 * osd_sec_set_caps - set cap-bits into the capabilities header
615 *
616 * @cap: The osd_capability_head to set cap bits to.
617 * @bit_mask: Use an ORed list of enum osd_capability_bit_masks values
618 *
619 * permissions_bit_mask is unaligned use below to set into caps
620 * in a version independent way
621 */
622static inline void osd_sec_set_caps(struct osd_capability_head *cap,
623 u16 bit_mask)
624{
625 /*
626 *Note: The bits above are defined LE order this is because this way
627 * they can grow in the future to more then 16, and still retain
628 * there constant values.
629 */
630 put_unaligned_le16(bit_mask, &cap->permissions_bit_mask);
631}
632
633#endif /* ndef __OSD_PROTOCOL_H__ */