1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * Copyright © 2016 Intel Corporation 4 * 5 * Authors: 6 * Rafael Antognolli <[email protected]> 7 * Scott Bauer <[email protected]> 8 */ 9 10 #ifndef _UAPI_SED_OPAL_H 11 #define _UAPI_SED_OPAL_H 12 13 #include <linux/types.h> 14 15 #define OPAL_KEY_MAX 256 16 #define OPAL_MAX_LRS 9 17 18 enum opal_mbr { 19 OPAL_MBR_ENABLE = 0x0, 20 OPAL_MBR_DISABLE = 0x01, 21 }; 22 23 enum opal_mbr_done_flag { 24 OPAL_MBR_NOT_DONE = 0x0, 25 OPAL_MBR_DONE = 0x01 26 }; 27 28 enum opal_user { 29 OPAL_ADMIN1 = 0x0, 30 OPAL_USER1 = 0x01, 31 OPAL_USER2 = 0x02, 32 OPAL_USER3 = 0x03, 33 OPAL_USER4 = 0x04, 34 OPAL_USER5 = 0x05, 35 OPAL_USER6 = 0x06, 36 OPAL_USER7 = 0x07, 37 OPAL_USER8 = 0x08, 38 OPAL_USER9 = 0x09, 39 }; 40 41 enum opal_lock_state { 42 OPAL_RO = 0x01, /* 0001 */ 43 OPAL_RW = 0x02, /* 0010 */ 44 OPAL_LK = 0x04, /* 0100 */ 45 }; 46 47 enum opal_lock_flags { 48 /* IOC_OPAL_SAVE will also store the provided key for locking */ 49 OPAL_SAVE_FOR_LOCK = 0x01, 50 }; 51 52 struct opal_key { 53 __u8 lr; 54 __u8 key_len; 55 __u8 __align[6]; 56 __u8 key[OPAL_KEY_MAX]; 57 }; 58 59 enum opal_revert_lsp_opts { 60 OPAL_PRESERVE = 0x01, 61 }; 62 63 struct opal_lr_act { 64 struct opal_key key; 65 __u32 sum; 66 __u8 num_lrs; 67 __u8 lr[OPAL_MAX_LRS]; 68 __u8 align[2]; /* Align to 8 byte boundary */ 69 }; 70 71 struct opal_session_info { 72 __u32 sum; 73 __u32 who; 74 struct opal_key opal_key; 75 }; 76 77 struct opal_user_lr_setup { 78 __u64 range_start; 79 __u64 range_length; 80 __u32 RLE; /* Read Lock enabled */ 81 __u32 WLE; /* Write Lock Enabled */ 82 struct opal_session_info session; 83 }; 84 85 struct opal_lr_status { 86 struct opal_session_info session; 87 __u64 range_start; 88 __u64 range_length; 89 __u32 RLE; /* Read Lock enabled */ 90 __u32 WLE; /* Write Lock Enabled */ 91 __u32 l_state; 92 __u8 align[4]; 93 }; 94 95 struct opal_lock_unlock { 96 struct opal_session_info session; 97 __u32 l_state; 98 __u16 flags; 99 __u8 __align[2]; 100 }; 101 102 struct opal_new_pw { 103 struct opal_session_info session; 104 105 /* When we're not operating in sum, and we first set 106 * passwords we need to set them via ADMIN authority. 107 * After passwords are changed, we can set them via, 108 * User authorities. 109 * Because of this restriction we need to know about 110 * Two different users. One in 'session' which we will use 111 * to start the session and new_userr_pw as the user we're 112 * chaning the pw for. 113 */ 114 struct opal_session_info new_user_pw; 115 }; 116 117 struct opal_mbr_data { 118 struct opal_key key; 119 __u8 enable_disable; 120 __u8 __align[7]; 121 }; 122 123 struct opal_mbr_done { 124 struct opal_key key; 125 __u8 done_flag; 126 __u8 __align[7]; 127 }; 128 129 struct opal_shadow_mbr { 130 struct opal_key key; 131 const __u64 data; 132 __u64 offset; 133 __u64 size; 134 }; 135 136 /* Opal table operations */ 137 enum opal_table_ops { 138 OPAL_READ_TABLE, 139 OPAL_WRITE_TABLE, 140 }; 141 142 #define OPAL_UID_LENGTH 8 143 struct opal_read_write_table { 144 struct opal_key key; 145 const __u64 data; 146 const __u8 table_uid[OPAL_UID_LENGTH]; 147 __u64 offset; 148 __u64 size; 149 #define OPAL_TABLE_READ (1 << OPAL_READ_TABLE) 150 #define OPAL_TABLE_WRITE (1 << OPAL_WRITE_TABLE) 151 __u64 flags; 152 __u64 priv; 153 }; 154 155 #define OPAL_FL_SUPPORTED 0x00000001 156 #define OPAL_FL_LOCKING_SUPPORTED 0x00000002 157 #define OPAL_FL_LOCKING_ENABLED 0x00000004 158 #define OPAL_FL_LOCKED 0x00000008 159 #define OPAL_FL_MBR_ENABLED 0x00000010 160 #define OPAL_FL_MBR_DONE 0x00000020 161 #define OPAL_FL_SUM_SUPPORTED 0x00000040 162 163 struct opal_status { 164 __u32 flags; 165 __u32 reserved; 166 }; 167 168 /* 169 * Geometry Reporting per TCG Storage OPAL SSC 170 * section 3.1.1.4 171 */ 172 struct opal_geometry { 173 __u8 align; 174 __u32 logical_block_size; 175 __u64 alignment_granularity; 176 __u64 lowest_aligned_lba; 177 __u8 __align[3]; 178 }; 179 180 struct opal_discovery { 181 __u64 data; 182 __u64 size; 183 }; 184 185 struct opal_revert_lsp { 186 struct opal_key key; 187 __u32 options; 188 __u32 __pad; 189 }; 190 191 #define IOC_OPAL_SAVE _IOW('p', 220, struct opal_lock_unlock) 192 #define IOC_OPAL_LOCK_UNLOCK _IOW('p', 221, struct opal_lock_unlock) 193 #define IOC_OPAL_TAKE_OWNERSHIP _IOW('p', 222, struct opal_key) 194 #define IOC_OPAL_ACTIVATE_LSP _IOW('p', 223, struct opal_lr_act) 195 #define IOC_OPAL_SET_PW _IOW('p', 224, struct opal_new_pw) 196 #define IOC_OPAL_ACTIVATE_USR _IOW('p', 225, struct opal_session_info) 197 #define IOC_OPAL_REVERT_TPR _IOW('p', 226, struct opal_key) 198 #define IOC_OPAL_LR_SETUP _IOW('p', 227, struct opal_user_lr_setup) 199 #define IOC_OPAL_ADD_USR_TO_LR _IOW('p', 228, struct opal_lock_unlock) 200 #define IOC_OPAL_ENABLE_DISABLE_MBR _IOW('p', 229, struct opal_mbr_data) 201 #define IOC_OPAL_ERASE_LR _IOW('p', 230, struct opal_session_info) 202 #define IOC_OPAL_SECURE_ERASE_LR _IOW('p', 231, struct opal_session_info) 203 #define IOC_OPAL_PSID_REVERT_TPR _IOW('p', 232, struct opal_key) 204 #define IOC_OPAL_MBR_DONE _IOW('p', 233, struct opal_mbr_done) 205 #define IOC_OPAL_WRITE_SHADOW_MBR _IOW('p', 234, struct opal_shadow_mbr) 206 #define IOC_OPAL_GENERIC_TABLE_RW _IOW('p', 235, struct opal_read_write_table) 207 #define IOC_OPAL_GET_STATUS _IOR('p', 236, struct opal_status) 208 #define IOC_OPAL_GET_LR_STATUS _IOW('p', 237, struct opal_lr_status) 209 #define IOC_OPAL_GET_GEOMETRY _IOR('p', 238, struct opal_geometry) 210 #define IOC_OPAL_DISCOVERY _IOW('p', 239, struct opal_discovery) 211 #define IOC_OPAL_REVERT_LSP _IOW('p', 240, struct opal_revert_lsp) 212 213 #endif /* _UAPI_SED_OPAL_H */ 214