blob: 31799526082a57fffb1a1cc406073911e244e8bc [file] [log] [blame]
Scott Bauer19641f22017-02-03 12:50:30 -07001/*
2 * Copyright © 2016 Intel Corporation
3 *
4 * Authors:
5 * Rafael Antognolli <rafael.antognolli@intel.com>
6 * Scott Bauer <scott.bauer@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 */
17
18#ifndef _UAPI_SED_OPAL_H
19#define _UAPI_SED_OPAL_H
20
21#include <linux/types.h>
22
23#define OPAL_KEY_MAX 256
24#define OPAL_MAX_LRS 9
25
26enum opal_mbr {
27 OPAL_MBR_ENABLE = 0x0,
28 OPAL_MBR_DISABLE = 0x01,
29};
30
31enum opal_user {
32 OPAL_ADMIN1 = 0x0,
33 OPAL_USER1 = 0x01,
34 OPAL_USER2 = 0x02,
35 OPAL_USER3 = 0x03,
36 OPAL_USER4 = 0x04,
37 OPAL_USER5 = 0x05,
38 OPAL_USER6 = 0x06,
39 OPAL_USER7 = 0x07,
40 OPAL_USER8 = 0x08,
41 OPAL_USER9 = 0x09,
42};
43
44enum opal_lock_state {
45 OPAL_RO = 0x01, /* 0001 */
46 OPAL_RW = 0x02, /* 0010 */
47 OPAL_LK = 0x04, /* 0100 */
48};
49
50struct opal_key {
51 uint8_t lr;
52 uint8_t key_len;
53 char key[OPAL_KEY_MAX];
54};
55
56struct opal_lr_act {
57 int sum;
58 uint8_t num_lrs;
59 uint8_t lr[OPAL_MAX_LRS];
60 struct opal_key key;
61};
62
63struct opal_session_info {
64 int sum;
65 enum opal_user who;
66 struct opal_key opal_key;
67 uint8_t __align[2];
68};
69
70struct opal_user_lr_setup {
71 size_t range_start;
72 size_t range_length;
73 int RLE; /* Read Lock enabled */
74 int WLE; /* Write Lock Enabled */
75 struct opal_session_info session;
76 uint8_t __align[4];
77};
78
79struct opal_lock_unlock {
80 enum opal_lock_state l_state;
81 struct opal_session_info session;
82};
83
84struct opal_new_pw {
85 struct opal_session_info session;
86
87 /* When we're not operating in sum, and we first set
88 * passwords we need to set them via ADMIN authority.
89 * After passwords are changed, we can set them via,
90 * User authorities.
91 * Because of this restriction we need to know about
92 * Two different users. One in 'session' which we will use
93 * to start the session and new_userr_pw as the user we're
94 * chaning the pw for.
95 */
96 struct opal_session_info new_user_pw;
97};
98
99struct opal_mbr_data {
100 u8 enable_disable;
101 struct opal_key key;
102 uint8_t __align[5];
103};
104
105#define IOC_OPAL_SAVE _IOW('p', 220, struct opal_lock_unlock)
106#define IOC_OPAL_LOCK_UNLOCK _IOW('p', 221, struct opal_lock_unlock)
107#define IOC_OPAL_TAKE_OWNERSHIP _IOW('p', 222, struct opal_key)
108#define IOC_OPAL_ACTIVATE_LSP _IOW('p', 223, struct opal_key)
109#define IOC_OPAL_SET_PW _IOW('p', 224, struct opal_new_pw)
110#define IOC_OPAL_ACTIVATE_USR _IOW('p', 225, struct opal_session_info)
111#define IOC_OPAL_REVERT_TPR _IOW('p', 226, struct opal_key)
112#define IOC_OPAL_LR_SETUP _IOW('p', 227, struct opal_user_lr_setup)
113#define IOC_OPAL_ADD_USR_TO_LR _IOW('p', 228, struct opal_lock_unlock)
114#define IOC_OPAL_ENABLE_DISABLE_MBR _IOW('p', 229, struct opal_mbr_data)
115#define IOC_OPAL_ERASE_LR _IOW('p', 230, struct opal_session_info)
116#define IOC_OPAL_SECURE_ERASE_LR _IOW('p', 231, struct opal_session_info)
117
118#endif /* _UAPI_SED_OPAL_H */