1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * Copyright © 2016 Intel Corporation 4 * 5 * Authors: 6 * Rafael Antognolli <rafael.antognolli@intel.com> 7 * Scott Bauer <scott.bauer@intel.com> 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_user { 24 OPAL_ADMIN1 = 0x0, 25 OPAL_USER1 = 0x01, 26 OPAL_USER2 = 0x02, 27 OPAL_USER3 = 0x03, 28 OPAL_USER4 = 0x04, 29 OPAL_USER5 = 0x05, 30 OPAL_USER6 = 0x06, 31 OPAL_USER7 = 0x07, 32 OPAL_USER8 = 0x08, 33 OPAL_USER9 = 0x09, 34 }; 35 36 enum opal_lock_state { 37 OPAL_RO = 0x01, /* 0001 */ 38 OPAL_RW = 0x02, /* 0010 */ 39 OPAL_LK = 0x04, /* 0100 */ 40 }; 41 42 struct opal_key { 43 __u8 lr; 44 __u8 key_len; 45 __u8 __align[6]; 46 __u8 key[OPAL_KEY_MAX]; 47 }; 48 49 struct opal_lr_act { 50 struct opal_key key; 51 __u32 sum; 52 __u8 num_lrs; 53 __u8 lr[OPAL_MAX_LRS]; 54 __u8 align[2]; /* Align to 8 byte boundary */ 55 }; 56 57 struct opal_session_info { 58 __u32 sum; 59 __u32 who; 60 struct opal_key opal_key; 61 }; 62 63 struct opal_user_lr_setup { 64 __u64 range_start; 65 __u64 range_length; 66 __u32 RLE; /* Read Lock enabled */ 67 __u32 WLE; /* Write Lock Enabled */ 68 struct opal_session_info session; 69 }; 70 71 struct opal_lock_unlock { 72 struct opal_session_info session; 73 __u32 l_state; 74 __u8 __align[4]; 75 }; 76 77 struct opal_new_pw { 78 struct opal_session_info session; 79 80 /* When we're not operating in sum, and we first set 81 * passwords we need to set them via ADMIN authority. 82 * After passwords are changed, we can set them via, 83 * User authorities. 84 * Because of this restriction we need to know about 85 * Two different users. One in 'session' which we will use 86 * to start the session and new_userr_pw as the user we're 87 * chaning the pw for. 88 */ 89 struct opal_session_info new_user_pw; 90 }; 91 92 struct opal_mbr_data { 93 struct opal_key key; 94 __u8 enable_disable; 95 __u8 __align[7]; 96 }; 97 98 #define IOC_OPAL_SAVE _IOW('p', 220, struct opal_lock_unlock) 99 #define IOC_OPAL_LOCK_UNLOCK _IOW('p', 221, struct opal_lock_unlock) 100 #define IOC_OPAL_TAKE_OWNERSHIP _IOW('p', 222, struct opal_key) 101 #define IOC_OPAL_ACTIVATE_LSP _IOW('p', 223, struct opal_lr_act) 102 #define IOC_OPAL_SET_PW _IOW('p', 224, struct opal_new_pw) 103 #define IOC_OPAL_ACTIVATE_USR _IOW('p', 225, struct opal_session_info) 104 #define IOC_OPAL_REVERT_TPR _IOW('p', 226, struct opal_key) 105 #define IOC_OPAL_LR_SETUP _IOW('p', 227, struct opal_user_lr_setup) 106 #define IOC_OPAL_ADD_USR_TO_LR _IOW('p', 228, struct opal_lock_unlock) 107 #define IOC_OPAL_ENABLE_DISABLE_MBR _IOW('p', 229, struct opal_mbr_data) 108 #define IOC_OPAL_ERASE_LR _IOW('p', 230, struct opal_session_info) 109 #define IOC_OPAL_SECURE_ERASE_LR _IOW('p', 231, struct opal_session_info) 110 111 #endif /* _UAPI_SED_OPAL_H */ 112