Merge branch 'x86-asm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / include / scsi / osd_protocol.h
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
23 enum {
24         OSDv1_ADDITIONAL_CDB_LENGTH = 192,
25         OSDv1_TOTAL_CDB_LEN = OSDv1_ADDITIONAL_CDB_LENGTH + 8,
26         OSDv1_CAP_LEN = 80,
27
28         /* Latest supported version */
29         OSDv2_ADDITIONAL_CDB_LENGTH = 228,
30         OSD_ADDITIONAL_CDB_LENGTH =
31                 OSDv2_ADDITIONAL_CDB_LENGTH,
32         OSD_TOTAL_CDB_LEN = OSD_ADDITIONAL_CDB_LENGTH + 8,
33         OSD_CAP_LEN = 104,
34
35         OSD_SYSTEMID_LEN = 20,
36         OSDv1_CRYPTO_KEYID_SIZE = 20,
37         OSDv2_CRYPTO_KEYID_SIZE = 32,
38         OSD_CRYPTO_KEYID_SIZE = OSDv2_CRYPTO_KEYID_SIZE,
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  */
50 enum 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  */
60 enum 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  */
72 enum 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 */
82 enum {
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  */
91 enum 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  */
109 typedef __be32 __bitwise osd_cdb_offset;
110
111 enum {
112         OSD_OFFSET_UNUSED = 0xFFFFFFFF,
113         OSD_OFFSET_MAX_BITS = 28,
114
115         OSDv1_OFFSET_MIN_SHIFT = 8,
116         OSD_OFFSET_MIN_SHIFT = 3,
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  */
125 osd_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  */
132 static 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
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  */
142 static 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
148 /* osd2r03: 5.2.1 Overview */
149 struct 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;
163
164                 struct __osdv2_cdb_addr_len {
165                         /* called allocation_length in some commands */
166 /*32*/                  __be64  length;
167 /*40*/                  __be64  start_address;
168                         union {
169 /*48*/                          __be32 list_identifier;/* Rarely used */
170                                 /* OSD2r05 5.2.5 CDB continuation length */
171 /*48*/                          __be32 cdb_continuation_length;
172                         };
173                 } __packed v2;
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*/
212 struct osdv1_security_parameters {
213 /*160*/u8       integrity_check_value[OSDv1_CRYPTO_KEYID_SIZE];
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*/
219
220 /*184 v2*/
221 struct 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
229 struct osd_security_parameters {
230         union {
231                 struct osdv1_security_parameters v1;
232                 struct osdv2_security_parameters v2;
233         };
234 };
235
236 struct osdv1_cdb {
237         struct osd_cdb_head h;
238         u8 caps[OSDv1_CAP_LEN];
239         struct osdv1_security_parameters sec_params;
240 } __packed;
241
242 struct osdv2_cdb {
243         struct osd_cdb_head h;
244         u8 caps[OSD_CAP_LEN];
245         struct osdv2_security_parameters sec_params;
246 } __packed;
247
248 struct osd_cdb {
249         union {
250                 struct osdv1_cdb v1;
251                 struct osdv2_cdb v2;
252                 u8 buff[OSD_TOTAL_CDB_LEN];
253         };
254 } __packed;
255
256 static 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
276 enum 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)
306         OSD_ACT_V2(READ_MAP,                    0x31)
307
308         OSD_ACT_V1_V2(PERFORM_SCSI_COMMAND,     0x8F7E, 0x8F7C)
309         OSD_ACT_V1_V2(SCSI_TASK_MANAGEMENT,     0x8F7F, 0x8F7D)
310         /* 0x8F80 to 0x8FFF are Vendor specific */
311 };
312
313 /* osd2r03: 7.1.3.2 List entry format for retrieving attributes */
314 struct osd_attributes_list_attrid {
315         __be32 attr_page;
316         __be32 attr_id;
317 } __packed;
318
319 /*
320  * NOTE: v1: is not aligned.
321  */
322 struct osdv1_attributes_list_element {
323         __be32 attr_page;
324         __be32 attr_id;
325         __be16 attr_bytes; /* valid bytes at attr_val without padding */
326         u8 attr_val[0];
327 } __packed;
328
329 /*
330  * osd2r03: 7.1.3.3 List entry format for retrieved attributes and
331  *                  for setting attributes
332  * NOTE: v2 is 8-bytes aligned
333  */
334 struct osdv2_attributes_list_element {
335         __be32 attr_page;
336         __be32 attr_id;
337         u8 reserved[6];
338         __be16 attr_bytes; /* valid bytes at attr_val without padding */
339         u8 attr_val[0];
340 } __packed;
341
342 enum {
343         OSDv1_ATTRIBUTES_ELEM_ALIGN = 1,
344         OSD_ATTRIBUTES_ELEM_ALIGN = 8,
345 };
346
347 enum {
348         OSD_ATTR_LIST_ALL_PAGES = 0xFFFFFFFF,
349         OSD_ATTR_LIST_ALL_IN_PAGE = 0xFFFFFFFF,
350 };
351
352 static inline unsigned osdv1_attr_list_elem_size(unsigned len)
353 {
354         return ALIGN(len + sizeof(struct osdv1_attributes_list_element),
355                      OSDv1_ATTRIBUTES_ELEM_ALIGN);
356 }
357
358 static inline unsigned osdv2_attr_list_elem_size(unsigned len)
359 {
360         return ALIGN(len + sizeof(struct osdv2_attributes_list_element),
361                      OSD_ATTRIBUTES_ELEM_ALIGN);
362 }
363
364 /*
365  * osd2r03: 7.1.3 OSD attributes lists (Table 184) â€” List type values
366  */
367 enum osd_attr_list_types {
368         OSD_ATTR_LIST_GET = 0x1,        /* descriptors only */
369         OSD_ATTR_LIST_SET_RETRIEVE = 0x9, /*descriptors/values variable-length*/
370         OSD_V2_ATTR_LIST_MULTIPLE = 0xE,  /* ver2, Multiple Objects lists*/
371         OSD_V1_ATTR_LIST_CREATE_MULTIPLE = 0xF,/*ver1, used by create_multple*/
372 };
373
374 /* osd2r03: 7.1.3.4 Multi-object retrieved attributes format */
375 struct osd_attributes_list_multi_header {
376         __be64 object_id;
377         u8 object_type; /* object_type enum below */
378         u8 reserved[5];
379         __be16 list_bytes;
380         /* followed by struct osd_attributes_list_element's */
381 };
382
383 struct osdv1_attributes_list_header {
384         u8 type;        /* low 4-bit only */
385         u8 pad;
386         __be16 list_bytes; /* Initiator shall set to Zero. Only set by target */
387         /*
388          * type=9 followed by struct osd_attributes_list_element's
389          * type=E followed by struct osd_attributes_list_multi_header's
390          */
391 } __packed;
392
393 static inline unsigned osdv1_list_size(struct osdv1_attributes_list_header *h)
394 {
395         return be16_to_cpu(h->list_bytes);
396 }
397
398 struct osdv2_attributes_list_header {
399         u8 type;        /* lower 4-bits only */
400         u8 pad[3];
401 /*4*/   __be32 list_bytes; /* Initiator shall set to zero. Only set by target */
402         /*
403          * type=9 followed by struct osd_attributes_list_element's
404          * type=E followed by struct osd_attributes_list_multi_header's
405          */
406 } __packed;
407
408 static inline unsigned osdv2_list_size(struct osdv2_attributes_list_header *h)
409 {
410         return be32_to_cpu(h->list_bytes);
411 }
412
413 /* (osd-r10 6.13)
414  * osd2r03: 6.15 LIST (Table 79) LIST command parameter data.
415  *      for root_lstchg below
416  */
417 enum {
418         OSD_OBJ_ID_LIST_PAR = 0x1, /* V1-only. Not used in V2 */
419         OSD_OBJ_ID_LIST_LSTCHG = 0x2,
420 };
421
422 /*
423  * osd2r03: 6.15.2 LIST command parameter data
424  * (Also for LIST COLLECTION)
425  */
426 struct osd_obj_id_list {
427         __be64 list_bytes; /* bytes in list excluding list_bytes (-8) */
428         __be64 continuation_id;
429         __be32 list_identifier;
430         u8 pad[3];
431         u8 root_lstchg;
432         __be64 object_ids[0];
433 } __packed;
434
435 static inline bool osd_is_obj_list_done(struct osd_obj_id_list *list,
436         bool *is_changed)
437 {
438         *is_changed = (0 != (list->root_lstchg & OSD_OBJ_ID_LIST_LSTCHG));
439         return 0 != list->continuation_id;
440 }
441
442 /*
443  * osd2r03: 4.12.4.5 The ALLDATA security method
444  */
445 struct osd_data_out_integrity_info {
446         __be64 data_bytes;
447         __be64 set_attributes_bytes;
448         __be64 get_attributes_bytes;
449         __u8 integrity_check_value[OSD_CRYPTO_KEYID_SIZE];
450 } __packed;
451
452 /* Same osd_data_out_integrity_info is used for OSD2/OSD1. The only difference
453  * Is the sizeof the structure since in OSD1 the last array is smaller. Use
454  * below for version independent handling of this structure
455  */
456 static inline int osd_data_out_integrity_info_sizeof(bool is_ver1)
457 {
458         return sizeof(struct osd_data_out_integrity_info) -
459                 (is_ver1 * (OSDv2_CRYPTO_KEYID_SIZE - OSDv1_CRYPTO_KEYID_SIZE));
460 }
461
462 struct osd_data_in_integrity_info {
463         __be64 data_bytes;
464         __be64 retrieved_attributes_bytes;
465         __u8 integrity_check_value[OSD_CRYPTO_KEYID_SIZE];
466 } __packed;
467
468 /* Same osd_data_in_integrity_info is used for OSD2/OSD1. The only difference
469  * Is the sizeof the structure since in OSD1 the last array is smaller. Use
470  * below for version independent handling of this structure
471  */
472 static inline int osd_data_in_integrity_info_sizeof(bool is_ver1)
473 {
474         return sizeof(struct osd_data_in_integrity_info) -
475                 (is_ver1 * (OSDv2_CRYPTO_KEYID_SIZE - OSDv1_CRYPTO_KEYID_SIZE));
476 }
477
478 struct osd_timestamp {
479         u8 time[6]; /* number of milliseconds since 1/1/1970 UT (big endian) */
480 } __packed;
481 /* FIXME: define helper functions to convert to/from osd time format */
482
483 /*
484  * Capability & Security definitions
485  * osd2r03: 4.11.2.2 Capability format
486  * osd2r03: 5.2.8 Security parameters
487  */
488
489 struct osd_key_identifier {
490         u8 id[7]; /* if you know why 7 please email bharrosh@panasas.com */
491 } __packed;
492
493 /* for osd_capability.format */
494 enum {
495         OSD_SEC_CAP_FORMAT_NO_CAPS = 0,
496         OSD_SEC_CAP_FORMAT_VER1 = 1,
497         OSD_SEC_CAP_FORMAT_VER2 = 2,
498 };
499
500 /* security_method */
501 enum {
502         OSD_SEC_NOSEC = 0,
503         OSD_SEC_CAPKEY = 1,
504         OSD_SEC_CMDRSP = 2,
505         OSD_SEC_ALLDATA = 3,
506 };
507
508 enum object_type {
509         OSD_SEC_OBJ_ROOT = 0x1,
510         OSD_SEC_OBJ_PARTITION = 0x2,
511         OSD_SEC_OBJ_COLLECTION = 0x40,
512         OSD_SEC_OBJ_USER = 0x80,
513 };
514
515 enum osd_capability_bit_masks {
516         OSD_SEC_CAP_APPEND      = BIT(0),
517         OSD_SEC_CAP_OBJ_MGMT    = BIT(1),
518         OSD_SEC_CAP_REMOVE      = BIT(2),
519         OSD_SEC_CAP_CREATE      = BIT(3),
520         OSD_SEC_CAP_SET_ATTR    = BIT(4),
521         OSD_SEC_CAP_GET_ATTR    = BIT(5),
522         OSD_SEC_CAP_WRITE       = BIT(6),
523         OSD_SEC_CAP_READ        = BIT(7),
524
525         OSD_SEC_CAP_NONE1       = BIT(8),
526         OSD_SEC_CAP_NONE2       = BIT(9),
527         OSD_SEC_GBL_REM         = BIT(10), /*v2 only*/
528         OSD_SEC_CAP_QUERY       = BIT(11), /*v2 only*/
529         OSD_SEC_CAP_M_OBJECT    = BIT(12), /*v2 only*/
530         OSD_SEC_CAP_POL_SEC     = BIT(13),
531         OSD_SEC_CAP_GLOBAL      = BIT(14),
532         OSD_SEC_CAP_DEV_MGMT    = BIT(15),
533 };
534
535 /* for object_descriptor_type (hi nibble used) */
536 enum {
537         OSD_SEC_OBJ_DESC_NONE = 0,     /* Not allowed */
538         OSD_SEC_OBJ_DESC_OBJ = 1 << 4, /* v1: also collection */
539         OSD_SEC_OBJ_DESC_PAR = 2 << 4, /* also root */
540         OSD_SEC_OBJ_DESC_COL = 3 << 4, /* v2 only */
541 };
542
543 /* (osd-r10:4.9.2.2)
544  * osd2r03:4.11.2.2 Capability format
545  */
546 struct osd_capability_head {
547         u8 format; /* low nibble */
548         u8 integrity_algorithm__key_version; /* MAKE_BYTE(integ_alg, key_ver) */
549         u8 security_method;
550         u8 reserved1;
551 /*04*/  struct osd_timestamp expiration_time;
552 /*10*/  u8 audit[20];
553 /*30*/  u8 discriminator[12];
554 /*42*/  struct osd_timestamp object_created_time;
555 /*48*/  u8 object_type;
556 /*49*/  u8 permissions_bit_mask[5];
557 /*54*/  u8 reserved2;
558 /*55*/  u8 object_descriptor_type; /* high nibble */
559 } __packed;
560
561 /*56 v1*/
562 struct osdv1_cap_object_descriptor {
563         union {
564                 struct {
565 /*56*/                  __be32 policy_access_tag;
566 /*60*/                  __be64 allowed_partition_id;
567 /*68*/                  __be64 allowed_object_id;
568 /*76*/                  __be32 reserved;
569                 } __packed obj_desc;
570
571 /*56*/          u8 object_descriptor[24];
572         };
573 } __packed;
574 /*80 v1*/
575
576 /*56 v2*/
577 struct osd_cap_object_descriptor {
578         union {
579                 struct {
580 /*56*/                  __be32 allowed_attributes_access;
581 /*60*/                  __be32 policy_access_tag;
582 /*64*/                  __be16 boot_epoch;
583 /*66*/                  u8 reserved[6];
584 /*72*/                  __be64 allowed_partition_id;
585 /*80*/                  __be64 allowed_object_id;
586 /*88*/                  __be64 allowed_range_length;
587 /*96*/                  __be64 allowed_range_start;
588                 } __packed obj_desc;
589
590 /*56*/          u8 object_descriptor[48];
591         };
592 } __packed;
593 /*104 v2*/
594
595 struct osdv1_capability {
596         struct osd_capability_head h;
597         struct osdv1_cap_object_descriptor od;
598 } __packed;
599
600 struct osd_capability {
601         struct osd_capability_head h;
602         struct osd_cap_object_descriptor od;
603 } __packed;
604
605 /**
606  * osd_sec_set_caps - set cap-bits into the capabilities header
607  *
608  * @cap:        The osd_capability_head to set cap bits to.
609  * @bit_mask:   Use an ORed list of enum osd_capability_bit_masks values
610  *
611  * permissions_bit_mask is unaligned use below to set into caps
612  * in a version independent way
613  */
614 static inline void osd_sec_set_caps(struct osd_capability_head *cap,
615         u16 bit_mask)
616 {
617         /*
618          *Note: The bits above are defined LE order this is because this way
619          *      they can grow in the future to more then 16, and still retain
620          *      there constant values.
621          */
622         put_unaligned_le16(bit_mask, &cap->permissions_bit_mask);
623 }
624
625 #endif /* ndef __OSD_PROTOCOL_H__ */