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