xref: /linux/include/uapi/fwctl/fwctl.h (revision fb39e9092be5a18eaab05b5a2492741fe6e395fe)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /* Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES.
3  */
4 #ifndef _UAPI_FWCTL_H
5 #define _UAPI_FWCTL_H
6 
7 #include <linux/types.h>
8 #include <linux/ioctl.h>
9 
10 #define FWCTL_TYPE 0x9A
11 
12 /**
13  * DOC: General ioctl format
14  *
15  * The ioctl interface follows a general format to allow for extensibility. Each
16  * ioctl is passed a structure pointer as the argument providing the size of
17  * the structure in the first u32. The kernel checks that any structure space
18  * beyond what it understands is 0. This allows userspace to use the backward
19  * compatible portion while consistently using the newer, larger, structures.
20  *
21  * ioctls use a standard meaning for common errnos:
22  *
23  *  - ENOTTY: The IOCTL number itself is not supported at all
24  *  - E2BIG: The IOCTL number is supported, but the provided structure has
25  *    non-zero in a part the kernel does not understand.
26  *  - EOPNOTSUPP: The IOCTL number is supported, and the structure is
27  *    understood, however a known field has a value the kernel does not
28  *    understand or support.
29  *  - EINVAL: Everything about the IOCTL was understood, but a field is not
30  *    correct.
31  *  - ENOMEM: Out of memory.
32  *  - ENODEV: The underlying device has been hot-unplugged and the FD is
33  *            orphaned.
34  *
35  * As well as additional errnos, within specific ioctls.
36  */
37 enum {
38 	FWCTL_CMD_BASE = 0,
39 	FWCTL_CMD_INFO = 0,
40 };
41 
42 enum fwctl_device_type {
43 	FWCTL_DEVICE_TYPE_ERROR = 0,
44 };
45 
46 /**
47  * struct fwctl_info - ioctl(FWCTL_INFO)
48  * @size: sizeof(struct fwctl_info)
49  * @flags: Must be 0
50  * @out_device_type: Returns the type of the device from enum fwctl_device_type
51  * @device_data_len: On input the length of the out_device_data memory. On
52  *	output the size of the kernel's device_data which may be larger or
53  *	smaller than the input. Maybe 0 on input.
54  * @out_device_data: Pointer to a memory of device_data_len bytes. Kernel will
55  *	fill the entire memory, zeroing as required.
56  *
57  * Returns basic information about this fwctl instance, particularly what driver
58  * is being used to define the device_data format.
59  */
60 struct fwctl_info {
61 	__u32 size;
62 	__u32 flags;
63 	__u32 out_device_type;
64 	__u32 device_data_len;
65 	__aligned_u64 out_device_data;
66 };
67 #define FWCTL_INFO _IO(FWCTL_TYPE, FWCTL_CMD_INFO)
68 
69 #endif
70