blob: 3e76b6d7d97f60e0d8a666e930093959fbc451c3 [file] [log] [blame]
Christoph Hellwig8c165672019-04-30 14:42:39 -04001/* SPDX-License-Identifier: GPL-2.0 */
Scott Bauer455a7b22017-02-03 12:50:31 -07002/*
3 * Copyright © 2016 Intel Corporation
4 *
5 * Authors:
6 * Rafael Antognolli <rafael.antognolli@intel.com>
7 * Scott Bauer <scott.bauer@intel.com>
Scott Bauer455a7b22017-02-03 12:50:31 -07008 */
9
10#ifndef LINUX_OPAL_H
11#define LINUX_OPAL_H
12
13#include <uapi/linux/sed-opal.h>
14#include <linux/kernel.h>
15
Scott Bauer455a7b22017-02-03 12:50:31 -070016struct opal_dev;
17
Christoph Hellwig4f1244c2017-02-17 13:59:39 +010018typedef int (sec_send_recv)(void *data, u16 spsp, u8 secp, void *buffer,
19 size_t len, bool send);
Scott Bauer455a7b22017-02-03 12:50:31 -070020
21#ifdef CONFIG_BLK_SED_OPAL
Scott Bauer7d6d1572017-02-22 10:15:06 -070022void free_opal_dev(struct opal_dev *dev);
Scott Bauer455a7b22017-02-03 12:50:31 -070023bool opal_unlock_from_suspend(struct opal_dev *dev);
Christoph Hellwig4f1244c2017-02-17 13:59:39 +010024struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv);
Scott Bauere225c202017-02-14 17:29:36 -070025int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *ioctl_ptr);
Scott Bauer455a7b22017-02-03 12:50:31 -070026
27static inline bool is_sed_ioctl(unsigned int cmd)
28{
29 switch (cmd) {
30 case IOC_OPAL_SAVE:
31 case IOC_OPAL_LOCK_UNLOCK:
32 case IOC_OPAL_TAKE_OWNERSHIP:
33 case IOC_OPAL_ACTIVATE_LSP:
34 case IOC_OPAL_SET_PW:
35 case IOC_OPAL_ACTIVATE_USR:
36 case IOC_OPAL_REVERT_TPR:
37 case IOC_OPAL_LR_SETUP:
38 case IOC_OPAL_ADD_USR_TO_LR:
39 case IOC_OPAL_ENABLE_DISABLE_MBR:
40 case IOC_OPAL_ERASE_LR:
41 case IOC_OPAL_SECURE_ERASE_LR:
42 return true;
43 }
44 return false;
45}
46#else
Scott Bauer7d6d1572017-02-22 10:15:06 -070047static inline void free_opal_dev(struct opal_dev *dev)
48{
49}
50
Scott Bauer455a7b22017-02-03 12:50:31 -070051static inline bool is_sed_ioctl(unsigned int cmd)
52{
53 return false;
54}
55
56static inline int sed_ioctl(struct opal_dev *dev, unsigned int cmd,
Scott Bauere225c202017-02-14 17:29:36 -070057 void __user *ioctl_ptr)
Scott Bauer455a7b22017-02-03 12:50:31 -070058{
59 return 0;
60}
61static inline bool opal_unlock_from_suspend(struct opal_dev *dev)
62{
63 return false;
64}
Christoph Hellwig4f1244c2017-02-17 13:59:39 +010065#define init_opal_dev(data, send_recv) NULL
Scott Bauer455a7b22017-02-03 12:50:31 -070066#endif /* CONFIG_BLK_SED_OPAL */
67#endif /* LINUX_OPAL_H */