1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
3 * Copyright © 2016 Intel Corporation
10 #ifndef _UAPI_SED_OPAL_H
11 #define _UAPI_SED_OPAL_H
13 #include <linux/types.h>
15 #define OPAL_KEY_MAX 256
16 #define OPAL_MAX_LRS 9
19 OPAL_MBR_ENABLE = 0x0,
20 OPAL_MBR_DISABLE = 0x01,
23 enum opal_mbr_done_flag {
24 OPAL_MBR_NOT_DONE = 0x0,
41 enum opal_lock_state {
42 OPAL_RO = 0x01, /* 0001 */
43 OPAL_RW = 0x02, /* 0010 */
44 OPAL_LK = 0x04, /* 0100 */
47 enum opal_lock_flags {
48 /* IOC_OPAL_SAVE will also store the provided key for locking */
49 OPAL_SAVE_FOR_LOCK = 0x01,
56 __u8 key[OPAL_KEY_MAX];
63 __u8 lr[OPAL_MAX_LRS];
64 __u8 align[2]; /* Align to 8 byte boundary */
67 struct opal_session_info {
70 struct opal_key opal_key;
73 struct opal_user_lr_setup {
76 __u32 RLE; /* Read Lock enabled */
77 __u32 WLE; /* Write Lock Enabled */
78 struct opal_session_info session;
81 struct opal_lr_status {
82 struct opal_session_info session;
85 __u32 RLE; /* Read Lock enabled */
86 __u32 WLE; /* Write Lock Enabled */
91 struct opal_lock_unlock {
92 struct opal_session_info session;
99 struct opal_session_info session;
101 /* When we're not operating in sum, and we first set
102 * passwords we need to set them via ADMIN authority.
103 * After passwords are changed, we can set them via,
105 * Because of this restriction we need to know about
106 * Two different users. One in 'session' which we will use
107 * to start the session and new_userr_pw as the user we're
108 * chaning the pw for.
110 struct opal_session_info new_user_pw;
113 struct opal_mbr_data {
119 struct opal_mbr_done {
125 struct opal_shadow_mbr {
132 /* Opal table operations */
133 enum opal_table_ops {
138 #define OPAL_UID_LENGTH 8
139 struct opal_read_write_table {
142 const __u8 table_uid[OPAL_UID_LENGTH];
145 #define OPAL_TABLE_READ (1 << OPAL_READ_TABLE)
146 #define OPAL_TABLE_WRITE (1 << OPAL_WRITE_TABLE)
151 #define OPAL_FL_SUPPORTED 0x00000001
152 #define OPAL_FL_LOCKING_SUPPORTED 0x00000002
153 #define OPAL_FL_LOCKING_ENABLED 0x00000004
154 #define OPAL_FL_LOCKED 0x00000008
155 #define OPAL_FL_MBR_ENABLED 0x00000010
156 #define OPAL_FL_MBR_DONE 0x00000020
157 #define OPAL_FL_SUM_SUPPORTED 0x00000040
165 * Geometry Reporting per TCG Storage OPAL SSC
168 struct opal_geometry {
170 __u32 logical_block_size;
171 __u64 alignment_granularity;
172 __u64 lowest_aligned_lba;
176 #define IOC_OPAL_SAVE _IOW('p', 220, struct opal_lock_unlock)
177 #define IOC_OPAL_LOCK_UNLOCK _IOW('p', 221, struct opal_lock_unlock)
178 #define IOC_OPAL_TAKE_OWNERSHIP _IOW('p', 222, struct opal_key)
179 #define IOC_OPAL_ACTIVATE_LSP _IOW('p', 223, struct opal_lr_act)
180 #define IOC_OPAL_SET_PW _IOW('p', 224, struct opal_new_pw)
181 #define IOC_OPAL_ACTIVATE_USR _IOW('p', 225, struct opal_session_info)
182 #define IOC_OPAL_REVERT_TPR _IOW('p', 226, struct opal_key)
183 #define IOC_OPAL_LR_SETUP _IOW('p', 227, struct opal_user_lr_setup)
184 #define IOC_OPAL_ADD_USR_TO_LR _IOW('p', 228, struct opal_lock_unlock)
185 #define IOC_OPAL_ENABLE_DISABLE_MBR _IOW('p', 229, struct opal_mbr_data)
186 #define IOC_OPAL_ERASE_LR _IOW('p', 230, struct opal_session_info)
187 #define IOC_OPAL_SECURE_ERASE_LR _IOW('p', 231, struct opal_session_info)
188 #define IOC_OPAL_PSID_REVERT_TPR _IOW('p', 232, struct opal_key)
189 #define IOC_OPAL_MBR_DONE _IOW('p', 233, struct opal_mbr_done)
190 #define IOC_OPAL_WRITE_SHADOW_MBR _IOW('p', 234, struct opal_shadow_mbr)
191 #define IOC_OPAL_GENERIC_TABLE_RW _IOW('p', 235, struct opal_read_write_table)
192 #define IOC_OPAL_GET_STATUS _IOR('p', 236, struct opal_status)
193 #define IOC_OPAL_GET_LR_STATUS _IOW('p', 237, struct opal_lr_status)
194 #define IOC_OPAL_GET_GEOMETRY _IOR('p', 238, struct opal_geometry)
196 #endif /* _UAPI_SED_OPAL_H */