1 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
3 * Userspace interface for AMD Dynamic Boost Control (DBC)
5 * Copyright (C) 2023 Advanced Micro Devices, Inc.
7 * Author: Mario Limonciello <mario.limonciello@amd.com>
10 #ifndef __PSP_DBC_USER_H__
11 #define __PSP_DBC_USER_H__
13 #include <linux/types.h>
16 * DOC: AMD Dynamic Boost Control (DBC) interface
19 #define DBC_NONCE_SIZE 16
20 #define DBC_SIG_SIZE 32
21 #define DBC_UID_SIZE 16
24 * struct dbc_user_nonce - Nonce exchange structure (input/output).
25 * @auth_needed: Whether the PSP should authenticate this request (input).
26 * 0: no authentication, PSP will return single use nonce.
27 * 1: authentication: PSP will return multi-use nonce.
28 * @nonce: 8 byte value used for future authentication (output).
29 * @signature: Optional 32 byte signature created by software using a
30 * previous nonce (input).
32 struct dbc_user_nonce {
34 __u8 nonce[DBC_NONCE_SIZE];
35 __u8 signature[DBC_SIG_SIZE];
39 * struct dbc_user_setuid - UID exchange structure (input).
40 * @uid: 16 byte value representing software identity
41 * @signature: 32 byte signature created by software using a previous nonce
43 struct dbc_user_setuid {
44 __u8 uid[DBC_UID_SIZE];
45 __u8 signature[DBC_SIG_SIZE];
49 * Dynamic Boost Control (DBC) IOC
51 * possible return codes for all DBC IOCTLs:
53 * -EINVAL: invalid input
54 * -E2BIG: excess data passed
55 * -EFAULT: failed to copy to/from userspace
56 * -EBUSY: mailbox in recovery or in use
57 * -ENODEV: driver not bound with PSP device
58 * -EACCES: request isn't authorized
59 * -EINVAL: invalid parameter
60 * -ETIMEDOUT: request timed out
61 * -EAGAIN: invalid request for state machine
62 * -ENOENT: not implemented
64 * -EPERM: invalid signature
67 #define DBC_IOC_TYPE 'D'
70 * DBCIOCNONCE - Fetch a nonce from the PSP for authenticating commands.
71 * If a nonce is fetched without authentication it can only
72 * be utilized for one command.
73 * If a nonce is fetched with authentication it can be used
74 * for multiple requests.
76 #define DBCIOCNONCE _IOWR(DBC_IOC_TYPE, 0x1, struct dbc_user_nonce)
79 * DBCIOCUID - Set the user ID (UID) of a calling process.
80 * The user ID is 8 bytes long. It must be programmed using a
81 * 32 byte signature built using the nonce fetched from
83 * The UID can only be set once until the system is rebooted.
85 #define DBCIOCUID _IOW(DBC_IOC_TYPE, 0x2, struct dbc_user_setuid)
87 #endif /* __PSP_DBC_USER_H__ */