/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */1/* Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES.2*/3#ifndef _UAPI_FWCTL_H4#define _UAPI_FWCTL_H56#include <linux/types.h>7#include <linux/ioctl.h>89#define FWCTL_TYPE 0x9A1011/**12* DOC: General ioctl format13*14* The ioctl interface follows a general format to allow for extensibility. Each15* ioctl is passed a structure pointer as the argument providing the size of16* the structure in the first u32. The kernel checks that any structure space17* beyond what it understands is 0. This allows userspace to use the backward18* compatible portion while consistently using the newer, larger, structures.19*20* ioctls use a standard meaning for common errnos:21*22* - ENOTTY: The IOCTL number itself is not supported at all23* - E2BIG: The IOCTL number is supported, but the provided structure has24* non-zero in a part the kernel does not understand.25* - EOPNOTSUPP: The IOCTL number is supported, and the structure is26* understood, however a known field has a value the kernel does not27* understand or support.28* - EINVAL: Everything about the IOCTL was understood, but a field is not29* correct.30* - ENOMEM: Out of memory.31* - ENODEV: The underlying device has been hot-unplugged and the FD is32* orphaned.33*34* As well as additional errnos, within specific ioctls.35*/36enum {37FWCTL_CMD_BASE = 0,38FWCTL_CMD_INFO = 0,39FWCTL_CMD_RPC = 1,40};4142enum fwctl_device_type {43FWCTL_DEVICE_TYPE_ERROR = 0,44FWCTL_DEVICE_TYPE_MLX5 = 1,45FWCTL_DEVICE_TYPE_CXL = 2,46FWCTL_DEVICE_TYPE_PDS = 4,47};4849/**50* struct fwctl_info - ioctl(FWCTL_INFO)51* @size: sizeof(struct fwctl_info)52* @flags: Must be 053* @out_device_type: Returns the type of the device from enum fwctl_device_type54* @device_data_len: On input the length of the out_device_data memory. On55* output the size of the kernel's device_data which may be larger or56* smaller than the input. Maybe 0 on input.57* @out_device_data: Pointer to a memory of device_data_len bytes. Kernel will58* fill the entire memory, zeroing as required.59*60* Returns basic information about this fwctl instance, particularly what driver61* is being used to define the device_data format.62*/63struct fwctl_info {64__u32 size;65__u32 flags;66__u32 out_device_type;67__u32 device_data_len;68__aligned_u64 out_device_data;69};70#define FWCTL_INFO _IO(FWCTL_TYPE, FWCTL_CMD_INFO)7172/**73* enum fwctl_rpc_scope - Scope of access for the RPC74*75* Refer to fwctl.rst for a more detailed discussion of these scopes.76*/77enum fwctl_rpc_scope {78/**79* @FWCTL_RPC_CONFIGURATION: Device configuration access scope80*81* Read/write access to device configuration. When configuration82* is written to the device it remains in a fully supported state.83*/84FWCTL_RPC_CONFIGURATION = 0,85/**86* @FWCTL_RPC_DEBUG_READ_ONLY: Read only access to debug information87*88* Readable debug information. Debug information is compatible with89* kernel lockdown, and does not disclose any sensitive information. For90* instance exposing any encryption secrets from this information is91* forbidden.92*/93FWCTL_RPC_DEBUG_READ_ONLY = 1,94/**95* @FWCTL_RPC_DEBUG_WRITE: Writable access to lockdown compatible debug information96*97* Allows write access to data in the device which may leave a fully98* supported state. This is intended to permit intensive and possibly99* invasive debugging. This scope will taint the kernel.100*/101FWCTL_RPC_DEBUG_WRITE = 2,102/**103* @FWCTL_RPC_DEBUG_WRITE_FULL: Write access to all debug information104*105* Allows read/write access to everything. Requires CAP_SYS_RAW_IO, so106* it is not required to follow lockdown principals. If in doubt107* debugging should be placed in this scope. This scope will taint the108* kernel.109*/110FWCTL_RPC_DEBUG_WRITE_FULL = 3,111};112113/**114* struct fwctl_rpc - ioctl(FWCTL_RPC)115* @size: sizeof(struct fwctl_rpc)116* @scope: One of enum fwctl_rpc_scope, required scope for the RPC117* @in_len: Length of the in memory118* @out_len: Length of the out memory119* @in: Request message in device specific format120* @out: Response message in device specific format121*122* Deliver a Remote Procedure Call to the device FW and return the response. The123* call's parameters and return are marshaled into linear buffers of memory. Any124* errno indicates that delivery of the RPC to the device failed. Return status125* originating in the device during a successful delivery must be encoded into126* out.127*128* The format of the buffers matches the out_device_type from FWCTL_INFO.129*/130struct fwctl_rpc {131__u32 size;132__u32 scope;133__u32 in_len;134__u32 out_len;135__aligned_u64 in;136__aligned_u64 out;137};138#define FWCTL_RPC _IO(FWCTL_TYPE, FWCTL_CMD_RPC)139140#endif141142143