osd_protocol.h 17 KB

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