blob: 33e53b80cd1f375ae271de0b630644fde85d211b [file] [log] [blame]
Greg Kroah-Hartmane2be04c2017-11-01 15:09:13 +01001/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
Scott Bauer19641f22017-02-03 12:50:30 -07002/*
3 * Copyright © 2016 Intel Corporation
4 *
5 * Authors:
6 * Rafael Antognolli <rafael.antognolli@intel.com>
7 * Scott Bauer <scott.bauer@intel.com>
Scott Bauer19641f22017-02-03 12:50:30 -07008 */
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
18enum opal_mbr {
19 OPAL_MBR_ENABLE = 0x0,
20 OPAL_MBR_DISABLE = 0x01,
21};
22
23enum 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
36enum opal_lock_state {
37 OPAL_RO = 0x01, /* 0001 */
38 OPAL_RW = 0x02, /* 0010 */
39 OPAL_LK = 0x04, /* 0100 */
40};
41
42struct opal_key {
Scott Bauer8c87fe72017-02-06 17:22:49 -070043 __u8 lr;
44 __u8 key_len;
45 __u8 __align[6];
46 __u8 key[OPAL_KEY_MAX];
Scott Bauer19641f22017-02-03 12:50:30 -070047};
48
49struct opal_lr_act {
Scott Bauer19641f22017-02-03 12:50:30 -070050 struct opal_key key;
Scott Bauer8c87fe72017-02-06 17:22:49 -070051 __u32 sum;
David Kozub1e815b32019-02-14 01:15:54 +010052 __u8 num_lrs;
Scott Bauer8c87fe72017-02-06 17:22:49 -070053 __u8 lr[OPAL_MAX_LRS];
54 __u8 align[2]; /* Align to 8 byte boundary */
Scott Bauer19641f22017-02-03 12:50:30 -070055};
56
57struct opal_session_info {
Scott Bauer8c87fe72017-02-06 17:22:49 -070058 __u32 sum;
59 __u32 who;
Scott Bauer19641f22017-02-03 12:50:30 -070060 struct opal_key opal_key;
Scott Bauer19641f22017-02-03 12:50:30 -070061};
62
63struct opal_user_lr_setup {
Scott Bauer8c87fe72017-02-06 17:22:49 -070064 __u64 range_start;
65 __u64 range_length;
66 __u32 RLE; /* Read Lock enabled */
67 __u32 WLE; /* Write Lock Enabled */
Scott Bauer19641f22017-02-03 12:50:30 -070068 struct opal_session_info session;
Scott Bauer19641f22017-02-03 12:50:30 -070069};
70
71struct opal_lock_unlock {
Scott Bauer19641f22017-02-03 12:50:30 -070072 struct opal_session_info session;
Scott Bauer8c87fe72017-02-06 17:22:49 -070073 __u32 l_state;
74 __u8 __align[4];
Scott Bauer19641f22017-02-03 12:50:30 -070075};
76
77struct 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
92struct opal_mbr_data {
Scott Bauer19641f22017-02-03 12:50:30 -070093 struct opal_key key;
Scott Bauer8c87fe72017-02-06 17:22:49 -070094 __u8 enable_disable;
95 __u8 __align[7];
Scott Bauer19641f22017-02-03 12:50:30 -070096};
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)
Scott Bauer24bff4d2017-02-14 17:29:35 -0700101#define IOC_OPAL_ACTIVATE_LSP _IOW('p', 223, struct opal_lr_act)
Scott Bauer19641f22017-02-03 12:50:30 -0700102#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 */